1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AppController.cxx,v $
10 * $Revision: 1.63.20.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #include "AppController.hxx"
35 #include "dbustrings.hrc"
36 #include "advancedsettingsdlg.hxx"
37 #include "subcomponentmanager.hxx"
39 /** === begin UNO includes === **/
40 #include <com/sun/star/beans/NamedValue.hpp>
41 #include <com/sun/star/container/XChild.hpp>
42 #include <com/sun/star/container/XContainer.hpp>
43 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
44 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
45 #include <com/sun/star/container/XHierarchicalNameContainer.hpp>
46 #include <com/sun/star/container/XNameContainer.hpp>
47 #include <com/sun/star/frame/FrameSearchFlag.hpp>
48 #include <com/sun/star/frame/XStorable.hpp>
49 #include <com/sun/star/sdb/CommandType.hpp>
50 #include <com/sun/star/sdb/SQLContext.hpp>
51 #include <com/sun/star/sdb/XBookmarksSupplier.hpp>
52 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
53 #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
54 #include <com/sun/star/sdbc/XDataSource.hpp>
55 #include <com/sun/star/sdbcx/XAlterView.hpp>
56 #include <com/sun/star/sdbcx/XAppend.hpp>
57 #include <com/sun/star/sdbcx/XRename.hpp>
58 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
59 #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
60 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
61 #include <com/sun/star/uno/XNamingService.hpp>
62 #include <com/sun/star/util/XFlushable.hpp>
63 #include <com/sun/star/util/XModifiable.hpp>
64 #include <com/sun/star/util/XModifyBroadcaster.hpp>
65 #include <com/sun/star/util/XNumberFormatter.hpp>
66 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
67 #include <com/sun/star/document/XEmbeddedScripts.hpp>
68 #include <com/sun/star/frame/XModel2.hpp>
69 #include <com/sun/star/container/XHierarchicalNameContainer.hpp>
70 #include <com/sun/star/util/XModifyBroadcaster.hpp>
71 #include <com/sun/star/util/XModifiable.hpp>
72 #include <com/sun/star/frame/FrameSearchFlag.hpp>
73 #include <com/sun/star/util/XFlushable.hpp>
74 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
75 #include "com/sun/star/beans/NamedValue.hpp"
76 #include <com/sun/star/awt/XTopWindow.hpp>
77 #include <com/sun/star/task/XInteractionHandler.hpp>
78 #include <com/sun/star/sdb/application/DatabaseObject.hpp>
79 #include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
80 #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
81 /** === end UNO includes === **/
83 #ifndef _TOOLS_DEBUG_HXX
84 #include <tools/debug.hxx>
86 #ifndef TOOLS_DIAGNOSE_EX_H
87 #include <tools/diagnose_ex.h>
89 #ifndef SVTOOLS_URIHELPER_HXX
90 #include <svtools/urihelper.hxx>
92 #ifndef _COMPHELPER_TYPES_HXX_
93 #include <comphelper/types.hxx>
95 #ifndef _COMPHELPER_INTERACTION_HXX_
96 #include <comphelper/interaction.hxx>
98 #ifndef COMPHELPER_COMPONENTCONTEXT_HXX
99 #include <comphelper/componentcontext.hxx>
101 #ifndef _SV_MSGBOX_HXX
102 #include <vcl/msgbox.hxx>
104 #ifndef _VCL_STDTEXT_HXX
105 #include <vcl/stdtext.hxx>
107 #ifndef _FILEDLGHELPER_HXX
108 #include <sfx2/filedlghelper.hxx>
110 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
111 #include <cppuhelper/typeprovider.hxx>
113 #ifndef _CPPUHELPER_EXC_HLP_HXX_
114 #include <cppuhelper/exc_hlp.hxx>
116 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
117 #include <connectivity/dbtools.hxx>
119 #ifndef DBAUI_APPVIEW_HXX
120 #include "AppView.hxx"
122 #ifndef DBACCESS_UI_BROWSER_ID_HXX
123 #include "browserids.hxx"
125 #ifndef _DBAU_REGHELPER_HXX_
126 #include "dbu_reghelper.hxx"
128 #ifndef _DBU_APP_HRC_
129 #include "dbu_app.hrc"
131 #ifndef DBACCESS_SOURCE_UI_MISC_DEFAULTOBJECTNAMECHECK_HXX
132 #include "defaultobjectnamecheck.hxx"
135 #include <vcl/menu.hxx>
137 #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
138 #include <svtools/pathoptions.hxx>
140 #ifndef INCLUDED_SVTOOLS_INTERNALOPTIONS_HXX
141 #include <svtools/internaloptions.hxx>
143 #ifndef _COMPHELPER_UNO3_HXX_
144 #include <comphelper/uno3.hxx>
146 #ifndef DBACCESS_DATABASE_OBJECT_VIEW_HXX
147 #include "databaseobjectview.hxx"
149 #ifndef _SV_SVAPP_HXX //autogen
150 #include <vcl/svapp.hxx>
152 #ifndef _SVLBOXITM_HXX
153 #include <svtools/svlbitm.hxx>
155 #ifndef _DBAUI_LISTVIEWITEMS_HXX_
156 #include "listviewitems.hxx"
159 #ifndef DBAUI_APPDETAILVIEW_HXX
160 #include "AppDetailView.hxx"
162 #ifndef _DBAUI_LINKEDDOCUMENTS_HXX_
163 #include "linkeddocuments.hxx"
165 #ifndef _SV_LSTBOX_HXX
166 #include <vcl/lstbox.hxx>
168 #ifndef _DBHELPER_DBEXCEPTION_HXX_
169 #include <connectivity/dbexception.hxx>
171 #ifndef _DBAUI_SQLMESSAGE_HXX_
172 #include "sqlmessage.hxx"
175 #include <tools/string.hxx>
177 #ifndef INCLUDED_SFX_MAILMODELAPI_HXX
178 #include <sfx2/mailmodelapi.hxx>
180 #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
181 #include <svtools/moduleoptions.hxx>
183 #ifndef _SVTREEBOX_HXX
184 #include <svtools/svtreebx.hxx>
186 #ifndef _TRANSFER_HXX
187 #include <svtools/transfer.hxx>
189 #ifndef _CLIPLISTENER_HXX
190 #include <svtools/cliplistener.hxx>
192 #ifndef _SVX_DBAEXCHANGE_HXX_
193 #include <svx/dbaexchange.hxx>
195 #ifndef SVX_DBAOBJECTEX_HXX
196 #include <svx/dbaobjectex.hxx>
198 #ifndef DBAUI_TOOLS_HXX
199 #include "UITools.hxx"
201 #ifndef _DBAUI_DSNTYPES_HXX_
202 #include "dsntypes.hxx"
204 #include <svx/svxdlg.hxx>
205 #include <svtools/insdlg.hxx>
206 #ifndef _UNOTOOLS_TEMPFILE_HXX
207 #include <unotools/tempfile.hxx>
209 #ifndef _DBA_DBACCESS_HELPID_HRC_
210 #include "dbaccess_helpid.hrc"
212 #ifndef DBAUI_DLGSAVE_HXX
213 #include "dlgsave.hxx"
215 #ifndef _SFX_DOCFILT_HACK_HXX
216 #include <sfx2/docfilt.hxx>
218 #ifndef SFX_QUERYSAVEDOCUMENT_HXX
219 #include <sfx2/QuerySaveDocument.hxx>
221 #ifndef INCLUDED_SVTOOLS_HISTORYOPTIONS_HXX
222 #include <svtools/historyoptions.hxx>
224 #ifndef SVTOOLS_FILENOTATION_HXX_
225 #include <svtools/filenotation.hxx>
227 #ifndef _COMPHELPER_SEQUENCE_HXX_
228 #include <comphelper/sequence.hxx>
230 #ifndef _VOS_MUTEX_HXX_
231 #include <vos/mutex.hxx>
233 #ifndef _DBACCESS_SLOTID_HRC_
234 #include "dbaccess_slotid.hrc"
238 #include <functional>
240 #include <boost/noncopyable.hpp>
242 extern "C" void SAL_CALL
createRegistryInfo_ODBApplication()
244 static ::dbaui::OMultiInstanceAutoRegistration
< ::dbaui::OApplicationController
> aAutoRegistration
;
246 //........................................................................
249 //........................................................................
250 using namespace ::dbtools
;
251 using namespace ::svx
;
252 using namespace ::com::sun::star
;
253 using namespace ::com::sun::star::uno
;
254 using namespace ::com::sun::star::ucb
;
255 using namespace ::com::sun::star::view
;
256 using namespace ::com::sun::star::util
;
257 using namespace ::com::sun::star::beans
;
258 using namespace ::com::sun::star::lang
;
259 using namespace ::com::sun::star::frame
;
260 using namespace ::com::sun::star::container
;
261 using namespace ::com::sun::star::sdb
;
262 using namespace ::com::sun::star::sdbc
;
263 using namespace ::com::sun::star::sdbcx
;
264 using namespace ::com::sun::star::datatransfer
;
265 using namespace ::com::sun::star::ui::dialogs
;
266 using namespace ::com::sun::star::task
;
267 using ::com::sun::star::document::XEmbeddedScripts
;
268 using ::com::sun::star::document::XDocumentEventBroadcaster
;
269 using ::com::sun::star::document::DocumentEvent
;
270 using ::com::sun::star::sdb::application::NamedDatabaseObject
;
272 namespace DatabaseObject
= ::com::sun::star::sdb::application::DatabaseObject
;
273 namespace DatabaseObjectContainer
= ::com::sun::star::sdb::application::DatabaseObjectContainer
;
275 //------------------------------------------------------------------------------
276 ::rtl::OUString SAL_CALL
OApplicationController::getImplementationName() throw( RuntimeException
)
278 return getImplementationName_Static();
281 //------------------------------------------------------------------------------
282 ::rtl::OUString
OApplicationController::getImplementationName_Static() throw( RuntimeException
)
284 return ::rtl::OUString(SERVICE_SDB_APPLICATIONCONTROLLER
);
286 //------------------------------------------------------------------------------
287 Sequence
< ::rtl::OUString
> OApplicationController::getSupportedServiceNames_Static(void) throw( RuntimeException
)
289 Sequence
< ::rtl::OUString
> aSupported(1);
290 aSupported
.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.application.DefaultViewController");
293 //-------------------------------------------------------------------------
294 Sequence
< ::rtl::OUString
> SAL_CALL
OApplicationController::getSupportedServiceNames() throw(RuntimeException
)
296 return getSupportedServiceNames_Static();
298 // -------------------------------------------------------------------------
299 Reference
< XInterface
> SAL_CALL
OApplicationController::Create(const Reference
<XMultiServiceFactory
>& _rxFactory
)
301 return *(new OApplicationController(_rxFactory
));
303 // -----------------------------------------------------------------------------
305 struct XContainerFunctor
: public ::std::unary_function
< OApplicationController::TContainerVector::value_type
, bool>
307 Reference
<XContainerListener
> m_xContainerListener
;
308 XContainerFunctor( const Reference
<XContainerListener
>& _xContainerListener
)
309 : m_xContainerListener(_xContainerListener
){}
311 bool operator() (const OApplicationController::TContainerVector::value_type
& lhs
) const
314 lhs
->removeContainerListener(m_xContainerListener
);
319 //====================================================================
320 //= OApplicationController
321 //====================================================================
322 class SelectionNotifier
: public ::boost::noncopyable
325 ::cppu::OInterfaceContainerHelper m_aSelectionListeners
;
326 ::cppu::OWeakObject
& m_rContext
;
327 sal_Int32 m_nSelectionNestingLevel
;
330 SelectionNotifier( ::osl::Mutex
& _rMutex
, ::cppu::OWeakObject
& _rContext
)
331 :m_aSelectionListeners( _rMutex
)
332 ,m_rContext( _rContext
)
333 ,m_nSelectionNestingLevel( 0 )
337 void addListener( const Reference
< XSelectionChangeListener
>& _Listener
)
339 m_aSelectionListeners
.addInterface( _Listener
);
342 void removeListener( const Reference
< XSelectionChangeListener
>& _Listener
)
344 m_aSelectionListeners
.removeInterface( _Listener
);
349 EventObject
aEvent( m_rContext
);
350 m_aSelectionListeners
.disposeAndClear( aEvent
);
357 struct SelectionGuardAccess
{ friend class SelectionGuard
; private: SelectionGuardAccess() { } };
359 /** enters a block which modifies the selection of our owner.
361 Can be called multiple times, the only important thing is to call leaveSelection
364 void enterSelection( SelectionGuardAccess
)
366 ++m_nSelectionNestingLevel
;
369 /** leaves a block which modifies the selection of our owner
371 Must be paired with enterSelection calls.
373 When the last block is left, i.e. the last leaveSelection call is made on the current stack,
374 then our SelectionChangeListeners are notified
376 void leaveSelection( SelectionGuardAccess
)
378 if ( --m_nSelectionNestingLevel
== 0 )
380 EventObject
aEvent( m_rContext
);
381 m_aSelectionListeners
.notifyEach( &XSelectionChangeListener::selectionChanged
, aEvent
);
386 class SelectionGuard
: public ::boost::noncopyable
389 SelectionGuard( SelectionNotifier
& _rNotifier
)
390 :m_rNotifier( _rNotifier
)
392 m_rNotifier
.enterSelection( SelectionNotifier::SelectionGuardAccess() );
397 m_rNotifier
.leaveSelection( SelectionNotifier::SelectionGuardAccess() );
401 SelectionNotifier
& m_rNotifier
;
404 //====================================================================
405 //= OApplicationController
406 //====================================================================
407 DBG_NAME(OApplicationController
)
408 //--------------------------------------------------------------------
409 OApplicationController::OApplicationController(const Reference
< XMultiServiceFactory
>& _rxORB
)
410 :OApplicationController_CBASE( _rxORB
)
411 ,m_aContextMenuInterceptors( getMutex() )
412 ,m_pSubComponentManager( new SubComponentManager( *this, getSharedMutex() ) )
413 ,m_aTypeCollection(_rxORB
)
414 ,m_aTableCopyHelper(this)
415 ,m_pClipbordNotifier(NULL
)
417 ,m_aControllerConnectedEvent( LINK( this, OApplicationController
, OnFirstControllerConnected
) )
418 ,m_aSelectContainerEvent( LINK( this, OApplicationController
, OnSelectContainer
) )
419 ,m_ePreviewMode(E_PREVIEWNONE
)
420 ,m_eCurrentType(E_NONE
)
421 ,m_bNeedToReconnect(sal_False
)
422 ,m_bSuspended( sal_False
)
423 ,m_pSelectionNotifier( new SelectionNotifier( getMutex(), *this ) )
425 DBG_CTOR(OApplicationController
,NULL
);
427 //------------------------------------------------------------------------------
428 OApplicationController::~OApplicationController()
430 if ( !rBHelper
.bDisposed
&& !rBHelper
.bInDispose
)
432 OSL_ENSURE(0,"Please check who doesn't dispose this component!");
433 // increment ref count to prevent double call of Dtor
434 osl_incrementInterlockedCount( &m_refCount
);
437 ::std::auto_ptr
< Window
> aTemp(m_pView
);
440 DBG_DTOR(OApplicationController
,NULL
);
442 //--------------------------------------------------------------------
443 IMPLEMENT_FORWARD_XTYPEPROVIDER2(OApplicationController
,OApplicationController_CBASE
,OApplicationController_Base
)
444 IMPLEMENT_FORWARD_XINTERFACE2(OApplicationController
,OApplicationController_CBASE
,OApplicationController_Base
)
445 // -----------------------------------------------------------------------------
446 void OApplicationController::disconnect()
448 if ( m_xDataSourceConnection
.is() )
449 stopConnectionListening( m_xDataSourceConnection
);
453 // temporary (hopefully!) hack for #i55274#
454 Reference
< XFlushable
> xFlush( m_xDataSourceConnection
, UNO_QUERY
);
455 if ( xFlush
.is() && m_xMetaData
.is() && !m_xMetaData
->isReadOnly() )
458 catch( const Exception
& )
460 DBG_UNHANDLED_EXCEPTION();
463 m_xDataSourceConnection
.clear();
469 //--------------------------------------------------------------------
470 void SAL_CALL
OApplicationController::disposing()
472 m_aControllerConnectedEvent
.CancelCall();
474 ::std::for_each(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),XContainerFunctor(this));
475 m_aCurrentContainers
.clear();
476 m_pSubComponentManager
->disposing();
477 m_pSelectionNotifier
->disposing();
481 getContainer()->showPreview(NULL
);
482 m_pClipbordNotifier
->ClearCallbackLink();
483 m_pClipbordNotifier
->AddRemoveListener( getView(), sal_False
);
484 m_pClipbordNotifier
->release();
485 m_pClipbordNotifier
= NULL
;
491 Reference
< XFrame
> xFrame
;
492 attachFrame( xFrame
);
494 if ( m_xDataSource
.is() )
496 m_xDataSource
->removePropertyChangeListener(::rtl::OUString(), this);
497 m_xDataSource
->removePropertyChangeListener(PROPERTY_INFO
, this);
498 m_xDataSource
->removePropertyChangeListener(PROPERTY_URL
, this);
499 m_xDataSource
->removePropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED
, this);
500 m_xDataSource
->removePropertyChangeListener(PROPERTY_LAYOUTINFORMATION
, this);
501 m_xDataSource
->removePropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL
, this);
502 m_xDataSource
->removePropertyChangeListener(PROPERTY_TABLEFILTER
, this);
503 m_xDataSource
->removePropertyChangeListener(PROPERTY_TABLETYPEFILTER
, this);
504 m_xDataSource
->removePropertyChangeListener(PROPERTY_USER
, this);
505 // otherwise we may delete our datasource twice
506 Reference
<XPropertySet
> xProp
= m_xDataSource
;
507 m_xDataSource
= NULL
;
510 Reference
< XModifyBroadcaster
> xBroadcaster( m_xModel
, UNO_QUERY
);
511 if ( xBroadcaster
.is() )
512 xBroadcaster
->removeModifyListener(static_cast<XModifyListener
*>(this));
516 ::rtl::OUString sUrl
= m_xModel
->getURL();
517 if ( sUrl
.getLength() )
519 ::comphelper::NamedValueCollection
aArgs( m_xModel
->getArgs() );
520 if ( true == aArgs
.getOrDefault( "PickListEntry", true ) )
522 ::rtl::OUString aFilter
;
523 INetURLObject
aURL( m_xModel
->getURL() );
524 const SfxFilter
* pFilter
= getStandardDatabaseFilter();
526 aFilter
= pFilter
->GetFilterName();
528 // add to svtool history options
529 SvtHistoryOptions().AppendItem( ePICKLIST
,
530 aURL
.GetURLNoPass( INetURLObject::NO_DECODE
),
532 getStrippedDatabaseName(),
537 m_aModelConnector
.clear();
543 DBG_UNHANDLED_EXCEPTION();
547 OApplicationController_CBASE::disposing(); // here the m_refCount must be equal 5
550 //--------------------------------------------------------------------
551 sal_Bool
OApplicationController::Construct(Window
* _pParent
)
553 m_pView
= new OApplicationView( _pParent
, getORB(), *this, m_ePreviewMode
);
554 m_pView
->SetUniqueId(UID_APP_VIEW
);
557 sal_Bool bSuccess
= sal_False
;
560 getContainer()->Construct();
568 DBG_ERROR("OApplicationController::Construct : the construction of UnoDataBrowserView failed !");
573 ::std::auto_ptr
< Window
> aTemp(m_pView
);
578 DBG_ASSERT( getView(), "OApplicationController::Construct: have no view!" );
580 getView()->enableSeparator( );
582 // now that we have a view we can create the clipboard listener
583 m_aSystemClipboard
= TransferableDataHelper::CreateFromSystemClipboard( getView() );
584 m_aSystemClipboard
.StartClipboardListening( );
586 m_pClipbordNotifier
= new TransferableClipboardListener( LINK( this, OApplicationController
, OnClipboardChanged
) );
587 m_pClipbordNotifier
->acquire();
588 m_pClipbordNotifier
->AddRemoveListener( getView(), sal_True
);
590 OApplicationController_CBASE::Construct( _pParent
);
596 //--------------------------------------------------------------------
597 void SAL_CALL
OApplicationController::disposing(const EventObject
& _rSource
) throw( RuntimeException
)
599 ::osl::MutexGuard
aGuard( getMutex() );
600 Reference
<XConnection
> xCon(_rSource
.Source
, UNO_QUERY
);
603 DBG_ASSERT( ( m_xDataSourceConnection
== xCon
) && getContainer() && ( getContainer()->getElementType() == E_TABLE
),
604 "OApplicationController::disposing: the below code will ignore this call - why?" );
606 if ( getContainer() && getContainer()->getElementType() == E_TABLE
)
607 getContainer()->clearPages();
608 if ( m_xDataSourceConnection
== xCon
)
611 m_xDataSourceConnection
.clear();
614 else if ( _rSource
.Source
== m_xModel
)
617 m_aModelConnector
.clear();
619 else if ( _rSource
.Source
== m_xDataSource
)
621 m_xDataSource
= NULL
;
625 Reference
<XContainer
> xContainer( _rSource
.Source
, UNO_QUERY
);
626 if ( xContainer
.is() )
628 TContainerVector::iterator aFind
= ::std::find(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),xContainer
);
629 if ( aFind
!= m_aCurrentContainers
.end() )
630 m_aCurrentContainers
.erase(aFind
);
632 OApplicationController_CBASE::disposing( _rSource
);
635 //--------------------------------------------------------------------
636 sal_Bool SAL_CALL
OApplicationController::suspend(sal_Bool bSuspend
) throw( RuntimeException
)
638 // notify the OnPrepareViewClosing event (before locking any mutex)
639 Reference
< XDocumentEventBroadcaster
> xBroadcaster( m_xModel
, UNO_QUERY
);
640 if ( xBroadcaster
.is() )
642 xBroadcaster
->notifyDocumentEvent(
643 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnPrepareViewClosing" ) ),
649 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
650 ::osl::MutexGuard
aGuard( getMutex() );
652 if ( getView() && getView()->IsInModalMode() )
655 sal_Bool bCanSuspend
= sal_True
;
657 if ( m_bSuspended
!= bSuspend
)
659 if ( bSuspend
&& !closeSubComponents() )
662 Reference
<XModifiable
> xModi(m_xModel
,UNO_QUERY
);
663 Reference
<XStorable
> xStor(getModel(),UNO_QUERY
);
667 && !xStor
->isReadonly()
669 && xModi
->isModified()
673 switch (ExecuteQuerySaveDocument(getView(),getStrippedDatabaseName()))
676 Execute(ID_BROWSER_SAVEDOC
,Sequence
<PropertyValue
>());
677 bCanSuspend
= !xModi
->isModified();
678 // when we save the document this must be false else some press cancel
681 bCanSuspend
= sal_False
;
689 m_bSuspended
= bSuspend
;
693 // -----------------------------------------------------------------------------
694 FeatureState
OApplicationController::GetState(sal_uInt16 _nId
) const
696 FeatureState aReturn
;
697 aReturn
.bEnabled
= sal_False
;
699 if ( !getContainer() || m_bReadOnly
)
707 aReturn
.bEnabled
= sal_True
;
709 aReturn
.sTitle
= m_xModel
->getURL();
711 case ID_BROWSER_COPY
:
713 sal_Int32 nCount
= getContainer()->getSelectionCount();
714 aReturn
.bEnabled
= nCount
>= 1;
715 if ( aReturn
.bEnabled
&& nCount
== 1 && getContainer()->getElementType() == E_TABLE
)
716 aReturn
.bEnabled
= getContainer()->isALeafSelected();
720 aReturn
.bEnabled
= !isDataSourceReadOnly() && getContainer()->getSelectionCount() >= 1;
721 aReturn
.bEnabled
= aReturn
.bEnabled
&& ( (ID_BROWSER_CUT
== _nId
&& getContainer()->getElementType() == E_TABLE
) ? getContainer()->isCutAllowed() : sal_True
);
723 case ID_BROWSER_PASTE
:
724 switch( getContainer()->getElementType() )
727 aReturn
.bEnabled
= !isDataSourceReadOnly() && !isConnectionReadOnly() && isTableFormat();
730 aReturn
.bEnabled
= !isDataSourceReadOnly() && getViewClipboard().HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY
);
733 aReturn
.bEnabled
= !isDataSourceReadOnly() && OComponentTransferable::canExtractComponentDescriptor(getViewClipboard().GetDataFlavorExVector(),getContainer()->getElementType() == E_FORM
);
736 case SID_DB_APP_PASTE_SPECIAL
:
737 aReturn
.bEnabled
= getContainer()->getElementType() == E_TABLE
&& !isDataSourceReadOnly() && !isConnectionReadOnly() && isTableFormat();
741 aReturn
.bEnabled
= sal_True
;
743 case ID_BROWSER_SAVEDOC
:
744 aReturn
.bEnabled
= !isDataSourceReadOnly() && m_xDocumentModify
.is() && m_xDocumentModify
->isModified();
746 case ID_BROWSER_SAVEASDOC
:
747 aReturn
.bEnabled
= sal_True
;
749 case ID_BROWSER_SORTUP
:
750 aReturn
.bEnabled
= getContainer()->isFilled() && getContainer()->getElementCount();
751 aReturn
.bChecked
= aReturn
.bEnabled
&& getContainer()->isSortUp();
753 case ID_BROWSER_SORTDOWN
:
754 aReturn
.bEnabled
= getContainer()->isFilled() && getContainer()->getElementCount();
755 aReturn
.bChecked
= aReturn
.bEnabled
&& !getContainer()->isSortUp();
759 case SID_APP_NEW_FORM
:
760 case ID_DOCUMENT_CREATE_REPWIZ
:
761 aReturn
.bEnabled
= !isDataSourceReadOnly() && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER
);
763 case SID_APP_NEW_REPORT
:
764 aReturn
.bEnabled
= !isDataSourceReadOnly()
765 && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER
);
766 if ( aReturn
.bEnabled
)
768 Reference
< XContentEnumerationAccess
> xEnumAccess(m_xServiceFactory
, UNO_QUERY
);
769 aReturn
.bEnabled
= xEnumAccess
.is();
770 if ( aReturn
.bEnabled
)
772 const ::rtl::OUString sReportEngineServiceName
= ::dbtools::getDefaultReportEngineServiceName(m_xServiceFactory
);
773 aReturn
.bEnabled
= sReportEngineServiceName
.getLength() != 0;
774 if ( aReturn
.bEnabled
)
776 const Reference
< XEnumeration
> xEnumDrivers
= xEnumAccess
->createContentEnumeration(sReportEngineServiceName
);
777 aReturn
.bEnabled
= xEnumDrivers
.is() && xEnumDrivers
->hasMoreElements();
782 case SID_DB_APP_VIEW_TABLES
:
783 aReturn
.bEnabled
= sal_True
;
784 aReturn
.bChecked
= getContainer()->getElementType() == E_TABLE
;
786 case SID_DB_APP_VIEW_QUERIES
:
787 aReturn
.bEnabled
= sal_True
;
788 aReturn
.bChecked
= getContainer()->getElementType() == E_QUERY
;
790 case SID_DB_APP_VIEW_FORMS
:
791 aReturn
.bEnabled
= sal_True
;
792 aReturn
.bChecked
= getContainer()->getElementType() == E_FORM
;
794 case SID_DB_APP_VIEW_REPORTS
:
795 aReturn
.bEnabled
= sal_True
;
796 aReturn
.bChecked
= getContainer()->getElementType() == E_REPORT
;
798 case ID_NEW_QUERY_DESIGN
:
799 case ID_NEW_QUERY_SQL
:
800 case ID_APP_NEW_QUERY_AUTO_PILOT
:
801 case SID_DB_FORM_NEW_PILOT
:
802 aReturn
.bEnabled
= !isDataSourceReadOnly();
804 case ID_NEW_VIEW_DESIGN
:
805 case SID_DB_NEW_VIEW_SQL
:
806 case ID_NEW_VIEW_DESIGN_AUTO_PILOT
:
807 aReturn
.bEnabled
= !isDataSourceReadOnly() && !isConnectionReadOnly();
808 if ( aReturn
.bEnabled
)
810 Reference
<XViewsSupplier
> xViewsSup( getConnection(), UNO_QUERY
);
811 aReturn
.bEnabled
= xViewsSup
.is();
814 case ID_NEW_TABLE_DESIGN
:
815 case ID_NEW_TABLE_DESIGN_AUTO_PILOT
:
816 aReturn
.bEnabled
= !isDataSourceReadOnly() && !isConnectionReadOnly();
819 aReturn
.bEnabled
= sal_True
;
821 case ID_MIGRATE_SCRIPTS
:
823 // Our document supports embedding scripts into it, if and only if there are no
824 // forms/reports with macros/scripts into them. So, we need to enable migration
825 // if and only if the database document does *not* support embedding scripts.
827 !Reference
< XEmbeddedScripts
>( m_xModel
, UNO_QUERY
).is()
828 && !Reference
< XStorable
>( m_xModel
, UNO_QUERY_THROW
)->isReadonly();
829 aReturn
.bEnabled
= bAvailable
;
831 aReturn
.bInvisible
= true;
834 case SID_APP_NEW_FOLDER
:
835 aReturn
.bEnabled
= !isDataSourceReadOnly() && getContainer()->getSelectionCount() <= 1;
836 if ( aReturn
.bEnabled
)
838 const ElementType eType
= getContainer()->getElementType();
839 aReturn
.bEnabled
= eType
== E_REPORT
|| eType
== E_FORM
;
842 case SID_FORM_CREATE_REPWIZ_PRE_SEL
:
843 case SID_REPORT_CREATE_REPWIZ_PRE_SEL
:
844 case SID_APP_NEW_REPORT_PRE_SEL
:
845 aReturn
.bEnabled
= !isDataSourceReadOnly()
846 && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER
)
847 && getContainer()->isALeafSelected();
848 if ( aReturn
.bEnabled
)
850 ElementType eType
= getContainer()->getElementType();
851 aReturn
.bEnabled
= eType
== E_QUERY
|| eType
== E_TABLE
;
852 if ( aReturn
.bEnabled
&& SID_APP_NEW_REPORT_PRE_SEL
== _nId
)
854 Reference
< XContentEnumerationAccess
> xEnumAccess(m_xServiceFactory
, UNO_QUERY
);
855 aReturn
.bEnabled
= xEnumAccess
.is();
856 if ( aReturn
.bEnabled
)
858 static ::rtl::OUString
s_sReportDesign(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOReportJobFactory"));
859 Reference
< XEnumeration
> xEnumDrivers
= xEnumAccess
->createContentEnumeration(s_sReportDesign
);
860 aReturn
.bEnabled
= xEnumDrivers
.is() && xEnumDrivers
->hasMoreElements();
865 case SID_DB_APP_DELETE
:
866 case SID_DB_APP_RENAME
:
867 aReturn
.bEnabled
= isRenameDeleteAllowed(getContainer()->getElementType(), _nId
== SID_DB_APP_DELETE
);
869 case SID_DB_APP_TABLE_DELETE
:
870 case SID_DB_APP_TABLE_RENAME
:
871 aReturn
.bEnabled
= isRenameDeleteAllowed(E_TABLE
, _nId
== SID_DB_APP_TABLE_DELETE
);
873 case SID_DB_APP_QUERY_DELETE
:
874 case SID_DB_APP_QUERY_RENAME
:
875 aReturn
.bEnabled
= isRenameDeleteAllowed(E_QUERY
, _nId
== SID_DB_APP_QUERY_DELETE
);
877 case SID_DB_APP_FORM_DELETE
:
878 case SID_DB_APP_FORM_RENAME
:
879 aReturn
.bEnabled
= isRenameDeleteAllowed(E_FORM
, _nId
== SID_DB_APP_FORM_DELETE
);
881 case SID_DB_APP_REPORT_DELETE
:
882 case SID_DB_APP_REPORT_RENAME
:
883 aReturn
.bEnabled
= isRenameDeleteAllowed(E_REPORT
, _nId
== SID_DB_APP_REPORT_DELETE
);
887 aReturn
.bEnabled
= getContainer()->getElementCount() > 0 && getContainer()->getSelectionCount() != getContainer()->getElementCount();
889 case SID_DB_APP_EDIT
:
890 case SID_DB_APP_TABLE_EDIT
:
891 case SID_DB_APP_QUERY_EDIT
:
892 case SID_DB_APP_FORM_EDIT
:
893 case SID_DB_APP_REPORT_EDIT
:
894 aReturn
.bEnabled
= !isDataSourceReadOnly() && getContainer()->getSelectionCount() > 0
895 && getContainer()->isALeafSelected();
897 case SID_DB_APP_EDIT_SQL_VIEW
:
898 if ( isDataSourceReadOnly() )
899 aReturn
.bEnabled
= sal_False
;
902 switch ( getContainer()->getElementType() )
905 aReturn
.bEnabled
= ( getContainer()->getSelectionCount() > 0 )
906 && ( getContainer()->isALeafSelected() );
909 aReturn
.bEnabled
= sal_False
;
910 // there's one exception: views which support altering their underlying
911 // command can be edited in SQL view, too
912 if ( ( getContainer()->getSelectionCount() > 0 )
913 && ( getContainer()->isALeafSelected() )
916 ::std::vector
< ::rtl::OUString
> aSelected
;
917 getSelectionElementNames( aSelected
);
918 bool bAlterableViews
= true;
919 for ( ::std::vector
< ::rtl::OUString
>::const_iterator selectedName
= aSelected
.begin();
920 bAlterableViews
&& ( selectedName
!= aSelected
.end() ) ;
924 bAlterableViews
&= impl_isAlterableView_nothrow( *selectedName
);
926 aReturn
.bEnabled
= bAlterableViews
;
934 case SID_DB_APP_OPEN
:
935 case SID_DB_APP_TABLE_OPEN
:
936 case SID_DB_APP_QUERY_OPEN
:
937 case SID_DB_APP_FORM_OPEN
:
938 case SID_DB_APP_REPORT_OPEN
:
939 aReturn
.bEnabled
= getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
941 case SID_DB_APP_DSUSERADMIN
:
942 aReturn
.bEnabled
= !m_aTypeCollection
.isEmbeddedDatabase(::comphelper::getString(m_xDataSource
->getPropertyValue(PROPERTY_URL
)));
944 case SID_DB_APP_DSRELDESIGN
:
945 aReturn
.bEnabled
= sal_True
;
947 case SID_DB_APP_TABLEFILTER
:
948 aReturn
.bEnabled
= !isDataSourceReadOnly();
950 case SID_DB_APP_REFRESH_TABLES
:
951 aReturn
.bEnabled
= getContainer()->getElementType() == E_TABLE
&& isConnected();
953 case SID_DB_APP_DSPROPS
:
954 aReturn
.bEnabled
= m_xDataSource
.is() && m_aTypeCollection
.isShowPropertiesEnabled(::comphelper::getString(m_xDataSource
->getPropertyValue(PROPERTY_URL
)));
956 case SID_DB_APP_DSCONNECTION_TYPE
:
957 aReturn
.bEnabled
= !isDataSourceReadOnly() && m_xDataSource
.is() && !m_aTypeCollection
.isEmbeddedDatabase(::comphelper::getString(m_xDataSource
->getPropertyValue(PROPERTY_URL
)));
959 case SID_DB_APP_DSADVANCED_SETTINGS
:
960 aReturn
.bEnabled
= m_xDataSource
.is() && AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( m_aTypeCollection
.getType(::comphelper::getString( m_xDataSource
->getPropertyValue( PROPERTY_URL
) )) );
962 case SID_DB_APP_CONVERTTOVIEW
:
963 aReturn
.bEnabled
= !isDataSourceReadOnly();
964 if ( aReturn
.bEnabled
)
966 ElementType eType
= getContainer()->getElementType();
967 aReturn
.bEnabled
= eType
== E_QUERY
&& getContainer()->getSelectionCount() > 0;
968 if ( aReturn
.bEnabled
)
970 Reference
<XViewsSupplier
> xViewSup( getConnection(), UNO_QUERY
);
971 aReturn
.bEnabled
= xViewSup
.is() && Reference
<XAppend
>(xViewSup
->getViews(),UNO_QUERY
).is();
975 case SID_DB_APP_DISABLE_PREVIEW
:
976 aReturn
.bEnabled
= sal_True
;
977 aReturn
.bChecked
= getContainer()->getPreviewMode() == E_PREVIEWNONE
;
979 case SID_DB_APP_VIEW_DOCINFO_PREVIEW
:
981 ElementType eType
= getContainer()->getElementType();
982 aReturn
.bEnabled
= (E_REPORT
== eType
|| E_FORM
== eType
);
983 aReturn
.bChecked
= getContainer()->getPreviewMode() == E_DOCUMENTINFO
;
986 case SID_DB_APP_VIEW_DOC_PREVIEW
:
987 aReturn
.bEnabled
= sal_True
;
988 aReturn
.bChecked
= getContainer()->getPreviewMode() == E_DOCUMENT
;
990 case ID_BROWSER_UNDO
:
991 aReturn
.bEnabled
= sal_False
;
993 case SID_MAIL_SENDDOC
:
994 aReturn
.bEnabled
= sal_True
;
996 case SID_DB_APP_SENDREPORTASMAIL
:
998 ElementType eType
= getContainer()->getElementType();
999 aReturn
.bEnabled
= E_REPORT
== eType
&& getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
1002 case SID_DB_APP_SENDREPORTTOWRITER
:
1003 case SID_DB_APP_DBADMIN
:
1004 aReturn
.bEnabled
= sal_False
;
1006 case SID_DB_APP_STATUS_TYPE
:
1007 aReturn
.bEnabled
= m_xDataSource
.is();
1008 if ( aReturn
.bEnabled
)
1010 ::rtl::OUString sURL
;
1011 m_xDataSource
->getPropertyValue(PROPERTY_URL
) >>= sURL
;
1012 ::rtl::OUString sDSTypeName
;
1013 if ( m_aTypeCollection
.isEmbeddedDatabase( sURL
) )
1015 sDSTypeName
= String( ModuleRes( RID_STR_EMBEDDED_DATABASE
) );
1019 sDSTypeName
= m_aTypeCollection
.getTypeDisplayName(sURL
);
1021 aReturn
.sTitle
= sDSTypeName
;
1024 case SID_DB_APP_STATUS_DBNAME
:
1025 aReturn
.bEnabled
= m_xDataSource
.is();
1026 if ( aReturn
.bEnabled
)
1028 ::rtl::OUString sURL
;
1029 m_xDataSource
->getPropertyValue(PROPERTY_URL
) >>= sURL
;
1030 String sDatabaseName
;
1032 sal_Int32
nPortNumber( -1 );
1034 m_aTypeCollection
.extractHostNamePort( sURL
, sDatabaseName
, sHostName
, nPortNumber
);
1036 if ( !sDatabaseName
.Len() )
1037 sDatabaseName
= m_aTypeCollection
.cutPrefix( sURL
);
1038 if ( m_aTypeCollection
.isFileSystemBased(sURL
) )
1040 sDatabaseName
= SvtPathOptions().SubstituteVariable( sDatabaseName
);
1041 if ( sDatabaseName
.Len() )
1043 ::svt::OFileNotation
aFileNotation(sDatabaseName
);
1044 // set this decoded URL as text
1045 sDatabaseName
= aFileNotation
.get(::svt::OFileNotation::N_SYSTEM
);
1049 if ( sDatabaseName
.Len() == 0 )
1050 sDatabaseName
= m_aTypeCollection
.getTypeDisplayName( sURL
);
1052 aReturn
.sTitle
= sDatabaseName
;
1055 case SID_DB_APP_STATUS_USERNAME
:
1056 aReturn
.bEnabled
= m_xDataSource
.is();
1057 if ( aReturn
.bEnabled
)
1058 m_xDataSource
->getPropertyValue( PROPERTY_USER
) >>= aReturn
.sTitle
;
1060 case SID_DB_APP_STATUS_HOSTNAME
:
1061 aReturn
.bEnabled
= m_xDataSource
.is();
1062 if ( aReturn
.bEnabled
)
1064 ::rtl::OUString sURL
;
1065 m_xDataSource
->getPropertyValue( PROPERTY_URL
) >>= sURL
;
1067 String sHostName
, sDatabaseName
;
1068 sal_Int32 nPortNumber
= -1;
1069 m_aTypeCollection
.extractHostNamePort( sURL
, sDatabaseName
, sHostName
, nPortNumber
);
1070 aReturn
.sTitle
= sHostName
;
1074 aReturn
= OApplicationController_CBASE::GetState(_nId
);
1077 catch(const Exception
& )
1079 DBG_UNHANDLED_EXCEPTION();
1084 // -----------------------------------------------------------------------------
1087 bool lcl_handleException_nothrow( const Reference
< XModel
>& _rxDocument
, const Any
& _rException
)
1089 bool bHandled
= false;
1091 // try handling the error with an interaction handler
1092 ::comphelper::NamedValueCollection
aArgs( _rxDocument
->getArgs() );
1093 Reference
< XInteractionHandler
> xHandler( aArgs
.getOrDefault( "InteractionHandler", Reference
< XInteractionHandler
>() ) );
1094 if ( xHandler
.is() )
1096 ::rtl::Reference
< ::comphelper::OInteractionRequest
> pRequest( new ::comphelper::OInteractionRequest( _rException
) );
1097 ::rtl::Reference
< ::comphelper::OInteractionApprove
> pApprove( new ::comphelper::OInteractionApprove
);
1098 pRequest
->addContinuation( pApprove
.get() );
1102 xHandler
->handle( pRequest
.get() );
1104 catch( const Exception
& )
1106 DBG_UNHANDLED_EXCEPTION();
1109 bHandled
= pApprove
->wasSelected();
1115 // -----------------------------------------------------------------------------
1116 void OApplicationController::Execute(sal_uInt16 _nId
, const Sequence
< PropertyValue
>& aArgs
)
1118 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
1119 ::osl::MutexGuard
aGuard( getMutex() );
1121 if ( isUserDefinedFeature( _nId
) )
1123 OApplicationController_CBASE::Execute( _nId
, aArgs
);
1127 if ( !getContainer() || m_bReadOnly
)
1128 return; // return without execution
1134 case ID_BROWSER_CUT
:
1135 getContainer()->cut();
1137 case ID_BROWSER_COPY
:
1139 TransferableHelper
* pTransfer
= copyObject( );
1140 Reference
< XTransferable
> aEnsureDelete
= pTransfer
;
1143 pTransfer
->CopyToClipboard(getView());
1146 case ID_BROWSER_PASTE
:
1148 const TransferableDataHelper
& rTransferData( getViewClipboard() );
1149 ElementType eType
= getContainer()->getElementType();
1155 // get the selected tablename
1156 ::std::vector
< ::rtl::OUString
> aList
;
1157 getSelectionElementNames( aList
);
1158 if ( !aList
.empty() )
1159 m_aTableCopyHelper
.SetTableNameForAppend( *aList
.begin() );
1161 m_aTableCopyHelper
.ResetTableNameForAppend();
1163 m_aTableCopyHelper
.pasteTable( rTransferData
, getDatabaseName(), ensureConnection() );
1168 if ( rTransferData
.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY
) )
1169 paste( E_QUERY
, ODataAccessObjectTransferable::extractObjectDescriptor( rTransferData
) );
1173 ::std::vector
< ::rtl::OUString
> aList
;
1174 getSelectionElementNames(aList
);
1175 ::rtl::OUString sFolderNameToInsertInto
;
1176 if ( !aList
.empty() )
1178 Reference
< XHierarchicalNameAccess
> xContainer(getElements(eType
),UNO_QUERY
);
1179 if ( xContainer
.is()
1180 && xContainer
->hasByHierarchicalName(*aList
.begin())
1181 && (xContainer
->getByHierarchicalName(*aList
.begin()) >>= xContainer
)
1184 sFolderNameToInsertInto
= *aList
.begin();
1186 paste( eType
, OComponentTransferable::extractComponentDescriptor( rTransferData
),
1187 sFolderNameToInsertInto
);
1193 case SID_DB_APP_PASTE_SPECIAL
:
1195 if ( !aArgs
.getLength() )
1197 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1198 ::std::auto_ptr
<SfxAbstractPasteDialog
> pDlg(pFact
->CreatePasteDialog( getView() ));
1199 ::std::vector
<SotFormatStringId
> aFormatIds
;
1200 getSupportedFormats(getContainer()->getElementType(),aFormatIds
);
1201 const ::std::vector
<SotFormatStringId
>::iterator aEnd
= aFormatIds
.end();
1202 ::rtl::OUString sEmpty
;
1203 for (::std::vector
<SotFormatStringId
>::iterator aIter
= aFormatIds
.begin();aIter
!= aEnd
; ++aIter
)
1204 pDlg
->Insert(*aIter
,sEmpty
);
1206 const TransferableDataHelper
& rClipboard
= getViewClipboard();
1207 pasteFormat(pDlg
->GetFormat(rClipboard
.GetTransferable()));
1211 const PropertyValue
* pIter
= aArgs
.getConstArray();
1212 const PropertyValue
* pEnd
= pIter
+ aArgs
.getLength();
1213 for( ; pIter
!= pEnd
; ++pIter
)
1215 if ( pIter
->Name
.equalsAscii("FormatStringId") )
1217 SotFormatStringId nFormatId
= 0;
1218 if ( pIter
->Value
>>= nFormatId
)
1219 pasteFormat(nFormatId
);
1227 case SID_HELP_INDEX
:
1229 Reference
< XDispatchProvider
> xProv( getFrame(), UNO_QUERY
);
1235 case SID_HELP_INDEX
:
1236 aURL
.Complete
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:HelpIndex"));
1239 aURL
.Complete
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Open"));
1243 if ( m_xUrlTransformer
.is() )
1244 m_xUrlTransformer
->parseStrict( aURL
);
1245 Reference
< XDispatch
> xDisp
= xProv
->queryDispatch( aURL
, String(), 0 );
1247 xDisp
->dispatch( aURL
, Sequence
< PropertyValue
>() );
1251 case ID_BROWSER_SAVEDOC
:
1253 Reference
< XStorable
> xStore( m_xModel
, UNO_QUERY_THROW
);
1258 catch( const Exception
& )
1260 lcl_handleException_nothrow( m_xModel
, ::cppu::getCaughtException() );
1265 case ID_BROWSER_SAVEASDOC
:
1267 WinBits
nBits(WB_STDMODAL
|WB_SAVEAS
);
1268 ::rtl::OUString sUrl
;
1269 if ( m_xModel
.is() )
1270 sUrl
= m_xModel
->getURL();
1271 if ( !sUrl
.getLength() )
1272 sUrl
= SvtPathOptions().GetWorkPath();
1274 ::sfx2::FileDialogHelper
aFileDlg( com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
,static_cast<sal_uInt32
>(nBits
) ,getView());
1275 aFileDlg
.SetDisplayDirectory( sUrl
);
1277 const SfxFilter
* pFilter
= getStandardDatabaseFilter();
1280 aFileDlg
.AddFilter(pFilter
->GetUIName(),pFilter
->GetDefaultExtension());
1281 aFileDlg
.SetCurrentFilter(pFilter
->GetUIName());
1284 if ( aFileDlg
.Execute() != ERRCODE_NONE
)
1287 Reference
<XStorable
> xStore( m_xModel
, UNO_QUERY_THROW
);
1288 INetURLObject
aURL( aFileDlg
.GetPath() );
1291 xStore
->storeAsURL( aURL
.GetMainURL( INetURLObject::NO_DECODE
), Sequence
< PropertyValue
>() );
1293 catch( const Exception
& )
1295 lcl_handleException_nothrow( m_xModel
, ::cppu::getCaughtException() );
1299 m_bCurrentlyModified
= sal_False
;
1300 InvalidateFeature(ID_BROWSER_SAVEDOC
);
1301 if ( getContainer()->getElementType() == E_NONE
)
1303 getContainer()->selectContainer(E_NONE
);
1304 getContainer()->selectContainer(E_TABLE
);
1306 getContainer()->Invalidate();
1312 case ID_BROWSER_SORTUP
:
1313 getContainer()->sortUp();
1314 InvalidateFeature(ID_BROWSER_SORTDOWN
);
1316 case ID_BROWSER_SORTDOWN
:
1317 getContainer()->sortDown();
1318 InvalidateFeature(ID_BROWSER_SORTUP
);
1321 case ID_NEW_TABLE_DESIGN_AUTO_PILOT
:
1322 case ID_NEW_VIEW_DESIGN_AUTO_PILOT
:
1323 case ID_APP_NEW_QUERY_AUTO_PILOT
:
1324 case SID_DB_FORM_NEW_PILOT
:
1325 case SID_REPORT_CREATE_REPWIZ_PRE_SEL
:
1326 case SID_APP_NEW_REPORT_PRE_SEL
:
1327 case SID_FORM_CREATE_REPWIZ_PRE_SEL
:
1328 case ID_DOCUMENT_CREATE_REPWIZ
:
1329 case SID_APP_NEW_FORM
:
1330 case SID_APP_NEW_REPORT
:
1331 case ID_NEW_QUERY_SQL
:
1332 case ID_NEW_QUERY_DESIGN
:
1333 case ID_NEW_TABLE_DESIGN
:
1335 ElementType eType
= E_TABLE
;
1336 sal_Bool bAutoPilot
= sal_False
;
1337 sal_Bool bSQLView
= sal_False
;
1341 case SID_DB_FORM_NEW_PILOT
:
1342 case SID_FORM_CREATE_REPWIZ_PRE_SEL
:
1343 bAutoPilot
= sal_True
;
1345 case SID_APP_NEW_FORM
:
1348 case ID_DOCUMENT_CREATE_REPWIZ
:
1349 case SID_REPORT_CREATE_REPWIZ_PRE_SEL
:
1350 bAutoPilot
= sal_True
;
1352 case SID_APP_NEW_REPORT
:
1353 case SID_APP_NEW_REPORT_PRE_SEL
:
1356 case ID_APP_NEW_QUERY_AUTO_PILOT
:
1357 bAutoPilot
= sal_True
;
1360 case ID_NEW_QUERY_SQL
:
1361 bSQLView
= sal_True
;
1363 case ID_NEW_QUERY_DESIGN
:
1366 case ID_NEW_TABLE_DESIGN_AUTO_PILOT
:
1367 bAutoPilot
= sal_True
;
1369 case ID_NEW_TABLE_DESIGN
:
1372 OSL_ENSURE(0,"illegal switch call!");
1375 getContainer()->PostUserEvent( LINK( this, OApplicationController
, OnCreateWithPilot
), reinterpret_cast< void* >( eType
) );
1377 newElement( eType
, bSQLView
);
1380 case SID_APP_NEW_FOLDER
:
1382 ElementType eType
= getContainer()->getElementType();
1383 ::rtl::OUString sName
= getContainer()->getQualifiedName( NULL
);
1384 insertHierachyElement(eType
,sName
);
1387 case ID_NEW_VIEW_DESIGN
:
1388 case SID_DB_NEW_VIEW_SQL
:
1390 SharedConnection
xConnection( ensureConnection() );
1391 if ( xConnection
.is() )
1393 QueryDesigner
aDesigner( getORB(), this, getFrame(), true, SID_DB_NEW_VIEW_SQL
== _nId
);
1395 Reference
< XDataSource
> xDataSource( m_xDataSource
, UNO_QUERY
);
1396 Reference
< XComponent
> xComponent( aDesigner
.createNew( xDataSource
), UNO_QUERY
);
1397 onDocumentOpened( ::rtl::OUString(), E_QUERY
, E_OPEN_DESIGN
, xComponent
, NULL
);
1401 case SID_DB_APP_DELETE
:
1402 case SID_DB_APP_TABLE_DELETE
:
1403 case SID_DB_APP_QUERY_DELETE
:
1404 case SID_DB_APP_FORM_DELETE
:
1405 case SID_DB_APP_REPORT_DELETE
:
1408 case SID_DB_APP_RENAME
:
1409 case SID_DB_APP_TABLE_RENAME
:
1410 case SID_DB_APP_QUERY_RENAME
:
1411 case SID_DB_APP_FORM_RENAME
:
1412 case SID_DB_APP_REPORT_RENAME
:
1415 case SID_DB_APP_EDIT
:
1416 case SID_DB_APP_EDIT_SQL_VIEW
:
1417 case SID_DB_APP_TABLE_EDIT
:
1418 case SID_DB_APP_QUERY_EDIT
:
1419 case SID_DB_APP_FORM_EDIT
:
1420 case SID_DB_APP_REPORT_EDIT
:
1421 doAction( _nId
, E_OPEN_DESIGN
);
1423 case SID_DB_APP_OPEN
:
1424 case SID_DB_APP_TABLE_OPEN
:
1425 case SID_DB_APP_QUERY_OPEN
:
1426 case SID_DB_APP_FORM_OPEN
:
1427 case SID_DB_APP_REPORT_OPEN
:
1428 doAction( _nId
, E_OPEN_NORMAL
);
1430 case SID_DB_APP_CONVERTTOVIEW
:
1431 doAction( _nId
, E_OPEN_NORMAL
);
1434 getContainer()->selectAll();
1437 case SID_DB_APP_DSRELDESIGN
:
1438 if ( !m_pSubComponentManager
->activateSubFrame( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN
, E_OPEN_DESIGN
) )
1440 SharedConnection
xConnection( ensureConnection() );
1441 if ( xConnection
.is() )
1443 RelationDesigner
aDesigner( getORB(), this, m_aCurrentFrame
.getFrame() );
1445 Reference
< XDataSource
> xDataSource( m_xDataSource
, UNO_QUERY
);
1446 Reference
< XComponent
> xComponent( aDesigner
.createNew( xDataSource
), UNO_QUERY
);
1447 onDocumentOpened( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN
, E_OPEN_DESIGN
, xComponent
, NULL
);
1451 case SID_DB_APP_DSUSERADMIN
:
1453 SharedConnection
xConnection( ensureConnection() );
1454 if ( xConnection
.is() )
1455 openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.UserAdministrationDialog")));
1458 case SID_DB_APP_TABLEFILTER
:
1459 openTableFilterDialog();
1462 case SID_DB_APP_REFRESH_TABLES
:
1465 case SID_DB_APP_DSPROPS
:
1466 openDataSourceAdminDialog();
1469 case SID_DB_APP_DSADVANCED_SETTINGS
:
1470 openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.AdvancedDatabaseSettingsDialog")));
1473 case SID_DB_APP_DSCONNECTION_TYPE
:
1474 openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DataSourceTypeChangeDialog")));
1479 SharedConnection
xConnection( ensureConnection() );
1480 if ( xConnection
.is() )
1481 openDirectSQLDialog();
1484 case ID_MIGRATE_SCRIPTS
:
1485 impl_migrateScripts_nothrow();
1487 case SID_DB_APP_VIEW_TABLES
:
1488 m_aSelectContainerEvent
.Call( reinterpret_cast< void* >( E_TABLE
) );
1490 case SID_DB_APP_VIEW_QUERIES
:
1491 m_aSelectContainerEvent
.Call( reinterpret_cast< void* >( E_QUERY
) );
1493 case SID_DB_APP_VIEW_FORMS
:
1494 m_aSelectContainerEvent
.Call( reinterpret_cast< void* >( E_FORM
) );
1496 case SID_DB_APP_VIEW_REPORTS
:
1497 m_aSelectContainerEvent
.Call( reinterpret_cast< void* >( E_REPORT
) );
1499 case SID_DB_APP_DISABLE_PREVIEW
:
1500 m_ePreviewMode
= E_PREVIEWNONE
;
1501 getContainer()->switchPreview(m_ePreviewMode
);
1503 case SID_DB_APP_VIEW_DOCINFO_PREVIEW
:
1504 m_ePreviewMode
= E_DOCUMENTINFO
;
1505 getContainer()->switchPreview(m_ePreviewMode
);
1507 case SID_DB_APP_VIEW_DOC_PREVIEW
:
1508 m_ePreviewMode
= E_DOCUMENT
;
1509 getContainer()->switchPreview(m_ePreviewMode
);
1511 case SID_MAIL_SENDDOC
:
1513 SfxMailModel aSendMail
;
1514 if ( aSendMail
.AttachDocument(rtl::OUString(),getModel(), rtl::OUString()) == SfxMailModel::SEND_MAIL_OK
)
1515 aSendMail
.Send( getFrame() );
1518 case SID_DB_APP_SENDREPORTASMAIL
:
1519 doAction( _nId
, E_OPEN_FOR_MAIL
);
1523 catch( const Exception
& )
1525 DBG_UNHANDLED_EXCEPTION();
1527 InvalidateFeature(_nId
);
1529 // -----------------------------------------------------------------------------
1530 void OApplicationController::describeSupportedFeatures()
1532 OApplicationController_CBASE::describeSupportedFeatures();
1534 implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVEDOC
, CommandGroup::DOCUMENT
);
1535 implDescribeSupportedFeature( ".uno:SaveAs", ID_BROWSER_SAVEASDOC
, CommandGroup::DOCUMENT
);
1536 implDescribeSupportedFeature( ".uno:SendMail", SID_MAIL_SENDDOC
, CommandGroup::DOCUMENT
);
1537 implDescribeSupportedFeature( ".uno:DBSendReportAsMail",SID_DB_APP_SENDREPORTASMAIL
,
1538 CommandGroup::DOCUMENT
);
1539 implDescribeSupportedFeature( ".uno:DBSendReportToWriter",SID_DB_APP_SENDREPORTTOWRITER
,
1540 CommandGroup::DOCUMENT
);
1541 implDescribeSupportedFeature( ".uno:DBNewForm", SID_APP_NEW_FORM
, CommandGroup::INSERT
);
1542 implDescribeSupportedFeature( ".uno:DBNewFolder", SID_APP_NEW_FOLDER
, CommandGroup::INSERT
);
1543 implDescribeSupportedFeature( ".uno:DBNewFormAutoPilot", SID_DB_FORM_NEW_PILOT
, CommandGroup::INSERT
);
1544 implDescribeSupportedFeature( ".uno:DBNewFormAutoPilotWithPreSelection",
1545 SID_FORM_CREATE_REPWIZ_PRE_SEL
,
1546 CommandGroup::APPLICATION
);
1548 implDescribeSupportedFeature( ".uno:DBNewReport", SID_APP_NEW_REPORT
, CommandGroup::INSERT
);
1549 implDescribeSupportedFeature( ".uno:DBNewReportAutoPilot",
1550 ID_DOCUMENT_CREATE_REPWIZ
, CommandGroup::INSERT
);
1551 implDescribeSupportedFeature( ".uno:DBNewReportAutoPilotWithPreSelection",
1552 SID_REPORT_CREATE_REPWIZ_PRE_SEL
,
1553 CommandGroup::APPLICATION
);
1554 implDescribeSupportedFeature( ".uno:DBNewQuery", ID_NEW_QUERY_DESIGN
, CommandGroup::INSERT
);
1555 implDescribeSupportedFeature( ".uno:DBNewQuerySql", ID_NEW_QUERY_SQL
, CommandGroup::INSERT
);
1556 implDescribeSupportedFeature( ".uno:DBNewQueryAutoPilot",ID_APP_NEW_QUERY_AUTO_PILOT
,
1557 CommandGroup::INSERT
);
1558 implDescribeSupportedFeature( ".uno:DBNewTable", ID_NEW_TABLE_DESIGN
, CommandGroup::INSERT
);
1559 implDescribeSupportedFeature( ".uno:DBNewTableAutoPilot",ID_NEW_TABLE_DESIGN_AUTO_PILOT
,
1560 CommandGroup::INSERT
);
1561 implDescribeSupportedFeature( ".uno:DBNewView", ID_NEW_VIEW_DESIGN
, CommandGroup::INSERT
);
1562 implDescribeSupportedFeature( ".uno:DBNewViewSQL", SID_DB_NEW_VIEW_SQL
, CommandGroup::INSERT
);
1564 implDescribeSupportedFeature( ".uno:DBDelete", SID_DB_APP_DELETE
, CommandGroup::EDIT
);
1565 implDescribeSupportedFeature( ".uno:Delete", SID_DB_APP_DELETE
, CommandGroup::EDIT
);
1566 implDescribeSupportedFeature( ".uno:DBRename", SID_DB_APP_RENAME
, CommandGroup::EDIT
);
1567 implDescribeSupportedFeature( ".uno:DBEdit", SID_DB_APP_EDIT
, CommandGroup::EDIT
);
1568 implDescribeSupportedFeature( ".uno:DBEditSqlView", SID_DB_APP_EDIT_SQL_VIEW
, CommandGroup::EDIT
);
1569 implDescribeSupportedFeature( ".uno:DBOpen", SID_DB_APP_OPEN
, CommandGroup::EDIT
);
1571 implDescribeSupportedFeature( ".uno:DBTableDelete", SID_DB_APP_TABLE_DELETE
, CommandGroup::EDIT
);
1572 implDescribeSupportedFeature( ".uno:DBTableRename", SID_DB_APP_TABLE_RENAME
, CommandGroup::EDIT
);
1573 implDescribeSupportedFeature( ".uno:DBTableEdit", SID_DB_APP_TABLE_EDIT
, CommandGroup::EDIT
);
1574 implDescribeSupportedFeature( ".uno:DBTableOpen", SID_DB_APP_TABLE_OPEN
, CommandGroup::EDIT
);
1576 implDescribeSupportedFeature( ".uno:DBQueryDelete", SID_DB_APP_QUERY_DELETE
, CommandGroup::EDIT
);
1577 implDescribeSupportedFeature( ".uno:DBQueryRename", SID_DB_APP_QUERY_RENAME
, CommandGroup::EDIT
);
1578 implDescribeSupportedFeature( ".uno:DBQueryEdit", SID_DB_APP_QUERY_EDIT
, CommandGroup::EDIT
);
1579 implDescribeSupportedFeature( ".uno:DBQueryOpen", SID_DB_APP_QUERY_OPEN
, CommandGroup::EDIT
);
1581 implDescribeSupportedFeature( ".uno:DBFormDelete", SID_DB_APP_FORM_DELETE
, CommandGroup::EDIT
);
1582 implDescribeSupportedFeature( ".uno:DBFormRename", SID_DB_APP_FORM_RENAME
, CommandGroup::EDIT
);
1583 implDescribeSupportedFeature( ".uno:DBFormEdit", SID_DB_APP_FORM_EDIT
, CommandGroup::EDIT
);
1584 implDescribeSupportedFeature( ".uno:DBFormOpen", SID_DB_APP_FORM_OPEN
, CommandGroup::EDIT
);
1586 implDescribeSupportedFeature( ".uno:DBReportDelete", SID_DB_APP_REPORT_DELETE
, CommandGroup::EDIT
);
1587 implDescribeSupportedFeature( ".uno:DBReportRename", SID_DB_APP_REPORT_RENAME
, CommandGroup::EDIT
);
1588 implDescribeSupportedFeature( ".uno:DBReportEdit", SID_DB_APP_REPORT_EDIT
, CommandGroup::EDIT
);
1589 implDescribeSupportedFeature( ".uno:DBReportOpen", SID_DB_APP_REPORT_OPEN
, CommandGroup::EDIT
);
1591 implDescribeSupportedFeature( ".uno:SelectAll", SID_SELECTALL
, CommandGroup::EDIT
);
1592 implDescribeSupportedFeature( ".uno:Undo", ID_BROWSER_UNDO
, CommandGroup::EDIT
);
1594 implDescribeSupportedFeature( ".uno:Sortup", ID_BROWSER_SORTUP
, CommandGroup::VIEW
);
1595 implDescribeSupportedFeature( ".uno:SortDown", ID_BROWSER_SORTDOWN
, CommandGroup::VIEW
);
1596 implDescribeSupportedFeature( ".uno:DBRelationDesign", SID_DB_APP_DSRELDESIGN
, CommandGroup::APPLICATION
);
1597 implDescribeSupportedFeature( ".uno:DBUserAdmin", SID_DB_APP_DSUSERADMIN
, CommandGroup::APPLICATION
);
1598 implDescribeSupportedFeature( ".uno:DBTableFilter", SID_DB_APP_TABLEFILTER
, CommandGroup::APPLICATION
);
1599 implDescribeSupportedFeature( ".uno:DBDSProperties", SID_DB_APP_DSPROPS
, CommandGroup::EDIT
);
1600 implDescribeSupportedFeature( ".uno:DBDSConnectionType", SID_DB_APP_DSCONNECTION_TYPE
,
1601 CommandGroup::EDIT
);
1602 implDescribeSupportedFeature( ".uno:DBDSAdvancedSettings",
1603 SID_DB_APP_DSADVANCED_SETTINGS
,
1604 CommandGroup::EDIT
);
1605 implDescribeSupportedFeature( ".uno:PasteSpecial", SID_DB_APP_PASTE_SPECIAL
, CommandGroup::EDIT
);
1606 implDescribeSupportedFeature( ".uno:DBConvertToView", SID_DB_APP_CONVERTTOVIEW
, CommandGroup::EDIT
);
1607 implDescribeSupportedFeature( ".uno:DBRefreshTables", SID_DB_APP_REFRESH_TABLES
, CommandGroup::APPLICATION
);
1608 implDescribeSupportedFeature( ".uno:DBDirectSQL", ID_DIRECT_SQL
, CommandGroup::APPLICATION
);
1609 implDescribeSupportedFeature( ".uno:DBMigrateScripts", ID_MIGRATE_SCRIPTS
, CommandGroup::APPLICATION
);
1610 implDescribeSupportedFeature( ".uno:DBViewTables", SID_DB_APP_VIEW_TABLES
, CommandGroup::VIEW
);
1611 implDescribeSupportedFeature( ".uno:DBViewQueries", SID_DB_APP_VIEW_QUERIES
, CommandGroup::VIEW
);
1612 implDescribeSupportedFeature( ".uno:DBViewForms", SID_DB_APP_VIEW_FORMS
, CommandGroup::VIEW
);
1613 implDescribeSupportedFeature( ".uno:DBViewReports", SID_DB_APP_VIEW_REPORTS
, CommandGroup::VIEW
);
1614 implDescribeSupportedFeature( ".uno:DBDisablePreview", SID_DB_APP_DISABLE_PREVIEW
,CommandGroup::VIEW
);
1615 implDescribeSupportedFeature( ".uno:DBShowDocInfoPreview",
1616 SID_DB_APP_VIEW_DOCINFO_PREVIEW
,
1617 CommandGroup::VIEW
);
1618 implDescribeSupportedFeature( ".uno:DBShowDocPreview", SID_DB_APP_VIEW_DOC_PREVIEW
,
1619 CommandGroup::VIEW
);
1621 implDescribeSupportedFeature( ".uno:OpenUrl", SID_OPENURL
, CommandGroup::APPLICATION
);
1623 // this one should not appear under Tools->Customize->Keyboard
1624 implDescribeSupportedFeature( ".uno:DBNewReportWithPreSelection",
1625 SID_APP_NEW_REPORT_PRE_SEL
,CommandGroup::INTERNAL
);
1626 implDescribeSupportedFeature( ".uno:DBDSImport", SID_DB_APP_DSIMPORT
, CommandGroup::INTERNAL
);
1627 implDescribeSupportedFeature( ".uno:DBDSExport", SID_DB_APP_DSEXPORT
, CommandGroup::INTERNAL
);
1628 implDescribeSupportedFeature( ".uno:DBDBAdmin", SID_DB_APP_DBADMIN
, CommandGroup::INTERNAL
);
1631 implDescribeSupportedFeature( ".uno:DBStatusType", SID_DB_APP_STATUS_TYPE
, CommandGroup::INTERNAL
);
1632 implDescribeSupportedFeature( ".uno:DBStatusDBName", SID_DB_APP_STATUS_DBNAME
, CommandGroup::INTERNAL
);
1633 implDescribeSupportedFeature( ".uno:DBStatusUserName", SID_DB_APP_STATUS_USERNAME
, CommandGroup::INTERNAL
);
1634 implDescribeSupportedFeature( ".uno:DBStatusHostName", SID_DB_APP_STATUS_HOSTNAME
, CommandGroup::INTERNAL
);
1636 // -----------------------------------------------------------------------------
1637 OApplicationView
* OApplicationController::getContainer() const
1639 return static_cast< OApplicationView
* >( getView() );
1642 // -----------------------------------------------------------------------------
1643 // ::com::sun::star::container::XContainerListener
1644 void SAL_CALL
OApplicationController::elementInserted( const ContainerEvent
& _rEvent
) throw(RuntimeException
)
1646 ::vos::OGuard
aSolarGuard(Application::GetSolarMutex());
1647 ::osl::MutexGuard
aGuard( getMutex() );
1649 Reference
< XContainer
> xContainer(_rEvent
.Source
, UNO_QUERY
);
1650 if ( ::std::find(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),xContainer
) != m_aCurrentContainers
.end() )
1652 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1653 if ( getContainer() )
1655 ::rtl::OUString sName
;
1656 _rEvent
.Accessor
>>= sName
;
1657 ElementType eType
= getElementType(xContainer
);
1667 Reference
< XContainer
> xSubContainer(_rEvent
.Element
,UNO_QUERY
);
1668 if ( xSubContainer
.is() )
1669 containerFound(xSubContainer
);
1675 getContainer()->elementAdded(eType
,sName
,_rEvent
.Element
);
1679 // -----------------------------------------------------------------------------
1680 void SAL_CALL
OApplicationController::elementRemoved( const ContainerEvent
& _rEvent
) throw(RuntimeException
)
1682 ::vos::OGuard
aSolarGuard(Application::GetSolarMutex());
1683 ::osl::MutexGuard
aGuard( getMutex() );
1685 Reference
< XContainer
> xContainer(_rEvent
.Source
, UNO_QUERY
);
1686 if ( ::std::find(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),xContainer
) != m_aCurrentContainers
.end() )
1688 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1689 ::rtl::OUString sName
;
1690 _rEvent
.Accessor
>>= sName
;
1691 ElementType eType
= getElementType(xContainer
);
1700 Reference
<XContent
> xContent(xContainer
,UNO_QUERY
);
1701 if ( xContent
.is() )
1703 sName
= xContent
->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName
;
1710 getContainer()->elementRemoved(eType
,sName
);
1713 // -----------------------------------------------------------------------------
1714 void SAL_CALL
OApplicationController::elementReplaced( const ContainerEvent
& _rEvent
) throw(RuntimeException
)
1716 ::vos::OGuard
aSolarGuard(Application::GetSolarMutex());
1717 ::osl::MutexGuard
aGuard( getMutex() );
1719 Reference
< XContainer
> xContainer(_rEvent
.Source
, UNO_QUERY
);
1720 if ( ::std::find(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),xContainer
) != m_aCurrentContainers
.end() )
1722 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1723 ::rtl::OUString sName
;
1726 _rEvent
.Accessor
>>= sName
;
1727 Reference
<XConnection
> xConnection
;
1728 Reference
<XPropertySet
> xProp(_rEvent
.Element
,UNO_QUERY
);
1729 ::rtl::OUString sNewName
;
1731 ElementType eType
= getElementType(xContainer
);
1737 if ( xProp
.is() && m_xMetaData
.is() )
1738 sNewName
= ::dbaui::composeTableName( m_xMetaData
, xProp
, ::dbtools::eInDataManipulation
, false, false, false );
1744 Reference
<XContent
> xContent(xContainer
,UNO_QUERY
);
1745 if ( xContent
.is() )
1747 sName
= xContent
->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName
;
1754 // getContainer()->elementReplaced(getContainer()->getElementType(),sName,sNewName);
1758 DBG_UNHANDLED_EXCEPTION();
1764 ::rtl::OUString
lcl_getToolBarResource(ElementType _eType
)
1766 ::rtl::OUString sToolbar
;
1770 sToolbar
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/tableobjectbar" ));
1773 sToolbar
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/queryobjectbar" ));
1776 sToolbar
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/formobjectbar" ));
1779 sToolbar
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/reportobjectbar" ));
1784 OSL_ENSURE(0,"Invalid ElementType!");
1790 // -----------------------------------------------------------------------------
1791 sal_Bool
OApplicationController::onContainerSelect(ElementType _eType
)
1793 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1795 if ( m_eCurrentType
!= _eType
&& _eType
!= E_NONE
)
1797 SelectionGuard
aSelGuard( *m_pSelectionNotifier
);
1799 if ( _eType
== E_TABLE
)
1803 SharedConnection
xConnection( ensureConnection() );
1804 if ( xConnection
.is() && getContainer()->getDetailView() )
1806 getContainer()->getDetailView()->createTablesPage(xConnection
);
1807 Reference
<XTablesSupplier
> xTabSup(xConnection
,UNO_QUERY
);
1809 addContainerListener(xTabSup
->getTables());
1816 catch( const Exception
& )
1821 Reference
< XLayoutManager
> xLayoutManager
= getLayoutManager( getFrame() );
1822 if ( xLayoutManager
.is() )
1824 ::rtl::OUString sToolbar
= lcl_getToolBarResource(_eType
);
1825 ::rtl::OUString sDestroyToolbar
= lcl_getToolBarResource(m_eCurrentType
);
1827 xLayoutManager
->lock();
1828 xLayoutManager
->destroyElement( sDestroyToolbar
);
1829 if ( sToolbar
.getLength() )
1831 xLayoutManager
->createElement( sToolbar
);
1832 xLayoutManager
->requestElement( sToolbar
);
1834 xLayoutManager
->unlock();
1835 xLayoutManager
->doLayout();
1838 if ( _eType
!= E_TABLE
&& getContainer()->getDetailView() )
1840 Reference
< XNameAccess
> xContainer
= getElements(_eType
);
1841 addContainerListener(xContainer
);
1842 getContainer()->getDetailView()->createPage(_eType
,xContainer
);
1845 SelectionByElementType::iterator pendingSelection
= m_aPendingSelection
.find( _eType
);
1846 if ( pendingSelection
!= m_aPendingSelection
.end() )
1848 Sequence
< ::rtl::OUString
> aSelected( pendingSelection
->second
.size() );
1849 ::std::copy( pendingSelection
->second
.begin(), pendingSelection
->second
.end(), aSelected
.getArray() );
1850 getContainer()->selectElements( aSelected
);
1852 m_aPendingSelection
.erase( pendingSelection
);
1857 m_eCurrentType
= _eType
;
1861 // -----------------------------------------------------------------------------
1862 bool OApplicationController::onEntryDoubleClick( SvTreeListBox
& _rTree
)
1864 if ( getContainer() && getContainer()->isLeaf( _rTree
.GetHdlEntry() ) )
1869 getContainer()->getQualifiedName( _rTree
.GetHdlEntry() ),
1870 getContainer()->getElementType(),
1873 return true; // handled
1875 catch(const Exception
&)
1877 OSL_ENSURE(0,"Could not open element!");
1880 return false; // not handled
1882 // -----------------------------------------------------------------------------
1883 bool OApplicationController::impl_isAlterableView_nothrow( const ::rtl::OUString
& _rTableOrViewName
) const
1885 OSL_PRECOND( m_xDataSourceConnection
.is(), "OApplicationController::impl_isAlterableView_nothrow: no connection!" );
1887 bool bIsAlterableView( false );
1890 Reference
< XViewsSupplier
> xViewsSupp( m_xDataSourceConnection
, UNO_QUERY
);
1891 Reference
< XNameAccess
> xViews
;
1892 if ( xViewsSupp
.is() )
1893 xViews
= xViewsSupp
->getViews();
1895 Reference
< XAlterView
> xAsAlterableView
;
1896 if ( xViews
.is() && xViews
->hasByName( _rTableOrViewName
) )
1897 xAsAlterableView
.set( xViews
->getByName( _rTableOrViewName
), UNO_QUERY
);
1899 bIsAlterableView
= xAsAlterableView
.is();
1901 catch( const Exception
& )
1903 DBG_UNHANDLED_EXCEPTION();
1905 return bIsAlterableView
;
1908 // -----------------------------------------------------------------------------
1909 Reference
< XComponent
> OApplicationController::openElement(const ::rtl::OUString
& _sName
, ElementType _eType
,
1910 ElementOpenMode _eOpenMode
, sal_uInt16 _nInstigatorCommand
)
1912 return openElementWithArguments( _sName
, _eType
, _eOpenMode
, _nInstigatorCommand
, ::comphelper::NamedValueCollection() );
1915 // -----------------------------------------------------------------------------
1916 Reference
< XComponent
> OApplicationController::openElementWithArguments( const ::rtl::OUString
& _sName
, ElementType _eType
,
1917 ElementOpenMode _eOpenMode
, sal_uInt16 _nInstigatorCommand
, const ::comphelper::NamedValueCollection
& _rAdditionalArguments
)
1919 OSL_PRECOND( getContainer(), "OApplicationController::openElementWithArguments: no view!" );
1920 if ( !getContainer() )
1923 Reference
< XComponent
> xRet
;
1924 if ( _eOpenMode
== E_OPEN_DESIGN
)
1926 // OJ: http://www.openoffice.org/issues/show_bug.cgi?id=30382
1927 getContainer()->showPreview(NULL
);
1935 ::std::auto_ptr
< OLinkedDocumentsAccess
> aHelper
= getDocumentsAccess( _eType
);
1936 if ( !aHelper
->isConnected() )
1939 Reference
< XComponent
> xDefinition
;
1940 xRet
= aHelper
->open( _sName
, xDefinition
, _eOpenMode
, _rAdditionalArguments
);
1942 onDocumentOpened( _sName
, _eType
, _eOpenMode
, xRet
, xDefinition
);
1949 if ( !m_pSubComponentManager
->activateSubFrame( _sName
, _eType
, _eOpenMode
) )
1951 SharedConnection
xConnection( ensureConnection() );
1952 if ( !xConnection
.is() )
1955 ::std::auto_ptr
< DatabaseObjectView
> pDesigner
;
1956 ::comphelper::NamedValueCollection
aArguments( _rAdditionalArguments
);
1959 if ( _eOpenMode
== E_OPEN_DESIGN
)
1961 sal_Bool bQuerySQLMode
=( _nInstigatorCommand
== SID_DB_APP_EDIT_SQL_VIEW
);
1963 if ( _eType
== E_TABLE
)
1965 if ( impl_isAlterableView_nothrow( _sName
) )
1966 pDesigner
.reset( new QueryDesigner( getORB(), this, m_aCurrentFrame
.getFrame(), true, bQuerySQLMode
) );
1968 pDesigner
.reset( new TableDesigner( getORB(), this, m_aCurrentFrame
.getFrame() ) );
1970 else if ( _eType
== E_QUERY
)
1972 pDesigner
.reset( new QueryDesigner( getORB(), this, m_aCurrentFrame
.getFrame(), false, bQuerySQLMode
) );
1974 aDataSource
<<= m_xDataSource
;
1978 pDesigner
.reset( new ResultSetBrowser( getORB(), this, m_aCurrentFrame
.getFrame(), _eType
== E_TABLE
) );
1980 if ( !aArguments
.has( (::rtl::OUString
)PROPERTY_SHOWMENU
) )
1981 aArguments
.put( (::rtl::OUString
)PROPERTY_SHOWMENU
, makeAny( (sal_Bool
)sal_True
) );
1983 aDataSource
<<= getDatabaseName();
1986 xRet
.set( pDesigner
->openExisting( aDataSource
, _sName
, aArguments
.getPropertyValues() ) );
1987 onDocumentOpened( _sName
, _eType
, _eOpenMode
, xRet
, NULL
);
1993 OSL_ENSURE( false, "OApplicationController::openElement: illegal object type!" );
1998 // -----------------------------------------------------------------------------
1999 IMPL_LINK( OApplicationController
, OnSelectContainer
, void*, _pType
)
2001 ElementType eType
= (ElementType
)reinterpret_cast< sal_IntPtr
>( _pType
);
2002 getContainer()->selectContainer(eType
);
2005 // -----------------------------------------------------------------------------
2006 IMPL_LINK( OApplicationController
, OnCreateWithPilot
, void*, _pType
)
2008 ElementType eType
= (ElementType
)reinterpret_cast< sal_IntPtr
>( _pType
);
2009 newElementWithPilot( eType
);
2013 // -----------------------------------------------------------------------------
2014 void OApplicationController::newElementWithPilot( ElementType _eType
)
2016 OSL_ENSURE( getContainer(), "OApplicationController::newElementWithPilot: without a view?" );
2023 ::std::auto_ptr
<OLinkedDocumentsAccess
> aHelper
= getDocumentsAccess(_eType
);
2024 if ( aHelper
->isConnected() )
2026 sal_Int32 nCommandType
= -1;
2027 const ::rtl::OUString
sName(getCurrentlySelectedName(nCommandType
));
2028 Reference
< XComponent
> xComponent
,xDefinition
;
2029 if ( E_REPORT
== _eType
)
2030 xComponent
= aHelper
->newReportWithPilot(xDefinition
,nCommandType
,sName
);
2032 xComponent
= aHelper
->newFormWithPilot(xDefinition
,nCommandType
,sName
);
2034 onDocumentOpened( ::rtl::OUString(), _eType
, E_OPEN_DESIGN
, xComponent
, xDefinition
);
2041 ::std::auto_ptr
<OLinkedDocumentsAccess
> aHelper
= getDocumentsAccess(_eType
);
2042 if ( aHelper
->isConnected() )
2044 Reference
< XComponent
> xComponent
;
2045 if ( E_QUERY
== _eType
)
2046 xComponent
= aHelper
->newQueryWithPilot();
2048 xComponent
= aHelper
->newTableWithPilot();
2050 onDocumentOpened( ::rtl::OUString(), _eType
, E_OPEN_DESIGN
, xComponent
, NULL
);
2059 // -----------------------------------------------------------------------------
2060 void OApplicationController::newElement( ElementType _eType
, sal_Bool _bSQLView
)
2062 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
2069 ::std::auto_ptr
<OLinkedDocumentsAccess
> aHelper
= getDocumentsAccess(_eType
);
2070 if ( aHelper
->isConnected() )
2072 Reference
< XComponent
> xComponent
,xDefinition
;
2073 sal_Int32 nCommandType
= -1;
2074 const ::rtl::OUString
sName(getCurrentlySelectedName(nCommandType
));
2075 xComponent
= aHelper
->newDocument(_eType
== E_FORM
? ID_FORM_NEW_TEXT
: ID_REPORT_NEW_TEXT
,xDefinition
,nCommandType
,sName
);
2076 onDocumentOpened( ::rtl::OUString(), _eType
, E_OPEN_DESIGN
, xComponent
, xDefinition
);
2083 ::std::auto_ptr
< DatabaseObjectView
> pDesigner
;
2084 SharedConnection
xConnection( ensureConnection() );
2085 if ( xConnection
.is() )
2087 if ( _eType
== E_TABLE
)
2089 pDesigner
.reset( new TableDesigner( getORB(), this, getFrame() ) );
2091 else if ( _eType
== E_QUERY
)
2093 pDesigner
.reset( new QueryDesigner( getORB(), this, getFrame(), false, _bSQLView
) );
2096 Reference
< XDataSource
> xDataSource( m_xDataSource
, UNO_QUERY
);
2097 Reference
< XComponent
> xComponent( pDesigner
->createNew( xDataSource
), UNO_QUERY
);
2098 onDocumentOpened( ::rtl::OUString(), _eType
, E_OPEN_DESIGN
, xComponent
, NULL
);
2106 // -----------------------------------------------------------------------------
2107 void OApplicationController::addContainerListener(const Reference
<XNameAccess
>& _xCollection
)
2111 Reference
< XContainer
> xCont(_xCollection
, UNO_QUERY
);
2114 // add as listener to get notified if elements are inserted or removed
2115 TContainerVector::iterator aFind
= ::std::find(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),xCont
);
2116 if ( aFind
== m_aCurrentContainers
.end() )
2118 xCont
->addContainerListener(this);
2119 m_aCurrentContainers
.push_back(xCont
);
2123 catch( const Exception
& )
2125 DBG_UNHANDLED_EXCEPTION();
2128 // -----------------------------------------------------------------------------
2129 void OApplicationController::renameEntry()
2131 ::vos::OGuard
aSolarGuard(Application::GetSolarMutex());
2132 ::osl::MutexGuard
aGuard( getMutex() );
2134 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
2135 ::std::vector
< ::rtl::OUString
> aList
;
2136 getSelectionElementNames(aList
);
2138 Reference
< XNameAccess
> xContainer
= getElements(getContainer()->getElementType());
2139 OSL_ENSURE(aList
.size() == 1,"Invalid rename call here. More than one element!");
2140 if ( aList
.empty() )
2145 if ( xContainer
.is() )
2147 ::std::auto_ptr
< IObjectNameCheck
> pNameChecker
;
2148 ::std::auto_ptr
< OSaveAsDlg
> aDialog
;
2150 Reference
<XRename
> xRename
;
2151 const ElementType eType
= getContainer()->getElementType();
2157 Reference
<XHierarchicalNameContainer
> xHNames(xContainer
, UNO_QUERY
);
2161 if ( eType
== E_FORM
)
2162 sLabel
= String(ModuleRes( STR_FRM_LABEL
));
2164 sLabel
= String(ModuleRes( STR_RPT_LABEL
));
2166 ::rtl::OUString sName
= *aList
.begin();
2167 if ( xHNames
->hasByHierarchicalName(sName
) )
2169 xRename
.set(xHNames
->getByHierarchicalName(sName
),UNO_QUERY
);
2170 Reference
<XChild
> xChild(xRename
,UNO_QUERY
);
2173 Reference
<XHierarchicalNameContainer
> xParent(xChild
->getParent(),UNO_QUERY
);
2177 Reference
<XPropertySet
>(xRename
,UNO_QUERY
)->getPropertyValue(PROPERTY_NAME
) >>= sName
;
2180 pNameChecker
.reset( new HierarchicalNameCheck( xHNames
.get(), String() ) );
2181 aDialog
.reset( new OSaveAsDlg(
2182 getView(), getORB(), sName
, sLabel
, *pNameChecker
, SAD_TITLE_RENAME
) );
2189 if ( !getConnection().is() )
2193 if ( xContainer
->hasByName(*aList
.begin()) )
2195 xRename
.set(xContainer
->getByName(*aList
.begin()),UNO_QUERY
);
2196 sal_Int32 nCommandType
= eType
== E_QUERY
? CommandType::QUERY
: CommandType::TABLE
;
2199 pNameChecker
.reset( new DynamicTableOrQueryNameCheck( getConnection(), nCommandType
) );
2200 aDialog
.reset( new OSaveAsDlg(
2201 getView(), nCommandType
, getORB(), getConnection(),
2202 *aList
.begin(), *pNameChecker
, SAD_TITLE_RENAME
) );
2209 if ( xRename
.is() && aDialog
.get() )
2212 sal_Bool bTryAgain
= sal_True
;
2215 if ( aDialog
->Execute() == RET_OK
)
2219 ::rtl::OUString sNewName
;
2220 if ( eType
== E_TABLE
)
2222 ::rtl::OUString sName
= aDialog
->getName();
2223 ::rtl::OUString sCatalog
= aDialog
->getCatalog();
2224 ::rtl::OUString sSchema
= aDialog
->getSchema();
2226 sNewName
= ::dbtools::composeTableName( m_xMetaData
, sCatalog
, sSchema
, sName
, sal_False
, ::dbtools::eInDataManipulation
);
2229 sNewName
= aDialog
->getName();
2231 ::rtl::OUString sOldName
= *aList
.begin();
2232 if ( eType
== E_FORM
|| eType
== E_REPORT
)
2234 Reference
<XContent
> xContent(xRename
,UNO_QUERY
);
2235 if ( xContent
.is() )
2237 sOldName
= xContent
->getIdentifier()->getContentIdentifier();
2241 xRename
->rename(sNewName
);
2243 if ( eType
== E_TABLE
)
2245 Reference
<XPropertySet
> xProp(xRename
,UNO_QUERY
);
2246 sNewName
= ::dbaui::composeTableName( m_xMetaData
, xProp
, ::dbtools::eInDataManipulation
, false, false, false );
2248 getContainer()->elementReplaced( eType
, sOldName
, sNewName
);
2250 bTryAgain
= sal_False
;
2252 catch(const SQLException
& )
2254 showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
2257 catch(const ElementExistException
& e
)
2259 static ::rtl::OUString sStatus
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000"));
2260 String sMsg
= String( ModuleRes( STR_NAME_ALREADY_EXISTS
) );
2261 sMsg
.SearchAndReplace('#',e
.Message
);
2262 showError(SQLExceptionInfo(SQLException(sMsg
, e
.Context
, sStatus
, 0, Any())));
2264 catch(const Exception
& )
2266 DBG_UNHANDLED_EXCEPTION();
2270 bTryAgain
= sal_False
;
2275 catch(const Exception
& )
2277 DBG_UNHANDLED_EXCEPTION();
2281 // -----------------------------------------------------------------------------
2282 void OApplicationController::onSelectionChanged()
2286 SelectionGuard
aSelGuard( *m_pSelectionNotifier
);
2288 OApplicationView
* pView
= getContainer();
2292 if ( pView
->getSelectionCount() == 1 )
2294 const ElementType eType
= pView
->getElementType();
2295 if ( pView
->isALeafSelected() )
2297 const ::rtl::OUString sName
= pView
->getQualifiedName( NULL
/* means 'first selected' */ );
2298 showPreviewFor( eType
, sName
);
2302 // -----------------------------------------------------------------------------
2303 void OApplicationController::showPreviewFor(const ElementType _eType
,const ::rtl::OUString
& _sName
)
2305 if ( m_ePreviewMode
== E_PREVIEWNONE
)
2308 OApplicationView
* pView
= getContainer();
2319 Reference
< XHierarchicalNameAccess
> xContainer( getElements( _eType
), UNO_QUERY_THROW
);
2320 Reference
< XContent
> xContent( xContainer
->getByHierarchicalName( _sName
), UNO_QUERY_THROW
);
2321 pView
->showPreview( xContent
);
2328 SharedConnection
xConnection( ensureConnection() );
2329 if ( xConnection
.is() )
2330 pView
->showPreview( getDatabaseName(), xConnection
, _sName
, _eType
== E_TABLE
);
2335 OSL_ENSURE( false, "OApplicationController::showPreviewFor: unexpected element type!" );
2339 catch( const SQLException
& )
2341 showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
2343 catch(const Exception
& )
2345 DBG_UNHANDLED_EXCEPTION();
2349 //------------------------------------------------------------------------------
2350 IMPL_LINK( OApplicationController
, OnClipboardChanged
, void*, EMPTYARG
)
2352 return OnInvalidateClipboard( NULL
);
2354 //------------------------------------------------------------------------------
2355 IMPL_LINK(OApplicationController
, OnInvalidateClipboard
, void*, EMPTYARG
)
2357 InvalidateFeature(ID_BROWSER_CUT
);
2358 InvalidateFeature(ID_BROWSER_COPY
);
2359 InvalidateFeature(ID_BROWSER_PASTE
);
2360 InvalidateFeature(SID_DB_APP_PASTE_SPECIAL
);
2363 // -----------------------------------------------------------------------------
2364 void OApplicationController::onCutEntry()
2367 // -----------------------------------------------------------------------------
2368 void OApplicationController::onCopyEntry()
2370 Execute(ID_BROWSER_COPY
,Sequence
<PropertyValue
>());
2372 // -----------------------------------------------------------------------------
2373 void OApplicationController::onPasteEntry()
2375 Execute(ID_BROWSER_PASTE
,Sequence
<PropertyValue
>());
2377 // -----------------------------------------------------------------------------
2378 void OApplicationController::onDeleteEntry()
2380 ElementType eType
= getContainer()->getElementType();
2385 nId
= SID_DB_APP_TABLE_DELETE
;
2388 nId
= SID_DB_APP_QUERY_DELETE
;
2391 nId
= SID_DB_APP_FORM_DELETE
;
2394 nId
= SID_DB_APP_REPORT_DELETE
;
2397 OSL_ENSURE(0,"Invalid ElementType!");
2400 executeChecked(nId
,Sequence
<PropertyValue
>());
2403 // -----------------------------------------------------------------------------
2404 void OApplicationController::executeUnChecked(const URL
& _rCommand
, const Sequence
< PropertyValue
>& aArgs
)
2406 OApplicationController_CBASE::executeUnChecked( _rCommand
, aArgs
);
2409 // -----------------------------------------------------------------------------
2410 void OApplicationController::executeChecked(const URL
& _rCommand
, const Sequence
< PropertyValue
>& aArgs
)
2412 OApplicationController_CBASE::executeChecked( _rCommand
, aArgs
);
2415 // -----------------------------------------------------------------------------
2416 void OApplicationController::executeUnChecked(sal_uInt16 _nCommandId
, const Sequence
< PropertyValue
>& aArgs
)
2418 OApplicationController_CBASE::executeUnChecked( _nCommandId
, aArgs
);
2421 // -----------------------------------------------------------------------------
2422 void OApplicationController::executeChecked(sal_uInt16 _nCommandId
, const Sequence
< PropertyValue
>& aArgs
)
2424 OApplicationController_CBASE::executeChecked( _nCommandId
, aArgs
);
2427 // -----------------------------------------------------------------------------
2428 sal_Bool
OApplicationController::isCommandEnabled(sal_uInt16 _nCommandId
) const
2430 return OApplicationController_CBASE::isCommandEnabled( _nCommandId
);
2433 // -----------------------------------------------------------------------------
2434 sal_Bool
OApplicationController::isCommandEnabled( const ::rtl::OUString
& _rCompleteCommandURL
) const
2436 return OApplicationController_CBASE::isCommandEnabled( _rCompleteCommandURL
);
2439 // -----------------------------------------------------------------------------
2440 sal_uInt16
OApplicationController::registerCommandURL( const ::rtl::OUString
& _rCompleteCommandURL
)
2442 return OApplicationController_CBASE::registerCommandURL( _rCompleteCommandURL
);
2445 // -----------------------------------------------------------------------------
2446 void OApplicationController::notifyHiContrastChanged()
2448 OApplicationController_CBASE::notifyHiContrastChanged();
2451 // -----------------------------------------------------------------------------
2452 Reference
< XController
> OApplicationController::getXController() throw( RuntimeException
)
2454 return OApplicationController_CBASE::getXController();
2457 // -----------------------------------------------------------------------------
2458 bool OApplicationController::interceptUserInput( const NotifyEvent
& _rEvent
)
2460 return OApplicationController_CBASE::interceptUserInput( _rEvent
);
2463 // -----------------------------------------------------------------------------
2464 PopupMenu
* OApplicationController::getContextMenu( Control
& /*_rControl*/ ) const
2466 return new PopupMenu( ModuleRes( RID_MENU_APP_EDIT
) );
2469 // -----------------------------------------------------------------------------
2470 IController
& OApplicationController::getCommandController()
2472 return *static_cast< IApplicationController
* >( this );
2475 // -----------------------------------------------------------------------------
2476 ::cppu::OInterfaceContainerHelper
* OApplicationController::getContextMenuInterceptors()
2478 return &m_aContextMenuInterceptors
;
2481 // -----------------------------------------------------------------------------
2482 Any
OApplicationController::getCurrentSelection( Control
& _rControl
) const
2484 Sequence
< NamedDatabaseObject
> aSelection
;
2485 getContainer()->describeCurrentSelectionForControl( _rControl
, aSelection
);
2486 return makeAny( aSelection
);
2489 // -----------------------------------------------------------------------------
2490 sal_Bool
OApplicationController::requestQuickHelp( const SvLBoxEntry
* /*_pEntry*/, String
& /*_rText*/ ) const
2495 // -----------------------------------------------------------------------------
2496 sal_Bool
OApplicationController::requestDrag( sal_Int8
/*_nAction*/, const Point
& /*_rPosPixel*/ )
2498 TransferableHelper
* pTransfer
= NULL
;
2499 if ( getContainer() && getContainer()->getSelectionCount() )
2503 pTransfer
= copyObject( );
2504 Reference
< XTransferable
> xEnsureDelete
= pTransfer
;
2506 if ( pTransfer
&& getContainer()->getDetailView() )
2508 ElementType eType
= getContainer()->getElementType();
2509 pTransfer
->StartDrag( getContainer()->getDetailView()->getTreeWindow(), ((eType
== E_FORM
|| eType
== E_REPORT
) ? DND_ACTION_COPYMOVE
: DND_ACTION_COPY
) );
2512 catch(const Exception
& )
2514 DBG_UNHANDLED_EXCEPTION();
2518 return NULL
!= pTransfer
;
2520 // -----------------------------------------------------------------------------
2521 sal_Int8
OApplicationController::queryDrop( const AcceptDropEvent
& _rEvt
, const DataFlavorExVector
& _rFlavors
)
2523 sal_Int8 nActionAskedFor
= _rEvt
.mnAction
;
2524 // check if we're a table or query container
2525 OApplicationView
* pView
= getContainer();
2526 if ( pView
&& !isDataSourceReadOnly() )
2528 ElementType eType
= pView
->getElementType();
2529 if ( eType
!= E_NONE
&& (eType
!= E_TABLE
|| !isConnectionReadOnly()) )
2531 // check for the concrete type
2532 if(::std::find_if(_rFlavors
.begin(),_rFlavors
.end(),TAppSupportedSotFunctor(eType
,sal_True
)) != _rFlavors
.end())
2533 return DND_ACTION_COPY
;
2534 if ( eType
== E_FORM
|| eType
== E_REPORT
)
2536 sal_Int8 nAction
= OComponentTransferable::canExtractComponentDescriptor(_rFlavors
,eType
== E_FORM
) ? DND_ACTION_COPY
: DND_ACTION_NONE
;
2537 if ( nAction
!= DND_ACTION_NONE
)
2539 SvLBoxEntry
* pHitEntry
= pView
->getEntry(_rEvt
.maPosPixel
);
2540 ::rtl::OUString sName
;
2543 sName
= pView
->getQualifiedName( pHitEntry
);
2544 if ( sName
.getLength() )
2546 Reference
< XHierarchicalNameAccess
> xContainer(getElements(pView
->getElementType()),UNO_QUERY
);
2547 if ( xContainer
.is() && xContainer
->hasByHierarchicalName(sName
) )
2549 Reference
< XHierarchicalNameAccess
> xHitObject(xContainer
->getByHierarchicalName(sName
),UNO_QUERY
);
2550 if ( xHitObject
.is() )
2551 nAction
= nActionAskedFor
& DND_ACTION_COPYMOVE
;
2554 nAction
= DND_ACTION_NONE
;
2558 nAction = nActionAskedFor & DND_ACTION_COPYMOVE;
2566 return DND_ACTION_NONE
;
2568 // -----------------------------------------------------------------------------
2569 sal_Int8
OApplicationController::executeDrop( const ExecuteDropEvent
& _rEvt
)
2571 OApplicationView
* pView
= getContainer();
2572 if ( !pView
|| pView
->getElementType() == E_NONE
)
2574 DBG_ERROR("OApplicationController::executeDrop: what the hell did queryDrop do?");
2575 // queryDrop shoud not have allowed us to reach this situation ....
2576 return DND_ACTION_NONE
;
2579 // a TransferableDataHelper for accessing the dropped data
2580 TransferableDataHelper
aDroppedData(_rEvt
.maDropEvent
.Transferable
);
2583 // reset the data of the previous async drop (if any)
2585 Application::RemoveUserEvent(m_nAsyncDrop
);
2589 m_aAsyncDrop
.aDroppedData
.clear();
2590 m_aAsyncDrop
.nType
= pView
->getElementType();
2591 m_aAsyncDrop
.nAction
= _rEvt
.mnAction
;
2592 m_aAsyncDrop
.bError
= sal_False
;
2593 m_aAsyncDrop
.bHtml
= sal_False
;
2594 m_aAsyncDrop
.aUrl
= ::rtl::OUString();
2597 // loop through the available formats and see what we can do ...
2598 // first we have to check if it is our own format, if not we have to copy the stream :-(
2599 if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(aDroppedData
.GetDataFlavorExVector()) )
2601 m_aAsyncDrop
.aDroppedData
= ODataAccessObjectTransferable::extractObjectDescriptor(aDroppedData
);
2603 // asyncron because we some dialogs and we aren't allowed to show them while in D&D
2604 m_nAsyncDrop
= Application::PostUserEvent(LINK(this, OApplicationController
, OnAsyncDrop
));
2605 return DND_ACTION_COPY
;
2607 else if ( OComponentTransferable::canExtractComponentDescriptor(aDroppedData
.GetDataFlavorExVector(),m_aAsyncDrop
.nType
== E_FORM
) )
2609 m_aAsyncDrop
.aDroppedData
= OComponentTransferable::extractComponentDescriptor(aDroppedData
);
2610 SvLBoxEntry
* pHitEntry
= pView
->getEntry(_rEvt
.maPosPixel
);
2612 m_aAsyncDrop
.aUrl
= pView
->getQualifiedName( pHitEntry
);
2614 sal_Int8 nAction
= _rEvt
.mnAction
;
2615 Reference
<XContent
> xContent
;
2616 m_aAsyncDrop
.aDroppedData
[daComponent
] >>= xContent
;
2617 if ( xContent
.is() )
2619 ::rtl::OUString sName
= xContent
->getIdentifier()->getContentIdentifier();
2620 sal_Int32 nIndex
= 0;
2621 sName
= sName
.copy(sName
.getToken(0,'/',nIndex
).getLength() + 1);
2622 if ( m_aAsyncDrop
.aUrl
.Len() >= sName
.getLength() && 0 == sName
.compareTo(m_aAsyncDrop
.aUrl
,sName
.getLength()) )
2624 m_aAsyncDrop
.aDroppedData
.clear();
2625 return DND_ACTION_NONE
;
2628 // check if move is allowed, if another object with the same name exists only copy is allowed
2629 Reference
< XHierarchicalNameAccess
> xContainer(getElements(m_aAsyncDrop
.nType
),UNO_QUERY
);
2630 Reference
<XNameAccess
> xNameAccess(xContainer
,UNO_QUERY
);
2632 if ( m_aAsyncDrop
.aUrl
.Len() && xContainer
.is() && xContainer
->hasByHierarchicalName(m_aAsyncDrop
.aUrl
) )
2633 xNameAccess
.set(xContainer
->getByHierarchicalName(m_aAsyncDrop
.aUrl
),UNO_QUERY
);
2635 if ( xNameAccess
.is() )
2637 Reference
<XPropertySet
> xProp(xContent
,UNO_QUERY
);
2640 xProp
->getPropertyValue(PROPERTY_NAME
) >>= sName
;
2641 if ( xNameAccess
.is() && xNameAccess
->hasByName(sName
) )
2642 nAction
&= ~DND_ACTION_MOVE
;
2645 nAction
&= ~DND_ACTION_MOVE
;
2648 if ( nAction
!= DND_ACTION_NONE
)
2650 m_aAsyncDrop
.nAction
= nAction
;
2651 // asyncron because we some dialogs and we aren't allowed to show them while in D&D
2652 m_nAsyncDrop
= Application::PostUserEvent(LINK(this, OApplicationController
, OnAsyncDrop
));
2655 m_aAsyncDrop
.aDroppedData
.clear();
2660 SharedConnection
xConnection( ensureConnection() );
2661 if ( xConnection
.is() && m_aTableCopyHelper
.copyTagTable( aDroppedData
, m_aAsyncDrop
, xConnection
) )
2663 // asyncron because we some dialogs and we aren't allowed to show them while in D&D
2664 m_nAsyncDrop
= Application::PostUserEvent(LINK(this, OApplicationController
, OnAsyncDrop
));
2665 return DND_ACTION_COPY
;
2669 return DND_ACTION_NONE
;
2671 // -----------------------------------------------------------------------------
2672 Reference
< XModel
> SAL_CALL
OApplicationController::getModel(void) throw( RuntimeException
)
2677 // -----------------------------------------------------------------------------
2678 void OApplicationController::onConnectedModel()
2680 sal_Int32
nConnectedControllers( 0 );
2683 Reference
< XModel2
> xModel( m_xModel
, UNO_QUERY_THROW
);
2684 Reference
< XEnumeration
> xEnumControllers( xModel
->getControllers(), UNO_SET_THROW
);
2685 while ( xEnumControllers
->hasMoreElements() )
2687 Reference
< XController
> xController( xEnumControllers
->nextElement(), UNO_QUERY_THROW
);
2688 ++nConnectedControllers
;
2691 catch( const Exception
& )
2693 DBG_UNHANDLED_EXCEPTION();
2696 if ( nConnectedControllers
> 1 )
2697 { // we are not the first connected controller, there were already others
2701 m_aControllerConnectedEvent
.Call();
2704 // -----------------------------------------------------------------------------
2705 IMPL_LINK( OApplicationController
, OnFirstControllerConnected
, void*, /**/ )
2707 // if we have forms or reports which contain macros/scripts, then show a warning
2708 // which suggests the user to migrate them to the database document
2710 Reference
< XEmbeddedScripts
> xDocumentScripts( m_xModel
, UNO_QUERY
);
2711 if ( xDocumentScripts
.is() )
2713 // no need to show this warning, obviously the document supports embedding scripts
2714 // into itself, so there are no "old-style" forms/reports which have macros/scripts
2721 // If the migration just happened, but was not successful, the document is reloaded.
2722 // In this case, we should not show the warning, again.
2723 ::comphelper::NamedValueCollection
aModelArgs( m_xModel
->getArgs() );
2724 if ( aModelArgs
.getOrDefault( "SuppressMigrationWarning", sal_False
) )
2727 // also, if the document is read-only, then no migration is possible, and the
2728 // respective menu entry is hidden. So, don't show the warning in this case, too.
2729 if ( Reference
< XStorable
>( m_xModel
, UNO_QUERY_THROW
)->isReadonly() )
2732 SQLWarning aWarning
;
2733 aWarning
.Message
= String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS
) );
2734 SQLException aDetail
;
2735 aDetail
.Message
= String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS_DETAIL
) );
2736 aWarning
.NextException
<<= aDetail
;
2738 ::comphelper::ComponentContext
aContext( getORB() );
2739 Sequence
< Any
> aArgs(1);
2740 aArgs
[0] <<= NamedValue( PROPERTY_SQLEXCEPTION
, makeAny( aWarning
) );
2741 Reference
< XExecutableDialog
> xDialog(
2742 aContext
.createComponentWithArguments( "com.sun.star.sdb.ErrorMessageDialog", aArgs
),
2746 catch( const Exception
& )
2748 DBG_UNHANDLED_EXCEPTION();
2754 // -----------------------------------------------------------------------------
2755 sal_Bool SAL_CALL
OApplicationController::attachModel(const Reference
< XModel
> & _rxModel
) throw( RuntimeException
)
2757 ::osl::MutexGuard
aGuard( getMutex() );
2758 Reference
< XOfficeDatabaseDocument
> xOfficeDoc( _rxModel
, UNO_QUERY
);
2759 if ( !xOfficeDoc
.is() && _rxModel
.is() )
2761 DBG_ERROR( "OApplicationController::attachModel: invalid model!" );
2765 DBG_ASSERT( !( m_xModel
.is() && ( m_xModel
!= _rxModel
) ),
2766 "OApplicationController::attachModel: missing implementation: setting a new model while we have another one!" );
2767 // at least: remove as property change listener from the old model/data source
2769 m_xModel
= _rxModel
;
2770 if ( _rxModel
.is() )
2772 m_xDocumentModify
.set( m_xModel
, UNO_QUERY_THROW
);
2773 m_aModelConnector
.connect( _rxModel
, this );
2778 m_xDocumentModify
.clear();
2779 m_aModelConnector
.clear();
2782 m_xDataSource
.set(xOfficeDoc
.is() ? xOfficeDoc
->getDataSource() : Reference
<XDataSource
>(),UNO_QUERY
);
2783 if ( m_xDataSource
.is() )
2787 m_xDataSource
->addPropertyChangeListener(PROPERTY_INFO
, this);
2788 m_xDataSource
->addPropertyChangeListener(PROPERTY_URL
, this);
2789 m_xDataSource
->addPropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED
, this);
2790 m_xDataSource
->addPropertyChangeListener(PROPERTY_LAYOUTINFORMATION
, this);
2791 m_xDataSource
->addPropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL
, this);
2792 m_xDataSource
->addPropertyChangeListener(PROPERTY_TABLEFILTER
, this);
2793 m_xDataSource
->addPropertyChangeListener(PROPERTY_TABLETYPEFILTER
, this);
2794 m_xDataSource
->addPropertyChangeListener(PROPERTY_USER
, this);
2795 // to get the 'modified' for the data source
2796 Reference
< XModifyBroadcaster
> xBroadcaster(m_xModel
, UNO_QUERY
);
2797 if ( xBroadcaster
.is() )
2798 xBroadcaster
->addModifyListener(static_cast<XModifyListener
*>(this));
2800 Sequence
<PropertyValue
> aFields
;
2801 m_xDataSource
->getPropertyValue(PROPERTY_LAYOUTINFORMATION
) >>= aFields
;
2802 PropertyValue
*pIter
= aFields
.getArray();
2803 PropertyValue
*pEnd
= pIter
+ aFields
.getLength();
2804 for (; pIter
!= pEnd
&& pIter
->Name
!= INFO_PREVIEW
; ++pIter
)
2807 if ( pIter
!= pEnd
)
2809 sal_Int32 nValue
= 0;
2810 pIter
->Value
>>= nValue
;
2811 m_ePreviewMode
= static_cast<PreviewMode
>(nValue
);
2814 getContainer()->switchPreview(m_ePreviewMode
);
2818 catch( const Exception
& )
2820 DBG_UNHANDLED_EXCEPTION();
2826 // -----------------------------------------------------------------------------
2827 void OApplicationController::containerFound( const Reference
< XContainer
>& _xContainer
)
2831 if ( _xContainer
.is() )
2833 m_aCurrentContainers
.push_back(_xContainer
);
2834 _xContainer
->addContainerListener(this);
2839 OSL_ENSURE(0,"Could not listener on the container!");
2842 // -----------------------------------------------------------------------------
2843 ::rtl::OUString
OApplicationController::getCurrentlySelectedName(sal_Int32
& _rnCommandType
) const
2845 _rnCommandType
= ( (getContainer()->getElementType() == E_QUERY
)
2846 ? CommandType::QUERY
: ( (getContainer()->getElementType() == E_TABLE
) ? CommandType::TABLE
: -1 ));
2849 ::rtl::OUString sName
;
2850 if ( _rnCommandType
!= -1 )
2854 sName
= getContainer()->getQualifiedName( NULL
);
2855 OSL_ENSURE( sName
.getLength(), "OApplicationController::newElementWithPilot: no name given!" );
2857 catch( const Exception
& )
2859 DBG_UNHANDLED_EXCEPTION();
2865 // -----------------------------------------------------------------------------
2866 void SAL_CALL
OApplicationController::addSelectionChangeListener( const Reference
< view::XSelectionChangeListener
>& _Listener
) throw (RuntimeException
)
2868 m_pSelectionNotifier
->addListener( _Listener
);
2871 // -----------------------------------------------------------------------------
2872 void SAL_CALL
OApplicationController::removeSelectionChangeListener( const Reference
< view::XSelectionChangeListener
>& _Listener
) throw (RuntimeException
)
2874 m_pSelectionNotifier
->removeListener( _Listener
);
2877 // -----------------------------------------------------------------------------
2878 ::sal_Bool SAL_CALL
OApplicationController::select( const Any
& _aSelection
) throw (IllegalArgumentException
, RuntimeException
)
2880 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
2881 ::osl::MutexGuard
aGuard( getMutex() );
2882 Sequence
< ::rtl::OUString
> aSelection
;
2883 if ( !_aSelection
.hasValue() || !getView() )
2885 getContainer()->selectElements(aSelection
);
2889 // --------------------------------------------------------------
2890 // BEGIN compatibility
2891 Sequence
< NamedValue
> aCurrentSelection
;
2892 if ( (_aSelection
>>= aCurrentSelection
) && aCurrentSelection
.getLength() )
2894 ElementType eType
= E_NONE
;
2895 const NamedValue
* pIter
= aCurrentSelection
.getConstArray();
2896 const NamedValue
* pEnd
= pIter
+ aCurrentSelection
.getLength();
2897 for(;pIter
!= pEnd
;++pIter
)
2899 if ( pIter
->Name
.equalsAscii("Type") )
2901 sal_Int32 nType
= 0;
2902 pIter
->Value
>>= nType
;
2903 if ( nType
< DatabaseObject::TABLE
|| nType
> DatabaseObject::REPORT
)
2904 throw IllegalArgumentException();
2905 eType
= static_cast< ElementType
>( nType
);
2907 else if ( pIter
->Name
.equalsAscii("Selection") )
2908 pIter
->Value
>>= aSelection
;
2911 m_aSelectContainerEvent
.CancelCall(); // just in case the async select request was running
2912 getContainer()->selectContainer(eType
);
2913 getContainer()->selectElements(aSelection
);
2916 // END compatibility
2917 // --------------------------------------------------------------
2919 Sequence
< NamedDatabaseObject
> aSelectedObjects
;
2920 if ( !( _aSelection
>>= aSelectedObjects
) )
2922 aSelectedObjects
.realloc( 1 );
2923 if ( !( _aSelection
>>= aSelectedObjects
[0] ) )
2924 throw IllegalArgumentException();
2927 SelectionByElementType aSelectedElements
;
2928 ElementType eSelectedCategory
= E_NONE
;
2929 for ( const NamedDatabaseObject
* pObject
= aSelectedObjects
.getConstArray();
2930 pObject
!= aSelectedObjects
.getConstArray() + aSelectedObjects
.getLength();
2934 switch ( pObject
->Type
)
2936 case DatabaseObject::TABLE
:
2937 case DatabaseObjectContainer::SCHEMA
:
2938 case DatabaseObjectContainer::CATALOG
:
2939 aSelectedElements
[ E_TABLE
].push_back( pObject
->Name
);
2941 case DatabaseObject::QUERY
:
2942 aSelectedElements
[ E_QUERY
].push_back( pObject
->Name
);
2944 case DatabaseObject::FORM
:
2945 case DatabaseObjectContainer::FORMS_FOLDER
:
2946 aSelectedElements
[ E_FORM
].push_back( pObject
->Name
);
2948 case DatabaseObject::REPORT
:
2949 case DatabaseObjectContainer::REPORTS_FOLDER
:
2950 aSelectedElements
[ E_REPORT
].push_back( pObject
->Name
);
2952 case DatabaseObjectContainer::TABLES
:
2953 case DatabaseObjectContainer::QUERIES
:
2954 case DatabaseObjectContainer::FORMS
:
2955 case DatabaseObjectContainer::REPORTS
:
2956 if ( eSelectedCategory
!= E_NONE
)
2957 throw IllegalArgumentException(
2958 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "You cannot select different categories." ) ),
2960 *this, sal_Int16( pObject
- aSelectedObjects
.getConstArray() ) );
2962 ( pObject
->Type
== DatabaseObjectContainer::TABLES
) ? E_TABLE
2963 : ( pObject
->Type
== DatabaseObjectContainer::QUERIES
) ? E_QUERY
2964 : ( pObject
->Type
== DatabaseObjectContainer::FORMS
) ? E_FORM
2965 : ( pObject
->Type
== DatabaseObjectContainer::REPORTS
) ? E_REPORT
2970 case DatabaseObjectContainer::DATA_SOURCE
:
2972 ::rtl::OUStringBuffer aMessage
;
2973 aMessage
.appendAscii( "Unsupported object type found (" );
2974 aMessage
.append ( sal_Int32( pObject
->Type
) );
2975 aMessage
.appendAscii( ")." );
2977 throw IllegalArgumentException(
2978 aMessage
.makeStringAndClear(), *this, sal_Int16( pObject
- aSelectedObjects
.getConstArray() ) );
2983 for ( SelectionByElementType::const_iterator sel
= aSelectedElements
.begin();
2984 sel
!= aSelectedElements
.end();
2988 if ( sel
->first
== m_eCurrentType
)
2990 Sequence
< ::rtl::OUString
> aSelected( sel
->second
.size() );
2991 ::std::copy( sel
->second
.begin(), sel
->second
.end(), aSelected
.getArray() );
2992 getContainer()->selectElements( aSelected
);
2996 m_aPendingSelection
[ sel
->first
] = sel
->second
;
3000 m_aSelectContainerEvent
.CancelCall(); // just in case the async select request was running
3001 getContainer()->selectContainer( eSelectedCategory
);
3005 // -----------------------------------------------------------------------------
3006 Any SAL_CALL
OApplicationController::getSelection( ) throw (RuntimeException
)
3008 ::vos::OGuard
aSolarGuard( Application::GetSolarMutex() );
3009 ::osl::MutexGuard
aGuard( getMutex() );
3011 Sequence
< NamedDatabaseObject
> aCurrentSelection
;
3012 const ElementType
eType( getContainer()->getElementType() );
3013 if ( eType
!= E_NONE
)
3015 getContainer()->describeCurrentSelectionForType( eType
, aCurrentSelection
);
3016 if ( aCurrentSelection
.getLength() == 0 )
3017 { // if no objects are selected, add an entry to the sequence which describes the overall category
3018 // which is selected currently
3019 aCurrentSelection
.realloc(1);
3020 aCurrentSelection
[0].Name
= getDatabaseName();
3023 case E_TABLE
: aCurrentSelection
[0].Type
= DatabaseObjectContainer::TABLES
; break;
3024 case E_QUERY
: aCurrentSelection
[0].Type
= DatabaseObjectContainer::QUERIES
; break;
3025 case E_FORM
: aCurrentSelection
[0].Type
= DatabaseObjectContainer::FORMS
; break;
3026 case E_REPORT
: aCurrentSelection
[0].Type
= DatabaseObjectContainer::REPORTS
; break;
3028 OSL_ENSURE( false, "OApplicationController::getSelection: unexpected current element type!" );
3033 return makeAny( aCurrentSelection
);
3035 // -----------------------------------------------------------------------------
3036 void OApplicationController::impl_migrateScripts_nothrow()
3040 ::rtl::OUString
sDialogService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.application.MacroMigrationWizard" ) );
3041 ::comphelper::ComponentContext
aContext( getORB() );
3042 Sequence
< Any
> aDialogArgs(1);
3043 aDialogArgs
[0] <<= Reference
< XOfficeDatabaseDocument
>( m_xModel
, UNO_QUERY_THROW
);
3044 Reference
< XExecutableDialog
> xDialog(
3045 aContext
.createComponentWithArguments( sDialogService
, aDialogArgs
),
3048 if ( !xDialog
.is() )
3050 ShowServiceNotAvailableError( getView(), sDialogService
, true );
3056 catch( const Exception
& )
3058 DBG_UNHANDLED_EXCEPTION();
3062 //........................................................................
3063 } // namespace dbaui
3064 //........................................................................