2000-10-26 13:46:14 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: unodatbr.cxx,v $
|
|
|
|
*
|
2001-05-08 15:12:51 +00:00
|
|
|
* $Revision: 1.63 $
|
2000-10-26 13:46:14 +00:00
|
|
|
*
|
2001-05-08 15:12:51 +00:00
|
|
|
* last change: $Author: fs $ $Date: 2001-05-08 16:12:51 $
|
2000-10-26 13:46:14 +00:00
|
|
|
*
|
|
|
|
* 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
|
2000-11-09 06:34:47 +00:00
|
|
|
#ifndef _SVTREEBOX_HXX
|
|
|
|
#include <svtools/svtreebx.hxx>
|
|
|
|
#endif
|
2001-04-11 11:43:39 +00:00
|
|
|
#ifndef _SVX_DATACCESSDESCRIPTOR_HXX_
|
|
|
|
#include <svx/dataaccessdescriptor.hxx>
|
|
|
|
#endif
|
2001-01-09 14:52:33 +00:00
|
|
|
|
2000-12-10 15:12:18 +00:00
|
|
|
#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
|
2001-01-09 14:52:33 +00:00
|
|
|
#include <toolkit/unohlp.hxx>
|
2000-12-10 15:12:18 +00:00
|
|
|
#endif
|
2000-10-26 13:46:14 +00:00
|
|
|
#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
|
2001-01-09 14:52:33 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
|
|
|
|
#endif
|
2001-03-02 16:07:28 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
|
|
|
|
#endif
|
2000-10-26 13:46:14 +00:00
|
|
|
#ifndef _URLOBJ_HXX //autogen
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SFXINTITEM_HXX //autogen
|
|
|
|
#include <svtools/intitem.hxx>
|
|
|
|
#endif
|
2001-01-09 14:52:33 +00:00
|
|
|
#ifndef _SV_WAITOBJ_HXX
|
|
|
|
#include <vcl/waitobj.hxx>
|
|
|
|
#endif
|
2000-10-26 13:46:14 +00:00
|
|
|
#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_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
|
2001-04-26 10:36:16 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_XBOOKMARKSSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdb/XBookmarksSupplier.hpp>
|
|
|
|
#endif
|
2000-11-09 06:34:47 +00:00
|
|
|
#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
|
2001-02-14 13:37:35 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XDrop.hpp>
|
|
|
|
#endif
|
2000-11-09 06:34:47 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_
|
|
|
|
#include <com/sun/star/sdb/XCompletedConnection.hpp>
|
|
|
|
#endif
|
2000-10-26 13:46:14 +00:00
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
|
|
|
|
#include <com/sun/star/container/XNameContainer.hpp>
|
|
|
|
#endif
|
2000-11-07 17:37:34 +00:00
|
|
|
#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
|
|
|
|
#include <com/sun/star/frame/FrameSearchFlag.hpp>
|
|
|
|
#endif
|
2000-11-09 06:34:47 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XDataSource.hpp>
|
|
|
|
#endif
|
2001-02-23 14:17:34 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
|
|
|
|
#endif
|
2000-11-09 06:34:47 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UI_XEXECUTABLEDIALOG_HPP_
|
|
|
|
#include <com/sun/star/ui/XExecutableDialog.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
|
|
|
#endif
|
2001-03-23 09:57:10 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
|
|
|
|
#endif
|
2000-10-26 13:46:14 +00:00
|
|
|
#ifndef _SVX_ALGITEM_HXX //autogen
|
|
|
|
#include <svx/algitem.hxx>
|
|
|
|
#endif
|
2000-11-07 17:37:34 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDB_XRESULTSETACCESS_HPP_
|
|
|
|
#include <com/sun/star/sdb/XResultSetAccess.hpp>
|
|
|
|
#endif
|
2001-01-09 14:52:33 +00:00
|
|
|
#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/lang/DisposedException.hpp>
|
|
|
|
#endif
|
2000-11-09 13:42:09 +00:00
|
|
|
#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_
|
|
|
|
#include <com/sun/star/sdbc/SQLWarning.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
|
|
|
|
#include <com/sun/star/sdb/SQLContext.hpp>
|
|
|
|
#endif
|
2000-10-26 13:46:14 +00:00
|
|
|
#ifndef _COMPHELPER_TYPES_HXX_
|
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
#endif
|
2000-11-09 06:34:47 +00:00
|
|
|
#ifndef DBAUI_DBTREEMODEL_HXX
|
2000-10-26 13:46:14 +00:00
|
|
|
#include "dbtreemodel.hxx"
|
2000-11-09 06:34:47 +00:00
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_UI_DBTREEVIEW_HXX
|
2000-10-26 13:46:14 +00:00
|
|
|
#include "dbtreeview.hxx"
|
2000-11-09 06:34:47 +00:00
|
|
|
#endif
|
2000-10-26 13:46:14 +00:00
|
|
|
#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
|
2000-12-15 14:54:12 +00:00
|
|
|
#ifndef _DBU_REGHELPER_HXX_
|
|
|
|
#include "dbu_reghelper.hxx"
|
2000-10-26 13:46:14 +00:00
|
|
|
#endif
|
2001-03-15 07:29:16 +00:00
|
|
|
#ifndef _COMPHELPER_EXTRACT_HXX_
|
|
|
|
#include <comphelper/extract.hxx>
|
2001-01-09 14:52:33 +00:00
|
|
|
#endif
|
2000-11-09 06:34:47 +00:00
|
|
|
#ifndef _DBHELPER_DBEXCEPTION_HXX_
|
|
|
|
#include <connectivity/dbexception.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _VCL_STDTEXT_HXX
|
|
|
|
#include <vcl/stdtext.hxx>
|
|
|
|
#endif
|
2000-11-23 09:46:21 +00:00
|
|
|
#ifndef DBAUI_DBTREELISTBOX_HXX
|
|
|
|
#include "dbtreelistbox.hxx"
|
|
|
|
#endif
|
2001-01-26 13:16:30 +00:00
|
|
|
#ifndef _DBA_DBACCESS_HELPID_HRC_
|
2000-11-30 15:55:19 +00:00
|
|
|
#include "dbaccess_helpid.hrc"
|
2001-01-26 13:16:30 +00:00
|
|
|
#endif
|
2001-01-09 14:52:33 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_
|
|
|
|
#include <com/sun/star/util/XFlushable.hpp>
|
2000-12-08 20:16:38 +00:00
|
|
|
#endif
|
2001-01-26 13:16:30 +00:00
|
|
|
#ifndef _DBAUI_QUERYDESIGNACCESS_HXX_
|
|
|
|
#include "querydesignaccess.hxx"
|
|
|
|
#endif
|
2001-01-30 07:32:01 +00:00
|
|
|
#ifndef _DBAUI_LISTVIEWITEMS_HXX_
|
|
|
|
#include "listviewitems.hxx"
|
|
|
|
#endif
|
2001-02-16 15:00:13 +00:00
|
|
|
#ifndef _CPPUHELPER_IMPLBASE2_HXX_
|
|
|
|
#include <cppuhelper/implbase2.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_TOKENWRITER_HXX
|
|
|
|
#include "TokenWriter.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_DBEXCHANGE_HXX
|
|
|
|
#include "dbexchange.hxx"
|
|
|
|
#endif
|
2001-02-23 14:17:34 +00:00
|
|
|
#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
|
|
|
|
#include "WCopyTable.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_WIZ_EXTENDPAGES_HXX
|
|
|
|
#include "WExtendPages.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_WIZ_NAMEMATCHING_HXX
|
|
|
|
#include "WNameMatch.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_WIZ_COLUMNSELECT_HXX
|
|
|
|
#include "WColumnSelect.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_ENUMTYPES_HXX
|
|
|
|
#include "QEnumTypes.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_WIZARD_CPAGE_HXX
|
|
|
|
#include "WCPage.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_TOOLS_HXX
|
|
|
|
#include "UITools.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_RTFREADER_HXX
|
|
|
|
#include "RtfReader.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_HTMLREADER_HXX
|
|
|
|
#include "HtmlReader.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBAUI_SQLMESSAGE_HXX_
|
|
|
|
#include "sqlmessage.hxx"
|
|
|
|
#endif
|
2001-03-23 09:57:10 +00:00
|
|
|
#ifndef DBAUI_DLGSAVE_HXX
|
|
|
|
#include "dlgsave.hxx"
|
|
|
|
#endif
|
2001-03-22 09:40:10 +00:00
|
|
|
#ifndef _SOT_STORAGE_HXX
|
2001-02-28 09:01:54 +00:00
|
|
|
#include <sot/storage.hxx>
|
2001-03-22 09:40:10 +00:00
|
|
|
#endif
|
2001-04-26 10:36:16 +00:00
|
|
|
#ifndef _DBAUI_LINKEDDOCUMENTS_HXX_
|
|
|
|
#include "linkeddocuments.hxx"
|
|
|
|
#endif
|
2001-02-28 09:01:54 +00:00
|
|
|
|
2000-10-26 13:46:14 +00:00
|
|
|
|
|
|
|
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;
|
2000-11-07 17:37:34 +00:00
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
using namespace ::com::sun::star::frame;
|
2000-10-26 13:46:14 +00:00
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::lang;
|
2000-11-09 06:34:47 +00:00
|
|
|
using namespace ::com::sun::star::ui;
|
|
|
|
using namespace ::com::sun::star::task;
|
2001-01-09 14:52:33 +00:00
|
|
|
using namespace ::com::sun::star::form;
|
|
|
|
using namespace ::com::sun::star::io;
|
2001-03-16 15:24:32 +00:00
|
|
|
using namespace ::com::sun::star::i18n;
|
2001-03-23 09:57:10 +00:00
|
|
|
using namespace ::com::sun::star::datatransfer;
|
2000-11-09 06:34:47 +00:00
|
|
|
using namespace ::dbtools;
|
2001-04-11 11:43:39 +00:00
|
|
|
using namespace ::svx;
|
2000-11-09 06:34:47 +00:00
|
|
|
|
|
|
|
// .........................................................................
|
|
|
|
namespace dbaui
|
|
|
|
{
|
|
|
|
// .........................................................................
|
2001-03-22 09:40:10 +00:00
|
|
|
|
2000-10-26 13:46:14 +00:00
|
|
|
//==================================================================
|
|
|
|
//= 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)
|
|
|
|
{
|
2001-01-05 11:08:57 +00:00
|
|
|
return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.ODatasourceBrowser");
|
2000-10-26 13:46:14 +00:00
|
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
::comphelper::StringSequence SbaTableQueryBrowser::getSupportedServiceNames_Static() throw(RuntimeException)
|
|
|
|
{
|
|
|
|
::comphelper::StringSequence aSupported(1);
|
2000-11-08 08:27:29 +00:00
|
|
|
aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.DataSourceBrowser");
|
2000-10-26 13:46:14 +00:00
|
|
|
return aSupported;
|
|
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
Reference< XInterface > SAL_CALL SbaTableQueryBrowser::Create(const Reference<XMultiServiceFactory >& _rxFactory)
|
|
|
|
{
|
2001-01-24 10:46:47 +00:00
|
|
|
::vos::OGuard aGuard(Application::GetSolarMutex());
|
2000-10-26 13:46:14 +00:00
|
|
|
return *(new SbaTableQueryBrowser(_rxFactory));
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
SbaTableQueryBrowser::SbaTableQueryBrowser(const Reference< XMultiServiceFactory >& _rM)
|
|
|
|
:SbaXDataBrowserController(_rM)
|
|
|
|
,m_pTreeModel(NULL)
|
|
|
|
,m_pTreeView(NULL)
|
|
|
|
,m_pSplitter(NULL)
|
2001-01-09 14:52:33 +00:00
|
|
|
,m_pCurrentlyDisplayed(NULL)
|
2001-03-23 09:57:10 +00:00
|
|
|
,m_nAsyncDrop(0)
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
|
|
|
// 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()
|
|
|
|
{
|
2000-11-06 16:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2001-03-01 14:17:55 +00:00
|
|
|
void SAL_CALL SbaTableQueryBrowser::disposing()
|
2000-11-06 16:40:34 +00:00
|
|
|
{
|
2001-01-24 10:49:21 +00:00
|
|
|
::vos::OGuard aGuard(Application::GetSolarMutex());
|
|
|
|
// doin' a lot of VCL stuff here -> lock the SolarMutex
|
|
|
|
|
2000-11-06 16:40:34 +00:00
|
|
|
// reset the content's tree view: it holds a reference to our model which is to be deleted immediately,
|
|
|
|
// and it will live longer than we do.
|
2001-01-09 14:52:33 +00:00
|
|
|
if (getBrowserView())
|
|
|
|
getBrowserView()->setTreeView(NULL);
|
2000-11-09 06:34:47 +00:00
|
|
|
|
2001-04-19 15:16:25 +00:00
|
|
|
if (m_pTreeModel)
|
2000-11-09 06:34:47 +00:00
|
|
|
{
|
2001-04-19 15:16:25 +00:00
|
|
|
// clear the user data of the tree model
|
|
|
|
SvLBoxEntry* pEntryLoop = m_pTreeModel->First();
|
|
|
|
while (pEntryLoop)
|
2000-12-07 10:40:07 +00:00
|
|
|
{
|
2001-04-19 15:16:25 +00:00
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pEntryLoop->GetUserData());
|
|
|
|
if(pData)
|
2001-01-09 14:52:33 +00:00
|
|
|
{
|
2001-04-19 15:16:25 +00:00
|
|
|
Reference<XConnection> xCon(pData->xObject,UNO_QUERY);
|
|
|
|
if(xCon.is())
|
2001-01-09 14:52:33 +00:00
|
|
|
{
|
2001-04-19 15:16:25 +00:00
|
|
|
Reference< XComponent > xComponent(xCon, UNO_QUERY);
|
|
|
|
if (xComponent.is())
|
|
|
|
{
|
|
|
|
Reference< ::com::sun::star::lang::XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY);
|
|
|
|
xComponent->removeEventListener(xEvtL);
|
|
|
|
}
|
|
|
|
::comphelper::disposeComponent(pData->xObject);
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
2001-04-19 15:16:25 +00:00
|
|
|
delete pData;
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
2001-04-19 15:16:25 +00:00
|
|
|
pEntryLoop = m_pTreeModel->Next(pEntryLoop);
|
2000-12-07 10:40:07 +00:00
|
|
|
}
|
2000-11-09 06:34:47 +00:00
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
m_pCurrentlyDisplayed = NULL;
|
2000-11-09 06:34:47 +00:00
|
|
|
// clear the tree model
|
2000-10-26 13:46:14 +00:00
|
|
|
delete m_pTreeModel;
|
2000-11-06 16:40:34 +00:00
|
|
|
m_pTreeModel = NULL;
|
2000-11-09 06:34:47 +00:00
|
|
|
|
2001-03-07 07:19:43 +00:00
|
|
|
// remove ourself as status listener
|
|
|
|
implRemoveStatusListeners();
|
|
|
|
|
2000-12-10 15:12:18 +00:00
|
|
|
// remove the container listener from the database context
|
|
|
|
Reference< XContainer > xDatasourceContainer(m_xDatabaseContext, UNO_QUERY);
|
|
|
|
if (xDatasourceContainer.is())
|
|
|
|
xDatasourceContainer->removeContainerListener(this);
|
|
|
|
|
2001-03-01 14:17:55 +00:00
|
|
|
SbaXDataBrowserController::disposing();
|
2000-10-26 13:46:14 +00:00
|
|
|
}
|
2000-11-06 16:40:34 +00:00
|
|
|
|
2000-10-26 13:46:14 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
sal_Bool SbaTableQueryBrowser::Construct(Window* pParent)
|
|
|
|
{
|
|
|
|
if (!SbaXDataBrowserController::Construct(pParent))
|
|
|
|
return sal_False;
|
|
|
|
|
2000-12-10 15:12:18 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XContainer > xDatasourceContainer(m_xDatabaseContext, UNO_QUERY);
|
|
|
|
if (xDatasourceContainer.is())
|
|
|
|
xDatasourceContainer->addContainerListener(this);
|
|
|
|
else
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::Construct: the DatabaseContext should allow us to be a listener!");
|
2001-03-16 15:24:32 +00:00
|
|
|
|
|
|
|
// the collator for the string compares
|
|
|
|
m_xCollator = Reference< XCollator >(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.i18n.Collator")), UNO_QUERY);
|
|
|
|
if (m_xCollator.is())
|
|
|
|
m_xCollator->loadDefaultCollator(Application::GetSettings().GetLocale(), 0);
|
2000-12-10 15:12:18 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::Construct: could not create (or start listening at) the database context!");
|
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
// some help ids
|
2001-01-09 14:52:33 +00:00
|
|
|
if (getBrowserView() && getBrowserView()->getVclControl())
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
// create controls and set sizes
|
2001-01-09 14:52:33 +00:00
|
|
|
const long nFrameWidth = getBrowserView()->LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width();
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
m_pSplitter = new Splitter(getBrowserView(),WB_HSCROLL);
|
2000-10-26 13:46:14 +00:00
|
|
|
m_pSplitter->SetPosSizePixel( Point(0,0), Size(nFrameWidth,0) );
|
|
|
|
m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
|
|
|
|
m_pSplitter->Show();
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
m_pTreeView = new DBTreeView(getBrowserView(),m_xMultiServiceFacatory, WB_TABSTOP);
|
2000-10-26 13:46:14 +00:00
|
|
|
m_pTreeView->Show();
|
2000-11-09 06:34:47 +00:00
|
|
|
m_pTreeView->SetPreExpandHandler(LINK(this, SbaTableQueryBrowser, OnExpandEntry));
|
2001-03-22 09:40:10 +00:00
|
|
|
m_pTreeView->getListBox()->setControlActionListener(this);
|
2000-11-30 15:55:19 +00:00
|
|
|
m_pTreeView->SetHelpId(HID_CTL_TREEVIEW);
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2000-11-06 16:40:34 +00:00
|
|
|
// a default pos for the splitter, so that the listbox is about 80 (logical) pixels wide
|
2001-01-09 14:52:33 +00:00
|
|
|
m_pSplitter->SetSplitPosPixel( getBrowserView()->LogicToPixel( Size( 80, 0 ), MAP_APPFONT ).Width() );
|
2000-11-06 16:40:34 +00:00
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
getBrowserView()->setSplitter(m_pSplitter);
|
|
|
|
getBrowserView()->setTreeView(m_pTreeView);
|
2000-10-26 13:46:14 +00:00
|
|
|
|
|
|
|
// fill view with data
|
2000-11-09 06:34:47 +00:00
|
|
|
m_pTreeModel = new DBTreeListModel;
|
2001-03-16 15:24:32 +00:00
|
|
|
m_pTreeModel->SetSortMode(SortAscending);
|
|
|
|
m_pTreeModel->SetCompareHdl(LINK(this, SbaTableQueryBrowser, OnTreeEntryCompare));
|
2000-10-26 13:46:14 +00:00
|
|
|
m_pTreeView->setModel(m_pTreeModel);
|
|
|
|
m_pTreeView->setSelectHdl(LINK(this, SbaTableQueryBrowser, OnSelectEntry));
|
2001-04-26 10:36:16 +00:00
|
|
|
m_pTreeView->getListBox()->SetDoubleClickHdl(LINK(this, SbaTableQueryBrowser, OnEntryDoubleClicked));
|
2000-11-09 06:34:47 +00:00
|
|
|
initializeTreeModel();
|
2000-10-26 13:46:14 +00:00
|
|
|
|
|
|
|
// TODO
|
2001-01-09 14:52:33 +00:00
|
|
|
getBrowserView()->getVclControl()->GetDataWindow().SetUniqueId(UID_DATABROWSE_DATAWINDOW);
|
|
|
|
getBrowserView()->getVclControl()->SetHelpId(HID_CTL_TABBROWSER);
|
|
|
|
getBrowserView()->SetUniqueId(UID_CTL_CONTENT);
|
|
|
|
if (getBrowserView()->getVclControl()->GetHeaderBar())
|
|
|
|
getBrowserView()->getVclControl()->GetHeaderBar()->SetHelpId(HID_DATABROWSE_HEADER);
|
2000-12-08 20:16:38 +00:00
|
|
|
InvalidateFeature(ID_BROWSER_EXPLORER);
|
2000-10-26 13:46:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SbaTableQueryBrowser::InitializeForm(const Reference< ::com::sun::star::sdbc::XRowSet > & _rxForm)
|
|
|
|
{
|
2001-01-09 14:52:33 +00:00
|
|
|
if(!m_pCurrentlyDisplayed)
|
|
|
|
return sal_True;
|
|
|
|
// this method set all format settings from the orignal table or query
|
2000-10-26 13:46:14 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// we send all properties at once, maybe the implementation is clever enough to handle one big PropertiesChanged
|
|
|
|
// more effective than many small PropertyChanged ;)
|
2001-01-09 14:52:33 +00:00
|
|
|
Sequence< ::rtl::OUString> aProperties(3);
|
|
|
|
Sequence< Any> aValues(3);
|
|
|
|
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
|
|
|
OSL_ENSURE(pData,"No user data set at the currently displayed entry!");
|
|
|
|
Reference<XPropertySet> xTableProp(pData->xObject,UNO_QUERY);
|
|
|
|
OSL_ENSURE(xTableProp.is(),"No table available!");
|
2000-10-26 13:46:14 +00:00
|
|
|
|
|
|
|
// is the filter intially applied ?
|
2001-01-09 14:52:33 +00:00
|
|
|
aProperties.getArray()[0] = PROPERTY_APPLYFILTER;
|
|
|
|
aValues.getArray()[0] = xTableProp->getPropertyValue(PROPERTY_APPLYFILTER);
|
|
|
|
|
|
|
|
// the initial filter
|
|
|
|
aProperties.getArray()[1] = PROPERTY_FILTER;
|
|
|
|
aValues.getArray()[1] = xTableProp->getPropertyValue(PROPERTY_FILTER);
|
|
|
|
|
|
|
|
// the initial ordering
|
|
|
|
aProperties.getArray()[2] = PROPERTY_ORDER;
|
|
|
|
aValues.getArray()[2] = xTableProp->getPropertyValue(PROPERTY_ORDER);
|
|
|
|
|
|
|
|
Reference< XMultiPropertySet > xFormMultiSet(_rxForm, UNO_QUERY);
|
|
|
|
xFormMultiSet->setPropertyValues(aProperties, aValues);
|
2000-10-26 13:46:14 +00:00
|
|
|
}
|
2000-11-06 16:40:34 +00:00
|
|
|
catch(Exception&)
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
2000-11-23 11:27:21 +00:00
|
|
|
Reference< ::com::sun::star::form::XGridColumnFactory > xColFactory(xGrid, UNO_QUERY);
|
|
|
|
Reference< XNameContainer > xColContainer(xGrid, UNO_QUERY);
|
|
|
|
// first we have to clear the grid
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
2000-11-23 11:27:21 +00:00
|
|
|
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);
|
2000-10-26 13:46:14 +00:00
|
|
|
}
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
// set the formats from the table
|
|
|
|
if(m_pCurrentlyDisplayed)
|
|
|
|
{
|
|
|
|
Sequence< ::rtl::OUString> aProperties(3);
|
|
|
|
Sequence< Any> aValues(3);
|
|
|
|
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
|
|
|
Reference<XPropertySet> xTableProp(pData->xObject,UNO_QUERY);
|
2001-02-23 14:17:34 +00:00
|
|
|
OSL_ENSURE(xTableProp.is(),"No table available!");
|
2001-01-09 14:52:33 +00:00
|
|
|
|
|
|
|
aProperties.getArray()[0] = PROPERTY_FONT;
|
|
|
|
aValues.getArray()[0] = xTableProp->getPropertyValue(PROPERTY_FONT);
|
|
|
|
aProperties.getArray()[1] = PROPERTY_ROW_HEIGHT;
|
|
|
|
aValues.getArray()[1] = xTableProp->getPropertyValue(PROPERTY_ROW_HEIGHT);
|
|
|
|
aProperties.getArray()[2] = PROPERTY_TEXTCOLOR;
|
|
|
|
aValues.getArray()[2] = xTableProp->getPropertyValue(PROPERTY_TEXTCOLOR);
|
|
|
|
|
|
|
|
Reference< XMultiPropertySet > xFormMultiSet(xGrid, UNO_QUERY);
|
|
|
|
xFormMultiSet->setPropertyValues(aProperties, aValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-23 11:27:21 +00:00
|
|
|
// get the formats supplier of the database we're working with
|
|
|
|
Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = getNumberFormatter()->getNumberFormatsSupplier();
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2000-11-23 11:27:21 +00:00
|
|
|
Reference<XConnection> xConnection;
|
|
|
|
Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY);
|
2001-02-14 13:37:35 +00:00
|
|
|
::cppu::extractInterface(xConnection,xProp->getPropertyValue(PROPERTY_ACTIVECONNECTION));
|
2001-04-02 11:21:49 +00:00
|
|
|
OSL_ENSURE(xConnection.is(),"A ActiveConnection should normaly exists!");
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2000-11-23 11:27:21 +00:00
|
|
|
Reference<XChild> xChild(xConnection,UNO_QUERY);
|
|
|
|
Reference<XPropertySet> xDataSourceProp(xChild->getParent(),UNO_QUERY);
|
|
|
|
sal_Bool bSupress = ::cppu::any2bool(xDataSourceProp->getPropertyValue(PROPERTY_SUPPRESSVERSIONCL));
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2000-11-23 11:27:21 +00:00
|
|
|
// 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();
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2000-11-23 11:27:21 +00:00
|
|
|
Reference<XPropertySet> xColumn;
|
|
|
|
for (sal_uInt16 i=0; pBegin != pEnd; ++i,++pBegin)
|
|
|
|
{
|
|
|
|
// Typ
|
|
|
|
// first get type to determine wich control we need
|
2001-02-14 13:37:35 +00:00
|
|
|
::cppu::extractInterface(xColumn,xColumns->getByName(*pBegin));
|
2000-11-23 11:27:21 +00:00
|
|
|
|
|
|
|
// ignore the column when it is a rowversion one
|
|
|
|
if(bSupress && xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISROWVERSION)
|
|
|
|
&& ::cppu::any2bool(xColumn->getPropertyValue(PROPERTY_ISROWVERSION)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
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
|
2001-03-22 06:59:18 +00:00
|
|
|
xCurrentCol->setPropertyValue(PROPERTY_ALIGN, makeAny(sal_Int16(::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_ALIGN)))));
|
2000-11-23 11:27:21 +00:00
|
|
|
|
|
|
|
// ... 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));
|
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
}
|
2000-11-07 17:37:34 +00:00
|
|
|
catch(Exception&)
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return pTB;
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference<XPropertySet> getColumnHelper(SvLBoxEntry* _pCurrentlyDisplayed,const Reference<XPropertySet>& _rxSource)
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xRet;
|
|
|
|
if(_pCurrentlyDisplayed)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pCurrentlyDisplayed->GetUserData());
|
|
|
|
Reference<XColumnsSupplier> xColumnsSup(pData->xObject,UNO_QUERY);
|
|
|
|
Reference<XNameAccess> xNames = xColumnsSup->getColumns();
|
|
|
|
::rtl::OUString aName;
|
|
|
|
_rxSource->getPropertyValue(PROPERTY_NAME) >>= aName;
|
|
|
|
if(xNames.is() && xNames->hasByName(aName))
|
2001-02-14 13:37:35 +00:00
|
|
|
::cppu::extractInterface(xRet,xNames->getByName(aName));
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
|
|
|
return xRet;
|
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt)
|
|
|
|
{
|
|
|
|
SbaXDataBrowserController::propertyChange(evt);
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
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 ?
|
|
|
|
else if (evt.PropertyName.equals(PROPERTY_WIDTH))
|
|
|
|
{ // a column width has changed -> update the model
|
|
|
|
// (the update of the view is done elsewhere)
|
|
|
|
Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
|
|
|
|
if(xProp.is())
|
|
|
|
{
|
|
|
|
if(!evt.NewValue.hasValue())
|
|
|
|
xProp->setPropertyValue(PROPERTY_WIDTH,makeAny((sal_Int32)227));
|
|
|
|
else
|
|
|
|
xProp->setPropertyValue(PROPERTY_WIDTH,evt.NewValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// a column's 'visible' state ?
|
|
|
|
else if (evt.PropertyName.equals(PROPERTY_HIDDEN))
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
|
|
|
|
if(xProp.is())
|
|
|
|
xProp->setPropertyValue(PROPERTY_HIDDEN,evt.NewValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
// a columns alignment ?
|
|
|
|
else if (evt.PropertyName.equals(PROPERTY_ALIGN))
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
|
2001-02-14 13:37:35 +00:00
|
|
|
try
|
2001-01-09 14:52:33 +00:00
|
|
|
{
|
2001-02-14 13:37:35 +00:00
|
|
|
if(xProp.is())
|
|
|
|
{
|
2001-04-06 12:40:25 +00:00
|
|
|
if(evt.NewValue.hasValue())
|
|
|
|
{
|
|
|
|
sal_Int16 nAlign = 0;
|
|
|
|
if(evt.NewValue >>= nAlign)
|
|
|
|
xProp->setPropertyValue(PROPERTY_ALIGN,makeAny(sal_Int32(nAlign)));
|
|
|
|
else
|
|
|
|
xProp->setPropertyValue(PROPERTY_ALIGN,evt.NewValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
xProp->setPropertyValue(PROPERTY_ALIGN,makeAny((sal_Int32)0));
|
2001-02-14 13:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
2001-04-03 13:16:03 +00:00
|
|
|
OSL_ENSURE(sal_False, "SbaTableQueryBrowser::propertyChange: caught an exception!");
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// a column's format ?
|
|
|
|
else if ( (evt.PropertyName.equals(PROPERTY_FORMATKEY))
|
|
|
|
&& (TypeClass_LONG == evt.NewValue.getValueTypeClass())
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// update the model (means the definition object)
|
|
|
|
Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
|
|
|
|
if(xProp.is())
|
|
|
|
xProp->setPropertyValue(PROPERTY_FORMATKEY,evt.NewValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
// some table definition properties ?
|
|
|
|
// the height of the rows in the grid ?
|
|
|
|
else if (evt.PropertyName.equals(PROPERTY_ROW_HEIGHT))
|
|
|
|
{
|
|
|
|
if(m_pCurrentlyDisplayed)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
|
|
|
Reference<XPropertySet> xProp(pData->xObject,UNO_QUERY);
|
2001-04-02 11:21:49 +00:00
|
|
|
OSL_ENSURE(xProp.is(),"No table available!");
|
2001-01-09 14:52:33 +00:00
|
|
|
|
|
|
|
sal_Bool bDefault = !evt.NewValue.hasValue();
|
|
|
|
if (bDefault)
|
|
|
|
xProp->setPropertyValue(PROPERTY_ROW_HEIGHT,makeAny((sal_Int32)45));
|
|
|
|
else
|
|
|
|
xProp->setPropertyValue(PROPERTY_ROW_HEIGHT,evt.NewValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// // the font of the grid ?
|
|
|
|
else if (evt.PropertyName.equals(PROPERTY_FONT))
|
|
|
|
{
|
|
|
|
if(m_pCurrentlyDisplayed)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
|
|
|
Reference<XPropertySet> xProp(pData->xObject,UNO_QUERY);
|
2001-04-02 11:21:49 +00:00
|
|
|
OSL_ENSURE(xProp.is(),"No table available!");
|
2001-01-09 14:52:33 +00:00
|
|
|
xProp->setPropertyValue(PROPERTY_FONT,evt.NewValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// // the text color of the grid ?
|
|
|
|
else if (evt.PropertyName.equals(PROPERTY_TEXTCOLOR))
|
|
|
|
{
|
|
|
|
if(m_pCurrentlyDisplayed)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
|
|
|
Reference<XPropertySet> xProp(pData->xObject,UNO_QUERY);
|
2001-04-02 11:21:49 +00:00
|
|
|
OSL_ENSURE(xProp.is(),"No table available!");
|
2001-01-09 14:52:33 +00:00
|
|
|
xProp->setPropertyValue(PROPERTY_TEXTCOLOR,evt.NewValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// // the filter ?
|
|
|
|
else if (evt.PropertyName.equals(PROPERTY_FILTER))
|
|
|
|
{
|
|
|
|
if(m_pCurrentlyDisplayed)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
|
|
|
Reference<XPropertySet> xProp(pData->xObject,UNO_QUERY);
|
2001-04-02 11:21:49 +00:00
|
|
|
OSL_ENSURE(xProp.is(),"No table available!");
|
2001-01-09 14:52:33 +00:00
|
|
|
xProp->setPropertyValue(PROPERTY_FILTER,evt.NewValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// the sort ?
|
|
|
|
else if (evt.PropertyName.equals(PROPERTY_ORDER))
|
|
|
|
{
|
|
|
|
if(m_pCurrentlyDisplayed)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
|
|
|
Reference<XPropertySet> xProp(pData->xObject,UNO_QUERY);
|
2001-04-02 11:21:49 +00:00
|
|
|
OSL_ENSURE(xProp.is(),"No table available!");
|
2001-01-09 14:52:33 +00:00
|
|
|
xProp->setPropertyValue(PROPERTY_ORDER,evt.NewValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// the appliance of the filter ?
|
|
|
|
else if (evt.PropertyName.equals(PROPERTY_APPLYFILTER))
|
|
|
|
{
|
|
|
|
if(m_pCurrentlyDisplayed)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
|
|
|
Reference<XPropertySet> xProp(pData->xObject,UNO_QUERY);
|
2001-04-02 11:21:49 +00:00
|
|
|
OSL_ENSURE(xProp.is(),"No table available!");
|
2001-01-09 14:52:33 +00:00
|
|
|
xProp->setPropertyValue(PROPERTY_APPLYFILTER,evt.NewValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-03-23 09:57:10 +00:00
|
|
|
catch(Exception&)
|
2001-01-09 14:52:33 +00:00
|
|
|
{
|
2001-03-23 09:57:10 +00:00
|
|
|
DBG_ERROR("SbaTableQueryBrowser::propertyChange: caught an exception!");
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
sal_Bool SbaTableQueryBrowser::suspend(sal_Bool bSuspend) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
if (!SbaXDataBrowserController::suspend(bSuspend))
|
|
|
|
return sal_False;
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
if(m_pCurrentlyDisplayed)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
2001-02-23 14:17:34 +00:00
|
|
|
if(pData)
|
2001-01-09 14:52:33 +00:00
|
|
|
{
|
2001-02-23 14:17:34 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference<XFlushable> xFlush(pData->xObject,UNO_QUERY);
|
|
|
|
if(xFlush.is())
|
|
|
|
xFlush->flush();
|
|
|
|
}
|
|
|
|
catch(DisposedException&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Object already disposed!");
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
2000-11-07 17:37:34 +00:00
|
|
|
void SAL_CALL SbaTableQueryBrowser::statusChanged( const FeatureStateEvent& _rEvent ) throw(RuntimeException)
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
2000-11-07 17:37:34 +00:00
|
|
|
// search the external dispatcher causing this call
|
|
|
|
Reference< XDispatch > xSource(_rEvent.Source, UNO_QUERY);
|
|
|
|
for ( SpecialSlotDispatchersIterator aLoop = m_aDispatchers.begin();
|
|
|
|
aLoop != m_aDispatchers.end();
|
|
|
|
++aLoop
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (_rEvent.FeatureURL.Complete == getURLForId(aLoop->first).Complete)
|
|
|
|
{
|
|
|
|
DBG_ASSERT(xSource.get() == aLoop->second.get(), "SbaTableQueryBrowser::statusChanged: inconsistent!");
|
|
|
|
m_aDispatchStates[aLoop->first] = _rEvent.IsEnabled;
|
|
|
|
implCheckExternalSlot(aLoop->first);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DBG_ASSERT(aLoop != m_aDispatchers.end(), "SbaTableQueryBrowser::statusChanged: don't know who sent this!");
|
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2000-11-07 17:37:34 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SbaTableQueryBrowser::implCheckExternalSlot(sal_Int32 _nId)
|
|
|
|
{
|
|
|
|
// check if we have to hide this item from the toolbox
|
2001-01-09 14:52:33 +00:00
|
|
|
ToolBox* pTB = getBrowserView()->getToolBox();
|
2000-11-07 17:37:34 +00:00
|
|
|
if (pTB)
|
|
|
|
{
|
|
|
|
sal_Bool bHaveDispatcher = m_aDispatchers[_nId].is();
|
2001-03-23 09:57:10 +00:00
|
|
|
if (bHaveDispatcher != pTB->IsItemVisible((sal_uInt16)_nId))
|
|
|
|
bHaveDispatcher ? pTB->ShowItem((sal_uInt16)_nId) : pTB->HideItem((sal_uInt16)_nId);
|
2000-11-07 17:37:34 +00:00
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2000-11-07 17:37:34 +00:00
|
|
|
// and invalidate this feature in general
|
2001-03-23 09:57:10 +00:00
|
|
|
InvalidateFeature((sal_uInt16)_nId);
|
2000-11-07 17:37:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL SbaTableQueryBrowser::disposing( const EventObject& _rSource ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
// search the external dispatcher causing this call in our map
|
|
|
|
Reference< XDispatch > xSource(_rSource.Source, UNO_QUERY);
|
2001-01-09 14:52:33 +00:00
|
|
|
if(xSource.is())
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
2001-01-09 14:52:33 +00:00
|
|
|
for ( SpecialSlotDispatchersIterator aLoop = m_aDispatchers.begin();
|
|
|
|
aLoop != m_aDispatchers.end();
|
|
|
|
++aLoop
|
|
|
|
)
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
2001-01-09 14:52:33 +00:00
|
|
|
if (aLoop->second.get() == xSource.get())
|
|
|
|
{
|
|
|
|
SpecialSlotDispatchersIterator aPrevious = aLoop;
|
|
|
|
--aPrevious;
|
2000-11-07 17:37:34 +00:00
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
// remove it
|
|
|
|
m_aDispatchers.erase(aLoop);
|
|
|
|
m_aDispatchStates.erase(aLoop->first);
|
2000-11-07 17:37:34 +00:00
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
// maybe update the UI
|
|
|
|
implCheckExternalSlot(aLoop->first);
|
|
|
|
|
|
|
|
// continue, the same XDispatch may be resposible for more than one URL
|
|
|
|
aLoop = aPrevious;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Reference<XConnection> xCon(_rSource.Source, UNO_QUERY);
|
|
|
|
if(xCon.is())
|
|
|
|
{ // our connection is in dispose so we have to find the entry equal with this connection
|
|
|
|
// and close it what means to collapse the entry
|
|
|
|
// get the top-level representing the removed data source
|
|
|
|
SvLBoxEntry* pDSLoop = m_pTreeView->getListBox()->FirstChild(NULL);
|
|
|
|
while (pDSLoop)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pDSLoop->GetUserData());
|
|
|
|
if(pData && pData->xObject == xCon)
|
|
|
|
{
|
|
|
|
// we set the conenction to null to avoid a second disposing of the connection
|
|
|
|
pData->xObject = NULL;
|
|
|
|
closeConnection(pDSLoop,sal_False);
|
|
|
|
break;
|
|
|
|
}
|
2000-11-07 17:37:34 +00:00
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
pDSLoop = m_pTreeView->getListBox()->NextSibling(pDSLoop);
|
|
|
|
}
|
2000-11-07 17:37:34 +00:00
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
else
|
|
|
|
SbaXDataBrowserController::disposing(_rSource);
|
2000-11-07 17:37:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
2001-03-07 07:19:43 +00:00
|
|
|
void SbaTableQueryBrowser::implRemoveStatusListeners()
|
2000-11-07 17:37:34 +00:00
|
|
|
{
|
|
|
|
// clear all old dispatches
|
|
|
|
for ( ConstSpecialSlotDispatchersIterator aLoop = m_aDispatchers.begin();
|
|
|
|
aLoop != m_aDispatchers.end();
|
|
|
|
++aLoop
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (aLoop->second.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
aLoop->second->removeStatusListener(this, getURLForId(aLoop->first));
|
|
|
|
}
|
|
|
|
catch (Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::attachFrame: could not remove a status listener!");
|
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
}
|
|
|
|
}
|
2000-11-07 17:37:34 +00:00
|
|
|
m_aDispatchers.clear();
|
|
|
|
m_aDispatchStates.clear();
|
2001-03-07 07:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SbaTableQueryBrowser::attachFrame(const Reference< ::com::sun::star::frame::XFrame > & _xFrame) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
implRemoveStatusListeners();
|
2000-11-07 17:37:34 +00:00
|
|
|
|
|
|
|
SbaXDataBrowserController::attachFrame(_xFrame);
|
|
|
|
|
|
|
|
// get the dispatchers for the external slots
|
|
|
|
Reference< XDispatchProvider > xProvider(m_xCurrentFrame, UNO_QUERY);
|
|
|
|
DBG_ASSERT(xProvider.is(), "SbaTableQueryBrowser::attachFrame: no DispatchPprovider !");
|
|
|
|
if (xProvider.is())
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
2000-11-07 17:37:34 +00:00
|
|
|
sal_Int32 nExternalIds[] = { ID_BROWSER_FORMLETTER, ID_BROWSER_INSERTCOLUMNS, ID_BROWSER_INSERTCONTENT };
|
|
|
|
for (sal_Int32 i=0; i<sizeof(nExternalIds)/sizeof(nExternalIds[0]); ++i)
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
2000-11-07 17:37:34 +00:00
|
|
|
URL aURL = getURLForId(nExternalIds[i]);
|
|
|
|
m_aDispatchers[nExternalIds[i]] = xProvider->queryDispatch(aURL, ::rtl::OUString::createFromAscii("_parent"), FrameSearchFlag::PARENT);
|
|
|
|
if (m_aDispatchers[nExternalIds[i]].get() == static_cast< XDispatch* >(this))
|
|
|
|
// as the URL is one of our "supported features", we may answer the request ourself if nobody out there
|
|
|
|
// is interested in.
|
|
|
|
m_aDispatchers[nExternalIds[i]].clear();
|
|
|
|
|
|
|
|
// assume te general availability of the feature. This is overruled if there is no dispatcher for the URL
|
|
|
|
m_aDispatchStates[nExternalIds[i]] = sal_True;
|
|
|
|
|
|
|
|
if (m_aDispatchers[nExternalIds[i]].is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
m_aDispatchers[nExternalIds[i]]->addStatusListener(this, aURL);
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
catch(DisposedException&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Object already disposed!");
|
|
|
|
}
|
2000-11-07 17:37:34 +00:00
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::attachFrame: could not attach a status listener!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
implCheckExternalSlot(nExternalIds[i]);
|
2000-10-26 13:46:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
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;
|
2000-11-07 17:37:34 +00:00
|
|
|
m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:DataSourceBrowser/FormLetter")] = ID_BROWSER_FORMLETTER;
|
|
|
|
m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:DataSourceBrowser/InsertColumns")] = ID_BROWSER_INSERTCOLUMNS;
|
|
|
|
m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:DataSourceBrowser/InsertContent")] = ID_BROWSER_INSERTCONTENT;
|
2001-01-09 14:52:33 +00:00
|
|
|
m_aSupportedFeatures[ ::rtl::OUString::createFromAscii(".uno:DataSourceBrowser/ToggleExplore")] = ID_BROWSER_EXPLORER;
|
2000-10-26 13:46:14 +00:00
|
|
|
|
|
|
|
// TODO reenable our own code if we really have a handling for the formslots
|
2000-11-07 17:37:34 +00:00
|
|
|
// 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 )
|
2000-10-26 13:46:14 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId)
|
|
|
|
{
|
|
|
|
FeatureState aReturn;
|
|
|
|
// (disabled automatically)
|
|
|
|
|
2000-12-08 20:16:38 +00:00
|
|
|
if (ID_BROWSER_EXPLORER == nId)
|
2001-01-09 14:52:33 +00:00
|
|
|
{ // this slot is available even if no form is loaded
|
2000-12-08 20:16:38 +00:00
|
|
|
aReturn.bEnabled = sal_True;
|
|
|
|
aReturn.aState = ::cppu::bool2any(haveExplorer());
|
|
|
|
return aReturn;
|
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// no chance without a view
|
2001-01-09 14:52:33 +00:00
|
|
|
if (!getBrowserView() || !getBrowserView()->getVclControl())
|
2000-10-26 13:46:14 +00:00
|
|
|
return aReturn;
|
|
|
|
// no chance without valid models
|
2001-01-09 14:52:33 +00:00
|
|
|
if (isValid() && !isValidCursor() && nId != ID_BROWSER_CLOSE) // the close button should always be enabled
|
2000-10-26 13:46:14 +00:00
|
|
|
return aReturn;
|
|
|
|
// no chance while loading the form
|
|
|
|
if (PendingLoad())
|
|
|
|
return aReturn;
|
|
|
|
|
|
|
|
switch (nId)
|
|
|
|
{
|
2000-11-07 17:37:34 +00:00
|
|
|
case ID_BROWSER_INSERTCOLUMNS:
|
|
|
|
case ID_BROWSER_INSERTCONTENT:
|
|
|
|
case ID_BROWSER_FORMLETTER:
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
2000-11-07 17:37:34 +00:00
|
|
|
// the slot is enabled if we have an external dispatcher able to handle it,
|
|
|
|
// and the dispatcher must have enabled the slot in general
|
|
|
|
if (m_aDispatchers[nId].is())
|
|
|
|
aReturn.bEnabled = m_aDispatchStates[nId];
|
|
|
|
else
|
|
|
|
aReturn.bEnabled = sal_False;
|
|
|
|
|
|
|
|
// for the Insert* slots, we need at least one selected row
|
|
|
|
if (ID_BROWSER_FORMLETTER != nId)
|
2001-01-09 14:52:33 +00:00
|
|
|
aReturn.bEnabled = aReturn.bEnabled && getBrowserView()->getVclControl()->GetSelectRowCount();
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2000-11-07 17:37:34 +00:00
|
|
|
// disabled for native queries which are not saved within the database
|
|
|
|
// 67706 - 23.08.99 - FS
|
2000-10-26 13:46:14 +00:00
|
|
|
Reference< XPropertySet > xDataSource(getRowSet(), UNO_QUERY);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
aReturn.bEnabled = aReturn.bEnabled && xDataSource.is();
|
|
|
|
|
|
|
|
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)));
|
|
|
|
}
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
catch(DisposedException&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Object already disposed!");
|
|
|
|
}
|
2000-11-07 17:37:34 +00:00
|
|
|
catch(Exception&)
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
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:
|
2001-01-09 14:52:33 +00:00
|
|
|
case CommandType::COMMAND:
|
2000-10-26 13:46:14 +00:00
|
|
|
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:
|
2001-01-09 14:52:33 +00:00
|
|
|
aReturn.bEnabled = getBrowserView() && getBrowserView()->getVclControl() && isValid() && isValidCursor();
|
2000-10-26 13:46:14 +00:00
|
|
|
// aReturn.bEnabled &= getDefinition() && !getDefinition()->GetDatabase()->IsReadOnly();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_BROWSER_EDITDOC:
|
|
|
|
aReturn = SbaXDataBrowserController::GetState(nId);
|
|
|
|
// aReturn.bEnabled &= !getDefinition()->IsLocked();
|
|
|
|
// somebody is modifying the definition -> no edit mode
|
|
|
|
break;
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
case ID_BROWSER_CLOSE:
|
|
|
|
aReturn.bEnabled = sal_True;
|
|
|
|
break;
|
2001-04-06 12:40:25 +00:00
|
|
|
case ID_BROWSER_COPY:
|
|
|
|
if(m_pTreeView->HasChildPathFocus())
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pEntry = m_pTreeView->getListBox()->GetCurEntry();
|
|
|
|
EntryType eType = getEntryType(pEntry);
|
|
|
|
aReturn.bEnabled = (eType == ET_TABLE || eType == ET_QUERY);
|
|
|
|
break;
|
|
|
|
}// else run through
|
|
|
|
case ID_BROWSER_CUT:
|
|
|
|
if(m_pTreeView->HasChildPathFocus())
|
|
|
|
{
|
|
|
|
aReturn.bEnabled = sal_False;
|
|
|
|
break;
|
|
|
|
}// else run through
|
2001-04-06 13:33:32 +00:00
|
|
|
|
2001-04-06 12:40:25 +00:00
|
|
|
case ID_BROWSER_PASTE:
|
|
|
|
// first look which side is active
|
|
|
|
if(m_pTreeView->HasChildPathFocus())
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pEntry = m_pTreeView->getListBox()->GetCurEntry();
|
|
|
|
EntryType eType = getEntryType(pEntry);
|
|
|
|
aReturn.bEnabled = ((eType == ET_TABLE || eType == ET_TABLE_CONTAINER) && isTableFormat());
|
|
|
|
break;
|
|
|
|
}// else run through
|
2000-10-26 13:46:14 +00:00
|
|
|
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)
|
|
|
|
{
|
2000-12-08 20:16:38 +00:00
|
|
|
case ID_BROWSER_EXPLORER:
|
|
|
|
toggleExplorer();
|
|
|
|
break;
|
2001-05-07 13:09:01 +00:00
|
|
|
|
2000-10-26 13:46:14 +00:00
|
|
|
case ID_BROWSER_EDITDOC:
|
|
|
|
SbaXDataBrowserController::Execute(nId);
|
|
|
|
break;
|
|
|
|
|
2000-11-07 17:37:34 +00:00
|
|
|
case ID_BROWSER_INSERTCOLUMNS:
|
|
|
|
case ID_BROWSER_INSERTCONTENT:
|
|
|
|
case ID_BROWSER_FORMLETTER:
|
2001-01-09 14:52:33 +00:00
|
|
|
if (getBrowserView() && isValidCursor())
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
2000-11-07 17:37:34 +00:00
|
|
|
// the URL the slot id is assigned to
|
|
|
|
URL aParentUrl = getURLForId(nId);
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2000-11-07 17:37:34 +00:00
|
|
|
// let the dispatcher execute the slot
|
|
|
|
Reference< XDispatch > xDispatch(m_aDispatchers[nId]);
|
|
|
|
if (xDispatch.is())
|
2000-10-26 13:46:14 +00:00
|
|
|
{
|
|
|
|
// set the properties for the dispatch
|
|
|
|
|
|
|
|
// first fill the selection
|
2001-01-09 14:52:33 +00:00
|
|
|
SbaGridControl* pGrid = getBrowserView()->getVclControl();
|
2000-10-26 13:46:14 +00:00
|
|
|
MultiSelection* pSelection = (MultiSelection*)pGrid->GetSelection();
|
2001-04-11 11:43:39 +00:00
|
|
|
Sequence< Any > aSelection;
|
2000-10-26 13:46:14 +00:00
|
|
|
if (pSelection != NULL)
|
|
|
|
{
|
|
|
|
aSelection.realloc(pSelection->GetSelectCount());
|
|
|
|
long nIdx = pSelection->FirstSelected();
|
2001-04-11 11:43:39 +00:00
|
|
|
Any* pSelectionNos = aSelection.getArray();
|
2000-10-26 13:46:14 +00:00
|
|
|
while (nIdx >= 0)
|
|
|
|
{
|
2001-04-11 11:43:39 +00:00
|
|
|
*pSelectionNos++ <<= (sal_Int32)(nIdx + 1);
|
2000-10-26 13:46:14 +00:00
|
|
|
nIdx = pSelection->NextSelected();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-07 17:37:34 +00:00
|
|
|
Reference< XResultSet > xCursorClone;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XResultSetAccess > xResultSetAccess(getRowSet(),UNO_QUERY);
|
|
|
|
if (xResultSetAccess.is())
|
|
|
|
xCursorClone = xResultSetAccess->createResultSet();
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
catch(DisposedException&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Object already disposed!");
|
|
|
|
}
|
2000-11-07 17:37:34 +00:00
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::Execute(ID_BROWSER_?): could not clone the cursor!");
|
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2000-11-07 17:37:34 +00:00
|
|
|
Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY);
|
2000-10-26 13:46:14 +00:00
|
|
|
|
2000-11-07 17:37:34 +00:00
|
|
|
try
|
|
|
|
{
|
2001-04-11 11:43:39 +00:00
|
|
|
ODataAccessDescriptor aDescriptor;
|
|
|
|
aDescriptor[daDataSource] = xProp->getPropertyValue(PROPERTY_DATASOURCENAME);
|
|
|
|
aDescriptor[daCommand] = xProp->getPropertyValue(PROPERTY_COMMAND);
|
|
|
|
aDescriptor[daCommandType] = xProp->getPropertyValue(PROPERTY_COMMANDTYPE);
|
|
|
|
aDescriptor[daCursor] <<= xCursorClone;
|
|
|
|
aDescriptor[daSelection] <<= aSelection;
|
|
|
|
|
|
|
|
xDispatch->dispatch(aParentUrl, aDescriptor.createPropertyValueSequence());
|
2000-11-07 17:37:34 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::Execute(ID_BROWSER_?): could not dispatch the slot (caught an exception)!");
|
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
case ID_BROWSER_CLOSE:
|
|
|
|
{
|
|
|
|
Reference<XComponent> xComp(m_xCurrentFrame,UNO_QUERY);
|
|
|
|
::comphelper::disposeComponent(xComp);
|
|
|
|
}
|
|
|
|
break;
|
2001-04-06 12:40:25 +00:00
|
|
|
|
|
|
|
case ID_BROWSER_PASTE:
|
|
|
|
if(m_pTreeView->HasChildPathFocus())
|
|
|
|
{
|
2001-05-07 13:09:01 +00:00
|
|
|
TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(getView()));
|
2001-04-06 12:40:25 +00:00
|
|
|
SvLBoxEntry* pEntry = m_pTreeView->getListBox()->GetCurEntry();
|
|
|
|
implPasteTable( pEntry, aTransferData );
|
|
|
|
break;
|
|
|
|
}// else run through
|
|
|
|
case ID_BROWSER_COPY:
|
|
|
|
if(m_pTreeView->HasChildPathFocus())
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pEntry = m_pTreeView->getListBox()->GetCurEntry();
|
2001-04-11 05:48:19 +00:00
|
|
|
TransferableHelper* pTransfer = NULL;
|
|
|
|
Reference< XTransferable> aEnsureDelete;
|
2001-04-06 12:40:25 +00:00
|
|
|
EntryType eType = getEntryType(pEntry);
|
2001-04-11 05:48:19 +00:00
|
|
|
pTransfer = implCopyObject( pEntry, eType == ET_QUERY ? CommandType::QUERY : CommandType::TABLE);
|
|
|
|
aEnsureDelete = pTransfer;
|
|
|
|
if (pTransfer)
|
2001-05-07 13:09:01 +00:00
|
|
|
pTransfer->CopyToClipboard(getView());
|
2001-04-06 12:40:25 +00:00
|
|
|
break;
|
|
|
|
}// else run through
|
2001-04-11 05:48:19 +00:00
|
|
|
case ID_BROWSER_CUT:// cut isn't allowed for the treeview
|
2000-10-26 13:46:14 +00:00
|
|
|
default:
|
|
|
|
SbaXDataBrowserController::Execute(nId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-11-09 06:34:47 +00:00
|
|
|
// -------------------------------------------------------------------------
|
2000-12-10 15:12:18 +00:00
|
|
|
void SbaTableQueryBrowser::implAddDatasource(const String& _rDbName, Image& _rDbImage,
|
2001-04-26 10:36:16 +00:00
|
|
|
String& _rQueryName, Image& _rQueryImage, String& _rTableName, Image& _rTableImage,
|
|
|
|
String& _rBookmarkName, Image& _rBookmarkImage)
|
2000-11-09 06:34:47 +00:00
|
|
|
{
|
2000-12-10 15:12:18 +00:00
|
|
|
// initialize the names/images if necessary
|
|
|
|
if (!_rQueryName.Len())
|
|
|
|
_rQueryName = String(ModuleRes(RID_STR_QUERIES_CONTAINER));
|
|
|
|
if (!_rTableName.Len())
|
|
|
|
_rTableName = String(ModuleRes(RID_STR_TABLES_CONTAINER));
|
2001-04-26 10:36:16 +00:00
|
|
|
if (!_rBookmarkName.Len())
|
|
|
|
_rBookmarkName = String(ModuleRes(RID_STR_BOOKMARKS_CONTAINER));
|
2000-12-10 15:12:18 +00:00
|
|
|
|
|
|
|
if (!_rQueryImage)
|
|
|
|
_rQueryImage = Image(ModuleRes(QUERYFOLDER_TREE_ICON));
|
|
|
|
if (!_rTableImage)
|
|
|
|
_rTableImage = Image(ModuleRes(TABLEFOLDER_TREE_ICON));
|
2001-04-26 10:36:16 +00:00
|
|
|
if (!_rBookmarkImage)
|
|
|
|
_rBookmarkImage = Image(ModuleRes(BOOKMARKFOLDER_TREE_ICON));
|
2000-12-10 15:12:18 +00:00
|
|
|
|
|
|
|
if (!_rDbImage)
|
|
|
|
_rDbImage = Image(ModuleRes(IMG_DATABASE));
|
|
|
|
|
|
|
|
// add the entry for the data source
|
|
|
|
SvLBoxEntry* pDatasourceEntry = m_pTreeView->getListBox()->InsertEntry(_rDbName, _rDbImage, _rDbImage, NULL, sal_False);
|
|
|
|
pDatasourceEntry->SetUserData(new DBTreeListModel::DBTreeListUserData);
|
|
|
|
|
|
|
|
// the child for the queries container
|
2001-04-26 10:36:16 +00:00
|
|
|
{
|
|
|
|
SvLBoxEntry* pQueries = m_pTreeView->getListBox()->InsertEntry(_rQueryName, _rQueryImage, _rQueryImage, pDatasourceEntry, sal_True);
|
|
|
|
DBTreeListModel::DBTreeListUserData* pQueriesData = new DBTreeListModel::DBTreeListUserData;
|
|
|
|
pQueriesData->eType = DBTreeListModel::etQuery;
|
|
|
|
pQueries->SetUserData(pQueriesData);
|
|
|
|
}
|
2000-12-10 15:12:18 +00:00
|
|
|
|
|
|
|
// the child for the tables container
|
2001-04-26 10:36:16 +00:00
|
|
|
{
|
|
|
|
SvLBoxEntry* pTables = m_pTreeView->getListBox()->InsertEntry(_rTableName, _rTableImage, _rTableImage, pDatasourceEntry, sal_True);
|
|
|
|
DBTreeListModel::DBTreeListUserData* pTablesData = new DBTreeListModel::DBTreeListUserData;
|
|
|
|
pTablesData->eType = DBTreeListModel::etTable;
|
|
|
|
pTables->SetUserData(pTablesData);
|
|
|
|
}
|
|
|
|
|
|
|
|
// the child for the boomarks container
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pBookmarks = m_pTreeView->getListBox()->InsertEntry(_rBookmarkName, _rBookmarkImage, _rBookmarkImage, pDatasourceEntry, sal_True);
|
|
|
|
DBTreeListModel::DBTreeListUserData* pBookmarksData = new DBTreeListModel::DBTreeListUserData;
|
|
|
|
pBookmarksData->eType = DBTreeListModel::etBookmark;
|
|
|
|
pBookmarks->SetUserData(pBookmarksData);
|
|
|
|
}
|
2000-12-10 15:12:18 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SbaTableQueryBrowser::initializeTreeModel()
|
|
|
|
{
|
2000-11-09 06:34:47 +00:00
|
|
|
if (m_xDatabaseContext.is())
|
|
|
|
{
|
2001-04-26 10:36:16 +00:00
|
|
|
Image aDBImage, aQueriesImage, aTablesImage, aBookmarksImage;
|
|
|
|
String sQueriesName, sTablesName, aBookmarksName;
|
2000-11-09 06:34:47 +00:00
|
|
|
|
|
|
|
// 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)
|
2001-04-26 10:36:16 +00:00
|
|
|
implAddDatasource(*pBegin, aDBImage, sQueriesName, aQueriesImage, sTablesName, aTablesImage, aBookmarksName, aBookmarksImage);
|
2000-11-09 06:34:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAccess, SvLBoxEntry* _pParent, const Image& _rImage)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pParent->GetUserData());
|
2001-03-29 06:09:53 +00:00
|
|
|
if(pData) // don't ask if the nameaccess is already set see OnExpandEntry views and tables
|
2000-11-09 06:34:47 +00:00
|
|
|
pData->xObject = _xNameAccess;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Sequence< ::rtl::OUString > aNames = _xNameAccess->getElementNames();
|
|
|
|
const ::rtl::OUString* pBegin = aNames.getConstArray();
|
|
|
|
const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
|
|
|
|
for (; pBegin != pEnd; ++pBegin)
|
2001-03-29 06:09:53 +00:00
|
|
|
if(!m_pTreeView->getListBox()->GetEntryPosByName(*pBegin,_pParent))
|
|
|
|
m_pTreeView->getListBox()->InsertEntry(*pBegin, _rImage, _rImage, _pParent, sal_False);
|
2000-11-09 06:34:47 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::populateTree: could not fill the tree");
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
return sal_True;
|
|
|
|
}
|
2000-12-10 15:12:18 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2001-03-22 09:40:10 +00:00
|
|
|
IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent)
|
2000-12-10 15:12:18 +00:00
|
|
|
{
|
2001-03-22 09:40:10 +00:00
|
|
|
if (_pParent->HasChilds())
|
|
|
|
// nothing to to ...
|
|
|
|
return 1L;
|
2001-03-19 04:58:43 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
::osl::MutexGuard aGuard(m_aEntryMutex);
|
2000-12-10 15:12:18 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
SvLBoxEntry* pFirstParent = m_pTreeView->getListBox()->GetRootLevelParent(_pParent);
|
2001-04-02 11:21:49 +00:00
|
|
|
OSL_ENSURE(pFirstParent,"SbaTableQueryBrowser::OnExpandEntry: No rootlevelparent!");
|
2000-12-10 15:12:18 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast< DBTreeListModel::DBTreeListUserData* >(_pParent->GetUserData());
|
2001-04-02 11:21:49 +00:00
|
|
|
OSL_ENSURE(pData,"SbaTableQueryBrowser::OnExpandEntry: No user data!");
|
2001-03-22 09:40:10 +00:00
|
|
|
SvLBoxString* pString = static_cast<SvLBoxString*>(pFirstParent->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING));
|
2001-04-02 11:21:49 +00:00
|
|
|
OSL_ENSURE(pString,"SbaTableQueryBrowser::OnExpandEntry: No string item!");
|
2001-03-22 09:40:10 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
if (DBTreeListModel::etTable == pData->eType)
|
2001-01-09 14:52:33 +00:00
|
|
|
{
|
2001-03-22 09:40:10 +00:00
|
|
|
// it could be that we already have a connection
|
|
|
|
DBTreeListModel::DBTreeListUserData* pFirstData = static_cast<DBTreeListModel::DBTreeListUserData*>(pFirstParent->GetUserData());
|
|
|
|
Reference<XConnection> xConnection(pFirstData->xObject,UNO_QUERY);
|
|
|
|
WaitObject aWaitCursor(getBrowserView());
|
|
|
|
if(!pFirstData->xObject.is())
|
|
|
|
{
|
2001-04-12 14:31:37 +00:00
|
|
|
// show the "connecting to ..." status
|
|
|
|
String sConnecting(ModuleRes(STR_CONNECTING_DATASOURCE));
|
|
|
|
sConnecting.SearchAndReplaceAscii("$name$", pString->GetText());
|
|
|
|
BrowserViewStatusDisplay aShowStatus(static_cast<UnoDataBrowserView*>(getView()), sConnecting);
|
2001-04-03 07:16:53 +00:00
|
|
|
|
2001-04-12 14:31:37 +00:00
|
|
|
// connect
|
2001-03-22 09:40:10 +00:00
|
|
|
xConnection = connect(pString->GetText());
|
|
|
|
pFirstData->xObject = xConnection;
|
|
|
|
}
|
|
|
|
if(xConnection.is())
|
|
|
|
{
|
|
|
|
Reference< XWarningsSupplier > xWarnings(xConnection, UNO_QUERY);
|
|
|
|
if (xWarnings.is())
|
|
|
|
xWarnings->clearWarnings();
|
2001-02-14 13:37:35 +00:00
|
|
|
|
2001-03-29 06:09:53 +00:00
|
|
|
// first insert the views because the tables can also include
|
|
|
|
// views but that time the bitmap is the wrong one
|
|
|
|
// the nameaccess will be overwriten in populateTree
|
2001-03-22 09:40:10 +00:00
|
|
|
Reference<XViewsSupplier> xViewSup(xConnection,UNO_QUERY);
|
|
|
|
if(xViewSup.is())
|
|
|
|
{
|
|
|
|
Image aImage(ModuleRes(VIEW_TREE_ICON));
|
|
|
|
populateTree(xViewSup->getViews(),_pParent,aImage);
|
|
|
|
}
|
2001-02-28 09:01:54 +00:00
|
|
|
|
2001-03-29 06:09:53 +00:00
|
|
|
Reference<XTablesSupplier> xTabSup(xConnection,UNO_QUERY);
|
|
|
|
if(xTabSup.is())
|
|
|
|
{
|
2001-05-03 13:49:48 +00:00
|
|
|
ModuleRes aResId(DBTreeListModel::getImageResId(DBTreeListModel::etTable));
|
|
|
|
Image aImage(aResId);
|
2001-03-29 06:09:53 +00:00
|
|
|
populateTree(xTabSup->getTables(),_pParent,aImage);
|
|
|
|
Reference<XContainer> xCont(xTabSup->getTables(),UNO_QUERY);
|
|
|
|
if(xCont.is())
|
|
|
|
// add as listener to know when elements are inserted or removed
|
|
|
|
xCont->addContainerListener(this);
|
|
|
|
}
|
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
if (xWarnings.is())
|
|
|
|
{
|
|
|
|
SQLExceptionInfo aInfo(xWarnings->getWarnings());
|
|
|
|
if (aInfo.isValid() && sal_False)
|
|
|
|
{
|
|
|
|
SQLContext aContext;
|
|
|
|
aContext.Message = String(ModuleRes(STR_OPENTABLES_WARNINGS));
|
|
|
|
aContext.Details = String(ModuleRes(STR_OPENTABLES_WARNINGS_DETAILS));
|
|
|
|
aContext.NextException = aInfo.get();
|
|
|
|
aInfo = aContext;
|
|
|
|
showError(aInfo);
|
|
|
|
}
|
|
|
|
// TODO: we need a better concept for these warnings:
|
|
|
|
// something like "don't show any warnings for this datasource, again" would be nice
|
|
|
|
// But this requires an extension of the InteractionHandler and an additional property on the data source
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0L;
|
|
|
|
// 0 indicates that an error occured
|
|
|
|
}
|
2001-03-23 09:57:10 +00:00
|
|
|
else
|
2001-04-26 10:36:16 +00:00
|
|
|
{ // we have to expand the queries or bookmarks
|
|
|
|
sal_uInt16 nImageResId =
|
|
|
|
DBTreeListModel::getImageResId( ET_QUERY == getChildType(_pParent) ? DBTreeListModel::etQuery : DBTreeListModel::etBookmark );
|
2001-03-23 09:57:10 +00:00
|
|
|
if (ensureEntryObject(_pParent))
|
2001-02-16 15:00:13 +00:00
|
|
|
{
|
2001-04-26 10:36:16 +00:00
|
|
|
Reference< XNameAccess > xCollection(static_cast< DBTreeListModel::DBTreeListUserData* >(_pParent->GetUserData())->xObject, UNO_QUERY);
|
|
|
|
populateTree(xCollection, _pParent, Image(ModuleRes(nImageResId)));
|
2001-02-16 15:00:13 +00:00
|
|
|
}
|
2001-03-23 09:57:10 +00:00
|
|
|
}
|
|
|
|
return 1L;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
sal_Bool SbaTableQueryBrowser::ensureEntryObject( SvLBoxEntry* _pEntry )
|
|
|
|
{
|
|
|
|
DBG_ASSERT(_pEntry, "SbaTableQueryBrowser::ensureEntryObject: invalid argument!");
|
|
|
|
if (!_pEntry)
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
EntryType eType = getEntryType( _pEntry );
|
|
|
|
|
|
|
|
// the user data of the entry
|
|
|
|
DBTreeListModel::DBTreeListUserData* pEntryData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pEntry->GetUserData());
|
|
|
|
if (!pEntryData)
|
|
|
|
{ // create
|
|
|
|
pEntryData = new DBTreeListModel::DBTreeListUserData;
|
2001-04-26 10:36:16 +00:00
|
|
|
pEntryData->eType = (ET_TABLE == eType)
|
|
|
|
? DBTreeListModel::etTable
|
|
|
|
: (ET_QUERY == eType)
|
|
|
|
? DBTreeListModel::etQuery
|
|
|
|
: DBTreeListModel::etBookmark;
|
2001-03-23 09:57:10 +00:00
|
|
|
_pEntry->SetUserData(pEntryData);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pEntryData->xObject.is())
|
|
|
|
// nothing to do
|
|
|
|
return sal_True;
|
|
|
|
|
|
|
|
SvLBoxEntry* pDataSourceEntry = m_pTreeView->getListBox()->GetRootLevelParent(_pEntry);
|
|
|
|
switch (eType)
|
|
|
|
{
|
|
|
|
case ET_QUERY_CONTAINER:
|
2001-03-22 09:40:10 +00:00
|
|
|
{
|
2001-03-23 09:57:10 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XQueryDefinitionsSupplier > xQuerySup;
|
2001-04-26 10:36:16 +00:00
|
|
|
m_xDatabaseContext->getByName( GetEntryText( pDataSourceEntry ) ) >>= xQuerySup;
|
2001-03-23 09:57:10 +00:00
|
|
|
if (xQuerySup.is())
|
|
|
|
{
|
|
|
|
Reference< XNameAccess > xQueryDefs = xQuerySup->getQueryDefinitions();
|
|
|
|
Reference< XContainer > xCont(xQueryDefs, UNO_QUERY);
|
|
|
|
if (xCont.is())
|
|
|
|
// add as listener to get notified if elements are inserted or removed
|
|
|
|
xCont->addContainerListener(this);
|
|
|
|
|
|
|
|
pEntryData->xObject = xQueryDefs;
|
|
|
|
}
|
2001-04-26 10:36:16 +00:00
|
|
|
else
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::ensureEntryObject: no XQueryDefinitionsSupplier interface!");
|
2001-03-23 09:57:10 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
2001-03-22 09:40:10 +00:00
|
|
|
{
|
2001-03-23 09:57:10 +00:00
|
|
|
DBG_ERROR("SbaTableQueryBrowser::ensureEntryObject: caught an exception while retrieving the queries container!");
|
2001-03-22 09:40:10 +00:00
|
|
|
}
|
|
|
|
}
|
2001-03-23 09:57:10 +00:00
|
|
|
break;
|
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
case ET_BOOKMARK_CONTAINER:
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XBookmarksSupplier > xBookmarksSupp;
|
|
|
|
m_xDatabaseContext->getByName( GetEntryText( pDataSourceEntry ) ) >>= xBookmarksSupp;
|
|
|
|
if (xBookmarksSupp.is())
|
|
|
|
{
|
|
|
|
Reference< XNameAccess > xBookmarks = xBookmarksSupp->getBookmarks();
|
|
|
|
Reference< XContainer > xCont(xBookmarks, UNO_QUERY);
|
|
|
|
if (xCont.is())
|
|
|
|
// add as listener to get notified if elements are inserted or removed
|
|
|
|
xCont->addContainerListener(this);
|
|
|
|
|
|
|
|
pEntryData->xObject = xBookmarks;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::ensureEntryObject: no XBookmarksSupplier interface!");
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::ensureEntryObject: caught an exception while retrieving the bookmarks container!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-03-23 09:57:10 +00:00
|
|
|
default:
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::ensureEntryObject: ooops ... missing some implementation here!");
|
|
|
|
// TODO ...
|
|
|
|
break;
|
2001-03-22 09:40:10 +00:00
|
|
|
}
|
2001-03-23 09:57:10 +00:00
|
|
|
|
|
|
|
return pEntryData->xObject.is();
|
2001-03-22 09:40:10 +00:00
|
|
|
}
|
2001-03-23 09:57:10 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
sal_Bool SbaTableQueryBrowser::isSelected(SvLBoxEntry* _pEntry) const
|
|
|
|
{
|
|
|
|
SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING) : NULL;
|
|
|
|
if (pTextItem)
|
|
|
|
return static_cast<OBoldListboxString*>(pTextItem)->isEmphasized();
|
|
|
|
else
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::isSelected: invalid entry!");
|
|
|
|
return sal_False;
|
|
|
|
}
|
2001-02-16 15:00:13 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SbaTableQueryBrowser::select(SvLBoxEntry* _pEntry, sal_Bool _bSelect)
|
|
|
|
{
|
|
|
|
SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING) : NULL;
|
|
|
|
if (pTextItem)
|
|
|
|
{
|
|
|
|
static_cast<OBoldListboxString*>(pTextItem)->emphasize(_bSelect);
|
|
|
|
m_pTreeModel->InvalidateEntry(_pEntry);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::select: invalid entry!");
|
|
|
|
}
|
2001-02-14 13:37:35 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void SbaTableQueryBrowser::selectPath(SvLBoxEntry* _pEntry, sal_Bool _bSelect)
|
|
|
|
{
|
|
|
|
while (_pEntry)
|
|
|
|
{
|
|
|
|
select(_pEntry, _bSelect);
|
|
|
|
_pEntry = m_pTreeModel->GetParent(_pEntry);
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
2001-03-22 09:40:10 +00:00
|
|
|
}
|
2000-12-10 15:12:18 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
IMPL_LINK(SbaTableQueryBrowser, OnEntryDoubleClicked, SvLBoxEntry*, _pEntry)
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pSelected = m_pTreeView->getListBox()->FirstSelected();
|
|
|
|
if (!pSelected)
|
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::OnEntryDoubleClicked: invalid selection!");
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ET_BOOKMARK != getEntryType(pSelected))
|
|
|
|
return 0L;
|
|
|
|
|
|
|
|
// a bookmarks has been double-clicked
|
|
|
|
SvLBoxEntry* pContainer = m_pTreeView->getListBox()->GetParent(pSelected);
|
|
|
|
if (!ensureEntryObject(pContainer))
|
|
|
|
return 0L;
|
|
|
|
|
|
|
|
DBTreeListModel::DBTreeListUserData* pContainerData = static_cast<DBTreeListModel::DBTreeListUserData*>(pContainer->GetUserData());
|
|
|
|
Reference< XNameAccess > xBookmarks(pContainerData->xObject, UNO_QUERY);
|
|
|
|
|
|
|
|
OLinkedDocumentsAccess aHelper(getView(), getORB(), xBookmarks);
|
|
|
|
aHelper.open(GetEntryText(pSelected), sal_True);
|
|
|
|
|
|
|
|
return 1L;
|
|
|
|
};
|
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
IMPL_LINK(SbaTableQueryBrowser, OnSelectEntry, SvLBoxEntry*, _pEntry)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard(m_aEntryMutex);
|
2001-04-26 10:36:16 +00:00
|
|
|
|
|
|
|
// get the entry for the tables or queries
|
|
|
|
SvLBoxEntry* pContainer = m_pTreeModel->GetParent(_pEntry);
|
|
|
|
DBTreeListModel::DBTreeListUserData* pContainerData = static_cast<DBTreeListModel::DBTreeListUserData*>(pContainer->GetUserData());
|
|
|
|
|
|
|
|
// get the entry for the datasource
|
|
|
|
SvLBoxEntry* pConnection = m_pTreeModel->GetParent(pContainer);
|
|
|
|
DBTreeListModel::DBTreeListUserData* pConData = static_cast<DBTreeListModel::DBTreeListUserData*>(pConnection->GetUserData());
|
|
|
|
|
|
|
|
if (DBTreeListModel::etBookmark == pContainerData->eType)
|
|
|
|
// nothing to display if it's a bookmark
|
|
|
|
return 0L;
|
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
// reinitialize the rowset
|
|
|
|
// but first check if it is necessary
|
|
|
|
// get all old properties
|
|
|
|
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;
|
|
|
|
::cppu::extractInterface(xOldConnection,xProp->getPropertyValue(PROPERTY_ACTIVECONNECTION));
|
|
|
|
// the name of the table or query
|
|
|
|
SvLBoxString* pString = (SvLBoxString*)_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
|
|
|
|
OSL_ENSURE(pString,"There must be a string item!");
|
|
|
|
::rtl::OUString aName(pString->GetText().GetBuffer());
|
2000-12-10 15:12:18 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
Reference<XConnection> xConnection(pConData->xObject,UNO_QUERY);
|
2001-04-26 10:36:16 +00:00
|
|
|
sal_Int32 nCommandType = (DBTreeListModel:: etTable == pContainerData->eType)
|
|
|
|
? CommandType::TABLE
|
|
|
|
: CommandType::QUERY;
|
2001-02-20 08:06:08 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
// check if need to rebuild the rowset
|
|
|
|
sal_Bool bRebuild = xOldConnection != xConnection || nOldType != nCommandType || aName != aOldName;
|
2001-02-20 08:06:08 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
Reference< ::com::sun::star::form::XLoadable > xLoadable(getRowSet(),UNO_QUERY);
|
|
|
|
bRebuild |= !xLoadable->isLoaded();
|
|
|
|
if(bRebuild)
|
2000-12-10 15:12:18 +00:00
|
|
|
{
|
2001-03-22 09:40:10 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// if table was selected before flush it
|
|
|
|
if(m_pCurrentlyDisplayed)
|
2001-01-09 14:52:33 +00:00
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
2001-02-23 14:17:34 +00:00
|
|
|
if(pData) // can be null because the first load can be failed @see below
|
|
|
|
{
|
|
|
|
Reference<XFlushable> xFlush(pData->xObject,UNO_QUERY);
|
|
|
|
if(xFlush.is())
|
|
|
|
xFlush->flush();
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
2001-02-23 14:17:34 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Object can not be flushed!");
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
2001-01-09 14:52:33 +00:00
|
|
|
WaitObject aWaitCursor(getBrowserView());
|
|
|
|
|
|
|
|
// tell the old entry it has been deselected
|
|
|
|
selectPath(m_pCurrentlyDisplayed, sal_False);
|
|
|
|
m_pCurrentlyDisplayed = _pEntry;
|
|
|
|
// tell the new entry it has been selected
|
|
|
|
selectPath(m_pCurrentlyDisplayed, sal_True);
|
|
|
|
|
|
|
|
// get the name of the data source currently selected
|
|
|
|
::rtl::OUString sDataSourceName;
|
|
|
|
SvLBoxEntry* pEntry = m_pTreeView->getListBox()->GetRootLevelParent(m_pCurrentlyDisplayed);
|
|
|
|
|
|
|
|
if (pEntry)
|
|
|
|
{
|
2001-01-30 07:32:01 +00:00
|
|
|
SvLBoxItem* pTextItem = pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
|
2001-01-09 14:52:33 +00:00
|
|
|
if (pTextItem)
|
|
|
|
sDataSourceName = static_cast<SvLBoxString*>(pTextItem)->GetText();
|
|
|
|
}
|
|
|
|
if(!xConnection.is())
|
|
|
|
{
|
|
|
|
xConnection = connect(sDataSourceName);
|
|
|
|
pConData->xObject = xConnection;
|
|
|
|
}
|
2001-02-06 08:43:00 +00:00
|
|
|
if(!xConnection.is())
|
|
|
|
{
|
|
|
|
unloadForm(sal_False,sal_False);
|
|
|
|
return 0L;
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
|
|
|
|
Reference<XNameAccess> xNameAccess;
|
|
|
|
switch(nCommandType)
|
|
|
|
{
|
|
|
|
case CommandType::TABLE:
|
|
|
|
{
|
|
|
|
// only for tables
|
2001-04-26 10:36:16 +00:00
|
|
|
if(!pContainerData->xObject.is())
|
2001-01-09 14:52:33 +00:00
|
|
|
{
|
|
|
|
Reference<XTablesSupplier> xSup(xConnection,UNO_QUERY);
|
|
|
|
if(xSup.is())
|
|
|
|
xNameAccess = xSup->getTables();
|
2000-12-10 15:12:18 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
pContainerData->xObject = xNameAccess;
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
|
|
|
else
|
2001-04-26 10:36:16 +00:00
|
|
|
xNameAccess = Reference<XNameAccess>(pContainerData->xObject,UNO_QUERY);
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CommandType::QUERY:
|
|
|
|
{
|
|
|
|
Reference<XQueriesSupplier> xSup(xConnection,UNO_QUERY);
|
|
|
|
if(xSup.is())
|
|
|
|
xNameAccess = xSup->getQueries();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(xNameAccess.is() && xNameAccess->hasByName(aName))
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
|
|
|
if(!pData)
|
|
|
|
{
|
2001-04-06 12:40:25 +00:00
|
|
|
Reference<XInterface> xObject;
|
|
|
|
if(xNameAccess->getByName(aName) >>= xObject) // remember the table or query object
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pTableData = new DBTreeListModel::DBTreeListUserData;
|
|
|
|
pTableData->xObject = xObject;
|
2001-04-26 10:36:16 +00:00
|
|
|
pTableData->eType = pContainerData->eType;
|
2001-01-09 14:52:33 +00:00
|
|
|
m_pCurrentlyDisplayed->SetUserData(pTableData);
|
2001-04-06 12:40:25 +00:00
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// the values allowing the RowSet to re-execute
|
|
|
|
xProp->setPropertyValue(PROPERTY_DATASOURCENAME,makeAny(sDataSourceName));
|
|
|
|
// set this _before_ setting the connection, else the rowset would rebuild it ...
|
|
|
|
xProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,makeAny(xConnection));
|
|
|
|
xProp->setPropertyValue(PROPERTY_COMMANDTYPE,makeAny(nCommandType));
|
|
|
|
xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(aName));
|
|
|
|
// the formatter depends on the data source we're working on, so rebuild it here ...
|
|
|
|
initFormatter();
|
|
|
|
|
2001-04-17 13:05:53 +00:00
|
|
|
String sStatus(ModuleRes( CommandType::TABLE == nCommandType ? STR_LOADING_TABLE : STR_LOADING_QUERY ));
|
2001-04-12 14:31:37 +00:00
|
|
|
sStatus.SearchAndReplaceAscii("$name$", aName);
|
|
|
|
BrowserViewStatusDisplay aShowStatus(static_cast<UnoDataBrowserView*>(getView()), sStatus);
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
// switch the grid to design mode while loading
|
|
|
|
getBrowserView()->getGridControl()->setDesignMode(sal_True);
|
|
|
|
InitializeForm(getRowSet());
|
2001-01-26 13:16:30 +00:00
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
// load the row set
|
2001-01-26 13:16:30 +00:00
|
|
|
{
|
|
|
|
FormErrorHelper aNoticeErrors(this);
|
|
|
|
if (xLoadable->isLoaded())
|
|
|
|
// reload does not work if not already loaded
|
|
|
|
xLoadable->reload();
|
|
|
|
else
|
|
|
|
xLoadable->load();
|
|
|
|
|
|
|
|
sal_Bool bLoadSuccess = !errorOccured();
|
|
|
|
// initialize the model
|
|
|
|
InitializeGridModel(getFormComponent());
|
|
|
|
// reload ...
|
|
|
|
// TODO: why this reload ... me thinks the GridModel can't handle beeing initialized when the form
|
|
|
|
// is already loaded, but I'm not sure ...
|
|
|
|
// have to change this, reloading is much too expensive ...
|
|
|
|
if (xLoadable->isLoaded() && bLoadSuccess)
|
|
|
|
xLoadable->reload();
|
|
|
|
FormLoaded(sal_True);
|
|
|
|
}
|
2001-04-06 12:40:25 +00:00
|
|
|
// set the title of the beamer
|
|
|
|
Reference<XPropertySet> xProp(m_xCurrentFrame,UNO_QUERY);
|
|
|
|
if(xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_TITLE))
|
|
|
|
{
|
|
|
|
xProp->setPropertyValue(PROPERTY_TITLE,makeAny(aName));
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
2001-02-23 14:17:34 +00:00
|
|
|
catch(SQLException& e)
|
|
|
|
{
|
|
|
|
showError(SQLExceptionInfo(e));
|
|
|
|
// reset the values
|
|
|
|
xProp->setPropertyValue(PROPERTY_DATASOURCENAME,Any());
|
|
|
|
xProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,Any());
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
// reset the values
|
|
|
|
xProp->setPropertyValue(PROPERTY_DATASOURCENAME,Any());
|
|
|
|
xProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,Any());
|
|
|
|
}
|
2001-04-11 05:48:19 +00:00
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Unkown Exception in SbaTableQueryBrowser::OnSelectEntry!");
|
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
}
|
|
|
|
return 0L;
|
|
|
|
}
|
2001-04-26 10:36:16 +00:00
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2001-04-26 10:36:16 +00:00
|
|
|
SvLBoxEntry* SbaTableQueryBrowser::getEntryFromContainer(const Reference<XNameAccess>& _rxNameAccess)
|
2001-01-09 14:52:33 +00:00
|
|
|
{
|
|
|
|
SvLBoxEntry* pDSLoop = m_pTreeView->getListBox()->FirstChild(NULL);
|
|
|
|
SvLBoxEntry* pContainer = NULL;
|
|
|
|
while (pDSLoop)
|
|
|
|
{
|
2001-03-23 09:57:10 +00:00
|
|
|
pContainer = m_pTreeView->getListBox()->GetEntry(pDSLoop, CONTAINER_QUERIES);
|
2001-01-09 14:52:33 +00:00
|
|
|
DBTreeListModel::DBTreeListUserData* pQueriesData = static_cast<DBTreeListModel::DBTreeListUserData*>(pContainer->GetUserData());
|
|
|
|
if(pQueriesData && pQueriesData->xObject.get() == _rxNameAccess.get())
|
|
|
|
break;
|
|
|
|
|
2001-03-23 09:57:10 +00:00
|
|
|
pContainer = m_pTreeView->getListBox()->GetEntry(pDSLoop, CONTAINER_TABLES);
|
2001-01-09 14:52:33 +00:00
|
|
|
DBTreeListModel::DBTreeListUserData* pTablesData = static_cast<DBTreeListModel::DBTreeListUserData*>(pContainer->GetUserData());
|
|
|
|
if(pTablesData && pTablesData->xObject.get() == _rxNameAccess.get())
|
|
|
|
break;
|
2000-12-10 15:12:18 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
pContainer = m_pTreeView->getListBox()->GetEntry(pDSLoop, CONTAINER_BOOKMARKS);
|
|
|
|
DBTreeListModel::DBTreeListUserData* pBookmarksData = static_cast<DBTreeListModel::DBTreeListUserData*>(pContainer->GetUserData());
|
|
|
|
if(pBookmarksData && pBookmarksData->xObject.get() == _rxNameAccess.get())
|
|
|
|
break;
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
pDSLoop = m_pTreeView->getListBox()->NextSibling(pDSLoop);
|
|
|
|
pContainer = NULL;
|
|
|
|
}
|
|
|
|
return pContainer;
|
|
|
|
}
|
2001-04-26 10:36:16 +00:00
|
|
|
|
2000-12-10 15:12:18 +00:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL SbaTableQueryBrowser::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
|
|
|
|
{
|
2001-04-26 10:36:16 +00:00
|
|
|
::osl::MutexGuard aGuard(m_aEntryMutex);
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
|
|
|
|
// first search for a definition container where we can insert this element
|
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
SvLBoxEntry* pEntry = getEntryFromContainer(xNames);
|
2001-01-09 14:52:33 +00:00
|
|
|
if(pEntry) // found one
|
|
|
|
{
|
|
|
|
// insert the new entry into the tree
|
2001-04-26 10:36:16 +00:00
|
|
|
DBTreeListModel::DBTreeListUserData* pContainerData = static_cast<DBTreeListModel::DBTreeListUserData*>(pEntry->GetUserData());
|
|
|
|
OSL_ENSURE(pContainerData, "elementInserted: There must be user data for this type!");
|
|
|
|
|
|
|
|
sal_uInt16 nImageResId = DBTreeListModel::getImageResId(pContainerData->eType);
|
|
|
|
Image aImage = Image(ModuleRes(nImageResId));
|
|
|
|
|
|
|
|
sal_Bool bIsTable = DBTreeListModel::etTable == pContainerData->eType;
|
|
|
|
if (bIsTable)
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pNewEntry = m_pTreeView->getListBox()->InsertEntry(::comphelper::getString(_rEvent.Accessor),
|
|
|
|
aImage, aImage, pEntry, sal_False);
|
|
|
|
// only insert userdata when we have a table because the query is only a commanddefinition object and not a query
|
2001-01-09 14:52:33 +00:00
|
|
|
DBTreeListModel::DBTreeListUserData* pNewData = new DBTreeListModel::DBTreeListUserData;
|
2001-04-26 10:36:16 +00:00
|
|
|
pNewData->eType = pContainerData->eType;
|
2001-02-14 13:37:35 +00:00
|
|
|
::cppu::extractInterface(pNewData->xObject,_rEvent.Element);// remember the new element
|
2001-01-09 14:52:33 +00:00
|
|
|
pNewEntry->SetUserData(pNewData);
|
|
|
|
}
|
2001-04-26 10:36:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_pTreeView->getListBox()->GetChildCount(pEntry) < ( xNames->getElementNames().getLength() - 1 ) )
|
|
|
|
{
|
|
|
|
// the item inserts its children on demand, but it has not been expanded yet. So ensure here and
|
|
|
|
// now that it has all items
|
|
|
|
populateTree(xNames, pEntry, aImage);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_pTreeView->getListBox()->InsertEntry(::comphelper::getString(_rEvent.Accessor),
|
|
|
|
aImage, aImage, pEntry, sal_False);
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
|
|
|
else if (xNames.get() == m_xDatabaseContext.get())
|
2000-12-10 15:12:18 +00:00
|
|
|
{ // a new datasource has been added to the context
|
|
|
|
// the name of the new ds
|
|
|
|
::rtl::OUString sNewDS;
|
|
|
|
_rEvent.Accessor >>= sNewDS;
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
// add new entries to the list box model
|
2001-04-26 10:36:16 +00:00
|
|
|
Image a, b, c, d; // not interested in reusing them
|
|
|
|
String e, f, g;
|
|
|
|
implAddDatasource(sNewDS, a, e, b, f, c, g, d);
|
2000-12-10 15:12:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
SbaXDataBrowserController::elementInserted(_rEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
|
|
|
|
{
|
2001-04-26 10:36:16 +00:00
|
|
|
::osl::MutexGuard aGuard(m_aEntryMutex);
|
2001-01-09 14:52:33 +00:00
|
|
|
|
|
|
|
Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
|
|
|
|
// get the top-level representing the removed data source
|
|
|
|
// and search for the queries and tables
|
2001-04-26 10:36:16 +00:00
|
|
|
SvLBoxEntry* pContainer = getEntryFromContainer(xNames);
|
|
|
|
if (pContainer)
|
2001-01-09 14:52:33 +00:00
|
|
|
{ // a query or table has been removed
|
|
|
|
String aName = ::comphelper::getString(_rEvent.Accessor).getStr();
|
2001-04-26 10:36:16 +00:00
|
|
|
|
|
|
|
if ( m_pCurrentlyDisplayed
|
|
|
|
&& getEntryType(m_pCurrentlyDisplayed) == getChildType(pContainer)
|
|
|
|
&& m_pTreeView->getListBox()->GetEntryText(m_pCurrentlyDisplayed) == aName
|
|
|
|
)
|
|
|
|
{ // the element displayed currently has been replaced
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
// we need to remember the old value
|
|
|
|
SvLBoxEntry* pTemp = m_pCurrentlyDisplayed;
|
2001-04-26 10:36:16 +00:00
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
// unload
|
2001-01-26 13:16:30 +00:00
|
|
|
unloadForm(sal_False, sal_False); // don't dispose the connection, don't flush
|
2001-04-26 10:36:16 +00:00
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pTemp->GetUserData());
|
2001-04-26 10:36:16 +00:00
|
|
|
pTemp->SetUserData(NULL);
|
|
|
|
delete pData;
|
|
|
|
// the data could be null because we have a table which isn't correct
|
2001-01-09 14:52:33 +00:00
|
|
|
m_pTreeModel->Remove(pTemp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// remove the entry from the model
|
2001-04-26 10:36:16 +00:00
|
|
|
SvLBoxEntry* pChild = m_pTreeModel->FirstChild(pContainer);
|
2001-01-09 14:52:33 +00:00
|
|
|
while(pChild)
|
|
|
|
{
|
|
|
|
if (m_pTreeView->getListBox()->GetEntryText(pChild) == aName)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pChild->GetUserData());
|
2001-04-26 10:36:16 +00:00
|
|
|
pChild->SetUserData(NULL);
|
2001-01-09 14:52:33 +00:00
|
|
|
delete pData;
|
|
|
|
m_pTreeModel->Remove(pChild);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pChild = m_pTreeModel->NextSibling(pChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (xNames.get() == m_xDatabaseContext.get())
|
2000-12-10 15:12:18 +00:00
|
|
|
{ // a datasource has been removed from the context
|
|
|
|
|
|
|
|
// the name
|
|
|
|
::rtl::OUString sNewDS;
|
|
|
|
_rEvent.Accessor >>= sNewDS;
|
|
|
|
String sNewDatasource = sNewDS;
|
|
|
|
|
|
|
|
// get the top-level representing the removed data source
|
|
|
|
SvLBoxEntry* pDSLoop = m_pTreeView->getListBox()->FirstChild(NULL);
|
|
|
|
while (pDSLoop)
|
|
|
|
{
|
|
|
|
if (m_pTreeView->getListBox()->GetEntryText(pDSLoop) == sNewDatasource)
|
|
|
|
break;
|
|
|
|
|
|
|
|
pDSLoop = m_pTreeView->getListBox()->NextSibling(pDSLoop);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pDSLoop)
|
|
|
|
{
|
2001-01-17 07:16:53 +00:00
|
|
|
if (isSelected(pDSLoop))
|
|
|
|
{ // a table or query belonging to the deleted data source is currently beeing displayed.
|
2001-01-23 08:48:35 +00:00
|
|
|
OSL_ENSURE(m_pTreeView->getListBox()->GetRootLevelParent(m_pCurrentlyDisplayed) == pDSLoop, "SbaTableQueryBrowser::elementRemoved: inconsistence (1)!");
|
2001-05-08 15:12:51 +00:00
|
|
|
unloadForm(sal_True, sal_False); // don't flush
|
2001-01-17 07:16:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
OSL_ENSURE(
|
2001-01-23 08:48:35 +00:00
|
|
|
(NULL == m_pCurrentlyDisplayed)
|
|
|
|
|| (m_pTreeView->getListBox()->GetRootLevelParent(m_pCurrentlyDisplayed) != pDSLoop), "SbaTableQueryBrowser::elementRemoved: inconsistence (2)!");
|
2001-01-17 07:16:53 +00:00
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
// look for user data to delete
|
|
|
|
SvTreeEntryList* pList = m_pTreeModel->GetChildList(pDSLoop);
|
|
|
|
if(pList)
|
2000-12-10 15:12:18 +00:00
|
|
|
{
|
2001-01-09 14:52:33 +00:00
|
|
|
SvLBoxEntry* pEntryLoop = static_cast<SvLBoxEntry*>(pList->First());
|
|
|
|
while (pEntryLoop)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pEntryLoop->GetUserData());
|
|
|
|
delete pData;
|
|
|
|
pEntryLoop = static_cast<SvLBoxEntry*>(pList->Next());
|
|
|
|
}
|
2000-12-10 15:12:18 +00:00
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
// remove the entry. This should remove all children, too.
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pDSLoop->GetUserData());
|
|
|
|
delete pData;
|
|
|
|
m_pTreeModel->Remove(pDSLoop);
|
2000-12-10 15:12:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::elementRemoved: unknown datasource name!");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SbaXDataBrowserController::elementRemoved(_rEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEvent ) throw(RuntimeException)
|
|
|
|
{
|
2001-04-26 10:36:16 +00:00
|
|
|
::osl::MutexGuard aGuard(m_aEntryMutex);
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
|
2001-04-26 10:36:16 +00:00
|
|
|
SvLBoxEntry* pContainer = getEntryFromContainer(xNames);
|
|
|
|
if (pContainer)
|
2001-01-09 14:52:33 +00:00
|
|
|
{ // a table or query as been replaced
|
|
|
|
String aName = ::comphelper::getString(_rEvent.Accessor).getStr();
|
2001-04-26 10:36:16 +00:00
|
|
|
|
|
|
|
if ( m_pCurrentlyDisplayed
|
|
|
|
&& getEntryType(m_pCurrentlyDisplayed) == getChildType(pContainer)
|
|
|
|
&& m_pTreeView->getListBox()->GetEntryText(m_pCurrentlyDisplayed) == aName
|
|
|
|
)
|
|
|
|
{ // the element displayed currently has been replaced
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
// we need to remember the old value
|
|
|
|
SvLBoxEntry* pTemp = m_pCurrentlyDisplayed;
|
|
|
|
unloadForm(sal_False); // don't dispose the connection
|
|
|
|
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pTemp->GetUserData());
|
2001-04-26 10:36:16 +00:00
|
|
|
if (pData)
|
2001-01-09 14:52:33 +00:00
|
|
|
{
|
2001-04-26 10:36:16 +00:00
|
|
|
if (DBTreeListModel::etTable == pData->eType)
|
|
|
|
{ // only insert userdata when we have a table because the query is only a commanddefinition object and not a query
|
|
|
|
::cppu::extractInterface(pData->xObject, _rEvent.Element);// remember the new element
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pTemp->SetUserData(NULL);
|
|
|
|
delete pData;
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
2001-04-26 10:36:16 +00:00
|
|
|
else
|
|
|
|
OSL_ENSURE(ET_BOOKMARK_CONTAINER == getEntryType(pContainer), "SbaTableQueryBrowser::elementReplaced: a non-bookmark entry without data?");
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// find the entry for this name
|
2001-04-26 10:36:16 +00:00
|
|
|
SvLBoxEntry* pChild = m_pTreeModel->FirstChild(pContainer);
|
2001-01-09 14:52:33 +00:00
|
|
|
while(pChild)
|
|
|
|
{
|
|
|
|
if (m_pTreeView->getListBox()->GetEntryText(pChild) == aName)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pChild->GetUserData());
|
2001-04-26 10:36:16 +00:00
|
|
|
if (pData)
|
2001-01-09 14:52:33 +00:00
|
|
|
{
|
2001-04-26 10:36:16 +00:00
|
|
|
if (DBTreeListModel::etTable == pData->eType)
|
|
|
|
{ // only insert userdata when we have a table because the query is only a commanddefinition object and not a query
|
|
|
|
::cppu::extractInterface(pData->xObject, _rEvent.Element);// remember the new element
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pChild->SetUserData(NULL);
|
|
|
|
delete pData;
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
}
|
2001-04-26 10:36:16 +00:00
|
|
|
else
|
|
|
|
OSL_ENSURE(ET_BOOKMARK_CONTAINER == getEntryType(pContainer), "SbaTableQueryBrowser::elementReplaced: a non-bookmark entry without data (2)?");
|
2001-01-09 14:52:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
pChild = m_pTreeModel->NextSibling(pChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (xNames.get() == m_xDatabaseContext.get())
|
2000-12-10 15:12:18 +00:00
|
|
|
{ // a datasource has been replaced in the context
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::elementReplaced: no support for replaced data sources!");
|
|
|
|
// very suspicious: the database context should not allow to replace data source, only to register
|
|
|
|
// and revoke them
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SbaXDataBrowserController::elementReplaced(_rEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
2001-01-09 14:52:33 +00:00
|
|
|
void SbaTableQueryBrowser::closeConnection(SvLBoxEntry* _pDSEntry,sal_Bool _bDisposeConnection)
|
2000-12-10 15:12:18 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT(_pDSEntry, "SbaTableQueryBrowser::closeConnection: invalid entry (NULL)!");
|
2001-04-02 11:21:49 +00:00
|
|
|
OSL_ENSURE(m_pTreeView->getListBox()->GetRootLevelParent(_pDSEntry) == _pDSEntry, "SbaTableQueryBrowser::closeConnection: invalid entry (not top-level)!");
|
2000-12-10 15:12:18 +00:00
|
|
|
|
2000-12-10 18:10:43 +00:00
|
|
|
// if one of the entries of the given DS is displayed currently, unload the form
|
2001-01-09 14:52:33 +00:00
|
|
|
if (m_pCurrentlyDisplayed && (m_pTreeView->getListBox()->GetRootLevelParent(m_pCurrentlyDisplayed) == _pDSEntry))
|
|
|
|
unloadForm(_bDisposeConnection);
|
2000-12-10 18:10:43 +00:00
|
|
|
|
2000-12-10 15:12:18 +00:00
|
|
|
// collapse the query/table container
|
|
|
|
for (SvLBoxEntry* pContainers = m_pTreeModel->FirstChild(_pDSEntry); pContainers; pContainers= m_pTreeModel->NextSibling(pContainers))
|
|
|
|
{
|
|
|
|
m_pTreeView->getListBox()->Collapse(pContainers);
|
|
|
|
m_pTreeView->getListBox()->EnableExpandHandler(pContainers);
|
|
|
|
// and delete their children (they are connection-relative)
|
|
|
|
for (SvLBoxEntry* pElements = m_pTreeModel->FirstChild(pContainers); pElements; )
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pRemove = pElements;
|
|
|
|
pElements= m_pTreeModel->NextSibling(pElements);
|
2001-01-09 14:52:33 +00:00
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pRemove->GetUserData());
|
|
|
|
delete pData;
|
2000-12-10 15:12:18 +00:00
|
|
|
m_pTreeModel->Remove(pRemove);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// collapse the entry itself
|
|
|
|
m_pTreeView->getListBox()->Collapse(_pDSEntry);
|
|
|
|
|
|
|
|
// get the connection
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pDSEntry->GetUserData());
|
2001-01-09 14:52:33 +00:00
|
|
|
if(_bDisposeConnection) // and dispose/reset it
|
|
|
|
{
|
|
|
|
Reference< XComponent > xComponent(pData->xObject, UNO_QUERY);
|
|
|
|
if (xComponent.is())
|
|
|
|
{
|
|
|
|
Reference< ::com::sun::star::lang::XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY);
|
|
|
|
xComponent->removeEventListener(xEvtL);
|
|
|
|
}
|
|
|
|
::comphelper::disposeComponent(pData->xObject);
|
|
|
|
}
|
2000-12-10 15:12:18 +00:00
|
|
|
pData->xObject.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
2001-01-26 13:16:30 +00:00
|
|
|
void SbaTableQueryBrowser::unloadForm(sal_Bool _bDisposeConnection, sal_Bool _bFlushData)
|
2000-12-10 15:12:18 +00:00
|
|
|
{
|
2001-01-09 14:52:33 +00:00
|
|
|
if (!m_pCurrentlyDisplayed)
|
2000-12-10 15:12:18 +00:00
|
|
|
// nothing to do
|
|
|
|
return;
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
SvLBoxEntry* pDSEntry = m_pTreeView->getListBox()->GetRootLevelParent(m_pCurrentlyDisplayed);
|
2000-12-10 15:12:18 +00:00
|
|
|
|
|
|
|
// de-select the path for the currently displayed table/query
|
2001-01-09 14:52:33 +00:00
|
|
|
if (m_pCurrentlyDisplayed)
|
|
|
|
{
|
2001-01-26 13:16:30 +00:00
|
|
|
if (_bFlushData)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
|
|
|
|
try
|
|
|
|
{
|
2001-02-14 13:37:35 +00:00
|
|
|
if(pData)
|
|
|
|
{
|
|
|
|
Reference<XFlushable> xFlush(pData->xObject, UNO_QUERY);
|
|
|
|
if(xFlush.is())
|
|
|
|
xFlush->flush();
|
|
|
|
}
|
2001-01-26 13:16:30 +00:00
|
|
|
}
|
|
|
|
catch (RuntimeException&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(sal_False, "SbaTableQueryBrowser::unloadForm: could not flush the data (caught a RuntimeException)!");
|
|
|
|
}
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
selectPath(m_pCurrentlyDisplayed, sal_False);
|
|
|
|
}
|
|
|
|
m_pCurrentlyDisplayed = NULL;
|
2000-12-10 15:12:18 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// get the active connection. We need to dispose it.
|
|
|
|
Reference< XPropertySet > xProp(getRowSet(),UNO_QUERY);
|
|
|
|
Reference< XConnection > xConn;
|
|
|
|
::cppu::extractInterface(xConn, xProp->getPropertyValue(PROPERTY_ACTIVECONNECTION));
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
Reference< XComponent > xComp;
|
|
|
|
::cppu::extractInterface(xComp, xProp->getPropertyValue(PROPERTY_ACTIVECONNECTION));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// unload the form
|
|
|
|
Reference< XLoadable > xLoadable(getRowSet(), UNO_QUERY);
|
|
|
|
xLoadable->unload();
|
|
|
|
|
|
|
|
// clear the grid control
|
|
|
|
Reference< XNameContainer > xColContainer(getControlModel(), 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// dispose the connection
|
2001-01-09 14:52:33 +00:00
|
|
|
if(_bDisposeConnection)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pDSEntry->GetUserData());
|
|
|
|
if(pData)
|
|
|
|
{
|
|
|
|
Reference< XComponent > xComponent(pData->xObject, UNO_QUERY);
|
|
|
|
if (xComponent.is())
|
|
|
|
{
|
|
|
|
Reference< ::com::sun::star::lang::XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY);
|
|
|
|
xComponent->removeEventListener(xEvtL);
|
|
|
|
}
|
|
|
|
pData->xObject = NULL;
|
|
|
|
}
|
|
|
|
::comphelper::disposeComponent(xConn);
|
|
|
|
}
|
2000-12-10 15:12:18 +00:00
|
|
|
}
|
2001-02-23 14:17:34 +00:00
|
|
|
catch(SQLException& e)
|
|
|
|
{
|
|
|
|
showError(SQLExceptionInfo(e));
|
|
|
|
}
|
2000-12-10 15:12:18 +00:00
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(sal_False, "SbaTableQueryBrowser::unloadForm: could not reset the form");
|
|
|
|
}
|
|
|
|
}
|
2000-10-26 13:46:14 +00:00
|
|
|
// -------------------------------------------------------------------------
|
2000-11-23 09:46:21 +00:00
|
|
|
void SAL_CALL SbaTableQueryBrowser::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException)
|
|
|
|
{
|
2001-01-24 10:46:47 +00:00
|
|
|
::vos::OGuard aGuard(Application::GetSolarMutex());
|
|
|
|
// doin' a lot of VCL stuff here -> lock the SolarMutex
|
|
|
|
|
2000-11-23 09:46:21 +00:00
|
|
|
// first initialize the parent
|
|
|
|
SbaXDataBrowserController::initialize( aArguments );
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
Reference<XConnection> xConnection;
|
2000-11-23 09:46:21 +00:00
|
|
|
PropertyValue aValue;
|
|
|
|
const Any* pBegin = aArguments.getConstArray();
|
|
|
|
const Any* pEnd = pBegin + aArguments.getLength();
|
|
|
|
|
2001-01-09 14:52:33 +00:00
|
|
|
::rtl::OUString aTableName,aCatalogName,aSchemaName;
|
|
|
|
sal_Bool bEsacpeProcessing = sal_True;
|
2001-04-26 10:36:16 +00:00
|
|
|
sal_Int32 nInitialDisplayCommandType;
|
2000-11-23 09:46:21 +00:00
|
|
|
for(;pBegin != pEnd;++pBegin)
|
|
|
|
{
|
|
|
|
if((*pBegin >>= aValue) && aValue.Name == PROPERTY_DATASOURCENAME)
|
|
|
|
aValue.Value >>= m_sDefaultDataSourceName;
|
|
|
|
else if(aValue.Name == PROPERTY_COMMANDTYPE)
|
2001-04-26 10:36:16 +00:00
|
|
|
aValue.Value >>= nInitialDisplayCommandType;
|
2000-11-23 09:46:21 +00:00
|
|
|
else if(aValue.Name == PROPERTY_COMMAND)
|
|
|
|
aValue.Value >>= m_sDefaultCommand;
|
2001-01-09 14:52:33 +00:00
|
|
|
else if(aValue.Name == PROPERTY_ACTIVECONNECTION)
|
2001-02-14 13:37:35 +00:00
|
|
|
::cppu::extractInterface(xConnection,aValue.Value);
|
2001-01-09 14:52:33 +00:00
|
|
|
else if(aValue.Name == PROPERTY_UPDATE_CATALOGNAME)
|
|
|
|
aValue.Value >>= aCatalogName;
|
|
|
|
else if(aValue.Name == PROPERTY_UPDATE_SCHEMANAME)
|
|
|
|
aValue.Value >>= aSchemaName;
|
|
|
|
else if(aValue.Name == PROPERTY_UPDATE_TABLENAME)
|
|
|
|
aValue.Value >>= aTableName;
|
|
|
|
else if(aValue.Name == PROPERTY_USE_ESCAPE_PROCESSING)
|
|
|
|
bEsacpeProcessing = ::cppu::any2bool(aValue.Value);
|
|
|
|
else if(aValue.Name == PROPERTY_SHOWTREEVIEW)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if(::cppu::any2bool(aValue.Value))
|
|
|
|
showExplorer();
|
|
|
|
else
|
|
|
|
hideExplorer();
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(aValue.Name == PROPERTY_SHOWTREEVIEWBUTTON)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if(!::cppu::any2bool(aValue.Value) && getView())
|
|
|
|
{
|
|
|
|
// hide the explorer and the separator
|
|
|
|
getView()->getToolBox()->HideItem(ID_BROWSER_EXPLORER);
|
|
|
|
getView()->getToolBox()->HideItem(getView()->getToolBox()->GetItemId(getView()->getToolBox()->GetItemPos(ID_BROWSER_EXPLORER)+1));
|
|
|
|
getView()->getToolBox()->ShowItem(ID_BROWSER_CLOSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2000-11-23 09:46:21 +00:00
|
|
|
}
|
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
if(m_sDefaultDataSourceName.getLength() && m_sDefaultCommand.getLength() && nInitialDisplayCommandType != -1)
|
2000-11-23 09:46:21 +00:00
|
|
|
{
|
|
|
|
SvLBoxEntry* pDataSource = m_pTreeView->getListBox()->GetEntryPosByName(m_sDefaultDataSourceName,NULL);
|
|
|
|
if(pDataSource)
|
|
|
|
{
|
|
|
|
m_pTreeView->getListBox()->Expand(pDataSource);
|
|
|
|
SvLBoxEntry* pCommandType = NULL;
|
2001-04-26 10:36:16 +00:00
|
|
|
if(CommandType::TABLE == nInitialDisplayCommandType)
|
2001-03-23 09:57:10 +00:00
|
|
|
pCommandType = m_pTreeView->getListBox()->GetModel()->GetEntry(pDataSource, CONTAINER_TABLES);
|
2001-04-26 10:36:16 +00:00
|
|
|
else if(CommandType::QUERY == nInitialDisplayCommandType)
|
2001-03-23 09:57:10 +00:00
|
|
|
pCommandType = m_pTreeView->getListBox()->GetModel()->GetEntry(pDataSource, CONTAINER_QUERIES);
|
2001-04-26 10:36:16 +00:00
|
|
|
|
2000-11-23 09:46:21 +00:00
|
|
|
if(pCommandType)
|
|
|
|
{
|
|
|
|
// we need to expand the command
|
|
|
|
m_pTreeView->getListBox()->Expand(pCommandType);
|
|
|
|
SvLBoxEntry* pCommand = m_pTreeView->getListBox()->GetEntryPosByName(m_sDefaultCommand,pCommandType);
|
|
|
|
if(pCommand)
|
|
|
|
m_pTreeView->getListBox()->Select(pCommand);
|
|
|
|
}
|
2001-01-09 14:52:33 +00:00
|
|
|
else // we have a command and need to display this in the rowset
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY);
|
|
|
|
if(xProp.is())
|
|
|
|
{
|
|
|
|
Reference< ::com::sun::star::form::XLoadable > xLoadable(xProp,UNO_QUERY);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// the values allowing the RowSet to re-execute
|
|
|
|
xProp->setPropertyValue(PROPERTY_DATASOURCENAME,makeAny(m_sDefaultDataSourceName));
|
|
|
|
// set this _before_ setting the connection, else the rowset would rebuild it ...
|
|
|
|
if(xConnection.is())
|
|
|
|
xProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,makeAny(xConnection));
|
2001-04-26 10:36:16 +00:00
|
|
|
xProp->setPropertyValue(PROPERTY_COMMANDTYPE,makeAny(nInitialDisplayCommandType));
|
2001-01-09 14:52:33 +00:00
|
|
|
xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(m_sDefaultCommand));
|
|
|
|
|
|
|
|
xProp->setPropertyValue(PROPERTY_UPDATE_CATALOGNAME,makeAny(aCatalogName));
|
|
|
|
xProp->setPropertyValue(PROPERTY_UPDATE_SCHEMANAME,makeAny(aSchemaName));
|
|
|
|
xProp->setPropertyValue(PROPERTY_UPDATE_TABLENAME,makeAny(aTableName));
|
|
|
|
xProp->setPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING,::cppu::bool2any(bEsacpeProcessing));
|
|
|
|
// the formatter depends on the data source we're working on, so rebuild it here ...
|
|
|
|
initFormatter();
|
|
|
|
// switch the grid to design mode while loading
|
|
|
|
getBrowserView()->getGridControl()->setDesignMode(sal_True);
|
|
|
|
InitializeForm(getRowSet());
|
|
|
|
{
|
2001-03-22 09:40:10 +00:00
|
|
|
FormErrorHelper aHelper(this);
|
|
|
|
// load the row set
|
|
|
|
if (xLoadable->isLoaded())
|
|
|
|
// reload does not work if not already loaded
|
|
|
|
xLoadable->reload();
|
|
|
|
else
|
|
|
|
xLoadable->load();
|
|
|
|
// initialize the model
|
|
|
|
InitializeGridModel(getFormComponent());
|
|
|
|
Reference< ::com::sun::star::form::XLoadable > xLoadable(getRowSet(),UNO_QUERY);
|
|
|
|
if (xLoadable->isLoaded() && !errorOccured())
|
|
|
|
xLoadable->reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
FormLoaded(sal_True);
|
|
|
|
}
|
|
|
|
catch(SQLException& e)
|
|
|
|
{
|
|
|
|
showError(SQLExceptionInfo(e));
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
sal_Bool SbaTableQueryBrowser::haveExplorer() const
|
|
|
|
{
|
|
|
|
return m_pTreeView && m_pTreeView->IsVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SbaTableQueryBrowser::hideExplorer()
|
|
|
|
{
|
|
|
|
if (!haveExplorer())
|
|
|
|
return;
|
|
|
|
if (!getBrowserView())
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_pTreeView->Hide();
|
|
|
|
m_pSplitter->Hide();
|
|
|
|
getBrowserView()->Resize();
|
|
|
|
|
|
|
|
InvalidateFeature(ID_BROWSER_EXPLORER);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SbaTableQueryBrowser::showExplorer()
|
|
|
|
{
|
|
|
|
if (haveExplorer())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!getBrowserView())
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_pTreeView->Show();
|
|
|
|
m_pSplitter->Show();
|
|
|
|
getBrowserView()->Resize();
|
|
|
|
|
|
|
|
InvalidateFeature(ID_BROWSER_EXPLORER);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool SbaTableQueryBrowser::ensureConnection(SvLBoxEntry* _pAnyEntry, Reference< XConnection>& _xConnection)
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pDSEntry = m_pTreeView->getListBox()->GetRootLevelParent(_pAnyEntry);
|
|
|
|
DBTreeListModel::DBTreeListUserData* pDSData =
|
|
|
|
pDSEntry
|
|
|
|
? static_cast<DBTreeListModel::DBTreeListUserData*>(pDSEntry->GetUserData())
|
|
|
|
: NULL;
|
|
|
|
|
|
|
|
return ensureConnection( pDSEntry, pDSData, _xConnection);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool SbaTableQueryBrowser::ensureConnection(SvLBoxEntry* _pDSEntry, void* pDSData, Reference<XConnection>& _xConnection)
|
|
|
|
{
|
|
|
|
if(_pDSEntry)
|
|
|
|
{
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pDSData);
|
2001-04-26 10:36:16 +00:00
|
|
|
::rtl::OUString aDSName = GetEntryText(_pDSEntry);
|
2001-03-22 09:40:10 +00:00
|
|
|
|
|
|
|
if (pData)
|
|
|
|
_xConnection = Reference<XConnection>(pData->xObject,UNO_QUERY);
|
|
|
|
if(!_xConnection.is() && pData)
|
|
|
|
{
|
|
|
|
_xConnection = connect(aDSName);
|
|
|
|
pData->xObject = _xConnection; // share the conenction with the querydesign
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return _xConnection.is();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
IMPL_LINK( SbaTableQueryBrowser, OnTreeEntryCompare, const SvSortData*, _pSortData )
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pLHS = static_cast<SvLBoxEntry*>(_pSortData->pLeft);
|
|
|
|
SvLBoxEntry* pRHS = static_cast<SvLBoxEntry*>(_pSortData->pRight);
|
|
|
|
DBG_ASSERT(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!");
|
2001-04-06 12:40:25 +00:00
|
|
|
// we want the table entry and the end so we have to do a check
|
2001-04-26 10:36:16 +00:00
|
|
|
|
|
|
|
if (isContainer(pRHS))
|
|
|
|
{
|
|
|
|
// don't use getEntryType (directly or indirecly) for the LHS:
|
|
|
|
// LHS is currently beeing inserted, so it is not "completely valid" at the moment
|
|
|
|
|
|
|
|
const EntryType eRight = getEntryType(pRHS);
|
|
|
|
if (ET_TABLE_CONTAINER == eRight)
|
|
|
|
// every other container should be placed _before_ the bookmark container
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
const String sLeft = m_pTreeView->getListBox()->GetEntryText(pLHS);
|
|
|
|
|
|
|
|
EntryType eLeft;
|
|
|
|
if (String(ModuleRes(RID_STR_TABLES_CONTAINER)) == sLeft)
|
|
|
|
eLeft = ET_TABLE_CONTAINER;
|
|
|
|
else if (String(ModuleRes(RID_STR_QUERIES_CONTAINER)) == sLeft)
|
|
|
|
eLeft = ET_QUERY_CONTAINER;
|
|
|
|
else
|
|
|
|
eLeft = ET_BOOKMARK_CONTAINER;
|
|
|
|
|
|
|
|
return eLeft < eRight
|
|
|
|
? COMPARE_LESS
|
|
|
|
: eLeft == eRight
|
|
|
|
? COMPARE_EQUAL
|
|
|
|
: COMPARE_GREATER;
|
|
|
|
}
|
2001-03-22 09:40:10 +00:00
|
|
|
|
|
|
|
SvLBoxString* pLeftTextItem = static_cast<SvLBoxString*>(pLHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
|
|
|
|
SvLBoxString* pRightTextItem = static_cast<SvLBoxString*>(pRHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
|
|
|
|
DBG_ASSERT(pLeftTextItem && pRightTextItem, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid text items!");
|
|
|
|
|
|
|
|
String sLeftText = pLeftTextItem->GetText();
|
|
|
|
String sRightText = pRightTextItem->GetText();
|
|
|
|
|
|
|
|
sal_Int32 nCompareResult = 0; // equal by default
|
|
|
|
|
|
|
|
if (m_xCollator.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nCompareResult = m_xCollator->compareString(sLeftText, sRightText);
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// default behaviour if we do not have a collator -> do the simple string compare
|
|
|
|
nCompareResult = sLeftText.CompareTo(sRightText);
|
|
|
|
|
|
|
|
return nCompareResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SbaTableQueryBrowser::implAdministrate( SvLBoxEntry* _pApplyTo )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// the parameters:
|
|
|
|
Sequence< Any > aArgs(2);
|
|
|
|
// the parent window
|
|
|
|
aArgs[0] <<= PropertyValue(
|
|
|
|
::rtl::OUString::createFromAscii("ParentWindow"), 0,
|
|
|
|
makeAny(VCLUnoHelper::GetInterface(m_pTreeView->getListBox()->Window::GetParent())), PropertyState_DIRECT_VALUE);
|
|
|
|
// the initial selection
|
|
|
|
SvLBoxEntry* pTopLevelSelected = _pApplyTo;
|
|
|
|
while (pTopLevelSelected && m_pTreeView->getListBox()->GetParent(pTopLevelSelected))
|
|
|
|
pTopLevelSelected = m_pTreeView->getListBox()->GetParent(pTopLevelSelected);
|
|
|
|
::rtl::OUString sInitialSelection;
|
|
|
|
if (pTopLevelSelected)
|
|
|
|
sInitialSelection = m_pTreeView->getListBox()->GetEntryText(pTopLevelSelected);
|
|
|
|
aArgs[1] <<= PropertyValue(
|
|
|
|
::rtl::OUString::createFromAscii("InitialSelection"), 0,
|
|
|
|
makeAny(sInitialSelection), PropertyState_DIRECT_VALUE);
|
|
|
|
|
|
|
|
// create the dialog
|
|
|
|
Reference< XExecutableDialog > xAdminDialog;
|
|
|
|
xAdminDialog = Reference< XExecutableDialog >(
|
|
|
|
m_xMultiServiceFacatory->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.sdb.DatasourceAdministrationDialog"),
|
|
|
|
aArgs), UNO_QUERY);
|
|
|
|
|
|
|
|
// execute it
|
|
|
|
if (xAdminDialog.is())
|
|
|
|
xAdminDialog->execute();
|
|
|
|
}
|
|
|
|
catch(::com::sun::star::uno::Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::implAdministrate: caught an exception while creating/executing the dialog!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SbaTableQueryBrowser::implCreateObject( SvLBoxEntry* _pApplyTo, sal_uInt16 _nAction )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard(m_aEntryMutex);
|
|
|
|
|
|
|
|
// get all needed properties for design
|
|
|
|
Reference<XConnection> xConnection; // supports the service sdb::connection
|
|
|
|
if(!ensureConnection(_pApplyTo, xConnection))
|
|
|
|
return;
|
|
|
|
|
|
|
|
::rtl::OUString sCurrentObject;
|
|
|
|
if ((ID_TREE_QUERY_EDIT == _nAction || ID_TREE_TABLE_EDIT == _nAction) && _pApplyTo)
|
|
|
|
{
|
|
|
|
// get the name of the query
|
|
|
|
SvLBoxItem* pQueryTextItem = _pApplyTo->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
|
|
|
|
if (pQueryTextItem)
|
|
|
|
sCurrentObject = static_cast<SvLBoxString*>(pQueryTextItem)->GetText();
|
|
|
|
|
|
|
|
DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pApplyTo->GetUserData());
|
|
|
|
if(!pData)
|
|
|
|
{
|
|
|
|
// the query has not been accessed before -> create it's user data
|
|
|
|
pData = new DBTreeListModel::DBTreeListUserData;
|
|
|
|
|
|
|
|
Reference<XNameAccess> xNameAccess;
|
|
|
|
if(ID_TREE_TABLE_EDIT == _nAction)
|
|
|
|
{
|
|
|
|
Reference<XTablesSupplier> xSup(xConnection,UNO_QUERY);
|
|
|
|
if(xSup.is())
|
|
|
|
xNameAccess = xSup->getTables();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Reference<XQueriesSupplier> xSup(xConnection,UNO_QUERY);
|
|
|
|
if(xSup.is())
|
|
|
|
xNameAccess = xSup->getQueries();
|
|
|
|
}
|
|
|
|
|
|
|
|
SvLBoxItem* pTextItem = _pApplyTo->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
|
|
|
|
if (pTextItem)
|
|
|
|
sCurrentObject = static_cast<SvLBoxString*>(pTextItem)->GetText();
|
|
|
|
|
|
|
|
if(xNameAccess.is() && xNameAccess->hasByName(sCurrentObject) &&
|
|
|
|
::cppu::extractInterface(pData->xObject,xNameAccess->getByName(sCurrentObject))) // remember the table or query object
|
|
|
|
_pApplyTo->SetUserData(pData);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete pData;
|
|
|
|
pData = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ODesignAccess* pDispatcher = NULL;
|
|
|
|
sal_Bool bEdit = sal_False;
|
|
|
|
switch(_nAction)
|
|
|
|
{
|
|
|
|
case ID_TREE_RELATION_DESIGN:
|
|
|
|
pDispatcher = new ORelationDesignAccess(m_xMultiServiceFacatory) ;
|
|
|
|
break;
|
|
|
|
case ID_TREE_TABLE_EDIT:
|
|
|
|
bEdit = sal_True; // run through
|
|
|
|
case ID_TREE_TABLE_CREATE_DESIGN:
|
|
|
|
pDispatcher = new OTableDesignAccess(m_xMultiServiceFacatory) ;
|
|
|
|
break;
|
|
|
|
case ID_TREE_QUERY_EDIT:
|
|
|
|
bEdit = sal_True; // run through
|
|
|
|
case ID_TREE_QUERY_CREATE_DESIGN:
|
|
|
|
case ID_TREE_QUERY_CREATE_TEXT:
|
|
|
|
pDispatcher = new OQueryDesignAccess(m_xMultiServiceFacatory) ;
|
|
|
|
break;
|
2001-04-24 13:36:44 +00:00
|
|
|
case ID_TREE_VIEW_CREATE_DESIGN:
|
|
|
|
pDispatcher = new OQueryDesignAccess(m_xMultiServiceFacatory,sal_True) ;
|
|
|
|
break;
|
2001-03-22 09:40:10 +00:00
|
|
|
}
|
2001-04-26 10:36:16 +00:00
|
|
|
::rtl::OUString aDSName = GetEntryText( m_pTreeView->getListBox()->GetRootLevelParent( _pApplyTo ) );
|
2001-03-22 09:40:10 +00:00
|
|
|
|
|
|
|
if (bEdit)
|
|
|
|
pDispatcher->edit(aDSName, sCurrentObject, xConnection);
|
|
|
|
else
|
2001-04-24 13:36:44 +00:00
|
|
|
pDispatcher->create(aDSName, xConnection, (ID_TREE_QUERY_CREATE_DESIGN == _nAction) || (ID_TREE_VIEW_CREATE_DESIGN == _nAction));
|
2001-04-06 12:40:25 +00:00
|
|
|
delete pDispatcher;
|
2001-03-22 09:40:10 +00:00
|
|
|
}
|
|
|
|
catch(SQLException& e)
|
|
|
|
{
|
|
|
|
showError(SQLExceptionInfo(e));
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::implCreateObject: caught an exception!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-03-23 09:57:10 +00:00
|
|
|
void SbaTableQueryBrowser::implRemoveQuery( SvLBoxEntry* _pApplyTo )
|
2001-03-22 09:40:10 +00:00
|
|
|
{
|
2001-04-26 10:36:16 +00:00
|
|
|
String sDsName = GetEntryText( m_pTreeView->getListBox()->GetRootLevelParent( _pApplyTo ) );
|
|
|
|
String sName = GetEntryText( _pApplyTo );
|
2001-04-06 08:02:57 +00:00
|
|
|
if (!sDsName.Len() || !sName.Len())
|
2001-03-23 09:57:10 +00:00
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::implRemoveQuery: invalid entries detected!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
String aMsg(ModuleRes(STR_QUERY_DELETE_QUERY));
|
2001-04-26 10:36:16 +00:00
|
|
|
aMsg.SearchAndReplaceAscii("$name$", sName);
|
2001-03-22 09:40:10 +00:00
|
|
|
OSQLMessageBox aDlg(getBrowserView()->getVclControl(),String(ModuleRes(STR_TITLE_CONFIRM_DELETION )),aMsg,WB_YES_NO | WB_DEF_YES,OSQLMessageBox::Query);
|
|
|
|
if(aDlg.Execute() == RET_YES)
|
|
|
|
{
|
|
|
|
Reference<XQueryDefinitionsSupplier> xSet;
|
|
|
|
try
|
|
|
|
{
|
2001-03-23 09:57:10 +00:00
|
|
|
if(m_xDatabaseContext->hasByName(sDsName))
|
|
|
|
m_xDatabaseContext->getByName(sDsName) >>= xSet;
|
2001-03-22 09:40:10 +00:00
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
if(xSet.is())
|
|
|
|
{
|
|
|
|
Reference<XNameContainer> xNames(xSet->getQueryDefinitions(),UNO_QUERY);
|
|
|
|
if(xNames.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-03-23 09:57:10 +00:00
|
|
|
xNames->removeByName(sName);
|
2001-03-22 09:40:10 +00:00
|
|
|
}
|
|
|
|
catch(SQLException& e)
|
|
|
|
{
|
|
|
|
showError(SQLExceptionInfo(e));
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
2001-03-23 09:57:10 +00:00
|
|
|
DBG_ERROR("SbaTableQueryBrowser::implRemoveQuery: caught a generic exception!");
|
2001-03-22 09:40:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SbaTableQueryBrowser::implDropTable( SvLBoxEntry* _pApplyTo )
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard(m_aEntryMutex);
|
|
|
|
Reference<XConnection> xConnection; // supports the service sdb::connection
|
|
|
|
if(!ensureConnection(_pApplyTo, xConnection))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// get all needed properties for design
|
|
|
|
Reference<XTablesSupplier> xSup(xConnection,UNO_QUERY);
|
|
|
|
OSL_ENSURE(xSup.is(),"SbaTableQueryBrowser::implDropTable: no XTablesSuppier!");
|
|
|
|
if(!xSup.is())
|
|
|
|
return;
|
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
::rtl::OUString sTableName = GetEntryText( _pApplyTo );
|
2001-03-22 09:40:10 +00:00
|
|
|
|
|
|
|
Reference<XNameAccess> xTables = xSup->getTables();
|
|
|
|
Reference<XDrop> xDrop(xTables,UNO_QUERY);
|
|
|
|
if(xDrop.is())
|
|
|
|
{
|
|
|
|
String aMsg(ModuleRes(STR_QUERY_DELETE_TABLE));
|
|
|
|
aMsg.SearchAndReplace(String::CreateFromAscii("%1"),String(sTableName));
|
|
|
|
OSQLMessageBox aDlg(getBrowserView()->getVclControl(),String(ModuleRes(STR_TITLE_CONFIRM_DELETION )),aMsg,WB_YES_NO | WB_DEF_YES,OSQLMessageBox::Query);
|
|
|
|
if(aDlg.Execute() == RET_YES)
|
|
|
|
{
|
|
|
|
SQLExceptionInfo aErrorInfo;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xDrop->dropByName(sTableName);
|
|
|
|
}
|
|
|
|
catch(SQLContext& e) { aErrorInfo = e; }
|
|
|
|
catch(SQLWarning& e) { aErrorInfo = e; }
|
|
|
|
catch(SQLException& e) { aErrorInfo = e; }
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::implDropTable: suspicious exception caught!");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aErrorInfo.isValid())
|
|
|
|
showError(aErrorInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// TODO
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool SbaTableQueryBrowser::requestContextMenu( const CommandEvent& _rEvent )
|
2000-12-08 20:16:38 +00:00
|
|
|
{
|
2001-03-22 09:40:10 +00:00
|
|
|
Point aPosition;
|
|
|
|
SvLBoxEntry* pEntry = NULL;
|
|
|
|
SvLBoxEntry* pOldSelection = NULL;
|
|
|
|
if (_rEvent.IsMouseEvent())
|
|
|
|
{
|
|
|
|
aPosition = _rEvent.GetMousePosPixel();
|
|
|
|
// ensure that the entry which the user clicked at is selected
|
|
|
|
pEntry = m_pTreeView->getListBox()->GetEntry(aPosition);
|
|
|
|
if (pEntry && !m_pTreeView->getListBox()->IsSelected(pEntry))
|
|
|
|
{
|
|
|
|
pOldSelection = m_pTreeView->getListBox()->FirstSelected();
|
|
|
|
m_pTreeView->getListBox()->lockAutoSelect();
|
|
|
|
m_pTreeView->getListBox()->Select(pEntry);
|
|
|
|
m_pTreeView->getListBox()->unlockAutoSelect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// use the center of the current entry
|
|
|
|
pEntry = m_pTreeView->getListBox()->GetCurEntry();
|
|
|
|
OSL_ENSURE(pEntry,"No current entry!");
|
|
|
|
aPosition = m_pTreeView->getListBox()->GetEntryPos(pEntry);
|
|
|
|
aPosition.X() += m_pTreeView->getListBox()->GetOutputSizePixel().Width() / 2;
|
|
|
|
aPosition.Y() += m_pTreeView->getListBox()->GetEntryHeight() / 2;
|
|
|
|
}
|
2000-12-08 20:16:38 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
// disable entries according to the currently selected entry
|
2001-03-16 15:24:32 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
// does the datasource which the selected entry belongs to has an open connection ?
|
2001-03-29 06:09:53 +00:00
|
|
|
SvLBoxEntry* pDSEntry = NULL;
|
|
|
|
DBTreeListModel::DBTreeListUserData* pDSData = NULL;
|
|
|
|
if(pEntry)
|
|
|
|
{
|
|
|
|
pDSEntry = m_pTreeView->getListBox()->GetRootLevelParent(pEntry);
|
|
|
|
pDSData = pDSEntry
|
|
|
|
? static_cast<DBTreeListModel::DBTreeListUserData*>(pDSEntry->GetUserData())
|
|
|
|
: NULL;
|
|
|
|
}
|
2001-02-16 15:00:13 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
EntryType eType = pEntry ? getEntryType(pEntry) : ET_UNKNOWN;
|
|
|
|
EntryType eLeafType = ET_UNKNOWN;
|
2001-03-22 09:40:10 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
// get the popup menu to use
|
|
|
|
sal_uInt16 nMenuResId = MENU_BROWSER_DEFAULTCONTEXT;
|
|
|
|
if (pEntry && (ET_DATASOURCE != getEntryType(pEntry)))
|
|
|
|
{
|
|
|
|
switch (getEntryType(pEntry))
|
|
|
|
{
|
|
|
|
case ET_TABLE:
|
|
|
|
case ET_TABLE_CONTAINER:
|
|
|
|
nMenuResId = MENU_BROWSER_TABLECONTEXT;
|
|
|
|
eLeafType = ET_TABLE;
|
|
|
|
break;
|
2001-03-22 09:40:10 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
case ET_QUERY:
|
|
|
|
case ET_QUERY_CONTAINER:
|
|
|
|
nMenuResId = MENU_BROWSER_QUERYCONTEXT;
|
|
|
|
eLeafType = ET_QUERY;
|
|
|
|
break;
|
2001-03-22 09:40:10 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
case ET_BOOKMARK:
|
|
|
|
case ET_BOOKMARK_CONTAINER:
|
|
|
|
nMenuResId = MENU_BROWSER_BOOKMARKCONTEXT;
|
|
|
|
eLeafType = ET_BOOKMARK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-03-23 09:57:10 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
ModuleRes nMenuRes( nMenuResId );
|
|
|
|
PopupMenu aContextMenu( nMenuRes );
|
|
|
|
PopupMenu* pDynamicSubMenu = NULL;
|
2001-03-23 09:57:10 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
// enable menu entries
|
|
|
|
if (!pDSData || !pDSData->xObject.is())
|
|
|
|
{ // no -> disable the connection-related menu entries
|
|
|
|
aContextMenu.EnableItem(ID_TREE_CLOSE_CONN, sal_False);
|
|
|
|
aContextMenu.EnableItem(ID_TREE_REBUILD_CONN, sal_False);
|
2001-02-16 15:00:13 +00:00
|
|
|
}
|
2001-04-26 10:36:16 +00:00
|
|
|
|
|
|
|
if(pEntry)
|
2001-03-29 06:09:53 +00:00
|
|
|
{
|
2001-04-26 10:36:16 +00:00
|
|
|
switch (eLeafType)
|
|
|
|
{
|
|
|
|
// 1. for tables
|
|
|
|
case ET_TABLE:
|
|
|
|
{
|
|
|
|
// 1.2 pasting tables
|
|
|
|
sal_Bool bPasteAble = isTableFormat();
|
|
|
|
aContextMenu.EnableItem(ID_TREE_TABLE_PASTE, bPasteAble);
|
2001-03-29 06:09:53 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
// 1.3 actions on existing tables
|
|
|
|
aContextMenu.EnableItem(ID_TREE_TABLE_EDIT, ET_TABLE == eType);
|
|
|
|
aContextMenu.EnableItem(ID_TREE_TABLE_DELETE, ET_TABLE == eType);
|
|
|
|
aContextMenu.EnableItem(ID_TREE_TABLE_COPY, ET_TABLE == eType);
|
2001-03-29 06:09:53 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-03-29 06:09:53 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
// 2. for queries
|
|
|
|
case ET_QUERY:
|
|
|
|
{
|
|
|
|
// 2.2 actions on existing queries
|
|
|
|
aContextMenu.EnableItem(ID_TREE_QUERY_EDIT, ET_QUERY == eType);
|
|
|
|
aContextMenu.EnableItem(ID_TREE_QUERY_DELETE, ET_QUERY == eType);
|
|
|
|
aContextMenu.EnableItem(ID_TREE_QUERY_COPY, ET_QUERY == eType);
|
|
|
|
}
|
|
|
|
break;
|
2001-03-29 06:09:53 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
// 3. for bookmarks
|
|
|
|
case ET_BOOKMARK:
|
|
|
|
{
|
|
|
|
aContextMenu.EnableItem(ID_EDIT_LINK, ET_BOOKMARK == eType);
|
|
|
|
aContextMenu.EnableItem(ID_DROP_LINK, ET_BOOKMARK == eType);
|
|
|
|
aContextMenu.EnableItem(ID_OPEN_DOCUMENT, ET_BOOKMARK == eType);
|
|
|
|
aContextMenu.EnableItem(ID_EDIT_DOCUMENT, ET_BOOKMARK == eType);
|
2001-03-29 06:09:53 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
pDynamicSubMenu = new PopupMenu(ModuleRes(RID_NEW_FORM));
|
|
|
|
aContextMenu.SetPopupMenu(ID_CREATE_NEW_DOC, pDynamicSubMenu);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2001-03-29 06:09:53 +00:00
|
|
|
}
|
2001-02-16 15:00:13 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
// rebuild conn not implemented yet
|
|
|
|
aContextMenu.EnableItem(ID_TREE_REBUILD_CONN, sal_False);
|
2001-03-16 15:24:32 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
if (!m_xMultiServiceFacatory.is())
|
|
|
|
// no ORB -> no administration dialog
|
|
|
|
aContextMenu.EnableItem(ID_TREE_ADMINISTRATE, sal_False);
|
2001-03-16 15:24:32 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
// no disabled entries
|
|
|
|
aContextMenu.RemoveDisabledEntries();
|
2001-03-16 15:24:32 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
sal_Bool bReopenConn = sal_False;
|
|
|
|
USHORT nPos = aContextMenu.Execute(m_pTreeView->getListBox(), aPosition);
|
2001-03-16 15:24:32 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
delete pDynamicSubMenu;
|
|
|
|
pDynamicSubMenu = NULL;
|
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
// restore the old selection
|
|
|
|
if (pOldSelection)
|
|
|
|
{
|
|
|
|
m_pTreeView->getListBox()->lockAutoSelect();
|
|
|
|
m_pTreeView->getListBox()->Select(pOldSelection);
|
|
|
|
m_pTreeView->getListBox()->unlockAutoSelect();
|
|
|
|
}
|
2001-03-16 15:24:32 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
switch (nPos)
|
2001-03-16 15:24:32 +00:00
|
|
|
{
|
2001-03-22 09:40:10 +00:00
|
|
|
case ID_TREE_ADMINISTRATE:
|
|
|
|
implAdministrate(pEntry);
|
|
|
|
break;
|
2001-03-23 09:57:10 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
case ID_TREE_REBUILD_CONN:
|
|
|
|
bReopenConn = sal_True;
|
2001-03-23 09:57:10 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
case ID_TREE_CLOSE_CONN:
|
|
|
|
closeConnection(pDSEntry);
|
|
|
|
break;
|
2001-03-23 09:57:10 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
case ID_TREE_RELATION_DESIGN:
|
|
|
|
case ID_TREE_TABLE_CREATE_DESIGN:
|
2001-04-24 13:36:44 +00:00
|
|
|
case ID_TREE_VIEW_CREATE_DESIGN:
|
2001-03-22 09:40:10 +00:00
|
|
|
case ID_TREE_QUERY_CREATE_DESIGN:
|
|
|
|
case ID_TREE_QUERY_CREATE_TEXT:
|
|
|
|
case ID_TREE_QUERY_EDIT:
|
|
|
|
case ID_TREE_TABLE_EDIT:
|
|
|
|
implCreateObject( pEntry, nPos );
|
|
|
|
break;
|
|
|
|
|
2001-03-23 09:57:10 +00:00
|
|
|
case ID_TREE_QUERY_DELETE:
|
2001-04-06 08:02:57 +00:00
|
|
|
implRemoveQuery( pEntry );
|
2001-03-22 09:40:10 +00:00
|
|
|
break;
|
2001-03-23 09:57:10 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
case ID_TREE_TABLE_DELETE:
|
2001-03-23 09:57:10 +00:00
|
|
|
implDropTable( pEntry );
|
|
|
|
break;
|
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
case ID_TREE_QUERY_COPY:
|
2001-04-11 05:48:19 +00:00
|
|
|
{
|
|
|
|
TransferableHelper* pTransfer = implCopyObject( pEntry, CommandType::QUERY );
|
|
|
|
Reference< XTransferable> aEnsureDelete = pTransfer;
|
|
|
|
if (pTransfer)
|
2001-05-07 13:09:01 +00:00
|
|
|
pTransfer->CopyToClipboard(getView());
|
2001-04-11 05:48:19 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-03-23 09:57:10 +00:00
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
case ID_TREE_TABLE_COPY:
|
2001-03-23 09:57:10 +00:00
|
|
|
{
|
|
|
|
TransferableHelper* pTransfer = implCopyObject( pEntry, CommandType::TABLE );
|
|
|
|
Reference< XTransferable> aEnsureDelete = pTransfer;
|
|
|
|
|
|
|
|
if (pTransfer)
|
2001-05-07 13:09:01 +00:00
|
|
|
pTransfer->CopyToClipboard(getView());
|
2001-03-23 09:57:10 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
case ID_TREE_TABLE_PASTE:
|
2001-03-23 09:57:10 +00:00
|
|
|
{
|
2001-05-07 13:09:01 +00:00
|
|
|
TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(getView()));
|
2001-03-23 09:57:10 +00:00
|
|
|
implPasteTable( pEntry, aTransferData );
|
|
|
|
}
|
|
|
|
break;
|
2001-04-26 10:36:16 +00:00
|
|
|
|
|
|
|
case ID_NEW_LINK:
|
|
|
|
case ID_OPEN_DOCUMENT:
|
|
|
|
case ID_EDIT_DOCUMENT:
|
|
|
|
case ID_EDIT_LINK:
|
|
|
|
case ID_DROP_LINK:
|
|
|
|
case ID_FORM_NEW_TEXT:
|
|
|
|
case ID_FORM_NEW_CALC:
|
|
|
|
case ID_FORM_NEW_IMPRESS:
|
|
|
|
case ID_FORM_NEW_PILOT:
|
|
|
|
case ID_FORM_NEW_TEMPLATE:
|
|
|
|
{
|
|
|
|
// get the container of the bookmarks
|
|
|
|
SvLBoxEntry* pContainer = isContainer(pEntry) ? pEntry : m_pTreeView->getListBox()->GetParent(pEntry);
|
|
|
|
if (!ensureEntryObject(pContainer))
|
|
|
|
break;
|
|
|
|
|
|
|
|
String sSelectedObject = GetEntryText(pEntry);
|
|
|
|
|
|
|
|
DBTreeListModel::DBTreeListUserData* pContainerData = static_cast<DBTreeListModel::DBTreeListUserData*>(pContainer->GetUserData());
|
|
|
|
Reference< XNameAccess > xBookmarks(pContainerData->xObject, UNO_QUERY);
|
|
|
|
|
|
|
|
OLinkedDocumentsAccess aHelper(getView(), getORB(), xBookmarks);
|
|
|
|
|
|
|
|
switch (nPos)
|
|
|
|
{
|
|
|
|
case ID_NEW_LINK:
|
|
|
|
aHelper.addLinkUI();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_OPEN_DOCUMENT:
|
|
|
|
aHelper.open(sSelectedObject, sal_True);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_EDIT_DOCUMENT:
|
|
|
|
aHelper.open(sSelectedObject, sal_False);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_EDIT_LINK:
|
|
|
|
{
|
|
|
|
::rtl::OUString sNewName, sNewLocation;
|
|
|
|
aHelper.edit(sSelectedObject, sNewName, sNewLocation);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_DROP_LINK:
|
|
|
|
aHelper.drop(sSelectedObject);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_FORM_NEW_TEXT:
|
|
|
|
case ID_FORM_NEW_CALC:
|
|
|
|
case ID_FORM_NEW_IMPRESS:
|
|
|
|
case ID_FORM_NEW_PILOT:
|
|
|
|
case ID_FORM_NEW_TEMPLATE:
|
|
|
|
aHelper.newForm(nPos);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DBG_ERROR("SbaTableQueryBrowser::requestContextMenu: invalid menu id!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2001-03-16 15:24:32 +00:00
|
|
|
}
|
|
|
|
|
2001-03-22 09:40:10 +00:00
|
|
|
return sal_True; // handled
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-04-26 10:36:16 +00:00
|
|
|
SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getChildType( SvLBoxEntry* _pEntry )
|
2001-03-23 09:57:10 +00:00
|
|
|
{
|
2001-04-26 10:36:16 +00:00
|
|
|
DBG_ASSERT(isContainer(_pEntry), "SbaTableQueryBrowser::getChildType: invalid entry!");
|
|
|
|
switch (getEntryType(_pEntry))
|
|
|
|
{
|
|
|
|
case ET_TABLE_CONTAINER:
|
|
|
|
return ET_TABLE;
|
|
|
|
case ET_QUERY_CONTAINER:
|
|
|
|
return ET_QUERY;
|
|
|
|
case ET_BOOKMARK_CONTAINER:
|
|
|
|
return ET_BOOKMARK;
|
|
|
|
}
|
|
|
|
return ET_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
String SbaTableQueryBrowser::GetEntryText( SvLBoxEntry* _pEntry )
|
|
|
|
{
|
|
|
|
return m_pTreeView->getListBox()->GetEntryText(_pEntry);
|
2001-03-23 09:57:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType( SvLBoxEntry* _pEntry )
|
2001-03-22 09:40:10 +00:00
|
|
|
{
|
2001-03-23 09:57:10 +00:00
|
|
|
if (!_pEntry)
|
|
|
|
return ET_UNKNOWN;
|
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
SvLBoxEntry* pRootEntry = m_pTreeView->getListBox()->GetRootLevelParent(_pEntry);
|
|
|
|
SvLBoxEntry* pEntryParent = m_pTreeView->getListBox()->GetParent(_pEntry);
|
|
|
|
SvLBoxEntry* pTables = m_pTreeView->getListBox()->GetEntry(pRootEntry, CONTAINER_TABLES);
|
|
|
|
SvLBoxEntry* pQueries = m_pTreeView->getListBox()->GetEntry(pRootEntry, CONTAINER_QUERIES);
|
|
|
|
SvLBoxEntry* pBookmarks = m_pTreeView->getListBox()->GetEntry(pRootEntry, CONTAINER_BOOKMARKS);
|
|
|
|
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
String sTest;
|
|
|
|
if (pTables) sTest = m_pTreeView->getListBox()->GetEntryText(pTables);
|
|
|
|
if (pQueries) sTest = m_pTreeView->getListBox()->GetEntryText(pQueries);
|
|
|
|
if (pBookmarks) sTest = m_pTreeView->getListBox()->GetEntryText(pBookmarks);
|
|
|
|
#endif
|
2001-03-23 09:57:10 +00:00
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
if (pRootEntry == _pEntry)
|
2001-03-23 09:57:10 +00:00
|
|
|
return ET_DATASOURCE;
|
|
|
|
|
|
|
|
if (pTables == _pEntry)
|
|
|
|
return ET_TABLE_CONTAINER;
|
|
|
|
|
|
|
|
if (pQueries == _pEntry)
|
|
|
|
return ET_QUERY_CONTAINER;
|
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
if (pBookmarks == _pEntry)
|
|
|
|
return ET_BOOKMARK_CONTAINER;
|
|
|
|
|
2001-03-23 09:57:10 +00:00
|
|
|
if (pTables == pEntryParent)
|
|
|
|
return ET_TABLE;
|
|
|
|
|
|
|
|
if (pQueries == pEntryParent)
|
|
|
|
return ET_QUERY;
|
|
|
|
|
2001-04-26 10:36:16 +00:00
|
|
|
if (pBookmarks == pEntryParent)
|
|
|
|
return ET_BOOKMARK;
|
|
|
|
|
2001-03-23 09:57:10 +00:00
|
|
|
return ET_UNKNOWN;
|
2001-03-16 15:24:32 +00:00
|
|
|
}
|
|
|
|
|
2000-11-09 06:34:47 +00:00
|
|
|
// .........................................................................
|
|
|
|
} // namespace dbaui
|
|
|
|
// .........................................................................
|
|
|
|
|
2000-10-26 13:46:14 +00:00
|
|
|
|