23#include <core_resource.hxx>
24#include <dbaccess_slotid.hrc>
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>
54#include <osl/diagnose.h>
59#include <osl/mutex.hxx>
80using ::com::sun::star::ui::XContextMenuInterceptor;
82namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
109 ::dbtools::composeTableName( xMeta,
sCatalog,
sSchema,
sName,
false, ::dbtools::EComposeRule::InTableDefinitions ) );
112 throw SQLException(
DBA_RES(STR_NO_TABLE_FORMAT_INSIDE),*
this,
"S1000",0,
Any());
116 catch(
const SQLException& )
128 if ( _nFormatId == SotClipboardFormatId::NONE )
140 paste(
eType, ODataAccessObjectTransferable::extractObjectDescriptor( rClipboard ) );
154 ::osl::MutexGuard aGuard(
getMutex() );
158 auto pArgs = aArgs.getArray();
159 sal_Int32 nArgPos = 0;
164 OSL_ENSURE(
getContainer(),
"OApplicationController::Construct: have no view!" );
169 pArgs[nArgPos++] <<= PropertyValue(
"ParentWindow",
172 PropertyState_DIRECT_VALUE);
175 OUString sInitialSelection;
178 if ( !sInitialSelection.isEmpty() )
180 pArgs[ nArgPos++ ] <<= PropertyValue(
181 "InitialSelection", 0,
182 Any( sInitialSelection ), PropertyState_DIRECT_VALUE );
186 if ( xConnection.
is() )
188 pArgs[ nArgPos++ ] <<= PropertyValue(
190 makeAny( xConnection ), PropertyState_DIRECT_VALUE );
192 aArgs.realloc( nArgPos );
197 getORB()->getServiceManager()->createInstanceWithArgumentsAndContext(_sServiceName, aArgs,
getORB()),
201 if (xAdminDialog.is())
202 xAdminDialog->execute();
225 OSL_FAIL(
"Could not refresh tables!");
235 ::osl::MutexGuard aGuard(
getMutex() );
253 OUString sOldName,sNewName;
254 evt.OldValue >>= sOldName;
255 evt.NewValue >>= sNewName;
260 if ( !sOldName.isEmpty() )
267 sOldName = xContent->getIdentifier()->getContentIdentifier() +
"/" + sOldName;
282 ::osl::MutexGuard aGuard(
getMutex() );
289 ::osl::MutexGuard aGuard(
getMutex() );
297 ::osl::MutexGuard aGuard(
getMutex() );
303 ::osl::MutexGuard aGuard(
getMutex() );
309 ::osl::MutexGuard aGuard(
getMutex() );
317 if ( !xConnection.
is() )
323 OUString sConnectingContext(
DBA_RES( STR_COULDNOTCONNECT_DATASOURCE ) );
324 ::dbtools::throwGenericSQLException( sConnectingContext.replaceFirst(
"$name$",
getStrippedDatabaseName() ), *
this );
330 ::osl::MutexGuard aGuard(
getMutex() );
332 sal_Int32
nType = -1;
336 throw IllegalArgumentException( OUString(), *
this, 1 );
338 if (
nType == SID_DB_APP_DSRELDESIGN )
343 return beans::Pair< ::sal_Int32, OUString >(
nType,
sName );
349 ::osl::MutexGuard aGuard(
getMutex() );
355 ElementType lcl_objectType2ElementType(
const sal_Int32 _nObjectType )
358 switch ( _nObjectType )
365 OSL_FAIL(
"lcl_objectType2ElementType: unsupported object type!" );
384 && ( _nObjectType != DatabaseObject::FORM )
387 throw IllegalArgumentException( OUString(), *
this, 1 );
389 if ( !i_rObjectName )
394 if ( !xContainer.is() )
399 bool bExistentObject =
false;
400 switch ( _nObjectType )
404 bExistentObject = xContainer->hasByName( *i_rObjectName );
406 case DatabaseObject::FORM:
410 bExistentObject = xHierarchy->hasByHierarchicalName( *i_rObjectName );
415 if ( !bExistentObject )
416 throw NoSuchElementException( *i_rObjectName, *
this );
420 const OUString& ObjectName,
sal_Bool ForEditing )
429 ::osl::MutexGuard aGuard(
getMutex() );
437 ForEditing ? SID_DB_APP_EDIT : SID_DB_APP_OPEN,
452 ::osl::MutexGuard aGuard(
getMutex() );
457 lcl_objectType2ElementType( i_nObjectType ),
479 ::osl::MutexGuard aGuard(
getMutex() );
486 sal_Int32 nOldMode =
aLayoutInfo.getOrDefault(
"Preview", _nMode );
487 if ( nOldMode != _nMode )
513 VclMessageType::Question, VclButtonsType::YesNo,
514 DBA_RES(STR_QUERY_CLOSEDOCUMENTS)));
538 OUString sDatabaseName;
550 return sDatabaseName;
555 OUString sDatabaseName;
562 if ( !_xDocument.is() )
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 );
570 if ( _rxDefinition.is() )
574 xProp->addPropertyChangeListener(
PROPERTY_NAME,
static_cast< XPropertyChangeListener*
>(
this ) );
606 bool bCompareRes =
false;
614 std::vector< OUString> aList;
620 bEnabled = (xContainer.is() && xContainer->hasByName(*aList.begin()));
631 bEnabled = bEnabled && bCompareRes;
639 if ( !_xLayoutManager.is() )
642 static constexpr OUStringLiteral s_sStatusbar =
u"private:resource/statusbar/statusbar";
643 _xLayoutManager->createElement( s_sStatusbar );
644 _xLayoutManager->requestElement( s_sStatusbar );
652 pSystemWindow->CollectMenuBarMnemonics(aMnemonicGenerator);
665 std::vector< OUString> aList;
676 std::vector< std::pair< OUString ,Reference< XModel > > > aComponents;
677 for (
auto const& elem : aList)
679 if ( SID_DB_APP_CONVERTTOVIEW == _nId )
684 aComponents.emplace_back( elem,
xModel );
695 for (
auto const& component : aComponents)
703 ::comphelper::disposeComponent(
xModel);
720 if ( xServiceInfo.is() )
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)
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
ElementType m_eCurrentType
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
OApplicationDetailView * getDetailView() const
get the detail page
bool isALeafSelected() const
returns if one of the selected entries is a leaf
std::unique_ptr< weld::TreeIter > elementAdded(ElementType eType, const OUString &rName, const css::uno::Any &rObject)
adds a new object to the detail page.
void elementReplaced(ElementType eType, const OUString &_rOldName, const OUString &_rNewName)
replaces an objects name with a new one
ElementType getElementType() const
return the element of currently select entry
void selectContainer(ElementType _eType)
changes the container which should be displayed.
void createIconAutoMnemonics(MnemonicGenerator &_rMnemonics)
automatically creates mnemonics for the icon/texts in our left hand side panel
void setTaskExternalMnemonics(MnemonicGenerator const &_rMnemonics)
automatically creates mnemonics for the texts in our task pane
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)
ODataView * getView() const
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
OUString getSchema() const
OUString getCatalog() const
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
#define DBG_UNHANDLED_EXCEPTION(...)
Sequence< PropertyValue > aArguments
sal_Int32 getToken(const Context &rContext, const char *pToken)
::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.
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)
const PPTXLayoutInfo aLayoutInfo[LAYOUT_SIZE]
constexpr OUStringLiteral PROPERTY_USER(u"User")
constexpr OUStringLiteral PROPERTY_URL(u"URL")
constexpr OUStringLiteral SERVICE_NAME_FORM_COLLECTION
constexpr OUStringLiteral PROPERTY_ACTIVE_CONNECTION(u"ActiveConnection")
constexpr OUStringLiteral SERVICE_NAME_REPORT_COLLECTION
constexpr OUStringLiteral PROPERTY_NAME(u"Name")
constexpr OUStringLiteral SERVICE_SDBCX_TABLES
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>