/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <memory>
#include "AppController.hxx"
#include <core_resource.hxx>
#include <dbexchange.hxx>
#include <strings.hxx>
#include <advancedsettingsdlg.hxx>
#include "subcomponentmanager.hxx"
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/container/XContainer.hpp>
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/sdb/CommandType.hpp>
#include <com/sun/star/sdb/ErrorMessageDialog.hpp>
#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/sdbc/SQLWarning.hpp>
#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/util/XFlushable.hpp>
#include <com/sun/star/util/XModifiable.hpp>
#include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/document/XEmbeddedScripts.hpp>
#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/sdb/application/DatabaseObject.hpp>
#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
#include <comphelper/diagnose_ex.hxx>
#include <tools/urlobj.hxx>
#include <osl/diagnose.h>
#include <svl/filenotation.hxx>
#include <vcl/transfer.hxx>
#include <svtools/cliplistener.hxx>
#include <comphelper/interfacecontainer3.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/uno3.hxx>
#include <comphelper/types.hxx>
#include <comphelper/interaction.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
#include <unotools/closeveto.hxx>
#include <unotools/pathoptions.hxx>
#include <unotools/moduleoptions.hxx>
#include <unotools/historyoptions.hxx>
#include <sfx2/mailmodelapi.hxx>
#include <sfx2/filedlghelper.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/QuerySaveDocument.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <connectivity/dbtools.hxx>
#include <connectivity/dbexception.hxx>
#include <svx/dbaexchange.hxx>
#include <svx/dbaobjectex.hxx>
#include <svx/svxdlg.hxx>
#include <osl/mutex.hxx>
#include "AppView.hxx"
#include <browserids.hxx>
#include <strings.hrc>
#include <defaultobjectnamecheck.hxx>
#include <databaseobjectview.hxx>
#include <dbtreelistbox.hxx>
#include "AppDetailView.hxx"
#include <linkeddocuments.hxx>
#include <UITools.hxx>
#include <dsntypes.hxx>
#include <dlgsave.hxx>
#include <dbaccess_slotid.hrc>
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
org_openoffice_comp_dbu_OApplicationController_get_implementation(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const & )
{
return cppu::acquire(
new ::dbaui::OApplicationController(context));
}
namespace dbaui
{
using namespace ::dbtools;
using namespace ::svx;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::view;
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;
using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::task;
using ::com::sun::star::document::XEmbeddedScripts;
using ::com::sun::star::document::XDocumentEventBroadcaster;
using ::com::sun::star::sdb::application::NamedDatabaseObject;
namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObj
ectContainer;
OUString SAL_CALL OApplicationController::getImplementationName()
{
return SERVICE_SDB_APPLICATIONCONTROLLER;
}
Sequence< OUString> SAL_CALL OApplicationController::getSupportedServiceNames()
{
return { u"com.sun.star.sdb.application.DefaultViewController" _ustr };
}
namespace {
class SelectionGuard;
}
// OApplicationController
class SelectionNotifier
{
private :
::comphelper::OInterfaceContainerHelper3<XSelectionChangeListener> 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 )
{
}
SelectionNotifier(const SelectionNotifier&) = delete ;
const SelectionNotifier& operator =(const SelectionNotifier&) = delete ;
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 );
}
struct SelectionGuardAccess { friend 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 );
}
}
};
namespace {
class SelectionGuard
{
public :
explicit SelectionGuard( SelectionNotifier& _rNotifier )
:m_rNotifier( _rNotifier )
{
m_rNotifier.enterSelection( SelectionNotifier::SelectionGuardAccess() );
}
~SelectionGuard()
{
m_rNotifier.leaveSelection( SelectionNotifier::SelectionGuardAccess() );
}
SelectionGuard(const SelectionGuard&) = delete ;
const SelectionGuard& operator =(const SelectionGuard&) = delete ;
private :
SelectionNotifier& m_rNotifier;
};
}
// OApplicationController
OApplicationController::OApplicationController(const Reference< XComponentContext >& _rxORB)
:OGenericUnoController( _rxORB )
,m_aContextMenuInterceptors( getMutex() )
,m_pSubComponentManager( new SubComponentManager( *this , getSharedMutex() ) )
,m_aTypeCollection( _rxORB )
,m_aTableCopyHelper(this )
,m_nAsyncDrop(nullptr)
,m_aSelectContainerEvent( LINK( this , OApplicationController, OnSelectContainer ) )
,m_ePreviewMode(PreviewMode::NONE)
,m_eCurrentType(E_NONE)
,m_bNeedToReconnect(false )
,m_bSuspended( false )
,m_pSelectionNotifier( new SelectionNotifier( getMutex(), *this ) )
{
}
OApplicationController::~OApplicationController()
{
if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
{
OSL_FAIL("Please check who doesn't dispose this component!" );
// increment ref count to prevent double call of Dtor
osl_atomic_increment( &m_refCount );
dispose();
}
clearView();
}
IMPLEMENT_FORWARD_XTYPEPROVIDER2(OApplicationController,OGenericUnoController,OApplicationController_Base)
IMPLEMENT_FORWARD_XINTERFACE2(OApplicationController,OGenericUnoController,OApplicationController_Base)
void OApplicationController::disconnect()
{
if ( m_xDataSourceConnection.is() )
stopConnectionListening( m_xDataSourceConnection );
try
{
// temporary (hopefully!) hack for #i55274#
Reference< XFlushable > xFlush( m_xDataSourceConnection, UNO_QUERY );
if ( xFlush.is() && m_xMetaData.is() && !m_xMetaData->isReadOnly() )
xFlush->flush();
}
catch ( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("dbaccess" );
}
m_xDataSourceConnection.clear();
m_xMetaData.clear();
InvalidateAll();
}
void SAL_CALL OApplicationController::disposing()
{
for ( const auto & rContainerListener : m_aCurrentContainers )
{
if ( rContainerListener.is() )
{
rContainerListener->removeContainerListener( this );
}
}
m_aCurrentContainers.clear();
m_pSubComponentManager->disposing();
m_pSelectionNotifier->disposing();
if ( getView() )
{
getContainer()->showPreview(nullptr);
m_pClipboardNotifier->ClearCallbackLink();
m_pClipboardNotifier->RemoveListener( getView() );
m_pClipboardNotifier.clear();
}
disconnect();
try
{
Reference < XFrame > xFrame;
attachFrame( xFrame );
if ( m_xDataSource.is() )
{
// Should correspond to ODatabaseSource::createArrayHelper in dbaccess/source/core/dataaccess/datasource.cxx
m_xDataSource->removePropertyChangeListener(OUString(), this );
m_xDataSource->removePropertyChangeListener(PROPERTY_INFO, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_ISREADONLY, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_LAYOUTINFORMATION, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_NAME, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_NUMBERFORMATSSUPPLIER, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_PASSWORD, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_SETTINGS, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_TABLEFILTER, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_TABLETYPEFILTER, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_URL, this );
m_xDataSource->removePropertyChangeListener(PROPERTY_USER, this );
m_xDataSource = nullptr;
}
Reference< XModifyBroadcaster > xBroadcaster( m_xModel, UNO_QUERY );
if ( xBroadcaster.is() )
xBroadcaster->removeModifyListener(static_cast <XModifyListener*>(this ));
if ( m_xModel.is() )
{
OUString sUrl = m_xModel->getURL();
if ( !sUrl.isEmpty() )
{
if ( ::comphelper::NamedValueCollection::getOrDefault( m_xModel->getArgs(), u"PickListEntry" , true ) )
{
OUString aFilter;
INetURLObject aURL( m_xModel->getURL() );
std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter();
if ( pFilter )
aFilter = pFilter->GetFilterName();
OUString sDatabaseName;
// add to svtool history options
SvtHistoryOptions::AppendItem( EHistoryType::PickList,
aURL.GetURLNoPass( INetURLObject::DecodeMechanism::NONE ),
aFilter,
::dbaui::getStrippedDatabaseName(m_xDataSource, sDatabaseName),
std::nullopt, std::nullopt);
// add to recent document list
if ( aURL.GetProtocol() == INetProtocol::File )
Application::AddToRecentDocumentList( aURL.GetURLNoPass( INetURLObject::DecodeMechanism::NONE ),
pFilter ? pFilter->GetMimeType() : OUString(),
pFilter ? pFilter->GetServiceName() : OUString() );
}
}
m_xModel->disconnectController( this );
m_xModel.clear();
}
}
catch (const Exception&)
{
DBG_UNHANDLED_EXCEPTION("dbaccess" );
}
clearView();
OGenericUnoController::disposing(); // here the m_refCount must be equal 5
}
bool OApplicationController::Construct(vcl::Window* _pParent)
{
setView( VclPtr<OApplicationView>::Create( _pParent, getORB(), *this , m_ePreviewMode ) );
// late construction
bool bSuccess = false ;
try
{
getContainer()->Construct();
bSuccess = true ;
}
catch (const SQLException&)
{
}
catch (const Exception&)
{
OSL_FAIL("OApplicationController::Construct : the construction of UnoDataBrowserView failed !" );
}
if ( !bSuccess )
{
clearView();
return false ;
}
// now that we have a view we can create the clipboard listener
m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
m_aSystemClipboard.StartClipboardListening( );
m_pClipboardNotifier = new TransferableClipboardListener( LINK( this , OApplicationController, OnClipboardChanged ) );
m_pClipboardNotifier->AddListener( getView() );
OGenericUnoController::Construct( _pParent );
getView()->Show();
return true ;
}
void SAL_CALL OApplicationController::disposing(const EventObject& _rSource)
{
::osl::MutexGuard aGuard( getMutex() );
Reference<XConnection> xCon(_rSource.Source, UNO_QUERY);
if ( xCon.is() )
{
OSL_ENSURE( m_xDataSourceConnection == xCon,
"OApplicationController::disposing: which connection does this come from?" );
if ( getContainer() && getContainer()->getElementType() == E_TABLE )
getContainer()->clearPages();
if ( m_xDataSourceConnection == xCon )
{
m_xMetaData.clear();
m_xDataSourceConnection.clear();
}
}
else if ( _rSource.Source == m_xModel )
{
m_xModel.clear();
}
else if ( _rSource.Source == m_xDataSource )
{
m_xDataSource = nullptr;
}
else
{
Reference<XContainer> xContainer( _rSource.Source, UNO_QUERY );
if ( xContainer.is() )
{
TContainerVector::iterator aFind = std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer);
if ( aFind != m_aCurrentContainers.end() )
m_aCurrentContainers.erase(aFind);
}
OGenericUnoController::disposing( _rSource );
}
}
sal_Bool SAL_CALL OApplicationController::suspend(sal_Bool bSuspend)
{
// notify the OnPrepareViewClosing event (before locking any mutex)
Reference< XDocumentEventBroadcaster > xBroadcaster( m_xModel, UNO_QUERY );
if ( xBroadcaster.is() )
{
xBroadcaster->notifyDocumentEvent(
u"OnPrepareViewClosing" _ustr,
this ,
Any()
);
}
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( getMutex() );
if ( getView() && getView()->IsInModalMode() )
return false ;
bool bCanSuspend = true ;
if ( m_bSuspended != bool (bSuspend) )
{
if ( bSuspend && !closeSubComponents() )
return false ;
Reference<XModifiable> xModi(m_xModel,UNO_QUERY);
Reference<XStorable> xStor(getModel(),UNO_QUERY);
if ( bSuspend
&& xStor.is()
&& !xStor->isReadonly()
&& ( xModi.is()
&& xModi->isModified()
)
)
{
OUString sDatabaseName;
switch (ExecuteQuerySaveDocument(getFrameWeld(), ::dbaui::getStrippedDatabaseName(m_xDataSource, sDatabaseName)))
{
case RET_YES:
Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>());
bCanSuspend = !xModi->isModified();
// when we save the document this must be false else some press cancel
break ;
case RET_CANCEL:
bCanSuspend = false ;
break ;
default :
break ;
}
}
}
if ( bCanSuspend )
m_bSuspended = bSuspend;
return bCanSuspend;
}
FeatureState OApplicationController::GetState(sal_uInt16 _nId) const
{
FeatureState aReturn;
aReturn.bEnabled = false ;
// check this first
if ( !getContainer() || m_bReadOnly )
return aReturn;
try
{
switch (_nId)
{
case SID_NEWDOCDIRECT:
aReturn.bEnabled = true ;
aReturn.sTitle = "private:factory/sdatabase" ;
break ;
case SID_OPENURL:
aReturn.bEnabled = true ;
if ( m_xModel.is() )
aReturn.sTitle = m_xModel->getURL();
break ;
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 && (getContainer()->getElementType() != E_TABLE || getContainer()->isCutAllowed());
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(SotClipboardFormatId::DBACCESS_QUERY);
break ;
default :
aReturn.bEnabled = !isDataSourceReadOnly() && OComponentTransferable::canExtractComponentDescriptor(getViewClipboard().GetDataFlavorExVector(),getContainer()->getElementType() == E_FORM);
}
break ;
case SID_DB_APP_PASTE_SPECIAL:
aReturn.bEnabled = getContainer()->getElementType() == E_TABLE && !isDataSourceReadOnly() && !isConnectionReadOnly() && isTableFormat();
break ;
case SID_OPENDOC:
aReturn.bEnabled = true ;
break ;
case ID_BROWSER_SAVEDOC:
aReturn.bEnabled = !isDataSourceReadOnly();
break ;
case ID_BROWSER_SAVEASDOC:
aReturn.bEnabled = true ;
break ;
case ID_BROWSER_SORTUP:
aReturn.bEnabled = getContainer()->isFilled() && getContainer()->getElementCount();
aReturn.bChecked = aReturn.bEnabled && getContainer()->isSortUp();
break ;
case ID_BROWSER_SORTDOWN:
aReturn.bEnabled = getContainer()->isFilled() && getContainer()->getElementCount();
aReturn.bChecked = aReturn.bEnabled && !getContainer()->isSortUp();
break ;
case SID_NEWDOC:
case SID_APP_NEW_FORM:
case ID_DOCUMENT_CREATE_REPWIZ:
aReturn.bEnabled = !isDataSourceReadOnly() && SvtModuleOptions().IsWriterInstalled();
break ;
case SID_APP_NEW_REPORT:
aReturn.bEnabled = !isDataSourceReadOnly() && SvtModuleOptions().IsWriterInstalled();
if ( aReturn.bEnabled )
{
Reference< XContentEnumerationAccess > xEnumAccess(m_xContext->getServiceManager(), UNO_QUERY);
aReturn.bEnabled = xEnumAccess.is();
if ( aReturn.bEnabled )
{
const OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(m_xContext);
aReturn.bEnabled = !sReportEngineServiceName.isEmpty();
if ( aReturn.bEnabled )
{
const Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(sReportEngineServiceName);
aReturn.bEnabled = xEnumDrivers.is() && xEnumDrivers->hasMoreElements();
}
}
}
break ;
case SID_DB_APP_VIEW_TABLES:
aReturn.bEnabled = true ;
aReturn.bChecked = getContainer()->getElementType() == E_TABLE;
break ;
case SID_DB_APP_VIEW_QUERIES:
aReturn.bEnabled = true ;
aReturn.bChecked = getContainer()->getElementType() == E_QUERY;
break ;
case SID_DB_APP_VIEW_FORMS:
aReturn.bEnabled = true ;
aReturn.bChecked = getContainer()->getElementType() == E_FORM;
break ;
case SID_DB_APP_VIEW_REPORTS:
aReturn.bEnabled = true ;
aReturn.bChecked = getContainer()->getElementType() == E_REPORT;
break ;
case ID_NEW_QUERY_DESIGN:
case ID_NEW_QUERY_SQL:
case ID_APP_NEW_QUERY_AUTO_PILOT:
case SID_DB_FORM_NEW_PILOT:
aReturn.bEnabled = !isDataSourceReadOnly();
break ;
case ID_NEW_VIEW_DESIGN:
case SID_DB_NEW_VIEW_SQL:
case ID_NEW_VIEW_DESIGN_AUTO_PILOT:
aReturn.bEnabled = !isDataSourceReadOnly() && !isConnectionReadOnly();
if ( aReturn.bEnabled )
{
Reference<XViewsSupplier> xViewsSup( getConnection(), UNO_QUERY );
aReturn.bEnabled = xViewsSup.is();
}
break ;
case ID_NEW_TABLE_DESIGN:
case ID_NEW_TABLE_DESIGN_AUTO_PILOT:
aReturn.bEnabled = !isDataSourceReadOnly() && !isConnectionReadOnly();
break ;
case ID_DIRECT_SQL:
aReturn.bEnabled = true ;
break ;
case SID_APP_NEW_FOLDER:
aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() <= 1;
if ( aReturn.bEnabled )
{
const ElementType eType = getContainer()->getElementType();
aReturn.bEnabled = eType == E_REPORT || eType == E_FORM;
}
break ;
case SID_FORM_CREATE_REPWIZ_PRE_SEL:
case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
case SID_APP_NEW_REPORT_PRE_SEL:
aReturn.bEnabled = !isDataSourceReadOnly()
&& SvtModuleOptions().IsWriterInstalled()
&& getContainer()->isALeafSelected();
if ( aReturn.bEnabled )
{
ElementType eType = getContainer()->getElementType();
aReturn.bEnabled = eType == E_QUERY || eType == E_TABLE;
if ( aReturn.bEnabled && SID_APP_NEW_REPORT_PRE_SEL == _nId )
{
Reference< XContentEnumerationAccess > xEnumAccess(m_xContext->getServiceManager(), UNO_QUERY);
aReturn.bEnabled = xEnumAccess.is();
if ( aReturn.bEnabled )
{
static constexpr OUStringLiteral s_sReportDesign = u"org.libreoffice.report.pentaho.SOReportJobFactory" ;
Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(s_sReportDesign);
aReturn.bEnabled = xEnumDrivers.is() && xEnumDrivers->hasMoreElements();
}
}
}
break ;
case SID_DB_APP_DELETE:
case SID_DB_APP_RENAME:
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);
break ;
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:
aReturn.bEnabled = getContainer()->getElementCount() > 0 && getContainer()->getSelectionCount() != getContainer()->getElementCount();
break ;
case SID_DB_APP_EDIT:
case SID_DB_APP_TABLE_EDIT:
case SID_DB_APP_QUERY_EDIT:
case SID_DB_APP_FORM_EDIT:
case SID_DB_APP_REPORT_EDIT:
aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() > 0
&& getContainer()->isALeafSelected();
break ;
case SID_DB_APP_EDIT_SQL_VIEW:
if ( isDataSourceReadOnly() )
aReturn.bEnabled = false ;
else
{
switch ( getContainer()->getElementType() )
{
case E_QUERY:
aReturn.bEnabled = ( getContainer()->getSelectionCount() > 0 )
&& ( getContainer()->isALeafSelected() );
break ;
case E_TABLE:
aReturn.bEnabled = 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< OUString > aSelected;
getSelectionElementNames( aSelected );
bool bAlterableViews = true ;
for (auto const & selectedName : aSelected)
{
bAlterableViews &= impl_isAlterableView_nothrow(selectedName);
if (!bAlterableViews)
break ;
}
aReturn.bEnabled = bAlterableViews;
}
break ;
default :
break ;
}
}
break ;
case SID_DB_APP_OPEN:
case SID_DB_APP_TABLE_OPEN:
case SID_DB_APP_QUERY_OPEN:
case SID_DB_APP_FORM_OPEN:
case SID_DB_APP_REPORT_OPEN:
aReturn.bEnabled = getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
break ;
case SID_DB_APP_DSUSERADMIN:
aReturn.bEnabled = !dbaccess::ODsnTypeCollection::isEmbeddedDatabase(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
break ;
case SID_DB_APP_DSRELDESIGN:
aReturn.bEnabled = true ;
break ;
case SID_DB_APP_TABLEFILTER:
aReturn.bEnabled = !isDataSourceReadOnly();
break ;
case SID_DB_APP_REFRESH_TABLES:
aReturn.bEnabled = getContainer()->getElementType() == E_TABLE && isConnected();
break ;
case SID_DB_APP_DSPROPS:
aReturn.bEnabled = m_xDataSource.is() && dbaccess::ODsnTypeCollection::isShowPropertiesEnabled(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
break ;
case SID_DB_APP_DSCONNECTION_TYPE:
aReturn.bEnabled = !isDataSourceReadOnly() && m_xDataSource.is() && !dbaccess::ODsnTypeCollection::isEmbeddedDatabase(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
break ;
case SID_DB_APP_DSADVANCED_SETTINGS:
aReturn.bEnabled = m_xDataSource.is() && AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( m_aTypeCollection.getType(::comphelper::getString( m_xDataSource->getPropertyValue( PROPERTY_URL ) )) );
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 )
{
Reference<XViewsSupplier> xViewSup( getConnection(), UNO_QUERY );
aReturn.bEnabled = xViewSup.is() && Reference<XAppend>(xViewSup->getViews(),UNO_QUERY).is();
}
}
break ;
case SID_DB_APP_DISABLE_PREVIEW:
aReturn.bEnabled = true ;
aReturn.bChecked = getContainer()->getPreviewMode() == PreviewMode::NONE;
break ;
case SID_DB_APP_VIEW_DOCINFO_PREVIEW:
{
ElementType eType = getContainer()->getElementType();
aReturn.bEnabled = (E_REPORT == eType || E_FORM == eType);
aReturn.bChecked = getContainer()->getPreviewMode() == PreviewMode::DocumentInfo;
}
break ;
case SID_DB_APP_VIEW_DOC_PREVIEW:
aReturn.bEnabled = true ;
aReturn.bChecked = getContainer()->getPreviewMode() == PreviewMode::Document;
break ;
case ID_BROWSER_UNDO:
case SID_DB_APP_SENDREPORTTOWRITER:
case SID_DB_APP_DBADMIN:
aReturn.bEnabled = false ;
break ;
case SID_MAIL_SENDDOC:
aReturn.bEnabled = true ;
break ;
case SID_DB_APP_SENDREPORTASMAIL:
{
ElementType eType = getContainer()->getElementType();
aReturn.bEnabled = E_REPORT == eType && getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
}
break ;
case SID_DB_APP_STATUS_TYPE:
aReturn.bEnabled = m_xDataSource.is();
if ( aReturn.bEnabled )
{
OUString sURL;
m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sURL;
OUString sDSTypeName;
if ( dbaccess::ODsnTypeCollection::isEmbeddedDatabase( sURL ) )
{
sDSTypeName = DBA_RES(RID_STR_EMBEDDED_DATABASE);
}
else
{
sDSTypeName = m_aTypeCollection.getTypeDisplayName(sURL);
}
aReturn.sTitle = sDSTypeName;
}
break ;
case SID_DB_APP_STATUS_DBNAME:
aReturn.bEnabled = m_xDataSource.is();
if ( aReturn.bEnabled )
{
OUString sURL;
m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sURL;
OUString sDatabaseName;
OUString sHostName;
sal_Int32 nPortNumber( -1 );
m_aTypeCollection.extractHostNamePort( sURL, sDatabaseName, sHostName, nPortNumber );
if ( sDatabaseName.isEmpty() )
sDatabaseName = m_aTypeCollection.cutPrefix( sURL );
if ( m_aTypeCollection.isFileSystemBased(sURL) )
{
sDatabaseName = SvtPathOptions().SubstituteVariable( sDatabaseName );
if ( !sDatabaseName.isEmpty() )
{
::svt::OFileNotation aFileNotation(sDatabaseName);
// set this decoded URL as text
sDatabaseName = aFileNotation.get(::svt::OFileNotation::N_SYSTEM);
}
}
if ( sDatabaseName.isEmpty() )
sDatabaseName = m_aTypeCollection.getTypeDisplayName( sURL );
aReturn.sTitle = sDatabaseName;
}
break ;
case SID_DB_APP_STATUS_USERNAME:
aReturn.bEnabled = m_xDataSource.is();
if ( aReturn.bEnabled )
m_xDataSource->getPropertyValue( PROPERTY_USER ) >>= aReturn.sTitle;
break ;
case SID_DB_APP_STATUS_HOSTNAME:
aReturn.bEnabled = m_xDataSource.is();
if ( aReturn.bEnabled )
{
OUString sURL;
m_xDataSource->getPropertyValue( PROPERTY_URL ) >>= sURL;
OUString sHostName, sDatabaseName;
sal_Int32 nPortNumber = -1;
m_aTypeCollection.extractHostNamePort( sURL, sDatabaseName, sHostName, nPortNumber );
aReturn.sTitle = sHostName;
}
break ;
default :
aReturn = OGenericUnoController::GetState(_nId);
}
}
catch (const Exception& )
{
DBG_UNHANDLED_EXCEPTION("dbaccess" );
}
return aReturn;
}
namespace
{
bool lcl_handleException_nothrow( const Reference< XModel >& _rxDocument, const Any& _rException )
{
bool bHandled = false ;
// try handling the error with an interaction handler
Reference< XInteractionHandler > xHandler = ::comphelper::NamedValueCollection::getOrDefault( _rxDocument->getArgs(), u"InteractionHandler" , Reference< XInteractionHandler >() );
if ( xHandler.is() )
{
rtl::Reference pRequest( new ::comphelper::OInteractionRequest( _rException ) );
rtl::Reference pApprove( new ::comphelper::OInteractionApprove );
pRequest->addContinuation( pApprove );
try
{
xHandler->handle( pRequest );
}
catch ( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("dbaccess" );
}
bHandled = pApprove->wasSelected();
}
return bHandled;
}
}
void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( getMutex() );
if ( isUserDefinedFeature( _nId ) )
{
OGenericUnoController::Execute( _nId, aArgs );
return ;
}
if ( !getContainer() || m_bReadOnly )
return ; // return without execution
try
{
switch (_nId)
{
case ID_BROWSER_CUT:
getContainer()->cut();
break ;
case ID_BROWSER_COPY:
{
rtl::Reference<TransferableHelper> pTransfer = copyObject();
if ( pTransfer )
pTransfer->CopyToClipboard(getView());
}
break ;
case ID_BROWSER_PASTE:
{
const TransferableDataHelper& rTransferData( getViewClipboard() );
ElementType eType = getContainer()->getElementType();
switch ( eType )
{
case E_TABLE:
{
// get the selected tablename
std::vector< OUString > aList;
getSelectionElementNames( aList );
if ( !aList.empty() )
m_aTableCopyHelper.SetTableNameForAppend( *aList.begin() );
else
m_aTableCopyHelper.ResetTableNameForAppend();
m_aTableCopyHelper.pasteTable( rTransferData , getDatabaseName(), ensureConnection() );
}
break ;
case E_QUERY:
if ( rTransferData.HasFormat(SotClipboardFormatId::DBACCESS_QUERY) )
paste( E_QUERY, ODataAccessObjectTransferable::extractObjectDescriptor( rTransferData ) );
break ;
default :
{
std::vector< OUString> aList;
getSelectionElementNames(aList);
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();
}
paste( eType, OComponentTransferable::extractComponentDescriptor( rTransferData ),
sFolderNameToInsertInto );
}
break ;
}
}
break ;
case SID_DB_APP_PASTE_SPECIAL:
{
if ( !aArgs.hasElements() )
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(getFrameWeld()));
std::vector<SotClipboardFormatId> aFormatIds;
getSupportedFormats(getContainer()->getElementType(),aFormatIds);
for (auto const & formatId : aFormatIds)
pDlg->Insert(formatId,u"" _ustr);
const TransferableDataHelper& rClipboard = getViewClipboard();
pasteFormat(pDlg->GetFormat(rClipboard.GetTransferable()));
}
else
{
for (auto & arg : aArgs)
{
if (arg.Name == "FormatStringId" )
{
sal_uInt32 nTmp;
if (arg.Value >>= nTmp)
pasteFormat(static_cast <SotClipboardFormatId>(nTmp));
break ;
}
}
}
}
break ;
case SID_NEWDOCDIRECT:
case SID_OPENDOC:
{
Reference < XDispatchProvider > xProv( getFrame(), UNO_QUERY );
if ( xProv.is() )
{
URL aURL;
OUString aTarget;
if ( _nId == SID_NEWDOCDIRECT )
{
aURL.Complete = "private:factory/sdatabase?Interactive" ;
aTarget = "_default" ;
}
else
aURL.Complete = ".uno:Open" ;
if ( m_xUrlTransformer.is() )
m_xUrlTransformer->parseStrict( aURL );
Reference < XDispatch > xDisp = xProv->queryDispatch( aURL, aTarget, 0 );
if ( xDisp.is() )
xDisp->dispatch( aURL, Sequence < PropertyValue >() );
}
}
break ;
case ID_BROWSER_SAVEDOC:
{
Reference< XStorable > xStore( m_xModel, UNO_QUERY_THROW );
try
{
xStore->store();
}
catch ( const Exception& )
{
lcl_handleException_nothrow( m_xModel, ::cppu::getCaughtException() );
}
}
break ;
case ID_BROWSER_SAVEASDOC:
{
OUString sUrl;
if ( m_xModel.is() )
sUrl = m_xModel->getURL();
::sfx2::FileDialogHelper aFileDlg(
ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
FileDialogFlags::NONE, getFrameWeld());
aFileDlg.SetContext(sfx2::FileDialogHelper::BaseSaveAs);
if (!sUrl.isEmpty())
aFileDlg.SetDisplayDirectory( sUrl );
std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter();
if ( pFilter )
{
aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
aFileDlg.SetCurrentFilter(pFilter->GetUIName());
}
if ( aFileDlg.Execute() != ERRCODE_NONE )
break ;
Reference<XStorable> xStore( m_xModel, UNO_QUERY_THROW );
INetURLObject aURL( aFileDlg.GetPath() );
try
{
xStore->storeAsURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), Sequence< PropertyValue >() );
}
catch ( const Exception& )
{
lcl_handleException_nothrow( m_xModel, ::cppu::getCaughtException() );
}
/*updateTitle();*/
m_bCurrentlyModified = false ;
InvalidateFeature(ID_BROWSER_SAVEDOC);
if ( getContainer()->getElementType() == E_NONE )
{
getContainer()->selectContainer(E_NONE);
getContainer()->selectContainer(E_TABLE);
// #i95524#
getContainer()->Invalidate();
refreshTables();
}
}
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:
case SID_DB_FORM_NEW_PILOT:
case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
case SID_APP_NEW_REPORT_PRE_SEL:
case SID_FORM_CREATE_REPWIZ_PRE_SEL:
case ID_DOCUMENT_CREATE_REPWIZ:
case SID_APP_NEW_FORM:
case SID_APP_NEW_REPORT:
case ID_NEW_QUERY_SQL:
case ID_NEW_QUERY_DESIGN:
case ID_NEW_TABLE_DESIGN:
{
ElementType eType = E_TABLE;
bool bAutoPilot = false ;
::comphelper::NamedValueCollection aCreationArgs;
switch ( _nId )
{
case SID_DB_FORM_NEW_PILOT:
case SID_FORM_CREATE_REPWIZ_PRE_SEL:
bAutoPilot = true ;
[[fallthrough]];
case SID_APP_NEW_FORM:
eType = E_FORM;
break ;
case ID_DOCUMENT_CREATE_REPWIZ:
case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
bAutoPilot = true ;
[[fallthrough]];
case SID_APP_NEW_REPORT:
case SID_APP_NEW_REPORT_PRE_SEL:
eType = E_REPORT;
break ;
case ID_APP_NEW_QUERY_AUTO_PILOT:
bAutoPilot = true ;
eType = E_QUERY;
break ;
case ID_NEW_QUERY_DESIGN:
aCreationArgs.put( PROPERTY_GRAPHICAL_DESIGN, true );
[[fallthrough]];
case ID_NEW_QUERY_SQL:
eType = E_QUERY;
break ;
case ID_NEW_TABLE_DESIGN_AUTO_PILOT:
bAutoPilot = true ;
[[fallthrough]];
case ID_NEW_TABLE_DESIGN:
break ;
default :
OSL_FAIL("illegal switch call!" );
}
if ( bAutoPilot )
getContainer()->PostUserEvent( LINK( this , OApplicationController, OnCreateWithPilot ), reinterpret_cast < void * >( eType ) );
else
{
Reference< XComponent > xDocDefinition;
newElement( eType, aCreationArgs, xDocDefinition );
}
}
break ;
case SID_APP_NEW_FOLDER:
{
ElementType eType = getContainer()->getElementType();
OUString sName = getContainer()->getQualifiedName( nullptr );
insertHierarchyElement(eType,sName);
}
break ;
case ID_NEW_VIEW_DESIGN:
case SID_DB_NEW_VIEW_SQL:
{
SharedConnection xConnection( ensureConnection() );
if ( xConnection.is() )
{
QueryDesigner aDesigner( getORB(), this , getFrame(), true );
::comphelper::NamedValueCollection aCreationArgs;
aCreationArgs.put( PROPERTY_GRAPHICAL_DESIGN, ID_NEW_VIEW_DESIGN == _nId );
const Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
const Reference< XComponent > xComponent = aDesigner.createNew( xDataSource, aCreationArgs );
onDocumentOpened( OUString(), E_QUERY, ElementOpenMode::Design, xComponent, nullptr );
}
}
break ;
case SID_DB_APP_DELETE:
case SID_DB_APP_TABLE_DELETE:
case SID_DB_APP_QUERY_DELETE:
case SID_DB_APP_FORM_DELETE:
case SID_DB_APP_REPORT_DELETE:
deleteEntries();
break ;
case SID_DB_APP_RENAME:
case SID_DB_APP_TABLE_RENAME:
case SID_DB_APP_QUERY_RENAME:
case SID_DB_APP_FORM_RENAME:
case SID_DB_APP_REPORT_RENAME:
renameEntry();
break ;
case SID_DB_APP_EDIT:
case SID_DB_APP_EDIT_SQL_VIEW:
case SID_DB_APP_TABLE_EDIT:
case SID_DB_APP_QUERY_EDIT:
case SID_DB_APP_FORM_EDIT:
case SID_DB_APP_REPORT_EDIT:
doAction( _nId, ElementOpenMode::Design );
break ;
case SID_DB_APP_OPEN:
case SID_DB_APP_TABLE_OPEN:
case SID_DB_APP_QUERY_OPEN:
case SID_DB_APP_FORM_OPEN:
case SID_DB_APP_REPORT_OPEN:
case SID_DB_APP_CONVERTTOVIEW:
doAction( _nId, ElementOpenMode::Normal );
break ;
case SID_SELECTALL:
getContainer()->selectAll();
InvalidateAll();
break ;
case SID_DB_APP_DSRELDESIGN:
{
Reference< XComponent > xRelationDesigner;
if ( !m_pSubComponentManager->activateSubFrame( OUString(), SID_DB_APP_DSRELDESIGN, ElementOpenMode::Design, xRelationDesigner ) )
{
SharedConnection xConnection( ensureConnection() );
if ( xConnection.is() )
{
RelationDesigner aDesigner( getORB(), this , m_aCurrentFrame.getFrame() );
const Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
const Reference< XComponent > xComponent = aDesigner.createNew( xDataSource );
onDocumentOpened( OUString(), SID_DB_APP_DSRELDESIGN, ElementOpenMode::Design, xComponent, nullptr );
}
}
}
break ;
case SID_DB_APP_DSUSERADMIN:
{
SharedConnection xConnection( ensureConnection() );
if ( xConnection.is() )
openDialog(u"com.sun.star.sdb.UserAdministrationDialog" _ustr);
}
break ;
case SID_DB_APP_TABLEFILTER:
// opens the table filter dialog for the selected data source
openDialog( u"com.sun.star.sdb.TableFilterDialog" _ustr );
askToReconnect();
break ;
case SID_DB_APP_REFRESH_TABLES:
refreshTables();
break ;
case SID_DB_APP_DSPROPS:
// opens the administration dialog for the selected data source
openDialog( u"com.sun.star.sdb.DatasourceAdministrationDialog" _ustr );
askToReconnect();
break ;
case SID_DB_APP_DSADVANCED_SETTINGS:
openDialog(u"com.sun.star.sdb.AdvancedDatabaseSettingsDialog" _ustr);
askToReconnect();
break ;
case SID_DB_APP_DSCONNECTION_TYPE:
openDialog(u"com.sun.star.sdb.DataSourceTypeChangeDialog" _ustr);
askToReconnect();
break ;
case ID_DIRECT_SQL:
{
SharedConnection xConnection( ensureConnection() );
if ( xConnection.is() )
// opens the DirectSQLDialog to execute hand made sql statements.
openDialog( SERVICE_SDB_DIRECTSQLDIALOG );
}
break ;
case SID_DB_APP_VIEW_TABLES:
m_aSelectContainerEvent.Call( reinterpret_cast < void * >( E_TABLE ) );
break ;
case SID_DB_APP_VIEW_QUERIES:
m_aSelectContainerEvent.Call( reinterpret_cast < void * >( E_QUERY ) );
break ;
case SID_DB_APP_VIEW_FORMS:
m_aSelectContainerEvent.Call( reinterpret_cast < void * >( E_FORM ) );
break ;
case SID_DB_APP_VIEW_REPORTS:
m_aSelectContainerEvent.Call( reinterpret_cast < void * >( E_REPORT ) );
break ;
case SID_DB_APP_DISABLE_PREVIEW:
m_ePreviewMode = PreviewMode::NONE;
getContainer()->switchPreview(m_ePreviewMode);
break ;
case SID_DB_APP_VIEW_DOCINFO_PREVIEW:
m_ePreviewMode = PreviewMode::DocumentInfo;
getContainer()->switchPreview(m_ePreviewMode);
break ;
case SID_DB_APP_VIEW_DOC_PREVIEW:
m_ePreviewMode = PreviewMode::Document;
getContainer()->switchPreview(m_ePreviewMode);
break ;
case SID_MAIL_SENDDOC:
{
SfxMailModel aSendMail;
if ( aSendMail.AttachDocument(getModel(), OUString()) == SfxMailModel::SEND_MAIL_OK )
aSendMail.Send( getFrame() );
}
break ;
case SID_DB_APP_SENDREPORTASMAIL:
doAction( _nId, ElementOpenMode::Mail );
break ;
}
}
catch ( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("dbaccess" );
}
InvalidateFeature(_nId);
}
void OApplicationController::describeSupportedFeatures()
{
OGenericUnoController::describeSupportedFeatures();
implDescribeSupportedFeature( u".uno:AddDirect" _ustr, SID_NEWDOCDIRECT, CommandGroup::APPLICATION );
implDescribeSupportedFeature( u".uno:Save" _ustr, ID_BROWSER_SAVEDOC, CommandGroup::DOCUMENT );
implDescribeSupportedFeature( u".uno:SaveAs" _ustr, ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT );
implDescribeSupportedFeature( u".uno:SendMail" _ustr, SID_MAIL_SENDDOC, CommandGroup::DOCUMENT );
implDescribeSupportedFeature( u".uno:DBSendReportAsMail" _ustr,SID_DB_APP_SENDREPORTASMAIL,
CommandGroup::DOCUMENT );
implDescribeSupportedFeature( u".uno:DBSendReportToWriter" _ustr,SID_DB_APP_SENDREPORTTOWRITER,
CommandGroup::DOCUMENT );
implDescribeSupportedFeature( u".uno:DBNewForm" _ustr, SID_APP_NEW_FORM, CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBNewFolder" _ustr, SID_APP_NEW_FOLDER, CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBNewFormAutoPilot" _ustr, SID_DB_FORM_NEW_PILOT, CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBNewFormAutoPilotWithPreSelection" _ustr,
SID_FORM_CREATE_REPWIZ_PRE_SEL,
CommandGroup::APPLICATION );
implDescribeSupportedFeature( u".uno:DBNewReport" _ustr, SID_APP_NEW_REPORT, CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBNewReportAutoPilot" _ustr,
ID_DOCUMENT_CREATE_REPWIZ, CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBNewReportAutoPilotWithPreSelection" _ustr,
SID_REPORT_CREATE_REPWIZ_PRE_SEL,
CommandGroup::APPLICATION );
implDescribeSupportedFeature( u".uno:DBNewQuery" _ustr, ID_NEW_QUERY_DESIGN, CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBNewQuerySql" _ustr, ID_NEW_QUERY_SQL, CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBNewQueryAutoPilot" _ustr,ID_APP_NEW_QUERY_AUTO_PILOT,
CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBNewTable" _ustr, ID_NEW_TABLE_DESIGN, CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBNewTableAutoPilot" _ustr,ID_NEW_TABLE_DESIGN_AUTO_PILOT,
CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBNewView" _ustr, ID_NEW_VIEW_DESIGN, CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBNewViewSQL" _ustr, SID_DB_NEW_VIEW_SQL, CommandGroup::INSERT );
implDescribeSupportedFeature( u".uno:DBDelete" _ustr, SID_DB_APP_DELETE, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:Delete" _ustr, SID_DB_APP_DELETE, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBRename" _ustr, SID_DB_APP_RENAME, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBEdit" _ustr, SID_DB_APP_EDIT, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBEditSqlView" _ustr, SID_DB_APP_EDIT_SQL_VIEW, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBOpen" _ustr, SID_DB_APP_OPEN, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBTableDelete" _ustr, SID_DB_APP_TABLE_DELETE, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBTableRename" _ustr, SID_DB_APP_TABLE_RENAME, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBTableEdit" _ustr, SID_DB_APP_TABLE_EDIT, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBTableOpen" _ustr, SID_DB_APP_TABLE_OPEN, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBQueryDelete" _ustr, SID_DB_APP_QUERY_DELETE, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBQueryRename" _ustr, SID_DB_APP_QUERY_RENAME, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBQueryEdit" _ustr, SID_DB_APP_QUERY_EDIT, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBQueryOpen" _ustr, SID_DB_APP_QUERY_OPEN, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBFormDelete" _ustr, SID_DB_APP_FORM_DELETE, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBFormRename" _ustr, SID_DB_APP_FORM_RENAME, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBFormEdit" _ustr, SID_DB_APP_FORM_EDIT, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBFormOpen" _ustr, SID_DB_APP_FORM_OPEN, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBReportDelete" _ustr, SID_DB_APP_REPORT_DELETE, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBReportRename" _ustr, SID_DB_APP_REPORT_RENAME, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBReportEdit" _ustr, SID_DB_APP_REPORT_EDIT, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBReportOpen" _ustr, SID_DB_APP_REPORT_OPEN, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:SelectAll" _ustr, SID_SELECTALL, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:Undo" _ustr, ID_BROWSER_UNDO, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:Sortup" _ustr, ID_BROWSER_SORTUP, CommandGroup::VIEW );
implDescribeSupportedFeature( u".uno:SortDown" _ustr, ID_BROWSER_SORTDOWN, CommandGroup::VIEW );
implDescribeSupportedFeature( u".uno:DBRelationDesign" _ustr, SID_DB_APP_DSRELDESIGN, CommandGroup::APPLICATION );
implDescribeSupportedFeature( u".uno:DBUserAdmin" _ustr, SID_DB_APP_DSUSERADMIN, CommandGroup::APPLICATION );
implDescribeSupportedFeature( u".uno:DBTableFilter" _ustr, SID_DB_APP_TABLEFILTER, CommandGroup::APPLICATION );
implDescribeSupportedFeature( u".uno:DBDSProperties" _ustr, SID_DB_APP_DSPROPS, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBDSConnectionType" _ustr, SID_DB_APP_DSCONNECTION_TYPE,
CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBDSAdvancedSettings" _ustr,
SID_DB_APP_DSADVANCED_SETTINGS,
CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:PasteSpecial" _ustr, SID_DB_APP_PASTE_SPECIAL, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBConvertToView" _ustr, SID_DB_APP_CONVERTTOVIEW, CommandGroup::EDIT );
implDescribeSupportedFeature( u".uno:DBRefreshTables" _ustr, SID_DB_APP_REFRESH_TABLES, CommandGroup::APPLICATION );
implDescribeSupportedFeature( u".uno:DBDirectSQL" _ustr, ID_DIRECT_SQL, CommandGroup::APPLICATION );
implDescribeSupportedFeature( u".uno:DBViewTables" _ustr, SID_DB_APP_VIEW_TABLES, CommandGroup::VIEW );
implDescribeSupportedFeature( u".uno:DBViewQueries" _ustr, SID_DB_APP_VIEW_QUERIES, CommandGroup::VIEW );
implDescribeSupportedFeature( u".uno:DBViewForms" _ustr, SID_DB_APP_VIEW_FORMS, CommandGroup::VIEW );
implDescribeSupportedFeature( u".uno:DBViewReports" _ustr, SID_DB_APP_VIEW_REPORTS, CommandGroup::VIEW );
implDescribeSupportedFeature( u".uno:DBDisablePreview" _ustr, SID_DB_APP_DISABLE_PREVIEW,CommandGroup::VIEW );
implDescribeSupportedFeature( u".uno:DBShowDocInfoPreview" _ustr,
SID_DB_APP_VIEW_DOCINFO_PREVIEW,
CommandGroup::VIEW );
implDescribeSupportedFeature( u".uno:DBShowDocPreview" _ustr, SID_DB_APP_VIEW_DOC_PREVIEW,
CommandGroup::VIEW );
implDescribeSupportedFeature( u".uno:OpenUrl" _ustr, SID_OPENURL, CommandGroup::APPLICATION );
// this one should not appear under Tools->Customize->Keyboard
implDescribeSupportedFeature( u".uno:DBNewReportWithPreSelection" _ustr,
SID_APP_NEW_REPORT_PRE_SEL );
implDescribeSupportedFeature( u".uno:DBDSImport" _ustr, SID_DB_APP_DSIMPORT);
implDescribeSupportedFeature( u".uno:DBDSExport" _ustr, SID_DB_APP_DSEXPORT);
implDescribeSupportedFeature( u".uno:DBDBAdmin" _ustr, SID_DB_APP_DBADMIN);
// status info
implDescribeSupportedFeature( u".uno:DBStatusType" _ustr, SID_DB_APP_STATUS_TYPE);
implDescribeSupportedFeature( u".uno:DBStatusDBName" _ustr, SID_DB_APP_STATUS_DBNAME);
implDescribeSupportedFeature( u".uno:DBStatusUserName" _ustr, SID_DB_APP_STATUS_USERNAME);
implDescribeSupportedFeature( u".uno:DBStatusHostName" _ustr, SID_DB_APP_STATUS_HOSTNAME);
}
OApplicationView* OApplicationController::getContainer() const
{
return static_cast < OApplicationView* >( getView() );
}
// css::container::XContainerListener
void SAL_CALL OApplicationController::elementInserted( const ContainerEvent& _rEvent )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( getMutex() );
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5 C=95 H=98 G=96
¤ Dauer der Verarbeitung: 0.26 Sekunden
(vorverarbeitet)
¤
*© Formatika GbR, Deutschland