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