1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "AppController.hxx"
31 #include "dbustrings.hrc"
32 #include "advancedsettingsdlg.hxx"
33 #include "subcomponentmanager.hxx"
35 /** === begin UNO includes === **/
36 #include <com/sun/star/beans/NamedValue.hpp>
37 #include <com/sun/star/container/XChild.hpp>
38 #include <com/sun/star/container/XContainer.hpp>
39 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
40 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
41 #include <com/sun/star/container/XHierarchicalNameContainer.hpp>
42 #include <com/sun/star/container/XNameContainer.hpp>
43 #include <com/sun/star/frame/FrameSearchFlag.hpp>
44 #include <com/sun/star/frame/XStorable.hpp>
45 #include <com/sun/star/sdb/CommandType.hpp>
46 #include <com/sun/star/sdb/SQLContext.hpp>
47 #include <com/sun/star/sdb/XBookmarksSupplier.hpp>
48 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
49 #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
50 #include <com/sun/star/sdbc/XDataSource.hpp>
51 #include <com/sun/star/sdbcx/XAlterView.hpp>
52 #include <com/sun/star/sdbcx/XAppend.hpp>
53 #include <com/sun/star/sdbcx/XRename.hpp>
54 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
55 #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
56 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
57 #include <com/sun/star/uno/XNamingService.hpp>
58 #include <com/sun/star/util/XFlushable.hpp>
59 #include <com/sun/star/util/XModifiable.hpp>
60 #include <com/sun/star/util/XModifyBroadcaster.hpp>
61 #include <com/sun/star/util/XNumberFormatter.hpp>
62 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
63 #include <com/sun/star/document/XEmbeddedScripts.hpp>
64 #include <com/sun/star/frame/XModel2.hpp>
65 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
66 #include "com/sun/star/beans/NamedValue.hpp"
67 #include <com/sun/star/awt/XTopWindow.hpp>
68 #include <com/sun/star/task/XInteractionHandler.hpp>
69 #include <com/sun/star/sdb/application/DatabaseObject.hpp>
70 #include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
71 #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
72 #include <com/sun/star/container/XHierarchicalName.hpp>
73 /** === end UNO includes === **/
74 #include <tools/diagnose_ex.h>
75 #include <osl/diagnose.h>
76 #include <tools/string.hxx>
78 #include <svl/urihelper.hxx>
79 #include <svl/filenotation.hxx>
80 #include <svtools/svtreebx.hxx>
81 #include <svtools/transfer.hxx>
82 #include <svtools/cliplistener.hxx>
83 #include <svtools/svlbitm.hxx>
84 #include <svtools/insdlg.hxx>
86 #include <comphelper/sequence.hxx>
87 #include <comphelper/uno3.hxx>
88 #include <comphelper/types.hxx>
89 #include <comphelper/interaction.hxx>
90 #include <comphelper/componentcontext.hxx>
92 #include <vcl/msgbox.hxx>
93 #include <vcl/stdtext.hxx>
94 #include <vcl/svapp.hxx>
95 #include <vcl/menu.hxx>
96 #include <vcl/lstbox.hxx>
98 #include <unotools/closeveto.hxx>
99 #include <unotools/pathoptions.hxx>
100 #include <unotools/tempfile.hxx>
101 #include <unotools/internaloptions.hxx>
102 #include <unotools/moduleoptions.hxx>
103 #include <unotools/historyoptions.hxx>
105 #include <sfx2/mailmodelapi.hxx>
106 #include <sfx2/filedlghelper.hxx>
107 #include <sfx2/docfilt.hxx>
108 #include <sfx2/QuerySaveDocument.hxx>
110 #include <cppuhelper/typeprovider.hxx>
111 #include <cppuhelper/exc_hlp.hxx>
113 #include <connectivity/dbtools.hxx>
114 #include <connectivity/dbexception.hxx>
116 #include <svx/dbaexchange.hxx>
117 #include <svx/dbaobjectex.hxx>
118 #include <svx/svxdlg.hxx>
120 #include <osl/mutex.hxx>
121 #include "AppView.hxx"
122 #include "browserids.hxx"
123 #include "dbu_reghelper.hxx"
124 #include "dbu_app.hrc"
125 #include "defaultobjectnamecheck.hxx"
126 #include "databaseobjectview.hxx"
127 #include "listviewitems.hxx"
128 #include "AppDetailView.hxx"
129 #include "linkeddocuments.hxx"
130 #include "sqlmessage.hxx"
131 #include "UITools.hxx"
132 #include "dsntypes.hxx"
133 #include "dbaccess_helpid.hrc"
134 #include "dlgsave.hxx"
135 #include "dbaccess_slotid.hrc"
138 #include <functional>
140 #include <boost/noncopyable.hpp>
142 extern "C" void SAL_CALL
createRegistryInfo_ODBApplication()
144 static ::dbaui::OMultiInstanceAutoRegistration
< ::dbaui::OApplicationController
> aAutoRegistration
;
146 //........................................................................
149 //........................................................................
150 using namespace ::dbtools
;
151 using namespace ::svx
;
152 using namespace ::com::sun::star
;
153 using namespace ::com::sun::star::uno
;
154 using namespace ::com::sun::star::ucb
;
155 using namespace ::com::sun::star::view
;
156 using namespace ::com::sun::star::util
;
157 using namespace ::com::sun::star::beans
;
158 using namespace ::com::sun::star::lang
;
159 using namespace ::com::sun::star::frame
;
160 using namespace ::com::sun::star::container
;
161 using namespace ::com::sun::star::sdb
;
162 using namespace ::com::sun::star::sdbc
;
163 using namespace ::com::sun::star::sdbcx
;
164 using namespace ::com::sun::star::datatransfer
;
165 using namespace ::com::sun::star::ui::dialogs
;
166 using namespace ::com::sun::star::task
;
167 using ::com::sun::star::document::XEmbeddedScripts
;
168 using ::com::sun::star::document::XDocumentEventBroadcaster
;
169 using ::com::sun::star::document::DocumentEvent
;
170 using ::com::sun::star::sdb::application::NamedDatabaseObject
;
172 namespace DatabaseObject
= ::com::sun::star::sdb::application::DatabaseObject
;
173 namespace DatabaseObjectContainer
= ::com::sun::star::sdb::application::DatabaseObjectContainer
;
175 //------------------------------------------------------------------------------
176 ::rtl::OUString SAL_CALL
OApplicationController::getImplementationName() throw( RuntimeException
)
178 return getImplementationName_Static();
181 //------------------------------------------------------------------------------
182 ::rtl::OUString
OApplicationController::getImplementationName_Static() throw( RuntimeException
)
184 return ::rtl::OUString(SERVICE_SDB_APPLICATIONCONTROLLER
);
186 //------------------------------------------------------------------------------
187 Sequence
< ::rtl::OUString
> OApplicationController::getSupportedServiceNames_Static(void) throw( RuntimeException
)
189 Sequence
< ::rtl::OUString
> aSupported(1);
190 aSupported
.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.application.DefaultViewController"));
193 //-------------------------------------------------------------------------
194 Sequence
< ::rtl::OUString
> SAL_CALL
OApplicationController::getSupportedServiceNames() throw(RuntimeException
)
196 return getSupportedServiceNames_Static();
198 // -------------------------------------------------------------------------
199 Reference
< XInterface
> SAL_CALL
OApplicationController::Create(const Reference
<XMultiServiceFactory
>& _rxFactory
)
201 return *(new OApplicationController(_rxFactory
));
203 // -----------------------------------------------------------------------------
205 struct XContainerFunctor
: public ::std::unary_function
< OApplicationController::TContainerVector::value_type
, bool>
207 Reference
<XContainerListener
> m_xContainerListener
;
208 XContainerFunctor( const Reference
<XContainerListener
>& _xContainerListener
)
209 : m_xContainerListener(_xContainerListener
){}
211 bool operator() (const OApplicationController::TContainerVector::value_type
& lhs
) const
214 lhs
->removeContainerListener(m_xContainerListener
);
219 //====================================================================
220 //= OApplicationController
221 //====================================================================
222 class SelectionNotifier
: public ::boost::noncopyable
225 ::cppu::OInterfaceContainerHelper m_aSelectionListeners
;
226 ::cppu::OWeakObject
& m_rContext
;
227 sal_Int32 m_nSelectionNestingLevel
;
230 SelectionNotifier( ::osl::Mutex
& _rMutex
, ::cppu::OWeakObject
& _rContext
)
231 :m_aSelectionListeners( _rMutex
)
232 ,m_rContext( _rContext
)
233 ,m_nSelectionNestingLevel( 0 )
237 void addListener( const Reference
< XSelectionChangeListener
>& _Listener
)
239 m_aSelectionListeners
.addInterface( _Listener
);
242 void removeListener( const Reference
< XSelectionChangeListener
>& _Listener
)
244 m_aSelectionListeners
.removeInterface( _Listener
);
249 EventObject
aEvent( m_rContext
);
250 m_aSelectionListeners
.disposeAndClear( aEvent
);
257 struct SelectionGuardAccess
{ friend class SelectionGuard
; private: SelectionGuardAccess() { } };
259 /** enters a block which modifies the selection of our owner.
261 Can be called multiple times, the only important thing is to call leaveSelection
264 void enterSelection( SelectionGuardAccess
)
266 ++m_nSelectionNestingLevel
;
269 /** leaves a block which modifies the selection of our owner
271 Must be paired with enterSelection calls.
273 When the last block is left, i.e. the last leaveSelection call is made on the current stack,
274 then our SelectionChangeListeners are notified
276 void leaveSelection( SelectionGuardAccess
)
278 if ( --m_nSelectionNestingLevel
== 0 )
280 EventObject
aEvent( m_rContext
);
281 m_aSelectionListeners
.notifyEach( &XSelectionChangeListener::selectionChanged
, aEvent
);
286 class SelectionGuard
: public ::boost::noncopyable
289 SelectionGuard( SelectionNotifier
& _rNotifier
)
290 :m_rNotifier( _rNotifier
)
292 m_rNotifier
.enterSelection( SelectionNotifier::SelectionGuardAccess() );
297 m_rNotifier
.leaveSelection( SelectionNotifier::SelectionGuardAccess() );
301 SelectionNotifier
& m_rNotifier
;
304 //====================================================================
305 //= OApplicationController
306 //====================================================================
307 DBG_NAME(OApplicationController
)
308 //--------------------------------------------------------------------
309 OApplicationController::OApplicationController(const Reference
< XMultiServiceFactory
>& _rxORB
)
310 :OApplicationController_CBASE( _rxORB
)
311 ,m_aContextMenuInterceptors( getMutex() )
312 ,m_pSubComponentManager( new SubComponentManager( *this, getSharedMutex() ) )
313 ,m_aTypeCollection(_rxORB
)
314 ,m_aTableCopyHelper(this)
315 ,m_pClipbordNotifier(NULL
)
317 ,m_aControllerConnectedEvent( LINK( this, OApplicationController
, OnFirstControllerConnected
) )
318 ,m_aSelectContainerEvent( LINK( this, OApplicationController
, OnSelectContainer
) )
319 ,m_ePreviewMode(E_PREVIEWNONE
)
320 ,m_eCurrentType(E_NONE
)
321 ,m_bNeedToReconnect(sal_False
)
322 ,m_bSuspended( sal_False
)
323 ,m_pSelectionNotifier( new SelectionNotifier( getMutex(), *this ) )
325 DBG_CTOR(OApplicationController
,NULL
);
327 //------------------------------------------------------------------------------
328 OApplicationController::~OApplicationController()
330 if ( !rBHelper
.bDisposed
&& !rBHelper
.bInDispose
)
332 OSL_FAIL("Please check who doesn't dispose this component!");
333 // increment ref count to prevent double call of Dtor
334 osl_incrementInterlockedCount( &m_refCount
);
337 SAL_WNODEPRECATED_DECLARATIONS_PUSH
338 ::std::auto_ptr
< Window
> aTemp( getView() );
339 SAL_WNODEPRECATED_DECLARATIONS_POP
342 DBG_DTOR(OApplicationController
,NULL
);
344 //--------------------------------------------------------------------
345 IMPLEMENT_FORWARD_XTYPEPROVIDER2(OApplicationController
,OApplicationController_CBASE
,OApplicationController_Base
)
346 IMPLEMENT_FORWARD_XINTERFACE2(OApplicationController
,OApplicationController_CBASE
,OApplicationController_Base
)
347 // -----------------------------------------------------------------------------
348 void OApplicationController::disconnect()
350 if ( m_xDataSourceConnection
.is() )
351 stopConnectionListening( m_xDataSourceConnection
);
355 // temporary (hopefully!) hack for #i55274#
356 Reference
< XFlushable
> xFlush( m_xDataSourceConnection
, UNO_QUERY
);
357 if ( xFlush
.is() && m_xMetaData
.is() && !m_xMetaData
->isReadOnly() )
360 catch( const Exception
& )
362 DBG_UNHANDLED_EXCEPTION();
365 m_xDataSourceConnection
.clear();
371 //--------------------------------------------------------------------
372 void SAL_CALL
OApplicationController::disposing()
374 m_aControllerConnectedEvent
.CancelCall();
376 ::std::for_each(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),XContainerFunctor(this));
377 m_aCurrentContainers
.clear();
378 m_pSubComponentManager
->disposing();
379 m_pSelectionNotifier
->disposing();
383 getContainer()->showPreview(NULL
);
384 m_pClipbordNotifier
->ClearCallbackLink();
385 m_pClipbordNotifier
->AddRemoveListener( getView(), sal_False
);
386 m_pClipbordNotifier
->release();
387 m_pClipbordNotifier
= NULL
;
393 Reference
< XFrame
> xFrame
;
394 attachFrame( xFrame
);
396 if ( m_xDataSource
.is() )
398 m_xDataSource
->removePropertyChangeListener(::rtl::OUString(), this);
399 m_xDataSource
->removePropertyChangeListener(PROPERTY_INFO
, this);
400 m_xDataSource
->removePropertyChangeListener(PROPERTY_URL
, this);
401 m_xDataSource
->removePropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED
, this);
402 m_xDataSource
->removePropertyChangeListener(PROPERTY_LAYOUTINFORMATION
, this);
403 m_xDataSource
->removePropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL
, this);
404 m_xDataSource
->removePropertyChangeListener(PROPERTY_TABLEFILTER
, this);
405 m_xDataSource
->removePropertyChangeListener(PROPERTY_TABLETYPEFILTER
, this);
406 m_xDataSource
->removePropertyChangeListener(PROPERTY_USER
, this);
407 // otherwise we may delete our datasource twice
408 Reference
<XPropertySet
> xProp
= m_xDataSource
;
409 m_xDataSource
= NULL
;
412 Reference
< XModifyBroadcaster
> xBroadcaster( m_xModel
, UNO_QUERY
);
413 if ( xBroadcaster
.is() )
414 xBroadcaster
->removeModifyListener(static_cast<XModifyListener
*>(this));
418 ::rtl::OUString sUrl
= m_xModel
->getURL();
419 if ( !sUrl
.isEmpty() )
421 ::comphelper::NamedValueCollection
aArgs( m_xModel
->getArgs() );
422 if ( true == aArgs
.getOrDefault( "PickListEntry", true ) )
424 ::rtl::OUString aFilter
;
425 INetURLObject
aURL( m_xModel
->getURL() );
426 const SfxFilter
* pFilter
= getStandardDatabaseFilter();
428 aFilter
= pFilter
->GetFilterName();
430 // add to svtool history options
431 SvtHistoryOptions().AppendItem( ePICKLIST
,
432 aURL
.GetURLNoPass( INetURLObject::NO_DECODE
),
434 getStrippedDatabaseName(),
439 m_xModel
->disconnectController( this );
444 catch(const Exception
&)
446 DBG_UNHANDLED_EXCEPTION();
450 OApplicationController_CBASE::disposing(); // here the m_refCount must be equal 5
453 //--------------------------------------------------------------------
454 sal_Bool
OApplicationController::Construct(Window
* _pParent
)
456 setView( * new OApplicationView( _pParent
, getORB(), *this, m_ePreviewMode
) );
457 getView()->SetUniqueId(UID_APP_VIEW
);
460 sal_Bool bSuccess
= sal_False
;
463 getContainer()->Construct();
466 catch(const SQLException
&)
469 catch(const Exception
&)
471 OSL_FAIL("OApplicationController::Construct : the construction of UnoDataBrowserView failed !");
476 SAL_WNODEPRECATED_DECLARATIONS_PUSH
477 ::std::auto_ptr
< Window
> aTemp( getView() );
478 SAL_WNODEPRECATED_DECLARATIONS_POP
483 // now that we have a view we can create the clipboard listener
484 m_aSystemClipboard
= TransferableDataHelper::CreateFromSystemClipboard( getView() );
485 m_aSystemClipboard
.StartClipboardListening( );
487 m_pClipbordNotifier
= new TransferableClipboardListener( LINK( this, OApplicationController
, OnClipboardChanged
) );
488 m_pClipbordNotifier
->acquire();
489 m_pClipbordNotifier
->AddRemoveListener( getView(), sal_True
);
491 OApplicationController_CBASE::Construct( _pParent
);
497 //--------------------------------------------------------------------
498 void SAL_CALL
OApplicationController::disposing(const EventObject
& _rSource
) throw( RuntimeException
)
500 ::osl::MutexGuard
aGuard( getMutex() );
501 Reference
<XConnection
> xCon(_rSource
.Source
, UNO_QUERY
);
504 OSL_ENSURE( m_xDataSourceConnection
== xCon
,
505 "OApplicationController::disposing: which connection does this come from?" );
507 if ( getContainer() && getContainer()->getElementType() == E_TABLE
)
508 getContainer()->clearPages();
509 if ( m_xDataSourceConnection
== xCon
)
512 m_xDataSourceConnection
.clear();
515 else if ( _rSource
.Source
== m_xModel
)
519 else if ( _rSource
.Source
== m_xDataSource
)
521 m_xDataSource
= NULL
;
525 Reference
<XContainer
> xContainer( _rSource
.Source
, UNO_QUERY
);
526 if ( xContainer
.is() )
528 TContainerVector::iterator aFind
= ::std::find(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),xContainer
);
529 if ( aFind
!= m_aCurrentContainers
.end() )
530 m_aCurrentContainers
.erase(aFind
);
532 OApplicationController_CBASE::disposing( _rSource
);
535 //--------------------------------------------------------------------
536 sal_Bool SAL_CALL
OApplicationController::suspend(sal_Bool bSuspend
) throw( RuntimeException
)
538 // notify the OnPrepareViewClosing event (before locking any mutex)
539 Reference
< XDocumentEventBroadcaster
> xBroadcaster( m_xModel
, UNO_QUERY
);
540 if ( xBroadcaster
.is() )
542 xBroadcaster
->notifyDocumentEvent(
543 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnPrepareViewClosing" ) ),
549 SolarMutexGuard aSolarGuard
;
550 ::osl::MutexGuard
aGuard( getMutex() );
552 if ( getView() && getView()->IsInModalMode() )
555 sal_Bool bCanSuspend
= sal_True
;
557 if ( m_bSuspended
!= bSuspend
)
559 if ( bSuspend
&& !closeSubComponents() )
562 Reference
<XModifiable
> xModi(m_xModel
,UNO_QUERY
);
563 Reference
<XStorable
> xStor(getModel(),UNO_QUERY
);
567 && !xStor
->isReadonly()
569 && xModi
->isModified()
573 switch (ExecuteQuerySaveDocument(getView(),getStrippedDatabaseName()))
576 Execute(ID_BROWSER_SAVEDOC
,Sequence
<PropertyValue
>());
577 bCanSuspend
= !xModi
->isModified();
578 // when we save the document this must be false else some press cancel
581 bCanSuspend
= sal_False
;
589 m_bSuspended
= bSuspend
;
593 // -----------------------------------------------------------------------------
594 FeatureState
OApplicationController::GetState(sal_uInt16 _nId
) const
596 FeatureState aReturn
;
597 aReturn
.bEnabled
= sal_False
;
599 if ( !getContainer() || m_bReadOnly
)
607 aReturn
.bEnabled
= sal_True
;
609 aReturn
.sTitle
= m_xModel
->getURL();
611 case ID_BROWSER_COPY
:
613 sal_Int32 nCount
= getContainer()->getSelectionCount();
614 aReturn
.bEnabled
= nCount
>= 1;
615 if ( aReturn
.bEnabled
&& nCount
== 1 && getContainer()->getElementType() == E_TABLE
)
616 aReturn
.bEnabled
= getContainer()->isALeafSelected();
620 aReturn
.bEnabled
= !isDataSourceReadOnly() && getContainer()->getSelectionCount() >= 1;
621 aReturn
.bEnabled
= aReturn
.bEnabled
&& ( (ID_BROWSER_CUT
== _nId
&& getContainer()->getElementType() == E_TABLE
) ? getContainer()->isCutAllowed() : sal_True
);
623 case ID_BROWSER_PASTE
:
624 switch( getContainer()->getElementType() )
627 aReturn
.bEnabled
= !isDataSourceReadOnly() && !isConnectionReadOnly() && isTableFormat();
630 aReturn
.bEnabled
= !isDataSourceReadOnly() && getViewClipboard().HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY
);
633 aReturn
.bEnabled
= !isDataSourceReadOnly() && OComponentTransferable::canExtractComponentDescriptor(getViewClipboard().GetDataFlavorExVector(),getContainer()->getElementType() == E_FORM
);
636 case SID_DB_APP_PASTE_SPECIAL
:
637 aReturn
.bEnabled
= getContainer()->getElementType() == E_TABLE
&& !isDataSourceReadOnly() && !isConnectionReadOnly() && isTableFormat();
641 aReturn
.bEnabled
= sal_True
;
643 case ID_BROWSER_SAVEDOC
:
644 aReturn
.bEnabled
= !isDataSourceReadOnly() && m_xDocumentModify
.is() && m_xDocumentModify
->isModified();
646 case ID_BROWSER_SAVEASDOC
:
647 aReturn
.bEnabled
= sal_True
;
649 case ID_BROWSER_SORTUP
:
650 aReturn
.bEnabled
= getContainer()->isFilled() && getContainer()->getElementCount();
651 aReturn
.bChecked
= aReturn
.bEnabled
&& getContainer()->isSortUp();
653 case ID_BROWSER_SORTDOWN
:
654 aReturn
.bEnabled
= getContainer()->isFilled() && getContainer()->getElementCount();
655 aReturn
.bChecked
= aReturn
.bEnabled
&& !getContainer()->isSortUp();
659 case SID_APP_NEW_FORM
:
660 case ID_DOCUMENT_CREATE_REPWIZ
:
661 aReturn
.bEnabled
= !isDataSourceReadOnly() && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER
);
663 case SID_APP_NEW_REPORT
:
664 aReturn
.bEnabled
= !isDataSourceReadOnly()
665 && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER
);
666 if ( aReturn
.bEnabled
)
668 Reference
< XContentEnumerationAccess
> xEnumAccess(m_xServiceFactory
, UNO_QUERY
);
669 aReturn
.bEnabled
= xEnumAccess
.is();
670 if ( aReturn
.bEnabled
)
672 const ::rtl::OUString sReportEngineServiceName
= ::dbtools::getDefaultReportEngineServiceName(m_xServiceFactory
);
673 aReturn
.bEnabled
= !sReportEngineServiceName
.isEmpty();
674 if ( aReturn
.bEnabled
)
676 const Reference
< XEnumeration
> xEnumDrivers
= xEnumAccess
->createContentEnumeration(sReportEngineServiceName
);
677 aReturn
.bEnabled
= xEnumDrivers
.is() && xEnumDrivers
->hasMoreElements();
682 case SID_DB_APP_VIEW_TABLES
:
683 aReturn
.bEnabled
= sal_True
;
684 aReturn
.bChecked
= getContainer()->getElementType() == E_TABLE
;
686 case SID_DB_APP_VIEW_QUERIES
:
687 aReturn
.bEnabled
= sal_True
;
688 aReturn
.bChecked
= getContainer()->getElementType() == E_QUERY
;
690 case SID_DB_APP_VIEW_FORMS
:
691 aReturn
.bEnabled
= sal_True
;
692 aReturn
.bChecked
= getContainer()->getElementType() == E_FORM
;
694 case SID_DB_APP_VIEW_REPORTS
:
695 aReturn
.bEnabled
= sal_True
;
696 aReturn
.bChecked
= getContainer()->getElementType() == E_REPORT
;
698 case ID_NEW_QUERY_DESIGN
:
699 case ID_NEW_QUERY_SQL
:
700 case ID_APP_NEW_QUERY_AUTO_PILOT
:
701 case SID_DB_FORM_NEW_PILOT
:
702 aReturn
.bEnabled
= !isDataSourceReadOnly();
704 case ID_NEW_VIEW_DESIGN
:
705 case SID_DB_NEW_VIEW_SQL
:
706 case ID_NEW_VIEW_DESIGN_AUTO_PILOT
:
707 aReturn
.bEnabled
= !isDataSourceReadOnly() && !isConnectionReadOnly();
708 if ( aReturn
.bEnabled
)
710 Reference
<XViewsSupplier
> xViewsSup( getConnection(), UNO_QUERY
);
711 aReturn
.bEnabled
= xViewsSup
.is();
714 case ID_NEW_TABLE_DESIGN
:
715 case ID_NEW_TABLE_DESIGN_AUTO_PILOT
:
716 aReturn
.bEnabled
= !isDataSourceReadOnly() && !isConnectionReadOnly();
719 aReturn
.bEnabled
= sal_True
;
721 case ID_MIGRATE_SCRIPTS
:
723 // Our document supports embedding scripts into it, if and only if there are no
724 // forms/reports with macros/scripts into them. So, we need to enable migration
725 // if and only if the database document does *not* support embedding scripts.
727 !Reference
< XEmbeddedScripts
>( m_xModel
, UNO_QUERY
).is()
728 && !Reference
< XStorable
>( m_xModel
, UNO_QUERY_THROW
)->isReadonly();
729 aReturn
.bEnabled
= bAvailable
;
731 aReturn
.bInvisible
= true;
734 case SID_APP_NEW_FOLDER
:
735 aReturn
.bEnabled
= !isDataSourceReadOnly() && getContainer()->getSelectionCount() <= 1;
736 if ( aReturn
.bEnabled
)
738 const ElementType eType
= getContainer()->getElementType();
739 aReturn
.bEnabled
= eType
== E_REPORT
|| eType
== E_FORM
;
742 case SID_FORM_CREATE_REPWIZ_PRE_SEL
:
743 case SID_REPORT_CREATE_REPWIZ_PRE_SEL
:
744 case SID_APP_NEW_REPORT_PRE_SEL
:
745 aReturn
.bEnabled
= !isDataSourceReadOnly()
746 && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER
)
747 && getContainer()->isALeafSelected();
748 if ( aReturn
.bEnabled
)
750 ElementType eType
= getContainer()->getElementType();
751 aReturn
.bEnabled
= eType
== E_QUERY
|| eType
== E_TABLE
;
752 if ( aReturn
.bEnabled
&& SID_APP_NEW_REPORT_PRE_SEL
== _nId
)
754 Reference
< XContentEnumerationAccess
> xEnumAccess(m_xServiceFactory
, UNO_QUERY
);
755 aReturn
.bEnabled
= xEnumAccess
.is();
756 if ( aReturn
.bEnabled
)
758 static ::rtl::OUString
s_sReportDesign(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOReportJobFactory"));
759 Reference
< XEnumeration
> xEnumDrivers
= xEnumAccess
->createContentEnumeration(s_sReportDesign
);
760 aReturn
.bEnabled
= xEnumDrivers
.is() && xEnumDrivers
->hasMoreElements();
765 case SID_DB_APP_DELETE
:
766 case SID_DB_APP_RENAME
:
767 aReturn
.bEnabled
= isRenameDeleteAllowed(getContainer()->getElementType(), _nId
== SID_DB_APP_DELETE
);
769 case SID_DB_APP_TABLE_DELETE
:
770 case SID_DB_APP_TABLE_RENAME
:
771 aReturn
.bEnabled
= isRenameDeleteAllowed(E_TABLE
, _nId
== SID_DB_APP_TABLE_DELETE
);
773 case SID_DB_APP_QUERY_DELETE
:
774 case SID_DB_APP_QUERY_RENAME
:
775 aReturn
.bEnabled
= isRenameDeleteAllowed(E_QUERY
, _nId
== SID_DB_APP_QUERY_DELETE
);
777 case SID_DB_APP_FORM_DELETE
:
778 case SID_DB_APP_FORM_RENAME
:
779 aReturn
.bEnabled
= isRenameDeleteAllowed(E_FORM
, _nId
== SID_DB_APP_FORM_DELETE
);
781 case SID_DB_APP_REPORT_DELETE
:
782 case SID_DB_APP_REPORT_RENAME
:
783 aReturn
.bEnabled
= isRenameDeleteAllowed(E_REPORT
, _nId
== SID_DB_APP_REPORT_DELETE
);
787 aReturn
.bEnabled
= getContainer()->getElementCount() > 0 && getContainer()->getSelectionCount() != getContainer()->getElementCount();
789 case SID_DB_APP_EDIT
:
790 case SID_DB_APP_TABLE_EDIT
:
791 case SID_DB_APP_QUERY_EDIT
:
792 case SID_DB_APP_FORM_EDIT
:
793 case SID_DB_APP_REPORT_EDIT
:
794 aReturn
.bEnabled
= !isDataSourceReadOnly() && getContainer()->getSelectionCount() > 0
795 && getContainer()->isALeafSelected();
797 case SID_DB_APP_EDIT_SQL_VIEW
:
798 if ( isDataSourceReadOnly() )
799 aReturn
.bEnabled
= sal_False
;
802 switch ( getContainer()->getElementType() )
805 aReturn
.bEnabled
= ( getContainer()->getSelectionCount() > 0 )
806 && ( getContainer()->isALeafSelected() );
809 aReturn
.bEnabled
= sal_False
;
810 // there's one exception: views which support altering their underlying
811 // command can be edited in SQL view, too
812 if ( ( getContainer()->getSelectionCount() > 0 )
813 && ( getContainer()->isALeafSelected() )
816 ::std::vector
< ::rtl::OUString
> aSelected
;
817 getSelectionElementNames( aSelected
);
818 bool bAlterableViews
= true;
819 for ( ::std::vector
< ::rtl::OUString
>::const_iterator selectedName
= aSelected
.begin();
820 bAlterableViews
&& ( selectedName
!= aSelected
.end() ) ;
824 bAlterableViews
&= impl_isAlterableView_nothrow( *selectedName
);
826 aReturn
.bEnabled
= bAlterableViews
;
834 case SID_DB_APP_OPEN
:
835 case SID_DB_APP_TABLE_OPEN
:
836 case SID_DB_APP_QUERY_OPEN
:
837 case SID_DB_APP_FORM_OPEN
:
838 case SID_DB_APP_REPORT_OPEN
:
839 aReturn
.bEnabled
= getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
841 case SID_DB_APP_DSUSERADMIN
:
842 aReturn
.bEnabled
= !m_aTypeCollection
.isEmbeddedDatabase(::comphelper::getString(m_xDataSource
->getPropertyValue(PROPERTY_URL
)));
844 case SID_DB_APP_DSRELDESIGN
:
845 aReturn
.bEnabled
= sal_True
;
847 case SID_DB_APP_TABLEFILTER
:
848 aReturn
.bEnabled
= !isDataSourceReadOnly();
850 case SID_DB_APP_REFRESH_TABLES
:
851 aReturn
.bEnabled
= getContainer()->getElementType() == E_TABLE
&& isConnected();
853 case SID_DB_APP_DSPROPS
:
854 aReturn
.bEnabled
= m_xDataSource
.is() && m_aTypeCollection
.isShowPropertiesEnabled(::comphelper::getString(m_xDataSource
->getPropertyValue(PROPERTY_URL
)));
856 case SID_DB_APP_DSCONNECTION_TYPE
:
857 aReturn
.bEnabled
= !isDataSourceReadOnly() && m_xDataSource
.is() && !m_aTypeCollection
.isEmbeddedDatabase(::comphelper::getString(m_xDataSource
->getPropertyValue(PROPERTY_URL
)));
859 case SID_DB_APP_DSADVANCED_SETTINGS
:
860 aReturn
.bEnabled
= m_xDataSource
.is() && AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( m_aTypeCollection
.getType(::comphelper::getString( m_xDataSource
->getPropertyValue( PROPERTY_URL
) )) );
862 case SID_DB_APP_CONVERTTOVIEW
:
863 aReturn
.bEnabled
= !isDataSourceReadOnly();
864 if ( aReturn
.bEnabled
)
866 ElementType eType
= getContainer()->getElementType();
867 aReturn
.bEnabled
= eType
== E_QUERY
&& getContainer()->getSelectionCount() > 0;
868 if ( aReturn
.bEnabled
)
870 Reference
<XViewsSupplier
> xViewSup( getConnection(), UNO_QUERY
);
871 aReturn
.bEnabled
= xViewSup
.is() && Reference
<XAppend
>(xViewSup
->getViews(),UNO_QUERY
).is();
875 case SID_DB_APP_DISABLE_PREVIEW
:
876 aReturn
.bEnabled
= sal_True
;
877 aReturn
.bChecked
= getContainer()->getPreviewMode() == E_PREVIEWNONE
;
879 case SID_DB_APP_VIEW_DOCINFO_PREVIEW
:
881 ElementType eType
= getContainer()->getElementType();
882 aReturn
.bEnabled
= (E_REPORT
== eType
|| E_FORM
== eType
);
883 aReturn
.bChecked
= getContainer()->getPreviewMode() == E_DOCUMENTINFO
;
886 case SID_DB_APP_VIEW_DOC_PREVIEW
:
887 aReturn
.bEnabled
= sal_True
;
888 aReturn
.bChecked
= getContainer()->getPreviewMode() == E_DOCUMENT
;
890 case ID_BROWSER_UNDO
:
891 aReturn
.bEnabled
= sal_False
;
893 case SID_MAIL_SENDDOC
:
894 aReturn
.bEnabled
= sal_True
;
896 case SID_DB_APP_SENDREPORTASMAIL
:
898 ElementType eType
= getContainer()->getElementType();
899 aReturn
.bEnabled
= E_REPORT
== eType
&& getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
902 case SID_DB_APP_SENDREPORTTOWRITER
:
903 case SID_DB_APP_DBADMIN
:
904 aReturn
.bEnabled
= sal_False
;
906 case SID_DB_APP_STATUS_TYPE
:
907 aReturn
.bEnabled
= m_xDataSource
.is();
908 if ( aReturn
.bEnabled
)
910 ::rtl::OUString sURL
;
911 m_xDataSource
->getPropertyValue(PROPERTY_URL
) >>= sURL
;
912 ::rtl::OUString sDSTypeName
;
913 if ( m_aTypeCollection
.isEmbeddedDatabase( sURL
) )
915 sDSTypeName
= String( ModuleRes( RID_STR_EMBEDDED_DATABASE
) );
919 sDSTypeName
= m_aTypeCollection
.getTypeDisplayName(sURL
);
921 aReturn
.sTitle
= sDSTypeName
;
924 case SID_DB_APP_STATUS_DBNAME
:
925 aReturn
.bEnabled
= m_xDataSource
.is();
926 if ( aReturn
.bEnabled
)
928 ::rtl::OUString sURL
;
929 m_xDataSource
->getPropertyValue(PROPERTY_URL
) >>= sURL
;
930 String sDatabaseName
;
932 sal_Int32
nPortNumber( -1 );
934 m_aTypeCollection
.extractHostNamePort( sURL
, sDatabaseName
, sHostName
, nPortNumber
);
936 if ( !sDatabaseName
.Len() )
937 sDatabaseName
= m_aTypeCollection
.cutPrefix( sURL
);
938 if ( m_aTypeCollection
.isFileSystemBased(sURL
) )
940 sDatabaseName
= SvtPathOptions().SubstituteVariable( sDatabaseName
);
941 if ( sDatabaseName
.Len() )
943 ::svt::OFileNotation
aFileNotation(sDatabaseName
);
944 // set this decoded URL as text
945 sDatabaseName
= aFileNotation
.get(::svt::OFileNotation::N_SYSTEM
);
949 if ( sDatabaseName
.Len() == 0 )
950 sDatabaseName
= m_aTypeCollection
.getTypeDisplayName( sURL
);
952 aReturn
.sTitle
= sDatabaseName
;
955 case SID_DB_APP_STATUS_USERNAME
:
956 aReturn
.bEnabled
= m_xDataSource
.is();
957 if ( aReturn
.bEnabled
)
958 m_xDataSource
->getPropertyValue( PROPERTY_USER
) >>= aReturn
.sTitle
;
960 case SID_DB_APP_STATUS_HOSTNAME
:
961 aReturn
.bEnabled
= m_xDataSource
.is();
962 if ( aReturn
.bEnabled
)
964 ::rtl::OUString sURL
;
965 m_xDataSource
->getPropertyValue( PROPERTY_URL
) >>= sURL
;
967 String sHostName
, sDatabaseName
;
968 sal_Int32 nPortNumber
= -1;
969 m_aTypeCollection
.extractHostNamePort( sURL
, sDatabaseName
, sHostName
, nPortNumber
);
970 aReturn
.sTitle
= sHostName
;
974 aReturn
= OApplicationController_CBASE::GetState(_nId
);
977 catch(const Exception
& )
979 DBG_UNHANDLED_EXCEPTION();
984 // -----------------------------------------------------------------------------
987 bool lcl_handleException_nothrow( const Reference
< XModel
>& _rxDocument
, const Any
& _rException
)
989 bool bHandled
= false;
991 // try handling the error with an interaction handler
992 ::comphelper::NamedValueCollection
aArgs( _rxDocument
->getArgs() );
993 Reference
< XInteractionHandler
> xHandler( aArgs
.getOrDefault( "InteractionHandler", Reference
< XInteractionHandler
>() ) );
996 ::rtl::Reference
< ::comphelper::OInteractionRequest
> pRequest( new ::comphelper::OInteractionRequest( _rException
) );
997 ::rtl::Reference
< ::comphelper::OInteractionApprove
> pApprove( new ::comphelper::OInteractionApprove
);
998 pRequest
->addContinuation( pApprove
.get() );
1002 xHandler
->handle( pRequest
.get() );
1004 catch( const Exception
& )
1006 DBG_UNHANDLED_EXCEPTION();
1009 bHandled
= pApprove
->wasSelected();
1015 // -----------------------------------------------------------------------------
1016 void OApplicationController::Execute(sal_uInt16 _nId
, const Sequence
< PropertyValue
>& aArgs
)
1018 SolarMutexGuard aSolarGuard
;
1019 ::osl::MutexGuard
aGuard( getMutex() );
1021 if ( isUserDefinedFeature( _nId
) )
1023 OApplicationController_CBASE::Execute( _nId
, aArgs
);
1027 if ( !getContainer() || m_bReadOnly
)
1028 return; // return without execution
1034 case ID_BROWSER_CUT
:
1035 getContainer()->cut();
1037 case ID_BROWSER_COPY
:
1039 TransferableHelper
* pTransfer
= copyObject( );
1040 Reference
< XTransferable
> aEnsureDelete
= pTransfer
;
1043 pTransfer
->CopyToClipboard(getView());
1046 case ID_BROWSER_PASTE
:
1048 const TransferableDataHelper
& rTransferData( getViewClipboard() );
1049 ElementType eType
= getContainer()->getElementType();
1055 // get the selected tablename
1056 ::std::vector
< ::rtl::OUString
> aList
;
1057 getSelectionElementNames( aList
);
1058 if ( !aList
.empty() )
1059 m_aTableCopyHelper
.SetTableNameForAppend( *aList
.begin() );
1061 m_aTableCopyHelper
.ResetTableNameForAppend();
1063 m_aTableCopyHelper
.pasteTable( rTransferData
, getDatabaseName(), ensureConnection() );
1068 if ( rTransferData
.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY
) )
1069 paste( E_QUERY
, ODataAccessObjectTransferable::extractObjectDescriptor( rTransferData
) );
1073 ::std::vector
< ::rtl::OUString
> aList
;
1074 getSelectionElementNames(aList
);
1075 ::rtl::OUString sFolderNameToInsertInto
;
1076 if ( !aList
.empty() )
1078 Reference
< XHierarchicalNameAccess
> xContainer(getElements(eType
),UNO_QUERY
);
1079 if ( xContainer
.is()
1080 && xContainer
->hasByHierarchicalName(*aList
.begin())
1081 && (xContainer
->getByHierarchicalName(*aList
.begin()) >>= xContainer
)
1084 sFolderNameToInsertInto
= *aList
.begin();
1086 paste( eType
, OComponentTransferable::extractComponentDescriptor( rTransferData
),
1087 sFolderNameToInsertInto
);
1093 case SID_DB_APP_PASTE_SPECIAL
:
1095 if ( !aArgs
.getLength() )
1097 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1098 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1099 ::std::auto_ptr
<SfxAbstractPasteDialog
> pDlg(pFact
->CreatePasteDialog( getView() ));
1100 SAL_WNODEPRECATED_DECLARATIONS_POP
1101 ::std::vector
<SotFormatStringId
> aFormatIds
;
1102 getSupportedFormats(getContainer()->getElementType(),aFormatIds
);
1103 const ::std::vector
<SotFormatStringId
>::iterator aEnd
= aFormatIds
.end();
1104 ::rtl::OUString sEmpty
;
1105 for (::std::vector
<SotFormatStringId
>::iterator aIter
= aFormatIds
.begin();aIter
!= aEnd
; ++aIter
)
1106 pDlg
->Insert(*aIter
,sEmpty
);
1108 const TransferableDataHelper
& rClipboard
= getViewClipboard();
1109 pasteFormat(pDlg
->GetFormat(rClipboard
.GetTransferable()));
1113 const PropertyValue
* pIter
= aArgs
.getConstArray();
1114 const PropertyValue
* pEnd
= pIter
+ aArgs
.getLength();
1115 for( ; pIter
!= pEnd
; ++pIter
)
1117 if ( pIter
->Name
== "FormatStringId" )
1119 SotFormatStringId nFormatId
= 0;
1120 if ( pIter
->Value
>>= nFormatId
)
1121 pasteFormat(nFormatId
);
1129 case SID_HELP_INDEX
:
1131 Reference
< XDispatchProvider
> xProv( getFrame(), UNO_QUERY
);
1137 case SID_HELP_INDEX
:
1138 aURL
.Complete
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:HelpIndex"));
1141 aURL
.Complete
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Open"));
1145 if ( m_xUrlTransformer
.is() )
1146 m_xUrlTransformer
->parseStrict( aURL
);
1147 Reference
< XDispatch
> xDisp
= xProv
->queryDispatch( aURL
, String(), 0 );
1149 xDisp
->dispatch( aURL
, Sequence
< PropertyValue
>() );
1153 case ID_BROWSER_SAVEDOC
:
1155 Reference
< XStorable
> xStore( m_xModel
, UNO_QUERY_THROW
);
1160 catch( const Exception
& )
1162 lcl_handleException_nothrow( m_xModel
, ::cppu::getCaughtException() );
1167 case ID_BROWSER_SAVEASDOC
:
1169 ::rtl::OUString sUrl
;
1170 if ( m_xModel
.is() )
1171 sUrl
= m_xModel
->getURL();
1172 if ( sUrl
.isEmpty() )
1173 sUrl
= SvtPathOptions().GetWorkPath();
1175 ::sfx2::FileDialogHelper
aFileDlg(
1176 ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
,
1178 aFileDlg
.SetDisplayDirectory( sUrl
);
1180 const SfxFilter
* pFilter
= getStandardDatabaseFilter();
1183 aFileDlg
.AddFilter(pFilter
->GetUIName(),pFilter
->GetDefaultExtension());
1184 aFileDlg
.SetCurrentFilter(pFilter
->GetUIName());
1187 if ( aFileDlg
.Execute() != ERRCODE_NONE
)
1190 Reference
<XStorable
> xStore( m_xModel
, UNO_QUERY_THROW
);
1191 INetURLObject
aURL( aFileDlg
.GetPath() );
1194 xStore
->storeAsURL( aURL
.GetMainURL( INetURLObject::NO_DECODE
), Sequence
< PropertyValue
>() );
1196 catch( const Exception
& )
1198 lcl_handleException_nothrow( m_xModel
, ::cppu::getCaughtException() );
1202 m_bCurrentlyModified
= sal_False
;
1203 InvalidateFeature(ID_BROWSER_SAVEDOC
);
1204 if ( getContainer()->getElementType() == E_NONE
)
1206 getContainer()->selectContainer(E_NONE
);
1207 getContainer()->selectContainer(E_TABLE
);
1209 getContainer()->Invalidate();
1215 case ID_BROWSER_SORTUP
:
1216 getContainer()->sortUp();
1217 InvalidateFeature(ID_BROWSER_SORTDOWN
);
1219 case ID_BROWSER_SORTDOWN
:
1220 getContainer()->sortDown();
1221 InvalidateFeature(ID_BROWSER_SORTUP
);
1224 case ID_NEW_TABLE_DESIGN_AUTO_PILOT
:
1225 case ID_NEW_VIEW_DESIGN_AUTO_PILOT
:
1226 case ID_APP_NEW_QUERY_AUTO_PILOT
:
1227 case SID_DB_FORM_NEW_PILOT
:
1228 case SID_REPORT_CREATE_REPWIZ_PRE_SEL
:
1229 case SID_APP_NEW_REPORT_PRE_SEL
:
1230 case SID_FORM_CREATE_REPWIZ_PRE_SEL
:
1231 case ID_DOCUMENT_CREATE_REPWIZ
:
1232 case SID_APP_NEW_FORM
:
1233 case SID_APP_NEW_REPORT
:
1234 case ID_NEW_QUERY_SQL
:
1235 case ID_NEW_QUERY_DESIGN
:
1236 case ID_NEW_TABLE_DESIGN
:
1238 ElementType eType
= E_TABLE
;
1239 sal_Bool bAutoPilot
= sal_False
;
1240 ::comphelper::NamedValueCollection aCreationArgs
;
1244 case SID_DB_FORM_NEW_PILOT
:
1245 case SID_FORM_CREATE_REPWIZ_PRE_SEL
:
1246 bAutoPilot
= sal_True
;
1248 case SID_APP_NEW_FORM
:
1251 case ID_DOCUMENT_CREATE_REPWIZ
:
1252 case SID_REPORT_CREATE_REPWIZ_PRE_SEL
:
1253 bAutoPilot
= sal_True
;
1255 case SID_APP_NEW_REPORT
:
1256 case SID_APP_NEW_REPORT_PRE_SEL
:
1259 case ID_APP_NEW_QUERY_AUTO_PILOT
:
1260 bAutoPilot
= sal_True
;
1263 case ID_NEW_QUERY_DESIGN
:
1264 aCreationArgs
.put( (::rtl::OUString
)PROPERTY_GRAPHICAL_DESIGN
, sal_True
);
1266 case ID_NEW_QUERY_SQL
:
1269 case ID_NEW_TABLE_DESIGN_AUTO_PILOT
:
1270 bAutoPilot
= sal_True
;
1272 case ID_NEW_TABLE_DESIGN
:
1275 OSL_FAIL("illegal switch call!");
1278 getContainer()->PostUserEvent( LINK( this, OApplicationController
, OnCreateWithPilot
), reinterpret_cast< void* >( eType
) );
1281 Reference
< XComponent
> xDocDefinition
;
1282 newElement( eType
, aCreationArgs
, xDocDefinition
);
1286 case SID_APP_NEW_FOLDER
:
1288 ElementType eType
= getContainer()->getElementType();
1289 ::rtl::OUString sName
= getContainer()->getQualifiedName( NULL
);
1290 insertHierachyElement(eType
,sName
);
1293 case ID_NEW_VIEW_DESIGN
:
1294 case SID_DB_NEW_VIEW_SQL
:
1296 SharedConnection
xConnection( ensureConnection() );
1297 if ( xConnection
.is() )
1299 QueryDesigner
aDesigner( getORB(), this, getFrame(), true );
1301 ::comphelper::NamedValueCollection aCreationArgs
;
1302 aCreationArgs
.put( (::rtl::OUString
)PROPERTY_GRAPHICAL_DESIGN
, ID_NEW_VIEW_DESIGN
== _nId
);
1304 const Reference
< XDataSource
> xDataSource( m_xDataSource
, UNO_QUERY
);
1305 const Reference
< XComponent
> xComponent( aDesigner
.createNew( xDataSource
, aCreationArgs
), UNO_QUERY
);
1306 onDocumentOpened( ::rtl::OUString(), E_QUERY
, E_OPEN_DESIGN
, xComponent
, NULL
);
1310 case SID_DB_APP_DELETE
:
1311 case SID_DB_APP_TABLE_DELETE
:
1312 case SID_DB_APP_QUERY_DELETE
:
1313 case SID_DB_APP_FORM_DELETE
:
1314 case SID_DB_APP_REPORT_DELETE
:
1317 case SID_DB_APP_RENAME
:
1318 case SID_DB_APP_TABLE_RENAME
:
1319 case SID_DB_APP_QUERY_RENAME
:
1320 case SID_DB_APP_FORM_RENAME
:
1321 case SID_DB_APP_REPORT_RENAME
:
1324 case SID_DB_APP_EDIT
:
1325 case SID_DB_APP_EDIT_SQL_VIEW
:
1326 case SID_DB_APP_TABLE_EDIT
:
1327 case SID_DB_APP_QUERY_EDIT
:
1328 case SID_DB_APP_FORM_EDIT
:
1329 case SID_DB_APP_REPORT_EDIT
:
1330 doAction( _nId
, E_OPEN_DESIGN
);
1332 case SID_DB_APP_OPEN
:
1333 case SID_DB_APP_TABLE_OPEN
:
1334 case SID_DB_APP_QUERY_OPEN
:
1335 case SID_DB_APP_FORM_OPEN
:
1336 case SID_DB_APP_REPORT_OPEN
:
1337 doAction( _nId
, E_OPEN_NORMAL
);
1339 case SID_DB_APP_CONVERTTOVIEW
:
1340 doAction( _nId
, E_OPEN_NORMAL
);
1343 getContainer()->selectAll();
1346 case SID_DB_APP_DSRELDESIGN
:
1348 Reference
< XComponent
> xRelationDesigner
;
1349 if ( !m_pSubComponentManager
->activateSubFrame( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN
, E_OPEN_DESIGN
, xRelationDesigner
) )
1351 SharedConnection
xConnection( ensureConnection() );
1352 if ( xConnection
.is() )
1354 RelationDesigner
aDesigner( getORB(), this, m_aCurrentFrame
.getFrame() );
1356 const Reference
< XDataSource
> xDataSource( m_xDataSource
, UNO_QUERY
);
1357 const Reference
< XComponent
> xComponent( aDesigner
.createNew( xDataSource
), UNO_QUERY
);
1358 onDocumentOpened( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN
, E_OPEN_DESIGN
, xComponent
, NULL
);
1363 case SID_DB_APP_DSUSERADMIN
:
1365 SharedConnection
xConnection( ensureConnection() );
1366 if ( xConnection
.is() )
1367 openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.UserAdministrationDialog")));
1370 case SID_DB_APP_TABLEFILTER
:
1371 openTableFilterDialog();
1374 case SID_DB_APP_REFRESH_TABLES
:
1377 case SID_DB_APP_DSPROPS
:
1378 openDataSourceAdminDialog();
1381 case SID_DB_APP_DSADVANCED_SETTINGS
:
1382 openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.AdvancedDatabaseSettingsDialog")));
1385 case SID_DB_APP_DSCONNECTION_TYPE
:
1386 openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DataSourceTypeChangeDialog")));
1391 SharedConnection
xConnection( ensureConnection() );
1392 if ( xConnection
.is() )
1393 openDirectSQLDialog();
1396 case ID_MIGRATE_SCRIPTS
:
1397 impl_migrateScripts_nothrow();
1399 case SID_DB_APP_VIEW_TABLES
:
1400 m_aSelectContainerEvent
.Call( reinterpret_cast< void* >( E_TABLE
) );
1402 case SID_DB_APP_VIEW_QUERIES
:
1403 m_aSelectContainerEvent
.Call( reinterpret_cast< void* >( E_QUERY
) );
1405 case SID_DB_APP_VIEW_FORMS
:
1406 m_aSelectContainerEvent
.Call( reinterpret_cast< void* >( E_FORM
) );
1408 case SID_DB_APP_VIEW_REPORTS
:
1409 m_aSelectContainerEvent
.Call( reinterpret_cast< void* >( E_REPORT
) );
1411 case SID_DB_APP_DISABLE_PREVIEW
:
1412 m_ePreviewMode
= E_PREVIEWNONE
;
1413 getContainer()->switchPreview(m_ePreviewMode
);
1415 case SID_DB_APP_VIEW_DOCINFO_PREVIEW
:
1416 m_ePreviewMode
= E_DOCUMENTINFO
;
1417 getContainer()->switchPreview(m_ePreviewMode
);
1419 case SID_DB_APP_VIEW_DOC_PREVIEW
:
1420 m_ePreviewMode
= E_DOCUMENT
;
1421 getContainer()->switchPreview(m_ePreviewMode
);
1423 case SID_MAIL_SENDDOC
:
1425 SfxMailModel aSendMail
;
1426 if ( aSendMail
.AttachDocument(rtl::OUString(),getModel(), rtl::OUString()) == SfxMailModel::SEND_MAIL_OK
)
1427 aSendMail
.Send( getFrame() );
1430 case SID_DB_APP_SENDREPORTASMAIL
:
1431 doAction( _nId
, E_OPEN_FOR_MAIL
);
1435 catch( const Exception
& )
1437 DBG_UNHANDLED_EXCEPTION();
1439 InvalidateFeature(_nId
);
1441 // -----------------------------------------------------------------------------
1442 void OApplicationController::describeSupportedFeatures()
1444 OApplicationController_CBASE::describeSupportedFeatures();
1446 implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVEDOC
, CommandGroup::DOCUMENT
);
1447 implDescribeSupportedFeature( ".uno:SaveAs", ID_BROWSER_SAVEASDOC
, CommandGroup::DOCUMENT
);
1448 implDescribeSupportedFeature( ".uno:SendMail", SID_MAIL_SENDDOC
, CommandGroup::DOCUMENT
);
1449 implDescribeSupportedFeature( ".uno:DBSendReportAsMail",SID_DB_APP_SENDREPORTASMAIL
,
1450 CommandGroup::DOCUMENT
);
1451 implDescribeSupportedFeature( ".uno:DBSendReportToWriter",SID_DB_APP_SENDREPORTTOWRITER
,
1452 CommandGroup::DOCUMENT
);
1453 implDescribeSupportedFeature( ".uno:DBNewForm", SID_APP_NEW_FORM
, CommandGroup::INSERT
);
1454 implDescribeSupportedFeature( ".uno:DBNewFolder", SID_APP_NEW_FOLDER
, CommandGroup::INSERT
);
1455 implDescribeSupportedFeature( ".uno:DBNewFormAutoPilot", SID_DB_FORM_NEW_PILOT
, CommandGroup::INSERT
);
1456 implDescribeSupportedFeature( ".uno:DBNewFormAutoPilotWithPreSelection",
1457 SID_FORM_CREATE_REPWIZ_PRE_SEL
,
1458 CommandGroup::APPLICATION
);
1460 implDescribeSupportedFeature( ".uno:DBNewReport", SID_APP_NEW_REPORT
, CommandGroup::INSERT
);
1461 implDescribeSupportedFeature( ".uno:DBNewReportAutoPilot",
1462 ID_DOCUMENT_CREATE_REPWIZ
, CommandGroup::INSERT
);
1463 implDescribeSupportedFeature( ".uno:DBNewReportAutoPilotWithPreSelection",
1464 SID_REPORT_CREATE_REPWIZ_PRE_SEL
,
1465 CommandGroup::APPLICATION
);
1466 implDescribeSupportedFeature( ".uno:DBNewQuery", ID_NEW_QUERY_DESIGN
, CommandGroup::INSERT
);
1467 implDescribeSupportedFeature( ".uno:DBNewQuerySql", ID_NEW_QUERY_SQL
, CommandGroup::INSERT
);
1468 implDescribeSupportedFeature( ".uno:DBNewQueryAutoPilot",ID_APP_NEW_QUERY_AUTO_PILOT
,
1469 CommandGroup::INSERT
);
1470 implDescribeSupportedFeature( ".uno:DBNewTable", ID_NEW_TABLE_DESIGN
, CommandGroup::INSERT
);
1471 implDescribeSupportedFeature( ".uno:DBNewTableAutoPilot",ID_NEW_TABLE_DESIGN_AUTO_PILOT
,
1472 CommandGroup::INSERT
);
1473 implDescribeSupportedFeature( ".uno:DBNewView", ID_NEW_VIEW_DESIGN
, CommandGroup::INSERT
);
1474 implDescribeSupportedFeature( ".uno:DBNewViewSQL", SID_DB_NEW_VIEW_SQL
, CommandGroup::INSERT
);
1476 implDescribeSupportedFeature( ".uno:DBDelete", SID_DB_APP_DELETE
, CommandGroup::EDIT
);
1477 implDescribeSupportedFeature( ".uno:Delete", SID_DB_APP_DELETE
, CommandGroup::EDIT
);
1478 implDescribeSupportedFeature( ".uno:DBRename", SID_DB_APP_RENAME
, CommandGroup::EDIT
);
1479 implDescribeSupportedFeature( ".uno:DBEdit", SID_DB_APP_EDIT
, CommandGroup::EDIT
);
1480 implDescribeSupportedFeature( ".uno:DBEditSqlView", SID_DB_APP_EDIT_SQL_VIEW
, CommandGroup::EDIT
);
1481 implDescribeSupportedFeature( ".uno:DBOpen", SID_DB_APP_OPEN
, CommandGroup::EDIT
);
1483 implDescribeSupportedFeature( ".uno:DBTableDelete", SID_DB_APP_TABLE_DELETE
, CommandGroup::EDIT
);
1484 implDescribeSupportedFeature( ".uno:DBTableRename", SID_DB_APP_TABLE_RENAME
, CommandGroup::EDIT
);
1485 implDescribeSupportedFeature( ".uno:DBTableEdit", SID_DB_APP_TABLE_EDIT
, CommandGroup::EDIT
);
1486 implDescribeSupportedFeature( ".uno:DBTableOpen", SID_DB_APP_TABLE_OPEN
, CommandGroup::EDIT
);
1488 implDescribeSupportedFeature( ".uno:DBQueryDelete", SID_DB_APP_QUERY_DELETE
, CommandGroup::EDIT
);
1489 implDescribeSupportedFeature( ".uno:DBQueryRename", SID_DB_APP_QUERY_RENAME
, CommandGroup::EDIT
);
1490 implDescribeSupportedFeature( ".uno:DBQueryEdit", SID_DB_APP_QUERY_EDIT
, CommandGroup::EDIT
);
1491 implDescribeSupportedFeature( ".uno:DBQueryOpen", SID_DB_APP_QUERY_OPEN
, CommandGroup::EDIT
);
1493 implDescribeSupportedFeature( ".uno:DBFormDelete", SID_DB_APP_FORM_DELETE
, CommandGroup::EDIT
);
1494 implDescribeSupportedFeature( ".uno:DBFormRename", SID_DB_APP_FORM_RENAME
, CommandGroup::EDIT
);
1495 implDescribeSupportedFeature( ".uno:DBFormEdit", SID_DB_APP_FORM_EDIT
, CommandGroup::EDIT
);
1496 implDescribeSupportedFeature( ".uno:DBFormOpen", SID_DB_APP_FORM_OPEN
, CommandGroup::EDIT
);
1498 implDescribeSupportedFeature( ".uno:DBReportDelete", SID_DB_APP_REPORT_DELETE
, CommandGroup::EDIT
);
1499 implDescribeSupportedFeature( ".uno:DBReportRename", SID_DB_APP_REPORT_RENAME
, CommandGroup::EDIT
);
1500 implDescribeSupportedFeature( ".uno:DBReportEdit", SID_DB_APP_REPORT_EDIT
, CommandGroup::EDIT
);
1501 implDescribeSupportedFeature( ".uno:DBReportOpen", SID_DB_APP_REPORT_OPEN
, CommandGroup::EDIT
);
1503 implDescribeSupportedFeature( ".uno:SelectAll", SID_SELECTALL
, CommandGroup::EDIT
);
1504 implDescribeSupportedFeature( ".uno:Undo", ID_BROWSER_UNDO
, CommandGroup::EDIT
);
1506 implDescribeSupportedFeature( ".uno:Sortup", ID_BROWSER_SORTUP
, CommandGroup::VIEW
);
1507 implDescribeSupportedFeature( ".uno:SortDown", ID_BROWSER_SORTDOWN
, CommandGroup::VIEW
);
1508 implDescribeSupportedFeature( ".uno:DBRelationDesign", SID_DB_APP_DSRELDESIGN
, CommandGroup::APPLICATION
);
1509 implDescribeSupportedFeature( ".uno:DBUserAdmin", SID_DB_APP_DSUSERADMIN
, CommandGroup::APPLICATION
);
1510 implDescribeSupportedFeature( ".uno:DBTableFilter", SID_DB_APP_TABLEFILTER
, CommandGroup::APPLICATION
);
1511 implDescribeSupportedFeature( ".uno:DBDSProperties", SID_DB_APP_DSPROPS
, CommandGroup::EDIT
);
1512 implDescribeSupportedFeature( ".uno:DBDSConnectionType", SID_DB_APP_DSCONNECTION_TYPE
,
1513 CommandGroup::EDIT
);
1514 implDescribeSupportedFeature( ".uno:DBDSAdvancedSettings",
1515 SID_DB_APP_DSADVANCED_SETTINGS
,
1516 CommandGroup::EDIT
);
1517 implDescribeSupportedFeature( ".uno:PasteSpecial", SID_DB_APP_PASTE_SPECIAL
, CommandGroup::EDIT
);
1518 implDescribeSupportedFeature( ".uno:DBConvertToView", SID_DB_APP_CONVERTTOVIEW
, CommandGroup::EDIT
);
1519 implDescribeSupportedFeature( ".uno:DBRefreshTables", SID_DB_APP_REFRESH_TABLES
, CommandGroup::APPLICATION
);
1520 implDescribeSupportedFeature( ".uno:DBDirectSQL", ID_DIRECT_SQL
, CommandGroup::APPLICATION
);
1521 implDescribeSupportedFeature( ".uno:DBMigrateScripts", ID_MIGRATE_SCRIPTS
, CommandGroup::APPLICATION
);
1522 implDescribeSupportedFeature( ".uno:DBViewTables", SID_DB_APP_VIEW_TABLES
, CommandGroup::VIEW
);
1523 implDescribeSupportedFeature( ".uno:DBViewQueries", SID_DB_APP_VIEW_QUERIES
, CommandGroup::VIEW
);
1524 implDescribeSupportedFeature( ".uno:DBViewForms", SID_DB_APP_VIEW_FORMS
, CommandGroup::VIEW
);
1525 implDescribeSupportedFeature( ".uno:DBViewReports", SID_DB_APP_VIEW_REPORTS
, CommandGroup::VIEW
);
1526 implDescribeSupportedFeature( ".uno:DBDisablePreview", SID_DB_APP_DISABLE_PREVIEW
,CommandGroup::VIEW
);
1527 implDescribeSupportedFeature( ".uno:DBShowDocInfoPreview",
1528 SID_DB_APP_VIEW_DOCINFO_PREVIEW
,
1529 CommandGroup::VIEW
);
1530 implDescribeSupportedFeature( ".uno:DBShowDocPreview", SID_DB_APP_VIEW_DOC_PREVIEW
,
1531 CommandGroup::VIEW
);
1533 implDescribeSupportedFeature( ".uno:OpenUrl", SID_OPENURL
, CommandGroup::APPLICATION
);
1535 // this one should not appear under Tools->Customize->Keyboard
1536 implDescribeSupportedFeature( ".uno:DBNewReportWithPreSelection",
1537 SID_APP_NEW_REPORT_PRE_SEL
,CommandGroup::INTERNAL
);
1538 implDescribeSupportedFeature( ".uno:DBDSImport", SID_DB_APP_DSIMPORT
, CommandGroup::INTERNAL
);
1539 implDescribeSupportedFeature( ".uno:DBDSExport", SID_DB_APP_DSEXPORT
, CommandGroup::INTERNAL
);
1540 implDescribeSupportedFeature( ".uno:DBDBAdmin", SID_DB_APP_DBADMIN
, CommandGroup::INTERNAL
);
1543 implDescribeSupportedFeature( ".uno:DBStatusType", SID_DB_APP_STATUS_TYPE
, CommandGroup::INTERNAL
);
1544 implDescribeSupportedFeature( ".uno:DBStatusDBName", SID_DB_APP_STATUS_DBNAME
, CommandGroup::INTERNAL
);
1545 implDescribeSupportedFeature( ".uno:DBStatusUserName", SID_DB_APP_STATUS_USERNAME
, CommandGroup::INTERNAL
);
1546 implDescribeSupportedFeature( ".uno:DBStatusHostName", SID_DB_APP_STATUS_HOSTNAME
, CommandGroup::INTERNAL
);
1548 // -----------------------------------------------------------------------------
1549 OApplicationView
* OApplicationController::getContainer() const
1551 return static_cast< OApplicationView
* >( getView() );
1554 // -----------------------------------------------------------------------------
1555 // ::com::sun::star::container::XContainerListener
1556 void SAL_CALL
OApplicationController::elementInserted( const ContainerEvent
& _rEvent
) throw(RuntimeException
)
1558 SolarMutexGuard aSolarGuard
;
1559 ::osl::MutexGuard
aGuard( getMutex() );
1561 Reference
< XContainer
> xContainer(_rEvent
.Source
, UNO_QUERY
);
1562 if ( ::std::find(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),xContainer
) != m_aCurrentContainers
.end() )
1564 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1565 if ( getContainer() )
1567 ::rtl::OUString sName
;
1568 _rEvent
.Accessor
>>= sName
;
1569 ElementType eType
= getElementType(xContainer
);
1579 Reference
< XContainer
> xSubContainer(_rEvent
.Element
,UNO_QUERY
);
1580 if ( xSubContainer
.is() )
1581 containerFound(xSubContainer
);
1587 getContainer()->elementAdded(eType
,sName
,_rEvent
.Element
);
1591 // -----------------------------------------------------------------------------
1592 void SAL_CALL
OApplicationController::elementRemoved( const ContainerEvent
& _rEvent
) throw(RuntimeException
)
1594 SolarMutexGuard aSolarGuard
;
1595 ::osl::MutexGuard
aGuard( getMutex() );
1597 Reference
< XContainer
> xContainer(_rEvent
.Source
, UNO_QUERY
);
1598 if ( ::std::find(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),xContainer
) != m_aCurrentContainers
.end() )
1600 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1601 ::rtl::OUString sName
;
1602 _rEvent
.Accessor
>>= sName
;
1603 ElementType eType
= getElementType(xContainer
);
1612 Reference
<XContent
> xContent(xContainer
,UNO_QUERY
);
1613 if ( xContent
.is() )
1615 sName
= xContent
->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName
;
1622 getContainer()->elementRemoved(eType
,sName
);
1625 // -----------------------------------------------------------------------------
1626 void SAL_CALL
OApplicationController::elementReplaced( const ContainerEvent
& _rEvent
) throw(RuntimeException
)
1628 SolarMutexGuard aSolarGuard
;
1629 ::osl::MutexGuard
aGuard( getMutex() );
1631 Reference
< XContainer
> xContainer(_rEvent
.Source
, UNO_QUERY
);
1632 if ( ::std::find(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),xContainer
) != m_aCurrentContainers
.end() )
1634 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1635 ::rtl::OUString sName
;
1638 _rEvent
.Accessor
>>= sName
;
1639 Reference
<XConnection
> xConnection
;
1640 Reference
<XPropertySet
> xProp(_rEvent
.Element
,UNO_QUERY
);
1641 ::rtl::OUString sNewName
;
1643 ElementType eType
= getElementType(xContainer
);
1649 if ( xProp
.is() && m_xMetaData
.is() )
1650 sNewName
= ::dbaui::composeTableName( m_xMetaData
, xProp
, ::dbtools::eInDataManipulation
, false, false, false );
1656 Reference
<XContent
> xContent(xContainer
,UNO_QUERY
);
1657 if ( xContent
.is() )
1659 sName
= xContent
->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName
;
1666 // getContainer()->elementReplaced(getContainer()->getElementType(),sName,sNewName);
1670 DBG_UNHANDLED_EXCEPTION();
1676 ::rtl::OUString
lcl_getToolBarResource(ElementType _eType
)
1678 ::rtl::OUString sToolbar
;
1682 sToolbar
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/tableobjectbar" ));
1685 sToolbar
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/queryobjectbar" ));
1688 sToolbar
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/formobjectbar" ));
1691 sToolbar
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/reportobjectbar" ));
1696 OSL_FAIL("Invalid ElementType!");
1702 // -----------------------------------------------------------------------------
1703 sal_Bool
OApplicationController::onContainerSelect(ElementType _eType
)
1705 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1707 if ( m_eCurrentType
!= _eType
&& _eType
!= E_NONE
)
1709 SelectionGuard
aSelGuard( *m_pSelectionNotifier
);
1711 if ( _eType
== E_TABLE
)
1715 SharedConnection
xConnection( ensureConnection() );
1716 if ( xConnection
.is() && getContainer()->getDetailView() )
1718 getContainer()->getDetailView()->createTablesPage(xConnection
);
1719 Reference
<XTablesSupplier
> xTabSup(xConnection
,UNO_QUERY
);
1721 addContainerListener(xTabSup
->getTables());
1728 catch( const Exception
& )
1733 Reference
< XLayoutManager
> xLayoutManager
= getLayoutManager( getFrame() );
1734 if ( xLayoutManager
.is() )
1736 ::rtl::OUString sToolbar
= lcl_getToolBarResource(_eType
);
1737 ::rtl::OUString sDestroyToolbar
= lcl_getToolBarResource(m_eCurrentType
);
1739 xLayoutManager
->lock();
1740 xLayoutManager
->destroyElement( sDestroyToolbar
);
1741 if ( sToolbar
.getLength() )
1743 xLayoutManager
->createElement( sToolbar
);
1744 xLayoutManager
->requestElement( sToolbar
);
1746 xLayoutManager
->unlock();
1747 xLayoutManager
->doLayout();
1750 if ( _eType
!= E_TABLE
&& getContainer()->getDetailView() )
1752 Reference
< XNameAccess
> xContainer
= getElements(_eType
);
1753 addContainerListener(xContainer
);
1754 getContainer()->getDetailView()->createPage(_eType
,xContainer
);
1757 SelectionByElementType::iterator pendingSelection
= m_aPendingSelection
.find( _eType
);
1758 if ( pendingSelection
!= m_aPendingSelection
.end() )
1760 Sequence
< ::rtl::OUString
> aSelected( pendingSelection
->second
.size() );
1761 ::std::copy( pendingSelection
->second
.begin(), pendingSelection
->second
.end(), aSelected
.getArray() );
1762 getContainer()->selectElements( aSelected
);
1764 m_aPendingSelection
.erase( pendingSelection
);
1769 m_eCurrentType
= _eType
;
1773 // -----------------------------------------------------------------------------
1774 bool OApplicationController::onEntryDoubleClick( SvTreeListBox
& _rTree
)
1776 if ( getContainer() && getContainer()->isLeaf( _rTree
.GetHdlEntry() ) )
1781 getContainer()->getQualifiedName( _rTree
.GetHdlEntry() ),
1782 getContainer()->getElementType(),
1785 return true; // handled
1787 catch(const Exception
&)
1789 DBG_UNHANDLED_EXCEPTION();
1792 return false; // not handled
1794 // -----------------------------------------------------------------------------
1795 bool OApplicationController::impl_isAlterableView_nothrow( const ::rtl::OUString
& _rTableOrViewName
) const
1797 OSL_PRECOND( m_xDataSourceConnection
.is(), "OApplicationController::impl_isAlterableView_nothrow: no connection!" );
1799 bool bIsAlterableView( false );
1802 Reference
< XViewsSupplier
> xViewsSupp( m_xDataSourceConnection
, UNO_QUERY
);
1803 Reference
< XNameAccess
> xViews
;
1804 if ( xViewsSupp
.is() )
1805 xViews
= xViewsSupp
->getViews();
1807 Reference
< XAlterView
> xAsAlterableView
;
1808 if ( xViews
.is() && xViews
->hasByName( _rTableOrViewName
) )
1809 xAsAlterableView
.set( xViews
->getByName( _rTableOrViewName
), UNO_QUERY
);
1811 bIsAlterableView
= xAsAlterableView
.is();
1813 catch( const Exception
& )
1815 DBG_UNHANDLED_EXCEPTION();
1817 return bIsAlterableView
;
1820 // -----------------------------------------------------------------------------
1821 Reference
< XComponent
> OApplicationController::openElement(const ::rtl::OUString
& _sName
, ElementType _eType
,
1822 ElementOpenMode _eOpenMode
, sal_uInt16 _nInstigatorCommand
)
1824 return openElementWithArguments( _sName
, _eType
, _eOpenMode
, _nInstigatorCommand
, ::comphelper::NamedValueCollection() );
1827 // -----------------------------------------------------------------------------
1828 Reference
< XComponent
> OApplicationController::openElementWithArguments( const ::rtl::OUString
& _sName
, ElementType _eType
,
1829 ElementOpenMode _eOpenMode
, sal_uInt16 _nInstigatorCommand
, const ::comphelper::NamedValueCollection
& _rAdditionalArguments
)
1831 OSL_PRECOND( getContainer(), "OApplicationController::openElementWithArguments: no view!" );
1832 if ( !getContainer() )
1835 Reference
< XComponent
> xRet
;
1836 if ( _eOpenMode
== E_OPEN_DESIGN
)
1838 // OJ: http://www.openoffice.org/issues/show_bug.cgi?id=30382
1839 getContainer()->showPreview(NULL
);
1842 bool isStandaloneDocument
= false;
1846 if ( _eOpenMode
!= E_OPEN_DESIGN
)
1848 // reports which are opened in a mode other than design are no sub components of our application
1849 // component, but standalone documents.
1850 isStandaloneDocument
= true;
1855 if ( isStandaloneDocument
|| !m_pSubComponentManager
->activateSubFrame( _sName
, _eType
, _eOpenMode
, xRet
) )
1857 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1858 ::std::auto_ptr
< OLinkedDocumentsAccess
> aHelper
= getDocumentsAccess( _eType
);
1859 SAL_WNODEPRECATED_DECLARATIONS_POP
1860 if ( !aHelper
->isConnected() )
1863 Reference
< XComponent
> xDefinition
;
1864 xRet
= aHelper
->open( _sName
, xDefinition
, _eOpenMode
, _rAdditionalArguments
);
1866 if ( !isStandaloneDocument
)
1867 onDocumentOpened( _sName
, _eType
, _eOpenMode
, xRet
, xDefinition
);
1875 if ( !m_pSubComponentManager
->activateSubFrame( _sName
, _eType
, _eOpenMode
, xRet
) )
1877 SharedConnection
xConnection( ensureConnection() );
1878 if ( !xConnection
.is() )
1881 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1882 ::std::auto_ptr
< DatabaseObjectView
> pDesigner
;
1883 SAL_WNODEPRECATED_DECLARATIONS_POP
1884 ::comphelper::NamedValueCollection
aArguments( _rAdditionalArguments
);
1887 if ( _eOpenMode
== E_OPEN_DESIGN
)
1889 bool bAddViewTypeArg
= false;
1891 if ( _eType
== E_TABLE
)
1893 if ( impl_isAlterableView_nothrow( _sName
) )
1895 pDesigner
.reset( new QueryDesigner( getORB(), this, m_aCurrentFrame
.getFrame(), true ) );
1896 bAddViewTypeArg
= true;
1900 pDesigner
.reset( new TableDesigner( getORB(), this, m_aCurrentFrame
.getFrame() ) );
1903 else if ( _eType
== E_QUERY
)
1905 pDesigner
.reset( new QueryDesigner( getORB(), this, m_aCurrentFrame
.getFrame(), false ) );
1906 bAddViewTypeArg
= true;
1908 aDataSource
<<= m_xDataSource
;
1910 if ( bAddViewTypeArg
)
1912 const bool bQueryGraphicalMode
=( _nInstigatorCommand
!= SID_DB_APP_EDIT_SQL_VIEW
);
1913 aArguments
.put( (::rtl::OUString
)PROPERTY_GRAPHICAL_DESIGN
, bQueryGraphicalMode
);
1919 pDesigner
.reset( new ResultSetBrowser( getORB(), this, m_aCurrentFrame
.getFrame(), _eType
== E_TABLE
) );
1921 if ( !aArguments
.has( (::rtl::OUString
)PROPERTY_SHOWMENU
) )
1922 aArguments
.put( (::rtl::OUString
)PROPERTY_SHOWMENU
, makeAny( (sal_Bool
)sal_True
) );
1924 aDataSource
<<= getDatabaseName();
1927 xRet
.set( pDesigner
->openExisting( aDataSource
, _sName
, aArguments
) );
1928 onDocumentOpened( _sName
, _eType
, _eOpenMode
, xRet
, NULL
);
1934 OSL_FAIL( "OApplicationController::openElement: illegal object type!" );
1939 // -----------------------------------------------------------------------------
1940 IMPL_LINK( OApplicationController
, OnSelectContainer
, void*, _pType
)
1942 ElementType eType
= (ElementType
)reinterpret_cast< sal_IntPtr
>( _pType
);
1944 getContainer()->selectContainer(eType
);
1947 // -----------------------------------------------------------------------------
1948 IMPL_LINK( OApplicationController
, OnCreateWithPilot
, void*, _pType
)
1950 ElementType eType
= (ElementType
)reinterpret_cast< sal_IntPtr
>( _pType
);
1951 newElementWithPilot( eType
);
1955 // -----------------------------------------------------------------------------
1956 void OApplicationController::newElementWithPilot( ElementType _eType
)
1958 utl::CloseVeto
aKeepDoc( getFrame() );
1959 // prevent the document being closed while the wizard is open
1961 OSL_ENSURE( getContainer(), "OApplicationController::newElementWithPilot: without a view?" );
1968 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1969 ::std::auto_ptr
<OLinkedDocumentsAccess
> aHelper
= getDocumentsAccess(_eType
);
1970 SAL_WNODEPRECATED_DECLARATIONS_POP
1971 if ( aHelper
->isConnected() )
1973 sal_Int32 nCommandType
= -1;
1974 const ::rtl::OUString
sCurrentSelected( getCurrentlySelectedName( nCommandType
) );
1975 if ( E_REPORT
== _eType
)
1976 aHelper
->newReportWithPilot( nCommandType
, sCurrentSelected
);
1978 aHelper
->newFormWithPilot( nCommandType
, sCurrentSelected
);
1985 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1986 ::std::auto_ptr
<OLinkedDocumentsAccess
> aHelper
= getDocumentsAccess(_eType
);
1987 SAL_WNODEPRECATED_DECLARATIONS_POP
1988 if ( aHelper
->isConnected() )
1990 if ( E_QUERY
== _eType
)
1991 aHelper
->newQueryWithPilot();
1993 aHelper
->newTableWithPilot();
2001 // no need for onDocumentOpened, the table wizard opens the created table by using
2002 // XDatabaseDocumentUI::loadComponent method.
2005 // -----------------------------------------------------------------------------
2006 Reference
< XComponent
> OApplicationController::newElement( ElementType _eType
, const ::comphelper::NamedValueCollection
& i_rAdditionalArguments
,
2007 Reference
< XComponent
>& o_rDocumentDefinition
)
2009 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
2011 Reference
< XComponent
> xComponent
;
2012 o_rDocumentDefinition
.clear();
2019 SAL_WNODEPRECATED_DECLARATIONS_PUSH
2020 ::std::auto_ptr
<OLinkedDocumentsAccess
> aHelper
= getDocumentsAccess( _eType
);
2021 SAL_WNODEPRECATED_DECLARATIONS_POP
2022 if ( !aHelper
->isConnected() )
2025 xComponent
= aHelper
->newDocument( _eType
== E_FORM
? ID_FORM_NEW_TEXT
: ID_REPORT_NEW_TEXT
, i_rAdditionalArguments
, o_rDocumentDefinition
);
2032 SAL_WNODEPRECATED_DECLARATIONS_PUSH
2033 ::std::auto_ptr
< DatabaseObjectView
> pDesigner
;
2034 SAL_WNODEPRECATED_DECLARATIONS_POP
2035 SharedConnection
xConnection( ensureConnection() );
2036 if ( !xConnection
.is() )
2039 if ( _eType
== E_TABLE
)
2041 pDesigner
.reset( new TableDesigner( getORB(), this, getFrame() ) );
2043 else if ( _eType
== E_QUERY
)
2045 pDesigner
.reset( new QueryDesigner( getORB(), this, getFrame(), false ) );
2048 Reference
< XDataSource
> xDataSource( m_xDataSource
, UNO_QUERY
);
2049 xComponent
.set( pDesigner
->createNew( xDataSource
, i_rAdditionalArguments
), UNO_QUERY
);
2054 OSL_FAIL( "OApplicationController::newElement: illegal type!" );
2058 if ( xComponent
.is() )
2059 onDocumentOpened( ::rtl::OUString(), _eType
, E_OPEN_DESIGN
, xComponent
, o_rDocumentDefinition
);
2064 // -----------------------------------------------------------------------------
2065 void OApplicationController::addContainerListener(const Reference
<XNameAccess
>& _xCollection
)
2069 Reference
< XContainer
> xCont(_xCollection
, UNO_QUERY
);
2072 // add as listener to get notified if elements are inserted or removed
2073 TContainerVector::iterator aFind
= ::std::find(m_aCurrentContainers
.begin(),m_aCurrentContainers
.end(),xCont
);
2074 if ( aFind
== m_aCurrentContainers
.end() )
2076 xCont
->addContainerListener(this);
2077 m_aCurrentContainers
.push_back(xCont
);
2081 catch( const Exception
& )
2083 DBG_UNHANDLED_EXCEPTION();
2086 // -----------------------------------------------------------------------------
2087 void OApplicationController::renameEntry()
2089 SolarMutexGuard aSolarGuard
;
2090 ::osl::MutexGuard
aGuard( getMutex() );
2092 OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
2093 ::std::vector
< ::rtl::OUString
> aList
;
2094 getSelectionElementNames(aList
);
2096 Reference
< XNameAccess
> xContainer
= getElements(getContainer()->getElementType());
2097 OSL_ENSURE(aList
.size() == 1,"Invalid rename call here. More than one element!");
2098 if ( aList
.empty() )
2103 if ( xContainer
.is() )
2105 SAL_WNODEPRECATED_DECLARATIONS_PUSH
2106 ::std::auto_ptr
< IObjectNameCheck
> pNameChecker
;
2107 ::std::auto_ptr
< OSaveAsDlg
> aDialog
;
2108 SAL_WNODEPRECATED_DECLARATIONS_POP
2110 Reference
<XRename
> xRename
;
2111 const ElementType eType
= getContainer()->getElementType();
2117 Reference
<XHierarchicalNameContainer
> xHNames(xContainer
, UNO_QUERY
);
2121 if ( eType
== E_FORM
)
2122 sLabel
= String(ModuleRes( STR_FRM_LABEL
));
2124 sLabel
= String(ModuleRes( STR_RPT_LABEL
));
2126 ::rtl::OUString sName
= *aList
.begin();
2127 if ( xHNames
->hasByHierarchicalName(sName
) )
2129 xRename
.set(xHNames
->getByHierarchicalName(sName
),UNO_QUERY
);
2130 Reference
<XChild
> xChild(xRename
,UNO_QUERY
);
2133 Reference
<XHierarchicalNameContainer
> xParent(xChild
->getParent(),UNO_QUERY
);
2137 Reference
<XPropertySet
>(xRename
,UNO_QUERY
)->getPropertyValue(PROPERTY_NAME
) >>= sName
;
2140 pNameChecker
.reset( new HierarchicalNameCheck( xHNames
.get(), String() ) );
2141 aDialog
.reset( new OSaveAsDlg(
2142 getView(), getORB(), sName
, sLabel
, *pNameChecker
, SAD_TITLE_RENAME
) );
2149 if ( !getConnection().is() )
2153 if ( xContainer
->hasByName(*aList
.begin()) )
2155 xRename
.set(xContainer
->getByName(*aList
.begin()),UNO_QUERY
);
2156 sal_Int32 nCommandType
= eType
== E_QUERY
? CommandType::QUERY
: CommandType::TABLE
;
2159 pNameChecker
.reset( new DynamicTableOrQueryNameCheck( getConnection(), nCommandType
) );
2160 aDialog
.reset( new OSaveAsDlg(
2161 getView(), nCommandType
, getORB(), getConnection(),
2162 *aList
.begin(), *pNameChecker
, SAD_TITLE_RENAME
) );
2169 if ( xRename
.is() && aDialog
.get() )
2172 sal_Bool bTryAgain
= sal_True
;
2175 if ( aDialog
->Execute() == RET_OK
)
2179 ::rtl::OUString sNewName
;
2180 if ( eType
== E_TABLE
)
2182 ::rtl::OUString sName
= aDialog
->getName();
2183 ::rtl::OUString sCatalog
= aDialog
->getCatalog();
2184 ::rtl::OUString sSchema
= aDialog
->getSchema();
2186 sNewName
= ::dbtools::composeTableName( m_xMetaData
, sCatalog
, sSchema
, sName
, sal_False
, ::dbtools::eInDataManipulation
);
2189 sNewName
= aDialog
->getName();
2191 ::rtl::OUString sOldName
= *aList
.begin();
2192 if ( eType
== E_FORM
|| eType
== E_REPORT
)
2194 Reference
<XContent
> xContent(xRename
,UNO_QUERY
);
2195 if ( xContent
.is() )
2197 sOldName
= xContent
->getIdentifier()->getContentIdentifier();
2201 xRename
->rename(sNewName
);
2203 if ( eType
== E_TABLE
)
2205 Reference
<XPropertySet
> xProp(xRename
,UNO_QUERY
);
2206 sNewName
= ::dbaui::composeTableName( m_xMetaData
, xProp
, ::dbtools::eInDataManipulation
, false, false, false );
2208 getContainer()->elementReplaced( eType
, sOldName
, sNewName
);
2210 bTryAgain
= sal_False
;
2212 catch(const SQLException
& )
2214 showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
2217 catch(const ElementExistException
& e
)
2219 static ::rtl::OUString sStatus
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000"));
2220 String sMsg
= String( ModuleRes( STR_NAME_ALREADY_EXISTS
) );
2221 sMsg
.SearchAndReplace('#',e
.Message
);
2222 showError(SQLExceptionInfo(SQLException(sMsg
, e
.Context
, sStatus
, 0, Any())));
2224 catch(const Exception
& )
2226 DBG_UNHANDLED_EXCEPTION();
2230 bTryAgain
= sal_False
;
2235 catch(const Exception
& )
2237 DBG_UNHANDLED_EXCEPTION();
2241 // -----------------------------------------------------------------------------
2242 void OApplicationController::onSelectionChanged()
2246 SelectionGuard
aSelGuard( *m_pSelectionNotifier
);
2248 OApplicationView
* pView
= getContainer();
2252 if ( pView
->getSelectionCount() == 1 )
2254 const ElementType eType
= pView
->getElementType();
2255 if ( pView
->isALeafSelected() )
2257 const ::rtl::OUString sName
= pView
->getQualifiedName( NULL
/* means 'first selected' */ );
2258 showPreviewFor( eType
, sName
);
2262 // -----------------------------------------------------------------------------
2263 void OApplicationController::showPreviewFor(const ElementType _eType
,const ::rtl::OUString
& _sName
)
2265 if ( m_ePreviewMode
== E_PREVIEWNONE
)
2268 OApplicationView
* pView
= getContainer();
2279 Reference
< XHierarchicalNameAccess
> xContainer( getElements( _eType
), UNO_QUERY_THROW
);
2280 Reference
< XContent
> xContent( xContainer
->getByHierarchicalName( _sName
), UNO_QUERY_THROW
);
2281 pView
->showPreview( xContent
);
2288 SharedConnection
xConnection( ensureConnection() );
2289 if ( xConnection
.is() )
2290 pView
->showPreview( getDatabaseName(), xConnection
, _sName
, _eType
== E_TABLE
);
2295 OSL_FAIL( "OApplicationController::showPreviewFor: unexpected element type!" );
2299 catch( const SQLException
& )
2301 showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
2303 catch(const Exception
& )
2305 DBG_UNHANDLED_EXCEPTION();
2309 //------------------------------------------------------------------------------
2310 IMPL_LINK_NOARG(OApplicationController
, OnClipboardChanged
)
2312 OnInvalidateClipboard();
2315 //------------------------------------------------------------------------------
2316 void OApplicationController::OnInvalidateClipboard()
2318 InvalidateFeature(ID_BROWSER_CUT
);
2319 InvalidateFeature(ID_BROWSER_COPY
);
2320 InvalidateFeature(ID_BROWSER_PASTE
);
2321 InvalidateFeature(SID_DB_APP_PASTE_SPECIAL
);
2323 // -----------------------------------------------------------------------------
2324 void OApplicationController::onCutEntry()
2327 // -----------------------------------------------------------------------------
2328 void OApplicationController::onCopyEntry()
2330 Execute(ID_BROWSER_COPY
,Sequence
<PropertyValue
>());
2332 // -----------------------------------------------------------------------------
2333 void OApplicationController::onPasteEntry()
2335 Execute(ID_BROWSER_PASTE
,Sequence
<PropertyValue
>());
2337 // -----------------------------------------------------------------------------
2338 void OApplicationController::onDeleteEntry()
2340 ElementType eType
= getContainer()->getElementType();
2345 nId
= SID_DB_APP_TABLE_DELETE
;
2348 nId
= SID_DB_APP_QUERY_DELETE
;
2351 nId
= SID_DB_APP_FORM_DELETE
;
2354 nId
= SID_DB_APP_REPORT_DELETE
;
2357 OSL_FAIL("Invalid ElementType!");
2360 executeChecked(nId
,Sequence
<PropertyValue
>());
2363 // -----------------------------------------------------------------------------
2364 void OApplicationController::executeUnChecked(const URL
& _rCommand
, const Sequence
< PropertyValue
>& aArgs
)
2366 OApplicationController_CBASE::executeUnChecked( _rCommand
, aArgs
);
2369 // -----------------------------------------------------------------------------
2370 void OApplicationController::executeChecked(const URL
& _rCommand
, const Sequence
< PropertyValue
>& aArgs
)
2372 OApplicationController_CBASE::executeChecked( _rCommand
, aArgs
);
2375 // -----------------------------------------------------------------------------
2376 void OApplicationController::executeUnChecked(sal_uInt16 _nCommandId
, const Sequence
< PropertyValue
>& aArgs
)
2378 OApplicationController_CBASE::executeUnChecked( _nCommandId
, aArgs
);
2381 // -----------------------------------------------------------------------------
2382 void OApplicationController::executeChecked(sal_uInt16 _nCommandId
, const Sequence
< PropertyValue
>& aArgs
)
2384 OApplicationController_CBASE::executeChecked( _nCommandId
, aArgs
);
2387 // -----------------------------------------------------------------------------
2388 sal_Bool
OApplicationController::isCommandEnabled(sal_uInt16 _nCommandId
) const
2390 return OApplicationController_CBASE::isCommandEnabled( _nCommandId
);
2393 // -----------------------------------------------------------------------------
2394 sal_Bool
OApplicationController::isCommandEnabled( const ::rtl::OUString
& _rCompleteCommandURL
) const
2396 return OApplicationController_CBASE::isCommandEnabled( _rCompleteCommandURL
);
2399 // -----------------------------------------------------------------------------
2400 sal_uInt16
OApplicationController::registerCommandURL( const ::rtl::OUString
& _rCompleteCommandURL
)
2402 return OApplicationController_CBASE::registerCommandURL( _rCompleteCommandURL
);
2405 // -----------------------------------------------------------------------------
2406 void OApplicationController::notifyHiContrastChanged()
2408 OApplicationController_CBASE::notifyHiContrastChanged();
2411 // -----------------------------------------------------------------------------
2412 Reference
< XController
> OApplicationController::getXController() throw( RuntimeException
)
2414 return OApplicationController_CBASE::getXController();
2417 // -----------------------------------------------------------------------------
2418 bool OApplicationController::interceptUserInput( const NotifyEvent
& _rEvent
)
2420 return OApplicationController_CBASE::interceptUserInput( _rEvent
);
2423 // -----------------------------------------------------------------------------
2424 PopupMenu
* OApplicationController::getContextMenu( Control
& /*_rControl*/ ) const
2426 return new PopupMenu( ModuleRes( RID_MENU_APP_EDIT
) );
2429 // -----------------------------------------------------------------------------
2430 IController
& OApplicationController::getCommandController()
2432 return *static_cast< IApplicationController
* >( this );
2435 // -----------------------------------------------------------------------------
2436 ::cppu::OInterfaceContainerHelper
* OApplicationController::getContextMenuInterceptors()
2438 return &m_aContextMenuInterceptors
;
2441 // -----------------------------------------------------------------------------
2442 Any
OApplicationController::getCurrentSelection( Control
& _rControl
) const
2444 Sequence
< NamedDatabaseObject
> aSelection
;
2445 getContainer()->describeCurrentSelectionForControl( _rControl
, aSelection
);
2446 return makeAny( aSelection
);
2449 // -----------------------------------------------------------------------------
2450 sal_Bool
OApplicationController::requestQuickHelp( const SvLBoxEntry
* /*_pEntry*/, String
& /*_rText*/ ) const
2455 // -----------------------------------------------------------------------------
2456 sal_Bool
OApplicationController::requestDrag( sal_Int8
/*_nAction*/, const Point
& /*_rPosPixel*/ )
2458 TransferableHelper
* pTransfer
= NULL
;
2459 if ( getContainer() && getContainer()->getSelectionCount() )
2463 pTransfer
= copyObject( );
2464 Reference
< XTransferable
> xEnsureDelete
= pTransfer
;
2466 if ( pTransfer
&& getContainer()->getDetailView() )
2468 ElementType eType
= getContainer()->getElementType();
2469 pTransfer
->StartDrag( getContainer()->getDetailView()->getTreeWindow(), ((eType
== E_FORM
|| eType
== E_REPORT
) ? DND_ACTION_COPYMOVE
: DND_ACTION_COPY
) );
2472 catch(const Exception
& )
2474 DBG_UNHANDLED_EXCEPTION();
2478 return NULL
!= pTransfer
;
2480 // -----------------------------------------------------------------------------
2481 sal_Int8
OApplicationController::queryDrop( const AcceptDropEvent
& _rEvt
, const DataFlavorExVector
& _rFlavors
)
2483 sal_Int8 nActionAskedFor
= _rEvt
.mnAction
;
2484 // check if we're a table or query container
2485 OApplicationView
* pView
= getContainer();
2486 if ( pView
&& !isDataSourceReadOnly() )
2488 ElementType eType
= pView
->getElementType();
2489 if ( eType
!= E_NONE
&& (eType
!= E_TABLE
|| !isConnectionReadOnly()) )
2491 // check for the concrete type
2492 if(::std::find_if(_rFlavors
.begin(),_rFlavors
.end(),TAppSupportedSotFunctor(eType
,sal_True
)) != _rFlavors
.end())
2493 return DND_ACTION_COPY
;
2494 if ( eType
== E_FORM
|| eType
== E_REPORT
)
2496 sal_Int8 nAction
= OComponentTransferable::canExtractComponentDescriptor(_rFlavors
,eType
== E_FORM
) ? DND_ACTION_COPY
: DND_ACTION_NONE
;
2497 if ( nAction
!= DND_ACTION_NONE
)
2499 SvLBoxEntry
* pHitEntry
= pView
->getEntry(_rEvt
.maPosPixel
);
2500 ::rtl::OUString sName
;
2503 sName
= pView
->getQualifiedName( pHitEntry
);
2504 if ( !sName
.isEmpty() )
2506 Reference
< XHierarchicalNameAccess
> xContainer(getElements(pView
->getElementType()),UNO_QUERY
);
2507 if ( xContainer
.is() && xContainer
->hasByHierarchicalName(sName
) )
2509 Reference
< XHierarchicalNameAccess
> xHitObject(xContainer
->getByHierarchicalName(sName
),UNO_QUERY
);
2510 if ( xHitObject
.is() )
2511 nAction
= nActionAskedFor
& DND_ACTION_COPYMOVE
;
2514 nAction
= DND_ACTION_NONE
;
2523 return DND_ACTION_NONE
;
2525 // -----------------------------------------------------------------------------
2526 sal_Int8
OApplicationController::executeDrop( const ExecuteDropEvent
& _rEvt
)
2528 OApplicationView
* pView
= getContainer();
2529 if ( !pView
|| pView
->getElementType() == E_NONE
)
2531 OSL_FAIL("OApplicationController::executeDrop: what the hell did queryDrop do?");
2532 // queryDrop shoud not have allowed us to reach this situation ....
2533 return DND_ACTION_NONE
;
2536 // a TransferableDataHelper for accessing the dropped data
2537 TransferableDataHelper
aDroppedData(_rEvt
.maDropEvent
.Transferable
);
2540 // reset the data of the previous async drop (if any)
2542 Application::RemoveUserEvent(m_nAsyncDrop
);
2546 m_aAsyncDrop
.aDroppedData
.clear();
2547 m_aAsyncDrop
.nType
= pView
->getElementType();
2548 m_aAsyncDrop
.nAction
= _rEvt
.mnAction
;
2549 m_aAsyncDrop
.bError
= sal_False
;
2550 m_aAsyncDrop
.bHtml
= sal_False
;
2551 m_aAsyncDrop
.aUrl
= ::rtl::OUString();
2554 // loop through the available formats and see what we can do ...
2555 // first we have to check if it is our own format, if not we have to copy the stream :-(
2556 if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(aDroppedData
.GetDataFlavorExVector()) )
2558 m_aAsyncDrop
.aDroppedData
= ODataAccessObjectTransferable::extractObjectDescriptor(aDroppedData
);
2560 // asyncron because we some dialogs and we aren't allowed to show them while in D&D
2561 m_nAsyncDrop
= Application::PostUserEvent(LINK(this, OApplicationController
, OnAsyncDrop
));
2562 return DND_ACTION_COPY
;
2564 else if ( OComponentTransferable::canExtractComponentDescriptor(aDroppedData
.GetDataFlavorExVector(),m_aAsyncDrop
.nType
== E_FORM
) )
2566 m_aAsyncDrop
.aDroppedData
= OComponentTransferable::extractComponentDescriptor(aDroppedData
);
2567 SvLBoxEntry
* pHitEntry
= pView
->getEntry(_rEvt
.maPosPixel
);
2569 m_aAsyncDrop
.aUrl
= pView
->getQualifiedName( pHitEntry
);
2571 sal_Int8 nAction
= _rEvt
.mnAction
;
2572 Reference
<XContent
> xContent
;
2573 m_aAsyncDrop
.aDroppedData
[daComponent
] >>= xContent
;
2574 if ( xContent
.is() )
2576 ::rtl::OUString sName
= xContent
->getIdentifier()->getContentIdentifier();
2577 sal_Int32 nIndex
= 0;
2578 sName
= sName
.copy(sName
.getToken(0,'/',nIndex
).getLength() + 1);
2579 if ( m_aAsyncDrop
.aUrl
.Len() >= sName
.getLength() && 0 == sName
.compareTo(m_aAsyncDrop
.aUrl
,sName
.getLength()) )
2581 m_aAsyncDrop
.aDroppedData
.clear();
2582 return DND_ACTION_NONE
;
2585 // check if move is allowed, if another object with the same name exists only copy is allowed
2586 Reference
< XHierarchicalNameAccess
> xContainer(getElements(m_aAsyncDrop
.nType
),UNO_QUERY
);
2587 Reference
<XNameAccess
> xNameAccess(xContainer
,UNO_QUERY
);
2589 if ( m_aAsyncDrop
.aUrl
.Len() && xContainer
.is() && xContainer
->hasByHierarchicalName(m_aAsyncDrop
.aUrl
) )
2590 xNameAccess
.set(xContainer
->getByHierarchicalName(m_aAsyncDrop
.aUrl
),UNO_QUERY
);
2592 if ( xNameAccess
.is() )
2594 Reference
<XPropertySet
> xProp(xContent
,UNO_QUERY
);
2597 xProp
->getPropertyValue(PROPERTY_NAME
) >>= sName
;
2598 if ( xNameAccess
.is() && xNameAccess
->hasByName(sName
) )
2599 nAction
&= ~DND_ACTION_MOVE
;
2602 nAction
&= ~DND_ACTION_MOVE
;
2605 if ( nAction
!= DND_ACTION_NONE
)
2607 m_aAsyncDrop
.nAction
= nAction
;
2608 // asyncron because we some dialogs and we aren't allowed to show them while in D&D
2609 m_nAsyncDrop
= Application::PostUserEvent(LINK(this, OApplicationController
, OnAsyncDrop
));
2612 m_aAsyncDrop
.aDroppedData
.clear();
2617 SharedConnection
xConnection( ensureConnection() );
2618 if ( xConnection
.is() && m_aTableCopyHelper
.copyTagTable( aDroppedData
, m_aAsyncDrop
, xConnection
) )
2620 // asyncron because we some dialogs and we aren't allowed to show them while in D&D
2621 m_nAsyncDrop
= Application::PostUserEvent(LINK(this, OApplicationController
, OnAsyncDrop
));
2622 return DND_ACTION_COPY
;
2626 return DND_ACTION_NONE
;
2628 // -----------------------------------------------------------------------------
2629 Reference
< XModel
> SAL_CALL
OApplicationController::getModel(void) throw( RuntimeException
)
2634 // -----------------------------------------------------------------------------
2635 void OApplicationController::onAttachedFrame()
2637 sal_Int32
nConnectedControllers( 0 );
2640 Reference
< XModel2
> xModel( m_xModel
, UNO_QUERY_THROW
);
2641 Reference
< XEnumeration
> xEnumControllers( xModel
->getControllers(), UNO_SET_THROW
);
2642 while ( xEnumControllers
->hasMoreElements() )
2644 Reference
< XController
> xController( xEnumControllers
->nextElement(), UNO_QUERY_THROW
);
2645 ++nConnectedControllers
;
2648 catch( const Exception
& )
2650 DBG_UNHANDLED_EXCEPTION();
2653 if ( nConnectedControllers
> 1 )
2654 { // we are not the first connected controller, there were already others
2658 m_aControllerConnectedEvent
.Call();
2661 // -----------------------------------------------------------------------------
2662 IMPL_LINK( OApplicationController
, OnFirstControllerConnected
, void*, /**/ )
2664 ::osl::MutexGuard
aGuard( getMutex() );
2666 if ( !m_xModel
.is() )
2668 OSL_FAIL( "OApplicationController::OnFirstControllerConnected: too late!" );
2671 // if we have forms or reports which contain macros/scripts, then show a warning
2672 // which suggests the user to migrate them to the database document
2673 Reference
< XEmbeddedScripts
> xDocumentScripts( m_xModel
, UNO_QUERY
);
2674 if ( xDocumentScripts
.is() )
2676 // no need to show this warning, obviously the document supports embedding scripts
2677 // into itself, so there are no "old-style" forms/reports which have macros/scripts
2684 // If the migration just happened, but was not successful, the document is reloaded.
2685 // In this case, we should not show the warning, again.
2686 ::comphelper::NamedValueCollection
aModelArgs( m_xModel
->getArgs() );
2687 if ( aModelArgs
.getOrDefault( "SuppressMigrationWarning", sal_False
) )
2690 // also, if the document is read-only, then no migration is possible, and the
2691 // respective menu entry is hidden. So, don't show the warning in this case, too.
2692 if ( Reference
< XStorable
>( m_xModel
, UNO_QUERY_THROW
)->isReadonly() )
2695 SQLWarning aWarning
;
2696 aWarning
.Message
= String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS
) );
2697 SQLException aDetail
;
2698 aDetail
.Message
= String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS_DETAIL
) );
2699 aWarning
.NextException
<<= aDetail
;
2701 ::comphelper::ComponentContext
aContext( getORB() );
2702 Sequence
< Any
> aArgs(1);
2703 aArgs
[0] <<= NamedValue( PROPERTY_SQLEXCEPTION
, makeAny( aWarning
) );
2704 Reference
< XExecutableDialog
> xDialog(
2705 aContext
.createComponentWithArguments( "com.sun.star.sdb.ErrorMessageDialog", aArgs
),
2709 catch( const Exception
& )
2711 DBG_UNHANDLED_EXCEPTION();
2717 // -----------------------------------------------------------------------------
2718 void SAL_CALL
OApplicationController::attachFrame( const Reference
< XFrame
> & i_rxFrame
) throw( RuntimeException
)
2720 OApplicationController_CBASE::attachFrame( i_rxFrame
);
2721 if ( getFrame().is() )
2725 // -----------------------------------------------------------------------------
2726 sal_Bool SAL_CALL
OApplicationController::attachModel(const Reference
< XModel
> & _rxModel
) throw( RuntimeException
)
2728 ::osl::MutexGuard
aGuard( getMutex() );
2729 const Reference
< XOfficeDatabaseDocument
> xOfficeDoc( _rxModel
, UNO_QUERY
);
2730 const Reference
< XModifiable
> xDocModify( _rxModel
, UNO_QUERY
);
2731 if ( ( !xOfficeDoc
.is() || !xDocModify
.is() ) && _rxModel
.is() )
2733 OSL_FAIL( "OApplicationController::attachModel: invalid model!" );
2737 if ( m_xModel
.is() && ( m_xModel
!= _rxModel
) && ( _rxModel
.is() ) )
2739 OSL_ENSURE( false, "OApplicationController::attachModel: missing implementation: setting a new model while we have another one!" );
2740 // we'd need to completely update our view here, close sub components, and the like
2744 const ::rtl::OUString aPropertyNames
[] =
2746 PROPERTY_URL
, PROPERTY_USER
2749 // disconnect from old model
2752 if ( m_xDataSource
.is() )
2754 for ( size_t i
=0; i
< sizeof( aPropertyNames
) / sizeof( aPropertyNames
[0] ); ++i
)
2756 m_xDataSource
->removePropertyChangeListener( aPropertyNames
[i
], this );
2760 Reference
< XModifyBroadcaster
> xBroadcaster( m_xModel
, UNO_QUERY
);
2761 if ( xBroadcaster
.is() )
2762 xBroadcaster
->removeModifyListener( this );
2764 catch( const Exception
& )
2766 DBG_UNHANDLED_EXCEPTION();
2769 m_xModel
= _rxModel
;
2770 m_xDocumentModify
= xDocModify
;
2771 m_xDataSource
.set( xOfficeDoc
.is() ? xOfficeDoc
->getDataSource() : Reference
< XDataSource
>(), UNO_QUERY
);
2773 // connect to new model
2776 if ( m_xDataSource
.is() )
2778 for ( size_t i
=0; i
< sizeof( aPropertyNames
) / sizeof( aPropertyNames
[0] ); ++i
)
2780 m_xDataSource
->addPropertyChangeListener( aPropertyNames
[i
], this );
2784 Reference
< XModifyBroadcaster
> xBroadcaster( m_xModel
, UNO_QUERY_THROW
);
2785 xBroadcaster
->addModifyListener( this );
2788 catch( const Exception
& )
2790 DBG_UNHANDLED_EXCEPTION();
2793 // initial preview mode
2794 if ( m_xDataSource
.is() )
2798 // to get the 'modified' for the data source
2799 ::comphelper::NamedValueCollection
aLayoutInfo( m_xDataSource
->getPropertyValue( PROPERTY_LAYOUTINFORMATION
) );
2800 if ( aLayoutInfo
.has( (rtl::OUString
)INFO_PREVIEW
) )
2802 const sal_Int32
nPreviewMode( aLayoutInfo
.getOrDefault( (rtl::OUString
)INFO_PREVIEW
, (sal_Int32
)0 ) );
2803 m_ePreviewMode
= static_cast< PreviewMode
>( nPreviewMode
);
2805 getContainer()->switchPreview( m_ePreviewMode
);
2808 catch( const Exception
& )
2810 DBG_UNHANDLED_EXCEPTION();
2816 // -----------------------------------------------------------------------------
2817 void OApplicationController::containerFound( const Reference
< XContainer
>& _xContainer
)
2821 if ( _xContainer
.is() )
2823 m_aCurrentContainers
.push_back(_xContainer
);
2824 _xContainer
->addContainerListener(this);
2827 catch(const Exception
&)
2829 DBG_UNHANDLED_EXCEPTION();
2832 // -----------------------------------------------------------------------------
2833 ::rtl::OUString
OApplicationController::getCurrentlySelectedName(sal_Int32
& _rnCommandType
) const
2835 _rnCommandType
= ( (getContainer()->getElementType() == E_QUERY
)
2836 ? CommandType::QUERY
: ( (getContainer()->getElementType() == E_TABLE
) ? CommandType::TABLE
: -1 ));
2839 ::rtl::OUString sName
;
2840 if ( _rnCommandType
!= -1 )
2844 sName
= getContainer()->getQualifiedName( NULL
);
2845 OSL_ENSURE( !sName
.isEmpty(), "OApplicationController::getCurrentlySelectedName: no name given!" );
2847 catch( const Exception
& )
2849 DBG_UNHANDLED_EXCEPTION();
2855 // -----------------------------------------------------------------------------
2856 void SAL_CALL
OApplicationController::addSelectionChangeListener( const Reference
< view::XSelectionChangeListener
>& _Listener
) throw (RuntimeException
)
2858 m_pSelectionNotifier
->addListener( _Listener
);
2861 // -----------------------------------------------------------------------------
2862 void SAL_CALL
OApplicationController::removeSelectionChangeListener( const Reference
< view::XSelectionChangeListener
>& _Listener
) throw (RuntimeException
)
2864 m_pSelectionNotifier
->removeListener( _Listener
);
2867 // -----------------------------------------------------------------------------
2868 ::sal_Bool SAL_CALL
OApplicationController::select( const Any
& _aSelection
) throw (IllegalArgumentException
, RuntimeException
)
2870 SolarMutexGuard aSolarGuard
;
2871 ::osl::MutexGuard
aGuard( getMutex() );
2872 Sequence
< ::rtl::OUString
> aSelection
;
2873 if ( !_aSelection
.hasValue() || !getView() )
2875 getContainer()->selectElements(aSelection
);
2879 // --------------------------------------------------------------
2880 // BEGIN compatibility
2881 Sequence
< NamedValue
> aCurrentSelection
;
2882 if ( (_aSelection
>>= aCurrentSelection
) && aCurrentSelection
.getLength() )
2884 ElementType eType
= E_NONE
;
2885 const NamedValue
* pIter
= aCurrentSelection
.getConstArray();
2886 const NamedValue
* pEnd
= pIter
+ aCurrentSelection
.getLength();
2887 for(;pIter
!= pEnd
;++pIter
)
2889 if ( pIter
->Name
== "Type" )
2891 sal_Int32 nType
= 0;
2892 pIter
->Value
>>= nType
;
2893 if ( nType
< DatabaseObject::TABLE
|| nType
> DatabaseObject::REPORT
)
2894 throw IllegalArgumentException();
2895 eType
= static_cast< ElementType
>( nType
);
2897 else if ( pIter
->Name
== "Selection" )
2898 pIter
->Value
>>= aSelection
;
2901 m_aSelectContainerEvent
.CancelCall(); // just in case the async select request was running
2902 getContainer()->selectContainer(eType
);
2903 getContainer()->selectElements(aSelection
);
2906 // END compatibility
2907 // --------------------------------------------------------------
2909 Sequence
< NamedDatabaseObject
> aSelectedObjects
;
2910 if ( !( _aSelection
>>= aSelectedObjects
) )
2912 aSelectedObjects
.realloc( 1 );
2913 if ( !( _aSelection
>>= aSelectedObjects
[0] ) )
2914 throw IllegalArgumentException();
2917 SelectionByElementType aSelectedElements
;
2918 ElementType eSelectedCategory
= E_NONE
;
2919 for ( const NamedDatabaseObject
* pObject
= aSelectedObjects
.getConstArray();
2920 pObject
!= aSelectedObjects
.getConstArray() + aSelectedObjects
.getLength();
2924 switch ( pObject
->Type
)
2926 case DatabaseObject::TABLE
:
2927 case DatabaseObjectContainer::SCHEMA
:
2928 case DatabaseObjectContainer::CATALOG
:
2929 aSelectedElements
[ E_TABLE
].push_back( pObject
->Name
);
2931 case DatabaseObject::QUERY
:
2932 aSelectedElements
[ E_QUERY
].push_back( pObject
->Name
);
2934 case DatabaseObject::FORM
:
2935 case DatabaseObjectContainer::FORMS_FOLDER
:
2936 aSelectedElements
[ E_FORM
].push_back( pObject
->Name
);
2938 case DatabaseObject::REPORT
:
2939 case DatabaseObjectContainer::REPORTS_FOLDER
:
2940 aSelectedElements
[ E_REPORT
].push_back( pObject
->Name
);
2942 case DatabaseObjectContainer::TABLES
:
2943 case DatabaseObjectContainer::QUERIES
:
2944 case DatabaseObjectContainer::FORMS
:
2945 case DatabaseObjectContainer::REPORTS
:
2946 if ( eSelectedCategory
!= E_NONE
)
2947 throw IllegalArgumentException(
2948 String(ModuleRes(RID_STR_NO_DIFF_CAT
)),
2949 *this, sal_Int16( pObject
- aSelectedObjects
.getConstArray() ) );
2951 ( pObject
->Type
== DatabaseObjectContainer::TABLES
) ? E_TABLE
2952 : ( pObject
->Type
== DatabaseObjectContainer::QUERIES
) ? E_QUERY
2953 : ( pObject
->Type
== DatabaseObjectContainer::FORMS
) ? E_FORM
2954 : ( pObject
->Type
== DatabaseObjectContainer::REPORTS
) ? E_REPORT
2959 case DatabaseObjectContainer::DATA_SOURCE
:
2961 ::rtl::OUString
sMessage(
2963 String(ModuleRes(RID_STR_UNSUPPORTED_OBJECT_TYPE
))).
2964 replaceFirst("$type$", ::rtl::OUString::valueOf(sal_Int32(pObject
->Type
))));
2965 throw IllegalArgumentException(sMessage
, *this, sal_Int16( pObject
- aSelectedObjects
.getConstArray() ));
2970 for ( SelectionByElementType::const_iterator sel
= aSelectedElements
.begin();
2971 sel
!= aSelectedElements
.end();
2975 if ( sel
->first
== m_eCurrentType
)
2977 Sequence
< ::rtl::OUString
> aSelected( sel
->second
.size() );
2978 ::std::copy( sel
->second
.begin(), sel
->second
.end(), aSelected
.getArray() );
2979 getContainer()->selectElements( aSelected
);
2983 m_aPendingSelection
[ sel
->first
] = sel
->second
;
2987 m_aSelectContainerEvent
.CancelCall(); // just in case the async select request was running
2988 getContainer()->selectContainer( eSelectedCategory
);
2992 // -----------------------------------------------------------------------------
2993 Any SAL_CALL
OApplicationController::getSelection( ) throw (RuntimeException
)
2995 SolarMutexGuard aSolarGuard
;
2996 ::osl::MutexGuard
aGuard( getMutex() );
2998 Sequence
< NamedDatabaseObject
> aCurrentSelection
;
2999 const ElementType
eType( getContainer()->getElementType() );
3000 if ( eType
!= E_NONE
)
3002 getContainer()->describeCurrentSelectionForType( eType
, aCurrentSelection
);
3003 if ( aCurrentSelection
.getLength() == 0 )
3004 { // if no objects are selected, add an entry to the sequence which describes the overall category
3005 // which is selected currently
3006 aCurrentSelection
.realloc(1);
3007 aCurrentSelection
[0].Name
= getDatabaseName();
3010 case E_TABLE
: aCurrentSelection
[0].Type
= DatabaseObjectContainer::TABLES
; break;
3011 case E_QUERY
: aCurrentSelection
[0].Type
= DatabaseObjectContainer::QUERIES
; break;
3012 case E_FORM
: aCurrentSelection
[0].Type
= DatabaseObjectContainer::FORMS
; break;
3013 case E_REPORT
: aCurrentSelection
[0].Type
= DatabaseObjectContainer::REPORTS
; break;
3015 OSL_FAIL( "OApplicationController::getSelection: unexpected current element type!" );
3020 return makeAny( aCurrentSelection
);
3022 // -----------------------------------------------------------------------------
3023 void OApplicationController::impl_migrateScripts_nothrow()
3027 ::rtl::OUString
sDialogService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.application.MacroMigrationWizard" ) );
3028 ::comphelper::ComponentContext
aContext( getORB() );
3029 Sequence
< Any
> aDialogArgs(1);
3030 aDialogArgs
[0] <<= Reference
< XOfficeDatabaseDocument
>( m_xModel
, UNO_QUERY_THROW
);
3031 Reference
< XExecutableDialog
> xDialog(
3032 aContext
.createComponentWithArguments( sDialogService
, aDialogArgs
),
3035 if ( !xDialog
.is() )
3037 ShowServiceNotAvailableError( getView(), sDialogService
, true );
3043 catch( const Exception
& )
3045 DBG_UNHANDLED_EXCEPTION();
3049 //........................................................................
3050 } // namespace dbaui
3051 //........................................................................
3053 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */