LibreOffice Module dbaccess (master) 1
AppControllerGen.cxx
Go to the documentation of this file.
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#include "AppController.hxx"
21#include "AppDetailView.hxx"
22#include "AppView.hxx"
23#include <core_resource.hxx>
24#include <dbaccess_slotid.hrc>
25#include <strings.hrc>
26#include <strings.hxx>
28#include <dlgsave.hxx>
29#include <UITools.hxx>
31
32#include <com/sun/star/container/XChild.hpp>
33#include <com/sun/star/container/XContainer.hpp>
34#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
35#include <com/sun/star/container/XNameAccess.hpp>
36#include <com/sun/star/sdb/CommandType.hpp>
37#include <com/sun/star/sdb/XQueriesSupplier.hpp>
38#include <com/sun/star/sdbcx/XRename.hpp>
39#include <com/sun/star/sdb/ErrorCondition.hpp>
40#include <com/sun/star/sdb/application/DatabaseObject.hpp>
41#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
42#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
43#include <com/sun/star/util/XRefreshable.hpp>
44
46#include <comphelper/types.hxx>
50#include <sfx2/mailmodelapi.hxx>
51#include <svx/dbaexchange.hxx>
54#include <osl/diagnose.h>
55#include <vcl/mnemonic.hxx>
56#include <vcl/svapp.hxx>
57#include <vcl/syswin.hxx>
58#include <vcl/weld.hxx>
59#include <osl/mutex.hxx>
60
61namespace dbaui
62{
63using namespace ::dbtools;
64using namespace ::connectivity;
65using namespace ::svx;
66using namespace ::com::sun::star;
67using namespace ::com::sun::star::uno;
68using namespace ::com::sun::star::awt;
69using namespace ::com::sun::star::util;
70using namespace ::com::sun::star::frame;
71using namespace ::com::sun::star::lang;
72using namespace ::com::sun::star::ui::dialogs;
73using namespace ::com::sun::star::sdb;
74using namespace ::com::sun::star::sdbc;
75using namespace ::com::sun::star::sdbcx;
76using namespace ::com::sun::star::beans;
77using namespace ::com::sun::star::container;
78using namespace ::com::sun::star::ucb;
79
80using ::com::sun::star::ui::XContextMenuInterceptor;
81
82namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
83namespace ErrorCondition = ::com::sun::star::sdb::ErrorCondition;
84
85void OApplicationController::convertToView(const OUString& _sName)
86{
87 try
88 {
89 SharedConnection xConnection( getConnection() );
90 Reference< XQueriesSupplier > xSup( xConnection, UNO_QUERY_THROW );
91 Reference< XNameAccess > xQueries( xSup->getQueries(), UNO_SET_THROW );
92 Reference< XPropertySet > xSourceObject( xQueries->getByName( _sName ), UNO_QUERY_THROW );
93
94 Reference< XTablesSupplier > xTablesSup( xConnection, UNO_QUERY_THROW );
95 Reference< XNameAccess > xTables( xTablesSup->getTables(), UNO_SET_THROW );
96
97 Reference< XDatabaseMetaData > xMeta = xConnection->getMetaData();
98
99 const OUString aDefaultName = ::dbaui::createDefaultName(xMeta, xTables, DBA_RES(STR_TBL_TITLE).getToken(0, ' '));
100
101 DynamicTableOrQueryNameCheck aNameChecker( xConnection, CommandType::TABLE );
102 OSaveAsDlg aDlg(getFrameWeld(), CommandType::TABLE, getORB(), xConnection, aDefaultName, aNameChecker, SADFlags::NONE);
103 if (aDlg.run() == RET_OK)
104 {
105 OUString sName = aDlg.getName();
106 OUString sCatalog = aDlg.getCatalog();
107 OUString sSchema = aDlg.getSchema();
108 OUString sNewName(
109 ::dbtools::composeTableName( xMeta, sCatalog, sSchema, sName, false, ::dbtools::EComposeRule::InTableDefinitions ) );
110 Reference<XPropertySet> xView = ::dbaui::createView(sNewName,xConnection,xSourceObject);
111 if ( !xView.is() )
112 throw SQLException(DBA_RES(STR_NO_TABLE_FORMAT_INSIDE),*this, "S1000",0,Any());
113 getContainer()->elementAdded(E_TABLE,sNewName,Any(xView));
114 }
115 }
116 catch(const SQLException& )
117 {
118 showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
119 }
120 catch( const Exception& )
121 {
122 DBG_UNHANDLED_EXCEPTION("dbaccess");
123 }
124}
125
127{
128 if ( _nFormatId == SotClipboardFormatId::NONE )
129 return;
130
131 try
132 {
133 const TransferableDataHelper& rClipboard = getViewClipboard();
135 if ( eType == E_TABLE )
136 {
137 m_aTableCopyHelper.pasteTable( _nFormatId, rClipboard, getDatabaseName(), ensureConnection() );
138 }
139 else
140 paste( eType, ODataAccessObjectTransferable::extractObjectDescriptor( rClipboard ) );
141
142 }
143 catch( const Exception& )
144 {
145 DBG_UNHANDLED_EXCEPTION("dbaccess");
146 }
147}
148
149void OApplicationController::openDialog( const OUString& _sServiceName )
150{
151 try
152 {
153 SolarMutexGuard aSolarGuard;
154 ::osl::MutexGuard aGuard( getMutex() );
156
157 Sequence< Any > aArgs(3);
158 auto pArgs = aArgs.getArray();
159 sal_Int32 nArgPos = 0;
160
162 if ( !xWindow.is() )
163 {
164 OSL_ENSURE( getContainer(), "OApplicationController::Construct: have no view!" );
165 if ( getContainer() )
167 }
168 // the parent window
169 pArgs[nArgPos++] <<= PropertyValue( "ParentWindow",
170 0,
171 Any(xWindow),
172 PropertyState_DIRECT_VALUE);
173
174 // the initial selection
175 OUString sInitialSelection;
176 if ( getContainer() )
177 sInitialSelection = getDatabaseName();
178 if ( !sInitialSelection.isEmpty() )
179 {
180 pArgs[ nArgPos++ ] <<= PropertyValue(
181 "InitialSelection", 0,
182 Any( sInitialSelection ), PropertyState_DIRECT_VALUE );
183 }
184
185 SharedConnection xConnection( getConnection() );
186 if ( xConnection.is() )
187 {
188 pArgs[ nArgPos++ ] <<= PropertyValue(
190 makeAny( xConnection ), PropertyState_DIRECT_VALUE );
191 }
192 aArgs.realloc( nArgPos );
193
194 // create the dialog
196 xAdminDialog.set(
197 getORB()->getServiceManager()->createInstanceWithArgumentsAndContext(_sServiceName, aArgs, getORB()),
198 UNO_QUERY);
199
200 // execute it
201 if (xAdminDialog.is())
202 xAdminDialog->execute();
203 }
204 catch( const Exception& )
205 {
206 DBG_UNHANDLED_EXCEPTION("dbaccess");
207 }
208}
209
211{
212 if ( !(getContainer() && getContainer()->getDetailView()) )
213 return;
214
216 OSL_ENSURE(getContainer()->getElementType() == E_TABLE,"Only allowed when the tables container is selected!");
217 try
218 {
219 Reference<XRefreshable> xRefresh(getElements(E_TABLE),UNO_QUERY);
220 if ( xRefresh.is() )
221 xRefresh->refresh();
222 }
223 catch(const Exception&)
224 {
225 OSL_FAIL("Could not refresh tables!");
226 }
227
230}
231
232void SAL_CALL OApplicationController::propertyChange( const PropertyChangeEvent& evt )
233{
234 SolarMutexGuard aSolarGuard;
235 ::osl::MutexGuard aGuard( getMutex() );
236 if ( evt.PropertyName == PROPERTY_USER )
237 {
238 m_bNeedToReconnect = true;
239 InvalidateFeature(SID_DB_APP_STATUS_USERNAME);
240 }
241 else if ( evt.PropertyName == PROPERTY_URL )
242 {
243 m_bNeedToReconnect = true;
244 InvalidateFeature(SID_DB_APP_STATUS_DBNAME);
245 InvalidateFeature(SID_DB_APP_STATUS_TYPE);
246 InvalidateFeature(SID_DB_APP_STATUS_HOSTNAME);
247 }
248 else if ( PROPERTY_NAME == evt.PropertyName )
249 {
251 if ( eType == E_FORM || eType == E_REPORT )
252 {
253 OUString sOldName,sNewName;
254 evt.OldValue >>= sOldName;
255 evt.NewValue >>= sNewName;
256
257 // if the old name is empty, then this is a newly inserted content. We're notified of it via the
258 // elementInserted method, so there's no need to handle it here.
259
260 if ( !sOldName.isEmpty() )
261 {
262 Reference<XChild> xChild(evt.Source,UNO_QUERY);
263 if ( xChild.is() )
264 {
265 Reference<XContent> xContent(xChild->getParent(),UNO_QUERY);
266 if ( xContent.is() )
267 sOldName = xContent->getIdentifier()->getContentIdentifier() + "/" + sOldName;
268 }
269
270 getContainer()->elementReplaced( eType , sOldName, sNewName );
271 }
272 }
273 }
274
275 EventObject aEvt;
276 aEvt.Source = m_xModel;
277 modified(aEvt);
278}
279
281{
282 ::osl::MutexGuard aGuard( getMutex() );
283 Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
284 return xDataSource;
285}
286
288{
289 ::osl::MutexGuard aGuard( getMutex() );
290 Reference< XFrame > xFrame( getFrame(), UNO_SET_THROW );
291 Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
292 return xWindow;
293}
294
296{
297 ::osl::MutexGuard aGuard( getMutex() );
298 return m_pSubComponentManager->getSubComponents();
299}
300
302{
303 ::osl::MutexGuard aGuard( getMutex() );
305}
306
308{
309 ::osl::MutexGuard aGuard( getMutex() );
311}
312
314{
315 SQLExceptionInfo aError;
316 SharedConnection xConnection = ensureConnection( &aError );
317 if ( !xConnection.is() )
318 {
319 if ( aError.isValid() )
320 aError.doThrow();
321
322 // no particular error, but nonetheless could not connect -> throw a generic exception
323 OUString sConnectingContext( DBA_RES( STR_COULDNOTCONNECT_DATASOURCE ) );
324 ::dbtools::throwGenericSQLException( sConnectingContext.replaceFirst( "$name$", getStrippedDatabaseName() ), *this );
325 }
326}
327
328beans::Pair< ::sal_Int32, OUString > SAL_CALL OApplicationController::identifySubComponent( const Reference< XComponent >& i_rSubComponent )
329{
330 ::osl::MutexGuard aGuard( getMutex() );
331
332 sal_Int32 nType = -1;
333 OUString sName;
334
335 if ( !m_pSubComponentManager->lookupSubComponent( i_rSubComponent, sName, nType ) )
336 throw IllegalArgumentException( OUString(), *this, 1 );
337
338 if ( nType == SID_DB_APP_DSRELDESIGN )
339 // this is somewhat hacky ... we're expected to return a DatabaseObject value. However, there is no such
340 // value for the relation design. /me thinks we should change the API definition here ...
341 nType = -1;
342
343 return beans::Pair< ::sal_Int32, OUString >( nType, sName );
344}
345
347{
348 SolarMutexGuard aSolarGuard;
349 ::osl::MutexGuard aGuard( getMutex() );
350 return m_pSubComponentManager->closeSubComponents();
351}
352
353namespace
354{
355 ElementType lcl_objectType2ElementType( const sal_Int32 _nObjectType )
356 {
358 switch ( _nObjectType )
359 {
360 case DatabaseObject::TABLE: eType = E_TABLE; break;
361 case DatabaseObject::QUERY: eType = E_QUERY; break;
362 case DatabaseObject::FORM: eType = E_FORM; break;
364 default:
365 OSL_FAIL( "lcl_objectType2ElementType: unsupported object type!" );
366 // this should have been caught earlier
367 }
368 return eType;
369 }
370}
371
372void OApplicationController::impl_validateObjectTypeAndName_throw( const sal_Int32 _nObjectType, const ::std::optional< OUString >& i_rObjectName )
373{
374 // ensure we're connected
375 if ( !isConnected() )
376 {
377 SQLError aError;
378 aError.raiseException( ErrorCondition::DB_NOT_CONNECTED, *this );
379 }
380
381 // ensure a proper object type
382 if ( ( _nObjectType != DatabaseObject::TABLE )
383 && ( _nObjectType != DatabaseObject::QUERY )
384 && ( _nObjectType != DatabaseObject::FORM )
385 && ( _nObjectType != DatabaseObject::REPORT )
386 )
387 throw IllegalArgumentException( OUString(), *this, 1 );
388
389 if ( !i_rObjectName )
390 return;
391
392 // ensure an existing object
393 Reference< XNameAccess > xContainer( getElements( lcl_objectType2ElementType( _nObjectType ) ) );
394 if ( !xContainer.is() )
395 // all possible reasons for this (e.g. not being connected currently) should
396 // have been handled before
397 throw RuntimeException( OUString(), *this );
398
399 bool bExistentObject = false;
400 switch ( _nObjectType )
401 {
404 bExistentObject = xContainer->hasByName( *i_rObjectName );
405 break;
406 case DatabaseObject::FORM:
408 {
409 Reference< XHierarchicalNameAccess > xHierarchy( xContainer, UNO_QUERY_THROW );
410 bExistentObject = xHierarchy->hasByHierarchicalName( *i_rObjectName );
411 }
412 break;
413 }
414
415 if ( !bExistentObject )
416 throw NoSuchElementException( *i_rObjectName, *this );
417}
418
420 const OUString& ObjectName, sal_Bool ForEditing )
421{
422 return loadComponentWithArguments( ObjectType, ObjectName, ForEditing, Sequence< PropertyValue >() );
423}
424
426 const OUString& ObjectName, sal_Bool ForEditing, const Sequence< PropertyValue >& Arguments )
427{
428 SolarMutexGuard aSolarGuard;
429 ::osl::MutexGuard aGuard( getMutex() );
430
432
434 ObjectName,
435 lcl_objectType2ElementType( ObjectType ),
437 ForEditing ? SID_DB_APP_EDIT : SID_DB_APP_OPEN,
439 ) );
440
441 return xComponent;
442}
443
444Reference< XComponent > SAL_CALL OApplicationController::createComponent( ::sal_Int32 i_nObjectType, Reference< XComponent >& o_DocumentDefinition )
445{
446 return createComponentWithArguments( i_nObjectType, Sequence< PropertyValue >(), o_DocumentDefinition );
447}
448
449Reference< XComponent > SAL_CALL OApplicationController::createComponentWithArguments( ::sal_Int32 i_nObjectType, const Sequence< PropertyValue >& i_rArguments, Reference< XComponent >& o_DocumentDefinition )
450{
451 SolarMutexGuard aSolarGuard;
452 ::osl::MutexGuard aGuard( getMutex() );
453
454 impl_validateObjectTypeAndName_throw( i_nObjectType, ::std::optional< OUString >() );
455
457 lcl_objectType2ElementType( i_nObjectType ),
459 o_DocumentDefinition
460 ) );
461
462 return xComponent;
463}
464
466{
467 if ( Interceptor.is() )
469}
470
472{
474}
475
477{
478 SolarMutexGuard aSolarGuard;
479 ::osl::MutexGuard aGuard( getMutex() );
480
481 if ( m_xDataSource.is() && !isDataSourceReadOnly() )
482 {
483 try
484 {
486 sal_Int32 nOldMode = aLayoutInfo.getOrDefault( "Preview", _nMode );
487 if ( nOldMode != _nMode )
488 {
489 aLayoutInfo.put( "Preview", _nMode );
490 m_xDataSource->setPropertyValue( PROPERTY_LAYOUTINFORMATION, Any( aLayoutInfo.getPropertyValues() ) );
491 }
492 }
493 catch ( const Exception& )
494 {
495 DBG_UNHANDLED_EXCEPTION("dbaccess");
496 }
497 }
498 InvalidateFeature(SID_DB_APP_DISABLE_PREVIEW);
499 InvalidateFeature(SID_DB_APP_VIEW_DOCINFO_PREVIEW);
500 InvalidateFeature(SID_DB_APP_VIEW_DOC_PREVIEW);
501}
502
504{
505 if ( !m_bNeedToReconnect )
506 return;
507
508 m_bNeedToReconnect = false;
509 bool bClear = true;
510 if ( !m_pSubComponentManager->empty() )
511 {
512 std::unique_ptr<weld::MessageDialog> xQry(Application::CreateMessageDialog(getFrameWeld(),
513 VclMessageType::Question, VclButtonsType::YesNo,
514 DBA_RES(STR_QUERY_CLOSEDOCUMENTS)));
515 switch (xQry->run())
516 {
517 case RET_YES:
519 break;
520 default:
521 bClear = false;
522 break;
523 }
524 }
525 if ( bClear )
526 {
528 disconnect();
530 getContainer()->selectContainer(E_NONE); // invalidate the old selection
532 getContainer()->selectContainer(eType); // reselect the current one again
533 }
534}
535
537{
538 OUString sDatabaseName;
539 try
540 {
541 if ( m_xDataSource.is() )
542 {
543 OSL_VERIFY( m_xDataSource->getPropertyValue( PROPERTY_NAME ) >>= sDatabaseName );
544 }
545 }
546 catch ( const Exception& )
547 {
548 DBG_UNHANDLED_EXCEPTION("dbaccess");
549 }
550 return sDatabaseName;
551}
552
554{
555 OUString sDatabaseName;
557}
558
559void OApplicationController::onDocumentOpened( const OUString& _rName, const sal_Int32 _nType,
560 const ElementOpenMode _eMode, const Reference< XComponent >& _xDocument, const Reference< XComponent >& _rxDefinition )
561{
562 if ( !_xDocument.is() )
563 return;
564
565 try
566 {
567 OSL_ENSURE( _xDocument.is(), "OApplicationController::onDocumentOpened: is there any *valid* scenario where this fails?" );
568 m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _xDocument.is() ? _xDocument : _rxDefinition );
569
570 if ( _rxDefinition.is() )
571 {
572 Reference< XPropertySet > xProp( _rxDefinition, UNO_QUERY_THROW );
573 Reference< XPropertySetInfo > xPSI( xProp->getPropertySetInfo(), UNO_SET_THROW );
574 xProp->addPropertyChangeListener( PROPERTY_NAME, static_cast< XPropertyChangeListener* >( this ) );
575 }
576 }
577 catch( const Exception& )
578 {
579 DBG_UNHANDLED_EXCEPTION("dbaccess");
580 }
581}
582
583bool OApplicationController::insertHierarchyElement(ElementType _eType, const OUString& _sParentFolder, bool _bCollection, const Reference<XContent>& _xContent, bool _bMove)
584{
585 Reference<XHierarchicalNameContainer> xNames(getElements(_eType), UNO_QUERY);
587 ,getORB()
588 ,xNames
589 ,_sParentFolder
590 ,_eType == E_FORM
591 ,_bCollection
592 ,_xContent
593 ,_bMove);
594}
595
597{
599 bool bEnabled = !isDataSourceReadOnly() && eType == _eType;
600 if ( bEnabled )
601 {
602
603 if ( E_TABLE == eType )
605
606 bool bCompareRes = false;
607 if ( _bDelete )
608 bCompareRes = getContainer()->getSelectionCount() > 0;
609 else
610 {
611 bCompareRes = getContainer()->getSelectionCount() == 1;
612 if ( bEnabled && bCompareRes && E_TABLE == eType )
613 {
614 std::vector< OUString> aList;
616
617 try
618 {
619 Reference< XNameAccess > xContainer = const_cast<OApplicationController*>(this)->getElements(eType);
620 bEnabled = (xContainer.is() && xContainer->hasByName(*aList.begin()));
621 if ( bEnabled )
622 bEnabled = Reference<XRename>(xContainer->getByName(*aList.begin()),UNO_QUERY).is();
623 }
624 catch(Exception&)
625 {
626 bEnabled = false;
627 }
628 }
629 }
630
631 bEnabled = bEnabled && bCompareRes;
632 }
633 return bEnabled;
634}
635
637{
638
639 if ( !_xLayoutManager.is() )
640 return;
641
642 static constexpr OUStringLiteral s_sStatusbar = u"private:resource/statusbar/statusbar";
643 _xLayoutManager->createElement( s_sStatusbar );
644 _xLayoutManager->requestElement( s_sStatusbar );
645
646 if ( getContainer() )
647 {
648 // we need to share the "mnemonic space":
649 MnemonicGenerator aMnemonicGenerator;
650 // - the menu already has mnemonics
651 if (SystemWindow* pSystemWindow = getContainer()->GetSystemWindow())
652 pSystemWindow->CollectMenuBarMnemonics(aMnemonicGenerator);
653 // - the icons should use automatic ones
654 getContainer()->createIconAutoMnemonics( aMnemonicGenerator );
655 // - as well as the entries in the task pane
656 getContainer()->setTaskExternalMnemonics( aMnemonicGenerator );
657 }
658
659 Execute( SID_DB_APP_VIEW_FORMS, Sequence< PropertyValue >() );
661}
662
663void OApplicationController::doAction(sal_uInt16 _nId, const ElementOpenMode _eOpenMode)
664{
665 std::vector< OUString> aList;
669 ElementOpenMode eOpenMode = _eOpenMode;
670 if ( eType == E_REPORT && ElementOpenMode::Mail == _eOpenMode )
671 {
672 aArguments.put("Hidden",true);
674 }
675
676 std::vector< std::pair< OUString ,Reference< XModel > > > aComponents;
677 for (auto const& elem : aList)
678 {
679 if ( SID_DB_APP_CONVERTTOVIEW == _nId )
680 convertToView(elem);
681 else
682 {
684 aComponents.emplace_back( elem, xModel );
685 }
686 }
687
688 // special handling for mail, if more than one document is selected attach them all
689 if ( _eOpenMode != ElementOpenMode::Mail )
690 return;
691
692
693 SfxMailModel aSendMail;
695 for (auto const& component : aComponents)
696 {
697 try
698 {
699 Reference< XModel > xModel = component.second;
700
701 // Send document as e-Mail using stored/default type
702 eResult = aSendMail.AttachDocument(xModel,component.first);
703 ::comphelper::disposeComponent(xModel);
704 if (eResult != SfxMailModel::SEND_MAIL_OK)
705 break;
706 }
707 catch(const Exception&)
708 {
709 DBG_UNHANDLED_EXCEPTION("dbaccess");
710 }
711 }
712 if ( !aSendMail.IsEmpty() )
713 aSendMail.Send( getFrame() );
714}
715
717{
718 ElementType eRet = E_NONE;
719 Reference<XServiceInfo> xServiceInfo(_xContainer,UNO_QUERY);
720 if ( xServiceInfo.is() )
721 {
722 if ( xServiceInfo->supportsService(SERVICE_SDBCX_TABLES) )
723 eRet = E_TABLE;
724 else if ( xServiceInfo->supportsService(SERVICE_NAME_FORM_COLLECTION) )
725 eRet = E_FORM;
726 else if ( xServiceInfo->supportsService(SERVICE_NAME_REPORT_COLLECTION) )
727 eRet = E_REPORT;
728 else
729 eRet = E_QUERY;
730 }
731 return eRet;
732}
733
734} // namespace dbaui
735
736/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OptionalString sSchema
OptionalString sCatalog
OptionalString sName
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
SendMailResult AttachDocument(const css::uno::Reference< css::uno::XInterface > &xFrameOrModel, const OUString &sAttachmentTitle)
bool IsEmpty() const
SendMailResult Send(const css::uno::Reference< css::frame::XFrame > &xFrame)
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
sal_Int32 removeInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
sal_Int32 addInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
void raiseException(const ErrorCondition _eCondition, const css::uno::Reference< css::uno::XInterface > &_rxContext, const std::optional< OUString > &_rParamValue1=std::nullopt, const std::optional< OUString > &_rParamValue2=std::nullopt, const std::optional< OUString > &_rParamValue3=std::nullopt) const
class implementing the IObjectNameCheck interface, and checking a given name for being valid as eithe...
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getApplicationMainWindow() override
virtual void SAL_CALL releaseContextMenuInterceptor(const css::uno::Reference< css::ui::XContextMenuInterceptor > &Interceptor) override
virtual css::uno::Reference< css::lang::XComponent > SAL_CALL createComponent(::sal_Int32 ObjectType, css::uno::Reference< css::lang::XComponent > &o_DocumentDefinition) override
const TransferableDataHelper & getViewClipboard() const
returns the system clipboard.
bool isRenameDeleteAllowed(ElementType _eType, bool _bDelete) const
checks if delete command or rename command is allowed
virtual css::uno::Reference< css::lang::XComponent > SAL_CALL loadComponent(::sal_Int32 ObjectType, const OUString &ObjectName, sal_Bool ForEditing) override
bool insertHierarchyElement(ElementType _eType, const OUString &_sParentFolder, bool _bCollection=true, const css::uno::Reference< css::ucb::XContent > &_xContent=css::uno::Reference< css::ucb::XContent >(), bool _bMove=false)
Inserts a new object into the hierarchy given be the type.
void pasteFormat(SotClipboardFormatId _nFormatId)
pastes a special format from the system clipboard to the currently selected object types
virtual void SAL_CALL registerContextMenuInterceptor(const css::uno::Reference< css::ui::XContextMenuInterceptor > &Interceptor) override
virtual css::uno::Reference< css::sdbc::XDataSource > SAL_CALL getDataSource() override
void openDialog(const OUString &_sServiceName)
opens a uno dialog with the currently selected data source as initialize argument
static ElementType getElementType(const css::uno::Reference< css::container::XContainer > &_xContainer)
return the element type for given container
virtual sal_Bool SAL_CALL closeSubComponents() override
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &evt) override
void refreshTables()
refreshes the tables
void askToReconnect()
when the settings of the data source changed, it opens a dialog which ask to close all depending docu...
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getActiveConnection() override
virtual css::uno::Reference< css::lang::XComponent > SAL_CALL loadComponentWithArguments(::sal_Int32 ObjectType, const OUString &ObjectName, sal_Bool ForEditing, const css::uno::Sequence< css::beans::PropertyValue > &Arguments) override
bool isConnectionReadOnly() const
checks if the connection for the selected data source is read only.
void impl_validateObjectTypeAndName_throw(const sal_Int32 _nObjectType, const ::std::optional< OUString > &i_rObjectName)
verifies the object type denotes a valid DatabaseObject, and the object name denotes an existing obje...
virtual css::uno::Reference< css::lang::XComponent > SAL_CALL createComponentWithArguments(::sal_Int32 ObjectType, const css::uno::Sequence< css::beans::PropertyValue > &Arguments, css::uno::Reference< css::lang::XComponent > &o_DocumentDefinition) override
virtual bool isDataSourceReadOnly() const override
checks if the selected data source is read only
css::uno::Reference< css::lang::XComponent > newElement(ElementType _eType, const ::comphelper::NamedValueCollection &i_rAdditionalArguments, css::uno::Reference< css::lang::XComponent > &o_rDocumentDefinition)
opens a new frame for creation or auto pilot
OTableCopyHelper m_aTableCopyHelper
void disconnect()
disconnects from our XConnection, and cleans up this connection
virtual sal_Bool SAL_CALL isConnected() override
void onDocumentOpened(const OUString &_rName, const sal_Int32 _nType, const ElementOpenMode _eMode, const css::uno::Reference< css::lang::XComponent > &_xDocument, const css::uno::Reference< css::lang::XComponent > &_xDefinition)
remember a newly opened sub document for later access
const SharedConnection & ensureConnection(::dbtools::SQLExceptionInfo *_pErrorInfo=nullptr)
retrieves the current connection, creates it if necessary
bool paste(ElementType _eType, const svx::ODataAccessDescriptor &_rPasteData, const OUString &_sParentFolder=OUString(), bool _bMove=false)
pastes a query, form or report into the data source
virtual css::beans::Pair< ::sal_Int32, OUString > SAL_CALL identifySubComponent(const css::uno::Reference< css::lang::XComponent > &SubComponent) override
const SharedConnection & getConnection() const
retrieves the current connection
css::uno::Reference< css::beans::XPropertySet > m_xDataSource
void getSelectionElementNames(std::vector< OUString > &_rNames) const
fills the list with the selected entries.
void convertToView(const OUString &_sName)
converts the query to a view
virtual css::uno::Sequence< css::uno::Reference< css::lang::XComponent > > SAL_CALL getSubComponents() override
css::uno::Reference< css::lang::XComponent > openElementWithArguments(const OUString &_sName, ElementType _eType, ElementOpenMode _eOpenMode, sal_uInt16 _nInstigatorCommand, const ::comphelper::NamedValueCollection &_rAdditionalArguments)
opens a new sub frame with a table/query/form/report/view, passing additional arguments
::comphelper::OInterfaceContainerHelper2 m_aContextMenuInterceptors
virtual void SAL_CALL connect() override
virtual void Execute(sal_uInt16 nId, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
void previewChanged(sal_Int32 _nMode)
called when the preview mode was changed
virtual void onLoadedMenu(const css::uno::Reference< css::frame::XLayoutManager > &_xLayoutManager) override
called when our menu has been loaded into our frame, can be used to load sub toolbars
void doAction(sal_uInt16 _nId, ElementOpenMode _eOpenMode)
all selected entries will be opened, or edited, or converted to a view
css::uno::Reference< css::frame::XModel > m_xModel
OUString getStrippedDatabaseName() const
returns the stripped database name.
OUString getDatabaseName() const
returns the database name
css::uno::Reference< css::container::XNameAccess > getElements(ElementType _eType)
returns the nameaccess
::rtl::Reference< SubComponentManager > m_pSubComponentManager
OApplicationView * getContainer() const
SharedConnection m_xDataSourceConnection
void createTablesPage(const css::uno::Reference< css::sdbc::XConnection > &_xConnection)
creates the tables page
void clearPages(bool _bTaskAlso=true)
clears the detail pages.
sal_Int32 getSelectionCount() const
returns the count of selected entries
Definition: AppView.cxx:294
OApplicationDetailView * getDetailView() const
get the detail page
Definition: AppView.hxx:127
bool isALeafSelected() const
returns if one of the selected entries is a leaf
Definition: AppView.cxx:252
std::unique_ptr< weld::TreeIter > elementAdded(ElementType eType, const OUString &rName, const css::uno::Any &rObject)
adds a new object to the detail page.
Definition: AppView.cxx:342
void elementReplaced(ElementType eType, const OUString &_rOldName, const OUString &_rNewName)
replaces an objects name with a new one
Definition: AppView.cxx:354
ElementType getElementType() const
return the element of currently select entry
Definition: AppView.cxx:288
void selectContainer(ElementType _eType)
changes the container which should be displayed.
Definition: AppView.cxx:369
void createIconAutoMnemonics(MnemonicGenerator &_rMnemonics)
automatically creates mnemonics for the icon/texts in our left hand side panel
Definition: AppView.cxx:118
void setTaskExternalMnemonics(MnemonicGenerator const &_rMnemonics)
automatically creates mnemonics for the texts in our task pane
Definition: AppView.cxx:124
weld::Window * getFrameWeld() const
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getFrame() override
void showError(const ::dbtools::SQLExceptionInfo &_rInfo)
void InvalidateFeature(sal_uInt16 nId, const css::uno::Reference< css::frame::XStatusListener > &xListener=nullptr, bool _bForceBroadcast=false)
::osl::Mutex & getMutex() const
void InvalidateAll()
InvalidateAll invalidates all features currently known.
const css::uno::Reference< css::uno::XComponentContext > & getORB() const
css::uno::Reference< css::awt::XWindow > getTopMostContainerWindow() const
return the container window of the top most frame
const OUString & getName() const
Definition: dlgsave.cxx:276
OUString getSchema() const
Definition: dlgsave.cxx:284
OUString getCatalog() const
Definition: dlgsave.cxx:280
void pasteTable(const TransferableDataHelper &_rTransData, std::u16string_view _sDestDataSourceName, const SharedConnection &_xConnection)
pastes a table into the data source
const css::uno::Reference< INTERFACE > & getTyped() const
vcl::Window * GetParent() const
virtual short run()
#define DBA_RES(id)
#define DBG_UNHANDLED_EXCEPTION(...)
float u
SotClipboardFormatId
OUString eType
Definition: generalpage.cxx:78
Sequence< PropertyValue > aArguments
Definition: intercept.cxx:88
sal_Int32 getToken(const Context &rContext, const char *pToken)
@ Exception
::sal_Int32 ErrorCondition
css::uno::Reference< css::beans::XPropertySet > createView(const OUString &_sName, const css::uno::Reference< css::sdbc::XConnection > &_xConnection, const css::uno::Reference< css::beans::XPropertySet > &_xSourceObject)
creates a new view from a query or table
OUString createDefaultName(const css::uno::Reference< css::sdbc::XDatabaseMetaData > &_xMetaData, const css::uno::Reference< css::container::XNameAccess > &_xTables, const OUString &_sName)
OUString getStrippedDatabaseName(const css::uno::Reference< css::beans::XPropertySet > &_xDataSource, OUString &_rsDatabaseName)
returns the stripped database name.
bool insertHierarchyElement(weld::Window *pParent, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::container::XHierarchicalNameContainer > &_xNames, const OUString &_sParentFolder, bool _bForm, bool _bCollection=true, const css::uno::Reference< css::ucb::XContent > &_xContent=nullptr, bool _bMove=false)
opens a save dialog to store a form or report folder in the current hierarchy.
ObjectType
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)
const PPTXLayoutInfo aLayoutInfo[LAYOUT_SIZE]
QPRO_FUNC_TYPE nType
constexpr OUStringLiteral PROPERTY_USER(u"User")
constexpr OUStringLiteral PROPERTY_URL(u"URL")
constexpr OUStringLiteral SERVICE_NAME_FORM_COLLECTION
Definition: strings.hxx:197
constexpr OUStringLiteral PROPERTY_ACTIVE_CONNECTION(u"ActiveConnection")
constexpr OUStringLiteral SERVICE_NAME_REPORT_COLLECTION
Definition: strings.hxx:198
constexpr OUStringLiteral PROPERTY_NAME(u"Name")
constexpr OUStringLiteral SERVICE_SDBCX_TABLES
Definition: strings.hxx:193
constexpr OUStringLiteral PROPERTY_LAYOUTINFORMATION(u"LayoutInformation")
ElementOpenMode eOpenMode
the mode in which the sub component has been opened
Reference< XFrame > xFrame
the frame which the component resides in. Must not be <NULL>
Reference< XModel > xModel
the model of the sub component. Might be <NULL>
unsigned char sal_Bool
RET_OK
RET_YES