Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "AppController.hxx"
22 : #include "dbustrings.hrc"
23 : #include "advancedsettingsdlg.hxx"
24 : #include "subcomponentmanager.hxx"
25 :
26 : #include <com/sun/star/beans/NamedValue.hpp>
27 : #include <com/sun/star/container/XChild.hpp>
28 : #include <com/sun/star/container/XContainer.hpp>
29 : #include <com/sun/star/container/XContentEnumerationAccess.hpp>
30 : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
31 : #include <com/sun/star/container/XHierarchicalNameContainer.hpp>
32 : #include <com/sun/star/container/XNameContainer.hpp>
33 : #include <com/sun/star/frame/FrameSearchFlag.hpp>
34 : #include <com/sun/star/frame/XStorable.hpp>
35 : #include <com/sun/star/sdb/CommandType.hpp>
36 : #include <com/sun/star/sdb/ErrorMessageDialog.hpp>
37 : #include <com/sun/star/sdb/SQLContext.hpp>
38 : #include <com/sun/star/sdb/XBookmarksSupplier.hpp>
39 : #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
40 : #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
41 : #include <com/sun/star/sdbc/XDataSource.hpp>
42 : #include <com/sun/star/sdbcx/XAlterView.hpp>
43 : #include <com/sun/star/sdbcx/XAppend.hpp>
44 : #include <com/sun/star/sdbcx/XRename.hpp>
45 : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
46 : #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
47 : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
48 : #include <com/sun/star/uno/XNamingService.hpp>
49 : #include <com/sun/star/util/XFlushable.hpp>
50 : #include <com/sun/star/util/XModifiable.hpp>
51 : #include <com/sun/star/util/XModifyBroadcaster.hpp>
52 : #include <com/sun/star/util/XNumberFormatter.hpp>
53 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
54 : #include <com/sun/star/document/XEmbeddedScripts.hpp>
55 : #include <com/sun/star/frame/XModel2.hpp>
56 : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
57 : #include "com/sun/star/beans/NamedValue.hpp"
58 : #include <com/sun/star/awt/XTopWindow.hpp>
59 : #include <com/sun/star/task/XInteractionHandler.hpp>
60 : #include <com/sun/star/sdb/application/DatabaseObject.hpp>
61 : #include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
62 : #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
63 : #include <com/sun/star/container/XHierarchicalName.hpp>
64 : #include <tools/diagnose_ex.h>
65 : #include <osl/diagnose.h>
66 : #include <tools/string.hxx>
67 :
68 : #include <svl/urihelper.hxx>
69 : #include <svl/filenotation.hxx>
70 : #include <svtools/treelistbox.hxx>
71 : #include <svtools/transfer.hxx>
72 : #include <svtools/cliplistener.hxx>
73 : #include <svtools/svlbitm.hxx>
74 : #include <svtools/insdlg.hxx>
75 :
76 : #include <comphelper/sequence.hxx>
77 : #include <comphelper/uno3.hxx>
78 : #include <comphelper/types.hxx>
79 : #include <comphelper/interaction.hxx>
80 : #include <comphelper/componentcontext.hxx>
81 : #include <comphelper/processfactory.hxx>
82 :
83 : #include <vcl/msgbox.hxx>
84 : #include <vcl/stdtext.hxx>
85 : #include <vcl/svapp.hxx>
86 : #include <vcl/menu.hxx>
87 : #include <vcl/lstbox.hxx>
88 :
89 : #include <unotools/closeveto.hxx>
90 : #include <unotools/pathoptions.hxx>
91 : #include <unotools/tempfile.hxx>
92 : #include <unotools/internaloptions.hxx>
93 : #include <unotools/moduleoptions.hxx>
94 : #include <unotools/historyoptions.hxx>
95 :
96 : #include <sfx2/mailmodelapi.hxx>
97 : #include <sfx2/filedlghelper.hxx>
98 : #include <sfx2/docfilt.hxx>
99 : #include <sfx2/QuerySaveDocument.hxx>
100 :
101 : #include <cppuhelper/typeprovider.hxx>
102 : #include <cppuhelper/exc_hlp.hxx>
103 :
104 : #include <connectivity/dbtools.hxx>
105 : #include <connectivity/dbexception.hxx>
106 :
107 : #include <svx/dbaexchange.hxx>
108 : #include <svx/dbaobjectex.hxx>
109 : #include <svx/svxdlg.hxx>
110 :
111 : #include <osl/mutex.hxx>
112 : #include "AppView.hxx"
113 : #include "browserids.hxx"
114 : #include "dbu_reghelper.hxx"
115 : #include "dbu_app.hrc"
116 : #include "defaultobjectnamecheck.hxx"
117 : #include "databaseobjectview.hxx"
118 : #include "listviewitems.hxx"
119 : #include "AppDetailView.hxx"
120 : #include "linkeddocuments.hxx"
121 : #include "sqlmessage.hxx"
122 : #include "UITools.hxx"
123 : #include "dsntypes.hxx"
124 : #include "dbaccess_helpid.hrc"
125 : #include "dlgsave.hxx"
126 : #include "dbaccess_slotid.hrc"
127 :
128 : #include <algorithm>
129 : #include <functional>
130 :
131 : #include <boost/noncopyable.hpp>
132 :
133 0 : extern "C" void SAL_CALL createRegistryInfo_ODBApplication()
134 : {
135 0 : static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OApplicationController > aAutoRegistration;
136 0 : }
137 : //........................................................................
138 : namespace dbaui
139 : {
140 : //........................................................................
141 : using namespace ::dbtools;
142 : using namespace ::svx;
143 : using namespace ::com::sun::star;
144 : using namespace ::com::sun::star::uno;
145 : using namespace ::com::sun::star::ucb;
146 : using namespace ::com::sun::star::view;
147 : using namespace ::com::sun::star::util;
148 : using namespace ::com::sun::star::beans;
149 : using namespace ::com::sun::star::lang;
150 : using namespace ::com::sun::star::frame;
151 : using namespace ::com::sun::star::container;
152 : using namespace ::com::sun::star::sdb;
153 : using namespace ::com::sun::star::sdbc;
154 : using namespace ::com::sun::star::sdbcx;
155 : using namespace ::com::sun::star::datatransfer;
156 : using namespace ::com::sun::star::ui::dialogs;
157 : using namespace ::com::sun::star::task;
158 : using ::com::sun::star::document::XEmbeddedScripts;
159 : using ::com::sun::star::document::XDocumentEventBroadcaster;
160 : using ::com::sun::star::document::DocumentEvent;
161 : using ::com::sun::star::sdb::application::NamedDatabaseObject;
162 :
163 : namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
164 : namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
165 :
166 : //------------------------------------------------------------------------------
167 0 : ::rtl::OUString SAL_CALL OApplicationController::getImplementationName() throw( RuntimeException )
168 : {
169 0 : return getImplementationName_Static();
170 : }
171 :
172 : //------------------------------------------------------------------------------
173 0 : ::rtl::OUString OApplicationController::getImplementationName_Static() throw( RuntimeException )
174 : {
175 0 : return ::rtl::OUString(SERVICE_SDB_APPLICATIONCONTROLLER);
176 : }
177 : //------------------------------------------------------------------------------
178 0 : Sequence< ::rtl::OUString> OApplicationController::getSupportedServiceNames_Static(void) throw( RuntimeException )
179 : {
180 0 : Sequence< ::rtl::OUString> aSupported(1);
181 0 : aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.application.DefaultViewController"));
182 0 : return aSupported;
183 : }
184 : //-------------------------------------------------------------------------
185 0 : Sequence< ::rtl::OUString> SAL_CALL OApplicationController::getSupportedServiceNames() throw(RuntimeException)
186 : {
187 0 : return getSupportedServiceNames_Static();
188 : }
189 : // -------------------------------------------------------------------------
190 0 : Reference< XInterface > SAL_CALL OApplicationController::Create(const Reference<XMultiServiceFactory >& _rxFactory)
191 : {
192 0 : return *(new OApplicationController(_rxFactory));
193 : }
194 : // -----------------------------------------------------------------------------
195 :
196 0 : struct XContainerFunctor : public ::std::unary_function< OApplicationController::TContainerVector::value_type , bool>
197 : {
198 : Reference<XContainerListener> m_xContainerListener;
199 0 : XContainerFunctor( const Reference<XContainerListener>& _xContainerListener)
200 0 : : m_xContainerListener(_xContainerListener){}
201 :
202 0 : bool operator() (const OApplicationController::TContainerVector::value_type& lhs) const
203 : {
204 0 : if ( lhs.is() )
205 0 : lhs->removeContainerListener(m_xContainerListener);
206 0 : return true;
207 : }
208 : };
209 :
210 : //====================================================================
211 : //= OApplicationController
212 : //====================================================================
213 : class SelectionNotifier : public ::boost::noncopyable
214 : {
215 : private:
216 : ::cppu::OInterfaceContainerHelper m_aSelectionListeners;
217 : ::cppu::OWeakObject& m_rContext;
218 : sal_Int32 m_nSelectionNestingLevel;
219 :
220 : public:
221 0 : SelectionNotifier( ::osl::Mutex& _rMutex, ::cppu::OWeakObject& _rContext )
222 : :m_aSelectionListeners( _rMutex )
223 : ,m_rContext( _rContext )
224 0 : ,m_nSelectionNestingLevel( 0 )
225 : {
226 0 : }
227 :
228 0 : void addListener( const Reference< XSelectionChangeListener >& _Listener )
229 : {
230 0 : m_aSelectionListeners.addInterface( _Listener );
231 0 : }
232 :
233 0 : void removeListener( const Reference< XSelectionChangeListener >& _Listener )
234 : {
235 0 : m_aSelectionListeners.removeInterface( _Listener );
236 0 : }
237 :
238 0 : void disposing()
239 : {
240 0 : EventObject aEvent( m_rContext );
241 0 : m_aSelectionListeners.disposeAndClear( aEvent );
242 0 : }
243 :
244 0 : ~SelectionNotifier()
245 0 : {
246 0 : }
247 :
248 0 : struct SelectionGuardAccess { friend class SelectionGuard; private: SelectionGuardAccess() { } };
249 :
250 : /** enters a block which modifies the selection of our owner.
251 :
252 : Can be called multiple times, the only important thing is to call leaveSelection
253 : equally often.
254 : */
255 0 : void enterSelection( SelectionGuardAccess )
256 : {
257 0 : ++m_nSelectionNestingLevel;
258 0 : }
259 :
260 : /** leaves a block which modifies the selection of our owner
261 :
262 : Must be paired with enterSelection calls.
263 :
264 : When the last block is left, i.e. the last leaveSelection call is made on the current stack,
265 : then our SelectionChangeListeners are notified
266 : */
267 0 : void leaveSelection( SelectionGuardAccess )
268 : {
269 0 : if ( --m_nSelectionNestingLevel == 0 )
270 : {
271 0 : EventObject aEvent( m_rContext );
272 0 : m_aSelectionListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvent );
273 : }
274 0 : }
275 : };
276 :
277 : class SelectionGuard : public ::boost::noncopyable
278 : {
279 : public:
280 0 : SelectionGuard( SelectionNotifier& _rNotifier )
281 0 : :m_rNotifier( _rNotifier )
282 : {
283 0 : m_rNotifier.enterSelection( SelectionNotifier::SelectionGuardAccess() );
284 0 : }
285 :
286 0 : ~SelectionGuard()
287 0 : {
288 0 : m_rNotifier.leaveSelection( SelectionNotifier::SelectionGuardAccess() );
289 0 : }
290 :
291 : private:
292 : SelectionNotifier& m_rNotifier;
293 : };
294 :
295 : //====================================================================
296 : //= OApplicationController
297 : //====================================================================
298 : DBG_NAME(OApplicationController)
299 : //--------------------------------------------------------------------
300 0 : OApplicationController::OApplicationController(const Reference< XMultiServiceFactory >& _rxORB)
301 : :OApplicationController_CBASE( _rxORB )
302 0 : ,m_aContextMenuInterceptors( getMutex() )
303 0 : ,m_pSubComponentManager( new SubComponentManager( *this, getSharedMutex() ) )
304 : ,m_aTypeCollection(_rxORB)
305 : ,m_aTableCopyHelper(this)
306 : ,m_pClipbordNotifier(NULL)
307 : ,m_nAsyncDrop(0)
308 : ,m_aControllerConnectedEvent( LINK( this, OApplicationController, OnFirstControllerConnected ) )
309 : ,m_aSelectContainerEvent( LINK( this, OApplicationController, OnSelectContainer ) )
310 : ,m_ePreviewMode(E_PREVIEWNONE)
311 : ,m_eCurrentType(E_NONE)
312 : ,m_bNeedToReconnect(sal_False)
313 : ,m_bSuspended( sal_False )
314 0 : ,m_pSelectionNotifier( new SelectionNotifier( getMutex(), *this ) )
315 : {
316 : DBG_CTOR(OApplicationController,NULL);
317 0 : }
318 : //------------------------------------------------------------------------------
319 0 : OApplicationController::~OApplicationController()
320 : {
321 0 : if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
322 : {
323 : OSL_FAIL("Please check who doesn't dispose this component!");
324 : // increment ref count to prevent double call of Dtor
325 0 : osl_atomic_increment( &m_refCount );
326 0 : dispose();
327 : }
328 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
329 0 : ::std::auto_ptr< Window> aTemp( getView() );
330 : SAL_WNODEPRECATED_DECLARATIONS_POP
331 0 : clearView();
332 :
333 0 : DBG_DTOR(OApplicationController,NULL);
334 0 : }
335 : //--------------------------------------------------------------------
336 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2(OApplicationController,OApplicationController_CBASE,OApplicationController_Base)
337 0 : IMPLEMENT_FORWARD_XINTERFACE2(OApplicationController,OApplicationController_CBASE,OApplicationController_Base)
338 : // -----------------------------------------------------------------------------
339 0 : void OApplicationController::disconnect()
340 : {
341 0 : if ( m_xDataSourceConnection.is() )
342 0 : stopConnectionListening( m_xDataSourceConnection );
343 :
344 : try
345 : {
346 : // temporary (hopefully!) hack for #i55274#
347 0 : Reference< XFlushable > xFlush( m_xDataSourceConnection, UNO_QUERY );
348 0 : if ( xFlush.is() && m_xMetaData.is() && !m_xMetaData->isReadOnly() )
349 0 : xFlush->flush();
350 : }
351 0 : catch( const Exception& )
352 : {
353 : DBG_UNHANDLED_EXCEPTION();
354 : }
355 :
356 0 : m_xDataSourceConnection.clear();
357 0 : m_xMetaData.clear();
358 :
359 0 : InvalidateAll();
360 0 : }
361 :
362 : //--------------------------------------------------------------------
363 0 : void SAL_CALL OApplicationController::disposing()
364 : {
365 0 : m_aControllerConnectedEvent.CancelCall();
366 :
367 0 : ::std::for_each(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),XContainerFunctor(this));
368 0 : m_aCurrentContainers.clear();
369 0 : m_pSubComponentManager->disposing();
370 0 : m_pSelectionNotifier->disposing();
371 :
372 0 : if ( getView() )
373 : {
374 0 : getContainer()->showPreview(NULL);
375 0 : m_pClipbordNotifier->ClearCallbackLink();
376 0 : m_pClipbordNotifier->AddRemoveListener( getView(), sal_False );
377 0 : m_pClipbordNotifier->release();
378 0 : m_pClipbordNotifier = NULL;
379 : }
380 :
381 0 : disconnect();
382 : try
383 : {
384 0 : Reference < XFrame > xFrame;
385 0 : attachFrame( xFrame );
386 :
387 0 : if ( m_xDataSource.is() )
388 : {
389 0 : m_xDataSource->removePropertyChangeListener(::rtl::OUString(), this);
390 0 : m_xDataSource->removePropertyChangeListener(PROPERTY_INFO, this);
391 0 : m_xDataSource->removePropertyChangeListener(PROPERTY_URL, this);
392 0 : m_xDataSource->removePropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED, this);
393 0 : m_xDataSource->removePropertyChangeListener(PROPERTY_LAYOUTINFORMATION, this);
394 0 : m_xDataSource->removePropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL, this);
395 0 : m_xDataSource->removePropertyChangeListener(PROPERTY_TABLEFILTER, this);
396 0 : m_xDataSource->removePropertyChangeListener(PROPERTY_TABLETYPEFILTER, this);
397 0 : m_xDataSource->removePropertyChangeListener(PROPERTY_USER, this);
398 : // otherwise we may delete our datasource twice
399 0 : Reference<XPropertySet> xProp = m_xDataSource;
400 0 : m_xDataSource = NULL;
401 : }
402 :
403 0 : Reference< XModifyBroadcaster > xBroadcaster( m_xModel, UNO_QUERY );
404 0 : if ( xBroadcaster.is() )
405 0 : xBroadcaster->removeModifyListener(static_cast<XModifyListener*>(this));
406 :
407 0 : if ( m_xModel.is() )
408 : {
409 0 : ::rtl::OUString sUrl = m_xModel->getURL();
410 0 : if ( !sUrl.isEmpty() )
411 : {
412 0 : ::comphelper::NamedValueCollection aArgs( m_xModel->getArgs() );
413 0 : if ( true == aArgs.getOrDefault( "PickListEntry", true ) )
414 : {
415 0 : ::rtl::OUString aFilter;
416 0 : INetURLObject aURL( m_xModel->getURL() );
417 0 : const SfxFilter* pFilter = getStandardDatabaseFilter();
418 0 : if ( pFilter )
419 0 : aFilter = pFilter->GetFilterName();
420 :
421 : // add to svtool history options
422 : SvtHistoryOptions().AppendItem( ePICKLIST,
423 : aURL.GetURLNoPass( INetURLObject::NO_DECODE ),
424 : aFilter,
425 : getStrippedDatabaseName(),
426 0 : ::rtl::OUString() );
427 0 : }
428 : }
429 :
430 0 : m_xModel->disconnectController( this );
431 :
432 0 : m_xModel.clear();
433 0 : }
434 : }
435 0 : catch(const Exception&)
436 : {
437 : DBG_UNHANDLED_EXCEPTION();
438 : }
439 :
440 0 : clearView();
441 0 : OApplicationController_CBASE::disposing(); // here the m_refCount must be equal 5
442 0 : }
443 :
444 : //--------------------------------------------------------------------
445 0 : sal_Bool OApplicationController::Construct(Window* _pParent)
446 : {
447 0 : setView( * new OApplicationView( _pParent, comphelper::getComponentContext(getORB()), *this, m_ePreviewMode ) );
448 0 : getView()->SetUniqueId(UID_APP_VIEW);
449 :
450 : // late construction
451 0 : sal_Bool bSuccess = sal_False;
452 : try
453 : {
454 0 : getContainer()->Construct();
455 0 : bSuccess = sal_True;
456 : }
457 0 : catch(const SQLException&)
458 : {
459 : }
460 0 : catch(const Exception&)
461 : {
462 : OSL_FAIL("OApplicationController::Construct : the construction of UnoDataBrowserView failed !");
463 : }
464 :
465 0 : if ( !bSuccess )
466 : {
467 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
468 0 : ::std::auto_ptr< Window> aTemp( getView() );
469 : SAL_WNODEPRECATED_DECLARATIONS_POP
470 0 : clearView();
471 0 : return sal_False;
472 : }
473 :
474 : // now that we have a view we can create the clipboard listener
475 0 : m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
476 0 : m_aSystemClipboard.StartClipboardListening( );
477 :
478 0 : m_pClipbordNotifier = new TransferableClipboardListener( LINK( this, OApplicationController, OnClipboardChanged ) );
479 0 : m_pClipbordNotifier->acquire();
480 0 : m_pClipbordNotifier->AddRemoveListener( getView(), sal_True );
481 :
482 0 : OApplicationController_CBASE::Construct( _pParent );
483 0 : getView()->Show();
484 :
485 0 : return sal_True;
486 : }
487 :
488 : //--------------------------------------------------------------------
489 0 : void SAL_CALL OApplicationController::disposing(const EventObject& _rSource) throw( RuntimeException )
490 : {
491 0 : ::osl::MutexGuard aGuard( getMutex() );
492 0 : Reference<XConnection> xCon(_rSource.Source, UNO_QUERY);
493 0 : if ( xCon.is() )
494 : {
495 : OSL_ENSURE( m_xDataSourceConnection == xCon,
496 : "OApplicationController::disposing: which connection does this come from?" );
497 :
498 0 : if ( getContainer() && getContainer()->getElementType() == E_TABLE )
499 0 : getContainer()->clearPages();
500 0 : if ( m_xDataSourceConnection == xCon )
501 : {
502 0 : m_xMetaData.clear();
503 0 : m_xDataSourceConnection.clear();
504 : }
505 : }
506 0 : else if ( _rSource.Source == m_xModel )
507 : {
508 0 : m_xModel.clear();
509 : }
510 0 : else if ( _rSource.Source == m_xDataSource )
511 : {
512 0 : m_xDataSource = NULL;
513 : }
514 : else
515 : {
516 0 : Reference<XContainer> xContainer( _rSource.Source, UNO_QUERY );
517 0 : if ( xContainer.is() )
518 : {
519 0 : TContainerVector::iterator aFind = ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer);
520 0 : if ( aFind != m_aCurrentContainers.end() )
521 0 : m_aCurrentContainers.erase(aFind);
522 : }
523 0 : OApplicationController_CBASE::disposing( _rSource );
524 0 : }
525 0 : }
526 : //--------------------------------------------------------------------
527 0 : sal_Bool SAL_CALL OApplicationController::suspend(sal_Bool bSuspend) throw( RuntimeException )
528 : {
529 : // notify the OnPrepareViewClosing event (before locking any mutex)
530 0 : Reference< XDocumentEventBroadcaster > xBroadcaster( m_xModel, UNO_QUERY );
531 0 : if ( xBroadcaster.is() )
532 : {
533 0 : xBroadcaster->notifyDocumentEvent(
534 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnPrepareViewClosing" ) ),
535 : this,
536 : Any()
537 0 : );
538 : }
539 :
540 0 : SolarMutexGuard aSolarGuard;
541 0 : ::osl::MutexGuard aGuard( getMutex() );
542 :
543 0 : if ( getView() && getView()->IsInModalMode() )
544 0 : return sal_False;
545 :
546 0 : sal_Bool bCanSuspend = sal_True;
547 :
548 0 : if ( m_bSuspended != bSuspend )
549 : {
550 0 : if ( bSuspend && !closeSubComponents() )
551 0 : return sal_False;
552 :
553 0 : Reference<XModifiable> xModi(m_xModel,UNO_QUERY);
554 0 : Reference<XStorable> xStor(getModel(),UNO_QUERY);
555 :
556 0 : if ( bSuspend
557 0 : && xStor.is()
558 0 : && !xStor->isReadonly()
559 0 : && ( xModi.is()
560 0 : && xModi->isModified()
561 : )
562 : )
563 : {
564 0 : switch (ExecuteQuerySaveDocument(getView(),getStrippedDatabaseName()))
565 : {
566 : case RET_YES:
567 0 : Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>());
568 0 : bCanSuspend = !xModi->isModified();
569 : // when we save the document this must be false else some press cancel
570 0 : break;
571 : case RET_CANCEL:
572 0 : bCanSuspend = sal_False;
573 : default:
574 0 : break;
575 : }
576 0 : }
577 : }
578 :
579 0 : if ( bCanSuspend )
580 0 : m_bSuspended = bSuspend;
581 :
582 0 : return bCanSuspend;
583 : }
584 : // -----------------------------------------------------------------------------
585 0 : FeatureState OApplicationController::GetState(sal_uInt16 _nId) const
586 : {
587 0 : FeatureState aReturn;
588 0 : aReturn.bEnabled = sal_False;
589 : // check this first
590 0 : if ( !getContainer() || m_bReadOnly )
591 0 : return aReturn;
592 :
593 : try
594 : {
595 0 : switch (_nId)
596 : {
597 : case SID_OPENURL:
598 0 : aReturn.bEnabled = sal_True;
599 0 : if ( m_xModel.is() )
600 0 : aReturn.sTitle = m_xModel->getURL();
601 0 : break;
602 : case ID_BROWSER_COPY:
603 : {
604 0 : sal_Int32 nCount = getContainer()->getSelectionCount();
605 0 : aReturn.bEnabled = nCount >= 1;
606 0 : if ( aReturn.bEnabled && nCount == 1 && getContainer()->getElementType() == E_TABLE )
607 0 : aReturn.bEnabled = getContainer()->isALeafSelected();
608 : }
609 0 : break;
610 : case ID_BROWSER_CUT:
611 0 : aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() >= 1;
612 0 : aReturn.bEnabled = aReturn.bEnabled && ( (ID_BROWSER_CUT == _nId && getContainer()->getElementType() == E_TABLE) ? getContainer()->isCutAllowed() : sal_True);
613 0 : break;
614 : case ID_BROWSER_PASTE:
615 0 : switch( getContainer()->getElementType() )
616 : {
617 : case E_TABLE:
618 0 : aReturn.bEnabled = !isDataSourceReadOnly() && !isConnectionReadOnly() && isTableFormat();
619 0 : break;
620 : case E_QUERY:
621 0 : aReturn.bEnabled = !isDataSourceReadOnly() && getViewClipboard().HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY);
622 0 : break;
623 : default:
624 0 : aReturn.bEnabled = !isDataSourceReadOnly() && OComponentTransferable::canExtractComponentDescriptor(getViewClipboard().GetDataFlavorExVector(),getContainer()->getElementType() == E_FORM);
625 : }
626 0 : break;
627 : case SID_DB_APP_PASTE_SPECIAL:
628 0 : aReturn.bEnabled = getContainer()->getElementType() == E_TABLE && !isDataSourceReadOnly() && !isConnectionReadOnly() && isTableFormat();
629 0 : break;
630 : case SID_OPENDOC:
631 : case SID_HELP_INDEX:
632 0 : aReturn.bEnabled = sal_True;
633 0 : break;
634 : case ID_BROWSER_SAVEDOC:
635 0 : aReturn.bEnabled = !isDataSourceReadOnly() && m_xDocumentModify.is() && m_xDocumentModify->isModified();
636 0 : break;
637 : case ID_BROWSER_SAVEASDOC:
638 0 : aReturn.bEnabled = sal_True;
639 0 : break;
640 : case ID_BROWSER_SORTUP:
641 0 : aReturn.bEnabled = getContainer()->isFilled() && getContainer()->getElementCount();
642 0 : aReturn.bChecked = aReturn.bEnabled && getContainer()->isSortUp();
643 0 : break;
644 : case ID_BROWSER_SORTDOWN:
645 0 : aReturn.bEnabled = getContainer()->isFilled() && getContainer()->getElementCount();
646 0 : aReturn.bChecked = aReturn.bEnabled && !getContainer()->isSortUp();
647 0 : break;
648 :
649 : case SID_NEWDOC:
650 : case SID_APP_NEW_FORM:
651 : case ID_DOCUMENT_CREATE_REPWIZ:
652 0 : aReturn.bEnabled = !isDataSourceReadOnly() && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER);
653 0 : break;
654 : case SID_APP_NEW_REPORT:
655 0 : aReturn.bEnabled = !isDataSourceReadOnly()
656 0 : && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER);
657 0 : if ( aReturn.bEnabled )
658 : {
659 0 : Reference< XContentEnumerationAccess > xEnumAccess(m_xServiceFactory, UNO_QUERY);
660 0 : aReturn.bEnabled = xEnumAccess.is();
661 0 : if ( aReturn.bEnabled )
662 : {
663 0 : const ::rtl::OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(m_xServiceFactory);
664 0 : aReturn.bEnabled = !sReportEngineServiceName.isEmpty();
665 0 : if ( aReturn.bEnabled )
666 : {
667 0 : const Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(sReportEngineServiceName);
668 0 : aReturn.bEnabled = xEnumDrivers.is() && xEnumDrivers->hasMoreElements();
669 0 : }
670 0 : }
671 : }
672 0 : break;
673 : case SID_DB_APP_VIEW_TABLES:
674 0 : aReturn.bEnabled = sal_True;
675 0 : aReturn.bChecked = getContainer()->getElementType() == E_TABLE;
676 0 : break;
677 : case SID_DB_APP_VIEW_QUERIES:
678 0 : aReturn.bEnabled = sal_True;
679 0 : aReturn.bChecked = getContainer()->getElementType() == E_QUERY;
680 0 : break;
681 : case SID_DB_APP_VIEW_FORMS:
682 0 : aReturn.bEnabled = sal_True;
683 0 : aReturn.bChecked = getContainer()->getElementType() == E_FORM;
684 0 : break;
685 : case SID_DB_APP_VIEW_REPORTS:
686 0 : aReturn.bEnabled = sal_True;
687 0 : aReturn.bChecked = getContainer()->getElementType() == E_REPORT;
688 0 : break;
689 : case ID_NEW_QUERY_DESIGN:
690 : case ID_NEW_QUERY_SQL:
691 : case ID_APP_NEW_QUERY_AUTO_PILOT:
692 : case SID_DB_FORM_NEW_PILOT:
693 0 : aReturn.bEnabled = !isDataSourceReadOnly();
694 0 : break;
695 : case ID_NEW_VIEW_DESIGN:
696 : case SID_DB_NEW_VIEW_SQL:
697 : case ID_NEW_VIEW_DESIGN_AUTO_PILOT:
698 0 : aReturn.bEnabled = !isDataSourceReadOnly() && !isConnectionReadOnly();
699 0 : if ( aReturn.bEnabled )
700 : {
701 0 : Reference<XViewsSupplier> xViewsSup( getConnection(), UNO_QUERY );
702 0 : aReturn.bEnabled = xViewsSup.is();
703 : }
704 0 : break;
705 : case ID_NEW_TABLE_DESIGN:
706 : case ID_NEW_TABLE_DESIGN_AUTO_PILOT:
707 0 : aReturn.bEnabled = !isDataSourceReadOnly() && !isConnectionReadOnly();
708 0 : break;
709 : case ID_DIRECT_SQL:
710 0 : aReturn.bEnabled = sal_True;
711 0 : break;
712 : case ID_MIGRATE_SCRIPTS:
713 : {
714 : // Our document supports embedding scripts into it, if and only if there are no
715 : // forms/reports with macros/scripts into them. So, we need to enable migration
716 : // if and only if the database document does *not* support embedding scripts.
717 : bool bAvailable =
718 0 : !Reference< XEmbeddedScripts >( m_xModel, UNO_QUERY ).is()
719 0 : && !Reference< XStorable >( m_xModel, UNO_QUERY_THROW )->isReadonly();
720 0 : aReturn.bEnabled = bAvailable;
721 0 : if ( !bAvailable )
722 0 : aReturn.bInvisible = true;
723 : }
724 0 : break;
725 : case SID_APP_NEW_FOLDER:
726 0 : aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() <= 1;
727 0 : if ( aReturn.bEnabled )
728 : {
729 0 : const ElementType eType = getContainer()->getElementType();
730 0 : aReturn.bEnabled = eType == E_REPORT || eType == E_FORM;
731 : }
732 0 : break;
733 : case SID_FORM_CREATE_REPWIZ_PRE_SEL:
734 : case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
735 : case SID_APP_NEW_REPORT_PRE_SEL:
736 0 : aReturn.bEnabled = !isDataSourceReadOnly()
737 0 : && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER)
738 0 : && getContainer()->isALeafSelected();
739 0 : if ( aReturn.bEnabled )
740 : {
741 0 : ElementType eType = getContainer()->getElementType();
742 0 : aReturn.bEnabled = eType == E_QUERY || eType == E_TABLE;
743 0 : if ( aReturn.bEnabled && SID_APP_NEW_REPORT_PRE_SEL == _nId )
744 : {
745 0 : Reference< XContentEnumerationAccess > xEnumAccess(m_xServiceFactory, UNO_QUERY);
746 0 : aReturn.bEnabled = xEnumAccess.is();
747 0 : if ( aReturn.bEnabled )
748 : {
749 0 : static ::rtl::OUString s_sReportDesign(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOReportJobFactory"));
750 0 : Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(s_sReportDesign);
751 0 : aReturn.bEnabled = xEnumDrivers.is() && xEnumDrivers->hasMoreElements();
752 0 : }
753 : }
754 : }
755 0 : break;
756 : case SID_DB_APP_DELETE:
757 : case SID_DB_APP_RENAME:
758 0 : aReturn.bEnabled = isRenameDeleteAllowed(getContainer()->getElementType(), _nId == SID_DB_APP_DELETE);
759 0 : break;
760 : case SID_DB_APP_TABLE_DELETE:
761 : case SID_DB_APP_TABLE_RENAME:
762 0 : aReturn.bEnabled = isRenameDeleteAllowed(E_TABLE, _nId == SID_DB_APP_TABLE_DELETE);
763 0 : break;
764 : case SID_DB_APP_QUERY_DELETE:
765 : case SID_DB_APP_QUERY_RENAME:
766 0 : aReturn.bEnabled = isRenameDeleteAllowed(E_QUERY, _nId == SID_DB_APP_QUERY_DELETE);
767 0 : break;
768 : case SID_DB_APP_FORM_DELETE:
769 : case SID_DB_APP_FORM_RENAME:
770 0 : aReturn.bEnabled = isRenameDeleteAllowed(E_FORM, _nId == SID_DB_APP_FORM_DELETE);
771 0 : break;
772 : case SID_DB_APP_REPORT_DELETE:
773 : case SID_DB_APP_REPORT_RENAME:
774 0 : aReturn.bEnabled = isRenameDeleteAllowed(E_REPORT, _nId == SID_DB_APP_REPORT_DELETE);
775 0 : break;
776 :
777 : case SID_SELECTALL:
778 0 : aReturn.bEnabled = getContainer()->getElementCount() > 0 && getContainer()->getSelectionCount() != getContainer()->getElementCount();
779 0 : break;
780 : case SID_DB_APP_EDIT:
781 : case SID_DB_APP_TABLE_EDIT:
782 : case SID_DB_APP_QUERY_EDIT:
783 : case SID_DB_APP_FORM_EDIT:
784 : case SID_DB_APP_REPORT_EDIT:
785 0 : aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() > 0
786 0 : && getContainer()->isALeafSelected();
787 0 : break;
788 : case SID_DB_APP_EDIT_SQL_VIEW:
789 0 : if ( isDataSourceReadOnly() )
790 0 : aReturn.bEnabled = sal_False;
791 : else
792 : {
793 0 : switch ( getContainer()->getElementType() )
794 : {
795 : case E_QUERY:
796 0 : aReturn.bEnabled = ( getContainer()->getSelectionCount() > 0 )
797 0 : && ( getContainer()->isALeafSelected() );
798 0 : break;
799 : case E_TABLE:
800 0 : aReturn.bEnabled = sal_False;
801 : // there's one exception: views which support altering their underlying
802 : // command can be edited in SQL view, too
803 0 : if ( ( getContainer()->getSelectionCount() > 0 )
804 0 : && ( getContainer()->isALeafSelected() )
805 : )
806 : {
807 0 : ::std::vector< ::rtl::OUString > aSelected;
808 0 : getSelectionElementNames( aSelected );
809 0 : bool bAlterableViews = true;
810 0 : for ( ::std::vector< ::rtl::OUString >::const_iterator selectedName = aSelected.begin();
811 0 : bAlterableViews && ( selectedName != aSelected.end() ) ;
812 : ++selectedName
813 : )
814 : {
815 0 : bAlterableViews &= impl_isAlterableView_nothrow( *selectedName );
816 : }
817 0 : aReturn.bEnabled = bAlterableViews;
818 : }
819 0 : break;
820 : default:
821 0 : break;
822 : }
823 : }
824 0 : break;
825 : case SID_DB_APP_OPEN:
826 : case SID_DB_APP_TABLE_OPEN:
827 : case SID_DB_APP_QUERY_OPEN:
828 : case SID_DB_APP_FORM_OPEN:
829 : case SID_DB_APP_REPORT_OPEN:
830 0 : aReturn.bEnabled = getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
831 0 : break;
832 : case SID_DB_APP_DSUSERADMIN:
833 0 : aReturn.bEnabled = !m_aTypeCollection.isEmbeddedDatabase(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
834 0 : break;
835 : case SID_DB_APP_DSRELDESIGN:
836 0 : aReturn.bEnabled = sal_True;
837 0 : break;
838 : case SID_DB_APP_TABLEFILTER:
839 0 : aReturn.bEnabled = !isDataSourceReadOnly();
840 0 : break;
841 : case SID_DB_APP_REFRESH_TABLES:
842 0 : aReturn.bEnabled = getContainer()->getElementType() == E_TABLE && isConnected();
843 0 : break;
844 : case SID_DB_APP_DSPROPS:
845 0 : aReturn.bEnabled = m_xDataSource.is() && m_aTypeCollection.isShowPropertiesEnabled(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
846 0 : break;
847 : case SID_DB_APP_DSCONNECTION_TYPE:
848 0 : aReturn.bEnabled = !isDataSourceReadOnly() && m_xDataSource.is() && !m_aTypeCollection.isEmbeddedDatabase(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
849 0 : break;
850 : case SID_DB_APP_DSADVANCED_SETTINGS:
851 0 : aReturn.bEnabled = m_xDataSource.is() && AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( m_aTypeCollection.getType(::comphelper::getString( m_xDataSource->getPropertyValue( PROPERTY_URL ) )) );
852 0 : break;
853 : case SID_DB_APP_CONVERTTOVIEW:
854 0 : aReturn.bEnabled = !isDataSourceReadOnly();
855 0 : if ( aReturn.bEnabled )
856 : {
857 0 : ElementType eType = getContainer()->getElementType();
858 0 : aReturn.bEnabled = eType == E_QUERY && getContainer()->getSelectionCount() > 0;
859 0 : if ( aReturn.bEnabled )
860 : {
861 0 : Reference<XViewsSupplier> xViewSup( getConnection(), UNO_QUERY );
862 0 : aReturn.bEnabled = xViewSup.is() && Reference<XAppend>(xViewSup->getViews(),UNO_QUERY).is();
863 : }
864 : }
865 0 : break;
866 : case SID_DB_APP_DISABLE_PREVIEW:
867 0 : aReturn.bEnabled = sal_True;
868 0 : aReturn.bChecked = getContainer()->getPreviewMode() == E_PREVIEWNONE;
869 0 : break;
870 : case SID_DB_APP_VIEW_DOCINFO_PREVIEW:
871 : {
872 0 : ElementType eType = getContainer()->getElementType();
873 0 : aReturn.bEnabled = (E_REPORT == eType || E_FORM == eType);
874 0 : aReturn.bChecked = getContainer()->getPreviewMode() == E_DOCUMENTINFO;
875 : }
876 0 : break;
877 : case SID_DB_APP_VIEW_DOC_PREVIEW:
878 0 : aReturn.bEnabled = sal_True;
879 0 : aReturn.bChecked = getContainer()->getPreviewMode() == E_DOCUMENT;
880 0 : break;
881 : case ID_BROWSER_UNDO:
882 0 : aReturn.bEnabled = sal_False;
883 0 : break;
884 : case SID_MAIL_SENDDOC:
885 0 : aReturn.bEnabled = sal_True;
886 0 : break;
887 : case SID_DB_APP_SENDREPORTASMAIL:
888 : {
889 0 : ElementType eType = getContainer()->getElementType();
890 0 : aReturn.bEnabled = E_REPORT == eType && getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
891 : }
892 0 : break;
893 : case SID_DB_APP_SENDREPORTTOWRITER:
894 : case SID_DB_APP_DBADMIN:
895 0 : aReturn.bEnabled = sal_False;
896 0 : break;
897 : case SID_DB_APP_STATUS_TYPE:
898 0 : aReturn.bEnabled = m_xDataSource.is();
899 0 : if ( aReturn.bEnabled )
900 : {
901 0 : ::rtl::OUString sURL;
902 0 : m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sURL;
903 0 : ::rtl::OUString sDSTypeName;
904 0 : if ( m_aTypeCollection.isEmbeddedDatabase( sURL ) )
905 : {
906 0 : sDSTypeName = String( ModuleRes( RID_STR_EMBEDDED_DATABASE ) );
907 : }
908 : else
909 : {
910 0 : sDSTypeName = m_aTypeCollection.getTypeDisplayName(sURL);
911 : }
912 0 : aReturn.sTitle = sDSTypeName;
913 : }
914 0 : break;
915 : case SID_DB_APP_STATUS_DBNAME:
916 0 : aReturn.bEnabled = m_xDataSource.is();
917 0 : if ( aReturn.bEnabled )
918 : {
919 0 : ::rtl::OUString sURL;
920 0 : m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sURL;
921 0 : String sDatabaseName;
922 0 : String sHostName;
923 0 : sal_Int32 nPortNumber( -1 );
924 :
925 0 : m_aTypeCollection.extractHostNamePort( sURL, sDatabaseName, sHostName, nPortNumber );
926 :
927 0 : if ( !sDatabaseName.Len() )
928 0 : sDatabaseName = m_aTypeCollection.cutPrefix( sURL );
929 0 : if ( m_aTypeCollection.isFileSystemBased(sURL) )
930 : {
931 0 : sDatabaseName = SvtPathOptions().SubstituteVariable( sDatabaseName );
932 0 : if ( sDatabaseName.Len() )
933 : {
934 0 : ::svt::OFileNotation aFileNotation(sDatabaseName);
935 : // set this decoded URL as text
936 0 : sDatabaseName = aFileNotation.get(::svt::OFileNotation::N_SYSTEM);
937 : }
938 : }
939 :
940 0 : if ( sDatabaseName.Len() == 0 )
941 0 : sDatabaseName = m_aTypeCollection.getTypeDisplayName( sURL );
942 :
943 0 : aReturn.sTitle = sDatabaseName;
944 : }
945 0 : break;
946 : case SID_DB_APP_STATUS_USERNAME:
947 0 : aReturn.bEnabled = m_xDataSource.is();
948 0 : if ( aReturn.bEnabled )
949 0 : m_xDataSource->getPropertyValue( PROPERTY_USER ) >>= aReturn.sTitle;
950 0 : break;
951 : case SID_DB_APP_STATUS_HOSTNAME:
952 0 : aReturn.bEnabled = m_xDataSource.is();
953 0 : if ( aReturn.bEnabled )
954 : {
955 0 : ::rtl::OUString sURL;
956 0 : m_xDataSource->getPropertyValue( PROPERTY_URL ) >>= sURL;
957 :
958 0 : String sHostName, sDatabaseName;
959 0 : sal_Int32 nPortNumber = -1;
960 0 : m_aTypeCollection.extractHostNamePort( sURL, sDatabaseName, sHostName, nPortNumber );
961 0 : aReturn.sTitle = sHostName;
962 : }
963 0 : break;
964 : default:
965 0 : aReturn = OApplicationController_CBASE::GetState(_nId);
966 : }
967 : }
968 0 : catch(const Exception& )
969 : {
970 : DBG_UNHANDLED_EXCEPTION();
971 : }
972 0 : return aReturn;
973 : }
974 :
975 : // -----------------------------------------------------------------------------
976 : namespace
977 : {
978 0 : bool lcl_handleException_nothrow( const Reference< XModel >& _rxDocument, const Any& _rException )
979 : {
980 0 : bool bHandled = false;
981 :
982 : // try handling the error with an interaction handler
983 0 : ::comphelper::NamedValueCollection aArgs( _rxDocument->getArgs() );
984 0 : Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) );
985 0 : if ( xHandler.is() )
986 : {
987 0 : ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new ::comphelper::OInteractionRequest( _rException ) );
988 0 : ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove );
989 0 : pRequest->addContinuation( pApprove.get() );
990 :
991 : try
992 : {
993 0 : xHandler->handle( pRequest.get() );
994 : }
995 0 : catch( const Exception& )
996 : {
997 : DBG_UNHANDLED_EXCEPTION();
998 : }
999 :
1000 0 : bHandled = pApprove->wasSelected();
1001 : }
1002 0 : return bHandled;
1003 : }
1004 : }
1005 :
1006 : // -----------------------------------------------------------------------------
1007 0 : void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
1008 : {
1009 0 : SolarMutexGuard aSolarGuard;
1010 0 : ::osl::MutexGuard aGuard( getMutex() );
1011 :
1012 0 : if ( isUserDefinedFeature( _nId ) )
1013 : {
1014 0 : OApplicationController_CBASE::Execute( _nId, aArgs );
1015 : return;
1016 : }
1017 :
1018 0 : if ( !getContainer() || m_bReadOnly )
1019 : return; // return without execution
1020 :
1021 : try
1022 : {
1023 0 : switch(_nId)
1024 : {
1025 : case ID_BROWSER_CUT:
1026 0 : getContainer()->cut();
1027 0 : break;
1028 : case ID_BROWSER_COPY:
1029 : {
1030 0 : TransferableHelper* pTransfer = copyObject( );
1031 0 : Reference< XTransferable> aEnsureDelete = pTransfer;
1032 :
1033 0 : if ( pTransfer )
1034 0 : pTransfer->CopyToClipboard(getView());
1035 : }
1036 0 : break;
1037 : case ID_BROWSER_PASTE:
1038 : {
1039 0 : const TransferableDataHelper& rTransferData( getViewClipboard() );
1040 0 : ElementType eType = getContainer()->getElementType();
1041 :
1042 0 : switch( eType )
1043 : {
1044 : case E_TABLE:
1045 : {
1046 : // get the selected tablename
1047 0 : ::std::vector< ::rtl::OUString > aList;
1048 0 : getSelectionElementNames( aList );
1049 0 : if ( !aList.empty() )
1050 0 : m_aTableCopyHelper.SetTableNameForAppend( *aList.begin() );
1051 : else
1052 0 : m_aTableCopyHelper.ResetTableNameForAppend();
1053 :
1054 0 : m_aTableCopyHelper.pasteTable( rTransferData , getDatabaseName(), ensureConnection() );
1055 : }
1056 0 : break;
1057 :
1058 : case E_QUERY:
1059 0 : if ( rTransferData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY) )
1060 0 : paste( E_QUERY, ODataAccessObjectTransferable::extractObjectDescriptor( rTransferData ) );
1061 0 : break;
1062 : default:
1063 : {
1064 0 : ::std::vector< ::rtl::OUString> aList;
1065 0 : getSelectionElementNames(aList);
1066 0 : ::rtl::OUString sFolderNameToInsertInto;
1067 0 : if ( !aList.empty() )
1068 : {
1069 0 : Reference< XHierarchicalNameAccess > xContainer(getElements(eType),UNO_QUERY);
1070 0 : if ( xContainer.is()
1071 0 : && xContainer->hasByHierarchicalName(*aList.begin())
1072 0 : && (xContainer->getByHierarchicalName(*aList.begin()) >>= xContainer)
1073 0 : && xContainer.is()
1074 : )
1075 0 : sFolderNameToInsertInto = *aList.begin();
1076 : }
1077 : paste( eType, OComponentTransferable::extractComponentDescriptor( rTransferData ),
1078 0 : sFolderNameToInsertInto );
1079 : }
1080 0 : break;
1081 : }
1082 : }
1083 0 : break;
1084 : case SID_DB_APP_PASTE_SPECIAL:
1085 : {
1086 0 : if ( !aArgs.getLength() )
1087 : {
1088 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1089 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1090 0 : ::std::auto_ptr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( getView() ));
1091 : SAL_WNODEPRECATED_DECLARATIONS_POP
1092 0 : ::std::vector<SotFormatStringId> aFormatIds;
1093 0 : getSupportedFormats(getContainer()->getElementType(),aFormatIds);
1094 0 : const ::std::vector<SotFormatStringId>::iterator aEnd = aFormatIds.end();
1095 0 : ::rtl::OUString sEmpty;
1096 0 : for (::std::vector<SotFormatStringId>::iterator aIter = aFormatIds.begin();aIter != aEnd; ++aIter)
1097 0 : pDlg->Insert(*aIter,sEmpty);
1098 :
1099 0 : const TransferableDataHelper& rClipboard = getViewClipboard();
1100 0 : pasteFormat(pDlg->GetFormat(rClipboard.GetTransferable()));
1101 : }
1102 : else
1103 : {
1104 0 : const PropertyValue* pIter = aArgs.getConstArray();
1105 0 : const PropertyValue* pEnd = pIter + aArgs.getLength();
1106 0 : for( ; pIter != pEnd ; ++pIter)
1107 : {
1108 0 : if ( pIter->Name == "FormatStringId" )
1109 : {
1110 0 : SotFormatStringId nFormatId = 0;
1111 0 : if ( pIter->Value >>= nFormatId )
1112 0 : pasteFormat(nFormatId);
1113 : break;
1114 : }
1115 : }
1116 : }
1117 : }
1118 0 : break;
1119 : case SID_OPENDOC:
1120 : case SID_HELP_INDEX:
1121 : {
1122 0 : Reference < XDispatchProvider > xProv( getFrame(), UNO_QUERY );
1123 0 : if ( xProv.is() )
1124 : {
1125 0 : URL aURL;
1126 0 : switch(_nId)
1127 : {
1128 : case SID_HELP_INDEX:
1129 0 : aURL.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:HelpIndex"));
1130 0 : break;
1131 : case SID_OPENDOC:
1132 0 : aURL.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Open"));
1133 0 : break;
1134 : }
1135 :
1136 0 : if ( m_xUrlTransformer.is() )
1137 0 : m_xUrlTransformer->parseStrict( aURL );
1138 0 : Reference < XDispatch > xDisp = xProv->queryDispatch( aURL, String(), 0 );
1139 0 : if ( xDisp.is() )
1140 0 : xDisp->dispatch( aURL, Sequence < PropertyValue >() );
1141 0 : }
1142 : }
1143 0 : break;
1144 : case ID_BROWSER_SAVEDOC:
1145 : {
1146 0 : Reference< XStorable > xStore( m_xModel, UNO_QUERY_THROW );
1147 : try
1148 : {
1149 0 : xStore->store();
1150 : }
1151 0 : catch( const Exception& )
1152 : {
1153 0 : lcl_handleException_nothrow( m_xModel, ::cppu::getCaughtException() );
1154 0 : }
1155 : }
1156 0 : break;
1157 :
1158 : case ID_BROWSER_SAVEASDOC:
1159 : {
1160 0 : ::rtl::OUString sUrl;
1161 0 : if ( m_xModel.is() )
1162 0 : sUrl = m_xModel->getURL();
1163 0 : if ( sUrl.isEmpty() )
1164 0 : sUrl = SvtPathOptions().GetWorkPath();
1165 :
1166 : ::sfx2::FileDialogHelper aFileDlg(
1167 : ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
1168 0 : 0, getView());
1169 0 : aFileDlg.SetDisplayDirectory( sUrl );
1170 :
1171 0 : const SfxFilter* pFilter = getStandardDatabaseFilter();
1172 0 : if ( pFilter )
1173 : {
1174 0 : aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
1175 0 : aFileDlg.SetCurrentFilter(pFilter->GetUIName());
1176 : }
1177 :
1178 0 : if ( aFileDlg.Execute() != ERRCODE_NONE )
1179 : break;
1180 :
1181 0 : Reference<XStorable> xStore( m_xModel, UNO_QUERY_THROW );
1182 0 : INetURLObject aURL( aFileDlg.GetPath() );
1183 : try
1184 : {
1185 0 : xStore->storeAsURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), Sequence< PropertyValue >() );
1186 : }
1187 0 : catch( const Exception& )
1188 : {
1189 0 : lcl_handleException_nothrow( m_xModel, ::cppu::getCaughtException() );
1190 : }
1191 :
1192 : /*updateTitle();*/
1193 0 : m_bCurrentlyModified = sal_False;
1194 0 : InvalidateFeature(ID_BROWSER_SAVEDOC);
1195 0 : if ( getContainer()->getElementType() == E_NONE )
1196 : {
1197 0 : getContainer()->selectContainer(E_NONE);
1198 0 : getContainer()->selectContainer(E_TABLE);
1199 : // #i95524#
1200 0 : getContainer()->Invalidate();
1201 0 : refreshTables();
1202 0 : }
1203 :
1204 : }
1205 0 : break;
1206 : case ID_BROWSER_SORTUP:
1207 0 : getContainer()->sortUp();
1208 0 : InvalidateFeature(ID_BROWSER_SORTDOWN);
1209 0 : break;
1210 : case ID_BROWSER_SORTDOWN:
1211 0 : getContainer()->sortDown();
1212 0 : InvalidateFeature(ID_BROWSER_SORTUP);
1213 0 : break;
1214 :
1215 : case ID_NEW_TABLE_DESIGN_AUTO_PILOT:
1216 : case ID_NEW_VIEW_DESIGN_AUTO_PILOT:
1217 : case ID_APP_NEW_QUERY_AUTO_PILOT:
1218 : case SID_DB_FORM_NEW_PILOT:
1219 : case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
1220 : case SID_APP_NEW_REPORT_PRE_SEL:
1221 : case SID_FORM_CREATE_REPWIZ_PRE_SEL:
1222 : case ID_DOCUMENT_CREATE_REPWIZ:
1223 : case SID_APP_NEW_FORM:
1224 : case SID_APP_NEW_REPORT:
1225 : case ID_NEW_QUERY_SQL:
1226 : case ID_NEW_QUERY_DESIGN:
1227 : case ID_NEW_TABLE_DESIGN:
1228 : {
1229 0 : ElementType eType = E_TABLE;
1230 0 : sal_Bool bAutoPilot = sal_False;
1231 0 : ::comphelper::NamedValueCollection aCreationArgs;
1232 :
1233 0 : switch( _nId )
1234 : {
1235 : case SID_DB_FORM_NEW_PILOT:
1236 : case SID_FORM_CREATE_REPWIZ_PRE_SEL:
1237 0 : bAutoPilot = sal_True;
1238 : // run through
1239 : case SID_APP_NEW_FORM:
1240 0 : eType = E_FORM;
1241 0 : break;
1242 : case ID_DOCUMENT_CREATE_REPWIZ:
1243 : case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
1244 0 : bAutoPilot = sal_True;
1245 : // run through
1246 : case SID_APP_NEW_REPORT:
1247 : case SID_APP_NEW_REPORT_PRE_SEL:
1248 0 : eType = E_REPORT;
1249 0 : break;
1250 : case ID_APP_NEW_QUERY_AUTO_PILOT:
1251 0 : bAutoPilot = sal_True;
1252 0 : eType = E_QUERY;
1253 0 : break;
1254 : case ID_NEW_QUERY_DESIGN:
1255 0 : aCreationArgs.put( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, sal_True );
1256 : // run through
1257 : case ID_NEW_QUERY_SQL:
1258 0 : eType = E_QUERY;
1259 0 : break;
1260 : case ID_NEW_TABLE_DESIGN_AUTO_PILOT:
1261 0 : bAutoPilot = sal_True;
1262 : // run through
1263 : case ID_NEW_TABLE_DESIGN:
1264 0 : break;
1265 : default:
1266 : OSL_FAIL("illegal switch call!");
1267 : }
1268 0 : if ( bAutoPilot )
1269 0 : getContainer()->PostUserEvent( LINK( this, OApplicationController, OnCreateWithPilot ), reinterpret_cast< void* >( eType ) );
1270 : else
1271 : {
1272 0 : Reference< XComponent > xDocDefinition;
1273 0 : newElement( eType, aCreationArgs, xDocDefinition );
1274 0 : }
1275 : }
1276 0 : break;
1277 : case SID_APP_NEW_FOLDER:
1278 : {
1279 0 : ElementType eType = getContainer()->getElementType();
1280 0 : ::rtl::OUString sName = getContainer()->getQualifiedName( NULL );
1281 0 : insertHierachyElement(eType,sName);
1282 : }
1283 0 : break;
1284 : case ID_NEW_VIEW_DESIGN:
1285 : case SID_DB_NEW_VIEW_SQL:
1286 : {
1287 0 : SharedConnection xConnection( ensureConnection() );
1288 0 : if ( xConnection.is() )
1289 : {
1290 0 : QueryDesigner aDesigner( getORB(), this, getFrame(), true );
1291 :
1292 0 : ::comphelper::NamedValueCollection aCreationArgs;
1293 0 : aCreationArgs.put( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, ID_NEW_VIEW_DESIGN == _nId );
1294 :
1295 0 : const Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
1296 0 : const Reference< XComponent > xComponent( aDesigner.createNew( xDataSource, aCreationArgs ), UNO_QUERY );
1297 0 : onDocumentOpened( ::rtl::OUString(), E_QUERY, E_OPEN_DESIGN, xComponent, NULL );
1298 0 : }
1299 : }
1300 0 : break;
1301 : case SID_DB_APP_DELETE:
1302 : case SID_DB_APP_TABLE_DELETE:
1303 : case SID_DB_APP_QUERY_DELETE:
1304 : case SID_DB_APP_FORM_DELETE:
1305 : case SID_DB_APP_REPORT_DELETE:
1306 0 : deleteEntries();
1307 0 : break;
1308 : case SID_DB_APP_RENAME:
1309 : case SID_DB_APP_TABLE_RENAME:
1310 : case SID_DB_APP_QUERY_RENAME:
1311 : case SID_DB_APP_FORM_RENAME:
1312 : case SID_DB_APP_REPORT_RENAME:
1313 0 : renameEntry();
1314 0 : break;
1315 : case SID_DB_APP_EDIT:
1316 : case SID_DB_APP_EDIT_SQL_VIEW:
1317 : case SID_DB_APP_TABLE_EDIT:
1318 : case SID_DB_APP_QUERY_EDIT:
1319 : case SID_DB_APP_FORM_EDIT:
1320 : case SID_DB_APP_REPORT_EDIT:
1321 0 : doAction( _nId, E_OPEN_DESIGN );
1322 0 : break;
1323 : case SID_DB_APP_OPEN:
1324 : case SID_DB_APP_TABLE_OPEN:
1325 : case SID_DB_APP_QUERY_OPEN:
1326 : case SID_DB_APP_FORM_OPEN:
1327 : case SID_DB_APP_REPORT_OPEN:
1328 0 : doAction( _nId, E_OPEN_NORMAL );
1329 0 : break;
1330 : case SID_DB_APP_CONVERTTOVIEW:
1331 0 : doAction( _nId, E_OPEN_NORMAL );
1332 0 : break;
1333 : case SID_SELECTALL:
1334 0 : getContainer()->selectAll();
1335 0 : InvalidateAll();
1336 0 : break;
1337 : case SID_DB_APP_DSRELDESIGN:
1338 : {
1339 0 : Reference< XComponent > xRelationDesigner;
1340 0 : if ( !m_pSubComponentManager->activateSubFrame( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN, xRelationDesigner ) )
1341 : {
1342 0 : SharedConnection xConnection( ensureConnection() );
1343 0 : if ( xConnection.is() )
1344 : {
1345 0 : RelationDesigner aDesigner( getORB(), this, m_aCurrentFrame.getFrame() );
1346 :
1347 0 : const Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
1348 0 : const Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY );
1349 0 : onDocumentOpened( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN, xComponent, NULL );
1350 0 : }
1351 0 : }
1352 : }
1353 0 : break;
1354 : case SID_DB_APP_DSUSERADMIN:
1355 : {
1356 0 : SharedConnection xConnection( ensureConnection() );
1357 0 : if ( xConnection.is() )
1358 0 : openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.UserAdministrationDialog")));
1359 : }
1360 0 : break;
1361 : case SID_DB_APP_TABLEFILTER:
1362 0 : openTableFilterDialog();
1363 0 : askToReconnect();
1364 0 : break;
1365 : case SID_DB_APP_REFRESH_TABLES:
1366 0 : refreshTables();
1367 0 : break;
1368 : case SID_DB_APP_DSPROPS:
1369 0 : openDataSourceAdminDialog();
1370 0 : askToReconnect();
1371 0 : break;
1372 : case SID_DB_APP_DSADVANCED_SETTINGS:
1373 0 : openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.AdvancedDatabaseSettingsDialog")));
1374 0 : askToReconnect();
1375 0 : break;
1376 : case SID_DB_APP_DSCONNECTION_TYPE:
1377 0 : openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DataSourceTypeChangeDialog")));
1378 0 : askToReconnect();
1379 0 : break;
1380 : case ID_DIRECT_SQL:
1381 : {
1382 0 : SharedConnection xConnection( ensureConnection() );
1383 0 : if ( xConnection.is() )
1384 0 : openDirectSQLDialog();
1385 : }
1386 0 : break;
1387 : case ID_MIGRATE_SCRIPTS:
1388 0 : impl_migrateScripts_nothrow();
1389 0 : break;
1390 : case SID_DB_APP_VIEW_TABLES:
1391 0 : m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_TABLE ) );
1392 0 : break;
1393 : case SID_DB_APP_VIEW_QUERIES:
1394 0 : m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_QUERY ) );
1395 0 : break;
1396 : case SID_DB_APP_VIEW_FORMS:
1397 0 : m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_FORM ) );
1398 0 : break;
1399 : case SID_DB_APP_VIEW_REPORTS:
1400 0 : m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_REPORT ) );
1401 0 : break;
1402 : case SID_DB_APP_DISABLE_PREVIEW:
1403 0 : m_ePreviewMode = E_PREVIEWNONE;
1404 0 : getContainer()->switchPreview(m_ePreviewMode);
1405 0 : break;
1406 : case SID_DB_APP_VIEW_DOCINFO_PREVIEW:
1407 0 : m_ePreviewMode = E_DOCUMENTINFO;
1408 0 : getContainer()->switchPreview(m_ePreviewMode);
1409 0 : break;
1410 : case SID_DB_APP_VIEW_DOC_PREVIEW:
1411 0 : m_ePreviewMode = E_DOCUMENT;
1412 0 : getContainer()->switchPreview(m_ePreviewMode);
1413 0 : break;
1414 : case SID_MAIL_SENDDOC:
1415 : {
1416 0 : SfxMailModel aSendMail;
1417 0 : if ( aSendMail.AttachDocument(rtl::OUString(),getModel(), rtl::OUString()) == SfxMailModel::SEND_MAIL_OK )
1418 0 : aSendMail.Send( getFrame() );
1419 : }
1420 0 : break;
1421 : case SID_DB_APP_SENDREPORTASMAIL:
1422 0 : doAction( _nId, E_OPEN_FOR_MAIL );
1423 0 : break;
1424 : }
1425 : }
1426 0 : catch( const Exception& )
1427 : {
1428 : DBG_UNHANDLED_EXCEPTION();
1429 : }
1430 0 : InvalidateFeature(_nId);
1431 : }
1432 : // -----------------------------------------------------------------------------
1433 0 : void OApplicationController::describeSupportedFeatures()
1434 : {
1435 0 : OApplicationController_CBASE::describeSupportedFeatures();
1436 :
1437 0 : implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVEDOC, CommandGroup::DOCUMENT );
1438 0 : implDescribeSupportedFeature( ".uno:SaveAs", ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT );
1439 0 : implDescribeSupportedFeature( ".uno:SendMail", SID_MAIL_SENDDOC, CommandGroup::DOCUMENT );
1440 : implDescribeSupportedFeature( ".uno:DBSendReportAsMail",SID_DB_APP_SENDREPORTASMAIL,
1441 0 : CommandGroup::DOCUMENT );
1442 : implDescribeSupportedFeature( ".uno:DBSendReportToWriter",SID_DB_APP_SENDREPORTTOWRITER,
1443 0 : CommandGroup::DOCUMENT );
1444 0 : implDescribeSupportedFeature( ".uno:DBNewForm", SID_APP_NEW_FORM, CommandGroup::INSERT );
1445 0 : implDescribeSupportedFeature( ".uno:DBNewFolder", SID_APP_NEW_FOLDER, CommandGroup::INSERT );
1446 0 : implDescribeSupportedFeature( ".uno:DBNewFormAutoPilot", SID_DB_FORM_NEW_PILOT, CommandGroup::INSERT );
1447 : implDescribeSupportedFeature( ".uno:DBNewFormAutoPilotWithPreSelection",
1448 : SID_FORM_CREATE_REPWIZ_PRE_SEL,
1449 0 : CommandGroup::APPLICATION );
1450 :
1451 0 : implDescribeSupportedFeature( ".uno:DBNewReport", SID_APP_NEW_REPORT, CommandGroup::INSERT );
1452 : implDescribeSupportedFeature( ".uno:DBNewReportAutoPilot",
1453 0 : ID_DOCUMENT_CREATE_REPWIZ, CommandGroup::INSERT );
1454 : implDescribeSupportedFeature( ".uno:DBNewReportAutoPilotWithPreSelection",
1455 : SID_REPORT_CREATE_REPWIZ_PRE_SEL,
1456 0 : CommandGroup::APPLICATION );
1457 0 : implDescribeSupportedFeature( ".uno:DBNewQuery", ID_NEW_QUERY_DESIGN, CommandGroup::INSERT );
1458 0 : implDescribeSupportedFeature( ".uno:DBNewQuerySql", ID_NEW_QUERY_SQL, CommandGroup::INSERT );
1459 : implDescribeSupportedFeature( ".uno:DBNewQueryAutoPilot",ID_APP_NEW_QUERY_AUTO_PILOT,
1460 0 : CommandGroup::INSERT );
1461 0 : implDescribeSupportedFeature( ".uno:DBNewTable", ID_NEW_TABLE_DESIGN, CommandGroup::INSERT );
1462 : implDescribeSupportedFeature( ".uno:DBNewTableAutoPilot",ID_NEW_TABLE_DESIGN_AUTO_PILOT,
1463 0 : CommandGroup::INSERT );
1464 0 : implDescribeSupportedFeature( ".uno:DBNewView", ID_NEW_VIEW_DESIGN, CommandGroup::INSERT );
1465 0 : implDescribeSupportedFeature( ".uno:DBNewViewSQL", SID_DB_NEW_VIEW_SQL, CommandGroup::INSERT );
1466 :
1467 0 : implDescribeSupportedFeature( ".uno:DBDelete", SID_DB_APP_DELETE, CommandGroup::EDIT );
1468 0 : implDescribeSupportedFeature( ".uno:Delete", SID_DB_APP_DELETE, CommandGroup::EDIT );
1469 0 : implDescribeSupportedFeature( ".uno:DBRename", SID_DB_APP_RENAME, CommandGroup::EDIT );
1470 0 : implDescribeSupportedFeature( ".uno:DBEdit", SID_DB_APP_EDIT, CommandGroup::EDIT );
1471 0 : implDescribeSupportedFeature( ".uno:DBEditSqlView", SID_DB_APP_EDIT_SQL_VIEW, CommandGroup::EDIT );
1472 0 : implDescribeSupportedFeature( ".uno:DBOpen", SID_DB_APP_OPEN, CommandGroup::EDIT );
1473 :
1474 0 : implDescribeSupportedFeature( ".uno:DBTableDelete", SID_DB_APP_TABLE_DELETE, CommandGroup::EDIT );
1475 0 : implDescribeSupportedFeature( ".uno:DBTableRename", SID_DB_APP_TABLE_RENAME, CommandGroup::EDIT );
1476 0 : implDescribeSupportedFeature( ".uno:DBTableEdit", SID_DB_APP_TABLE_EDIT, CommandGroup::EDIT );
1477 0 : implDescribeSupportedFeature( ".uno:DBTableOpen", SID_DB_APP_TABLE_OPEN, CommandGroup::EDIT );
1478 :
1479 0 : implDescribeSupportedFeature( ".uno:DBQueryDelete", SID_DB_APP_QUERY_DELETE, CommandGroup::EDIT );
1480 0 : implDescribeSupportedFeature( ".uno:DBQueryRename", SID_DB_APP_QUERY_RENAME, CommandGroup::EDIT );
1481 0 : implDescribeSupportedFeature( ".uno:DBQueryEdit", SID_DB_APP_QUERY_EDIT, CommandGroup::EDIT );
1482 0 : implDescribeSupportedFeature( ".uno:DBQueryOpen", SID_DB_APP_QUERY_OPEN, CommandGroup::EDIT );
1483 :
1484 0 : implDescribeSupportedFeature( ".uno:DBFormDelete", SID_DB_APP_FORM_DELETE, CommandGroup::EDIT );
1485 0 : implDescribeSupportedFeature( ".uno:DBFormRename", SID_DB_APP_FORM_RENAME, CommandGroup::EDIT );
1486 0 : implDescribeSupportedFeature( ".uno:DBFormEdit", SID_DB_APP_FORM_EDIT, CommandGroup::EDIT );
1487 0 : implDescribeSupportedFeature( ".uno:DBFormOpen", SID_DB_APP_FORM_OPEN, CommandGroup::EDIT );
1488 :
1489 0 : implDescribeSupportedFeature( ".uno:DBReportDelete", SID_DB_APP_REPORT_DELETE, CommandGroup::EDIT );
1490 0 : implDescribeSupportedFeature( ".uno:DBReportRename", SID_DB_APP_REPORT_RENAME, CommandGroup::EDIT );
1491 0 : implDescribeSupportedFeature( ".uno:DBReportEdit", SID_DB_APP_REPORT_EDIT, CommandGroup::EDIT );
1492 0 : implDescribeSupportedFeature( ".uno:DBReportOpen", SID_DB_APP_REPORT_OPEN, CommandGroup::EDIT );
1493 :
1494 0 : implDescribeSupportedFeature( ".uno:SelectAll", SID_SELECTALL, CommandGroup::EDIT );
1495 0 : implDescribeSupportedFeature( ".uno:Undo", ID_BROWSER_UNDO, CommandGroup::EDIT );
1496 :
1497 0 : implDescribeSupportedFeature( ".uno:Sortup", ID_BROWSER_SORTUP, CommandGroup::VIEW );
1498 0 : implDescribeSupportedFeature( ".uno:SortDown", ID_BROWSER_SORTDOWN, CommandGroup::VIEW );
1499 0 : implDescribeSupportedFeature( ".uno:DBRelationDesign", SID_DB_APP_DSRELDESIGN, CommandGroup::APPLICATION );
1500 0 : implDescribeSupportedFeature( ".uno:DBUserAdmin", SID_DB_APP_DSUSERADMIN, CommandGroup::APPLICATION );
1501 0 : implDescribeSupportedFeature( ".uno:DBTableFilter", SID_DB_APP_TABLEFILTER, CommandGroup::APPLICATION );
1502 0 : implDescribeSupportedFeature( ".uno:DBDSProperties", SID_DB_APP_DSPROPS, CommandGroup::EDIT );
1503 : implDescribeSupportedFeature( ".uno:DBDSConnectionType", SID_DB_APP_DSCONNECTION_TYPE,
1504 0 : CommandGroup::EDIT );
1505 : implDescribeSupportedFeature( ".uno:DBDSAdvancedSettings",
1506 : SID_DB_APP_DSADVANCED_SETTINGS,
1507 0 : CommandGroup::EDIT );
1508 0 : implDescribeSupportedFeature( ".uno:PasteSpecial", SID_DB_APP_PASTE_SPECIAL, CommandGroup::EDIT );
1509 0 : implDescribeSupportedFeature( ".uno:DBConvertToView", SID_DB_APP_CONVERTTOVIEW, CommandGroup::EDIT );
1510 0 : implDescribeSupportedFeature( ".uno:DBRefreshTables", SID_DB_APP_REFRESH_TABLES, CommandGroup::APPLICATION );
1511 0 : implDescribeSupportedFeature( ".uno:DBDirectSQL", ID_DIRECT_SQL, CommandGroup::APPLICATION );
1512 0 : implDescribeSupportedFeature( ".uno:DBMigrateScripts", ID_MIGRATE_SCRIPTS, CommandGroup::APPLICATION );
1513 0 : implDescribeSupportedFeature( ".uno:DBViewTables", SID_DB_APP_VIEW_TABLES, CommandGroup::VIEW );
1514 0 : implDescribeSupportedFeature( ".uno:DBViewQueries", SID_DB_APP_VIEW_QUERIES, CommandGroup::VIEW );
1515 0 : implDescribeSupportedFeature( ".uno:DBViewForms", SID_DB_APP_VIEW_FORMS, CommandGroup::VIEW );
1516 0 : implDescribeSupportedFeature( ".uno:DBViewReports", SID_DB_APP_VIEW_REPORTS, CommandGroup::VIEW );
1517 0 : implDescribeSupportedFeature( ".uno:DBDisablePreview", SID_DB_APP_DISABLE_PREVIEW,CommandGroup::VIEW );
1518 : implDescribeSupportedFeature( ".uno:DBShowDocInfoPreview",
1519 : SID_DB_APP_VIEW_DOCINFO_PREVIEW,
1520 0 : CommandGroup::VIEW );
1521 : implDescribeSupportedFeature( ".uno:DBShowDocPreview", SID_DB_APP_VIEW_DOC_PREVIEW,
1522 0 : CommandGroup::VIEW );
1523 :
1524 0 : implDescribeSupportedFeature( ".uno:OpenUrl", SID_OPENURL, CommandGroup::APPLICATION );
1525 :
1526 : // this one should not appear under Tools->Customize->Keyboard
1527 : implDescribeSupportedFeature( ".uno:DBNewReportWithPreSelection",
1528 0 : SID_APP_NEW_REPORT_PRE_SEL,CommandGroup::INTERNAL );
1529 0 : implDescribeSupportedFeature( ".uno:DBDSImport", SID_DB_APP_DSIMPORT, CommandGroup::INTERNAL);
1530 0 : implDescribeSupportedFeature( ".uno:DBDSExport", SID_DB_APP_DSEXPORT, CommandGroup::INTERNAL);
1531 0 : implDescribeSupportedFeature( ".uno:DBDBAdmin", SID_DB_APP_DBADMIN, CommandGroup::INTERNAL);
1532 :
1533 : // status info
1534 0 : implDescribeSupportedFeature( ".uno:DBStatusType", SID_DB_APP_STATUS_TYPE, CommandGroup::INTERNAL);
1535 0 : implDescribeSupportedFeature( ".uno:DBStatusDBName", SID_DB_APP_STATUS_DBNAME, CommandGroup::INTERNAL);
1536 0 : implDescribeSupportedFeature( ".uno:DBStatusUserName", SID_DB_APP_STATUS_USERNAME, CommandGroup::INTERNAL);
1537 0 : implDescribeSupportedFeature( ".uno:DBStatusHostName", SID_DB_APP_STATUS_HOSTNAME, CommandGroup::INTERNAL);
1538 0 : }
1539 : // -----------------------------------------------------------------------------
1540 0 : OApplicationView* OApplicationController::getContainer() const
1541 : {
1542 0 : return static_cast< OApplicationView* >( getView() );
1543 : }
1544 :
1545 : // -----------------------------------------------------------------------------
1546 : // ::com::sun::star::container::XContainerListener
1547 0 : void SAL_CALL OApplicationController::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
1548 : {
1549 0 : SolarMutexGuard aSolarGuard;
1550 0 : ::osl::MutexGuard aGuard( getMutex() );
1551 :
1552 0 : Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
1553 0 : if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
1554 : {
1555 : OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1556 0 : if ( getContainer() )
1557 : {
1558 0 : ::rtl::OUString sName;
1559 0 : _rEvent.Accessor >>= sName;
1560 0 : ElementType eType = getElementType(xContainer);
1561 :
1562 0 : switch( eType )
1563 : {
1564 : case E_TABLE:
1565 0 : ensureConnection();
1566 0 : break;
1567 : case E_FORM:
1568 : case E_REPORT:
1569 : {
1570 0 : Reference< XContainer > xSubContainer(_rEvent.Element,UNO_QUERY);
1571 0 : if ( xSubContainer.is() )
1572 0 : containerFound(xSubContainer);
1573 : }
1574 0 : break;
1575 : default:
1576 0 : break;
1577 : }
1578 0 : getContainer()->elementAdded(eType,sName,_rEvent.Element);
1579 : }
1580 0 : }
1581 0 : }
1582 : // -----------------------------------------------------------------------------
1583 0 : void SAL_CALL OApplicationController::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
1584 : {
1585 0 : SolarMutexGuard aSolarGuard;
1586 0 : ::osl::MutexGuard aGuard( getMutex() );
1587 :
1588 0 : Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
1589 0 : if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
1590 : {
1591 : OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1592 0 : ::rtl::OUString sName;
1593 0 : _rEvent.Accessor >>= sName;
1594 0 : ElementType eType = getElementType(xContainer);
1595 0 : switch( eType )
1596 : {
1597 : case E_TABLE:
1598 0 : ensureConnection();
1599 0 : break;
1600 : case E_FORM:
1601 : case E_REPORT:
1602 : {
1603 0 : Reference<XContent> xContent(xContainer,UNO_QUERY);
1604 0 : if ( xContent.is() )
1605 : {
1606 0 : sName = xContent->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName;
1607 0 : }
1608 : }
1609 0 : break;
1610 : default:
1611 0 : break;
1612 : }
1613 0 : getContainer()->elementRemoved(eType,sName);
1614 0 : }
1615 0 : }
1616 : // -----------------------------------------------------------------------------
1617 0 : void SAL_CALL OApplicationController::elementReplaced( const ContainerEvent& _rEvent ) throw(RuntimeException)
1618 : {
1619 0 : SolarMutexGuard aSolarGuard;
1620 0 : ::osl::MutexGuard aGuard( getMutex() );
1621 :
1622 0 : Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
1623 0 : if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
1624 : {
1625 : OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1626 0 : ::rtl::OUString sName;
1627 : try
1628 : {
1629 0 : _rEvent.Accessor >>= sName;
1630 0 : Reference<XConnection> xConnection;
1631 0 : Reference<XPropertySet> xProp(_rEvent.Element,UNO_QUERY);
1632 0 : ::rtl::OUString sNewName;
1633 :
1634 0 : ElementType eType = getElementType(xContainer);
1635 0 : switch( eType )
1636 : {
1637 : case E_TABLE:
1638 : {
1639 0 : ensureConnection();
1640 0 : if ( xProp.is() && m_xMetaData.is() )
1641 0 : sNewName = ::dbaui::composeTableName( m_xMetaData, xProp, ::dbtools::eInDataManipulation, false, false, false );
1642 : }
1643 0 : break;
1644 : case E_FORM:
1645 : case E_REPORT:
1646 : {
1647 0 : Reference<XContent> xContent(xContainer,UNO_QUERY);
1648 0 : if ( xContent.is() )
1649 : {
1650 0 : sName = xContent->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName;
1651 0 : }
1652 : }
1653 0 : break;
1654 : default:
1655 0 : break;
1656 0 : }
1657 : // getContainer()->elementReplaced(getContainer()->getElementType(),sName,sNewName);
1658 : }
1659 0 : catch( Exception& )
1660 : {
1661 : DBG_UNHANDLED_EXCEPTION();
1662 0 : }
1663 0 : }
1664 0 : }
1665 : namespace
1666 : {
1667 0 : ::rtl::OUString lcl_getToolBarResource(ElementType _eType)
1668 : {
1669 0 : ::rtl::OUString sToolbar;
1670 0 : switch(_eType)
1671 : {
1672 : case E_TABLE:
1673 0 : sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/tableobjectbar" ));
1674 0 : break;
1675 : case E_QUERY:
1676 0 : sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/queryobjectbar" ));
1677 0 : break;
1678 : case E_FORM:
1679 0 : sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/formobjectbar" ));
1680 0 : break;
1681 : case E_REPORT:
1682 0 : sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/reportobjectbar" ));
1683 0 : break;
1684 : case E_NONE:
1685 0 : break;
1686 : default:
1687 : OSL_FAIL("Invalid ElementType!");
1688 0 : break;
1689 : }
1690 0 : return sToolbar;
1691 : }
1692 : }
1693 : // -----------------------------------------------------------------------------
1694 0 : sal_Bool OApplicationController::onContainerSelect(ElementType _eType)
1695 : {
1696 : OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
1697 :
1698 0 : if ( m_eCurrentType != _eType && _eType != E_NONE )
1699 : {
1700 0 : SelectionGuard aSelGuard( *m_pSelectionNotifier );
1701 :
1702 0 : if ( _eType == E_TABLE )
1703 : {
1704 : try
1705 : {
1706 0 : SharedConnection xConnection( ensureConnection() );
1707 0 : if ( xConnection.is() && getContainer()->getDetailView() )
1708 : {
1709 0 : getContainer()->getDetailView()->createTablesPage(xConnection);
1710 0 : Reference<XTablesSupplier> xTabSup(xConnection,UNO_QUERY);
1711 0 : if ( xTabSup.is() )
1712 0 : addContainerListener(xTabSup->getTables());
1713 : }
1714 : else
1715 : {
1716 0 : return sal_False;
1717 0 : }
1718 : }
1719 0 : catch( const Exception& )
1720 : {
1721 0 : return sal_False;
1722 : }
1723 : }
1724 0 : Reference< XLayoutManager > xLayoutManager = getLayoutManager( getFrame() );
1725 0 : if ( xLayoutManager.is() )
1726 : {
1727 0 : ::rtl::OUString sToolbar = lcl_getToolBarResource(_eType);
1728 0 : ::rtl::OUString sDestroyToolbar = lcl_getToolBarResource(m_eCurrentType);
1729 :
1730 0 : xLayoutManager->lock();
1731 0 : xLayoutManager->destroyElement( sDestroyToolbar );
1732 0 : if ( sToolbar.getLength() )
1733 : {
1734 0 : xLayoutManager->createElement( sToolbar );
1735 0 : xLayoutManager->requestElement( sToolbar );
1736 : }
1737 0 : xLayoutManager->unlock();
1738 0 : xLayoutManager->doLayout();
1739 : }
1740 :
1741 0 : if ( _eType != E_TABLE && getContainer()->getDetailView() )
1742 : {
1743 0 : Reference< XNameAccess > xContainer = getElements(_eType);
1744 0 : addContainerListener(xContainer);
1745 0 : getContainer()->getDetailView()->createPage(_eType,xContainer);
1746 : }
1747 :
1748 0 : SelectionByElementType::iterator pendingSelection = m_aPendingSelection.find( _eType );
1749 0 : if ( pendingSelection != m_aPendingSelection.end() )
1750 : {
1751 0 : Sequence< ::rtl::OUString > aSelected( pendingSelection->second.size() );
1752 0 : ::std::copy( pendingSelection->second.begin(), pendingSelection->second.end(), aSelected.getArray() );
1753 0 : getContainer()->selectElements( aSelected );
1754 :
1755 0 : m_aPendingSelection.erase( pendingSelection );
1756 : }
1757 :
1758 0 : InvalidateAll();
1759 : }
1760 0 : m_eCurrentType = _eType;
1761 :
1762 0 : return sal_True;
1763 : }
1764 : // -----------------------------------------------------------------------------
1765 0 : bool OApplicationController::onEntryDoubleClick( SvTreeListBox& _rTree )
1766 : {
1767 0 : if ( getContainer() && getContainer()->isLeaf( _rTree.GetHdlEntry() ) )
1768 : {
1769 : try
1770 : {
1771 : openElement(
1772 : getContainer()->getQualifiedName( _rTree.GetHdlEntry() ),
1773 : getContainer()->getElementType(),
1774 : E_OPEN_NORMAL
1775 0 : );
1776 0 : return true; // handled
1777 : }
1778 0 : catch(const Exception&)
1779 : {
1780 : DBG_UNHANDLED_EXCEPTION();
1781 : }
1782 : }
1783 0 : return false; // not handled
1784 : }
1785 : // -----------------------------------------------------------------------------
1786 0 : bool OApplicationController::impl_isAlterableView_nothrow( const ::rtl::OUString& _rTableOrViewName ) const
1787 : {
1788 : OSL_PRECOND( m_xDataSourceConnection.is(), "OApplicationController::impl_isAlterableView_nothrow: no connection!" );
1789 :
1790 0 : bool bIsAlterableView( false );
1791 : try
1792 : {
1793 0 : Reference< XViewsSupplier > xViewsSupp( m_xDataSourceConnection, UNO_QUERY );
1794 0 : Reference< XNameAccess > xViews;
1795 0 : if ( xViewsSupp.is() )
1796 0 : xViews = xViewsSupp->getViews();
1797 :
1798 0 : Reference< XAlterView > xAsAlterableView;
1799 0 : if ( xViews.is() && xViews->hasByName( _rTableOrViewName ) )
1800 0 : xAsAlterableView.set( xViews->getByName( _rTableOrViewName ), UNO_QUERY );
1801 :
1802 0 : bIsAlterableView = xAsAlterableView.is();
1803 : }
1804 0 : catch( const Exception& )
1805 : {
1806 : DBG_UNHANDLED_EXCEPTION();
1807 : }
1808 0 : return bIsAlterableView;
1809 : }
1810 :
1811 : // -----------------------------------------------------------------------------
1812 0 : Reference< XComponent > OApplicationController::openElement(const ::rtl::OUString& _sName, ElementType _eType,
1813 : ElementOpenMode _eOpenMode, sal_uInt16 _nInstigatorCommand )
1814 : {
1815 0 : return openElementWithArguments( _sName, _eType, _eOpenMode, _nInstigatorCommand, ::comphelper::NamedValueCollection() );
1816 : }
1817 :
1818 : // -----------------------------------------------------------------------------
1819 0 : Reference< XComponent > OApplicationController::openElementWithArguments( const ::rtl::OUString& _sName, ElementType _eType,
1820 : ElementOpenMode _eOpenMode, sal_uInt16 _nInstigatorCommand, const ::comphelper::NamedValueCollection& _rAdditionalArguments )
1821 : {
1822 : OSL_PRECOND( getContainer(), "OApplicationController::openElementWithArguments: no view!" );
1823 0 : if ( !getContainer() )
1824 0 : return NULL;
1825 :
1826 0 : Reference< XComponent > xRet;
1827 0 : if ( _eOpenMode == E_OPEN_DESIGN )
1828 : {
1829 : // OJ: http://www.openoffice.org/issues/show_bug.cgi?id=30382
1830 0 : getContainer()->showPreview(NULL);
1831 : }
1832 :
1833 0 : bool isStandaloneDocument = false;
1834 0 : switch ( _eType )
1835 : {
1836 : case E_REPORT:
1837 0 : if ( _eOpenMode != E_OPEN_DESIGN )
1838 : {
1839 : // reports which are opened in a mode other than design are no sub components of our application
1840 : // component, but standalone documents.
1841 0 : isStandaloneDocument = true;
1842 : }
1843 : // NO break!
1844 : case E_FORM:
1845 : {
1846 0 : if ( isStandaloneDocument || !m_pSubComponentManager->activateSubFrame( _sName, _eType, _eOpenMode, xRet ) )
1847 : {
1848 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1849 0 : ::std::auto_ptr< OLinkedDocumentsAccess > aHelper = getDocumentsAccess( _eType );
1850 : SAL_WNODEPRECATED_DECLARATIONS_POP
1851 0 : if ( !aHelper->isConnected() )
1852 : break;
1853 :
1854 0 : Reference< XComponent > xDefinition;
1855 0 : xRet = aHelper->open( _sName, xDefinition, _eOpenMode, _rAdditionalArguments );
1856 :
1857 0 : if ( !isStandaloneDocument )
1858 0 : onDocumentOpened( _sName, _eType, _eOpenMode, xRet, xDefinition );
1859 : }
1860 : }
1861 0 : break;
1862 :
1863 : case E_QUERY:
1864 : case E_TABLE:
1865 : {
1866 0 : if ( !m_pSubComponentManager->activateSubFrame( _sName, _eType, _eOpenMode, xRet ) )
1867 : {
1868 0 : SharedConnection xConnection( ensureConnection() );
1869 0 : if ( !xConnection.is() )
1870 : break;
1871 :
1872 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1873 0 : ::std::auto_ptr< DatabaseObjectView > pDesigner;
1874 : SAL_WNODEPRECATED_DECLARATIONS_POP
1875 0 : ::comphelper::NamedValueCollection aArguments( _rAdditionalArguments );
1876 :
1877 0 : Any aDataSource;
1878 0 : if ( _eOpenMode == E_OPEN_DESIGN )
1879 : {
1880 0 : bool bAddViewTypeArg = false;
1881 :
1882 0 : if ( _eType == E_TABLE )
1883 : {
1884 0 : if ( impl_isAlterableView_nothrow( _sName ) )
1885 : {
1886 0 : pDesigner.reset( new QueryDesigner( getORB(), this, m_aCurrentFrame.getFrame(), true ) );
1887 0 : bAddViewTypeArg = true;
1888 : }
1889 : else
1890 : {
1891 0 : pDesigner.reset( new TableDesigner( getORB(), this, m_aCurrentFrame.getFrame() ) );
1892 : }
1893 : }
1894 0 : else if ( _eType == E_QUERY )
1895 : {
1896 0 : pDesigner.reset( new QueryDesigner( getORB(), this, m_aCurrentFrame.getFrame(), false ) );
1897 0 : bAddViewTypeArg = true;
1898 : }
1899 0 : aDataSource <<= m_xDataSource;
1900 :
1901 0 : if ( bAddViewTypeArg )
1902 : {
1903 0 : const bool bQueryGraphicalMode =( _nInstigatorCommand != SID_DB_APP_EDIT_SQL_VIEW );
1904 0 : aArguments.put( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, bQueryGraphicalMode );
1905 : }
1906 :
1907 : }
1908 : else
1909 : {
1910 0 : pDesigner.reset( new ResultSetBrowser( getORB(), this, m_aCurrentFrame.getFrame(), _eType == E_TABLE ) );
1911 :
1912 0 : if ( !aArguments.has( (::rtl::OUString)PROPERTY_SHOWMENU ) )
1913 0 : aArguments.put( (::rtl::OUString)PROPERTY_SHOWMENU, makeAny( (sal_Bool)sal_True ) );
1914 :
1915 0 : aDataSource <<= getDatabaseName();
1916 : }
1917 :
1918 0 : xRet.set( pDesigner->openExisting( aDataSource, _sName, aArguments ) );
1919 0 : onDocumentOpened( _sName, _eType, _eOpenMode, xRet, NULL );
1920 : }
1921 : }
1922 0 : break;
1923 :
1924 : default:
1925 : OSL_FAIL( "OApplicationController::openElement: illegal object type!" );
1926 0 : break;
1927 : }
1928 0 : return xRet;
1929 : }
1930 : // -----------------------------------------------------------------------------
1931 0 : IMPL_LINK( OApplicationController, OnSelectContainer, void*, _pType )
1932 : {
1933 0 : ElementType eType = (ElementType)reinterpret_cast< sal_IntPtr >( _pType );
1934 0 : if (getContainer())
1935 0 : getContainer()->selectContainer(eType);
1936 0 : return 0L;
1937 : }
1938 : // -----------------------------------------------------------------------------
1939 0 : IMPL_LINK( OApplicationController, OnCreateWithPilot, void*, _pType )
1940 : {
1941 0 : ElementType eType = (ElementType)reinterpret_cast< sal_IntPtr >( _pType );
1942 0 : newElementWithPilot( eType );
1943 0 : return 0L;
1944 : }
1945 :
1946 : // -----------------------------------------------------------------------------
1947 0 : void OApplicationController::newElementWithPilot( ElementType _eType )
1948 : {
1949 0 : utl::CloseVeto aKeepDoc( getFrame() );
1950 : // prevent the document being closed while the wizard is open
1951 :
1952 : OSL_ENSURE( getContainer(), "OApplicationController::newElementWithPilot: without a view?" );
1953 :
1954 0 : switch ( _eType )
1955 : {
1956 : case E_REPORT:
1957 : case E_FORM:
1958 : {
1959 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1960 0 : ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType);
1961 : SAL_WNODEPRECATED_DECLARATIONS_POP
1962 0 : if ( aHelper->isConnected() )
1963 : {
1964 0 : sal_Int32 nCommandType = -1;
1965 0 : const ::rtl::OUString sCurrentSelected( getCurrentlySelectedName( nCommandType ) );
1966 0 : if ( E_REPORT == _eType )
1967 0 : aHelper->newReportWithPilot( nCommandType, sCurrentSelected );
1968 : else
1969 0 : aHelper->newFormWithPilot( nCommandType, sCurrentSelected );
1970 0 : }
1971 : }
1972 0 : break;
1973 : case E_QUERY:
1974 : case E_TABLE:
1975 : {
1976 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1977 0 : ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType);
1978 : SAL_WNODEPRECATED_DECLARATIONS_POP
1979 0 : if ( aHelper->isConnected() )
1980 : {
1981 0 : if ( E_QUERY == _eType )
1982 0 : aHelper->newQueryWithPilot();
1983 : else
1984 0 : aHelper->newTableWithPilot();
1985 0 : }
1986 : }
1987 0 : break;
1988 : case E_NONE:
1989 0 : break;
1990 0 : }
1991 :
1992 : // no need for onDocumentOpened, the table wizard opens the created table by using
1993 : // XDatabaseDocumentUI::loadComponent method.
1994 0 : }
1995 :
1996 : // -----------------------------------------------------------------------------
1997 0 : Reference< XComponent > OApplicationController::newElement( ElementType _eType, const ::comphelper::NamedValueCollection& i_rAdditionalArguments,
1998 : Reference< XComponent >& o_rDocumentDefinition )
1999 : {
2000 : OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
2001 :
2002 0 : Reference< XComponent > xComponent;
2003 0 : o_rDocumentDefinition.clear();
2004 :
2005 0 : switch ( _eType )
2006 : {
2007 : case E_FORM:
2008 : case E_REPORT:
2009 : {
2010 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2011 0 : ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess( _eType );
2012 : SAL_WNODEPRECATED_DECLARATIONS_POP
2013 0 : if ( !aHelper->isConnected() )
2014 : break;
2015 :
2016 0 : xComponent = aHelper->newDocument( _eType == E_FORM ? ID_FORM_NEW_TEXT : ID_REPORT_NEW_TEXT, i_rAdditionalArguments, o_rDocumentDefinition );
2017 : }
2018 0 : break;
2019 :
2020 : case E_QUERY:
2021 : case E_TABLE:
2022 : {
2023 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2024 0 : ::std::auto_ptr< DatabaseObjectView > pDesigner;
2025 : SAL_WNODEPRECATED_DECLARATIONS_POP
2026 0 : SharedConnection xConnection( ensureConnection() );
2027 0 : if ( !xConnection.is() )
2028 : break;
2029 :
2030 0 : if ( _eType == E_TABLE )
2031 : {
2032 0 : pDesigner.reset( new TableDesigner( getORB(), this, getFrame() ) );
2033 : }
2034 0 : else if ( _eType == E_QUERY )
2035 : {
2036 0 : pDesigner.reset( new QueryDesigner( getORB(), this, getFrame(), false ) );
2037 : }
2038 :
2039 0 : Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
2040 0 : xComponent.set( pDesigner->createNew( xDataSource, i_rAdditionalArguments ), UNO_QUERY );
2041 : }
2042 0 : break;
2043 :
2044 : default:
2045 : OSL_FAIL( "OApplicationController::newElement: illegal type!" );
2046 0 : break;
2047 : }
2048 :
2049 0 : if ( xComponent.is() )
2050 0 : onDocumentOpened( ::rtl::OUString(), _eType, E_OPEN_DESIGN, xComponent, o_rDocumentDefinition );
2051 :
2052 0 : return xComponent;
2053 : }
2054 :
2055 : // -----------------------------------------------------------------------------
2056 0 : void OApplicationController::addContainerListener(const Reference<XNameAccess>& _xCollection)
2057 : {
2058 : try
2059 : {
2060 0 : Reference< XContainer > xCont(_xCollection, UNO_QUERY);
2061 0 : if ( xCont.is() )
2062 : {
2063 : // add as listener to get notified if elements are inserted or removed
2064 0 : TContainerVector::iterator aFind = ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xCont);
2065 0 : if ( aFind == m_aCurrentContainers.end() )
2066 : {
2067 0 : xCont->addContainerListener(this);
2068 0 : m_aCurrentContainers.push_back(xCont);
2069 : }
2070 0 : }
2071 : }
2072 0 : catch( const Exception& )
2073 : {
2074 : DBG_UNHANDLED_EXCEPTION();
2075 : }
2076 0 : }
2077 : // -----------------------------------------------------------------------------
2078 0 : void OApplicationController::renameEntry()
2079 : {
2080 0 : SolarMutexGuard aSolarGuard;
2081 0 : ::osl::MutexGuard aGuard( getMutex() );
2082 :
2083 : OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
2084 0 : ::std::vector< ::rtl::OUString> aList;
2085 0 : getSelectionElementNames(aList);
2086 :
2087 0 : Reference< XNameAccess > xContainer = getElements(getContainer()->getElementType());
2088 : OSL_ENSURE(aList.size() == 1,"Invalid rename call here. More than one element!");
2089 0 : if ( aList.empty() )
2090 0 : return;
2091 :
2092 : try
2093 : {
2094 0 : if ( xContainer.is() )
2095 : {
2096 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2097 0 : ::std::auto_ptr< IObjectNameCheck > pNameChecker;
2098 0 : ::std::auto_ptr< OSaveAsDlg > aDialog;
2099 : SAL_WNODEPRECATED_DECLARATIONS_POP
2100 :
2101 0 : Reference<XRename> xRename;
2102 0 : const ElementType eType = getContainer()->getElementType();
2103 0 : switch( eType )
2104 : {
2105 : case E_FORM:
2106 : case E_REPORT:
2107 : {
2108 0 : Reference<XHierarchicalNameContainer> xHNames(xContainer, UNO_QUERY);
2109 0 : if ( xHNames.is() )
2110 : {
2111 0 : String sLabel;
2112 0 : if ( eType == E_FORM )
2113 0 : sLabel = String(ModuleRes( STR_FRM_LABEL ));
2114 : else
2115 0 : sLabel = String(ModuleRes( STR_RPT_LABEL ));
2116 :
2117 0 : ::rtl::OUString sName = *aList.begin();
2118 0 : if ( xHNames->hasByHierarchicalName(sName) )
2119 : {
2120 0 : xRename.set(xHNames->getByHierarchicalName(sName),UNO_QUERY);
2121 0 : Reference<XChild> xChild(xRename,UNO_QUERY);
2122 0 : if ( xChild.is() )
2123 : {
2124 0 : Reference<XHierarchicalNameContainer> xParent(xChild->getParent(),UNO_QUERY);
2125 0 : if ( xParent.is() )
2126 : {
2127 0 : xHNames = xParent;
2128 0 : Reference<XPropertySet>(xRename,UNO_QUERY)->getPropertyValue(PROPERTY_NAME) >>= sName;
2129 0 : }
2130 : }
2131 0 : pNameChecker.reset( new HierarchicalNameCheck( xHNames.get(), String() ) );
2132 : aDialog.reset( new OSaveAsDlg(
2133 0 : getView(), comphelper::getComponentContext(getORB()), sName, sLabel, *pNameChecker, SAD_TITLE_RENAME ) );
2134 0 : }
2135 0 : }
2136 : }
2137 0 : break;
2138 : case E_TABLE:
2139 0 : ensureConnection();
2140 0 : if ( !getConnection().is() )
2141 0 : break;
2142 : // NO break
2143 : case E_QUERY:
2144 0 : if ( xContainer->hasByName(*aList.begin()) )
2145 : {
2146 0 : xRename.set(xContainer->getByName(*aList.begin()),UNO_QUERY);
2147 0 : sal_Int32 nCommandType = eType == E_QUERY ? CommandType::QUERY : CommandType::TABLE;
2148 :
2149 0 : ensureConnection();
2150 0 : pNameChecker.reset( new DynamicTableOrQueryNameCheck( getConnection(), nCommandType ) );
2151 : aDialog.reset( new OSaveAsDlg(
2152 0 : getView(), nCommandType, comphelper::getComponentContext(getORB()), getConnection(),
2153 0 : *aList.begin(), *pNameChecker, SAD_TITLE_RENAME ) );
2154 : }
2155 0 : break;
2156 : default:
2157 0 : break;
2158 : }
2159 :
2160 0 : if ( xRename.is() && aDialog.get() )
2161 : {
2162 :
2163 0 : sal_Bool bTryAgain = sal_True;
2164 0 : while( bTryAgain )
2165 : {
2166 0 : if ( aDialog->Execute() == RET_OK )
2167 : {
2168 : try
2169 : {
2170 0 : ::rtl::OUString sNewName;
2171 0 : if ( eType == E_TABLE )
2172 : {
2173 0 : ::rtl::OUString sName = aDialog->getName();
2174 0 : ::rtl::OUString sCatalog = aDialog->getCatalog();
2175 0 : ::rtl::OUString sSchema = aDialog->getSchema();
2176 :
2177 0 : sNewName = ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sName, sal_False, ::dbtools::eInDataManipulation );
2178 : }
2179 : else
2180 0 : sNewName = aDialog->getName();
2181 :
2182 0 : ::rtl::OUString sOldName = *aList.begin();
2183 0 : if ( eType == E_FORM || eType == E_REPORT )
2184 : {
2185 0 : Reference<XContent> xContent(xRename,UNO_QUERY);
2186 0 : if ( xContent.is() )
2187 : {
2188 0 : sOldName = xContent->getIdentifier()->getContentIdentifier();
2189 0 : }
2190 : }
2191 :
2192 0 : xRename->rename(sNewName);
2193 :
2194 0 : if ( eType == E_TABLE )
2195 : {
2196 0 : Reference<XPropertySet> xProp(xRename,UNO_QUERY);
2197 0 : sNewName = ::dbaui::composeTableName( m_xMetaData, xProp, ::dbtools::eInDataManipulation, false, false, false );
2198 : }
2199 0 : getContainer()->elementReplaced( eType , sOldName, sNewName );
2200 :
2201 0 : bTryAgain = sal_False;
2202 : }
2203 0 : catch(const SQLException& )
2204 : {
2205 0 : showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
2206 :
2207 : }
2208 0 : catch(const ElementExistException& e)
2209 : {
2210 0 : rtl::OUString sStatus("S1000");
2211 0 : String sMsg = String( ModuleRes( STR_NAME_ALREADY_EXISTS ) );
2212 0 : sMsg.SearchAndReplace(rtl::OUString('#'), e.Message);
2213 0 : showError(SQLExceptionInfo(SQLException(sMsg, e.Context, sStatus, 0, Any())));
2214 : }
2215 0 : catch(const Exception& )
2216 : {
2217 : DBG_UNHANDLED_EXCEPTION();
2218 : }
2219 : }
2220 : else
2221 0 : bTryAgain = sal_False;
2222 : }
2223 0 : }
2224 : }
2225 : }
2226 0 : catch(const Exception& )
2227 : {
2228 : DBG_UNHANDLED_EXCEPTION();
2229 0 : }
2230 : }
2231 :
2232 : // -----------------------------------------------------------------------------
2233 0 : void OApplicationController::onSelectionChanged()
2234 : {
2235 0 : InvalidateAll();
2236 :
2237 0 : SelectionGuard aSelGuard( *m_pSelectionNotifier );
2238 :
2239 0 : OApplicationView* pView = getContainer();
2240 0 : if ( !pView )
2241 0 : return;
2242 :
2243 0 : if ( pView->getSelectionCount() == 1 )
2244 : {
2245 0 : const ElementType eType = pView->getElementType();
2246 0 : if ( pView->isALeafSelected() )
2247 : {
2248 0 : const ::rtl::OUString sName = pView->getQualifiedName( NULL /* means 'first selected' */ );
2249 0 : showPreviewFor( eType, sName );
2250 : }
2251 0 : }
2252 : }
2253 : // -----------------------------------------------------------------------------
2254 0 : void OApplicationController::showPreviewFor(const ElementType _eType,const ::rtl::OUString& _sName)
2255 : {
2256 0 : if ( m_ePreviewMode == E_PREVIEWNONE )
2257 0 : return;
2258 :
2259 0 : OApplicationView* pView = getContainer();
2260 0 : if ( !pView )
2261 0 : return;
2262 :
2263 : try
2264 : {
2265 0 : switch( _eType )
2266 : {
2267 : case E_FORM:
2268 : case E_REPORT:
2269 : {
2270 0 : Reference< XHierarchicalNameAccess > xContainer( getElements( _eType ), UNO_QUERY_THROW );
2271 0 : Reference< XContent> xContent( xContainer->getByHierarchicalName( _sName ), UNO_QUERY_THROW );
2272 0 : pView->showPreview( xContent );
2273 : }
2274 0 : break;
2275 :
2276 : case E_TABLE:
2277 : case E_QUERY:
2278 : {
2279 0 : SharedConnection xConnection( ensureConnection() );
2280 0 : if ( xConnection.is() )
2281 0 : pView->showPreview( getDatabaseName(), xConnection, _sName, _eType == E_TABLE );
2282 : }
2283 0 : return;
2284 :
2285 : default:
2286 : OSL_FAIL( "OApplicationController::showPreviewFor: unexpected element type!" );
2287 0 : break;
2288 : }
2289 : }
2290 0 : catch( const SQLException& )
2291 : {
2292 0 : showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
2293 : }
2294 0 : catch(const Exception& )
2295 : {
2296 : DBG_UNHANDLED_EXCEPTION();
2297 : }
2298 : }
2299 :
2300 : //------------------------------------------------------------------------------
2301 0 : IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged)
2302 : {
2303 0 : OnInvalidateClipboard();
2304 0 : return 0L;
2305 : }
2306 : //------------------------------------------------------------------------------
2307 0 : void OApplicationController::OnInvalidateClipboard()
2308 : {
2309 0 : InvalidateFeature(ID_BROWSER_CUT);
2310 0 : InvalidateFeature(ID_BROWSER_COPY);
2311 0 : InvalidateFeature(ID_BROWSER_PASTE);
2312 0 : InvalidateFeature(SID_DB_APP_PASTE_SPECIAL);
2313 0 : }
2314 : // -----------------------------------------------------------------------------
2315 0 : void OApplicationController::onCutEntry()
2316 : {
2317 0 : }
2318 : // -----------------------------------------------------------------------------
2319 0 : void OApplicationController::onCopyEntry()
2320 : {
2321 0 : Execute(ID_BROWSER_COPY,Sequence<PropertyValue>());
2322 0 : }
2323 : // -----------------------------------------------------------------------------
2324 0 : void OApplicationController::onPasteEntry()
2325 : {
2326 0 : Execute(ID_BROWSER_PASTE,Sequence<PropertyValue>());
2327 0 : }
2328 : // -----------------------------------------------------------------------------
2329 0 : void OApplicationController::onDeleteEntry()
2330 : {
2331 0 : ElementType eType = getContainer()->getElementType();
2332 0 : sal_uInt16 nId = 0;
2333 0 : switch(eType)
2334 : {
2335 : case E_TABLE:
2336 0 : nId = SID_DB_APP_TABLE_DELETE;
2337 0 : break;
2338 : case E_QUERY:
2339 0 : nId = SID_DB_APP_QUERY_DELETE;
2340 0 : break;
2341 : case E_FORM:
2342 0 : nId = SID_DB_APP_FORM_DELETE;
2343 0 : break;
2344 : case E_REPORT:
2345 0 : nId = SID_DB_APP_REPORT_DELETE;
2346 0 : break;
2347 : default:
2348 : OSL_FAIL("Invalid ElementType!");
2349 0 : break;
2350 : }
2351 0 : executeChecked(nId,Sequence<PropertyValue>());
2352 0 : }
2353 :
2354 : // -----------------------------------------------------------------------------
2355 0 : void OApplicationController::executeUnChecked(const URL& _rCommand, const Sequence< PropertyValue>& aArgs)
2356 : {
2357 0 : OApplicationController_CBASE::executeUnChecked( _rCommand, aArgs );
2358 0 : }
2359 :
2360 : // -----------------------------------------------------------------------------
2361 0 : void OApplicationController::executeChecked(const URL& _rCommand, const Sequence< PropertyValue>& aArgs)
2362 : {
2363 0 : OApplicationController_CBASE::executeChecked( _rCommand, aArgs );
2364 0 : }
2365 :
2366 : // -----------------------------------------------------------------------------
2367 0 : void OApplicationController::executeUnChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue>& aArgs)
2368 : {
2369 0 : OApplicationController_CBASE::executeUnChecked( _nCommandId, aArgs );
2370 0 : }
2371 :
2372 : // -----------------------------------------------------------------------------
2373 0 : void OApplicationController::executeChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue>& aArgs)
2374 : {
2375 0 : OApplicationController_CBASE::executeChecked( _nCommandId, aArgs );
2376 0 : }
2377 :
2378 : // -----------------------------------------------------------------------------
2379 0 : sal_Bool OApplicationController::isCommandEnabled(sal_uInt16 _nCommandId) const
2380 : {
2381 0 : return OApplicationController_CBASE::isCommandEnabled( _nCommandId );
2382 : }
2383 :
2384 : // -----------------------------------------------------------------------------
2385 0 : sal_Bool OApplicationController::isCommandEnabled( const ::rtl::OUString& _rCompleteCommandURL ) const
2386 : {
2387 0 : return OApplicationController_CBASE::isCommandEnabled( _rCompleteCommandURL );
2388 : }
2389 :
2390 : // -----------------------------------------------------------------------------
2391 0 : sal_uInt16 OApplicationController::registerCommandURL( const ::rtl::OUString& _rCompleteCommandURL )
2392 : {
2393 0 : return OApplicationController_CBASE::registerCommandURL( _rCompleteCommandURL );
2394 : }
2395 :
2396 : // -----------------------------------------------------------------------------
2397 0 : void OApplicationController::notifyHiContrastChanged()
2398 : {
2399 0 : OApplicationController_CBASE::notifyHiContrastChanged();
2400 0 : }
2401 :
2402 : // -----------------------------------------------------------------------------
2403 0 : Reference< XController > OApplicationController::getXController() throw( RuntimeException )
2404 : {
2405 0 : return OApplicationController_CBASE::getXController();
2406 : }
2407 :
2408 : // -----------------------------------------------------------------------------
2409 0 : bool OApplicationController::interceptUserInput( const NotifyEvent& _rEvent )
2410 : {
2411 0 : return OApplicationController_CBASE::interceptUserInput( _rEvent );
2412 : }
2413 :
2414 : // -----------------------------------------------------------------------------
2415 0 : PopupMenu* OApplicationController::getContextMenu( Control& /*_rControl*/ ) const
2416 : {
2417 0 : return new PopupMenu( ModuleRes( RID_MENU_APP_EDIT ) );
2418 : }
2419 :
2420 : // -----------------------------------------------------------------------------
2421 0 : IController& OApplicationController::getCommandController()
2422 : {
2423 0 : return *static_cast< IApplicationController* >( this );
2424 : }
2425 :
2426 : // -----------------------------------------------------------------------------
2427 0 : ::cppu::OInterfaceContainerHelper* OApplicationController::getContextMenuInterceptors()
2428 : {
2429 0 : return &m_aContextMenuInterceptors;
2430 : }
2431 :
2432 : // -----------------------------------------------------------------------------
2433 0 : Any OApplicationController::getCurrentSelection( Control& _rControl ) const
2434 : {
2435 0 : Sequence< NamedDatabaseObject > aSelection;
2436 0 : getContainer()->describeCurrentSelectionForControl( _rControl, aSelection );
2437 0 : return makeAny( aSelection );
2438 : }
2439 :
2440 : // -----------------------------------------------------------------------------
2441 0 : sal_Bool OApplicationController::requestQuickHelp( const SvTreeListEntry* /*_pEntry*/, String& /*_rText*/ ) const
2442 : {
2443 0 : return sal_False;
2444 : }
2445 :
2446 : // -----------------------------------------------------------------------------
2447 0 : sal_Bool OApplicationController::requestDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
2448 : {
2449 0 : TransferableHelper* pTransfer = NULL;
2450 0 : if ( getContainer() && getContainer()->getSelectionCount() )
2451 : {
2452 : try
2453 : {
2454 0 : pTransfer = copyObject( );
2455 0 : Reference< XTransferable> xEnsureDelete = pTransfer;
2456 :
2457 0 : if ( pTransfer && getContainer()->getDetailView() )
2458 : {
2459 0 : ElementType eType = getContainer()->getElementType();
2460 0 : pTransfer->StartDrag( getContainer()->getDetailView()->getTreeWindow(), ((eType == E_FORM || eType == E_REPORT) ? DND_ACTION_COPYMOVE : DND_ACTION_COPY) );
2461 0 : }
2462 : }
2463 0 : catch(const Exception& )
2464 : {
2465 : DBG_UNHANDLED_EXCEPTION();
2466 : }
2467 : }
2468 :
2469 0 : return NULL != pTransfer;
2470 : }
2471 : // -----------------------------------------------------------------------------
2472 0 : sal_Int8 OApplicationController::queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors )
2473 : {
2474 0 : sal_Int8 nActionAskedFor = _rEvt.mnAction;
2475 : // check if we're a table or query container
2476 0 : OApplicationView* pView = getContainer();
2477 0 : if ( pView && !isDataSourceReadOnly() )
2478 : {
2479 0 : ElementType eType = pView->getElementType();
2480 0 : if ( eType != E_NONE && (eType != E_TABLE || !isConnectionReadOnly()) )
2481 : {
2482 : // check for the concrete type
2483 0 : if(::std::find_if(_rFlavors.begin(),_rFlavors.end(),TAppSupportedSotFunctor(eType,sal_True)) != _rFlavors.end())
2484 0 : return DND_ACTION_COPY;
2485 0 : if ( eType == E_FORM || eType == E_REPORT )
2486 : {
2487 0 : sal_Int8 nAction = OComponentTransferable::canExtractComponentDescriptor(_rFlavors,eType == E_FORM) ? DND_ACTION_COPY : DND_ACTION_NONE;
2488 0 : if ( nAction != DND_ACTION_NONE )
2489 : {
2490 0 : SvTreeListEntry* pHitEntry = pView->getEntry(_rEvt.maPosPixel);
2491 0 : ::rtl::OUString sName;
2492 0 : if ( pHitEntry )
2493 : {
2494 0 : sName = pView->getQualifiedName( pHitEntry );
2495 0 : if ( !sName.isEmpty() )
2496 : {
2497 0 : Reference< XHierarchicalNameAccess > xContainer(getElements(pView->getElementType()),UNO_QUERY);
2498 0 : if ( xContainer.is() && xContainer->hasByHierarchicalName(sName) )
2499 : {
2500 0 : Reference< XHierarchicalNameAccess > xHitObject(xContainer->getByHierarchicalName(sName),UNO_QUERY);
2501 0 : if ( xHitObject.is() )
2502 0 : nAction = nActionAskedFor & DND_ACTION_COPYMOVE;
2503 : }
2504 : else
2505 0 : nAction = DND_ACTION_NONE;
2506 : }
2507 0 : }
2508 : }
2509 0 : return nAction;
2510 : }
2511 : }
2512 : }
2513 :
2514 0 : return DND_ACTION_NONE;
2515 : }
2516 : // -----------------------------------------------------------------------------
2517 0 : sal_Int8 OApplicationController::executeDrop( const ExecuteDropEvent& _rEvt )
2518 : {
2519 0 : OApplicationView* pView = getContainer();
2520 0 : if ( !pView || pView->getElementType() == E_NONE )
2521 : {
2522 : OSL_FAIL("OApplicationController::executeDrop: what the hell did queryDrop do?");
2523 : // queryDrop shoud not have allowed us to reach this situation ....
2524 0 : return DND_ACTION_NONE;
2525 : }
2526 :
2527 : // a TransferableDataHelper for accessing the dropped data
2528 0 : TransferableDataHelper aDroppedData(_rEvt.maDropEvent.Transferable);
2529 :
2530 :
2531 : // reset the data of the previous async drop (if any)
2532 0 : if ( m_nAsyncDrop )
2533 0 : Application::RemoveUserEvent(m_nAsyncDrop);
2534 :
2535 :
2536 0 : m_nAsyncDrop = 0;
2537 0 : m_aAsyncDrop.aDroppedData.clear();
2538 0 : m_aAsyncDrop.nType = pView->getElementType();
2539 0 : m_aAsyncDrop.nAction = _rEvt.mnAction;
2540 0 : m_aAsyncDrop.bError = sal_False;
2541 0 : m_aAsyncDrop.bHtml = sal_False;
2542 0 : m_aAsyncDrop.aUrl = ::rtl::OUString();
2543 :
2544 :
2545 : // loop through the available formats and see what we can do ...
2546 : // first we have to check if it is our own format, if not we have to copy the stream :-(
2547 0 : if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(aDroppedData.GetDataFlavorExVector()) )
2548 : {
2549 0 : m_aAsyncDrop.aDroppedData = ODataAccessObjectTransferable::extractObjectDescriptor(aDroppedData);
2550 :
2551 : // asyncron because we some dialogs and we aren't allowed to show them while in D&D
2552 0 : m_nAsyncDrop = Application::PostUserEvent(LINK(this, OApplicationController, OnAsyncDrop));
2553 0 : return DND_ACTION_COPY;
2554 : }
2555 0 : else if ( OComponentTransferable::canExtractComponentDescriptor(aDroppedData.GetDataFlavorExVector(),m_aAsyncDrop.nType == E_FORM) )
2556 : {
2557 0 : m_aAsyncDrop.aDroppedData = OComponentTransferable::extractComponentDescriptor(aDroppedData);
2558 0 : SvTreeListEntry* pHitEntry = pView->getEntry(_rEvt.maPosPixel);
2559 0 : if ( pHitEntry )
2560 0 : m_aAsyncDrop.aUrl = pView->getQualifiedName( pHitEntry );
2561 :
2562 0 : sal_Int8 nAction = _rEvt.mnAction;
2563 0 : Reference<XContent> xContent;
2564 0 : m_aAsyncDrop.aDroppedData[daComponent] >>= xContent;
2565 0 : if ( xContent.is() )
2566 : {
2567 0 : ::rtl::OUString sName = xContent->getIdentifier()->getContentIdentifier();
2568 0 : sal_Int32 nIndex = 0;
2569 0 : sName = sName.copy(sName.getToken(0,'/',nIndex).getLength() + 1);
2570 0 : if ( m_aAsyncDrop.aUrl.Len() >= sName.getLength() && 0 == sName.compareTo(m_aAsyncDrop.aUrl,sName.getLength()) )
2571 : {
2572 0 : m_aAsyncDrop.aDroppedData.clear();
2573 0 : return DND_ACTION_NONE;
2574 : }
2575 :
2576 : // check if move is allowed, if another object with the same name exists only copy is allowed
2577 0 : Reference< XHierarchicalNameAccess > xContainer(getElements(m_aAsyncDrop.nType),UNO_QUERY);
2578 0 : Reference<XNameAccess> xNameAccess(xContainer,UNO_QUERY);
2579 :
2580 0 : if ( m_aAsyncDrop.aUrl.Len() && xContainer.is() && xContainer->hasByHierarchicalName(m_aAsyncDrop.aUrl) )
2581 0 : xNameAccess.set(xContainer->getByHierarchicalName(m_aAsyncDrop.aUrl),UNO_QUERY);
2582 :
2583 0 : if ( xNameAccess.is() )
2584 : {
2585 0 : Reference<XPropertySet> xProp(xContent,UNO_QUERY);
2586 0 : if ( xProp.is() )
2587 : {
2588 0 : xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
2589 0 : if ( xNameAccess.is() && xNameAccess->hasByName(sName) )
2590 0 : nAction &= ~DND_ACTION_MOVE;
2591 : }
2592 : else
2593 0 : nAction &= ~DND_ACTION_MOVE;
2594 0 : }
2595 : }
2596 0 : if ( nAction != DND_ACTION_NONE )
2597 : {
2598 0 : m_aAsyncDrop.nAction = nAction;
2599 : // asyncron because we some dialogs and we aren't allowed to show them while in D&D
2600 0 : m_nAsyncDrop = Application::PostUserEvent(LINK(this, OApplicationController, OnAsyncDrop));
2601 : }
2602 : else
2603 0 : m_aAsyncDrop.aDroppedData.clear();
2604 0 : return nAction;
2605 : }
2606 : else
2607 : {
2608 0 : SharedConnection xConnection( ensureConnection() );
2609 0 : if ( xConnection.is() && m_aTableCopyHelper.copyTagTable( aDroppedData, m_aAsyncDrop, xConnection ) )
2610 : {
2611 : // asyncron because we some dialogs and we aren't allowed to show them while in D&D
2612 0 : m_nAsyncDrop = Application::PostUserEvent(LINK(this, OApplicationController, OnAsyncDrop));
2613 0 : return DND_ACTION_COPY;
2614 0 : }
2615 : }
2616 :
2617 0 : return DND_ACTION_NONE;
2618 : }
2619 : // -----------------------------------------------------------------------------
2620 0 : Reference< XModel > SAL_CALL OApplicationController::getModel(void) throw( RuntimeException )
2621 : {
2622 0 : return m_xModel;
2623 : }
2624 :
2625 : // -----------------------------------------------------------------------------
2626 0 : void OApplicationController::onAttachedFrame()
2627 : {
2628 0 : sal_Int32 nConnectedControllers( 0 );
2629 : try
2630 : {
2631 0 : Reference< XModel2 > xModel( m_xModel, UNO_QUERY_THROW );
2632 0 : Reference< XEnumeration > xEnumControllers( xModel->getControllers(), UNO_SET_THROW );
2633 0 : while ( xEnumControllers->hasMoreElements() )
2634 : {
2635 0 : Reference< XController > xController( xEnumControllers->nextElement(), UNO_QUERY_THROW );
2636 0 : ++nConnectedControllers;
2637 0 : }
2638 : }
2639 0 : catch( const Exception& )
2640 : {
2641 : DBG_UNHANDLED_EXCEPTION();
2642 : }
2643 :
2644 0 : if ( nConnectedControllers > 1 )
2645 : { // we are not the first connected controller, there were already others
2646 0 : return;
2647 : }
2648 :
2649 0 : m_aControllerConnectedEvent.Call();
2650 : }
2651 :
2652 : // -----------------------------------------------------------------------------
2653 0 : IMPL_LINK( OApplicationController, OnFirstControllerConnected, void*, /**/ )
2654 : {
2655 0 : ::osl::MutexGuard aGuard( getMutex() );
2656 :
2657 0 : if ( !m_xModel.is() )
2658 : {
2659 : OSL_FAIL( "OApplicationController::OnFirstControllerConnected: too late!" );
2660 : }
2661 :
2662 : // if we have forms or reports which contain macros/scripts, then show a warning
2663 : // which suggests the user to migrate them to the database document
2664 0 : Reference< XEmbeddedScripts > xDocumentScripts( m_xModel, UNO_QUERY );
2665 0 : if ( xDocumentScripts.is() )
2666 : {
2667 : // no need to show this warning, obviously the document supports embedding scripts
2668 : // into itself, so there are no "old-style" forms/reports which have macros/scripts
2669 : // themselves
2670 0 : return 0L;
2671 : }
2672 :
2673 : try
2674 : {
2675 : // If the migration just happened, but was not successful, the document is reloaded.
2676 : // In this case, we should not show the warning, again.
2677 0 : ::comphelper::NamedValueCollection aModelArgs( m_xModel->getArgs() );
2678 0 : if ( aModelArgs.getOrDefault( "SuppressMigrationWarning", sal_False ) )
2679 0 : return 0L;
2680 :
2681 : // also, if the document is read-only, then no migration is possible, and the
2682 : // respective menu entry is hidden. So, don't show the warning in this case, too.
2683 0 : if ( Reference< XStorable >( m_xModel, UNO_QUERY_THROW )->isReadonly() )
2684 0 : return 0L;
2685 :
2686 0 : SQLWarning aWarning;
2687 0 : aWarning.Message = String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS ) );
2688 0 : SQLException aDetail;
2689 0 : aDetail.Message = String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS_DETAIL ) );
2690 0 : aWarning.NextException <<= aDetail;
2691 :
2692 0 : Reference< XExecutableDialog > xDialog = ErrorMessageDialog::create( ::comphelper::getComponentContext( getORB() ), "", NULL, makeAny( aWarning ) );
2693 0 : xDialog->execute();
2694 : }
2695 0 : catch( const Exception& )
2696 : {
2697 : DBG_UNHANDLED_EXCEPTION();
2698 : }
2699 :
2700 0 : return 1L;
2701 : }
2702 :
2703 : // -----------------------------------------------------------------------------
2704 0 : void SAL_CALL OApplicationController::attachFrame( const Reference< XFrame > & i_rxFrame ) throw( RuntimeException )
2705 : {
2706 0 : OApplicationController_CBASE::attachFrame( i_rxFrame );
2707 0 : if ( getFrame().is() )
2708 0 : onAttachedFrame();
2709 0 : }
2710 :
2711 : // -----------------------------------------------------------------------------
2712 0 : sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel > & _rxModel) throw( RuntimeException )
2713 : {
2714 0 : ::osl::MutexGuard aGuard( getMutex() );
2715 0 : const Reference< XOfficeDatabaseDocument > xOfficeDoc( _rxModel, UNO_QUERY );
2716 0 : const Reference< XModifiable > xDocModify( _rxModel, UNO_QUERY );
2717 0 : if ( ( !xOfficeDoc.is() || !xDocModify.is() ) && _rxModel.is() )
2718 : {
2719 : OSL_FAIL( "OApplicationController::attachModel: invalid model!" );
2720 0 : return sal_False;
2721 : }
2722 :
2723 0 : if ( m_xModel.is() && ( m_xModel != _rxModel ) && ( _rxModel.is() ) )
2724 : {
2725 : OSL_ENSURE( false, "OApplicationController::attachModel: missing implementation: setting a new model while we have another one!" );
2726 : // we'd need to completely update our view here, close sub components, and the like
2727 0 : return sal_False;
2728 : }
2729 :
2730 : const ::rtl::OUString aPropertyNames[] =
2731 : {
2732 : PROPERTY_URL, PROPERTY_USER
2733 0 : };
2734 :
2735 : // disconnect from old model
2736 : try
2737 : {
2738 0 : if ( m_xDataSource.is() )
2739 : {
2740 0 : for ( size_t i=0; i < sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i )
2741 : {
2742 0 : m_xDataSource->removePropertyChangeListener( aPropertyNames[i], this );
2743 : }
2744 : }
2745 :
2746 0 : Reference< XModifyBroadcaster > xBroadcaster( m_xModel, UNO_QUERY );
2747 0 : if ( xBroadcaster.is() )
2748 0 : xBroadcaster->removeModifyListener( this );
2749 : }
2750 0 : catch( const Exception& )
2751 : {
2752 : DBG_UNHANDLED_EXCEPTION();
2753 : }
2754 :
2755 0 : m_xModel = _rxModel;
2756 0 : m_xDocumentModify = xDocModify;
2757 0 : m_xDataSource.set( xOfficeDoc.is() ? xOfficeDoc->getDataSource() : Reference< XDataSource >(), UNO_QUERY );
2758 :
2759 : // connect to new model
2760 : try
2761 : {
2762 0 : if ( m_xDataSource.is() )
2763 : {
2764 0 : for ( size_t i=0; i < sizeof( aPropertyNames ) / sizeof( aPropertyNames[0] ); ++i )
2765 : {
2766 0 : m_xDataSource->addPropertyChangeListener( aPropertyNames[i], this );
2767 : }
2768 : }
2769 :
2770 0 : Reference< XModifyBroadcaster > xBroadcaster( m_xModel, UNO_QUERY_THROW );
2771 0 : xBroadcaster->addModifyListener( this );
2772 :
2773 : }
2774 0 : catch( const Exception& )
2775 : {
2776 : DBG_UNHANDLED_EXCEPTION();
2777 : }
2778 :
2779 : // initial preview mode
2780 0 : if ( m_xDataSource.is() )
2781 : {
2782 : try
2783 : {
2784 : // to get the 'modified' for the data source
2785 0 : ::comphelper::NamedValueCollection aLayoutInfo( m_xDataSource->getPropertyValue( PROPERTY_LAYOUTINFORMATION ) );
2786 0 : if ( aLayoutInfo.has( (rtl::OUString)INFO_PREVIEW ) )
2787 : {
2788 0 : const sal_Int32 nPreviewMode( aLayoutInfo.getOrDefault( (rtl::OUString)INFO_PREVIEW, (sal_Int32)0 ) );
2789 0 : m_ePreviewMode = static_cast< PreviewMode >( nPreviewMode );
2790 0 : if ( getView() )
2791 0 : getContainer()->switchPreview( m_ePreviewMode );
2792 0 : }
2793 : }
2794 0 : catch( const Exception& )
2795 : {
2796 : DBG_UNHANDLED_EXCEPTION();
2797 : }
2798 : }
2799 :
2800 0 : return sal_True;
2801 : }
2802 : // -----------------------------------------------------------------------------
2803 0 : void OApplicationController::containerFound( const Reference< XContainer >& _xContainer)
2804 : {
2805 : try
2806 : {
2807 0 : if ( _xContainer.is() )
2808 : {
2809 0 : m_aCurrentContainers.push_back(_xContainer);
2810 0 : _xContainer->addContainerListener(this);
2811 : }
2812 : }
2813 0 : catch(const Exception&)
2814 : {
2815 : DBG_UNHANDLED_EXCEPTION();
2816 : }
2817 0 : }
2818 : // -----------------------------------------------------------------------------
2819 0 : ::rtl::OUString OApplicationController::getCurrentlySelectedName(sal_Int32& _rnCommandType) const
2820 : {
2821 0 : _rnCommandType = ( (getContainer()->getElementType() == E_QUERY)
2822 0 : ? CommandType::QUERY : ( (getContainer()->getElementType() == E_TABLE) ? CommandType::TABLE : -1 ));
2823 :
2824 :
2825 0 : ::rtl::OUString sName;
2826 0 : if ( _rnCommandType != -1 )
2827 : {
2828 : try
2829 : {
2830 0 : sName = getContainer()->getQualifiedName( NULL );
2831 : OSL_ENSURE( !sName.isEmpty(), "OApplicationController::getCurrentlySelectedName: no name given!" );
2832 : }
2833 0 : catch( const Exception& )
2834 : {
2835 : DBG_UNHANDLED_EXCEPTION();
2836 : }
2837 : }
2838 0 : return sName;
2839 : }
2840 :
2841 : // -----------------------------------------------------------------------------
2842 0 : void SAL_CALL OApplicationController::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException)
2843 : {
2844 0 : m_pSelectionNotifier->addListener( _Listener );
2845 0 : }
2846 :
2847 : // -----------------------------------------------------------------------------
2848 0 : void SAL_CALL OApplicationController::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException)
2849 : {
2850 0 : m_pSelectionNotifier->removeListener( _Listener );
2851 0 : }
2852 :
2853 : // -----------------------------------------------------------------------------
2854 0 : ::sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) throw (IllegalArgumentException, RuntimeException)
2855 : {
2856 0 : SolarMutexGuard aSolarGuard;
2857 0 : ::osl::MutexGuard aGuard( getMutex() );
2858 0 : Sequence< ::rtl::OUString> aSelection;
2859 0 : if ( !_aSelection.hasValue() || !getView() )
2860 : {
2861 0 : getContainer()->selectElements(aSelection);
2862 0 : return sal_True;
2863 : }
2864 :
2865 : // --------------------------------------------------------------
2866 : // BEGIN compatibility
2867 0 : Sequence< NamedValue > aCurrentSelection;
2868 0 : if ( (_aSelection >>= aCurrentSelection) && aCurrentSelection.getLength() )
2869 : {
2870 0 : ElementType eType = E_NONE;
2871 0 : const NamedValue* pIter = aCurrentSelection.getConstArray();
2872 0 : const NamedValue* pEnd = pIter + aCurrentSelection.getLength();
2873 0 : for(;pIter != pEnd;++pIter)
2874 : {
2875 0 : if ( pIter->Name == "Type" )
2876 : {
2877 0 : sal_Int32 nType = 0;
2878 0 : pIter->Value >>= nType;
2879 0 : if ( nType < DatabaseObject::TABLE || nType > DatabaseObject::REPORT )
2880 0 : throw IllegalArgumentException();
2881 0 : eType = static_cast< ElementType >( nType );
2882 : }
2883 0 : else if ( pIter->Name == "Selection" )
2884 0 : pIter->Value >>= aSelection;
2885 : }
2886 :
2887 0 : m_aSelectContainerEvent.CancelCall(); // just in case the async select request was running
2888 0 : getContainer()->selectContainer(eType);
2889 0 : getContainer()->selectElements(aSelection);
2890 0 : return sal_True;
2891 : }
2892 : // END compatibility
2893 : // --------------------------------------------------------------
2894 :
2895 0 : Sequence< NamedDatabaseObject > aSelectedObjects;
2896 0 : if ( !( _aSelection >>= aSelectedObjects ) )
2897 : {
2898 0 : aSelectedObjects.realloc( 1 );
2899 0 : if ( !( _aSelection >>= aSelectedObjects[0] ) )
2900 0 : throw IllegalArgumentException();
2901 : }
2902 :
2903 0 : SelectionByElementType aSelectedElements;
2904 0 : ElementType eSelectedCategory = E_NONE;
2905 0 : for ( const NamedDatabaseObject* pObject = aSelectedObjects.getConstArray();
2906 0 : pObject != aSelectedObjects.getConstArray() + aSelectedObjects.getLength();
2907 : ++pObject
2908 : )
2909 : {
2910 0 : switch ( pObject->Type )
2911 : {
2912 : case DatabaseObject::TABLE:
2913 : case DatabaseObjectContainer::SCHEMA:
2914 : case DatabaseObjectContainer::CATALOG:
2915 0 : aSelectedElements[ E_TABLE ].push_back( pObject->Name );
2916 0 : break;
2917 : case DatabaseObject::QUERY:
2918 0 : aSelectedElements[ E_QUERY ].push_back( pObject->Name );
2919 0 : break;
2920 : case DatabaseObject::FORM:
2921 : case DatabaseObjectContainer::FORMS_FOLDER:
2922 0 : aSelectedElements[ E_FORM ].push_back( pObject->Name );
2923 0 : break;
2924 : case DatabaseObject::REPORT:
2925 : case DatabaseObjectContainer::REPORTS_FOLDER:
2926 0 : aSelectedElements[ E_REPORT ].push_back( pObject->Name );
2927 0 : break;
2928 : case DatabaseObjectContainer::TABLES:
2929 : case DatabaseObjectContainer::QUERIES:
2930 : case DatabaseObjectContainer::FORMS:
2931 : case DatabaseObjectContainer::REPORTS:
2932 0 : if ( eSelectedCategory != E_NONE )
2933 : throw IllegalArgumentException(
2934 : String(ModuleRes(RID_STR_NO_DIFF_CAT)),
2935 0 : *this, sal_Int16( pObject - aSelectedObjects.getConstArray() ) );
2936 : eSelectedCategory =
2937 : ( pObject->Type == DatabaseObjectContainer::TABLES ) ? E_TABLE
2938 : : ( pObject->Type == DatabaseObjectContainer::QUERIES ) ? E_QUERY
2939 : : ( pObject->Type == DatabaseObjectContainer::FORMS ) ? E_FORM
2940 : : ( pObject->Type == DatabaseObjectContainer::REPORTS ) ? E_REPORT
2941 0 : : E_NONE;
2942 0 : break;
2943 :
2944 : default:
2945 : case DatabaseObjectContainer::DATA_SOURCE:
2946 : {
2947 : ::rtl::OUString sMessage(
2948 : rtl::OUString(
2949 : String(ModuleRes(RID_STR_UNSUPPORTED_OBJECT_TYPE))).
2950 0 : replaceFirst("$type$", ::rtl::OUString::valueOf(sal_Int32(pObject->Type))));
2951 0 : throw IllegalArgumentException(sMessage, *this, sal_Int16( pObject - aSelectedObjects.getConstArray() ));
2952 : }
2953 : }
2954 : }
2955 :
2956 0 : for ( SelectionByElementType::const_iterator sel = aSelectedElements.begin();
2957 0 : sel != aSelectedElements.end();
2958 : ++sel
2959 : )
2960 : {
2961 0 : if ( sel->first == m_eCurrentType )
2962 : {
2963 0 : Sequence< ::rtl::OUString > aSelected( sel->second.size() );
2964 0 : ::std::copy( sel->second.begin(), sel->second.end(), aSelected.getArray() );
2965 0 : getContainer()->selectElements( aSelected );
2966 : }
2967 : else
2968 : {
2969 0 : m_aPendingSelection[ sel->first ] = sel->second;
2970 : }
2971 : }
2972 :
2973 0 : m_aSelectContainerEvent.CancelCall(); // just in case the async select request was running
2974 0 : getContainer()->selectContainer( eSelectedCategory );
2975 :
2976 0 : return sal_True;
2977 : }
2978 : // -----------------------------------------------------------------------------
2979 0 : Any SAL_CALL OApplicationController::getSelection( ) throw (RuntimeException)
2980 : {
2981 0 : SolarMutexGuard aSolarGuard;
2982 0 : ::osl::MutexGuard aGuard( getMutex() );
2983 :
2984 0 : Sequence< NamedDatabaseObject > aCurrentSelection;
2985 0 : const ElementType eType( getContainer()->getElementType() );
2986 0 : if ( eType != E_NONE )
2987 : {
2988 0 : getContainer()->describeCurrentSelectionForType( eType, aCurrentSelection );
2989 0 : if ( aCurrentSelection.getLength() == 0 )
2990 : { // if no objects are selected, add an entry to the sequence which describes the overall category
2991 : // which is selected currently
2992 0 : aCurrentSelection.realloc(1);
2993 0 : aCurrentSelection[0].Name = getDatabaseName();
2994 0 : switch ( eType )
2995 : {
2996 0 : case E_TABLE: aCurrentSelection[0].Type = DatabaseObjectContainer::TABLES; break;
2997 0 : case E_QUERY: aCurrentSelection[0].Type = DatabaseObjectContainer::QUERIES; break;
2998 0 : case E_FORM: aCurrentSelection[0].Type = DatabaseObjectContainer::FORMS; break;
2999 0 : case E_REPORT: aCurrentSelection[0].Type = DatabaseObjectContainer::REPORTS; break;
3000 : default:
3001 : OSL_FAIL( "OApplicationController::getSelection: unexpected current element type!" );
3002 0 : break;
3003 : }
3004 : }
3005 : }
3006 0 : return makeAny( aCurrentSelection );
3007 : }
3008 : // -----------------------------------------------------------------------------
3009 0 : void OApplicationController::impl_migrateScripts_nothrow()
3010 : {
3011 : try
3012 : {
3013 0 : ::rtl::OUString sDialogService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.application.MacroMigrationWizard" ) );
3014 0 : ::comphelper::ComponentContext aContext( getORB() );
3015 0 : Sequence< Any > aDialogArgs(1);
3016 0 : aDialogArgs[0] <<= Reference< XOfficeDatabaseDocument >( m_xModel, UNO_QUERY_THROW );
3017 : Reference< XExecutableDialog > xDialog(
3018 : aContext.createComponentWithArguments( sDialogService, aDialogArgs ),
3019 0 : UNO_QUERY );
3020 :
3021 0 : if ( !xDialog.is() )
3022 : {
3023 0 : ShowServiceNotAvailableError( getView(), sDialogService, true );
3024 0 : return;
3025 : }
3026 :
3027 0 : xDialog->execute();
3028 : }
3029 0 : catch( const Exception& )
3030 : {
3031 : DBG_UNHANDLED_EXCEPTION();
3032 : }
3033 : }
3034 :
3035 : //........................................................................
3036 0 : } // namespace dbaui
3037 : //........................................................................
3038 :
3039 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|