2004-08-02 14:28:11 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 12:52:31 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-08-02 14:28:11 +00:00
|
|
|
*
|
2008-04-10 12:52:31 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2004-08-02 14:28:11 +00:00
|
|
|
*
|
2008-04-10 12:52:31 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-08-02 14:28:11 +00:00
|
|
|
*
|
2008-04-10 12:52:31 +00:00
|
|
|
* $RCSfile: AppController.cxx,v $
|
2008-10-01 12:28:29 +00:00
|
|
|
* $Revision: 1.63.20.5 $
|
2004-08-02 14:28:11 +00:00
|
|
|
*
|
2008-04-10 12:52:31 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-08-02 14:28:11 +00:00
|
|
|
*
|
2008-04-10 12:52:31 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-08-02 14:28:11 +00:00
|
|
|
*
|
2008-04-10 12:52:31 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-08-02 14:28:11 +00:00
|
|
|
*
|
2008-04-10 12:52:31 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-08-02 14:28:11 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 05:53:49 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
#include "AppController.hxx"
|
|
|
|
#include "dbustrings.hrc"
|
2007-11-01 14:03:13 +00:00
|
|
|
#include "advancedsettingsdlg.hxx"
|
|
|
|
|
2005-10-24 07:30:07 +00:00
|
|
|
/** === begin UNO includes === **/
|
2008-03-06 17:09:10 +00:00
|
|
|
#include <com/sun/star/beans/NamedValue.hpp>
|
2004-08-02 14:28:11 +00:00
|
|
|
#include <com/sun/star/container/XChild.hpp>
|
|
|
|
#include <com/sun/star/container/XContainer.hpp>
|
2007-07-06 06:57:53 +00:00
|
|
|
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
|
2008-03-06 17:09:10 +00:00
|
|
|
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
|
|
|
|
#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
|
|
|
|
#include <com/sun/star/container/XNameContainer.hpp>
|
|
|
|
#include <com/sun/star/frame/FrameSearchFlag.hpp>
|
|
|
|
#include <com/sun/star/frame/XStorable.hpp>
|
2004-08-02 14:28:11 +00:00
|
|
|
#include <com/sun/star/sdb/CommandType.hpp>
|
|
|
|
#include <com/sun/star/sdb/SQLContext.hpp>
|
2008-03-06 17:09:10 +00:00
|
|
|
#include <com/sun/star/sdb/XBookmarksSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
|
2004-08-02 14:28:11 +00:00
|
|
|
#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
|
2008-03-06 17:09:10 +00:00
|
|
|
#include <com/sun/star/sdbc/XDataSource.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XAlterView.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XAppend.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XRename.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
|
|
|
|
#include <com/sun/star/uno/XNamingService.hpp>
|
2005-10-24 07:30:07 +00:00
|
|
|
#include <com/sun/star/util/XFlushable.hpp>
|
2008-03-06 17:09:10 +00:00
|
|
|
#include <com/sun/star/util/XModifiable.hpp>
|
|
|
|
#include <com/sun/star/util/XModifyBroadcaster.hpp>
|
|
|
|
#include <com/sun/star/util/XNumberFormatter.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
|
|
|
|
#include <com/sun/star/document/XEmbeddedScripts.hpp>
|
|
|
|
#include <com/sun/star/frame/XModel2.hpp>
|
2008-04-04 13:53:36 +00:00
|
|
|
#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
|
|
|
|
#include <com/sun/star/util/XModifyBroadcaster.hpp>
|
|
|
|
#include <com/sun/star/util/XModifiable.hpp>
|
|
|
|
#include <com/sun/star/frame/FrameSearchFlag.hpp>
|
|
|
|
#include <com/sun/star/util/XFlushable.hpp>
|
|
|
|
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
|
|
|
|
#include "com/sun/star/beans/NamedValue.hpp"
|
|
|
|
#include <com/sun/star/awt/XTopWindow.hpp>
|
2008-06-06 13:06:49 +00:00
|
|
|
#include <com/sun/star/task/XInteractionHandler.hpp>
|
2008-06-25 11:35:22 +00:00
|
|
|
#include <com/sun/star/sdb/application/DatabaseObject.hpp>
|
|
|
|
#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
|
2008-10-16 06:57:26 +00:00
|
|
|
#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
|
2005-10-24 07:30:07 +00:00
|
|
|
/** === end UNO includes === **/
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
2006-06-20 01:53:25 +00:00
|
|
|
#ifndef TOOLS_DIAGNOSE_EX_H
|
|
|
|
#include <tools/diagnose_ex.h>
|
|
|
|
#endif
|
2004-08-02 14:28:11 +00:00
|
|
|
#ifndef SVTOOLS_URIHELPER_HXX
|
|
|
|
#include <svtools/urihelper.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COMPHELPER_TYPES_HXX_
|
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
#endif
|
2008-06-06 13:06:49 +00:00
|
|
|
#ifndef _COMPHELPER_INTERACTION_HXX_
|
|
|
|
#include <comphelper/interaction.hxx>
|
|
|
|
#endif
|
2008-03-06 17:09:10 +00:00
|
|
|
#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
|
|
|
|
#include <comphelper/componentcontext.hxx>
|
|
|
|
#endif
|
2004-08-02 14:28:11 +00:00
|
|
|
#ifndef _SV_MSGBOX_HXX
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#endif
|
2008-03-06 17:09:10 +00:00
|
|
|
#ifndef _VCL_STDTEXT_HXX
|
|
|
|
#include <vcl/stdtext.hxx>
|
|
|
|
#endif
|
2004-08-02 14:28:11 +00:00
|
|
|
#ifndef _FILEDLGHELPER_HXX
|
|
|
|
#include <sfx2/filedlghelper.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
|
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
|
|
|
#endif
|
2008-05-05 14:51:14 +00:00
|
|
|
#ifndef _CPPUHELPER_EXC_HLP_HXX_
|
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
|
|
|
#endif
|
2004-08-02 14:28:11 +00:00
|
|
|
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
|
|
|
|
#include <connectivity/dbtools.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_APPVIEW_HXX
|
|
|
|
#include "AppView.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_UI_BROWSER_ID_HXX
|
|
|
|
#include "browserids.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBAU_REGHELPER_HXX_
|
|
|
|
#include "dbu_reghelper.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBU_APP_HRC_
|
|
|
|
#include "dbu_app.hrc"
|
|
|
|
#endif
|
2006-07-10 14:22:12 +00:00
|
|
|
#ifndef DBACCESS_SOURCE_UI_MISC_DEFAULTOBJECTNAMECHECK_HXX
|
|
|
|
#include "defaultobjectnamecheck.hxx"
|
|
|
|
#endif
|
2004-08-02 14:28:11 +00:00
|
|
|
#ifndef _SV_MENU_HXX
|
|
|
|
#include <vcl/menu.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
|
|
|
|
#include <svtools/pathoptions.hxx>
|
|
|
|
#endif
|
2005-01-21 16:05:05 +00:00
|
|
|
#ifndef INCLUDED_SVTOOLS_INTERNALOPTIONS_HXX
|
|
|
|
#include <svtools/internaloptions.hxx>
|
|
|
|
#endif
|
2004-08-02 14:28:11 +00:00
|
|
|
#ifndef _COMPHELPER_UNO3_HXX_
|
|
|
|
#include <comphelper/uno3.hxx>
|
|
|
|
#endif
|
2006-10-05 11:59:07 +00:00
|
|
|
#ifndef DBACCESS_DATABASE_OBJECT_VIEW_HXX
|
|
|
|
#include "databaseobjectview.hxx"
|
2004-08-02 14:28:11 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _SV_SVAPP_HXX //autogen
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVLBOXITM_HXX
|
|
|
|
#include <svtools/svlbitm.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DBAUI_LISTVIEWITEMS_HXX_
|
|
|
|
#include "listviewitems.hxx"
|
|
|
|
#endif
|
2007-08-03 11:47:47 +00:00
|
|
|
#include "ExtensionNotPresent.hxx"
|
2004-08-02 14:28:11 +00:00
|
|
|
#ifndef DBAUI_APPDETAILVIEW_HXX
|
|
|
|
#include "AppDetailView.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBAUI_LINKEDDOCUMENTS_HXX_
|
|
|
|
#include "linkeddocuments.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_LSTBOX_HXX
|
|
|
|
#include <vcl/lstbox.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DBHELPER_DBEXCEPTION_HXX_
|
|
|
|
#include <connectivity/dbexception.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DBAUI_SQLMESSAGE_HXX_
|
|
|
|
#include "sqlmessage.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _STRING_HXX
|
|
|
|
#include <tools/string.hxx>
|
|
|
|
#endif
|
2005-01-21 16:05:05 +00:00
|
|
|
#ifndef INCLUDED_SFX_MAILMODELAPI_HXX
|
|
|
|
#include <sfx2/mailmodelapi.hxx>
|
|
|
|
#endif
|
2004-08-02 14:28:11 +00:00
|
|
|
#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
|
|
|
|
#include <svtools/moduleoptions.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVTREEBOX_HXX
|
|
|
|
#include <svtools/svtreebx.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _TRANSFER_HXX
|
|
|
|
#include <svtools/transfer.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _CLIPLISTENER_HXX
|
|
|
|
#include <svtools/cliplistener.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVX_DBAEXCHANGE_HXX_
|
|
|
|
#include <svx/dbaexchange.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef SVX_DBAOBJECTEX_HXX
|
|
|
|
#include <svx/dbaobjectex.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_TOOLS_HXX
|
|
|
|
#include "UITools.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBAUI_DSNTYPES_HXX_
|
|
|
|
#include "dsntypes.hxx"
|
|
|
|
#endif
|
2007-09-11 09:33:21 +00:00
|
|
|
#include <svx/svxdlg.hxx>
|
|
|
|
#include <svtools/insdlg.hxx>
|
2004-08-02 14:28:11 +00:00
|
|
|
#ifndef _UNOTOOLS_TEMPFILE_HXX
|
|
|
|
#include <unotools/tempfile.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_DBACCESS_HELPID_HRC_
|
|
|
|
#include "dbaccess_helpid.hrc"
|
|
|
|
#endif
|
|
|
|
#ifndef DBAUI_DLGSAVE_HXX
|
|
|
|
#include "dlgsave.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _SFX_DOCFILT_HACK_HXX
|
|
|
|
#include <sfx2/docfilt.hxx>
|
|
|
|
#endif
|
2004-11-17 14:25:08 +00:00
|
|
|
#ifndef SFX_QUERYSAVEDOCUMENT_HXX
|
|
|
|
#include <sfx2/QuerySaveDocument.hxx>
|
|
|
|
#endif
|
2004-08-02 14:28:11 +00:00
|
|
|
#ifndef INCLUDED_SVTOOLS_HISTORYOPTIONS_HXX
|
|
|
|
#include <svtools/historyoptions.hxx>
|
|
|
|
#endif
|
2004-11-17 14:25:08 +00:00
|
|
|
#ifndef SVTOOLS_FILENOTATION_HXX_
|
|
|
|
#include <svtools/filenotation.hxx>
|
|
|
|
#endif
|
2005-10-24 07:30:07 +00:00
|
|
|
#ifndef _COMPHELPER_SEQUENCE_HXX_
|
|
|
|
#include <comphelper/sequence.hxx>
|
|
|
|
#endif
|
2008-03-06 17:09:10 +00:00
|
|
|
#ifndef _VOS_MUTEX_HXX_
|
|
|
|
#include <vos/mutex.hxx>
|
|
|
|
#endif
|
2004-10-27 11:55:51 +00:00
|
|
|
#ifndef _DBACCESS_SLOTID_HRC_
|
|
|
|
#include "dbaccess_slotid.hrc"
|
|
|
|
#endif
|
2008-03-06 17:09:10 +00:00
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <functional>
|
|
|
|
|
2008-06-25 11:35:22 +00:00
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
extern "C" void SAL_CALL createRegistryInfo_ODBApplication()
|
|
|
|
{
|
|
|
|
static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OApplicationController > aAutoRegistration;
|
|
|
|
}
|
|
|
|
//........................................................................
|
|
|
|
namespace dbaui
|
|
|
|
{
|
|
|
|
//........................................................................
|
|
|
|
using namespace ::dbtools;
|
|
|
|
using namespace ::svx;
|
2008-04-04 13:53:36 +00:00
|
|
|
using namespace ::com::sun::star;
|
2004-08-02 14:28:11 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::ucb;
|
2007-09-26 13:46:26 +00:00
|
|
|
using namespace ::com::sun::star::view;
|
2004-08-02 14:28:11 +00:00
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::frame;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::datatransfer;
|
2008-03-06 17:09:10 +00:00
|
|
|
using namespace ::com::sun::star::ui::dialogs;
|
2008-06-06 13:06:49 +00:00
|
|
|
using namespace ::com::sun::star::task;
|
2008-03-06 17:09:10 +00:00
|
|
|
using ::com::sun::star::document::XEmbeddedScripts;
|
2008-10-16 06:57:26 +00:00
|
|
|
using ::com::sun::star::document::XDocumentEventBroadcaster;
|
|
|
|
using ::com::sun::star::document::DocumentEvent;
|
2008-06-25 11:35:22 +00:00
|
|
|
using ::com::sun::star::sdb::application::NamedDatabaseObject;
|
|
|
|
|
|
|
|
namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
|
|
|
|
namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
|
2004-08-02 14:28:11 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL OApplicationController::getImplementationName() throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return getImplementationName_Static();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString OApplicationController::getImplementationName_Static() throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return ::rtl::OUString(SERVICE_SDB_APPLICATIONCONTROLLER);
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Sequence< ::rtl::OUString> OApplicationController::getSupportedServiceNames_Static(void) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
Sequence< ::rtl::OUString> aSupported(1);
|
2008-06-25 11:35:22 +00:00
|
|
|
aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.application.DefaultViewController");
|
2004-08-02 14:28:11 +00:00
|
|
|
return aSupported;
|
|
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
Sequence< ::rtl::OUString> SAL_CALL OApplicationController::getSupportedServiceNames() throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return getSupportedServiceNames_Static();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
Reference< XInterface > SAL_CALL OApplicationController::Create(const Reference<XMultiServiceFactory >& _rxFactory)
|
|
|
|
{
|
|
|
|
return *(new OApplicationController(_rxFactory));
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct XContainerFunctor : public ::std::unary_function< OApplicationController::TContainerVector::value_type , bool>
|
|
|
|
{
|
|
|
|
Reference<XContainerListener> m_xContainerListener;
|
|
|
|
XContainerFunctor( const Reference<XContainerListener>& _xContainerListener)
|
|
|
|
: m_xContainerListener(_xContainerListener){}
|
|
|
|
|
|
|
|
bool operator() (const OApplicationController::TContainerVector::value_type& lhs) const
|
|
|
|
{
|
|
|
|
if ( lhs.is() )
|
|
|
|
lhs->removeContainerListener(m_xContainerListener);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-06-25 11:35:22 +00:00
|
|
|
//====================================================================
|
|
|
|
//= OApplicationController
|
|
|
|
//====================================================================
|
|
|
|
class SelectionNotifier : public ::boost::noncopyable
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
::cppu::OInterfaceContainerHelper m_aSelectionListeners;
|
|
|
|
::cppu::OWeakObject& m_rContext;
|
|
|
|
sal_Int32 m_nSelectionNestingLevel;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SelectionNotifier( ::osl::Mutex& _rMutex, ::cppu::OWeakObject& _rContext )
|
|
|
|
:m_aSelectionListeners( _rMutex )
|
|
|
|
,m_rContext( _rContext )
|
|
|
|
,m_nSelectionNestingLevel( 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void addListener( const Reference< XSelectionChangeListener >& _Listener )
|
|
|
|
{
|
|
|
|
m_aSelectionListeners.addInterface( _Listener );
|
|
|
|
}
|
|
|
|
|
|
|
|
void removeListener( const Reference< XSelectionChangeListener >& _Listener )
|
|
|
|
{
|
|
|
|
m_aSelectionListeners.removeInterface( _Listener );
|
|
|
|
}
|
|
|
|
|
|
|
|
void disposing()
|
|
|
|
{
|
|
|
|
EventObject aEvent( m_rContext );
|
|
|
|
m_aSelectionListeners.disposeAndClear( aEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
~SelectionNotifier()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SelectionGuardAccess { friend class SelectionGuard; private: SelectionGuardAccess() { } };
|
|
|
|
|
|
|
|
/** enters a block which modifies the selection of our owner.
|
|
|
|
|
|
|
|
Can be called multiple times, the only important thing is to call leaveSelection
|
|
|
|
equally often.
|
|
|
|
*/
|
|
|
|
void enterSelection( SelectionGuardAccess )
|
|
|
|
{
|
|
|
|
++m_nSelectionNestingLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** leaves a block which modifies the selection of our owner
|
|
|
|
|
|
|
|
Must be paired with enterSelection calls.
|
|
|
|
|
|
|
|
When the last block is left, i.e. the last leaveSelection call is made on the current stack,
|
|
|
|
then our SelectionChangeListeners are notified
|
|
|
|
*/
|
|
|
|
void leaveSelection( SelectionGuardAccess )
|
|
|
|
{
|
|
|
|
if ( --m_nSelectionNestingLevel == 0 )
|
|
|
|
{
|
|
|
|
EventObject aEvent( m_rContext );
|
|
|
|
m_aSelectionListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvent );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class SelectionGuard : public ::boost::noncopyable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SelectionGuard( SelectionNotifier& _rNotifier )
|
|
|
|
:m_rNotifier( _rNotifier )
|
|
|
|
{
|
|
|
|
m_rNotifier.enterSelection( SelectionNotifier::SelectionGuardAccess() );
|
|
|
|
}
|
|
|
|
|
|
|
|
~SelectionGuard()
|
|
|
|
{
|
|
|
|
m_rNotifier.leaveSelection( SelectionNotifier::SelectionGuardAccess() );
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SelectionNotifier& m_rNotifier;
|
|
|
|
};
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
//====================================================================
|
|
|
|
//= OApplicationController
|
|
|
|
//====================================================================
|
2005-09-23 11:14:21 +00:00
|
|
|
DBG_NAME(OApplicationController)
|
2004-08-02 14:28:11 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
OApplicationController::OApplicationController(const Reference< XMultiServiceFactory >& _rxORB)
|
|
|
|
:OApplicationController_CBASE( _rxORB )
|
2008-06-25 11:35:22 +00:00
|
|
|
,m_aContextMenuInterceptors( m_aMutex )
|
2006-06-20 01:53:25 +00:00
|
|
|
,m_aTableCopyHelper(this)
|
2004-08-02 14:28:11 +00:00
|
|
|
,m_pClipbordNotifier(NULL)
|
|
|
|
,m_nAsyncDrop(0)
|
2008-03-06 17:09:10 +00:00
|
|
|
,m_aControllerConnectedEvent( LINK( this, OApplicationController, OnFirstControllerConnected ) )
|
2008-06-25 11:35:22 +00:00
|
|
|
,m_aSelectContainerEvent( LINK( this, OApplicationController, OnSelectContainer ) )
|
2004-08-02 14:28:11 +00:00
|
|
|
,m_ePreviewMode(E_PREVIEWNONE)
|
2008-03-06 17:09:10 +00:00
|
|
|
,m_eCurrentType(E_NONE)
|
2006-06-20 01:53:25 +00:00
|
|
|
,m_bNeedToReconnect(sal_False)
|
|
|
|
,m_bSuspended( sal_False )
|
2008-06-25 11:35:22 +00:00
|
|
|
,m_pSelectionNotifier( new SelectionNotifier( m_aMutex, *this ) )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2005-09-23 11:14:21 +00:00
|
|
|
DBG_CTOR(OApplicationController,NULL);
|
|
|
|
|
2004-11-17 14:25:08 +00:00
|
|
|
m_aTypeCollection.initUserDriverTypes(_rxORB);
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
OApplicationController::~OApplicationController()
|
|
|
|
{
|
|
|
|
if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Please check who doesn't dispose this component!");
|
|
|
|
// increment ref count to prevent double call of Dtor
|
|
|
|
osl_incrementInterlockedCount( &m_refCount );
|
|
|
|
dispose();
|
|
|
|
}
|
|
|
|
::std::auto_ptr< Window> aTemp(m_pView);
|
|
|
|
m_pView = NULL;
|
2005-09-23 11:14:21 +00:00
|
|
|
|
|
|
|
DBG_DTOR(OApplicationController,NULL);
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
IMPLEMENT_FORWARD_XTYPEPROVIDER2(OApplicationController,OApplicationController_CBASE,OApplicationController_Base)
|
|
|
|
IMPLEMENT_FORWARD_XINTERFACE2(OApplicationController,OApplicationController_CBASE,OApplicationController_Base)
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-10-24 07:30:07 +00:00
|
|
|
void OApplicationController::disconnect()
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2005-10-24 07:30:07 +00:00
|
|
|
if ( m_xDataSourceConnection.is() )
|
|
|
|
stopConnectionListening( m_xDataSourceConnection );
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
try
|
|
|
|
{
|
2005-10-24 07:30:07 +00:00
|
|
|
// temporary (hopefully!) hack for #i55274#
|
|
|
|
Reference< XFlushable > xFlush( m_xDataSourceConnection, UNO_QUERY );
|
2006-01-31 17:40:35 +00:00
|
|
|
if ( xFlush.is() && m_xMetaData.is() && !m_xMetaData->isReadOnly() )
|
2005-10-24 07:30:07 +00:00
|
|
|
xFlush->flush();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2006-06-20 01:53:25 +00:00
|
|
|
catch( const Exception& )
|
2005-10-24 07:30:07 +00:00
|
|
|
{
|
2006-06-20 01:53:25 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2005-10-24 07:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_xDataSourceConnection.clear();
|
|
|
|
m_xMetaData.clear();
|
|
|
|
|
|
|
|
InvalidateAll();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2005-10-24 07:30:07 +00:00
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL OApplicationController::disposing()
|
|
|
|
{
|
2008-03-06 17:09:10 +00:00
|
|
|
m_aControllerConnectedEvent.CancelCall();
|
|
|
|
|
2005-01-21 16:05:05 +00:00
|
|
|
::std::for_each(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),XContainerFunctor(this));
|
|
|
|
m_aCurrentContainers.clear();
|
2008-04-04 13:53:36 +00:00
|
|
|
m_aSpecialSubFrames.clear();
|
2004-08-02 14:28:11 +00:00
|
|
|
m_aDocuments.clear();
|
2008-06-25 11:35:22 +00:00
|
|
|
m_pSelectionNotifier->disposing();
|
2004-08-02 14:28:11 +00:00
|
|
|
|
|
|
|
if ( getView() )
|
|
|
|
{
|
2004-10-22 08:03:49 +00:00
|
|
|
getContainer()->showPreview(NULL);
|
2004-08-02 14:28:11 +00:00
|
|
|
m_pClipbordNotifier->ClearCallbackLink();
|
|
|
|
m_pClipbordNotifier->AddRemoveListener( getView(), sal_False );
|
|
|
|
m_pClipbordNotifier->release();
|
|
|
|
m_pClipbordNotifier = NULL;
|
|
|
|
}
|
|
|
|
|
2005-10-24 07:30:07 +00:00
|
|
|
disconnect();
|
2004-08-02 14:28:11 +00:00
|
|
|
try
|
|
|
|
{
|
2005-03-10 15:43:10 +00:00
|
|
|
Reference < XFrame > xFrame;
|
|
|
|
attachFrame( xFrame );
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
if ( m_xDataSource.is() )
|
|
|
|
{
|
|
|
|
m_xDataSource->removePropertyChangeListener(::rtl::OUString(), this);
|
2008-01-29 07:51:32 +00:00
|
|
|
m_xDataSource->removePropertyChangeListener(PROPERTY_INFO, this);
|
|
|
|
m_xDataSource->removePropertyChangeListener(PROPERTY_URL, this);
|
|
|
|
m_xDataSource->removePropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED, this);
|
|
|
|
m_xDataSource->removePropertyChangeListener(PROPERTY_LAYOUTINFORMATION, this);
|
|
|
|
m_xDataSource->removePropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL, this);
|
|
|
|
m_xDataSource->removePropertyChangeListener(PROPERTY_TABLEFILTER, this);
|
|
|
|
m_xDataSource->removePropertyChangeListener(PROPERTY_TABLETYPEFILTER, this);
|
|
|
|
m_xDataSource->removePropertyChangeListener(PROPERTY_USER, this);
|
2005-03-10 15:43:10 +00:00
|
|
|
// otherwise we may delete our datasource twice
|
|
|
|
Reference<XPropertySet> xProp = m_xDataSource;
|
2004-08-02 14:28:11 +00:00
|
|
|
m_xDataSource = NULL;
|
|
|
|
}
|
2005-03-10 15:43:10 +00:00
|
|
|
|
2005-09-23 11:14:21 +00:00
|
|
|
Reference< XModifyBroadcaster > xBroadcaster( m_xModel, UNO_QUERY );
|
2005-03-10 15:43:10 +00:00
|
|
|
if ( xBroadcaster.is() )
|
|
|
|
xBroadcaster->removeModifyListener(static_cast<XModifyListener*>(this));
|
|
|
|
|
|
|
|
if ( m_xModel.is() )
|
|
|
|
{
|
|
|
|
::rtl::OUString sUrl = m_xModel->getURL();
|
|
|
|
if ( sUrl.getLength() )
|
|
|
|
{
|
2008-10-16 06:57:26 +00:00
|
|
|
::comphelper::NamedValueCollection aArgs( m_xModel->getArgs() );
|
|
|
|
if ( true == aArgs.getOrDefault( "PickListEntry", true ) )
|
|
|
|
{
|
|
|
|
::rtl::OUString aFilter;
|
|
|
|
INetURLObject aURL( m_xModel->getURL() );
|
|
|
|
const SfxFilter* pFilter = getStandardDatabaseFilter();
|
|
|
|
if ( pFilter )
|
|
|
|
aFilter = pFilter->GetFilterName();
|
|
|
|
|
|
|
|
// add to svtool history options
|
|
|
|
SvtHistoryOptions().AppendItem( ePICKLIST,
|
|
|
|
aURL.GetURLNoPass( INetURLObject::NO_DECODE ),
|
|
|
|
aFilter,
|
|
|
|
getStrippedDatabaseName(),
|
|
|
|
::rtl::OUString() );
|
|
|
|
}
|
2005-03-10 15:43:10 +00:00
|
|
|
}
|
|
|
|
|
2005-09-23 11:14:21 +00:00
|
|
|
m_aModelConnector.clear();
|
|
|
|
m_xModel.clear();
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
catch(Exception)
|
|
|
|
{
|
2008-10-16 06:57:26 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_pView = NULL;
|
2008-01-29 07:51:32 +00:00
|
|
|
OApplicationController_CBASE::disposing(); // here the m_refCount must be equal 5
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
sal_Bool OApplicationController::Construct(Window* _pParent)
|
|
|
|
{
|
2008-06-25 11:35:22 +00:00
|
|
|
m_pView = new OApplicationView( _pParent, getORB(), *this, m_ePreviewMode );
|
2004-08-02 14:28:11 +00:00
|
|
|
m_pView->SetUniqueId(UID_APP_VIEW);
|
2005-01-05 11:32:18 +00:00
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
// late construction
|
|
|
|
sal_Bool bSuccess = sal_False;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
getContainer()->Construct();
|
|
|
|
bSuccess = sal_True;
|
|
|
|
}
|
|
|
|
catch(SQLException&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
DBG_ERROR("OApplicationController::Construct : the construction of UnoDataBrowserView failed !");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bSuccess )
|
|
|
|
{
|
|
|
|
::std::auto_ptr< Window> aTemp(m_pView);
|
|
|
|
m_pView = NULL;
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG_ASSERT( getView(), "OApplicationController::Construct: have no view!" );
|
|
|
|
if ( getView() )
|
|
|
|
getView()->enableSeparator( );
|
|
|
|
|
|
|
|
// now that we have a view we can create the clipboard listener
|
|
|
|
m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
|
|
|
|
m_aSystemClipboard.StartClipboardListening( );
|
|
|
|
|
|
|
|
m_pClipbordNotifier = new TransferableClipboardListener( LINK( this, OApplicationController, OnClipboardChanged ) );
|
|
|
|
m_pClipbordNotifier->acquire();
|
|
|
|
m_pClipbordNotifier->AddRemoveListener( getView(), sal_True );
|
|
|
|
|
|
|
|
OApplicationController_CBASE::Construct( _pParent );
|
2005-01-05 11:32:18 +00:00
|
|
|
getView()->Show();
|
2004-08-02 14:28:11 +00:00
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL OApplicationController::disposing(const EventObject& _rSource) throw( RuntimeException )
|
|
|
|
{
|
2004-10-22 08:03:49 +00:00
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
2004-08-02 14:28:11 +00:00
|
|
|
Reference<XConnection> xCon(_rSource.Source, UNO_QUERY);
|
|
|
|
if ( xCon.is() )
|
|
|
|
{
|
2005-10-24 07:30:07 +00:00
|
|
|
DBG_ASSERT( ( m_xDataSourceConnection == xCon ) && getContainer() && ( getContainer()->getElementType() == E_TABLE ),
|
|
|
|
"OApplicationController::disposing: the below code will ignore this call - why?" );
|
|
|
|
|
2005-02-16 15:00:49 +00:00
|
|
|
if ( getContainer() && getContainer()->getElementType() == E_TABLE )
|
2008-01-29 13:07:00 +00:00
|
|
|
getContainer()->clearPages();
|
|
|
|
if ( m_xDataSourceConnection == xCon )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-01-29 13:07:00 +00:00
|
|
|
m_xMetaData.clear();
|
|
|
|
m_xDataSourceConnection.clear();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
2005-03-10 15:43:10 +00:00
|
|
|
else if ( _rSource.Source == m_xModel )
|
|
|
|
{
|
2005-09-23 11:14:21 +00:00
|
|
|
m_xModel.clear();
|
|
|
|
m_aModelConnector.clear();
|
2005-03-10 15:43:10 +00:00
|
|
|
}
|
|
|
|
else if ( _rSource.Source == m_xDataSource )
|
|
|
|
{
|
|
|
|
m_xDataSource = NULL;
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Reference<XComponent> xComp(_rSource.Source,UNO_QUERY);
|
2005-01-21 16:05:05 +00:00
|
|
|
Reference<XContainer> xContainer(_rSource.Source,UNO_QUERY);
|
|
|
|
if ( xComp.is() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2005-01-21 16:05:05 +00:00
|
|
|
TDocuments::iterator aFind = ::std::find_if(m_aDocuments.begin(),m_aDocuments.end(),
|
|
|
|
::std::compose1(::std::bind2nd(::std::equal_to<Reference<XComponent> >(),xComp),::std::select1st<TDocuments::value_type>()));
|
|
|
|
if ( aFind != m_aDocuments.end() )
|
|
|
|
m_aDocuments.erase(aFind);
|
2008-04-04 13:53:36 +00:00
|
|
|
|
|
|
|
TFrames::iterator aFind2 = ::std::find_if(m_aSpecialSubFrames.begin(),m_aSpecialSubFrames.end(),
|
|
|
|
::std::compose1(::std::bind2nd(::std::equal_to<Reference<XComponent> >(),xComp),
|
|
|
|
::std::compose1(::std::select2nd<TTypeFrame>(),::std::select2nd<TFrames::value_type>())));
|
|
|
|
if ( aFind2 != m_aSpecialSubFrames.end() )
|
|
|
|
m_aSpecialSubFrames.erase(aFind2);
|
|
|
|
|
2005-01-21 16:05:05 +00:00
|
|
|
}
|
2006-04-19 12:19:19 +00:00
|
|
|
if ( xContainer.is() )
|
2005-01-21 16:05:05 +00:00
|
|
|
{
|
|
|
|
TContainerVector::iterator aFind = ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer);
|
|
|
|
if ( aFind != m_aCurrentContainers.end() )
|
|
|
|
m_aCurrentContainers.erase(aFind);
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2006-04-19 12:19:19 +00:00
|
|
|
OApplicationController_CBASE::disposing( _rSource );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL OApplicationController::suspend(sal_Bool bSuspend) throw( RuntimeException )
|
|
|
|
{
|
2008-10-16 06:57:26 +00:00
|
|
|
// notify the OnPrepareViewClosing event (before locking any mutex)
|
|
|
|
Reference< XDocumentEventBroadcaster > xBroadcaster( m_xModel, UNO_QUERY );
|
|
|
|
if ( xBroadcaster.is() )
|
|
|
|
{
|
|
|
|
xBroadcaster->notifyDocumentEvent(
|
|
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnPrepareViewClosing" ) ),
|
|
|
|
this,
|
|
|
|
Any()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2004-10-22 08:03:49 +00:00
|
|
|
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
2006-04-19 12:19:19 +00:00
|
|
|
|
|
|
|
if ( getView() && getView()->IsInModalMode() )
|
|
|
|
return sal_False;
|
|
|
|
|
2005-04-06 08:47:41 +00:00
|
|
|
sal_Bool bCanSuspend = sal_True;
|
|
|
|
|
2005-02-17 10:05:43 +00:00
|
|
|
if ( m_bSuspended != bSuspend )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-03-06 17:09:10 +00:00
|
|
|
if ( bSuspend && !closeSubComponents() )
|
2005-02-17 10:05:43 +00:00
|
|
|
return sal_False;
|
|
|
|
|
2005-03-10 15:43:10 +00:00
|
|
|
Reference<XModifiable> xModi(m_xModel,UNO_QUERY);
|
2005-03-18 09:07:07 +00:00
|
|
|
Reference<XStorable> xStor(getModel(),UNO_QUERY);
|
|
|
|
|
2005-04-06 08:47:41 +00:00
|
|
|
if ( bSuspend
|
|
|
|
&& xStor.is()
|
2005-03-18 09:07:07 +00:00
|
|
|
&& !xStor->isReadonly()
|
2008-03-06 17:09:10 +00:00
|
|
|
&& ( xModi.is()
|
|
|
|
&& xModi->isModified()
|
2005-03-18 09:07:07 +00:00
|
|
|
)
|
|
|
|
)
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2005-02-17 10:05:43 +00:00
|
|
|
switch (ExecuteQuerySaveDocument(getView(),getStrippedDatabaseName()))
|
|
|
|
{
|
|
|
|
case RET_YES:
|
|
|
|
Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>());
|
2005-04-06 08:47:41 +00:00
|
|
|
bCanSuspend = !xModi->isModified();
|
|
|
|
// when we save the document this must be false else some press cancel
|
2005-02-17 10:05:43 +00:00
|
|
|
break;
|
|
|
|
case RET_CANCEL:
|
2005-04-06 08:47:41 +00:00
|
|
|
bCanSuspend = sal_False;
|
2005-02-17 10:05:43 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-06 08:47:41 +00:00
|
|
|
if ( bCanSuspend )
|
|
|
|
m_bSuspended = bSuspend;
|
|
|
|
|
|
|
|
return bCanSuspend;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
FeatureState OApplicationController::GetState(sal_uInt16 _nId) const
|
|
|
|
{
|
|
|
|
FeatureState aReturn;
|
|
|
|
aReturn.bEnabled = sal_False;
|
|
|
|
// check this first
|
2005-01-05 11:32:18 +00:00
|
|
|
if ( !getContainer() || m_bReadOnly )
|
2004-08-02 14:28:11 +00:00
|
|
|
return aReturn;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
switch (_nId)
|
|
|
|
{
|
2008-01-30 07:41:07 +00:00
|
|
|
case SID_OPENURL:
|
|
|
|
aReturn.bEnabled = sal_True;
|
|
|
|
if ( m_xModel.is() )
|
|
|
|
aReturn.sTitle = m_xModel->getURL();
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
case ID_BROWSER_COPY:
|
|
|
|
{
|
|
|
|
sal_Int32 nCount = getContainer()->getSelectionCount();
|
|
|
|
aReturn.bEnabled = nCount >= 1;
|
|
|
|
if ( aReturn.bEnabled && nCount == 1 && getContainer()->getElementType() == E_TABLE )
|
|
|
|
aReturn.bEnabled = getContainer()->isALeafSelected();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_BROWSER_CUT:
|
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() >= 1;
|
|
|
|
aReturn.bEnabled = aReturn.bEnabled && ( (ID_BROWSER_CUT == _nId && getContainer()->getElementType() == E_TABLE) ? getContainer()->isCutAllowed() : sal_True);
|
|
|
|
break;
|
|
|
|
case ID_BROWSER_PASTE:
|
|
|
|
switch( getContainer()->getElementType() )
|
|
|
|
{
|
|
|
|
case E_TABLE:
|
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly() && !isConnectionReadOnly() && isTableFormat();
|
|
|
|
break;
|
|
|
|
case E_QUERY:
|
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly() && getViewClipboard().HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY);
|
|
|
|
break;
|
|
|
|
default:
|
2005-09-23 11:14:21 +00:00
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly() && OComponentTransferable::canExtractComponentDescriptor(getViewClipboard().GetDataFlavorExVector(),getContainer()->getElementType() == E_FORM);
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_PASTE_SPECIAL:
|
|
|
|
aReturn.bEnabled = getContainer()->getElementType() == E_TABLE && !isDataSourceReadOnly() && !isConnectionReadOnly() && isTableFormat();
|
|
|
|
break;
|
|
|
|
case SID_OPENDOC:
|
|
|
|
case SID_HELP_INDEX:
|
|
|
|
aReturn.bEnabled = sal_True;
|
|
|
|
break;
|
|
|
|
case ID_BROWSER_SAVEDOC:
|
2008-03-06 17:09:10 +00:00
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly() && m_xDocumentModify.is() && m_xDocumentModify->isModified();
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case ID_BROWSER_SAVEASDOC:
|
|
|
|
aReturn.bEnabled = sal_True;
|
|
|
|
break;
|
|
|
|
case ID_BROWSER_SORTUP:
|
|
|
|
aReturn.bEnabled = getContainer()->isFilled() && getContainer()->getElementCount();
|
2006-07-10 14:22:12 +00:00
|
|
|
aReturn.bChecked = aReturn.bEnabled && getContainer()->isSortUp();
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case ID_BROWSER_SORTDOWN:
|
|
|
|
aReturn.bEnabled = getContainer()->isFilled() && getContainer()->getElementCount();
|
2006-07-10 14:22:12 +00:00
|
|
|
aReturn.bChecked = aReturn.bEnabled && !getContainer()->isSortUp();
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SID_NEWDOC:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_APP_NEW_FORM:
|
2004-08-02 14:28:11 +00:00
|
|
|
case ID_DOCUMENT_CREATE_REPWIZ:
|
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly() && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER);
|
|
|
|
break;
|
2007-07-06 06:57:53 +00:00
|
|
|
case SID_APP_NEW_REPORT:
|
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly()
|
|
|
|
&& SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER);
|
|
|
|
if ( aReturn.bEnabled )
|
|
|
|
{
|
|
|
|
Reference< XContentEnumerationAccess > xEnumAccess(m_xServiceFactory, UNO_QUERY);
|
|
|
|
aReturn.bEnabled = xEnumAccess.is();
|
|
|
|
if ( aReturn.bEnabled )
|
|
|
|
{
|
2008-01-29 13:07:00 +00:00
|
|
|
const ::rtl::OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(m_xServiceFactory);
|
|
|
|
aReturn.bEnabled = sReportEngineServiceName.getLength() != 0;
|
|
|
|
if ( aReturn.bEnabled )
|
|
|
|
{
|
|
|
|
const Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(sReportEngineServiceName);
|
|
|
|
aReturn.bEnabled = xEnumDrivers.is() && xEnumDrivers->hasMoreElements();
|
|
|
|
}
|
2007-07-06 06:57:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
case SID_DB_APP_VIEW_TABLES:
|
|
|
|
aReturn.bEnabled = sal_True;
|
2006-07-10 14:22:12 +00:00
|
|
|
aReturn.bChecked = getContainer()->getElementType() == E_TABLE;
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_VIEW_QUERIES:
|
|
|
|
aReturn.bEnabled = sal_True;
|
2006-07-10 14:22:12 +00:00
|
|
|
aReturn.bChecked = getContainer()->getElementType() == E_QUERY;
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_VIEW_FORMS:
|
|
|
|
aReturn.bEnabled = sal_True;
|
2006-07-10 14:22:12 +00:00
|
|
|
aReturn.bChecked = getContainer()->getElementType() == E_FORM;
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_VIEW_REPORTS:
|
|
|
|
aReturn.bEnabled = sal_True;
|
2006-07-10 14:22:12 +00:00
|
|
|
aReturn.bChecked = getContainer()->getElementType() == E_REPORT;
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case ID_NEW_QUERY_DESIGN:
|
|
|
|
case ID_NEW_QUERY_SQL:
|
|
|
|
case ID_APP_NEW_QUERY_AUTO_PILOT:
|
2004-11-17 14:25:08 +00:00
|
|
|
case SID_DB_FORM_NEW_PILOT:
|
2004-08-02 14:28:11 +00:00
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly();
|
|
|
|
break;
|
|
|
|
case ID_NEW_VIEW_DESIGN:
|
2004-11-17 14:25:08 +00:00
|
|
|
case SID_DB_NEW_VIEW_SQL:
|
2004-08-02 14:28:11 +00:00
|
|
|
case ID_NEW_VIEW_DESIGN_AUTO_PILOT:
|
2005-01-05 11:32:18 +00:00
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly() && !isConnectionReadOnly();
|
|
|
|
if ( aReturn.bEnabled )
|
|
|
|
{
|
2005-10-24 07:30:07 +00:00
|
|
|
Reference<XViewsSupplier> xViewsSup( getConnection(), UNO_QUERY );
|
2005-01-05 11:32:18 +00:00
|
|
|
aReturn.bEnabled = xViewsSup.is();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_NEW_TABLE_DESIGN:
|
|
|
|
case ID_NEW_TABLE_DESIGN_AUTO_PILOT:
|
2004-08-02 14:28:11 +00:00
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly() && !isConnectionReadOnly();
|
|
|
|
break;
|
|
|
|
case ID_DIRECT_SQL:
|
2005-01-21 16:05:05 +00:00
|
|
|
aReturn.bEnabled = sal_True;
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
2008-03-06 17:09:10 +00:00
|
|
|
case ID_MIGRATE_SCRIPTS:
|
|
|
|
{
|
|
|
|
// Our document supports embedding scripts into it, if and only if there are no
|
|
|
|
// forms/reports with macros/scripts into them. So, we need to enable migration
|
|
|
|
// if and only if the database document does *not* support embedding scripts.
|
2008-10-16 06:57:26 +00:00
|
|
|
bool bAvailable =
|
|
|
|
!Reference< XEmbeddedScripts >( m_xModel, UNO_QUERY ).is()
|
|
|
|
&& !Reference< XStorable >( m_xModel, UNO_QUERY_THROW )->isReadonly();
|
2008-03-06 17:09:10 +00:00
|
|
|
aReturn.bEnabled = bAvailable;
|
|
|
|
if ( !bAvailable )
|
|
|
|
aReturn.bInvisible = true;
|
|
|
|
}
|
|
|
|
break;
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_APP_NEW_FOLDER:
|
2004-08-02 14:28:11 +00:00
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() <= 1;
|
|
|
|
if ( aReturn.bEnabled )
|
|
|
|
{
|
2007-09-26 13:46:26 +00:00
|
|
|
const ElementType eType = getContainer()->getElementType();
|
2004-08-02 14:28:11 +00:00
|
|
|
aReturn.bEnabled = eType == E_REPORT || eType == E_FORM;
|
|
|
|
}
|
|
|
|
break;
|
2004-11-09 11:26:30 +00:00
|
|
|
case SID_FORM_CREATE_REPWIZ_PRE_SEL:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
|
2007-11-20 18:22:51 +00:00
|
|
|
case SID_APP_NEW_REPORT_PRE_SEL:
|
2004-08-02 14:28:11 +00:00
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly()
|
|
|
|
&& SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER)
|
|
|
|
&& getContainer()->isALeafSelected();
|
|
|
|
if ( aReturn.bEnabled )
|
|
|
|
{
|
|
|
|
ElementType eType = getContainer()->getElementType();
|
|
|
|
aReturn.bEnabled = eType == E_QUERY || eType == E_TABLE;
|
2007-11-20 18:22:51 +00:00
|
|
|
if ( aReturn.bEnabled && SID_APP_NEW_REPORT_PRE_SEL == _nId )
|
|
|
|
{
|
|
|
|
Reference< XContentEnumerationAccess > xEnumAccess(m_xServiceFactory, UNO_QUERY);
|
|
|
|
aReturn.bEnabled = xEnumAccess.is();
|
|
|
|
if ( aReturn.bEnabled )
|
|
|
|
{
|
|
|
|
static ::rtl::OUString s_sReportDesign(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOReportJobFactory"));
|
|
|
|
Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(s_sReportDesign);
|
|
|
|
aReturn.bEnabled = xEnumDrivers.is() && xEnumDrivers->hasMoreElements();
|
|
|
|
}
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_DELETE:
|
|
|
|
case SID_DB_APP_RENAME:
|
2004-09-09 08:38:28 +00:00
|
|
|
aReturn.bEnabled = isRenameDeleteAllowed(getContainer()->getElementType(), _nId == SID_DB_APP_DELETE);
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_TABLE_DELETE:
|
|
|
|
case SID_DB_APP_TABLE_RENAME:
|
|
|
|
aReturn.bEnabled = isRenameDeleteAllowed(E_TABLE, _nId == SID_DB_APP_TABLE_DELETE);
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_QUERY_DELETE:
|
|
|
|
case SID_DB_APP_QUERY_RENAME:
|
|
|
|
aReturn.bEnabled = isRenameDeleteAllowed(E_QUERY, _nId == SID_DB_APP_QUERY_DELETE);
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_DB_APP_FORM_DELETE:
|
|
|
|
case SID_DB_APP_FORM_RENAME:
|
|
|
|
aReturn.bEnabled = isRenameDeleteAllowed(E_FORM, _nId == SID_DB_APP_FORM_DELETE);
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_REPORT_DELETE:
|
|
|
|
case SID_DB_APP_REPORT_RENAME:
|
|
|
|
aReturn.bEnabled = isRenameDeleteAllowed(E_REPORT, _nId == SID_DB_APP_REPORT_DELETE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SID_SELECTALL:
|
2004-08-02 14:28:11 +00:00
|
|
|
aReturn.bEnabled = getContainer()->getElementCount() > 0 && getContainer()->getSelectionCount() != getContainer()->getElementCount();
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_EDIT:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_DB_APP_TABLE_EDIT:
|
|
|
|
case SID_DB_APP_QUERY_EDIT:
|
|
|
|
case SID_DB_APP_FORM_EDIT:
|
|
|
|
case SID_DB_APP_REPORT_EDIT:
|
2004-08-02 14:28:11 +00:00
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() > 0
|
|
|
|
&& getContainer()->isALeafSelected();
|
|
|
|
break;
|
2006-12-13 15:46:18 +00:00
|
|
|
case SID_DB_APP_EDIT_SQL_VIEW:
|
2007-11-21 15:57:49 +00:00
|
|
|
if ( isDataSourceReadOnly() )
|
|
|
|
aReturn.bEnabled = sal_False;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch ( getContainer()->getElementType() )
|
|
|
|
{
|
|
|
|
case E_QUERY:
|
|
|
|
aReturn.bEnabled = ( getContainer()->getSelectionCount() > 0 )
|
|
|
|
&& ( getContainer()->isALeafSelected() );
|
|
|
|
break;
|
|
|
|
case E_TABLE:
|
|
|
|
aReturn.bEnabled = sal_False;
|
|
|
|
// there's one exception: views which support altering their underlying
|
|
|
|
// command can be edited in SQL view, too
|
|
|
|
if ( ( getContainer()->getSelectionCount() > 0 )
|
|
|
|
&& ( getContainer()->isALeafSelected() )
|
|
|
|
)
|
|
|
|
{
|
|
|
|
::std::vector< ::rtl::OUString > aSelected;
|
|
|
|
getSelectionElementNames( aSelected );
|
2008-05-05 14:51:14 +00:00
|
|
|
bool bAlterableViews = true;
|
|
|
|
for ( ::std::vector< ::rtl::OUString >::const_iterator selectedName = aSelected.begin();
|
|
|
|
bAlterableViews && ( selectedName != aSelected.end() ) ;
|
|
|
|
++selectedName
|
|
|
|
)
|
|
|
|
{
|
|
|
|
bAlterableViews &= impl_isAlterableView_nothrow( *selectedName );
|
|
|
|
}
|
|
|
|
aReturn.bEnabled = bAlterableViews;
|
2007-11-21 15:57:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-12-13 15:46:18 +00:00
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
case SID_DB_APP_OPEN:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_DB_APP_TABLE_OPEN:
|
|
|
|
case SID_DB_APP_QUERY_OPEN:
|
|
|
|
case SID_DB_APP_FORM_OPEN:
|
|
|
|
case SID_DB_APP_REPORT_OPEN:
|
2004-08-02 14:28:11 +00:00
|
|
|
aReturn.bEnabled = getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_DSUSERADMIN:
|
2004-11-16 13:48:43 +00:00
|
|
|
{
|
2008-10-01 12:28:29 +00:00
|
|
|
::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
|
|
|
|
aReturn.bEnabled = ::dbaccess::DST_EMBEDDED_HSQLDB != eType;
|
2004-11-16 13:48:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-11-09 11:26:30 +00:00
|
|
|
case SID_DB_APP_DSRELDESIGN:
|
2004-08-02 14:28:11 +00:00
|
|
|
aReturn.bEnabled = sal_True;
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_TABLEFILTER:
|
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly();
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_REFRESH_TABLES:
|
2005-10-24 07:30:07 +00:00
|
|
|
aReturn.bEnabled = getContainer()->getElementType() == E_TABLE && isConnected();
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_DSPROPS:
|
2006-08-28 14:05:18 +00:00
|
|
|
aReturn.bEnabled = m_xDataSource.is();
|
|
|
|
if ( aReturn.bEnabled )
|
2004-11-09 11:26:30 +00:00
|
|
|
{
|
2008-10-01 12:28:29 +00:00
|
|
|
::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
|
|
|
|
aReturn.bEnabled = ::dbaccess::DST_EMBEDDED_HSQLDB != eType && ::dbaccess::DST_MOZILLA != eType && ::dbaccess::DST_EVOLUTION != eType && ::dbaccess::DST_KAB != eType && ::dbaccess::DST_MACAB != eType && ::dbaccess::DST_OUTLOOK != eType && ::dbaccess::DST_OUTLOOKEXP != eType;
|
2004-11-09 11:26:30 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_DSCONNECTION_TYPE:
|
2006-10-12 13:16:16 +00:00
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly() && m_xDataSource.is();
|
|
|
|
if ( aReturn.bEnabled )
|
2004-11-09 11:26:30 +00:00
|
|
|
{
|
2008-10-01 12:28:29 +00:00
|
|
|
::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
|
|
|
|
aReturn.bEnabled = ::dbaccess::DST_EMBEDDED_HSQLDB != eType;
|
2004-11-09 11:26:30 +00:00
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_DSADVANCED_SETTINGS:
|
2006-08-28 14:05:18 +00:00
|
|
|
aReturn.bEnabled = m_xDataSource.is();
|
|
|
|
if ( aReturn.bEnabled )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-10-01 12:28:29 +00:00
|
|
|
::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType( ::comphelper::getString( m_xDataSource->getPropertyValue( PROPERTY_URL ) ) );
|
2007-11-01 14:03:13 +00:00
|
|
|
aReturn.bEnabled = AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( eType );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_CONVERTTOVIEW:
|
|
|
|
aReturn.bEnabled = !isDataSourceReadOnly();
|
|
|
|
if ( aReturn.bEnabled )
|
|
|
|
{
|
|
|
|
ElementType eType = getContainer()->getElementType();
|
|
|
|
aReturn.bEnabled = eType == E_QUERY && getContainer()->getSelectionCount() > 0;
|
|
|
|
if ( aReturn.bEnabled )
|
|
|
|
{
|
2005-10-24 07:30:07 +00:00
|
|
|
Reference<XViewsSupplier> xViewSup( getConnection(), UNO_QUERY );
|
2004-08-02 14:28:11 +00:00
|
|
|
aReturn.bEnabled = xViewSup.is() && Reference<XAppend>(xViewSup->getViews(),UNO_QUERY).is();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_DISABLE_PREVIEW:
|
2007-09-26 13:46:26 +00:00
|
|
|
aReturn.bEnabled = sal_True;
|
2006-07-10 14:22:12 +00:00
|
|
|
aReturn.bChecked = getContainer()->getPreviewMode() == E_PREVIEWNONE;
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_VIEW_DOCINFO_PREVIEW:
|
|
|
|
{
|
|
|
|
ElementType eType = getContainer()->getElementType();
|
2007-09-26 13:46:26 +00:00
|
|
|
aReturn.bEnabled = (E_REPORT == eType || E_FORM == eType);
|
2006-07-10 14:22:12 +00:00
|
|
|
aReturn.bChecked = getContainer()->getPreviewMode() == E_DOCUMENTINFO;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_VIEW_DOC_PREVIEW:
|
2007-09-26 13:46:26 +00:00
|
|
|
aReturn.bEnabled = sal_True;
|
2006-07-10 14:22:12 +00:00
|
|
|
aReturn.bChecked = getContainer()->getPreviewMode() == E_DOCUMENT;
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
2004-11-16 13:48:43 +00:00
|
|
|
case ID_BROWSER_UNDO:
|
2004-08-02 14:28:11 +00:00
|
|
|
aReturn.bEnabled = sal_False;
|
|
|
|
break;
|
2005-01-21 16:05:05 +00:00
|
|
|
case SID_MAIL_SENDDOC:
|
|
|
|
aReturn.bEnabled = sal_True;
|
|
|
|
break;
|
2004-11-17 14:25:08 +00:00
|
|
|
case SID_DB_APP_SENDREPORTASMAIL:
|
2005-01-21 16:05:05 +00:00
|
|
|
{
|
|
|
|
ElementType eType = getContainer()->getElementType();
|
|
|
|
aReturn.bEnabled = E_REPORT == eType && getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
|
|
|
|
}
|
|
|
|
break;
|
2004-11-17 14:25:08 +00:00
|
|
|
case SID_DB_APP_SENDREPORTTOWRITER:
|
|
|
|
case SID_DB_APP_DBADMIN:
|
|
|
|
aReturn.bEnabled = sal_False;
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_STATUS_TYPE:
|
2006-08-28 14:05:18 +00:00
|
|
|
aReturn.bEnabled = m_xDataSource.is();
|
|
|
|
if ( aReturn.bEnabled )
|
2004-11-17 14:25:08 +00:00
|
|
|
{
|
2008-10-01 12:28:29 +00:00
|
|
|
::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
|
|
|
|
::rtl::OUString sDSTypeName;
|
|
|
|
if ( m_aTypeCollection.isEmbeddedDatabase( eType ) )
|
|
|
|
{
|
|
|
|
sDSTypeName = String( ModuleRes( RID_STR_EMBEDDED_DATABASE ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sDSTypeName = m_aTypeCollection.getTypeDisplayName(eType);
|
|
|
|
}
|
2006-07-10 14:22:12 +00:00
|
|
|
aReturn.sTitle = sDSTypeName;
|
2004-11-17 14:25:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_STATUS_DBNAME:
|
2006-08-28 14:05:18 +00:00
|
|
|
aReturn.bEnabled = m_xDataSource.is();
|
|
|
|
if ( aReturn.bEnabled )
|
2004-11-17 14:25:08 +00:00
|
|
|
{
|
2007-11-01 14:03:13 +00:00
|
|
|
::rtl::OUString sURL;
|
|
|
|
m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sURL;
|
2008-10-01 12:28:29 +00:00
|
|
|
::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType( sURL );
|
2007-11-01 14:03:13 +00:00
|
|
|
|
2004-11-17 14:25:08 +00:00
|
|
|
String sDatabaseName;
|
2007-11-01 14:03:13 +00:00
|
|
|
String sHostName;
|
|
|
|
sal_Int32 nPortNumber( -1 );
|
|
|
|
|
|
|
|
m_aTypeCollection.extractHostNamePort( sURL, sDatabaseName, sHostName, nPortNumber );
|
|
|
|
|
|
|
|
if ( !sDatabaseName.Len() )
|
|
|
|
sDatabaseName = m_aTypeCollection.cutPrefix( sURL );
|
|
|
|
if ( m_aTypeCollection.isFileSystemBased(eType) )
|
2004-11-17 14:25:08 +00:00
|
|
|
{
|
2007-11-01 14:03:13 +00:00
|
|
|
sDatabaseName = SvtPathOptions().SubstituteVariable( sDatabaseName );
|
|
|
|
if ( sDatabaseName.Len() )
|
2004-11-17 14:25:08 +00:00
|
|
|
{
|
2007-11-01 14:03:13 +00:00
|
|
|
::svt::OFileNotation aFileNotation(sDatabaseName);
|
|
|
|
// set this decoded URL as text
|
|
|
|
sDatabaseName = aFileNotation.get(::svt::OFileNotation::N_SYSTEM);
|
2004-11-17 14:25:08 +00:00
|
|
|
}
|
|
|
|
}
|
2007-11-01 14:03:13 +00:00
|
|
|
|
|
|
|
if ( sDatabaseName.Len() == 0 )
|
|
|
|
sDatabaseName = m_aTypeCollection.getTypeDisplayName( eType );
|
|
|
|
|
2006-07-10 14:22:12 +00:00
|
|
|
aReturn.sTitle = sDatabaseName;
|
2004-11-17 14:25:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_STATUS_USERNAME:
|
2006-08-28 14:05:18 +00:00
|
|
|
aReturn.bEnabled = m_xDataSource.is();
|
|
|
|
if ( aReturn.bEnabled )
|
2006-07-10 14:22:12 +00:00
|
|
|
m_xDataSource->getPropertyValue( PROPERTY_USER ) >>= aReturn.sTitle;
|
2004-11-17 14:25:08 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_STATUS_HOSTNAME:
|
2006-08-28 14:05:18 +00:00
|
|
|
aReturn.bEnabled = m_xDataSource.is();
|
|
|
|
if ( aReturn.bEnabled )
|
2004-11-17 14:25:08 +00:00
|
|
|
{
|
2007-11-01 14:03:13 +00:00
|
|
|
::rtl::OUString sURL;
|
|
|
|
m_xDataSource->getPropertyValue( PROPERTY_URL ) >>= sURL;
|
|
|
|
|
|
|
|
String sHostName, sDatabaseName;
|
|
|
|
sal_Int32 nPortNumber = -1;
|
|
|
|
m_aTypeCollection.extractHostNamePort( sURL, sDatabaseName, sHostName, nPortNumber );
|
|
|
|
aReturn.sTitle = sHostName;
|
2004-11-17 14:25:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
default:
|
|
|
|
aReturn = OApplicationController_CBASE::GetState(_nId);
|
|
|
|
}
|
|
|
|
}
|
2006-06-20 01:53:25 +00:00
|
|
|
catch(const Exception& )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2006-06-20 01:53:25 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
return aReturn;
|
|
|
|
}
|
2008-06-06 13:06:49 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
bool lcl_handleException_nothrow( const Reference< XModel >& _rxDocument, const Any& _rException )
|
|
|
|
{
|
|
|
|
bool bHandled = false;
|
|
|
|
|
|
|
|
// try handling the error with an interaction handler
|
|
|
|
::comphelper::NamedValueCollection aArgs( _rxDocument->getArgs() );
|
|
|
|
Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) );
|
|
|
|
if ( xHandler.is() )
|
|
|
|
{
|
|
|
|
::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new ::comphelper::OInteractionRequest( _rException ) );
|
|
|
|
::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove );
|
|
|
|
pRequest->addContinuation( pApprove.get() );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xHandler->handle( pRequest.get() );
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
|
|
|
|
bHandled = pApprove->wasSelected();
|
|
|
|
}
|
|
|
|
return bHandled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2004-09-09 08:38:28 +00:00
|
|
|
void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
2008-06-25 11:35:22 +00:00
|
|
|
|
|
|
|
if ( isUserDefinedFeature( _nId ) )
|
|
|
|
{
|
|
|
|
OApplicationController_CBASE::Execute( _nId, aArgs );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-01-05 11:32:18 +00:00
|
|
|
if ( !getContainer() || m_bReadOnly )
|
2004-08-02 14:28:11 +00:00
|
|
|
return; // return without execution
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
switch(_nId)
|
|
|
|
{
|
|
|
|
case ID_BROWSER_CUT:
|
|
|
|
getContainer()->cut();
|
|
|
|
break;
|
|
|
|
case ID_BROWSER_COPY:
|
|
|
|
{
|
|
|
|
TransferableHelper* pTransfer = copyObject( );
|
|
|
|
Reference< XTransferable> aEnsureDelete = pTransfer;
|
|
|
|
|
|
|
|
if ( pTransfer )
|
|
|
|
pTransfer->CopyToClipboard(getView());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_BROWSER_PASTE:
|
|
|
|
{
|
2008-01-30 07:41:07 +00:00
|
|
|
const TransferableDataHelper& rTransferData( getViewClipboard() );
|
2004-08-02 14:28:11 +00:00
|
|
|
ElementType eType = getContainer()->getElementType();
|
2007-09-26 13:46:26 +00:00
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
switch( eType )
|
|
|
|
{
|
|
|
|
case E_TABLE:
|
2007-09-26 13:46:26 +00:00
|
|
|
{
|
2008-01-30 07:41:07 +00:00
|
|
|
// get the selected tablename
|
|
|
|
::std::vector< ::rtl::OUString > aList;
|
|
|
|
getSelectionElementNames( aList );
|
2007-09-26 13:46:26 +00:00
|
|
|
if ( !aList.empty() )
|
2008-01-30 07:41:07 +00:00
|
|
|
m_aTableCopyHelper.SetTableNameForAppend( *aList.begin() );
|
2007-09-26 13:46:26 +00:00
|
|
|
else
|
2008-01-30 07:41:07 +00:00
|
|
|
m_aTableCopyHelper.ResetTableNameForAppend();
|
|
|
|
|
|
|
|
m_aTableCopyHelper.pasteTable( rTransferData , getDatabaseName(), ensureConnection() );
|
2007-09-26 13:46:26 +00:00
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
2007-09-26 13:46:26 +00:00
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
case E_QUERY:
|
2008-01-30 07:41:07 +00:00
|
|
|
if ( rTransferData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY) )
|
|
|
|
paste( E_QUERY, ODataAccessObjectTransferable::extractObjectDescriptor( rTransferData ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
::std::vector< ::rtl::OUString> aList;
|
|
|
|
getSelectionElementNames(aList);
|
|
|
|
::rtl::OUString sFolderNameToInsertInto;
|
|
|
|
if ( !aList.empty() )
|
|
|
|
{
|
|
|
|
Reference< XHierarchicalNameAccess > xContainer(getElements(eType),UNO_QUERY);
|
|
|
|
if ( xContainer.is()
|
|
|
|
&& xContainer->hasByHierarchicalName(*aList.begin())
|
|
|
|
&& (xContainer->getByHierarchicalName(*aList.begin()) >>= xContainer)
|
|
|
|
&& xContainer.is()
|
|
|
|
)
|
|
|
|
sFolderNameToInsertInto = *aList.begin();
|
|
|
|
}
|
2008-05-05 14:51:14 +00:00
|
|
|
paste( eType, OComponentTransferable::extractComponentDescriptor( rTransferData ),
|
|
|
|
sFolderNameToInsertInto );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_PASTE_SPECIAL:
|
|
|
|
{
|
2004-09-09 08:38:28 +00:00
|
|
|
if ( !aArgs.getLength() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2007-09-11 09:33:21 +00:00
|
|
|
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
|
|
|
|
::std::auto_ptr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( getView() ));
|
2004-09-09 08:38:28 +00:00
|
|
|
::std::vector<SotFormatStringId> aFormatIds;
|
|
|
|
getSupportedFormats(getContainer()->getElementType(),aFormatIds);
|
2007-09-11 09:33:21 +00:00
|
|
|
const ::std::vector<SotFormatStringId>::iterator aEnd = aFormatIds.end();
|
|
|
|
::rtl::OUString sEmpty;
|
2004-09-09 08:38:28 +00:00
|
|
|
for (::std::vector<SotFormatStringId>::iterator aIter = aFormatIds.begin();aIter != aEnd; ++aIter)
|
2007-09-11 09:33:21 +00:00
|
|
|
pDlg->Insert(*aIter,sEmpty);
|
2004-08-02 14:28:11 +00:00
|
|
|
|
2004-09-09 08:38:28 +00:00
|
|
|
const TransferableDataHelper& rClipboard = getViewClipboard();
|
2007-09-11 09:33:21 +00:00
|
|
|
pasteFormat(pDlg->GetFormat(rClipboard.GetTransferable()));
|
2004-09-09 08:38:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const PropertyValue* pIter = aArgs.getConstArray();
|
|
|
|
const PropertyValue* pEnd = pIter + aArgs.getLength();
|
|
|
|
for( ; pIter != pEnd ; ++pIter)
|
|
|
|
{
|
|
|
|
if ( pIter->Name.equalsAscii("FormatStringId") )
|
|
|
|
{
|
2006-06-20 01:53:25 +00:00
|
|
|
SotFormatStringId nFormatId = 0;
|
2004-09-09 08:38:28 +00:00
|
|
|
if ( pIter->Value >>= nFormatId )
|
|
|
|
pasteFormat(nFormatId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_OPENDOC:
|
|
|
|
case SID_HELP_INDEX:
|
|
|
|
{
|
|
|
|
Reference < XDispatchProvider > xProv( getFrame(), UNO_QUERY );
|
|
|
|
if ( xProv.is() )
|
|
|
|
{
|
|
|
|
URL aURL;
|
|
|
|
switch(_nId)
|
|
|
|
{
|
|
|
|
case SID_HELP_INDEX:
|
|
|
|
aURL.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:HelpIndex"));
|
|
|
|
break;
|
|
|
|
case SID_OPENDOC:
|
|
|
|
aURL.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Open"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_xUrlTransformer.is() )
|
|
|
|
m_xUrlTransformer->parseStrict( aURL );
|
|
|
|
Reference < XDispatch > xDisp = xProv->queryDispatch( aURL, String(), 0 );
|
|
|
|
if ( xDisp.is() )
|
|
|
|
xDisp->dispatch( aURL, Sequence < PropertyValue >() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_BROWSER_SAVEDOC:
|
|
|
|
{
|
2008-06-06 13:06:49 +00:00
|
|
|
Reference< XStorable > xStore( m_xModel, UNO_QUERY_THROW );
|
|
|
|
try
|
|
|
|
{
|
2004-08-02 14:28:11 +00:00
|
|
|
xStore->store();
|
2008-06-06 13:06:49 +00:00
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
lcl_handleException_nothrow( m_xModel, ::cppu::getCaughtException() );
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-06-06 13:06:49 +00:00
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
case ID_BROWSER_SAVEASDOC:
|
|
|
|
{
|
|
|
|
WinBits nBits(WB_STDMODAL|WB_SAVEAS);
|
2005-02-16 15:00:49 +00:00
|
|
|
::rtl::OUString sUrl;
|
2005-03-10 15:43:10 +00:00
|
|
|
if ( m_xModel.is() )
|
|
|
|
sUrl = m_xModel->getURL();
|
2005-02-16 15:00:49 +00:00
|
|
|
if ( !sUrl.getLength() )
|
|
|
|
sUrl = SvtPathOptions().GetWorkPath();
|
2004-08-02 14:28:11 +00:00
|
|
|
|
2006-10-12 13:16:16 +00:00
|
|
|
::sfx2::FileDialogHelper aFileDlg( com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,static_cast<sal_uInt32>(nBits) ,getView());
|
2005-02-16 15:00:49 +00:00
|
|
|
aFileDlg.SetDisplayDirectory( sUrl );
|
2004-08-02 14:28:11 +00:00
|
|
|
|
2004-10-27 11:55:51 +00:00
|
|
|
const SfxFilter* pFilter = getStandardDatabaseFilter();
|
2004-08-02 14:28:11 +00:00
|
|
|
if ( pFilter )
|
|
|
|
{
|
2004-09-09 08:38:28 +00:00
|
|
|
aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
|
|
|
|
aFileDlg.SetCurrentFilter(pFilter->GetUIName());
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
|
2008-06-06 13:06:49 +00:00
|
|
|
if ( aFileDlg.Execute() != ERRCODE_NONE )
|
|
|
|
break;
|
|
|
|
|
|
|
|
Reference<XStorable> xStore( m_xModel, UNO_QUERY_THROW );
|
|
|
|
INetURLObject aURL( aFileDlg.GetPath() );
|
|
|
|
try
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-06-06 13:06:49 +00:00
|
|
|
xStore->storeAsURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), Sequence< PropertyValue >() );
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
lcl_handleException_nothrow( m_xModel, ::cppu::getCaughtException() );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_sDatabaseName = ::rtl::OUString();
|
|
|
|
/*updateTitle();*/
|
|
|
|
m_bCurrentlyModified = sal_False;
|
|
|
|
InvalidateFeature(ID_BROWSER_SAVEDOC);
|
|
|
|
if ( getContainer()->getElementType() == E_NONE )
|
|
|
|
{
|
|
|
|
getContainer()->selectContainer(E_NONE);
|
|
|
|
getContainer()->selectContainer(E_TABLE);
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_BROWSER_SORTUP:
|
|
|
|
getContainer()->sortUp();
|
|
|
|
InvalidateFeature(ID_BROWSER_SORTDOWN);
|
|
|
|
break;
|
|
|
|
case ID_BROWSER_SORTDOWN:
|
|
|
|
getContainer()->sortDown();
|
|
|
|
InvalidateFeature(ID_BROWSER_SORTUP);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_NEW_TABLE_DESIGN_AUTO_PILOT:
|
|
|
|
case ID_NEW_VIEW_DESIGN_AUTO_PILOT:
|
|
|
|
case ID_APP_NEW_QUERY_AUTO_PILOT:
|
2004-11-17 14:25:08 +00:00
|
|
|
case SID_DB_FORM_NEW_PILOT:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
|
2007-11-20 18:22:51 +00:00
|
|
|
case SID_APP_NEW_REPORT_PRE_SEL:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_FORM_CREATE_REPWIZ_PRE_SEL:
|
2004-08-02 14:28:11 +00:00
|
|
|
case ID_DOCUMENT_CREATE_REPWIZ:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_APP_NEW_FORM:
|
2007-07-06 06:57:53 +00:00
|
|
|
case SID_APP_NEW_REPORT:
|
2004-08-02 14:28:11 +00:00
|
|
|
case ID_NEW_QUERY_SQL:
|
|
|
|
case ID_NEW_QUERY_DESIGN:
|
|
|
|
case ID_NEW_TABLE_DESIGN:
|
|
|
|
{
|
|
|
|
ElementType eType = E_TABLE;
|
|
|
|
sal_Bool bAutoPilot = sal_False;
|
|
|
|
sal_Bool bSQLView = sal_False;
|
|
|
|
|
|
|
|
switch( _nId )
|
|
|
|
{
|
2004-11-17 14:25:08 +00:00
|
|
|
case SID_DB_FORM_NEW_PILOT:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_FORM_CREATE_REPWIZ_PRE_SEL:
|
2004-08-02 14:28:11 +00:00
|
|
|
bAutoPilot = sal_True;
|
|
|
|
// run through
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_APP_NEW_FORM:
|
2004-08-02 14:28:11 +00:00
|
|
|
eType = E_FORM;
|
|
|
|
break;
|
|
|
|
case ID_DOCUMENT_CREATE_REPWIZ:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
|
2004-08-02 14:28:11 +00:00
|
|
|
bAutoPilot = sal_True;
|
2007-07-06 06:57:53 +00:00
|
|
|
// run through
|
|
|
|
case SID_APP_NEW_REPORT:
|
2007-11-20 18:22:51 +00:00
|
|
|
case SID_APP_NEW_REPORT_PRE_SEL:
|
2004-08-02 14:28:11 +00:00
|
|
|
eType = E_REPORT;
|
|
|
|
break;
|
|
|
|
case ID_APP_NEW_QUERY_AUTO_PILOT:
|
|
|
|
bAutoPilot = sal_True;
|
|
|
|
eType = E_QUERY;
|
|
|
|
break;
|
|
|
|
case ID_NEW_QUERY_SQL:
|
|
|
|
bSQLView = sal_True;
|
|
|
|
// run through
|
|
|
|
case ID_NEW_QUERY_DESIGN:
|
|
|
|
eType = E_QUERY;
|
|
|
|
break;
|
2004-10-27 11:55:51 +00:00
|
|
|
case ID_NEW_TABLE_DESIGN_AUTO_PILOT:
|
|
|
|
bAutoPilot = sal_True;
|
|
|
|
// run through
|
2004-08-02 14:28:11 +00:00
|
|
|
case ID_NEW_TABLE_DESIGN:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
OSL_ENSURE(0,"illegal switch call!");
|
|
|
|
}
|
2005-01-21 16:05:05 +00:00
|
|
|
if ( bAutoPilot )
|
|
|
|
getContainer()->PostUserEvent( LINK( this, OApplicationController, OnCreateWithPilot ), reinterpret_cast< void* >( eType ) );
|
|
|
|
else
|
|
|
|
newElement( eType, bSQLView );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_APP_NEW_FOLDER:
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
ElementType eType = getContainer()->getElementType();
|
2006-10-05 11:59:07 +00:00
|
|
|
::rtl::OUString sName = getContainer()->getQualifiedName( NULL );
|
2004-08-02 14:28:11 +00:00
|
|
|
insertHierachyElement(eType,sName);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_NEW_VIEW_DESIGN:
|
2004-11-17 14:25:08 +00:00
|
|
|
case SID_DB_NEW_VIEW_SQL:
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2005-10-24 07:30:07 +00:00
|
|
|
SharedConnection xConnection( ensureConnection() );
|
2004-08-02 14:28:11 +00:00
|
|
|
if ( xConnection.is() )
|
|
|
|
{
|
2008-03-06 17:09:10 +00:00
|
|
|
QueryDesigner aDesigner( getORB(), this, getFrame(), true, SID_DB_NEW_VIEW_SQL == _nId );
|
2006-10-05 11:59:07 +00:00
|
|
|
|
|
|
|
Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
|
|
|
|
Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY );
|
|
|
|
addDocumentListener( xComponent, NULL );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_DELETE:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_DB_APP_TABLE_DELETE:
|
|
|
|
case SID_DB_APP_QUERY_DELETE:
|
|
|
|
case SID_DB_APP_FORM_DELETE:
|
|
|
|
case SID_DB_APP_REPORT_DELETE:
|
2004-08-02 14:28:11 +00:00
|
|
|
deleteEntries();
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_RENAME:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_DB_APP_TABLE_RENAME:
|
|
|
|
case SID_DB_APP_QUERY_RENAME:
|
|
|
|
case SID_DB_APP_FORM_RENAME:
|
|
|
|
case SID_DB_APP_REPORT_RENAME:
|
2004-08-02 14:28:11 +00:00
|
|
|
renameEntry();
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_EDIT:
|
2006-12-13 15:46:18 +00:00
|
|
|
case SID_DB_APP_EDIT_SQL_VIEW:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_DB_APP_TABLE_EDIT:
|
|
|
|
case SID_DB_APP_QUERY_EDIT:
|
|
|
|
case SID_DB_APP_FORM_EDIT:
|
|
|
|
case SID_DB_APP_REPORT_EDIT:
|
2008-05-05 14:51:14 +00:00
|
|
|
doAction( _nId, E_OPEN_DESIGN );
|
2004-09-09 08:38:28 +00:00
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
case SID_DB_APP_OPEN:
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_DB_APP_TABLE_OPEN:
|
|
|
|
case SID_DB_APP_QUERY_OPEN:
|
|
|
|
case SID_DB_APP_FORM_OPEN:
|
|
|
|
case SID_DB_APP_REPORT_OPEN:
|
2008-05-05 14:51:14 +00:00
|
|
|
doAction( _nId, E_OPEN_NORMAL );
|
2004-09-09 08:38:28 +00:00
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
case SID_DB_APP_CONVERTTOVIEW:
|
2008-05-05 14:51:14 +00:00
|
|
|
doAction( _nId, E_OPEN_NORMAL );
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
2004-09-09 08:38:28 +00:00
|
|
|
case SID_SELECTALL:
|
2004-08-02 14:28:11 +00:00
|
|
|
getContainer()->selectAll();
|
2005-03-18 09:07:07 +00:00
|
|
|
InvalidateAll();
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_DSRELDESIGN:
|
2008-05-05 14:51:14 +00:00
|
|
|
if ( !impl_activateSubFrame_throw(::rtl::OUString(),SID_DB_APP_DSRELDESIGN,E_OPEN_DESIGN) )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2005-10-24 07:30:07 +00:00
|
|
|
SharedConnection xConnection( ensureConnection() );
|
2004-08-02 14:28:11 +00:00
|
|
|
if ( xConnection.is() )
|
|
|
|
{
|
2008-04-08 11:46:07 +00:00
|
|
|
RelationDesigner aDesigner( getORB(), this, m_aCurrentFrame.getFrame() );
|
2006-10-05 11:59:07 +00:00
|
|
|
Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
|
|
|
|
Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY );
|
|
|
|
addDocumentListener( xComponent, NULL );
|
2008-04-04 13:53:36 +00:00
|
|
|
m_aSpecialSubFrames.insert(TFrames::value_type(::rtl::OUString(),
|
2008-05-05 14:51:14 +00:00
|
|
|
TTypeFrame(TTypeOpenMode(SID_DB_APP_DSRELDESIGN,E_OPEN_DESIGN),xComponent)));
|
2008-04-04 13:53:36 +00:00
|
|
|
} // if ( xConnection.is() )
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_DSUSERADMIN:
|
2005-03-18 09:07:07 +00:00
|
|
|
{
|
2005-10-24 07:30:07 +00:00
|
|
|
SharedConnection xConnection( ensureConnection() );
|
2005-03-18 09:07:07 +00:00
|
|
|
if ( xConnection.is() )
|
|
|
|
openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.UserAdministrationDialog")));
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_TABLEFILTER:
|
|
|
|
openTableFilterDialog();
|
|
|
|
askToReconnect();
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_REFRESH_TABLES:
|
|
|
|
refreshTables();
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_DSPROPS:
|
|
|
|
openDataSourceAdminDialog();
|
|
|
|
askToReconnect();
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_DSADVANCED_SETTINGS:
|
|
|
|
openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.AdvancedDatabaseSettingsDialog")));
|
|
|
|
askToReconnect();
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_DSCONNECTION_TYPE:
|
|
|
|
openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DataSourceTypeChangeDialog")));
|
|
|
|
askToReconnect();
|
|
|
|
break;
|
|
|
|
case ID_DIRECT_SQL:
|
2005-03-18 09:07:07 +00:00
|
|
|
{
|
2005-10-24 07:30:07 +00:00
|
|
|
SharedConnection xConnection( ensureConnection() );
|
2005-03-18 09:07:07 +00:00
|
|
|
if ( xConnection.is() )
|
|
|
|
openDirectSQLDialog();
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
2008-03-06 17:09:10 +00:00
|
|
|
case ID_MIGRATE_SCRIPTS:
|
|
|
|
impl_migrateScripts_nothrow();
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
case SID_DB_APP_VIEW_TABLES:
|
2008-06-25 11:35:22 +00:00
|
|
|
m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_TABLE ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_VIEW_QUERIES:
|
2008-06-25 11:35:22 +00:00
|
|
|
m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_QUERY ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_VIEW_FORMS:
|
2008-06-25 11:35:22 +00:00
|
|
|
m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_FORM ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_VIEW_REPORTS:
|
2008-06-25 11:35:22 +00:00
|
|
|
m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_REPORT ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case SID_DB_APP_DISABLE_PREVIEW:
|
|
|
|
m_ePreviewMode = E_PREVIEWNONE;
|
|
|
|
getContainer()->switchPreview(m_ePreviewMode);
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_VIEW_DOCINFO_PREVIEW:
|
|
|
|
m_ePreviewMode = E_DOCUMENTINFO;
|
|
|
|
getContainer()->switchPreview(m_ePreviewMode);
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_VIEW_DOC_PREVIEW:
|
|
|
|
m_ePreviewMode = E_DOCUMENT;
|
|
|
|
getContainer()->switchPreview(m_ePreviewMode);
|
|
|
|
break;
|
2005-01-21 16:05:05 +00:00
|
|
|
case SID_MAIL_SENDDOC:
|
|
|
|
{
|
2006-03-27 08:27:26 +00:00
|
|
|
SfxMailModel aSendMail;
|
|
|
|
if ( aSendMail.AttachDocument(rtl::OUString(),getModel(), rtl::OUString()) == SfxMailModel::SEND_MAIL_OK )
|
2008-03-06 17:09:10 +00:00
|
|
|
aSendMail.Send( getFrame() );
|
2005-01-21 16:05:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DB_APP_SENDREPORTASMAIL:
|
2008-05-05 14:51:14 +00:00
|
|
|
doAction( _nId, E_OPEN_FOR_MAIL );
|
2005-01-21 16:05:05 +00:00
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-20 01:53:25 +00:00
|
|
|
catch( const Exception& )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2006-06-20 01:53:25 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
InvalidateFeature(_nId);
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2004-11-16 13:48:43 +00:00
|
|
|
void OApplicationController::describeSupportedFeatures()
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2004-11-16 13:48:43 +00:00
|
|
|
OApplicationController_CBASE::describeSupportedFeatures();
|
|
|
|
|
|
|
|
implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVEDOC, CommandGroup::DOCUMENT );
|
|
|
|
implDescribeSupportedFeature( ".uno:SaveAs", ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT );
|
2005-01-21 16:05:05 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:SendMail", SID_MAIL_SENDDOC, CommandGroup::DOCUMENT );
|
2004-11-17 14:25:08 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBSendReportAsMail",SID_DB_APP_SENDREPORTASMAIL,
|
|
|
|
CommandGroup::DOCUMENT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBSendReportToWriter",SID_DB_APP_SENDREPORTTOWRITER,
|
|
|
|
CommandGroup::DOCUMENT );
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBNewForm", SID_APP_NEW_FORM, CommandGroup::INSERT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBNewFolder", SID_APP_NEW_FOLDER, CommandGroup::INSERT );
|
2004-11-17 14:25:08 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBNewFormAutoPilot", SID_DB_FORM_NEW_PILOT, CommandGroup::INSERT );
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBNewFormAutoPilotWithPreSelection",
|
|
|
|
SID_FORM_CREATE_REPWIZ_PRE_SEL,
|
|
|
|
CommandGroup::APPLICATION );
|
2004-11-17 14:25:08 +00:00
|
|
|
|
2007-07-06 06:57:53 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBNewReport", SID_APP_NEW_REPORT, CommandGroup::INSERT );
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBNewReportAutoPilot",
|
|
|
|
ID_DOCUMENT_CREATE_REPWIZ, CommandGroup::INSERT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBNewReportAutoPilotWithPreSelection",
|
|
|
|
SID_REPORT_CREATE_REPWIZ_PRE_SEL,
|
|
|
|
CommandGroup::APPLICATION );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBNewQuery", ID_NEW_QUERY_DESIGN, CommandGroup::INSERT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBNewQuerySql", ID_NEW_QUERY_SQL, CommandGroup::INSERT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBNewQueryAutoPilot",ID_APP_NEW_QUERY_AUTO_PILOT,
|
|
|
|
CommandGroup::INSERT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBNewTable", ID_NEW_TABLE_DESIGN, CommandGroup::INSERT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBNewTableAutoPilot",ID_NEW_TABLE_DESIGN_AUTO_PILOT,
|
|
|
|
CommandGroup::INSERT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBNewView", ID_NEW_VIEW_DESIGN, CommandGroup::INSERT );
|
2004-11-17 14:25:08 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBNewViewSQL", SID_DB_NEW_VIEW_SQL, CommandGroup::INSERT );
|
2004-09-09 08:38:28 +00:00
|
|
|
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBDelete", SID_DB_APP_DELETE, CommandGroup::EDIT );
|
2005-03-18 09:07:07 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:Delete", SID_DB_APP_DELETE, CommandGroup::EDIT );
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBRename", SID_DB_APP_RENAME, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBEdit", SID_DB_APP_EDIT, CommandGroup::EDIT );
|
2006-12-13 15:46:18 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBEditSqlView", SID_DB_APP_EDIT_SQL_VIEW, CommandGroup::EDIT );
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBOpen", SID_DB_APP_OPEN, CommandGroup::EDIT );
|
2004-09-09 08:38:28 +00:00
|
|
|
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBTableDelete", SID_DB_APP_TABLE_DELETE, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBTableRename", SID_DB_APP_TABLE_RENAME, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBTableEdit", SID_DB_APP_TABLE_EDIT, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBTableOpen", SID_DB_APP_TABLE_OPEN, CommandGroup::EDIT );
|
2004-09-09 08:38:28 +00:00
|
|
|
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBQueryDelete", SID_DB_APP_QUERY_DELETE, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBQueryRename", SID_DB_APP_QUERY_RENAME, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBQueryEdit", SID_DB_APP_QUERY_EDIT, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBQueryOpen", SID_DB_APP_QUERY_OPEN, CommandGroup::EDIT );
|
2004-09-09 08:38:28 +00:00
|
|
|
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBFormDelete", SID_DB_APP_FORM_DELETE, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBFormRename", SID_DB_APP_FORM_RENAME, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBFormEdit", SID_DB_APP_FORM_EDIT, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBFormOpen", SID_DB_APP_FORM_OPEN, CommandGroup::EDIT );
|
2004-09-09 08:38:28 +00:00
|
|
|
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBReportDelete", SID_DB_APP_REPORT_DELETE, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBReportRename", SID_DB_APP_REPORT_RENAME, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBReportEdit", SID_DB_APP_REPORT_EDIT, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBReportOpen", SID_DB_APP_REPORT_OPEN, CommandGroup::EDIT );
|
2004-09-09 08:38:28 +00:00
|
|
|
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:SelectAll", SID_SELECTALL, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:Undo", ID_BROWSER_UNDO, CommandGroup::EDIT );
|
2004-09-09 08:38:28 +00:00
|
|
|
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:Sortup", ID_BROWSER_SORTUP, CommandGroup::VIEW );
|
|
|
|
implDescribeSupportedFeature( ".uno:SortDown", ID_BROWSER_SORTDOWN, CommandGroup::VIEW );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBRelationDesign", SID_DB_APP_DSRELDESIGN, CommandGroup::APPLICATION );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBUserAdmin", SID_DB_APP_DSUSERADMIN, CommandGroup::APPLICATION );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBTableFilter", SID_DB_APP_TABLEFILTER, CommandGroup::APPLICATION );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBDSProperties", SID_DB_APP_DSPROPS, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBDSConnectionType", SID_DB_APP_DSCONNECTION_TYPE,
|
|
|
|
CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBDSAdvancedSettings",
|
|
|
|
SID_DB_APP_DSADVANCED_SETTINGS,
|
|
|
|
CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:PasteSpecial", SID_DB_APP_PASTE_SPECIAL, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBConvertToView", SID_DB_APP_CONVERTTOVIEW, CommandGroup::EDIT );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBRefreshTables", SID_DB_APP_REFRESH_TABLES, CommandGroup::APPLICATION );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBDirectSQL", ID_DIRECT_SQL, CommandGroup::APPLICATION );
|
2008-03-06 17:09:10 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBMigrateScripts", ID_MIGRATE_SCRIPTS, CommandGroup::APPLICATION );
|
2004-11-16 13:48:43 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBViewTables", SID_DB_APP_VIEW_TABLES, CommandGroup::VIEW );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBViewQueries", SID_DB_APP_VIEW_QUERIES, CommandGroup::VIEW );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBViewForms", SID_DB_APP_VIEW_FORMS, CommandGroup::VIEW );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBViewReports", SID_DB_APP_VIEW_REPORTS, CommandGroup::VIEW );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBDisablePreview", SID_DB_APP_DISABLE_PREVIEW,CommandGroup::VIEW );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBShowDocInfoPreview",
|
|
|
|
SID_DB_APP_VIEW_DOCINFO_PREVIEW,
|
|
|
|
CommandGroup::VIEW );
|
|
|
|
implDescribeSupportedFeature( ".uno:DBShowDocPreview", SID_DB_APP_VIEW_DOC_PREVIEW,
|
|
|
|
CommandGroup::VIEW );
|
2004-11-17 14:25:08 +00:00
|
|
|
|
2008-01-30 07:41:07 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:OpenUrl", SID_OPENURL, CommandGroup::APPLICATION );
|
|
|
|
|
2005-09-23 11:14:21 +00:00
|
|
|
// this one should not appear under Tools->Customize->Keyboard
|
2008-06-16 11:32:24 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBNewReportWithPreSelection",
|
|
|
|
SID_APP_NEW_REPORT_PRE_SEL,CommandGroup::INTERNAL );
|
2005-09-23 11:14:21 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBDSImport", SID_DB_APP_DSIMPORT, CommandGroup::INTERNAL);
|
|
|
|
implDescribeSupportedFeature( ".uno:DBDSExport", SID_DB_APP_DSEXPORT, CommandGroup::INTERNAL);
|
|
|
|
implDescribeSupportedFeature( ".uno:DBDBAdmin", SID_DB_APP_DBADMIN, CommandGroup::INTERNAL);
|
2004-11-17 14:25:08 +00:00
|
|
|
|
|
|
|
// status info
|
2005-09-23 11:14:21 +00:00
|
|
|
implDescribeSupportedFeature( ".uno:DBStatusType", SID_DB_APP_STATUS_TYPE, CommandGroup::INTERNAL);
|
|
|
|
implDescribeSupportedFeature( ".uno:DBStatusDBName", SID_DB_APP_STATUS_DBNAME, CommandGroup::INTERNAL);
|
|
|
|
implDescribeSupportedFeature( ".uno:DBStatusUserName", SID_DB_APP_STATUS_USERNAME, CommandGroup::INTERNAL);
|
|
|
|
implDescribeSupportedFeature( ".uno:DBStatusHostName", SID_DB_APP_STATUS_HOSTNAME, CommandGroup::INTERNAL);
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
OApplicationView* OApplicationController::getContainer() const
|
|
|
|
{
|
|
|
|
return static_cast< OApplicationView* >( getView() );
|
|
|
|
}
|
2008-06-25 11:35:22 +00:00
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// ::com::sun::star::container::XContainerListener
|
|
|
|
void SAL_CALL OApplicationController::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
|
2005-01-21 16:05:05 +00:00
|
|
|
Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
|
|
|
|
if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
|
|
|
|
if ( getContainer() )
|
|
|
|
{
|
|
|
|
::rtl::OUString sName;
|
|
|
|
_rEvent.Accessor >>= sName;
|
2005-01-21 16:05:05 +00:00
|
|
|
ElementType eType = getElementType(xContainer);
|
2004-08-02 14:28:11 +00:00
|
|
|
|
|
|
|
switch( eType )
|
|
|
|
{
|
|
|
|
case E_TABLE:
|
2005-10-24 07:30:07 +00:00
|
|
|
ensureConnection();
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case E_FORM:
|
|
|
|
case E_REPORT:
|
|
|
|
{
|
2005-01-21 16:05:05 +00:00
|
|
|
Reference< XContainer > xSubContainer(_rEvent.Element,UNO_QUERY);
|
|
|
|
if ( xSubContainer.is() )
|
|
|
|
containerFound(xSubContainer);
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-06-20 01:53:25 +00:00
|
|
|
default:
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2006-10-05 11:59:07 +00:00
|
|
|
getContainer()->elementAdded(eType,sName,_rEvent.Element);
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OApplicationController::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
|
2005-01-21 16:05:05 +00:00
|
|
|
Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
|
|
|
|
if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
|
|
|
|
::rtl::OUString sName;
|
|
|
|
_rEvent.Accessor >>= sName;
|
2005-01-21 16:05:05 +00:00
|
|
|
ElementType eType = getElementType(xContainer);
|
2004-08-02 14:28:11 +00:00
|
|
|
switch( eType )
|
|
|
|
{
|
|
|
|
case E_TABLE:
|
2005-10-24 07:30:07 +00:00
|
|
|
ensureConnection();
|
2004-08-02 14:28:11 +00:00
|
|
|
break;
|
|
|
|
case E_FORM:
|
|
|
|
case E_REPORT:
|
|
|
|
{
|
2005-01-21 16:05:05 +00:00
|
|
|
Reference<XContent> xContent(xContainer,UNO_QUERY);
|
2004-08-02 14:28:11 +00:00
|
|
|
if ( xContent.is() )
|
|
|
|
{
|
|
|
|
sName = xContent->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 01:53:25 +00:00
|
|
|
default:
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2006-10-05 11:59:07 +00:00
|
|
|
getContainer()->elementRemoved(eType,sName);
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OApplicationController::elementReplaced( const ContainerEvent& _rEvent ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
|
2005-01-21 16:05:05 +00:00
|
|
|
Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
|
|
|
|
if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
|
|
|
|
::rtl::OUString sName;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
_rEvent.Accessor >>= sName;
|
|
|
|
Reference<XConnection> xConnection;
|
|
|
|
Reference<XPropertySet> xProp(_rEvent.Element,UNO_QUERY);
|
|
|
|
::rtl::OUString sNewName;
|
|
|
|
|
2005-01-21 16:05:05 +00:00
|
|
|
ElementType eType = getElementType(xContainer);
|
2004-08-02 14:28:11 +00:00
|
|
|
switch( eType )
|
|
|
|
{
|
|
|
|
case E_TABLE:
|
2005-10-24 07:30:07 +00:00
|
|
|
{
|
|
|
|
ensureConnection();
|
|
|
|
if ( xProp.is() && m_xMetaData.is() )
|
2006-07-10 14:22:12 +00:00
|
|
|
sNewName = ::dbaui::composeTableName( m_xMetaData, xProp, ::dbtools::eInDataManipulation, false, false, false );
|
2005-10-24 07:30:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
case E_FORM:
|
|
|
|
case E_REPORT:
|
|
|
|
{
|
2005-01-21 16:05:05 +00:00
|
|
|
Reference<XContent> xContent(xContainer,UNO_QUERY);
|
2004-08-02 14:28:11 +00:00
|
|
|
if ( xContent.is() )
|
|
|
|
{
|
|
|
|
sName = xContent->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 01:53:25 +00:00
|
|
|
default:
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2006-10-05 11:59:07 +00:00
|
|
|
// getContainer()->elementReplaced(getContainer()->getElementType(),sName,sNewName);
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
catch( Exception& )
|
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-09-09 08:38:28 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
::rtl::OUString lcl_getToolBarResource(ElementType _eType)
|
|
|
|
{
|
|
|
|
::rtl::OUString sToolbar;
|
|
|
|
switch(_eType)
|
|
|
|
{
|
|
|
|
case E_TABLE:
|
|
|
|
sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/tableobjectbar" ));
|
|
|
|
break;
|
|
|
|
case E_QUERY:
|
|
|
|
sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/queryobjectbar" ));
|
|
|
|
break;
|
|
|
|
case E_FORM:
|
|
|
|
sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/formobjectbar" ));
|
|
|
|
break;
|
|
|
|
case E_REPORT:
|
|
|
|
sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/reportobjectbar" ));
|
|
|
|
break;
|
|
|
|
case E_NONE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
OSL_ENSURE(0,"Invalid ElementType!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return sToolbar;
|
|
|
|
}
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool OApplicationController::onContainerSelect(ElementType _eType)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
|
|
|
|
|
2008-03-06 17:09:10 +00:00
|
|
|
if ( m_eCurrentType != _eType && _eType != E_NONE )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-06-25 11:35:22 +00:00
|
|
|
SelectionGuard aSelGuard( *m_pSelectionNotifier );
|
|
|
|
|
2008-03-06 17:09:10 +00:00
|
|
|
if ( _eType == E_TABLE )
|
2004-09-09 08:38:28 +00:00
|
|
|
{
|
|
|
|
try
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2005-10-24 07:30:07 +00:00
|
|
|
SharedConnection xConnection( ensureConnection() );
|
2005-01-05 11:32:18 +00:00
|
|
|
if ( xConnection.is() && getContainer()->getDetailView() )
|
2004-09-09 08:38:28 +00:00
|
|
|
{
|
|
|
|
getContainer()->getDetailView()->createTablesPage(xConnection);
|
|
|
|
Reference<XTablesSupplier> xTabSup(xConnection,UNO_QUERY);
|
|
|
|
if ( xTabSup.is() )
|
|
|
|
addContainerListener(xTabSup->getTables());
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2004-09-09 08:38:28 +00:00
|
|
|
else
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
2008-03-06 17:09:10 +00:00
|
|
|
catch( const Exception& )
|
2004-09-09 08:38:28 +00:00
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
2008-03-06 17:09:10 +00:00
|
|
|
Reference< XLayoutManager > xLayoutManager = getLayoutManager( getFrame() );
|
|
|
|
if ( xLayoutManager.is() )
|
2004-09-09 08:38:28 +00:00
|
|
|
{
|
2008-03-06 17:09:10 +00:00
|
|
|
::rtl::OUString sToolbar = lcl_getToolBarResource(_eType);
|
|
|
|
::rtl::OUString sDestroyToolbar = lcl_getToolBarResource(m_eCurrentType);
|
|
|
|
|
|
|
|
xLayoutManager->lock();
|
|
|
|
xLayoutManager->destroyElement( sDestroyToolbar );
|
|
|
|
if ( sToolbar.getLength() )
|
|
|
|
{
|
|
|
|
xLayoutManager->createElement( sToolbar );
|
|
|
|
xLayoutManager->requestElement( sToolbar );
|
|
|
|
}
|
|
|
|
xLayoutManager->unlock();
|
|
|
|
xLayoutManager->doLayout();
|
2004-09-09 08:38:28 +00:00
|
|
|
}
|
2008-03-06 17:09:10 +00:00
|
|
|
|
|
|
|
if ( _eType != E_TABLE && getContainer()->getDetailView() )
|
2004-09-09 08:38:28 +00:00
|
|
|
{
|
|
|
|
Reference< XNameAccess > xContainer = getElements(_eType);
|
|
|
|
addContainerListener(xContainer);
|
|
|
|
getContainer()->getDetailView()->createPage(_eType,xContainer);
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
|
2008-06-25 11:35:22 +00:00
|
|
|
SelectionByElementType::iterator pendingSelection = m_aPendingSelection.find( _eType );
|
|
|
|
if ( pendingSelection != m_aPendingSelection.end() )
|
|
|
|
{
|
|
|
|
Sequence< ::rtl::OUString > aSelected( pendingSelection->second.size() );
|
|
|
|
::std::copy( pendingSelection->second.begin(), pendingSelection->second.end(), aSelected.getArray() );
|
|
|
|
getContainer()->selectElements( aSelected );
|
|
|
|
|
|
|
|
m_aPendingSelection.erase( pendingSelection );
|
|
|
|
}
|
|
|
|
|
2004-09-09 08:38:28 +00:00
|
|
|
InvalidateAll();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2008-03-06 17:09:10 +00:00
|
|
|
m_eCurrentType = _eType;
|
2004-08-02 14:28:11 +00:00
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-06-25 11:35:22 +00:00
|
|
|
bool OApplicationController::onEntryDoubleClick( SvTreeListBox& _rTree )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-06-25 11:35:22 +00:00
|
|
|
if ( getContainer() && getContainer()->isLeaf( _rTree.GetHdlEntry() ) )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2006-12-13 15:46:18 +00:00
|
|
|
openElement(
|
2008-06-25 11:35:22 +00:00
|
|
|
getContainer()->getQualifiedName( _rTree.GetHdlEntry() ),
|
2006-12-13 15:46:18 +00:00
|
|
|
getContainer()->getElementType(),
|
2008-05-05 14:51:14 +00:00
|
|
|
E_OPEN_NORMAL
|
2006-12-13 15:46:18 +00:00
|
|
|
);
|
2006-12-01 16:29:30 +00:00
|
|
|
return true; // handled
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
catch(const Exception&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Could not open element!");
|
|
|
|
}
|
|
|
|
}
|
2006-12-01 16:29:30 +00:00
|
|
|
return false; // not handled
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2007-11-21 15:57:49 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
bool OApplicationController::impl_isAlterableView_nothrow( const ::rtl::OUString& _rTableOrViewName ) const
|
|
|
|
{
|
|
|
|
OSL_PRECOND( m_xDataSourceConnection.is(), "OApplicationController::impl_isAlterableView_nothrow: no connection!" );
|
|
|
|
|
|
|
|
bool bIsAlterableView( false );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XViewsSupplier > xViewsSupp( m_xDataSourceConnection, UNO_QUERY );
|
|
|
|
Reference< XNameAccess > xViews;
|
|
|
|
if ( xViewsSupp.is() )
|
|
|
|
xViews = xViewsSupp->getViews();
|
|
|
|
|
|
|
|
Reference< XAlterView > xAsAlterableView;
|
|
|
|
if ( xViews.is() && xViews->hasByName( _rTableOrViewName ) )
|
|
|
|
xAsAlterableView.set( xViews->getByName( _rTableOrViewName ), UNO_QUERY );
|
|
|
|
|
|
|
|
bIsAlterableView = xAsAlterableView.is();
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
return bIsAlterableView;
|
|
|
|
}
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2006-12-13 15:46:18 +00:00
|
|
|
Reference< XComponent > OApplicationController::openElement(const ::rtl::OUString& _sName, ElementType _eType,
|
2008-05-05 14:51:14 +00:00
|
|
|
ElementOpenMode _eOpenMode, sal_uInt16 _nInstigatorCommand )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
return openElementWithArguments( _sName, _eType, _eOpenMode, _nInstigatorCommand, ::comphelper::NamedValueCollection() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XComponent > OApplicationController::openElementWithArguments( const ::rtl::OUString& _sName, ElementType _eType,
|
|
|
|
ElementOpenMode _eOpenMode, sal_uInt16 _nInstigatorCommand, const ::comphelper::NamedValueCollection& _rAdditionalArguments )
|
|
|
|
{
|
|
|
|
OSL_PRECOND( getContainer(), "OApplicationController::openElementWithArguments: no view!" );
|
|
|
|
if ( !getContainer() )
|
|
|
|
return NULL;
|
|
|
|
|
2005-01-21 16:05:05 +00:00
|
|
|
Reference< XComponent > xRet;
|
2008-05-05 14:51:14 +00:00
|
|
|
if ( _eOpenMode == E_OPEN_DESIGN )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
// OJ: http://www.openoffice.org/issues/show_bug.cgi?id=30382
|
|
|
|
getContainer()->showPreview(NULL);
|
|
|
|
}
|
2007-11-21 15:57:49 +00:00
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
switch ( _eType )
|
|
|
|
{
|
2007-11-21 15:57:49 +00:00
|
|
|
case E_REPORT:
|
|
|
|
case E_FORM:
|
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
::std::auto_ptr< OLinkedDocumentsAccess > aHelper = getDocumentsAccess( _eType );
|
|
|
|
if ( !aHelper->isConnected() )
|
|
|
|
break;
|
|
|
|
|
2007-11-21 15:57:49 +00:00
|
|
|
Reference< XComponent > xDefinition;
|
2008-05-05 14:51:14 +00:00
|
|
|
xRet = aHelper->open( _sName, xDefinition, _eOpenMode, _rAdditionalArguments );
|
|
|
|
|
2008-06-25 11:35:22 +00:00
|
|
|
addDocumentListener(xRet,xDefinition);
|
2007-11-21 15:57:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case E_QUERY:
|
|
|
|
case E_TABLE:
|
|
|
|
{
|
2008-04-04 13:53:36 +00:00
|
|
|
if ( !impl_activateSubFrame_throw(_sName,_eType,_eOpenMode) )
|
2007-11-21 15:57:49 +00:00
|
|
|
{
|
|
|
|
|
2008-04-04 13:53:36 +00:00
|
|
|
SharedConnection xConnection( ensureConnection() );
|
|
|
|
if ( !xConnection.is() )
|
|
|
|
break;
|
|
|
|
|
2008-08-19 08:54:27 +00:00
|
|
|
::std::auto_ptr< DatabaseObjectView > pDesigner;
|
|
|
|
::comphelper::NamedValueCollection aArguments( _rAdditionalArguments );
|
2008-04-04 13:53:36 +00:00
|
|
|
|
2008-08-19 08:54:27 +00:00
|
|
|
Any aDataSource;
|
|
|
|
if ( _eOpenMode == E_OPEN_DESIGN )
|
2008-05-05 14:51:14 +00:00
|
|
|
{
|
2008-08-19 08:54:27 +00:00
|
|
|
sal_Bool bQuerySQLMode =( _nInstigatorCommand == SID_DB_APP_EDIT_SQL_VIEW );
|
|
|
|
|
|
|
|
if ( _eType == E_TABLE )
|
|
|
|
{
|
|
|
|
if ( impl_isAlterableView_nothrow( _sName ) )
|
|
|
|
pDesigner.reset( new QueryDesigner( getORB(), this, m_aCurrentFrame.getFrame(), true, bQuerySQLMode ) );
|
|
|
|
else
|
|
|
|
pDesigner.reset( new TableDesigner( getORB(), this, m_aCurrentFrame.getFrame() ) );
|
|
|
|
}
|
|
|
|
else if ( _eType == E_QUERY )
|
|
|
|
{
|
|
|
|
pDesigner.reset( new QueryDesigner( getORB(), this, m_aCurrentFrame.getFrame(), false, bQuerySQLMode ) );
|
|
|
|
}
|
|
|
|
aDataSource <<= m_xDataSource;
|
2007-11-21 15:57:49 +00:00
|
|
|
}
|
2008-08-19 08:54:27 +00:00
|
|
|
else
|
2007-11-21 15:57:49 +00:00
|
|
|
{
|
2008-08-19 08:54:27 +00:00
|
|
|
pDesigner.reset( new ResultSetBrowser( getORB(), this, m_aCurrentFrame.getFrame(), _eType == E_TABLE ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
|
2008-08-19 08:54:27 +00:00
|
|
|
if ( !aArguments.has( (::rtl::OUString)PROPERTY_SHOWMENU ) )
|
|
|
|
aArguments.put( (::rtl::OUString)PROPERTY_SHOWMENU, makeAny( (sal_Bool)sal_True ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
|
2008-08-19 08:54:27 +00:00
|
|
|
aDataSource <<= getDatabaseName();
|
2008-04-04 13:53:36 +00:00
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
|
2008-08-19 08:54:27 +00:00
|
|
|
Reference< XComponent > xComponent( pDesigner->openExisting( aDataSource, _sName, aArguments.getPropertyValues() ), UNO_QUERY );
|
|
|
|
addDocumentListener( xComponent, NULL );
|
|
|
|
m_aSpecialSubFrames.insert(TFrames::value_type(_sName,
|
|
|
|
TTypeFrame(TTypeOpenMode(_eType,_eOpenMode),xComponent)));
|
2008-04-04 13:53:36 +00:00
|
|
|
}
|
2007-11-21 15:57:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-05-05 14:51:14 +00:00
|
|
|
OSL_ENSURE( false, "OApplicationController::openElement: illegal object type!" );
|
2007-11-21 15:57:49 +00:00
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2005-01-21 16:05:05 +00:00
|
|
|
return xRet;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-06-25 11:35:22 +00:00
|
|
|
IMPL_LINK( OApplicationController, OnSelectContainer, void*, _pType )
|
|
|
|
{
|
|
|
|
ElementType eType = (ElementType)reinterpret_cast< sal_IntPtr >( _pType );
|
|
|
|
getContainer()->selectContainer(eType);
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-01-21 16:05:05 +00:00
|
|
|
IMPL_LINK( OApplicationController, OnCreateWithPilot, void*, _pType )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2005-10-05 13:44:23 +00:00
|
|
|
ElementType eType = (ElementType)reinterpret_cast< sal_IntPtr >( _pType );
|
2005-01-21 16:05:05 +00:00
|
|
|
newElementWithPilot( eType );
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::newElementWithPilot( ElementType _eType )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( getContainer(), "OApplicationController::newElementWithPilot: without a view?" );
|
2004-08-02 14:28:11 +00:00
|
|
|
|
|
|
|
switch ( _eType )
|
|
|
|
{
|
2005-01-21 16:05:05 +00:00
|
|
|
case E_REPORT:
|
2004-08-02 14:28:11 +00:00
|
|
|
case E_FORM:
|
2005-01-21 16:05:05 +00:00
|
|
|
{
|
|
|
|
::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType);
|
2005-03-10 15:43:10 +00:00
|
|
|
if ( aHelper->isConnected() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2007-11-20 18:22:51 +00:00
|
|
|
sal_Int32 nCommandType = -1;
|
|
|
|
const ::rtl::OUString sName(getCurrentlySelectedName(nCommandType));
|
2005-04-06 10:40:09 +00:00
|
|
|
Reference< XComponent > xComponent,xDefinition;
|
2005-01-21 16:05:05 +00:00
|
|
|
if ( E_REPORT == _eType )
|
2005-04-06 10:40:09 +00:00
|
|
|
xComponent = aHelper->newReportWithPilot(xDefinition,nCommandType,sName);
|
2005-01-21 16:05:05 +00:00
|
|
|
else
|
2005-04-06 10:40:09 +00:00
|
|
|
xComponent = aHelper->newFormWithPilot(xDefinition,nCommandType,sName);
|
|
|
|
|
|
|
|
addDocumentListener(xComponent,xDefinition);
|
2005-01-21 16:05:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
case E_QUERY:
|
2005-01-21 16:05:05 +00:00
|
|
|
case E_TABLE:
|
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType);
|
2005-03-10 15:43:10 +00:00
|
|
|
if ( aHelper->isConnected() )
|
|
|
|
{
|
2008-01-29 07:51:32 +00:00
|
|
|
Reference< XComponent > xComponent,xDefinition;
|
2008-05-05 14:51:14 +00:00
|
|
|
if ( E_QUERY == _eType )
|
|
|
|
xComponent = aHelper->newQueryWithPilot();
|
|
|
|
else
|
|
|
|
xComponent = aHelper->newTableWithPilot();
|
2008-01-29 07:51:32 +00:00
|
|
|
addDocumentListener(xComponent,xDefinition);
|
2008-05-05 14:51:14 +00:00
|
|
|
}
|
2005-01-21 16:05:05 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-06-20 01:53:25 +00:00
|
|
|
case E_NONE:
|
|
|
|
break;
|
2005-01-21 16:05:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::newElement( ElementType _eType, sal_Bool _bSQLView )
|
|
|
|
{
|
|
|
|
OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
|
|
|
|
|
|
|
|
switch ( _eType )
|
|
|
|
{
|
|
|
|
case E_FORM:
|
2007-07-06 06:57:53 +00:00
|
|
|
case E_REPORT:
|
|
|
|
{
|
|
|
|
::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType);
|
2008-08-14 11:10:35 +00:00
|
|
|
if ( aHelper->isConnected() )
|
|
|
|
{
|
|
|
|
Reference< XComponent > xComponent,xDefinition;
|
|
|
|
sal_Int32 nCommandType = -1;
|
|
|
|
const ::rtl::OUString sName(getCurrentlySelectedName(nCommandType));
|
|
|
|
xComponent = aHelper->newDocument(_eType == E_FORM ? ID_FORM_NEW_TEXT : ID_REPORT_NEW_TEXT,xDefinition,nCommandType,sName);
|
|
|
|
addDocumentListener(xComponent,xDefinition);
|
|
|
|
}
|
2007-07-06 06:57:53 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-01-21 16:05:05 +00:00
|
|
|
case E_QUERY:
|
2004-08-02 14:28:11 +00:00
|
|
|
case E_TABLE:
|
|
|
|
{
|
2006-10-05 11:59:07 +00:00
|
|
|
::std::auto_ptr< DatabaseObjectView > pDesigner;
|
2005-10-24 07:30:07 +00:00
|
|
|
SharedConnection xConnection( ensureConnection() );
|
|
|
|
if ( xConnection.is() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
if ( _eType == E_TABLE )
|
|
|
|
{
|
2008-03-06 17:09:10 +00:00
|
|
|
pDesigner.reset( new TableDesigner( getORB(), this, getFrame() ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2007-07-06 06:57:53 +00:00
|
|
|
else if ( _eType == E_QUERY )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-03-06 17:09:10 +00:00
|
|
|
pDesigner.reset( new QueryDesigner( getORB(), this, getFrame(), false, _bSQLView ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2007-07-06 06:57:53 +00:00
|
|
|
|
2006-10-05 11:59:07 +00:00
|
|
|
Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
|
|
|
|
Reference< XComponent > xComponent( pDesigner->createNew( xDataSource ), UNO_QUERY );
|
2004-08-02 14:28:11 +00:00
|
|
|
addDocumentListener(xComponent,NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-06-20 01:53:25 +00:00
|
|
|
default:
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::addContainerListener(const Reference<XNameAccess>& _xCollection)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XContainer > xCont(_xCollection, UNO_QUERY);
|
2005-01-21 16:05:05 +00:00
|
|
|
if ( xCont.is() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
// add as listener to get notified if elements are inserted or removed
|
2005-01-21 16:05:05 +00:00
|
|
|
TContainerVector::iterator aFind = ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xCont);
|
|
|
|
if ( aFind == m_aCurrentContainers.end() )
|
|
|
|
{
|
|
|
|
xCont->addContainerListener(this);
|
|
|
|
m_aCurrentContainers.push_back(xCont);
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-05 14:51:14 +00:00
|
|
|
catch( const Exception& )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::renameEntry()
|
|
|
|
{
|
|
|
|
::vos::OGuard aSolarGuard(Application::GetSolarMutex());
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
|
|
|
|
::std::vector< ::rtl::OUString> aList;
|
|
|
|
getSelectionElementNames(aList);
|
|
|
|
|
|
|
|
Reference< XNameAccess > xContainer = getElements(getContainer()->getElementType());
|
|
|
|
OSL_ENSURE(aList.size() == 1,"Invalid rename call here. More than one element!");
|
2008-05-05 14:51:14 +00:00
|
|
|
if ( aList.empty() )
|
|
|
|
return;
|
2004-08-02 14:28:11 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if ( xContainer.is() )
|
|
|
|
{
|
2006-07-10 14:22:12 +00:00
|
|
|
::std::auto_ptr< IObjectNameCheck > pNameChecker;
|
|
|
|
::std::auto_ptr< OSaveAsDlg > aDialog;
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
Reference<XRename> xRename;
|
2006-08-28 14:05:18 +00:00
|
|
|
const ElementType eType = getContainer()->getElementType();
|
2004-08-02 14:28:11 +00:00
|
|
|
switch( eType )
|
|
|
|
{
|
|
|
|
case E_FORM:
|
|
|
|
case E_REPORT:
|
|
|
|
{
|
|
|
|
Reference<XHierarchicalNameContainer> xHNames(xContainer, UNO_QUERY);
|
|
|
|
if ( xHNames.is() )
|
|
|
|
{
|
|
|
|
String sLabel;
|
|
|
|
if ( eType == E_FORM )
|
|
|
|
sLabel = String(ModuleRes( STR_FRM_LABEL ));
|
|
|
|
else
|
|
|
|
sLabel = String(ModuleRes( STR_RPT_LABEL ));
|
|
|
|
|
|
|
|
::rtl::OUString sName = *aList.begin();
|
|
|
|
if ( xHNames->hasByHierarchicalName(sName) )
|
|
|
|
{
|
|
|
|
xRename.set(xHNames->getByHierarchicalName(sName),UNO_QUERY);
|
|
|
|
Reference<XChild> xChild(xRename,UNO_QUERY);
|
|
|
|
if ( xChild.is() )
|
|
|
|
{
|
|
|
|
Reference<XHierarchicalNameContainer> xParent(xChild->getParent(),UNO_QUERY);
|
|
|
|
if ( xParent.is() )
|
|
|
|
{
|
|
|
|
xHNames = xParent;
|
|
|
|
Reference<XPropertySet>(xRename,UNO_QUERY)->getPropertyValue(PROPERTY_NAME) >>= sName;
|
|
|
|
}
|
|
|
|
}
|
2006-07-10 14:22:12 +00:00
|
|
|
pNameChecker.reset( new HierarchicalNameCheck( xHNames.get(), String() ) );
|
|
|
|
aDialog.reset( new OSaveAsDlg(
|
|
|
|
getView(), getORB(), sName, sLabel, *pNameChecker, SAD_TITLE_RENAME ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_TABLE:
|
2005-10-24 07:30:07 +00:00
|
|
|
ensureConnection();
|
|
|
|
if ( !getConnection().is() )
|
2005-04-06 08:47:41 +00:00
|
|
|
break;
|
|
|
|
// NO break
|
|
|
|
case E_QUERY:
|
2004-08-02 14:28:11 +00:00
|
|
|
if ( xContainer->hasByName(*aList.begin()) )
|
|
|
|
{
|
|
|
|
xRename.set(xContainer->getByName(*aList.begin()),UNO_QUERY);
|
2005-04-06 08:47:41 +00:00
|
|
|
sal_Int32 nCommandType = eType == E_QUERY ? CommandType::QUERY : CommandType::TABLE;
|
2005-10-24 07:30:07 +00:00
|
|
|
|
2006-10-18 12:29:46 +00:00
|
|
|
ensureConnection();
|
2006-07-10 14:22:12 +00:00
|
|
|
pNameChecker.reset( new DynamicTableOrQueryNameCheck( getConnection(), nCommandType ) );
|
|
|
|
aDialog.reset( new OSaveAsDlg(
|
|
|
|
getView(), nCommandType, getORB(), getConnection(),
|
|
|
|
*aList.begin(), *pNameChecker, SAD_TITLE_RENAME ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-06-20 01:53:25 +00:00
|
|
|
default:
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 14:22:12 +00:00
|
|
|
if ( xRename.is() && aDialog.get() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
sal_Bool bTryAgain = sal_True;
|
|
|
|
while( bTryAgain )
|
|
|
|
{
|
2006-07-10 14:22:12 +00:00
|
|
|
if ( aDialog->Execute() == RET_OK )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
::rtl::OUString sNewName;
|
|
|
|
if ( eType == E_TABLE )
|
|
|
|
{
|
2006-07-10 14:22:12 +00:00
|
|
|
::rtl::OUString sName = aDialog->getName();
|
|
|
|
::rtl::OUString sCatalog = aDialog->getCatalog();
|
|
|
|
::rtl::OUString sSchema = aDialog->getSchema();
|
2004-08-02 14:28:11 +00:00
|
|
|
|
2006-08-28 14:05:18 +00:00
|
|
|
sNewName = ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sName, sal_False, ::dbtools::eInDataManipulation );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
else
|
2006-07-10 14:22:12 +00:00
|
|
|
sNewName = aDialog->getName();
|
2004-08-02 14:28:11 +00:00
|
|
|
|
|
|
|
::rtl::OUString sOldName = *aList.begin();
|
|
|
|
if ( eType == E_FORM || eType == E_REPORT )
|
|
|
|
{
|
|
|
|
Reference<XContent> xContent(xRename,UNO_QUERY);
|
|
|
|
if ( xContent.is() )
|
|
|
|
{
|
|
|
|
sOldName = xContent->getIdentifier()->getContentIdentifier();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xRename->rename(sNewName);
|
|
|
|
|
2007-05-09 12:24:34 +00:00
|
|
|
if ( eType == E_TABLE )
|
2006-08-28 14:05:18 +00:00
|
|
|
{
|
2007-05-09 12:24:34 +00:00
|
|
|
Reference<XPropertySet> xProp(xRename,UNO_QUERY);
|
|
|
|
sNewName = ::dbaui::composeTableName( m_xMetaData, xProp, ::dbtools::eInDataManipulation, false, false, false );
|
2006-08-28 14:05:18 +00:00
|
|
|
}
|
2007-05-09 12:24:34 +00:00
|
|
|
getContainer()->elementReplaced( eType , sOldName, sNewName );
|
2004-08-02 14:28:11 +00:00
|
|
|
|
|
|
|
bTryAgain = sal_False;
|
|
|
|
}
|
2008-05-05 14:51:14 +00:00
|
|
|
catch(const SQLException& )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
catch(const ElementExistException& e)
|
|
|
|
{
|
|
|
|
static ::rtl::OUString sStatus = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000"));
|
2006-07-10 14:22:12 +00:00
|
|
|
String sMsg = String( ModuleRes( STR_NAME_ALREADY_EXISTS ) );
|
2004-08-02 14:28:11 +00:00
|
|
|
sMsg.SearchAndReplace('#',e.Message);
|
|
|
|
showError(SQLExceptionInfo(SQLException(sMsg, e.Context, sStatus, 0, Any())));
|
|
|
|
}
|
|
|
|
catch(const Exception& )
|
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bTryAgain = sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(const Exception& )
|
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-06-25 11:35:22 +00:00
|
|
|
void OApplicationController::onEntryDeSelect(SvTreeListBox& /*_rTree*/)
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-06-25 11:35:22 +00:00
|
|
|
SelectionGuard aSelGuard( *m_pSelectionNotifier );
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
InvalidateAll();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::onEntrySelect(SvLBoxEntry* _pEntry)
|
|
|
|
{
|
|
|
|
InvalidateAll();
|
|
|
|
|
|
|
|
OApplicationView* pView = getContainer();
|
|
|
|
if ( pView )
|
|
|
|
{
|
2008-06-25 11:35:22 +00:00
|
|
|
SelectionGuard aSelGuard( *m_pSelectionNotifier );
|
|
|
|
|
2007-09-26 13:46:26 +00:00
|
|
|
const ElementType eType = pView->getElementType();
|
|
|
|
if ( _pEntry && pView->isALeafSelected() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2007-09-26 13:46:26 +00:00
|
|
|
const ::rtl::OUString sName = pView->getQualifiedName( _pEntry );
|
|
|
|
selectEntry(eType,sName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::selectEntry(const ElementType _eType,const ::rtl::OUString& _sName)
|
|
|
|
{
|
|
|
|
OApplicationView* pView = getContainer();
|
|
|
|
Reference< XContent> xContent;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
switch( _eType )
|
|
|
|
{
|
|
|
|
case E_FORM:
|
|
|
|
case E_REPORT:
|
|
|
|
if ( _sName.getLength() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2007-09-26 13:46:26 +00:00
|
|
|
Reference< XHierarchicalNameAccess > xContainer(getElements(_eType),UNO_QUERY);
|
|
|
|
if ( xContainer.is() && xContainer->hasByHierarchicalName(_sName) )
|
|
|
|
xContent.set(xContainer->getByHierarchicalName(_sName),UNO_QUERY);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case E_QUERY:
|
|
|
|
if ( pView->isPreviewEnabled() )
|
|
|
|
{
|
|
|
|
SharedConnection xConnection( ensureConnection() );
|
|
|
|
if ( xConnection.is() )
|
|
|
|
pView->showPreview(getDatabaseName(),xConnection,_sName,sal_False);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
case E_TABLE:
|
|
|
|
{
|
|
|
|
SharedConnection xConnection( ensureConnection() );
|
|
|
|
if ( xConnection.is() )
|
|
|
|
{
|
|
|
|
pView->showPreview(getDatabaseName(),xConnection,_sName,_eType == E_TABLE);
|
2006-06-20 01:53:25 +00:00
|
|
|
return;
|
2007-09-26 13:46:26 +00:00
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2007-09-26 13:46:26 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-05 14:51:14 +00:00
|
|
|
catch( const SQLException& )
|
2007-09-26 13:46:26 +00:00
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
|
2007-09-26 13:46:26 +00:00
|
|
|
}
|
2008-05-05 14:51:14 +00:00
|
|
|
catch(const Exception& )
|
2007-09-26 13:46:26 +00:00
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2007-09-26 13:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pView->showPreview(xContent);
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2008-03-06 17:09:10 +00:00
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
IMPL_LINK( OApplicationController, OnClipboardChanged, void*, EMPTYARG )
|
|
|
|
{
|
|
|
|
return OnInvalidateClipboard( NULL );
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
IMPL_LINK(OApplicationController, OnInvalidateClipboard, void*, EMPTYARG)
|
|
|
|
{
|
|
|
|
InvalidateFeature(ID_BROWSER_CUT);
|
|
|
|
InvalidateFeature(ID_BROWSER_COPY);
|
|
|
|
InvalidateFeature(ID_BROWSER_PASTE);
|
|
|
|
InvalidateFeature(SID_DB_APP_PASTE_SPECIAL);
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:53:25 +00:00
|
|
|
void OApplicationController::onCutEntry(SvLBoxEntry* /*_pEntry*/)
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:53:25 +00:00
|
|
|
void OApplicationController::onCopyEntry(SvLBoxEntry* /*_pEntry*/)
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2004-09-09 08:38:28 +00:00
|
|
|
Execute(ID_BROWSER_COPY,Sequence<PropertyValue>());
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:53:25 +00:00
|
|
|
void OApplicationController::onPasteEntry(SvLBoxEntry* /*_pEntry*/)
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2004-09-09 08:38:28 +00:00
|
|
|
Execute(ID_BROWSER_PASTE,Sequence<PropertyValue>());
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:53:25 +00:00
|
|
|
void OApplicationController::onDeleteEntry(SvLBoxEntry* /*_pEntry*/)
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2004-09-09 08:38:28 +00:00
|
|
|
ElementType eType = getContainer()->getElementType();
|
|
|
|
sal_uInt16 nId = 0;
|
|
|
|
switch(eType)
|
|
|
|
{
|
|
|
|
case E_TABLE:
|
|
|
|
nId = SID_DB_APP_TABLE_DELETE;
|
|
|
|
break;
|
|
|
|
case E_QUERY:
|
|
|
|
nId = SID_DB_APP_QUERY_DELETE;
|
|
|
|
break;
|
|
|
|
case E_FORM:
|
|
|
|
nId = SID_DB_APP_FORM_DELETE;
|
|
|
|
break;
|
|
|
|
case E_REPORT:
|
|
|
|
nId = SID_DB_APP_REPORT_DELETE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
OSL_ENSURE(0,"Invalid ElementType!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
executeChecked(nId,Sequence<PropertyValue>());
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2008-06-25 11:35:22 +00:00
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-06-25 11:35:22 +00:00
|
|
|
void OApplicationController::executeUnChecked(const URL& _rCommand, const Sequence< PropertyValue>& aArgs)
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-06-25 11:35:22 +00:00
|
|
|
OApplicationController_CBASE::executeUnChecked( _rCommand, aArgs );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::executeChecked(const URL& _rCommand, const Sequence< PropertyValue>& aArgs)
|
|
|
|
{
|
|
|
|
OApplicationController_CBASE::executeChecked( _rCommand, aArgs );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::executeUnChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue>& aArgs)
|
|
|
|
{
|
|
|
|
OApplicationController_CBASE::executeUnChecked( _nCommandId, aArgs );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::executeChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue>& aArgs)
|
|
|
|
{
|
|
|
|
OApplicationController_CBASE::executeChecked( _nCommandId, aArgs );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool OApplicationController::isCommandEnabled(sal_uInt16 _nCommandId) const
|
|
|
|
{
|
|
|
|
return OApplicationController_CBASE::isCommandEnabled( _nCommandId );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool OApplicationController::isCommandEnabled( const ::rtl::OUString& _rCompleteCommandURL ) const
|
|
|
|
{
|
|
|
|
return OApplicationController_CBASE::isCommandEnabled( _rCompleteCommandURL );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_uInt16 OApplicationController::registerCommandURL( const ::rtl::OUString& _rCompleteCommandURL )
|
|
|
|
{
|
|
|
|
return OApplicationController_CBASE::registerCommandURL( _rCompleteCommandURL );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::notifyHiContrastChanged()
|
|
|
|
{
|
|
|
|
OApplicationController_CBASE::notifyHiContrastChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XController > OApplicationController::getXController() throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return OApplicationController_CBASE::getXController();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
bool OApplicationController::interceptUserInput( const NotifyEvent& _rEvent )
|
|
|
|
{
|
|
|
|
return OApplicationController_CBASE::interceptUserInput( _rEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
PopupMenu* OApplicationController::getContextMenu( Control& /*_rControl*/ ) const
|
|
|
|
{
|
|
|
|
return new PopupMenu( ModuleRes( RID_MENU_APP_EDIT ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
IController& OApplicationController::getCommandController()
|
|
|
|
{
|
|
|
|
return *static_cast< IApplicationController* >( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
::cppu::OInterfaceContainerHelper* OApplicationController::getContextMenuInterceptors()
|
|
|
|
{
|
|
|
|
return &m_aContextMenuInterceptors;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Any OApplicationController::getCurrentSelection( Control& _rControl ) const
|
|
|
|
{
|
|
|
|
Sequence< NamedDatabaseObject > aSelection;
|
|
|
|
getContainer()->describeCurrentSelectionForControl( _rControl, aSelection );
|
|
|
|
return makeAny( aSelection );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2004-10-22 10:59:12 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:53:25 +00:00
|
|
|
sal_Bool OApplicationController::requestQuickHelp( const SvLBoxEntry* /*_pEntry*/, String& /*_rText*/ ) const
|
2004-10-22 10:59:12 +00:00
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 01:53:25 +00:00
|
|
|
sal_Bool OApplicationController::requestDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
TransferableHelper* pTransfer = NULL;
|
|
|
|
if ( getContainer() && getContainer()->getSelectionCount() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
pTransfer = copyObject( );
|
|
|
|
Reference< XTransferable> xEnsureDelete = pTransfer;
|
|
|
|
|
2005-01-05 11:32:18 +00:00
|
|
|
if ( pTransfer && getContainer()->getDetailView() )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
ElementType eType = getContainer()->getElementType();
|
2008-01-30 07:41:07 +00:00
|
|
|
pTransfer->StartDrag( getContainer()->getDetailView()->getTreeWindow(), ((eType == E_FORM || eType == E_REPORT) ? DND_ACTION_COPYMOVE : DND_ACTION_COPY) );
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(const Exception& )
|
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL != pTransfer;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Int8 OApplicationController::queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors )
|
|
|
|
{
|
2004-09-09 08:38:28 +00:00
|
|
|
sal_Int8 nActionAskedFor = _rEvt.mnAction;
|
2004-08-02 14:28:11 +00:00
|
|
|
// check if we're a table or query container
|
|
|
|
OApplicationView* pView = getContainer();
|
|
|
|
if ( pView && !isDataSourceReadOnly() )
|
|
|
|
{
|
|
|
|
ElementType eType = pView->getElementType();
|
|
|
|
if ( eType != E_NONE && (eType != E_TABLE || !isConnectionReadOnly()) )
|
|
|
|
{
|
|
|
|
// check for the concrete type
|
|
|
|
if(::std::find_if(_rFlavors.begin(),_rFlavors.end(),TAppSupportedSotFunctor(eType,sal_True)) != _rFlavors.end())
|
|
|
|
return DND_ACTION_COPY;
|
|
|
|
if ( eType == E_FORM || eType == E_REPORT )
|
|
|
|
{
|
2005-09-23 11:14:21 +00:00
|
|
|
sal_Int8 nAction = OComponentTransferable::canExtractComponentDescriptor(_rFlavors,eType == E_FORM) ? DND_ACTION_COPY : DND_ACTION_NONE;
|
2004-08-02 14:28:11 +00:00
|
|
|
if ( nAction != DND_ACTION_NONE )
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pHitEntry = pView->getEntry(_rEvt.maPosPixel);
|
|
|
|
::rtl::OUString sName;
|
|
|
|
if ( pHitEntry )
|
|
|
|
{
|
2006-10-05 11:59:07 +00:00
|
|
|
sName = pView->getQualifiedName( pHitEntry );
|
2004-08-02 14:28:11 +00:00
|
|
|
if ( sName.getLength() )
|
|
|
|
{
|
|
|
|
Reference< XHierarchicalNameAccess > xContainer(getElements(pView->getElementType()),UNO_QUERY);
|
|
|
|
if ( xContainer.is() && xContainer->hasByHierarchicalName(sName) )
|
|
|
|
{
|
|
|
|
Reference< XHierarchicalNameAccess > xHitObject(xContainer->getByHierarchicalName(sName),UNO_QUERY);
|
|
|
|
if ( xHitObject.is() )
|
2004-09-09 08:38:28 +00:00
|
|
|
nAction = nActionAskedFor & DND_ACTION_COPYMOVE;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
nAction = DND_ACTION_NONE;
|
|
|
|
}
|
|
|
|
}
|
2005-09-23 11:14:21 +00:00
|
|
|
/*else
|
2005-01-21 16:05:05 +00:00
|
|
|
nAction = nActionAskedFor & DND_ACTION_COPYMOVE;
|
2005-09-23 11:14:21 +00:00
|
|
|
*/
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
return nAction;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DND_ACTION_NONE;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Int8 OApplicationController::executeDrop( const ExecuteDropEvent& _rEvt )
|
|
|
|
{
|
|
|
|
OApplicationView* pView = getContainer();
|
|
|
|
if ( !pView || pView->getElementType() == E_NONE )
|
|
|
|
{
|
|
|
|
DBG_ERROR("OApplicationController::executeDrop: what the hell did queryDrop do?");
|
|
|
|
// queryDrop shoud not have allowed us to reach this situation ....
|
|
|
|
return DND_ACTION_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// a TransferableDataHelper for accessing the dropped data
|
|
|
|
TransferableDataHelper aDroppedData(_rEvt.maDropEvent.Transferable);
|
|
|
|
|
|
|
|
|
|
|
|
// reset the data of the previous async drop (if any)
|
|
|
|
if ( m_nAsyncDrop )
|
|
|
|
Application::RemoveUserEvent(m_nAsyncDrop);
|
|
|
|
|
|
|
|
|
|
|
|
m_nAsyncDrop = 0;
|
|
|
|
m_aAsyncDrop.aDroppedData.clear();
|
|
|
|
m_aAsyncDrop.nType = pView->getElementType();
|
|
|
|
m_aAsyncDrop.nAction = _rEvt.mnAction;
|
|
|
|
m_aAsyncDrop.bError = sal_False;
|
|
|
|
m_aAsyncDrop.bHtml = sal_False;
|
|
|
|
m_aAsyncDrop.aUrl = ::rtl::OUString();
|
|
|
|
|
|
|
|
|
|
|
|
// loop through the available formats and see what we can do ...
|
|
|
|
// first we have to check if it is our own format, if not we have to copy the stream :-(
|
|
|
|
if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(aDroppedData.GetDataFlavorExVector()) )
|
|
|
|
{
|
|
|
|
m_aAsyncDrop.aDroppedData = ODataAccessObjectTransferable::extractObjectDescriptor(aDroppedData);
|
|
|
|
|
|
|
|
// asyncron because we some dialogs and we aren't allowed to show them while in D&D
|
|
|
|
m_nAsyncDrop = Application::PostUserEvent(LINK(this, OApplicationController, OnAsyncDrop));
|
|
|
|
return DND_ACTION_COPY;
|
|
|
|
}
|
2005-09-23 11:14:21 +00:00
|
|
|
else if ( OComponentTransferable::canExtractComponentDescriptor(aDroppedData.GetDataFlavorExVector(),m_aAsyncDrop.nType == E_FORM) )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
m_aAsyncDrop.aDroppedData = OComponentTransferable::extractComponentDescriptor(aDroppedData);
|
|
|
|
SvLBoxEntry* pHitEntry = pView->getEntry(_rEvt.maPosPixel);
|
|
|
|
if ( pHitEntry )
|
2006-10-05 11:59:07 +00:00
|
|
|
m_aAsyncDrop.aUrl = pView->getQualifiedName( pHitEntry );
|
2004-08-02 14:28:11 +00:00
|
|
|
|
|
|
|
sal_Int8 nAction = _rEvt.mnAction;
|
|
|
|
Reference<XContent> xContent;
|
|
|
|
m_aAsyncDrop.aDroppedData[daComponent] >>= xContent;
|
|
|
|
if ( xContent.is() )
|
|
|
|
{
|
|
|
|
::rtl::OUString sName = xContent->getIdentifier()->getContentIdentifier();
|
|
|
|
sal_Int32 nIndex = 0;
|
|
|
|
sName = sName.copy(sName.getToken(0,'/',nIndex).getLength() + 1);
|
|
|
|
if ( m_aAsyncDrop.aUrl.Len() >= sName.getLength() && 0 == sName.compareTo(m_aAsyncDrop.aUrl,sName.getLength()) )
|
|
|
|
{
|
|
|
|
m_aAsyncDrop.aDroppedData.clear();
|
|
|
|
return DND_ACTION_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if move is allowed, if another object with the same name exists only copy is allowed
|
|
|
|
Reference< XHierarchicalNameAccess > xContainer(getElements(m_aAsyncDrop.nType),UNO_QUERY);
|
|
|
|
Reference<XNameAccess> xNameAccess(xContainer,UNO_QUERY);
|
|
|
|
|
|
|
|
if ( m_aAsyncDrop.aUrl.Len() && xContainer.is() && xContainer->hasByHierarchicalName(m_aAsyncDrop.aUrl) )
|
|
|
|
xNameAccess.set(xContainer->getByHierarchicalName(m_aAsyncDrop.aUrl),UNO_QUERY);
|
|
|
|
|
|
|
|
if ( xNameAccess.is() )
|
|
|
|
{
|
|
|
|
Reference<XPropertySet> xProp(xContent,UNO_QUERY);
|
|
|
|
if ( xProp.is() )
|
|
|
|
{
|
|
|
|
xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
|
|
|
|
if ( xNameAccess.is() && xNameAccess->hasByName(sName) )
|
|
|
|
nAction &= ~DND_ACTION_MOVE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nAction &= ~DND_ACTION_MOVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( nAction != DND_ACTION_NONE )
|
|
|
|
{
|
|
|
|
m_aAsyncDrop.nAction = nAction;
|
|
|
|
// asyncron because we some dialogs and we aren't allowed to show them while in D&D
|
|
|
|
m_nAsyncDrop = Application::PostUserEvent(LINK(this, OApplicationController, OnAsyncDrop));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_aAsyncDrop.aDroppedData.clear();
|
|
|
|
return nAction;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-24 07:30:07 +00:00
|
|
|
SharedConnection xConnection( ensureConnection() );
|
|
|
|
if ( xConnection.is() && m_aTableCopyHelper.copyTagTable( aDroppedData, m_aAsyncDrop, xConnection ) )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
// asyncron because we some dialogs and we aren't allowed to show them while in D&D
|
|
|
|
m_nAsyncDrop = Application::PostUserEvent(LINK(this, OApplicationController, OnAsyncDrop));
|
|
|
|
return DND_ACTION_COPY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DND_ACTION_NONE;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XModel > SAL_CALL OApplicationController::getModel(void) throw( RuntimeException )
|
|
|
|
{
|
2005-03-10 15:43:10 +00:00
|
|
|
return m_xModel;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
2008-03-06 17:09:10 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::onConnectedModel()
|
|
|
|
{
|
|
|
|
sal_Int32 nConnectedControllers( 0 );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XModel2 > xModel( m_xModel, UNO_QUERY_THROW );
|
|
|
|
Reference< XEnumeration > xEnumControllers( xModel->getControllers(), UNO_SET_THROW );
|
|
|
|
while ( xEnumControllers->hasMoreElements() )
|
|
|
|
{
|
|
|
|
Reference< XController > xController( xEnumControllers->nextElement(), UNO_QUERY_THROW );
|
|
|
|
++nConnectedControllers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nConnectedControllers > 1 )
|
|
|
|
{ // we are not the first connected controller, there were already others
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_aControllerConnectedEvent.Call();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
IMPL_LINK( OApplicationController, OnFirstControllerConnected, void*, /**/ )
|
|
|
|
{
|
|
|
|
// if we have forms or reports which contain macros/scripts, then show a warning
|
|
|
|
// which suggests the user to migrate them to the database document
|
|
|
|
|
|
|
|
Reference< XEmbeddedScripts > xDocumentScripts( m_xModel, UNO_QUERY );
|
|
|
|
if ( xDocumentScripts.is() )
|
|
|
|
{
|
|
|
|
// no need to show this warning, obviously the document supports embedding scripts
|
|
|
|
// into itself, so there are no "old-style" forms/reports which have macros/scripts
|
|
|
|
// themselves
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2008-06-06 13:06:49 +00:00
|
|
|
// If the migration just happened, but was not successful, the document is reloaded.
|
|
|
|
// In this case, we should not show the warning, again.
|
|
|
|
::comphelper::NamedValueCollection aModelArgs( m_xModel->getArgs() );
|
|
|
|
if ( aModelArgs.getOrDefault( "SuppressMigrationWarning", sal_False ) )
|
|
|
|
return 0L;
|
|
|
|
|
|
|
|
// also, if the document is read-only, then no migration is possible, and the
|
|
|
|
// respective menu entry is hidden. So, don't show the warning in this case, too.
|
|
|
|
if ( Reference< XStorable >( m_xModel, UNO_QUERY_THROW )->isReadonly() )
|
|
|
|
return 0L;
|
|
|
|
|
|
|
|
SQLWarning aWarning;
|
|
|
|
aWarning.Message = String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS ) );
|
|
|
|
SQLException aDetail;
|
|
|
|
aDetail.Message = String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS_DETAIL ) );
|
|
|
|
aWarning.NextException <<= aDetail;
|
|
|
|
|
2008-03-06 17:09:10 +00:00
|
|
|
::comphelper::ComponentContext aContext( getORB() );
|
|
|
|
Sequence< Any > aArgs(1);
|
|
|
|
aArgs[0] <<= NamedValue( PROPERTY_SQLEXCEPTION, makeAny( aWarning ) );
|
|
|
|
Reference< XExecutableDialog > xDialog(
|
|
|
|
aContext.createComponentWithArguments( "com.sun.star.sdb.ErrorMessageDialog", aArgs ),
|
|
|
|
UNO_QUERY_THROW );
|
|
|
|
xDialog->execute();
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1L;
|
|
|
|
}
|
|
|
|
|
2004-08-02 14:28:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2005-09-23 11:14:21 +00:00
|
|
|
sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel > & _rxModel) throw( RuntimeException )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2005-09-23 11:14:21 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
Reference< XOfficeDatabaseDocument > xOfficeDoc( _rxModel, UNO_QUERY );
|
|
|
|
if ( !xOfficeDoc.is() && _rxModel.is() )
|
|
|
|
{
|
|
|
|
DBG_ERROR( "OApplicationController::attachModel: invalid model!" );
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG_ASSERT( !( m_xModel.is() && ( m_xModel != _rxModel ) ),
|
|
|
|
"OApplicationController::attachModel: missing implementation: setting a new model while we have another one!" );
|
|
|
|
// at least: remove as property change listener from the old model/data source
|
|
|
|
|
|
|
|
m_xModel = _rxModel;
|
|
|
|
if ( _rxModel.is() )
|
2008-03-06 17:09:10 +00:00
|
|
|
{
|
|
|
|
m_xDocumentModify.set( m_xModel, UNO_QUERY_THROW );
|
2008-10-16 06:57:26 +00:00
|
|
|
m_aModelConnector.connect( _rxModel, this );
|
2008-03-06 17:09:10 +00:00
|
|
|
onConnectedModel();
|
|
|
|
}
|
2005-09-23 11:14:21 +00:00
|
|
|
else
|
2008-03-06 17:09:10 +00:00
|
|
|
{
|
|
|
|
m_xDocumentModify.clear();
|
2005-09-23 11:14:21 +00:00
|
|
|
m_aModelConnector.clear();
|
2008-03-06 17:09:10 +00:00
|
|
|
}
|
2005-09-23 11:14:21 +00:00
|
|
|
|
2005-03-10 15:43:10 +00:00
|
|
|
m_xDataSource.set(xOfficeDoc.is() ? xOfficeDoc->getDataSource() : Reference<XDataSource>(),UNO_QUERY);
|
2005-09-23 11:14:21 +00:00
|
|
|
if ( !m_xDataSource.is() )
|
|
|
|
m_sDatabaseName = ::rtl::OUString();
|
|
|
|
else
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
m_xDataSource->getPropertyValue(PROPERTY_NAME) >>= m_sDatabaseName;
|
|
|
|
|
|
|
|
m_xDataSource->addPropertyChangeListener(PROPERTY_INFO, this);
|
|
|
|
m_xDataSource->addPropertyChangeListener(PROPERTY_URL, this);
|
|
|
|
m_xDataSource->addPropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED, this);
|
|
|
|
m_xDataSource->addPropertyChangeListener(PROPERTY_LAYOUTINFORMATION, this);
|
|
|
|
m_xDataSource->addPropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL, this);
|
|
|
|
m_xDataSource->addPropertyChangeListener(PROPERTY_TABLEFILTER, this);
|
|
|
|
m_xDataSource->addPropertyChangeListener(PROPERTY_TABLETYPEFILTER, this);
|
|
|
|
m_xDataSource->addPropertyChangeListener(PROPERTY_USER, this);
|
|
|
|
// to get the 'modified' for the data source
|
2005-03-10 15:43:10 +00:00
|
|
|
Reference< XModifyBroadcaster > xBroadcaster(m_xModel, UNO_QUERY);
|
2004-08-02 14:28:11 +00:00
|
|
|
if ( xBroadcaster.is() )
|
|
|
|
xBroadcaster->addModifyListener(static_cast<XModifyListener*>(this));
|
|
|
|
|
|
|
|
Sequence<PropertyValue> aFields;
|
|
|
|
m_xDataSource->getPropertyValue(PROPERTY_LAYOUTINFORMATION) >>= aFields;
|
|
|
|
PropertyValue *pIter = aFields.getArray();
|
|
|
|
PropertyValue *pEnd = pIter + aFields.getLength();
|
|
|
|
for (; pIter != pEnd && pIter->Name != INFO_PREVIEW; ++pIter)
|
|
|
|
;
|
|
|
|
|
|
|
|
if ( pIter != pEnd )
|
|
|
|
{
|
|
|
|
sal_Int32 nValue = 0;
|
|
|
|
pIter->Value >>= nValue;
|
|
|
|
m_ePreviewMode = static_cast<PreviewMode>(nValue);
|
|
|
|
}
|
|
|
|
}
|
2008-05-05 14:51:14 +00:00
|
|
|
catch( const Exception& )
|
2004-08-02 14:28:11 +00:00
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
}
|
2005-09-23 11:14:21 +00:00
|
|
|
|
|
|
|
return sal_True;
|
2004-08-02 14:28:11 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::containerFound( const Reference< XContainer >& _xContainer)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if ( _xContainer.is() )
|
|
|
|
{
|
2005-01-21 16:05:05 +00:00
|
|
|
m_aCurrentContainers.push_back(_xContainer);
|
2004-08-02 14:28:11 +00:00
|
|
|
_xContainer->addContainerListener(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(0,"Could not listener on the container!");
|
|
|
|
}
|
|
|
|
}
|
2007-09-26 13:46:26 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2007-11-20 18:22:51 +00:00
|
|
|
::rtl::OUString OApplicationController::getCurrentlySelectedName(sal_Int32& _rnCommandType) const
|
|
|
|
{
|
|
|
|
_rnCommandType = ( (getContainer()->getElementType() == E_QUERY)
|
|
|
|
? CommandType::QUERY : ( (getContainer()->getElementType() == E_TABLE) ? CommandType::TABLE : -1 ));
|
|
|
|
|
|
|
|
|
|
|
|
::rtl::OUString sName;
|
|
|
|
if ( _rnCommandType != -1 )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sName = getContainer()->getQualifiedName( NULL );
|
|
|
|
OSL_ENSURE( sName.getLength(), "OApplicationController::newElementWithPilot: no name given!" );
|
|
|
|
}
|
2008-05-05 14:51:14 +00:00
|
|
|
catch( const Exception& )
|
2007-11-20 18:22:51 +00:00
|
|
|
{
|
2008-05-05 14:51:14 +00:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2007-11-20 18:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return sName;
|
|
|
|
}
|
2008-06-25 11:35:22 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OApplicationController::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
m_pSelectionNotifier->addListener( _Listener );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OApplicationController::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
m_pSelectionNotifier->removeListener( _Listener );
|
|
|
|
}
|
|
|
|
|
2007-11-20 18:22:51 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2007-09-26 13:46:26 +00:00
|
|
|
::sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) throw (IllegalArgumentException, RuntimeException)
|
|
|
|
{
|
|
|
|
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
Sequence< ::rtl::OUString> aSelection;
|
|
|
|
if ( !_aSelection.hasValue() || !getView() )
|
|
|
|
{
|
|
|
|
getContainer()->selectElements(aSelection);
|
|
|
|
return sal_True;
|
|
|
|
}
|
2008-06-25 11:35:22 +00:00
|
|
|
|
|
|
|
// --------------------------------------------------------------
|
|
|
|
// BEGIN compatibility
|
2007-09-26 13:46:26 +00:00
|
|
|
Sequence< NamedValue > aCurrentSelection;
|
|
|
|
if ( (_aSelection >>= aCurrentSelection) && aCurrentSelection.getLength() )
|
|
|
|
{
|
|
|
|
ElementType eType = E_NONE;
|
|
|
|
const NamedValue* pIter = aCurrentSelection.getConstArray();
|
|
|
|
const NamedValue* pEnd = pIter + aCurrentSelection.getLength();
|
|
|
|
for(;pIter != pEnd;++pIter)
|
|
|
|
{
|
|
|
|
if ( pIter->Name.equalsAscii("Type") )
|
|
|
|
{
|
|
|
|
sal_Int32 nType = 0;
|
|
|
|
pIter->Value >>= nType;
|
2008-06-25 11:35:22 +00:00
|
|
|
if ( nType < DatabaseObject::TABLE || nType > DatabaseObject::REPORT )
|
2007-09-26 13:46:26 +00:00
|
|
|
throw IllegalArgumentException();
|
2008-06-25 11:35:22 +00:00
|
|
|
eType = static_cast< ElementType >( nType );
|
2007-09-26 13:46:26 +00:00
|
|
|
}
|
|
|
|
else if ( pIter->Name.equalsAscii("Selection") )
|
|
|
|
pIter->Value >>= aSelection;
|
|
|
|
}
|
|
|
|
|
2008-06-25 11:35:22 +00:00
|
|
|
m_aSelectContainerEvent.CancelCall(); // just in case the async select request was running
|
2008-03-06 17:09:10 +00:00
|
|
|
getContainer()->selectContainer(eType);
|
2007-09-26 13:46:26 +00:00
|
|
|
getContainer()->selectElements(aSelection);
|
|
|
|
return sal_True;
|
|
|
|
}
|
2008-06-25 11:35:22 +00:00
|
|
|
// END compatibility
|
|
|
|
// --------------------------------------------------------------
|
|
|
|
|
|
|
|
Sequence< NamedDatabaseObject > aSelectedObjects;
|
|
|
|
if ( !( _aSelection >>= aSelectedObjects ) )
|
|
|
|
{
|
|
|
|
aSelectedObjects.realloc( 1 );
|
|
|
|
if ( !( _aSelection >>= aSelectedObjects[0] ) )
|
|
|
|
throw IllegalArgumentException();
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectionByElementType aSelectedElements;
|
|
|
|
ElementType eSelectedCategory = E_NONE;
|
|
|
|
for ( const NamedDatabaseObject* pObject = aSelectedObjects.getConstArray();
|
|
|
|
pObject != aSelectedObjects.getConstArray() + aSelectedObjects.getLength();
|
|
|
|
++pObject
|
|
|
|
)
|
|
|
|
{
|
|
|
|
switch ( pObject->Type )
|
|
|
|
{
|
|
|
|
case DatabaseObject::TABLE:
|
|
|
|
case DatabaseObjectContainer::SCHEMA:
|
|
|
|
case DatabaseObjectContainer::CATALOG:
|
|
|
|
aSelectedElements[ E_TABLE ].push_back( pObject->Name );
|
|
|
|
break;
|
|
|
|
case DatabaseObject::QUERY:
|
|
|
|
aSelectedElements[ E_QUERY ].push_back( pObject->Name );
|
|
|
|
break;
|
|
|
|
case DatabaseObject::FORM:
|
|
|
|
case DatabaseObjectContainer::FORMS_FOLDER:
|
|
|
|
aSelectedElements[ E_FORM ].push_back( pObject->Name );
|
|
|
|
break;
|
|
|
|
case DatabaseObject::REPORT:
|
|
|
|
case DatabaseObjectContainer::REPORTS_FOLDER:
|
|
|
|
aSelectedElements[ E_REPORT ].push_back( pObject->Name );
|
|
|
|
break;
|
|
|
|
case DatabaseObjectContainer::TABLES:
|
|
|
|
case DatabaseObjectContainer::QUERIES:
|
|
|
|
case DatabaseObjectContainer::FORMS:
|
|
|
|
case DatabaseObjectContainer::REPORTS:
|
|
|
|
if ( eSelectedCategory != E_NONE )
|
|
|
|
throw IllegalArgumentException(
|
|
|
|
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "You cannot select different categories." ) ),
|
|
|
|
// TODO: resource
|
|
|
|
*this, sal_Int16( pObject - aSelectedObjects.getConstArray() ) );
|
|
|
|
eSelectedCategory =
|
|
|
|
( pObject->Type == DatabaseObjectContainer::TABLES ) ? E_TABLE
|
|
|
|
: ( pObject->Type == DatabaseObjectContainer::QUERIES ) ? E_QUERY
|
|
|
|
: ( pObject->Type == DatabaseObjectContainer::FORMS ) ? E_FORM
|
|
|
|
: ( pObject->Type == DatabaseObjectContainer::REPORTS ) ? E_REPORT
|
|
|
|
: E_NONE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case DatabaseObjectContainer::DATA_SOURCE:
|
|
|
|
{
|
|
|
|
::rtl::OUStringBuffer aMessage;
|
|
|
|
aMessage.appendAscii( "Unsupported object type found (" );
|
|
|
|
aMessage.append ( sal_Int32( pObject->Type ) );
|
|
|
|
aMessage.appendAscii( ")." );
|
|
|
|
// TODO: resource
|
|
|
|
throw IllegalArgumentException(
|
|
|
|
aMessage.makeStringAndClear(), *this, sal_Int16( pObject - aSelectedObjects.getConstArray() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( SelectionByElementType::const_iterator sel = aSelectedElements.begin();
|
|
|
|
sel != aSelectedElements.end();
|
|
|
|
++sel
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if ( sel->first == m_eCurrentType )
|
|
|
|
{
|
|
|
|
Sequence< ::rtl::OUString > aSelected( sel->second.size() );
|
|
|
|
::std::copy( sel->second.begin(), sel->second.end(), aSelected.getArray() );
|
|
|
|
getContainer()->selectElements( aSelected );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_aPendingSelection[ sel->first ] = sel->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_aSelectContainerEvent.CancelCall(); // just in case the async select request was running
|
|
|
|
getContainer()->selectContainer( eSelectedCategory );
|
|
|
|
|
|
|
|
return sal_True;
|
2007-09-26 13:46:26 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Any SAL_CALL OApplicationController::getSelection( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
|
2008-06-25 11:35:22 +00:00
|
|
|
Sequence< NamedDatabaseObject > aCurrentSelection;
|
2008-10-01 12:28:29 +00:00
|
|
|
const ElementType eType( getContainer()->getElementType() );
|
|
|
|
if ( eType != E_NONE )
|
|
|
|
getContainer()->describeCurrentSelectionForType( eType, aCurrentSelection );
|
2008-06-25 11:35:22 +00:00
|
|
|
return makeAny( aCurrentSelection );
|
2007-09-26 13:46:26 +00:00
|
|
|
}
|
2008-03-06 17:09:10 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::impl_migrateScripts_nothrow()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
::rtl::OUString sDialogService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.application.MacroMigrationWizard" ) );
|
|
|
|
::comphelper::ComponentContext aContext( getORB() );
|
|
|
|
Sequence< Any > aDialogArgs(1);
|
|
|
|
aDialogArgs[0] <<= Reference< XOfficeDatabaseDocument >( m_xModel, UNO_QUERY_THROW );
|
|
|
|
Reference< XExecutableDialog > xDialog(
|
|
|
|
aContext.createComponentWithArguments( sDialogService, aDialogArgs ),
|
|
|
|
UNO_QUERY );
|
|
|
|
|
|
|
|
if ( !xDialog.is() )
|
|
|
|
{
|
|
|
|
ShowServiceNotAvailableError( getView(), sDialogService, true );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
xDialog->execute();
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-04 13:53:36 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-05-05 14:51:14 +00:00
|
|
|
bool OApplicationController::impl_activateSubFrame_throw(const ::rtl::OUString& _sName,const sal_Int32 _nKind,const ElementOpenMode _eOpenMode) const
|
2008-04-04 13:53:36 +00:00
|
|
|
{
|
|
|
|
bool bFound = false;
|
|
|
|
TFrames::const_iterator aFind = m_aSpecialSubFrames.find(_sName);
|
|
|
|
for(;aFind != m_aSpecialSubFrames.end();++aFind)
|
|
|
|
{
|
|
|
|
if ( aFind->second.first.first == _nKind && aFind->second.first.second == _eOpenMode )
|
|
|
|
{
|
|
|
|
const Reference< XFrame> xFrame(aFind->second.second,UNO_QUERY);
|
|
|
|
if ( xFrame.is() )
|
|
|
|
{
|
|
|
|
Reference< awt::XTopWindow> xTopWindow(xFrame->getContainerWindow(),UNO_QUERY);
|
|
|
|
if ( xTopWindow.is() )
|
|
|
|
xTopWindow->toFront();
|
|
|
|
bFound = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} // if ( aFind->second.first.first == _nKind && aFind->second.first.second == _eOpenMode )
|
2008-08-19 08:54:27 +00:00
|
|
|
}
|
2008-04-04 13:53:36 +00:00
|
|
|
return bFound;
|
|
|
|
}
|
2008-08-19 08:54:27 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OApplicationController::impl_deActivateSubFrame_throw(const ::rtl::OUString& _sName,const sal_Int32 _nKind)
|
|
|
|
{
|
|
|
|
TFrames aCopy = m_aSpecialSubFrames;
|
|
|
|
TFrames::iterator aFind = aCopy.find(_sName);
|
|
|
|
for(;aFind != aCopy.end();++aFind)
|
|
|
|
{
|
|
|
|
if ( aFind->second.first.first == _nKind )
|
|
|
|
{
|
|
|
|
Reference< XFrame> xFrame(aFind->second.second,UNO_QUERY);
|
|
|
|
if ( xFrame.is() )
|
|
|
|
{
|
|
|
|
::comphelper::disposeComponent(xFrame);
|
|
|
|
}
|
|
|
|
} // if ( aFind->second.first.first == _nKind && aFind->second.first.second == _eOpenMode )
|
|
|
|
}
|
|
|
|
}
|
2004-08-02 14:28:11 +00:00
|
|
|
//........................................................................
|
|
|
|
} // namespace dbaui
|
|
|
|
//........................................................................
|
|
|
|
|