diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /dbaccess/source/core/inc | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream.tar.xz libreoffice-upstream.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dbaccess/source/core/inc')
35 files changed, 4802 insertions, 0 deletions
diff --git a/dbaccess/source/core/inc/ContainerMediator.hxx b/dbaccess/source/core/inc/ContainerMediator.hxx new file mode 100644 index 000000000..8d1bf9d8d --- /dev/null +++ b/dbaccess/source/core/inc/ContainerMediator.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTAINERMEDIATOR_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTAINERMEDIATOR_HXX + +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> + +#include <map> + +namespace dbaccess +{ + + class OPropertyForward; + + class OContainerMediator : public ::cppu::BaseMutex + ,public ::cppu::WeakImplHelper< css::container::XContainerListener > + { + private: + typedef std::map< OUString, ::rtl::Reference< OPropertyForward > > PropertyForwardList; + PropertyForwardList m_aForwardList; + css::uno::Reference< css::container::XNameAccess > m_xSettings; // can not be weak + css::uno::Reference< css::container::XContainer > m_xContainer; // can not be weak + + protected: + virtual ~OContainerMediator() override; + + public: + OContainerMediator( + const css::uno::Reference< css::container::XContainer >& _xContainer, + const css::uno::Reference< css::container::XNameAccess >& _xSettings + ); + + virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& _rEvent ) override; + virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& _rEvent ) override; + virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& _rEvent ) override; + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + void notifyElementCreated(const OUString& _sElementName + ,const css::uno::Reference< css::beans::XPropertySet>& _xElement); + + private: + /** cleans up the instance, by deregistering as listener at the containers, + and resetting them to <NULL/> + */ + void impl_cleanup_nothrow(); + + /** initializes the properties of the given object from its counterpart in our settings container + */ + void impl_initSettings_nothrow( + const OUString& _rName, + const css::uno::Reference< css::beans::XPropertySet >& _rxDestination + ); + }; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTAINERMEDIATOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/ContentHelper.hxx b/dbaccess/source/core/inc/ContentHelper.hxx new file mode 100644 index 000000000..87686496a --- /dev/null +++ b/dbaccess/source/core/inc/ContentHelper.hxx @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTENTHELPER_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTENTHELPER_HXX + +#include <com/sun/star/ucb/XContent.hpp> +#include <com/sun/star/ucb/XCommandProcessor.hpp> +#include <com/sun/star/beans/XPropertiesChangeNotifier.hpp> +#include <com/sun/star/beans/XPropertyContainer.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <comphelper/interfacecontainer2.hxx> +#include <com/sun/star/beans/Property.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/sdbcx/XRename.hpp> +#include <connectivity/sqlerror.hxx> +#include <memory> + +namespace com::sun::star::beans { struct PropertyValue; } + +namespace dbaccess +{ + class ODatabaseModelImpl; + struct ContentProperties + { + OUString aTitle; // Title + ::std::optional< OUString > + aContentType; // ContentType (aka MediaType aka MimeType) + bool bIsDocument; // IsDocument + bool bIsFolder; // IsFolder + bool bAsTemplate; // AsTemplate + OUString sPersistentName;// persistent name of the document + + ContentProperties() + :bIsDocument( true ) + ,bIsFolder( false ) + ,bAsTemplate( false ) + { + } + }; + + class OContentHelper_Impl + { + public: + OContentHelper_Impl(); + virtual ~OContentHelper_Impl(); + + ContentProperties m_aProps; + ODatabaseModelImpl* m_pDataSource; // this will stay alive as long as the content exists + }; + + typedef std::shared_ptr<OContentHelper_Impl> TContentPtr; + + typedef cppu::OMultiTypeInterfaceContainerHelperVar<OUString> + PropertyChangeListenerContainer; + typedef ::cppu::WeakComponentImplHelper< css::ucb::XContent + , css::ucb::XCommandProcessor + , css::lang::XServiceInfo + , css::beans::XPropertiesChangeNotifier + , css::beans::XPropertyContainer + , css::lang::XInitialization + , css::lang::XUnoTunnel + , css::container::XChild + , css::sdbcx::XRename + > OContentHelper_COMPBASE; + + class OContentHelper : public ::cppu::BaseMutex + ,public OContentHelper_COMPBASE + { + css::uno::Sequence< css::uno::Any > + setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rValues ); + + void impl_rename_throw(const OUString& _sNewName,bool _bNotify = true); + + protected: + ::comphelper::OInterfaceContainerHelper2 m_aContentListeners; + PropertyChangeListenerContainer m_aPropertyChangeListeners; + css::uno::Reference< css::uno::XInterface > + m_xParentContainer; + const css::uno::Reference< css::uno::XComponentContext > + m_aContext; + const ::connectivity::SQLError m_aErrorHelper; + TContentPtr m_pImpl; + sal_uInt32 m_nCommandId; + + // helper + virtual void SAL_CALL disposing() override; + + void notifyDataSourceModified(); + + /** + * This method can be used to propagate changes of property values. + * + * @param evt is a sequence of property change events. + */ + void notifyPropertiesChange( const css::uno::Sequence< css::beans::PropertyChangeEvent >& evt ) const; + + OUString impl_getHierarchicalName( bool _includingRootContainer ) const; + + public: + + OContentHelper( const css::uno::Reference< css::uno::XComponentContext >& _xORB + ,const css::uno::Reference< css::uno::XInterface >& _xParentContainer + ,const TContentPtr& _pImpl + ); + + // css::lang::XTypeProvider + virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) override; + + // css::lang::XServiceInfo + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + virtual OUString SAL_CALL getImplementationName( ) override; + + // XContent + virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL getIdentifier( ) override ; + virtual OUString SAL_CALL getContentType( ) override ; + virtual void SAL_CALL addContentEventListener( const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override ; + virtual void SAL_CALL removeContentEventListener( const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override ; + + // XCommandProcessor + virtual sal_Int32 SAL_CALL createCommandIdentifier( ) override ; + virtual css::uno::Any SAL_CALL execute( const css::ucb::Command& aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override ; + virtual void SAL_CALL abort( sal_Int32 CommandId ) override ; + + // XPropertiesChangeNotifier + virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override ; + virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override ; + + // XPropertyContainer + virtual void SAL_CALL addProperty( const OUString& Name, sal_Int16 Attributes, const css::uno::Any& DefaultValue ) override ; + virtual void SAL_CALL removeProperty( const OUString& Name ) override ; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // css::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; + static css::uno::Sequence< sal_Int8 > getUnoTunnelId(); + + // css::container::XChild + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override; + virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override; + + // XRename + virtual void SAL_CALL rename( const OUString& newName ) override; + + const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; } + css::uno::Reference< css::sdbc::XRow > + getPropertyValues( const css::uno::Sequence< css::beans::Property >& rProperties ); + + const css::uno::Reference< css::uno::XComponentContext >& getContext() const { return m_aContext; } + + const TContentPtr& getImpl() const { return m_pImpl; } + + protected: + virtual OUString determineContentType() const = 0; + }; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTENTHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/DatabaseDataProvider.hxx b/dbaccess/source/core/inc/DatabaseDataProvider.hxx new file mode 100644 index 000000000..68c066412 --- /dev/null +++ b/dbaccess/source/core/inc/DatabaseDataProvider.hxx @@ -0,0 +1,273 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_DATABASEDATAPROVIDER_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_DATABASEDATAPROVIDER_HXX + +#include <sal/config.h> + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp> +#include <com/sun/star/chart2/XInternalDataProvider.hpp> +#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> +#include <com/sun/star/sdbc/XRowSet.hpp> +#include <com/sun/star/container/XChild.hpp> + +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/propertysetmixin.hxx> + +#include <connectivity/parameters.hxx> +#include <connectivity/filtermanager.hxx> + + +namespace dbaccess +{ + +typedef ::cppu::WeakComponentImplHelper< css::chart2::data::XDatabaseDataProvider + , css::container::XChild + , css::chart::XComplexDescriptionAccess + , css::lang::XServiceInfo > TDatabaseDataProvider; + +class DatabaseDataProvider: private ::cppu::BaseMutex, + public TDatabaseDataProvider, + public ::cppu::PropertySetMixin< css::chart2::data::XDatabaseDataProvider > +{ +public: + explicit DatabaseDataProvider(css::uno::Reference< css::uno::XComponentContext > const & context); + + // css::lang::XServiceInfo - static methods + /// @throws css::uno::RuntimeException + static css::uno::Sequence< OUString > getSupportedServiceNames_Static(); + /// @throws css::uno::RuntimeException + static OUString getImplementationName_Static(); + static css::uno::Reference< css::uno::XInterface > + Create(css::uno::Reference< css::uno::XComponentContext > const & context); + +private: + // css::uno::XInterface: + virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const & type) override; + virtual void SAL_CALL acquire() throw () override + { TDatabaseDataProvider::acquire(); } + virtual void SAL_CALL release() throw () override + { TDatabaseDataProvider::release(); } + + // css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // css::chart2::data::XDataProvider: + virtual sal_Bool SAL_CALL createDataSourcePossible(const css::uno::Sequence< css::beans::PropertyValue > & aArguments) override; + virtual css::uno::Reference< css::chart2::data::XDataSource > SAL_CALL createDataSource(const css::uno::Sequence< css::beans::PropertyValue > & aArguments) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL detectArguments(const css::uno::Reference< css::chart2::data::XDataSource > & xDataSource) override; + virtual sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(const OUString & aRangeRepresentation) override; + virtual css::uno::Reference< css::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(const OUString & aRangeRepresentation) override; + + virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL + createDataSequenceByValueArray( + const OUString& aRole, const OUString & aRangeRepresentation) override; + + virtual css::uno::Reference< css::sheet::XRangeSelection > SAL_CALL getRangeSelection() override; + + // css::chart2::data::XRangeXMLConversion: + virtual OUString SAL_CALL convertRangeToXML(const OUString & aRangeRepresentation) override; + virtual OUString SAL_CALL convertRangeFromXML(const OUString & aXMLRange) override; + + // css::lang::XInitialization: + virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > & aArguments) override; + + // css::beans::XPropertySet: + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue(const OUString & aPropertyName, const css::uno::Any & aValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue(const OUString & PropertyName) override; + virtual void SAL_CALL addPropertyChangeListener(const OUString & aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > & xListener) override; + virtual void SAL_CALL removePropertyChangeListener(const OUString & aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > & aListener) override; + virtual void SAL_CALL addVetoableChangeListener(const OUString & PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener) override; + virtual void SAL_CALL removeVetoableChangeListener(const OUString & PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener) override; + + // css::chart2::data::XDatabaseDataProvider: + virtual css::uno::Sequence< OUString > SAL_CALL getMasterFields() override; + virtual void SAL_CALL setMasterFields(const css::uno::Sequence< OUString > & the_value) override; + virtual css::uno::Sequence< OUString > SAL_CALL getDetailFields() override; + virtual void SAL_CALL setDetailFields(const css::uno::Sequence< OUString > & the_value) override; + virtual OUString SAL_CALL getCommand() override; + virtual void SAL_CALL setCommand(const OUString & the_value) override; + virtual ::sal_Int32 SAL_CALL getCommandType() override; + virtual void SAL_CALL setCommandType(::sal_Int32 the_value) override; + virtual OUString SAL_CALL getFilter() override; + virtual void SAL_CALL setFilter(const OUString & the_value) override; + virtual sal_Bool SAL_CALL getApplyFilter() override; + virtual void SAL_CALL setApplyFilter( sal_Bool _applyfilter ) override; + virtual OUString SAL_CALL getHavingClause() override; + virtual void SAL_CALL setHavingClause( const OUString& _havingclause ) override; + virtual OUString SAL_CALL getGroupBy() override; + virtual void SAL_CALL setGroupBy( const OUString& _groupby ) override; + virtual OUString SAL_CALL getOrder() override; + virtual void SAL_CALL setOrder( const OUString& _order ) override; + virtual sal_Bool SAL_CALL getEscapeProcessing() override; + virtual void SAL_CALL setEscapeProcessing(sal_Bool the_value) override; + virtual ::sal_Int32 SAL_CALL getRowLimit() override; + virtual void SAL_CALL setRowLimit( ::sal_Int32 _rowlimit ) override; + virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getActiveConnection() override; + virtual void SAL_CALL setActiveConnection(const css::uno::Reference< css::sdbc::XConnection > & the_value) override; + virtual OUString SAL_CALL getDataSourceName() override; + virtual void SAL_CALL setDataSourceName( const OUString& _datasourcename ) override; + + // css::sdbc::XParameters + virtual void SAL_CALL setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) override; + virtual void SAL_CALL setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName) override; + virtual void SAL_CALL setBoolean(sal_Int32 parameterIndex, sal_Bool x) override; + virtual void SAL_CALL setByte(sal_Int32 parameterIndex, sal_Int8 x) override; + virtual void SAL_CALL setShort(sal_Int32 parameterIndex, sal_Int16 x) override; + virtual void SAL_CALL setInt(sal_Int32 parameterIndex, sal_Int32 x) override; + virtual void SAL_CALL setLong(sal_Int32 parameterIndex, sal_Int64 x) override; + virtual void SAL_CALL setFloat(sal_Int32 parameterIndex, float x) override; + virtual void SAL_CALL setDouble(sal_Int32 parameterIndex, double x) override; + virtual void SAL_CALL setString(sal_Int32 parameterIndex, const OUString& x) override; + virtual void SAL_CALL setBytes(sal_Int32 parameterIndex, const css::uno::Sequence< sal_Int8 >& x) override; + virtual void SAL_CALL setDate(sal_Int32 parameterIndex, const css::util::Date& x) override; + virtual void SAL_CALL setTime(sal_Int32 parameterIndex, const css::util::Time& x) override; + virtual void SAL_CALL setTimestamp(sal_Int32 parameterIndex, const css::util::DateTime& x) override; + virtual void SAL_CALL setBinaryStream(sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream>& x, sal_Int32 length) override; + virtual void SAL_CALL setCharacterStream(sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream>& x, sal_Int32 length) override; + virtual void SAL_CALL setObject(sal_Int32 parameterIndex, const css::uno::Any& x) override; + virtual void SAL_CALL setObjectWithInfo(sal_Int32 parameterIndex, const css::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale) override; + virtual void SAL_CALL setRef(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XRef>& x) override; + virtual void SAL_CALL setBlob(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XBlob>& x) override; + virtual void SAL_CALL setClob(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XClob>& x) override; + virtual void SAL_CALL setArray(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XArray>& x) override; + virtual void SAL_CALL clearParameters() override; + + // css::sdbc::XRowSet + virtual void SAL_CALL execute() override; + virtual void SAL_CALL addRowSetListener(const css::uno::Reference< css::sdbc::XRowSetListener>& _rxListener) override; + virtual void SAL_CALL removeRowSetListener(const css::uno::Reference< css::sdbc::XRowSetListener>& _rxListener) override; + + // css::sdbc::XResultSet + virtual sal_Bool SAL_CALL next() override; + virtual sal_Bool SAL_CALL isBeforeFirst() override; + virtual sal_Bool SAL_CALL isAfterLast() override; + virtual sal_Bool SAL_CALL isFirst() override; + virtual sal_Bool SAL_CALL isLast() override; + virtual void SAL_CALL beforeFirst() override; + virtual void SAL_CALL afterLast() override; + virtual sal_Bool SAL_CALL first() override; + virtual sal_Bool SAL_CALL last() override; + virtual sal_Int32 SAL_CALL getRow() override; + virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override; + virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override; + virtual sal_Bool SAL_CALL previous() override; + virtual void SAL_CALL refreshRow() override; + virtual sal_Bool SAL_CALL rowUpdated() override; + virtual sal_Bool SAL_CALL rowInserted() override; + virtual sal_Bool SAL_CALL rowDeleted() override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override; + + // container::XChild + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override; + virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override; + + // ____ XComplexDescriptionAccess ____ + virtual css::uno::Sequence< css::uno::Sequence< OUString > > SAL_CALL getComplexRowDescriptions() override; + virtual void SAL_CALL setComplexRowDescriptions( const css::uno::Sequence< css::uno::Sequence< OUString > >& aRowDescriptions ) override; + virtual css::uno::Sequence< css::uno::Sequence< OUString > > SAL_CALL getComplexColumnDescriptions() override; + virtual void SAL_CALL setComplexColumnDescriptions( const css::uno::Sequence< css::uno::Sequence< OUString > >& aColumnDescriptions ) override; + + // ____ XChartDataArray (base of XComplexDescriptionAccess) ____ + virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL getData() override; + virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Sequence< double > >& aData ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions() override; + virtual void SAL_CALL setRowDescriptions( const css::uno::Sequence< OUString >& aRowDescriptions ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getColumnDescriptions() override; + virtual void SAL_CALL setColumnDescriptions( const css::uno::Sequence< OUString >& aColumnDescriptions ) override; + + // ____ XChartData (base of XChartDataArray) ____ + virtual void SAL_CALL addChartDataChangeEventListener(const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override; + virtual void SAL_CALL removeChartDataChangeEventListener(const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override; + virtual double SAL_CALL getNotANumber() override; + virtual sal_Bool SAL_CALL isNotANumber(double nNumber ) override; +private: + DatabaseDataProvider(DatabaseDataProvider const &) = delete; + DatabaseDataProvider& operator =(DatabaseDataProvider const &) = delete; + + virtual ~DatabaseDataProvider() override {} + + // This function is called upon disposing the component, + // if your component needs special work when it becomes + // disposed, do it here. + virtual void SAL_CALL disposing() override; + + void impl_fillRowSet_throw(); + bool impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies); + void impl_fillInternalDataProvider_throw(bool _bHasCategories,const css::uno::Sequence< OUString >& i_aColumnNames); + void impl_invalidateParameter_nothrow(); + css::uno::Any impl_getNumberFormatKey_nothrow(const OUString & _sRangeRepresentation) const; + + template <typename T> void set( const OUString& _sProperty + ,const T& Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + if ( _member != Value ) + { + prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l); + _member = Value; + } + } + l.notify(); + } + + ::dbtools::ParameterManager m_aParameterManager; + ::dbtools::FilterManager m_aFilterManager; + std::map< OUString, css::uno::Any> m_aNumberFormats; + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::sdbc::XConnection > m_xActiveConnection; + css::uno::Reference< css::sdbc::XRowSet > m_xRowSet; + css::uno::Reference< css::chart2::XInternalDataProvider > m_xInternal; + css::uno::Reference< css::chart::XComplexDescriptionAccess > m_xComplexDescriptionAccess; + css::uno::Reference< css::chart2::data::XRangeXMLConversion> m_xRangeConversion; + css::uno::Reference< css::task::XInteractionHandler> m_xHandler; + // the object doin' most of the work - an SDB-rowset + css::uno::Reference< css::uno::XAggregation> m_xAggregate; + css::uno::Reference< css::beans::XPropertySet> m_xAggregateSet; + css::uno::Reference< css::uno::XInterface> m_xParent; + css::uno::Sequence< OUString > m_MasterFields; + css::uno::Sequence< OUString > m_DetailFields; + + OUString m_Command; + OUString m_DataSourceName; + sal_Int32 m_CommandType; + sal_Int32 m_RowLimit; + OUString m_Filter; + OUString m_HavingClause; + OUString m_Order; + OUString m_GroupBy; + bool m_EscapeProcessing; + bool m_ApplyFilter; +}; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_DATABASEDATAPROVIDER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/FilteredContainer.hxx b/dbaccess/source/core/inc/FilteredContainer.hxx new file mode 100644 index 000000000..b07892731 --- /dev/null +++ b/dbaccess/source/core/inc/FilteredContainer.hxx @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_FILTEREDCONTAINER_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_FILTEREDCONTAINER_HXX + +#include <sal/config.h> + +#include <atomic> +#include <cstddef> + +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> + +#include <connectivity/sdbcx/VCollection.hxx> + +namespace dbtools +{ + class WarningsContainer; +} + +namespace dbaccess +{ + class IRefreshListener; + + class OFilteredContainer : public ::connectivity::sdbcx::OCollection + { + private: + mutable bool m_bConstructed; // late ctor called + + protected: + IRefreshListener* m_pRefreshListener; + std::atomic<std::size_t>& m_nInAppend; + + // holds the original container which where set in construct but they can be null + css::uno::Reference< css::container::XNameAccess > m_xMasterContainer; + css::uno::WeakReference< css::sdbc::XConnection > m_xConnection; + css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData; + + /** returns a string denoting the only type of tables allowed in this container, or an empty string + if there is no such restriction + */ + virtual OUString getTableTypeRestriction() const = 0; + + virtual void addMasterContainerListener(){} + virtual void removeMasterContainerListener(){} + + // ::connectivity::sdbcx::OCollection + virtual void impl_refresh() override; + + virtual OUString getNameForObject(const ::connectivity::sdbcx::ObjectType& _xObject) override; + + /** tell the container to free all elements and all additional resources.<BR> + After using this method the object may be reconstructed by calling one of the <code>construct</code> methods. + */ + virtual void disposing() override; + + class EnsureReset + { + public: + EnsureReset( std::atomic<std::size_t>& _rValueLocation) + :m_rValue( _rValueLocation ) + { + ++m_rValue; + } + + ~EnsureReset() + { + --m_rValue; + } + + private: + std::atomic<std::size_t>& m_rValue; + }; + + /** retrieve a table type filter to pass to <member scope="css::sdbc">XDatabaseMetaData::getTables</member>, + according to the current data source settings + */ + void getAllTableTypeFilter( css::uno::Sequence< OUString >& /* [out] */ _rFilter ) const; + + public: + /** ctor of the container. The parent has to support the <type scope="css::sdbc">XConnection</type> + interface.<BR> + @param _rParent the object which acts as parent for the container. + all refcounting is rerouted to this object + @param _rMutex the access safety object of the parent + @param _rTableFilter restricts the visible tables by name + @param _rTableTypeFilter restricts the visible tables by type + @see construct + */ + OFilteredContainer( ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const css::uno::Reference< css::sdbc::XConnection >& _xCon, + bool _bCase, + IRefreshListener* _pRefreshListener, + std::atomic<std::size_t>& _nInAppend + ); + + void dispose() { disposing(); } + + /** late ctor. The container will fill itself with the data got by the connection meta data, considering the + filters given (the connection is the parent object you passed in the ctor). + */ + void construct( + const css::uno::Sequence< OUString >& _rTableFilter, + const css::uno::Sequence< OUString >& _rTableTypeFilter + ); + + /** late ctor. The container will fill itself with wrapper objects for the tables returned by the given + name container. + */ + void construct( + const css::uno::Reference< css::container::XNameAccess >& _rxMasterContainer, + const css::uno::Sequence< OUString >& _rTableFilter, + const css::uno::Sequence< OUString >& _rTableTypeFilter + ); + + bool isInitialized() const { return m_bConstructed; } + }; +} // namespace + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_FILTEREDCONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/ModelImpl.hxx b/dbaccess/source/core/inc/ModelImpl.hxx new file mode 100644 index 000000000..c67e67d57 --- /dev/null +++ b/dbaccess/source/core/inc/ModelImpl.hxx @@ -0,0 +1,545 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_MODELIMPL_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_MODELIMPL_HXX + +#include "ContentHelper.hxx" +#include "documentevents.hxx" + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/XPropertyBag.hpp> +#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp> +#include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp> +#include <com/sun/star/sdbc/XDataSource.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> + +#include <comphelper/namedvaluecollection.hxx> +#include <cppuhelper/weakref.hxx> +#include <vcl/svapp.hxx> +#include <sfx2/docmacromode.hxx> +#include <sfx2/docstoragemodifylistener.hxx> +#include <unotools/sharedunocomponent.hxx> +#include <rtl/ref.hxx> + +namespace comphelper +{ + class NamedValueCollection; +} + +namespace dbaccess +{ + +typedef std::vector< css::uno::WeakReference< css::sdbc::XConnection > > OWeakConnectionArray; + +struct AsciiPropertyValue +{ + // note: the canonic member order would be AsciiName / DefaultValue, but + // this crashes on unxlngi6.pro, since there's a bug which somehow results in + // getDefaultDataSourceSettings returning corrupted Any instances then. + css::uno::Any DefaultValue; + const char* AsciiName; + const css::uno::Type& ValueType; + + AsciiPropertyValue() + :DefaultValue( ) + ,AsciiName( nullptr ) + ,ValueType( ::cppu::UnoType<void>::get() ) + { + } + + AsciiPropertyValue( const char* _pAsciiName, const css::uno::Any& _rDefaultValue ) + :DefaultValue( _rDefaultValue ) + ,AsciiName( _pAsciiName ) + ,ValueType( _rDefaultValue.getValueType() ) + { + OSL_ENSURE( ValueType.getTypeClass() != css::uno::TypeClass_VOID, + "AsciiPropertyValue::AsciiPropertyValue: NULL values not allowed here, use the other CTOR for this!" ); + } + AsciiPropertyValue( const char* _pAsciiName, const css::uno::Type& _rValeType ) + :DefaultValue() + ,AsciiName( _pAsciiName ) + ,ValueType( _rValeType ) + { + OSL_ENSURE( ValueType.getTypeClass() != css::uno::TypeClass_VOID, + "AsciiPropertyValue::AsciiPropertyValue: VOID property values not supported!" ); + } +}; + +class ODatabaseContext; +class OSharedConnectionManager; + +// ODatabaseModelImpl +typedef ::utl::SharedUNOComponent< css::embed::XStorage > SharedStorage; + +class ODatabaseContext; +class DocumentStorageAccess; +class OSharedConnectionManager; +class ODatabaseModelImpl :public ::sfx2::IMacroDocumentAccess + ,public ::sfx2::IModifiableDocument +{ +public: + enum ObjectType + { + E_FORM = 0, + E_REPORT = 1, + E_QUERY = 2, + E_TABLE = 3 + }; + + enum EmbeddedMacros + { + // the database document (storage) itself contains macros + eDocumentWideMacros, + // there are sub document( storage)s containing macros + eSubDocumentMacros, + // there are no known macro( storage)s + eNoMacros + }; + +private: + css::uno::WeakReference< css::frame::XModel > m_xModel; + css::uno::WeakReference< css::sdbc::XDataSource > m_xDataSource; + + rtl::Reference<DocumentStorageAccess> m_pStorageAccess; + std::vector< TContentPtr > m_aContainer; // one for each ObjectType + ::sfx2::DocumentMacroMode m_aMacroMode; + sal_Int16 m_nImposedMacroExecMode; + + css::uno::Reference< css::script::XStorageBasedLibraryContainer > m_xBasicLibraries; + css::uno::Reference< css::script::XStorageBasedLibraryContainer > m_xDialogLibraries; + + SharedStorage m_xDocumentStorage; + ::rtl::Reference< ::sfx2::DocumentStorageModifyListener > m_pStorageModifyListener; + ODatabaseContext& m_rDBContext; + DocumentEventsData m_aDocumentEvents; + + ::comphelper::NamedValueCollection m_aMediaDescriptor; + /// the URL the document was loaded from + OUString m_sDocFileLocation; + + oslInterlockedCount m_refCount; + + /// do we have any object (forms/reports) which contains macros? + ::std::optional< EmbeddedMacros > m_aEmbeddedMacros; + + /// true if setting the Modified flag of the document is currently locked + bool m_bModificationLock; + + /// true if and only if a database document existed previously (though meanwhile disposed), and was already initialized + bool m_bDocumentInitialized; + + /** the URL which the document should report as its URL + + This might differ from ->m_sDocFileLocation in case the document was loaded + as part of a crash recovery process. In this case, ->m_sDocFileLocation points to + the temporary file where the DB had been saved to, after a crash. + ->m_sDocumentURL then is the URL of the document which actually had + been recovered. + */ + OUString m_sDocumentURL; + + SignatureState m_nScriptingSignatureState; + +public: + OWeakConnectionArray m_aConnections; + const css::uno::Reference< css::uno::XComponentContext > m_aContext; + +public: + css::uno::WeakReference< css::container::XNameAccess > m_xCommandDefinitions; + css::uno::WeakReference< css::container::XNameAccess > m_xTableDefinitions; + + css::uno::Reference< css::util::XNumberFormatsSupplier > + m_xNumberFormatsSupplier; + OUString m_sConnectURL; + OUString m_sName; // transient, our creator has to tell us the title + OUString m_sUser; + OUString m_aPassword; // transient ! + OUString m_sFailedPassword; + css::uno::Sequence< css::beans::PropertyValue> + m_aLayoutInformation; + sal_Int32 m_nLoginTimeout; + bool m_bReadOnly : 1; + bool m_bPasswordRequired : 1; + bool m_bSuppressVersionColumns : 1; + bool m_bModified : 1; + bool m_bDocumentReadOnly : 1; + bool m_bMacroCallsSeenWhileLoading : 1; + css::uno::Reference< css::beans::XPropertyBag > + m_xSettings; + css::uno::Sequence< OUString > m_aTableFilter; + css::uno::Sequence< OUString > m_aTableTypeFilter; + OSharedConnectionManager* m_pSharedConnectionManager; + css::uno::Reference< css::lang::XEventListener > + m_xSharedConnectionManager; + css::uno::Reference<css::awt::XWindow> + m_xDialogParent; + sal_uInt16 m_nControllerLockCount; + + void reset(); + + /** determines whether the database document has an embedded data storage + */ + bool isEmbeddedDatabase() const { return m_sConnectURL.startsWith("sdbc:embedded:"); } + + /** stores the embedded storage ("database") + + @param _bPreventRootCommits + Normally, committing the embedded storage results in also committing the root storage + - this is an automatism for data safety reasons. + If you pass <TRUE/> here, committing the root storage is prevented for this particular + call. + @return <TRUE/> if the storage could be committed, otherwise <FALSE/> + */ + bool commitEmbeddedStorage( bool _bPreventRootCommits = false ); + + /// commits all sub storages + void commitStorages(); + + ODatabaseModelImpl( + const css::uno::Reference< css::uno::XComponentContext >& _rxContext, + ODatabaseContext& _pDBContext + ); + virtual ~ODatabaseModelImpl(); + + ODatabaseModelImpl( + const OUString& _rRegistrationName, + const css::uno::Reference< css::uno::XComponentContext >& _rxContext, + ODatabaseContext& _rDBContext + ); + + // XEventListener + /// @throws css::uno::RuntimeException + void disposing( const css::lang::EventObject& Source ); + + void setModified( bool bModified ); + + void dispose(); + + const OUString& getURL() const { return m_sDocumentURL; } + const OUString& getDocFileLocation() const { return m_sDocFileLocation; } + + css::uno::Reference< css::embed::XStorage > + getStorage( const ObjectType _eType ); + +// helper + const css::uno::Reference< css::util::XNumberFormatsSupplier >& + getNumberFormatsSupplier(); + + DocumentEventsData& + getDocumentEvents() { return m_aDocumentEvents; } + + const ::comphelper::NamedValueCollection& + getMediaDescriptor() const { return m_aMediaDescriptor; } + + void setResource( + const OUString& _rURL, + const css::uno::Sequence< css::beans::PropertyValue >& _rArgs + ); + void setDocFileLocation( + const OUString& i_rLoadedFrom + ); + + static ::comphelper::NamedValueCollection + stripLoadArguments( const ::comphelper::NamedValueCollection& _rArguments ); + +// other stuff + + // disposes all elements in m_aStorages, and clears it + void disposeStorages(); + + /// creates a ->css::embed::StorageFactory + css::uno::Reference< css::lang::XSingleServiceFactory > + createStorageFactory() const; + + /// commits our storage + void commitRootStorage(); + + /// commits a given storage if it's not readonly, ignoring (but asserting) all errors + bool commitStorageIfWriteable_ignoreErrors( + const css::uno::Reference< css::embed::XStorage >& _rxStorage + ); + + void clearConnections(); + + css::uno::Reference< css::embed::XStorage > const & getOrCreateRootStorage(); + css::uno::Reference< css::embed::XStorage > const & getRootStorage() const { return m_xDocumentStorage.getTyped(); } + void resetRootStorage() { impl_switchToStorage_throw( nullptr ); } + + /** returns the data source. If it doesn't exist it will be created + */ + css::uno::Reference< css::sdbc::XDataSource> getOrCreateDataSource(); + + /** returns the model, if there already exists one + */ + css::uno::Reference< css::frame::XModel > getModel_noCreate() const; + + /** returns a new ->ODatabaseDocument + + @precond + No ->ODatabaseDocument exists so far + + @seealso + getModel_noCreate + */ + css::uno::Reference< css::frame::XModel > createNewModel_deliverOwnership(); + + struct ResetModelAccess { friend class ODatabaseDocument; private: ResetModelAccess() { } }; + + /** resets the model to NULL + + Only to be called when the model is being disposed + */ + void modelIsDisposing( const bool _wasInitialized, ResetModelAccess ); + + bool hadInitializedDocument() const { return m_bDocumentInitialized; } + + DocumentStorageAccess* + getDocumentStorageAccess(); + + css::uno::Reference< css::document::XDocumentSubStorageSupplier > + getDocumentSubStorageSupplier(); + + void acquire(); + + void release(); + + /// returns all known data source settings, including their default values + static const AsciiPropertyValue* getDefaultDataSourceSettings(); + + /** retrieves the requested container of objects (forms/reports/tables/queries) + */ + TContentPtr& getObjectContainer( const ObjectType _eType ); + + /** returns the name of the storage which is used to stored objects of the given type, if applicable + */ + static OUString + getObjectContainerStorageName( const ObjectType _eType ); + + /** determines whether a given object storage contains macros + */ + static bool objectHasMacros( + const css::uno::Reference< css::embed::XStorage >& _rxContainerStorage, + const OUString& _rPersistentName + ); + + /** determines which kind of embedded macros are present in the document + */ + EmbeddedMacros determineEmbeddedMacros(); + + /** checks our document's macro execution mode, using the interaction handler as supplied with our + load arguments + */ + bool checkMacrosOnLoading(); + + /** adjusts our document's macro execution mode, without using any UI, assuming the user + would reject execution of macros, if she would have been asked. + + If checkMacrosOnLoading has been called before (and thus the macro execution mode + is already adjusted), then the current execution mode is simply returned. + + @return + whether or not macro execution is allowed + */ + bool adjustMacroMode_AutoReject(); + + /** resets our macro execute mode, so next time the checkMacrosOnLoading is called, it will + behave as if it has never been called before + */ + void resetMacroExecutionMode(); + + /** ensures that ->m_xBasicLibraries resp. m_xDialogLibraries exists + + @return + the requested library container. Is never <NULL/>. + + @throws RuntimeException + if something does wrong, which indicates a server error in the installation + */ + css::uno::Reference< css::script::XStorageBasedLibraryContainer > + getLibraryContainer( bool _bScript ); + + /** lets our library containers store themself into the given root storage + */ + void storeLibraryContainersTo( const css::uno::Reference< css::embed::XStorage >& _rxToRootStorage ); + + /** rebases the document to the given storage + + No actual committing, copying, saving, whatsoever happens. The storage is just remembered as the documents + new storage, nothing more. + + @throws css::lang::IllegalArgumentException + if the given storage is <NULL/> + @throws css::lang::RuntimeException + if any of the invoked operations does so + */ + css::uno::Reference< css::embed::XStorage > + switchToStorage( + const css::uno::Reference< css::embed::XStorage >& _rxNewRootStorage + ); + + /** returns the macro mode imposed by an external instance, which passed it to attachResource + */ + sal_Int16 getImposedMacroExecMode() const + { + return m_nImposedMacroExecMode; + } + void setImposedMacroExecMode( const sal_Int16 _nMacroMode ) + { + m_nImposedMacroExecMode = _nMacroMode; + } + +public: + // IMacroDocumentAccess overridables + virtual sal_Int16 getCurrentMacroExecMode() const override; + virtual void setCurrentMacroExecMode( sal_uInt16 ) override; + virtual OUString getDocumentLocation() const override; + virtual bool documentStorageHasMacros() const override; + virtual bool macroCallsSeenWhileLoading() const override; + virtual css::uno::Reference< css::document::XEmbeddedScripts > getEmbeddedDocumentScripts() const override; + virtual SignatureState getScriptingSignatureState() override; + virtual bool hasTrustedScriptingSignature( bool bAllowUIToAddAuthor ) override; + + // IModifiableDocument + virtual void storageIsModified() override; + + // don't use directly, use the ModifyLock class instead + void lockModify() { m_bModificationLock = true; } + void unlockModify() { m_bModificationLock = false; } + bool isModifyLocked() const { return m_bModificationLock; } + + weld::Window* GetFrameWeld(); + +private: + void impl_construct_nothrow(); + css::uno::Reference< css::embed::XStorage > const & + impl_switchToStorage_throw( const css::uno::Reference< css::embed::XStorage >& _rxNewRootStorage ); + + /** switches to the given document URL, which denotes the logical URL of the document, not necessarily the + URL where the doc was loaded/recovered from + */ + void impl_switchToLogicalURL( + const OUString& i_rDocumentURL + ); + +}; + +/** a small base class for UNO components whose functionality depends on an ODatabaseModelImpl +*/ +class ModelDependentComponent +{ +protected: + ::rtl::Reference< ODatabaseModelImpl > m_pImpl; + ::osl::Mutex m_aMutex; // only use this to init WeakComponentImplHelper + +protected: + explicit ModelDependentComponent( const ::rtl::Reference< ODatabaseModelImpl >& _model ); + virtual ~ModelDependentComponent(); + + /** returns the component itself + */ + virtual css::uno::Reference< css::uno::XInterface > getThis() const = 0; + + ::osl::Mutex& getMutex() + { + return m_aMutex; + } + +public: + /// checks whether the component is already disposed, throws a DisposedException if so + void checkDisposed() const + { + if ( !m_pImpl.is() ) + throw css::lang::DisposedException( "Component is already disposed.", getThis() ); + } + + void lockModify() + { + m_pImpl->lockModify(); + } + + void unlockModify() + { + m_pImpl->unlockModify(); + } +}; + +class ModifyLock +{ +public: + explicit ModifyLock( ModelDependentComponent& _component ) + :m_rComponent( _component ) + { + m_rComponent.lockModify(); + } + + ~ModifyLock() + { + m_rComponent.unlockModify(); + } + +private: + ModelDependentComponent& m_rComponent; +}; + +/** a guard for public methods of objects dependent on an ODatabaseModelImpl instance + + Just put this guard onto the stack at the beginning of your method. Don't bother yourself + with a MutexGuard, checks for being disposed, and the like. +*/ +class ModelMethodGuard +{ +private: + // to avoid deadlocks, lock SolarMutex + SolarMutexResettableGuard m_SolarGuard; + +public: + /** constructs the guard + + @param _component + the component whose functionality depends on an ODatabaseModelImpl instance + + @throws css::lang::DisposedException + If the given component is already disposed + */ + explicit ModelMethodGuard( const ModelDependentComponent& _component ) + { + _component.checkDisposed(); + } + + void clear() + { + // note: this only releases *once* so may still be locked + m_SolarGuard.clear(); + } + + void reset() + { + m_SolarGuard.reset(); + } +}; + +} // namespace dbaccess + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/PropertyForward.hxx b/dbaccess/source/core/inc/PropertyForward.hxx new file mode 100644 index 000000000..1b20e76e9 --- /dev/null +++ b/dbaccess/source/core/inc/PropertyForward.hxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_PROPERTYFORWARD_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_PROPERTYFORWARD_HXX + +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/basemutex.hxx> + +#include <vector> + +namespace dbaccess +{ + + // OPropertyForward + typedef ::cppu::WeakImplHelper< css::beans::XPropertyChangeListener + > OPropertyForward_Base; + class OPropertyForward :public ::cppu::BaseMutex + ,public OPropertyForward_Base + { + css::uno::Reference< css::beans::XPropertySet > m_xSource; + css::uno::Reference< css::beans::XPropertySet > m_xDest; + css::uno::Reference< css::beans::XPropertySetInfo > m_xDestInfo; + css::uno::Reference< css::container::XNameAccess > m_xDestContainer; + OUString m_sName; + bool m_bInInsert; + + protected: + virtual ~OPropertyForward() override; + + public: + OPropertyForward( const css::uno::Reference< css::beans::XPropertySet>& _xSource, + const css::uno::Reference< css::container::XNameAccess>& _xDestContainer, + const OUString& _sName, + const std::vector< OUString >& _aPropertyList + ); + + // css::beans::XPropertyChangeListener + virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override; + + // css::lang::XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& _rSource ) override; + + void setName( const OUString& _sName ) { m_sName = _sName; } + void setDefinition( const css::uno::Reference< css::beans::XPropertySet >& _xDest); + const css::uno::Reference< css::beans::XPropertySet >& getDefinition() const { return m_xDest; } + }; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_PROPERTYFORWARD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/RefreshListener.hxx b/dbaccess/source/core/inc/RefreshListener.hxx new file mode 100644 index 000000000..37c6ea511 --- /dev/null +++ b/dbaccess/source/core/inc/RefreshListener.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_REFRESHLISTENER_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_REFRESHLISTENER_HXX + +#include <com/sun/star/uno/Reference.h> + +namespace com::sun::star::container { class XNameAccess; } + + +namespace dbaccess +{ + + // IRefreshListener + class SAL_NO_VTABLE IRefreshListener + { + public: + virtual void refresh(const css::uno::Reference< css::container::XNameAccess >& _rToBeRefreshed) = 0; + + protected: + ~IRefreshListener() {} + }; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_REFRESHLISTENER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx new file mode 100644 index 000000000..be2f48fdb --- /dev/null +++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx @@ -0,0 +1,262 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_SINGLESELECTQUERYCOMPOSER_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_SINGLESELECTQUERYCOMPOSER_HXX + +#include <com/sun/star/sdb/XParametersSupplier.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/script/XTypeConverter.hpp> +#include <cppuhelper/implbase5.hxx> +#include <connectivity/sqliterator.hxx> +#include <connectivity/sqlparse.hxx> +#include <apitools.hxx> +#include <comphelper/broadcasthelper.hxx> +#include <comphelper/uno3.hxx> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/propertycontainer.hxx> +#include <svx/ParseContext.hxx> + +namespace com::sun::star::util { + class XNumberFormatsSupplier; + class XNumberFormatter; +} + +namespace dbaccess +{ + typedef ::cppu::ImplHelper5< css::sdb::XSingleSelectQueryComposer, + css::sdb::XParametersSupplier, + css::sdbcx::XColumnsSupplier, + css::sdbcx::XTablesSupplier, + css::lang::XServiceInfo > OSingleSelectQueryComposer_BASE; + + class OPrivateColumns; + class OPrivateTables; + + class OSingleSelectQueryComposer : public ::comphelper::OMutexAndBroadcastHelper + ,public OSubComponent + ,public ::comphelper::OPropertyContainer + ,public ::comphelper::OPropertyArrayUsageHelper < OSingleSelectQueryComposer > + ,public OSingleSelectQueryComposer_BASE + { + enum SQLPart + { + Where = 0, // the 0 is important, as it will be used as index into arrays + Group, + Having, + Order, + + SQLPartCount + }; + static void incSQLPart( SQLPart& e ) { e = static_cast<SQLPart>(1 + static_cast<size_t>(e)); } + enum EColumnType + { + SelectColumns = 0, + GroupByColumns = 1, + OrderColumns = 2, + ParameterColumns = 3 + }; + typedef std::function<const ::connectivity::OSQLParseNode*(::connectivity::OSQLParseTreeIterator *)> + TGetParseNode; + ::svxform::OSystemParseContext m_aParseContext; + ::connectivity::OSQLParser m_aSqlParser; + ::connectivity::OSQLParseTreeIterator m_aSqlIterator; // the iterator for the complete statement + ::connectivity::OSQLParseTreeIterator m_aAdditiveIterator; // the iterator for the "additive statement" (means without the clauses of the elementary statement) + std::vector<std::unique_ptr<OPrivateColumns>> + m_aColumnsCollection; // used for columns and parameters of old queries + std::vector<std::unique_ptr<OPrivateTables>> + m_aTablesCollection; + + std::vector< OUString > m_aElementaryParts; // the filter/groupby/having/order of the elementary statement + + css::uno::Reference< css::sdbc::XConnection> m_xConnection; + css::uno::Reference< css::sdbc::XDatabaseMetaData> m_xMetaData; + css::uno::Reference< css::container::XNameAccess> m_xConnectionTables; + css::uno::Reference< css::container::XNameAccess> m_xConnectionQueries; + css::uno::Reference< css::util::XNumberFormatsSupplier > m_xNumberFormatsSupplier; + css::uno::Reference< css::uno::XComponentContext> m_aContext; + css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter; + + std::vector<std::unique_ptr<OPrivateColumns>> m_aCurrentColumns; + std::unique_ptr<OPrivateTables> m_pTables; // currently used tables + + OUString m_aPureSelectSQL; // the pure select statement, without filter/order/groupby/having + OUString m_sDecimalSep; + OUString m_sCommand; + css::lang::Locale m_aLocale; + sal_Int32 m_nBoolCompareMode; // how to compare bool values + sal_Int32 m_nCommandType; + + // <properties> + OUString m_sOriginal; + // </properties> + + + bool setORCriteria(::connectivity::OSQLParseNode const * pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator, + std::vector< std::vector < css::beans::PropertyValue > >& rFilters, const css::uno::Reference< css::util::XNumberFormatter > & xFormatter) const; + bool setANDCriteria(::connectivity::OSQLParseNode const * pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator, + std::vector < css::beans::PropertyValue > & rFilters, const css::uno::Reference< css::util::XNumberFormatter > & xFormatter) const; + bool setLikePredicate(::connectivity::OSQLParseNode const * pCondition, ::connectivity::OSQLParseTreeIterator const & _rIterator, + std::vector < css::beans::PropertyValue > & rFilters, const css::uno::Reference< css::util::XNumberFormatter > & xFormatter) const; + bool setComparisonPredicate(::connectivity::OSQLParseNode const * pCondition, ::connectivity::OSQLParseTreeIterator const & _rIterator, + std::vector < css::beans::PropertyValue > & rFilters, const css::uno::Reference< css::util::XNumberFormatter > & xFormatter) const; + + static OUString getColumnName(::connectivity::OSQLParseNode const * pColumnRef, ::connectivity::OSQLParseTreeIterator const & _rIterator); + OUString getTableAlias(const css::uno::Reference< css::beans::XPropertySet >& column ) const; + static sal_Int32 getPredicateType(::connectivity::OSQLParseNode const * _pPredicate); + // clears all Columns,Parameters and tables and insert it to their vectors + void clearCurrentCollections(); + // clears the columns collection given by EColumnType + void clearColumns( const EColumnType _eType ); + + /** retrieves a particular part of a statement + @param _rIterator + the iterator to use. + */ + OUString getStatementPart( TGetParseNode const & _aGetFunctor, ::connectivity::OSQLParseTreeIterator& _rIterator ); + void setQuery_Impl( const OUString& command ); + + void setConditionByColumn( const css::uno::Reference< css::beans::XPropertySet >& column + , bool andCriteria + , std::function<bool(OSingleSelectQueryComposer *, const OUString&)> const & _aSetFunctor + ,sal_Int32 filterOperator); + + /** getStructuredCondition returns the structured condition for the where or having clause + @param _aGetFunctor + A member function to get the correct parse node. + + @return + The structured filter + */ + css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > + getStructuredCondition( TGetParseNode const & _aGetFunctor ); + + css::uno::Reference< css::container::XIndexAccess > + setCurrentColumns( EColumnType _eType, const ::rtl::Reference< ::connectivity::OSQLColumns >& _rCols ); + + //helper methods for mem_fun_t + bool implSetFilter(const OUString& _sFilter) { setFilter(_sFilter); return true;} + bool implSetHavingClause(const OUString& _sFilter) { setHavingClause(_sFilter); return true;} + + /** returns the part of the select statement + @param _ePart + Which part should be returned. + @param _bWithKeyword + If <TRUE/> the keyword will be added too. Otherwise not. + @param _rIterator + The iterator to use. + + @return + The part of the select statement. + */ + OUString getSQLPart( SQLPart _ePart, ::connectivity::OSQLParseTreeIterator& _rIterator, bool _bWithKeyword ); + + /** retrieves the keyword for the given SQLPart + */ + static OUString getKeyword( SQLPart _ePart ); + + /** sets a single "additive" clause, means a filter/groupby/having/order clause + */ + void setSingleAdditiveClause( SQLPart _ePart, const OUString& _rClause ); + + /** composes a statement from m_aPureSelectSQL and the 4 usual clauses + */ + OUString composeStatementFromParts( const std::vector< OUString >& _rParts ); + + /** return the name of the column in the *source* *table*. + + That is, for (SELECT a AS b FROM t), it returns A or "t"."A", as appropriate. + + Use e.g. for WHERE, GROUP BY and HAVING clauses. + + @param bGroupBy: for GROUP BY clause? In that case, throw exception if trying to use an unrelated column and the database does not support that. + */ + OUString impl_getColumnRealName_throw(const css::uno::Reference< css::beans::XPropertySet >& column, bool bGroupBy); + + /** return the name of the column in the *query* for ORDER BY clause. + + That is, for (SELECT a AS b FROM t), it returns "b" + + Throws exception if trying to use an unrelated column and the database does not support that. + */ + OUString impl_getColumnNameOrderBy_throw(const css::uno::Reference< css::beans::XPropertySet >& column); + + protected: + virtual ~OSingleSelectQueryComposer() override; + public: + + OSingleSelectQueryComposer( const css::uno::Reference< css::container::XNameAccess>& _xTableSupplier, + const css::uno::Reference< css::sdbc::XConnection>& _xConnection, + const css::uno::Reference< css::uno::XComponentContext>& _rContext); + + + void SAL_CALL disposing() override; + + virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override; + virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override; + + // css::uno::XInterface + DECLARE_XINTERFACE( ) + + // XServiceInfo + DECLARE_SERVICE_INFO(); + + DECLARE_PROPERTYCONTAINER_DEFAULTS(); + + // css::sdb::XSingleSelectQueryComposer + virtual OUString SAL_CALL getElementaryQuery() override; + virtual void SAL_CALL setElementaryQuery( const OUString& _rElementary ) override; + virtual void SAL_CALL setFilter( const OUString& filter ) override; + virtual void SAL_CALL setStructuredFilter( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& filter ) override; + virtual void SAL_CALL appendFilterByColumn( const css::uno::Reference< css::beans::XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) override; + virtual void SAL_CALL appendGroupByColumn( const css::uno::Reference< css::beans::XPropertySet >& column ) override; + virtual void SAL_CALL setGroup( const OUString& group ) override; + virtual void SAL_CALL setHavingClause( const OUString& filter ) override; + virtual void SAL_CALL setStructuredHavingClause( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& filter ) override; + virtual void SAL_CALL appendHavingClauseByColumn( const css::uno::Reference< css::beans::XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) override; + virtual void SAL_CALL appendOrderByColumn( const css::uno::Reference< css::beans::XPropertySet >& column, sal_Bool ascending ) override; + virtual void SAL_CALL setOrder( const OUString& order ) override; + + // XSingleSelectQueryAnalyzer + virtual OUString SAL_CALL getQuery( ) override; + virtual void SAL_CALL setQuery( const OUString& command ) override; + virtual void SAL_CALL setCommand( const OUString& command,sal_Int32 CommandType ) override; + virtual OUString SAL_CALL getFilter( ) override; + virtual css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > SAL_CALL getStructuredFilter( ) override; + virtual OUString SAL_CALL getGroup( ) override; + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getGroupColumns( ) override; + virtual OUString SAL_CALL getHavingClause( ) override; + virtual css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > SAL_CALL getStructuredHavingClause( ) override; + virtual OUString SAL_CALL getOrder( ) override; + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getOrderColumns( ) override; + virtual OUString SAL_CALL getQueryWithSubstitution( ) override; + + // XColumnsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns( ) override; + // XTablesSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables( ) override; + // XParametersSupplier + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getParameters( ) override; + }; +} +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_SINGLESELECTQUERYCOMPOSER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/TableDeco.hxx b/dbaccess/source/core/inc/TableDeco.hxx new file mode 100644 index 000000000..f7bec41b9 --- /dev/null +++ b/dbaccess/source/core/inc/TableDeco.hxx @@ -0,0 +1,166 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_TABLEDECO_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_TABLEDECO_HXX + +#include <memory> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> +#include <com/sun/star/sdbcx/XIndexesSupplier.hpp> +#include <com/sun/star/sdbcx/XKeysSupplier.hpp> +#include <com/sun/star/sdbcx/XRename.hpp> +#include <com/sun/star/sdbcx/XAlterTable.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <cppuhelper/compbase.hxx> +#include "datasettings.hxx" +#include "column.hxx" + +#include <connectivity/CommonTools.hxx> +#include <connectivity/sdbcx/IRefreshable.hxx> +#include <comphelper/IdPropArrayHelper.hxx> + +namespace dbaccess +{ + typedef ::cppu::WeakComponentImplHelper< css::sdbcx::XColumnsSupplier, + css::sdbcx::XKeysSupplier, + css::container::XNamed, + css::lang::XServiceInfo, + css::sdbcx::XDataDescriptorFactory, + css::sdbcx::XIndexesSupplier, + css::sdbcx::XRename, + css::lang::XUnoTunnel, + css::sdbcx::XAlterTable> OTableDescriptor_BASE; + // OTables + class ODBTableDecorator; + typedef ::comphelper::OIdPropertyArrayUsageHelper< ODBTableDecorator > ODBTableDecorator_PROP; + + class ODBTableDecorator :public cppu::BaseMutex + ,public OTableDescriptor_BASE + ,public ODataSettings //ODataSettings_Base + ,public IColumnFactory + ,public ::connectivity::sdbcx::IRefreshableColumns + ,public ODBTableDecorator_PROP + { + void fillPrivileges() const; + protected: + css::uno::Reference< css::container::XContainerListener > m_xColumnMediator; + css::uno::Reference< css::sdbcx::XColumnsSupplier > m_xTable; + css::uno::Reference< css::container::XNameAccess > m_xColumnDefinitions; + css::uno::Reference< css::sdbc::XConnection > m_xConnection; + css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData; + css::uno::Reference< css::util::XNumberFormatsSupplier > m_xNumberFormats; + + // <properties> + mutable sal_Int32 m_nPrivileges; + // </properties> + // note: this thing uses the ref-count of "this", see OCollection::acquire()! + std::unique_ptr<::connectivity::sdbcx::OCollection> m_pColumns; + + // IColumnFactory + virtual OColumn* createColumn(const OUString& _rName) const override; + virtual css::uno::Reference< css::beans::XPropertySet > createColumnDescriptor() override; + virtual void columnAppended( const css::uno::Reference< css::beans::XPropertySet >& _rxSourceDescriptor ) override; + virtual void columnDropped(const OUString& _sName) override; + + virtual void refreshColumns() override; + + virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 _nId) const override; + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any & rConvertedValue, + css::uno::Any & rOldValue, + sal_Int32 nHandle, + const css::uno::Any& rValue ) override; + virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle) const override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const css::uno::Any& rValue + ) override; + + virtual ~ODBTableDecorator() override; + public: + /** constructs a wrapper supporting the com.sun.star.sdb.Table service. + + @param _rxConn + the connection the table belongs to. Must not be <NULL/> + @param _rxTable + the table from the driver can be <NULL/> + @throws css::sdbc::SQLException + */ + ODBTableDecorator( + const css::uno::Reference< css::sdbc::XConnection >& _rxConn, + const css::uno::Reference< css::sdbcx::XColumnsSupplier >& _rxTable, + const css::uno::Reference< css::util::XNumberFormatsSupplier >& _rxNumberFormats, + const css::uno::Reference< css::container::XNameAccess >& _rxColumnDefinitions + ); + + // ODescriptor + void construct(); + + //XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + + // css::lang::XServiceInfo + DECLARE_SERVICE_INFO(); + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + // css::sdbcx::XRename, + virtual void SAL_CALL rename( const OUString& _rNewName ) override; + + // css::sdbcx::XAlterTable, + virtual void SAL_CALL alterColumnByName( const OUString& _rName, const css::uno::Reference< css::beans::XPropertySet >& _rxDescriptor ) override; + virtual void SAL_CALL alterColumnByIndex( sal_Int32 _nIndex, const css::uno::Reference< css::beans::XPropertySet >& _rxDescriptor ) override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + // css::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; + static css::uno::Sequence< sal_Int8 > getUnoTunnelId(); + + // XColumnsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns( ) override; + // XKeysSupplier + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getKeys( ) override; + // XIndexesSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getIndexes( ) override; + // XDataDescriptorFactory + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor( ) override; + + protected: + using ODataSettings::getFastPropertyValue; + }; +} +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_TABLEDECO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/View.hxx b/dbaccess/source/core/inc/View.hxx new file mode 100644 index 000000000..93985e068 --- /dev/null +++ b/dbaccess/source/core/inc/View.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_VIEW_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_VIEW_HXX + +#include <connectivity/sdbcx/VView.hxx> + +#include <com/sun/star/sdbcx/XAlterView.hpp> +#include <com/sun/star/sdb/tools/XViewAccess.hpp> + +#include <comphelper/uno3.hxx> +#include <cppuhelper/implbase1.hxx> + +namespace dbaccess +{ + + // View + typedef ::connectivity::sdbcx::OView View_Base; + typedef ::cppu::ImplHelper1< css::sdbcx::XAlterView > View_IBASE; + class View :public View_Base + ,public View_IBASE + { + public: + View( + const css::uno::Reference< css::sdbc::XConnection >& _rxConnection, + bool _bCaseSensitive, + const OUString& _rCatalogName, + const OUString& _rSchemaName, + const OUString& _rName + ); + + // UNO + DECLARE_XINTERFACE() + DECLARE_XTYPEPROVIDER() + + // XAlterView + virtual void SAL_CALL alterCommand( const OUString& NewCommand ) override; + + protected: + virtual ~View() override; + + protected: + // OPropertyContainer + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& _rValue, sal_Int32 _nHandle ) const override; + + private: + css::uno::Reference< css::sdb::tools::XViewAccess> m_xViewAccess; + sal_Int32 m_nCommandHandle; + private: + using View_Base::getFastPropertyValue; + }; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_VIEW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/bookmarkcontainer.hxx b/dbaccess/source/core/inc/bookmarkcontainer.hxx new file mode 100644 index 000000000..10da82a6c --- /dev/null +++ b/dbaccess/source/core/inc/bookmarkcontainer.hxx @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_BOOKMARKCONTAINER_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_BOOKMARKCONTAINER_HXX + +#include <sal/config.h> + +#include <map> +#include <vector> + +#include <comphelper/interfacecontainer2.hxx> +#include <cppuhelper/implbase.hxx> +#include <osl/mutex.hxx> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +namespace dbaccess +{ + +// OBookmarkContainer - base class of collections of database definition +// documents +typedef ::cppu::WeakImplHelper< + css::container::XIndexAccess + , css::container::XNameContainer + , css::container::XEnumerationAccess + , css::container::XContainer + , css::lang::XServiceInfo + , css::container::XChild + > OBookmarkContainer_Base; + +class OBookmarkContainer final + :public OBookmarkContainer_Base +{ + typedef std::map<OUString, OUString> MapString2String; + typedef std::vector<MapString2String::iterator> MapIteratorVector; + + MapString2String m_aBookmarks; // the bookmarks itself + MapIteratorVector m_aBookmarksIndexed; // for index access to the + + ::cppu::OWeakObject& m_rParent; // for the ref counting + ::comphelper::OInterfaceContainerHelper2 + m_aContainerListeners; + ::osl::Mutex& m_rMutex; + +public: + /** constructs the container.<BR> + after the construction of the object the creator has to call <code>initialize</code>. + @param _rParent the parent object which is used for ref counting + @param _rMutex the parent's mutex object for access safety + */ + OBookmarkContainer( + ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex + ); + + /** looks like the dtor ... + */ + virtual ~OBookmarkContainer() override; + +// css::uno::XInterface + virtual void SAL_CALL acquire( ) throw() override; + virtual void SAL_CALL release( ) throw() override; + +// css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + +// css::container::XElementAccess + virtual css::uno::Type SAL_CALL getElementType( ) override; + virtual sal_Bool SAL_CALL hasElements( ) override; + +// css::container::XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) override; + +// css::container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount( ) override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 _nIndex ) override; + +// css::container::XNameContainer + virtual void SAL_CALL insertByName( const OUString& _rName, const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& _rName ) override; + +// css::container::XNameReplace + virtual void SAL_CALL replaceByName( const OUString& _rName, const css::uno::Any& aElement ) override; + +// css::container::XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + +// css::container::XContainer + virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + +// css::container::XChild + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override; + virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override; + +private: + /** quickly checks if there already is an element with a given name. No access to the configuration occurs, i.e. + if there is such an object which is not already loaded, it won't be loaded now. + @param _rName the object name to check + @return sal_True if there already exists such an object + */ + inline bool checkExistence(const OUString& _rName); + + void implAppend( + const OUString& _rName, + const OUString& _rDocumentLocation + ); + + void implRemove(const OUString& _rName); + + void implReplace( + const OUString& _rName, + const OUString& _rNewLink); + +}; + +inline bool OBookmarkContainer::checkExistence(const OUString& _rName) +{ + return m_aBookmarks.find(_rName) != m_aBookmarks.end(); +} + +} // namespace dbaccess + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/callablestatement.hxx b/dbaccess/source/core/inc/callablestatement.hxx new file mode 100644 index 000000000..9ca89317c --- /dev/null +++ b/dbaccess/source/core/inc/callablestatement.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_CALLABLESTATEMENT_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_CALLABLESTATEMENT_HXX + +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XOutParameters.hpp> +#include "preparedstatement.hxx" + +namespace dbaccess +{ + + // OCallableStatement + + class OCallableStatement : public OPreparedStatement, + public css::sdbc::XRow, + public css::sdbc::XOutParameters + { + public: + OCallableStatement(const css::uno::Reference< css::sdbc::XConnection > & _xConn, + const css::uno::Reference< css::uno::XInterface > & _xStatement) + :OPreparedStatement(_xConn, _xStatement){} + + // css::lang::XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::uno::XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + + // css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // css::sdbc::XOutParameters + virtual void SAL_CALL registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName ) override; + virtual void SAL_CALL registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) override; + + // css::sdbc::XRow + virtual sal_Bool SAL_CALL wasNull( ) override; + virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) override; + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) override; + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) override; + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) override; + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) override; + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) override; + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) override; + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) override; + virtual css::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) override; + virtual css::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) override; + virtual css::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) override; + virtual css::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess >& typeMap ) override; + virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) override; + }; +} +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_CALLABLESTATEMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/column.hxx b/dbaccess/source/core/inc/column.hxx new file mode 100644 index 000000000..3744715c7 --- /dev/null +++ b/dbaccess/source/core/inc/column.hxx @@ -0,0 +1,219 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_COLUMN_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_COLUMN_HXX + +#include "columnsettings.hxx" + +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include <comphelper/propertycontainer.hxx> +#include <connectivity/TColumnsHelper.hxx> +#include <connectivity/sdbcx/IRefreshable.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/implbase1.hxx> + +namespace dbaccess +{ + + + // OColumn + + typedef ::cppu::WeakComponentImplHelper< css::lang::XServiceInfo, + css::container::XNamed + > OColumnBase; + + class OColumn :public cppu::BaseMutex + ,public OColumnBase + ,public ::comphelper::OPropertyContainer + ,public IPropertyContainer // convenience for the derived class which also derive from OColumnSettings + { + friend class OColumns; + + protected: + // <properties> + OUString m_sName; + // </properties> + + protected: + OColumn( const bool _bNameIsReadOnly ); + + public: + virtual ~OColumn() override; + + // css::lang::XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override = 0; + + // css::uno::XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + + // css::beans::XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + + // cppu::OComponentHelper + virtual void SAL_CALL disposing() override; + + // css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // XNamed + virtual OUString SAL_CALL getName( ) override; + virtual void SAL_CALL setName( const OUString& _rName ) override; + + protected: + // IPropertyContainer + virtual void registerProperty( const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void* _pPointerToMember, const css::uno::Type& _rMemberType ) override; + virtual void registerMayBeVoidProperty( const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, css::uno::Any* _pPointerToMember, const css::uno::Type& _rExpectedType ) override; + }; + + // IColumnFactory - used by OColumns for creating new columns + class SAL_NO_VTABLE IColumnFactory + { + public: + /** creates an OColumn object which should represent the column with a given name + */ + virtual OColumn* + createColumn( const OUString& _rName ) const = 0; + + /** creates a column descriptor object. + + A column descriptor object is used to append new columns to the collection. If such an append + actually happened, columnAppended is called afterwards. + */ + virtual css::uno::Reference< css::beans::XPropertySet > createColumnDescriptor() = 0; + + /** notifies that a column, created from a column descriptor, has been appended + */ + virtual void columnAppended( const css::uno::Reference< css::beans::XPropertySet >& _rxSourceDescriptor ) = 0; + + /** notifies that a column with a given name has been dropped + */ + virtual void columnDropped( const OUString& _sName ) = 0; + + protected: + ~IColumnFactory() {} + }; + + class OContainerMediator; + typedef ::cppu::ImplHelper1< css::container::XChild > TXChild; + typedef connectivity::OColumnsHelper OColumns_BASE; + + class OColumns : public OColumns_BASE + ,public TXChild + { + OContainerMediator* m_pMediator; + + protected: + // comes from the driver can be null + css::uno::Reference< css::container::XNameAccess > m_xDrvColumns; + css::uno::WeakReference< css::uno::XInterface > m_xParent; + IColumnFactory* m_pColFactoryImpl; + ::connectivity::sdbcx::IRefreshableColumns* m_pRefreshColumns; + + bool m_bInitialized : 1; + bool m_bAddColumn : 1; + bool m_bDropColumn : 1; + + virtual void impl_refresh() override; + virtual connectivity::sdbcx::ObjectType createObject(const OUString& _rName) override; + virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; + virtual connectivity::sdbcx::ObjectType appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; + virtual void dropObject(sal_Int32 _nPos, const OUString& _sElementName) override; + + public: + connectivity::sdbcx::ObjectType createBaseObject(const OUString& _rName) + { + return OColumns_BASE::createObject(_rName); + } + /** flag which determines whether the container is filled or not + */ + bool isInitialized() const { return m_bInitialized; } + void setInitialized() {m_bInitialized = true;} + void setMediator(OContainerMediator* _pMediator) { m_pMediator = _pMediator; } + + public: + /** constructs an empty container without configuration location. + @param rParent the parent object. This instance will be used for refcounting, so the parent + cannot die before the container does. + @param _rMutex the mutex of the parent. + @param _bCaseSensitive the initial case sensitivity flag + @see setCaseSensitive + */ + OColumns( + ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + bool _bCaseSensitive, + const std::vector< OUString>& _rVector, + IColumnFactory* _pColFactory, + ::connectivity::sdbcx::IRefreshableColumns* _pRefresh, + bool _bAddColumn = false, + bool _bDropColumn = false, + bool _bUseHardRef = true); + + OColumns( + ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const css::uno::Reference< css::container::XNameAccess >& _rxDrvColumns, + bool _bCaseSensitive, + const std::vector< OUString> &_rVector, + IColumnFactory* _pColFactory, + ::connectivity::sdbcx::IRefreshableColumns* _pRefresh, + bool _bAddColumn = false, + bool _bDropColumn = false, + bool _bUseHardRef = true); + virtual ~OColumns() override; + + //XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override { OColumns_BASE::acquire(); } + virtual void SAL_CALL release() throw() override { OColumns_BASE::release(); } + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // css::container::XChild + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override; + virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override; + + void append(const OUString& rName, OColumn*); + void clearColumns(); + // only the name is identical to ::cppu::OComponentHelper + virtual void disposing() override; + + private: + using OColumns_BASE::setParent; + }; +} +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_COLUMN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/columnsettings.hxx b/dbaccess/source/core/inc/columnsettings.hxx new file mode 100644 index 000000000..29a93effa --- /dev/null +++ b/dbaccess/source/core/inc/columnsettings.hxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_COLUMNSETTINGS_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_COLUMNSETTINGS_HXX + +#include <com/sun/star/beans/XPropertySet.hpp> + +namespace dbaccess +{ + + // TODO: move the following to comphelper/propertycontainerhelper.hxx + class IPropertyContainer + { + public: + virtual void registerProperty( + const OUString& _rName, + sal_Int32 _nHandle, + sal_Int32 _nAttributes, + void* _pPointerToMember, + const css::uno::Type& _rMemberType + ) = 0; + + virtual void registerMayBeVoidProperty( + const OUString& _rName, + sal_Int32 _nHandle, + sal_Int32 _nAttributes, + css::uno::Any* _pPointerToMember, + const css::uno::Type& _rExpectedType + ) = 0; + + protected: + ~IPropertyContainer() {} + }; + + // OColumnSettings + class OColumnSettings + { + // <properties> + css::uno::Any m_aWidth; // sal_Int32 or void + css::uno::Any m_aFormatKey; // sal_Int32 or void + css::uno::Any m_aRelativePosition; // sal_Int32 or void + css::uno::Any m_aAlignment; // sal_Int32 (css::awt::TextAlign) or void + css::uno::Any m_aHelpText; // the description of the column which is visible in the helptext of the column + css::uno::Any m_aControlDefault; // the default value which should be displayed as by a control when moving to a new row + css::uno::Reference< css::beans::XPropertySet > + m_xControlModel; + bool m_bHidden; + // </properties> + + protected: + virtual ~OColumnSettings(); + + public: + OColumnSettings(); + + protected: + void registerProperties( IPropertyContainer& _rPropertyContainer ); + + /** determines whether the property with the given handle is handled by the class + */ + static bool isColumnSettingProperty( const sal_Int32 _nPropertyHandle ); + static bool isDefaulted( const sal_Int32 _nPropertyHandle, const css::uno::Any& _rPropertyValue ); + + public: + /** check if the persistent settings have their default value + */ + static bool hasDefaultSettings( const css::uno::Reference< css::beans::XPropertySet >& _rxColumn ); + }; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_COLUMNSETTINGS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/commandbase.hxx b/dbaccess/source/core/inc/commandbase.hxx new file mode 100644 index 000000000..725e34876 --- /dev/null +++ b/dbaccess/source/core/inc/commandbase.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_COMMANDBASE_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_COMMANDBASE_HXX + +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> + +namespace dbaccess +{ + +// OCommandBase - a base class (in fact just a container for some members) +// for classes implementing the sdb.CommandDefinition service +class OCommandBase +{ +public: // need public access +// <properties> + css::uno::Sequence< css::beans::PropertyValue> + m_aLayoutInformation; + OUString m_sCommand; + bool m_bEscapeProcessing; // no BitField! So it can be used with an OPropertyStateContainer + OUString m_sUpdateTableName; + OUString m_sUpdateSchemaName; + OUString m_sUpdateCatalogName; +// </properties> + +protected: + OCommandBase() : m_bEscapeProcessing(true) { } + +}; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_COMMANDBASE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/composertools.hxx b/dbaccess/source/core/inc/composertools.hxx new file mode 100644 index 000000000..d0bfdc3ff --- /dev/null +++ b/dbaccess/source/core/inc/composertools.hxx @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX + +#include <rtl/ustrbuf.hxx> +#include <osl/diagnose.h> + +namespace dbaccess +{ + + // TokenComposer + struct TokenComposer + { + private: + #ifdef DBG_UTIL + bool m_bUsed; + #endif + + protected: + OUStringBuffer m_aBuffer; + + public: + OUString getComposedAndClear() + { + #ifdef DBG_UTIL + m_bUsed = true; + #endif + return m_aBuffer.makeStringAndClear(); + } + + void clear() + { + #ifdef DBG_UTIL + m_bUsed = false; + #endif + m_aBuffer.setLength(0); + } + + public: + TokenComposer() + #ifdef DBG_UTIL + :m_bUsed( false ) + #endif + { + } + + virtual ~TokenComposer() + { + } + + TokenComposer(TokenComposer const &) = default; + TokenComposer(TokenComposer &&) = default; + TokenComposer & operator =(TokenComposer const &) = default; + TokenComposer & operator =(TokenComposer &&) = default; + + void operator() (const OUString& lhs) + { + append(lhs); + } + + void append( const OUString& lhs ) + { + #ifdef DBG_UTIL + OSL_ENSURE( !m_bUsed, "FilterCreator::append: already used up!" ); + #endif + if ( !lhs.isEmpty() ) + { + if ( !m_aBuffer.isEmpty() ) + appendNonEmptyToNonEmpty( lhs ); + else + m_aBuffer.append( lhs ); + } + } + + /// append the given part. Only to be called when both the part and our buffer so far are not empty + virtual void appendNonEmptyToNonEmpty( const OUString& lhs ) = 0; + }; + + // FilterCreator + struct FilterCreator : public TokenComposer + { + virtual void appendNonEmptyToNonEmpty( const OUString& lhs ) override + { + m_aBuffer.insert( 0, ' ' ); + m_aBuffer.insert( 0, '(' ); + m_aBuffer.append( " ) AND ( " ); + m_aBuffer.append( lhs ); + m_aBuffer.append( " )" ); + } + }; + + // FilterCreator + struct OrderCreator : public TokenComposer + { + virtual void appendNonEmptyToNonEmpty( const OUString& lhs ) override + { + m_aBuffer.append( ", " ); + m_aBuffer.append( lhs ); + } + }; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/containerapprove.hxx b/dbaccess/source/core/inc/containerapprove.hxx new file mode 100644 index 000000000..d350470ad --- /dev/null +++ b/dbaccess/source/core/inc/containerapprove.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTAINERAPPROVE_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTAINERAPPROVE_HXX + +#include <rtl/ustring.hxx> + +#include <memory> + +namespace dbaccess +{ + + // IContainerApprove + /** interface for approving elements to be inserted into a container + + On the long run, one could imagine that this interface completely encapsulates + container/element approvals in all our various container classes herein (document + containers, definition containers, table containers, query containers, + command definition containers, bookmark containers). This would decrease coupling + of the respective classes. + */ + class SAL_NO_VTABLE IContainerApprove + { + public: + virtual ~IContainerApprove() {} + + /** approves a given element for insertion into the container + @param _rName + specifies the name under which the element is going to be inserted + @throws Exception + if the name or the object are invalid, or not eligible for insertion + into the container + */ + virtual void approveElement( const OUString& _rName ) = 0; + }; + + typedef std::shared_ptr< IContainerApprove > PContainerApprove; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_CONTAINERAPPROVE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/databasecontext.hxx b/dbaccess/source/core/inc/databasecontext.hxx new file mode 100644 index 000000000..0c1848042 --- /dev/null +++ b/dbaccess/source/core/inc/databasecontext.hxx @@ -0,0 +1,191 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_DATABASECONTEXT_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_DATABASECONTEXT_HXX + +#include <sal/config.h> + +#include <config_features.h> + +#include <map> + +#include "ModelImpl.hxx" + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/sdb/XDatabaseContext.hpp> +#include <com/sun/star/sdb/XDatabaseRegistrations.hpp> +#include <com/sun/star/uno/XAggregation.hpp> + +#if HAVE_FEATURE_SCRIPTING +#include <basic/basrdll.hxx> +#endif + +#include <basic/basicmanagerrepository.hxx> +#include <cppuhelper/compbase.hxx> + +// needed for registration +namespace com::sun::star { + namespace lang + { + class XMultiServiceFactory; + class IllegalArgumentException; + } +} + +namespace dbaccess +{ +class DatabaseDocumentLoader; + +typedef ::cppu::WeakComponentImplHelper< css::lang::XServiceInfo + , css::sdb::XDatabaseContext + , css::lang::XUnoTunnel + > DatabaseAccessContext_Base; + +class ODatabaseContext :public DatabaseAccessContext_Base + ,public ::basic::BasicManagerCreationListener +{ +private: + /** loads the given object from the given URL + @throws WrappedTargetException + if an error occurs accessing the URL via the UCB + */ + css::uno::Reference< css::uno::XInterface > loadObjectFromURL(const OUString& _rName,const OUString& _sURL); + css::uno::Reference< css::uno::XInterface > getObject( const OUString& _rURL ); + + /** sets all properties which were transient at the data source. e.g. password + @param _sURL The file URL of the data source + @param _xObject The data source itself. + */ + void setTransientProperties(const OUString& _sURL, ODatabaseModelImpl& _rDataSourceModel ); + + /** creates a new data source + */ + css::uno::Reference< css::uno::XInterface > + impl_createNewDataSource(); + +#if HAVE_FEATURE_SCRIPTING + BasicDLL m_aBasicDLL; +#endif + +protected: + ::osl::Mutex m_aMutex; + css::uno::Reference< css::uno::XComponentContext > + m_aContext; + + css::uno::Reference< css::uno::XAggregation > + m_xDBRegistrationAggregate; + css::uno::Reference< css::sdb::XDatabaseRegistrations > + m_xDatabaseRegistrations; + + typedef std::map<OUString, ODatabaseModelImpl*> ObjectCache; + ObjectCache m_aDatabaseObjects; + + typedef std::map< OUString, css::uno::Sequence< css::beans::PropertyValue > > PropertyCache; + PropertyCache m_aDatasourceProperties; + // as we hold our data sources weak, we have to cache all properties on the data sources which are + // transient but stored as long as the session lasts. The database context is the session (as it lives + // as long as the session does), but the data sources may die before the session does, and then be + // recreated afterwards. So it's our (the context's) responsibility to store the session-persistent + // properties. + + ::comphelper::OInterfaceContainerHelper2 m_aContainerListeners; + rtl::Reference<DatabaseDocumentLoader> m_xDatabaseDocumentLoader; + +public: + explicit ODatabaseContext( const css::uno::Reference< css::uno::XComponentContext >& ); + virtual ~ODatabaseContext() override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + + // XSingleServiceFactory + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( ) override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const css::uno::Sequence< css::uno::Any >& _rArguments ) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // XServiceInfo - static methods + /// @throws css::uno::RuntimeException + static css::uno::Sequence< OUString > getSupportedServiceNames_static(); + /// @throws css::uno::RuntimeException + static OUString getImplementationName_static(); + static css::uno::Reference< css::uno::XInterface > + Create(const css::uno::Reference< css::uno::XComponentContext >&); + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType( ) override; + virtual sal_Bool SAL_CALL hasElements( ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XNamingService + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRegisteredObject( const OUString& Name ) override; + virtual void SAL_CALL registerObject( const OUString& Name, const css::uno::Reference< css::uno::XInterface >& Object ) override; + virtual void SAL_CALL revokeObject( const OUString& Name ) override; + + // XDatabaseRegistrations + virtual sal_Bool SAL_CALL hasRegisteredDatabase( const OUString& Name ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getRegistrationNames() override; + virtual OUString SAL_CALL getDatabaseLocation( const OUString& Name ) override; + virtual void SAL_CALL registerDatabaseLocation( const OUString& Name, const OUString& Location ) override; + virtual void SAL_CALL revokeDatabaseLocation( const OUString& Name ) override; + virtual void SAL_CALL changeDatabaseLocation( const OUString& Name, const OUString& NewLocation ) override; + virtual sal_Bool SAL_CALL isDatabaseRegistrationReadOnly( const OUString& Name ) override; + virtual void SAL_CALL addDatabaseRegistrationsListener( const css::uno::Reference< css::sdb::XDatabaseRegistrationsListener >& Listener ) override; + virtual void SAL_CALL removeDatabaseRegistrationsListener( const css::uno::Reference< css::sdb::XDatabaseRegistrationsListener >& Listener ) override; + + // XContainer + virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + + // css::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; + static css::uno::Sequence< sal_Int8 > getUnoTunnelId(); + + void registerDatabaseDocument( ODatabaseModelImpl& _rModelImpl); + void revokeDatabaseDocument( const ODatabaseModelImpl& _rModelImpl); + void databaseDocumentURLChange(const OUString& _sOldName, const OUString& _sNewName); + void storeTransientProperties( ODatabaseModelImpl& _rModelImpl); + void appendAtTerminateListener(const ODatabaseModelImpl& _rDataSourceModel); + void removeFromTerminateListener(const ODatabaseModelImpl& _rDataSourceModel); + +private: + // BasicManagerCreationListener + virtual void onBasicManagerCreated( + const css::uno::Reference< css::frame::XModel >& _rxForDocument, + BasicManager& _rBasicManager + ) override; +}; + +} // namespace dbaccess + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/datasettings.hxx b/dbaccess/source/core/inc/datasettings.hxx new file mode 100644 index 000000000..9b6a7f686 --- /dev/null +++ b/dbaccess/source/core/inc/datasettings.hxx @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_DATASETTINGS_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_DATASETTINGS_HXX + +#include <com/sun/star/awt/FontDescriptor.hpp> +#include <rtl/ustring.hxx> +#include <comphelper/propertystatecontainer.hxx> + +namespace dbaccess +{ + +// ODataSettings_Base - a base class which implements the property member +// for an object implementing the sdb::DataSettings +// service +// the properties have to be registered when used +class ODataSettings_Base +{ +public: +// <properties> + OUString m_sFilter; + OUString m_sHavingClause; + OUString m_sGroupBy; + OUString m_sOrder; + bool m_bApplyFilter; // no BitField ! the base class needs a pointer to this member ! + bool m_bAutoGrow; + css::awt::FontDescriptor m_aFont; + css::uno::Any m_aRowHeight; + css::uno::Any m_aTextColor; + css::uno::Any m_aTextLineColor; + sal_Int16 m_nFontEmphasis; + sal_Int16 m_nFontRelief; +// </properties> + +protected: + ODataSettings_Base(); + ODataSettings_Base(const ODataSettings_Base& _rSource) = delete; + ~ODataSettings_Base(); +}; +// ODataSettings - a base class which implements the property handling +// for an object implementing the sdb::DataSettings +// service + +class ODataSettings : public ::comphelper::OPropertyStateContainer + , public ODataSettings_Base +{ + bool m_bQuery; +protected: + ODataSettings(::cppu::OBroadcastHelper& _rBHelper,bool _bQuery = false); + virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, css::uno::Any& _rDefault ) const override; + + /** register the properties from the param given. The parameter instance must be alive as long as its object lives. + @param _pItem + The database settings, can be <br>this</br> + */ + void registerPropertiesFor(ODataSettings_Base* _pItem); +}; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_DATASETTINGS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/definitioncolumn.hxx b/dbaccess/source/core/inc/definitioncolumn.hxx new file mode 100644 index 000000000..69d2c3c84 --- /dev/null +++ b/dbaccess/source/core/inc/definitioncolumn.hxx @@ -0,0 +1,293 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_DEFINITIONCOLUMN_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_DEFINITIONCOLUMN_HXX + +#include "column.hxx" +#include "columnsettings.hxx" + +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/container/XChild.hpp> + +#include <comphelper/IdPropArrayHelper.hxx> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/implbase1.hxx> + +namespace dbaccess +{ + + typedef ::cppu::ImplHelper1< css::container::XChild > TXChild; + // OTableColumnDescriptor + /** + * provides the properties for description. A descriptor could be used to create a new table column. + */ + class OTableColumnDescriptor : public OColumn + ,public OColumnSettings + ,public ::comphelper::OPropertyArrayUsageHelper < OTableColumnDescriptor > + ,public TXChild + { + css::uno::Reference< css::uno::XInterface > m_xParent; + const bool m_bActAsDescriptor; + + protected: + // <properties> + OUString m_aTypeName; + OUString m_aDescription; + OUString m_aDefaultValue; + OUString m_aAutoIncrementValue; + sal_Int32 m_nType; + sal_Int32 m_nPrecision; + sal_Int32 m_nScale; + sal_Int32 m_nIsNullable; + bool m_bAutoIncrement; + bool m_bRowVersion; + bool m_bCurrency; + // </properties> + + public: + OTableColumnDescriptor( const bool _bActAsDescriptor ) + :OColumn( !_bActAsDescriptor ) + ,m_bActAsDescriptor( _bActAsDescriptor ) + ,m_nType( css::sdbc::DataType::SQLNULL ) + ,m_nPrecision( 0 ) + ,m_nScale( 0 ) + ,m_nIsNullable( css::sdbc::ColumnValue::NULLABLE_UNKNOWN ) + ,m_bAutoIncrement( false ) + ,m_bRowVersion( false ) + ,m_bCurrency( false ) + { + impl_registerProperties(); + } + + DECLARE_XINTERFACE( ) + + // css::lang::XTypeProvider + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // css::container::XChild + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override; + virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override; + + // ::comphelper::OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; + + // ::cppu::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + + private: + void impl_registerProperties(); + }; + + // OTableColumn + class OTableColumn; + typedef ::comphelper::OPropertyArrayUsageHelper < OTableColumn > OTableColumn_PBase; + /** describes a column of a table + */ + class OTableColumn :public OTableColumnDescriptor + ,public OTableColumn_PBase + { + protected: + virtual ~OTableColumn() override; + + public: + OTableColumn(const OUString& _rName); + + // XTypeProvider + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; + }; + + // OQueryColumn + class OQueryColumn; + typedef ::comphelper::OPropertyArrayUsageHelper< OQueryColumn > OQueryColumn_PBase; + /** a column of a Query, with additional information obtained from parsing the query statement + */ + class OQueryColumn :public OTableColumnDescriptor + ,public OQueryColumn_PBase + { + // <properties> + OUString m_sCatalogName; + OUString m_sSchemaName; + OUString m_sTableName; + OUString m_sRealName; + OUString m_sLabel; + // </properties> + + css::uno::Reference< css::beans::XPropertySet > m_xOriginalTableColumn; + + protected: + virtual ~OQueryColumn() override; + + public: + OQueryColumn( + const css::uno::Reference< css::beans::XPropertySet>& _rxParserColumn, + const css::uno::Reference< css::sdbc::XConnection >& _rxConnection, + const OUString &i_sLabel + ); + + // XTypeProvider + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + + // *Property* + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override; + + private: + css::uno::Reference< css::beans::XPropertySet > + impl_determineOriginalTableColumn( + const css::uno::Reference< css::sdbc::XConnection >& _rxConnection + ); + + using ::cppu::OPropertySetHelper::getFastPropertyValue; + }; + + // OColumnWrapper + /** + * describes all properties for a columns of a table. Only the view parts are provided + * directly, all the other parts are derived from a driver implementation + */ + class OColumnWrapper :public OColumn + { + protected: + // definition which is provided by a driver! + css::uno::Reference< css::beans::XPropertySet > + m_xAggregate; + + sal_Int32 m_nColTypeID; + + protected: + OColumnWrapper( const css::uno::Reference< css::beans::XPropertySet >& _rCol, const bool _bNameIsReadOnly ); + virtual ~OColumnWrapper() override; + + public: + virtual void SAL_CALL getFastPropertyValue( + css::uno::Any& rValue, + sal_Int32 nHandle + ) const override; + virtual sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any & rConvertedValue, + css::uno::Any & rOldValue, + sal_Int32 nHandle, + const css::uno::Any& rValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const css::uno::Any& rValue + ) override; + + protected: + OUString impl_getPropertyNameFromHandle( const sal_Int32 _nHandle ) const; + + protected: + using OColumn::getFastPropertyValue; + }; + + // OTableColumnDescriptorWrapper + /** + * provides the properties for description. A descriptor could be used to create a new table column. + */ + class OTableColumnDescriptorWrapper :public OColumnWrapper + ,public OColumnSettings + ,public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnDescriptorWrapper > + { + const bool m_bPureWrap; + const bool m_bIsDescriptor; + + public: + OTableColumnDescriptorWrapper(const css::uno::Reference< css::beans::XPropertySet >& rCol, + const bool _bPureWrap, const bool _bIsDescriptor ); + + // css::lang::XTypeProvider + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // OIdPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const override; + + // cppu::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual void SAL_CALL getFastPropertyValue( + css::uno::Any& rValue, + sal_Int32 nHandle + ) const override; + virtual sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any & rConvertedValue, + css::uno::Any & rOldValue, + sal_Int32 nHandle, + const css::uno::Any& rValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const css::uno::Any& rValue + ) override; + + protected: + using OColumnWrapper::getFastPropertyValue; + }; + + // OTableColumnWrapper + /** + * describes all properties for a columns of a table. Only the view parts are provided + * directly, all the other parts are derived from a driver implementation + */ + class OTableColumnWrapper :public OTableColumnDescriptorWrapper + ,public ::comphelper::OIdPropertyArrayUsageHelper < OTableColumnWrapper > + { + protected: + virtual ~OTableColumnWrapper() override; + + public: + OTableColumnWrapper( const css::uno::Reference< css::beans::XPropertySet >& rCol, + const css::uno::Reference< css::beans::XPropertySet >& rColDefintion, + const bool _bPureWrap ); + + // css::lang::XTypeProvider + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // OIdPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const override; + }; +} +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_DEFINITIONCOLUMN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/definitioncontainer.hxx b/dbaccess/source/core/inc/definitioncontainer.hxx new file mode 100644 index 000000000..98a4c3f14 --- /dev/null +++ b/dbaccess/source/core/inc/definitioncontainer.hxx @@ -0,0 +1,325 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_DEFINITIONCONTAINER_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_DEFINITIONCONTAINER_HXX + +#include <sal/config.h> + +#include <map> +#include <vector> + +#include <cppuhelper/implbase7.hxx> +#include <osl/mutex.hxx> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/beans/XVetoableChangeListener.hpp> +#include <com/sun/star/container/XContainerApproveBroadcaster.hpp> +#include "ContentHelper.hxx" +#include "containerapprove.hxx" +#include <comphelper/uno3.hxx> + +namespace dbaccess +{ + +class ODefinitionContainer_Impl : public OContentHelper_Impl +{ +public: + typedef std::map< OUString, TContentPtr > NamedDefinitions; + typedef NamedDefinitions::iterator iterator; + typedef NamedDefinitions::const_iterator const_iterator; + +private: + NamedDefinitions m_aDefinitions; + +public: + size_t size() const { return m_aDefinitions.size(); } + + const_iterator begin() const { return m_aDefinitions.begin(); } + const_iterator end() const { return m_aDefinitions.end(); } + + const_iterator find( const OUString& _rName ) const { return m_aDefinitions.find( _rName ); } + const_iterator find( const TContentPtr& _pDefinition ) const; + + void erase( const OUString& _rName ) { m_aDefinitions.erase( _rName ); } + void erase( const TContentPtr& _pDefinition ); + + void insert( const OUString& _rName, TContentPtr _pDefinition ) + { + m_aDefinitions.emplace( _rName, _pDefinition ); + } + +private: + iterator find( const TContentPtr& _pDefinition ); + // (for the moment, this is private. Make it public if needed. If really needed.) +}; + +// ODefinitionContainer - base class of collections of database definition +// documents +typedef ::cppu::ImplHelper7 < css::container::XIndexAccess + , css::container::XNameContainer + , css::container::XEnumerationAccess + , css::container::XContainer + , css::container::XContainerApproveBroadcaster + , css::beans::XPropertyChangeListener + , css::beans::XVetoableChangeListener + > ODefinitionContainer_Base; + +class ODefinitionContainer + :public OContentHelper + ,public ODefinitionContainer_Base +{ +protected: + typedef std::map< OUString, css::uno::WeakReference< css::ucb::XContent > > Documents; + + enum ContainerOperation + { + E_REPLACED, + E_REMOVED, + E_INSERTED + }; + + enum ListenerType + { + ApproveListeners, + ContainerListemers + }; + +private: + PContainerApprove m_pElementApproval; + +protected: + // we can't just hold a vector of XContentRefs, as after initialization they're all empty + // cause we load them only on access + std::vector<Documents::iterator> + m_aDocuments; // for an efficient index access + Documents m_aDocumentMap; // for an efficient name access + + ::comphelper::OInterfaceContainerHelper2 + m_aApproveListeners; + ::comphelper::OInterfaceContainerHelper2 + m_aContainerListeners; + + bool m_bInPropertyChange; + bool m_bCheckSlash; + +protected: + /** Additionally to our own approvals which new elements must pass, derived classes + can specify an additional approval instance here. + + Every time a new element is inserted into the container (or an element is replaced + with a new one), this new element must pass our own internal approval, plus the approval + given here. + */ + void setElementApproval( PContainerApprove _pElementApproval ) { m_pElementApproval = _pElementApproval; } + const PContainerApprove& getElementApproval() const { return m_pElementApproval; } + +protected: + virtual ~ODefinitionContainer() override; + + const ODefinitionContainer_Impl& getDefinitions() const + { + return dynamic_cast< const ODefinitionContainer_Impl& >( *m_pImpl ); + } + + ODefinitionContainer_Impl& getDefinitions() + { + return dynamic_cast< ODefinitionContainer_Impl& >( *m_pImpl ); + } +public: + /** constructs the container. + */ + ODefinitionContainer( + const css::uno::Reference< css::uno::XComponentContext >& _xORB + , const css::uno::Reference< css::uno::XInterface >& _xParentContainer + , const TContentPtr& _pImpl + , bool _bCheckSlash = true + ); + +// css::uno::XInterface + DECLARE_XINTERFACE( ) + + virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override; + virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override; + +// css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + +// css::container::XElementAccess + virtual css::uno::Type SAL_CALL getElementType( ) override; + virtual sal_Bool SAL_CALL hasElements( ) override; + +// css::container::XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) override; + +// css::container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount( ) override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 _nIndex ) override; + +// css::container::XNameContainer + virtual void SAL_CALL insertByName( const OUString& _rName, const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& _rName ) override; + +// css::container::XNameReplace + virtual void SAL_CALL replaceByName( const OUString& _rName, const css::uno::Any& aElement ) override; + +// css::container::XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + +// css::container::XContainer + virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + + // XContainerApproveBroadcaster + virtual void SAL_CALL addContainerApproveListener( const css::uno::Reference< css::container::XContainerApproveListener >& Listener ) override; + virtual void SAL_CALL removeContainerApproveListener( const css::uno::Reference< css::container::XContainerApproveListener >& Listener ) override; + +// css::lang::XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XPropertyChangeListener + virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override; + // XVetoableChangeListener + virtual void SAL_CALL vetoableChange( const css::beans::PropertyChangeEvent& aEvent ) override; + +protected: + // helper + virtual void SAL_CALL disposing() override; + + /** create an object from its persistent data within the configuration. To be overwritten by derived classes. + @param _rName the name the object has within the container + @return the newly created object or an empty reference if something went wrong + */ + virtual css::uno::Reference< css::ucb::XContent > createObject( + const OUString& _rName) = 0; + + /** get the object specified by the given name. If desired, the object will be read if not already done so.<BR> + @param _rName the object name + @param _bReadIfNecessary if sal_True, the object will be created if necessary + @return the property set interface of the object. Usually the return value is not NULL, but + if so, then the object could not be read from the configuration + @throws NoSuchElementException if there is no object with the given name. + @see createObject + */ + css::uno::Reference< css::ucb::XContent > + implGetByName(const OUString& _rName, bool _bCreateIfNecessary); + + /** quickly checks if there already is an element with a given name. No access to the configuration occurs, i.e. + if there is such an object which is not already loaded, it won't be loaded now. + @param _rName the object name to check + @return sal_True if there already exists such an object + */ + virtual bool checkExistence(const OUString& _rName); + + /** append a new object to the container. No plausibility checks are done, e.g. if the object is non-NULL or + if the name is already used by another object or anything like this. This method is for derived classes + which may support different methods to create and/or append objects, and don't want to deal with the + internal structures of this class.<BR> + The old component will not be disposed, this is the callers responsibility, too. + @param _rName the name of the new object + @param _rxNewObject the new object (not surprising, is it ?) + @see createConfigKey + @see implReplace + @see implRemove + */ + void implAppend( + const OUString& _rName, + const css::uno::Reference< css::ucb::XContent >& _rxNewObject + ); + + /** remove all references to an object from the container. No plausibility checks are done, e.g. whether + or not there exists an object with the given name. This is the responsibility of the caller.<BR> + Additionally the node for the given object will be removed from the registry (including all sub nodes).<BR> + The old component will not be disposed, this is the callers responsibility, too. + @param _rName the objects name + @see implReplace + @see implAppend + */ + void implRemove(const OUString& _rName); + + /** remove an object in the container. No plausibility checks are done, e.g. whether + or not there exists an object with the given name or the object is non-NULL. This is the responsibility of the caller.<BR> + Additionally all object-related information within the registry will be deleted. The new object config node, + where the caller may want to store the new objects information, is returned.<BR> + The old component will not be disposed, this is the callers responsibility, too. + @param _rName the objects name + @param _rxNewObject the new object + @param _rNewObjectNode the configuration node where the new object may be stored + @see implAppend + @see implRemove + */ + void implReplace( + const OUString& _rName, + const css::uno::Reference< css::ucb::XContent >& _rxNewObject + ); + + /** notifies our container/approve listeners + */ + void notifyByName( + ::osl::ResettableMutexGuard& _rGuard, + const OUString& _rName, + const css::uno::Reference< css::ucb::XContent >& _xNewElement, + const css::uno::Reference< css::ucb::XContent >& xOldElement, + ContainerOperation _eOperation, + ListenerType _eType + ); + + operator css::uno::Reference< css::uno::XInterface > () const + { + return const_cast< XContainer* >( static_cast< const XContainer* >( this ) ); + } + +private: + void addObjectListener(const css::uno::Reference< css::ucb::XContent >& _xNewObject); + void removeObjectListener(const css::uno::Reference< css::ucb::XContent >& _xNewObject); + + /** approve that the object given may be inserted into the container. + Should be overridden by derived classes, + the default implementation just checks the object to be non-void. + + @throws IllegalArgumentException + if the name or the object are invalid + @throws ElementExistException + if the object already exists in the container, or another object with the same name + already exists + @throws WrappedTargetException + if another error occurs which prevents insertion of the object into the container + */ + void approveNewObject( + const OUString& _sName, + const css::uno::Reference< css::ucb::XContent >& _rxObject + ) const; + + bool impl_haveAnyListeners_nothrow() const + { + return ( m_aContainerListeners.getLength() > 0 ) || ( m_aApproveListeners.getLength() > 0 ); + } +}; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_DEFINITIONCONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/documentevents.hxx b/dbaccess/source/core/inc/documentevents.hxx new file mode 100644 index 000000000..9a04074a3 --- /dev/null +++ b/dbaccess/source/core/inc/documentevents.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_DOCUMENTEVENTS_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_DOCUMENTEVENTS_HXX + +#include <com/sun/star/container/XNameReplace.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> + +#include <cppuhelper/implbase.hxx> + +#include <memory> +#include <map> + +namespace dbaccess +{ + + typedef std::map< OUString, css::uno::Sequence< css::beans::PropertyValue > > + DocumentEventsData; + + // DocumentEvents + struct DocumentEvents_Data; + + typedef ::cppu::WeakImplHelper< css::container::XNameReplace + > DocumentEvents_Base; + + class DocumentEvents :public DocumentEvents_Base + { + public: + DocumentEvents( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData ); + virtual ~DocumentEvents() override; + + DocumentEvents(const DocumentEvents&) = delete; + const DocumentEvents& operator=(const DocumentEvents&) = delete; + + static bool needsSynchronousNotification( const OUString& _rEventName ); + + // XInterface + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType( ) override; + virtual sal_Bool SAL_CALL hasElements( ) override; + + private: + std::unique_ptr< DocumentEvents_Data > m_pData; + }; + +} // namespace dbaccess + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/migrwarndlg.hxx b/dbaccess/source/core/inc/migrwarndlg.hxx new file mode 100644 index 000000000..e01c2b9f0 --- /dev/null +++ b/dbaccess/source/core/inc/migrwarndlg.hxx @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_WARNDLG_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_WARNDLG_HXX + +#include <vcl/weld.hxx> + +namespace dbaccess +{ +class MigrationWarnDialog : public weld::MessageDialogController +{ + std::unique_ptr<weld::Button> m_xLater; + +public: + MigrationWarnDialog(weld::Window* pParent); +}; +} + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_WARNDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/object.hxx b/dbaccess/source/core/inc/object.hxx new file mode 100644 index 000000000..a6f085609 --- /dev/null +++ b/dbaccess/source/core/inc/object.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_OBJECT_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_OBJECT_HXX + +enum ObjectType +{ + dbaTable, + dbaQuery, + dbaForm, + dbaReport +}; + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_OBJECT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/objectnameapproval.hxx b/dbaccess/source/core/inc/objectnameapproval.hxx new file mode 100644 index 000000000..6e0ce4577 --- /dev/null +++ b/dbaccess/source/core/inc/objectnameapproval.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_OBJECTNAMEAPPROVAL_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_OBJECTNAMEAPPROVAL_HXX + +#include <memory> +#include "containerapprove.hxx" + +#include <com/sun/star/sdbc/XConnection.hpp> + +namespace dbaccess +{ + + // ObjectNameApproval + struct ObjectNameApproval_Impl; + /** implementation of the IContainerApprove interface which approves + elements for insertion into a query or tables container. + + The only check done by this instance is whether the query name is + not already used, taking into account that in some databases, queries + and tables share the same namespace. + + The class is not thread-safe. + */ + class ObjectNameApproval : public IContainerApprove + { + std::unique_ptr< ObjectNameApproval_Impl > m_pImpl; + + public: + enum ObjectType + { + TypeQuery, + TypeTable + }; + + public: + /** constructs the instance + + @param _rxConnection + the connection relative to which the names should be checked. This connection + will be held weak. In case it is closed, subsequent calls to this instance's + methods throw a DisposedException. + @param _eType + specifies which type of objects is to be approved with this instance + */ + ObjectNameApproval( + const css::uno::Reference< css::sdbc::XConnection >& _rxConnection, + ObjectType _eType + ); + virtual ~ObjectNameApproval() override; + + // IContainerApprove + virtual void approveElement( const OUString& _rName ) override; + + }; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_OBJECTNAMEAPPROVAL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/preparedstatement.hxx b/dbaccess/source/core/inc/preparedstatement.hxx new file mode 100644 index 000000000..d8e0f5b6a --- /dev/null +++ b/dbaccess/source/core/inc/preparedstatement.hxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_PREPAREDSTATEMENT_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_PREPAREDSTATEMENT_HXX + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/sdbc/XPreparedStatement.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/sdbc/XParameters.hpp> +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#include "statement.hxx" +#include "column.hxx" + +namespace dbaccess +{ + + // OPreparedStatement + + class OPreparedStatement : public OStatementBase, + public css::sdbc::XPreparedStatement, + public css::sdbc::XParameters, + public css::sdbc::XResultSetMetaDataSupplier, + public css::sdbcx::XColumnsSupplier, + public css::lang::XServiceInfo + { + std::unique_ptr<OColumns> m_pColumns; + css::uno::Reference< css::sdbc::XParameters > m_xAggregateAsParameters; + + public: + OPreparedStatement(const css::uno::Reference< css::sdbc::XConnection > & _xConn, + const css::uno::Reference< css::uno::XInterface > & _xStatement); + virtual ~OPreparedStatement() override; + + // css::lang::XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::uno::XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + + // css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + + // css::sdbc::XPreparedStatement + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( ) override; + virtual sal_Int32 SAL_CALL executeUpdate( ) override; + virtual sal_Bool SAL_CALL execute( ) override; + virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override; + + // css::sdbcx::XColumnsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns( ) override; + + // css::sdbc::XResultSetMetaDataSupplier + virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override; + + // css::sdbc::XParameters + virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) override; + virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName ) override; + virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) override; + virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) override; + virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) override; + virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) override; + virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) override; + virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) override; + virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) override; + virtual void SAL_CALL setString( sal_Int32 parameterIndex, const OUString& x ) override; + virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const css::uno::Sequence< sal_Int8 >& x ) override; + virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const css::util::Date& x ) override; + virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const css::util::Time& x ) override; + virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const css::util::DateTime& x ) override; + virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; + virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; + virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const css::uno::Any& x ) override; + virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const css::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) override; + virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XRef >& x ) override; + virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XBlob >& x ) override; + virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XClob >& x ) override; + virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XArray >& x ) override; + virtual void SAL_CALL clearParameters( ) override; + }; +} +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_PREPAREDSTATEMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/querycomposer.hxx b/dbaccess/source/core/inc/querycomposer.hxx new file mode 100644 index 000000000..1e5ef2ab0 --- /dev/null +++ b/dbaccess/source/core/inc/querycomposer.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_QUERYCOMPOSER_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_QUERYCOMPOSER_HXX + +#include <com/sun/star/sdb/XSQLQueryComposer.hpp> +#include <com/sun/star/sdb/XParametersSupplier.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase5.hxx> +#include <cppuhelper/basemutex.hxx> +#include <connectivity/sqliterator.hxx> +#include <apitools.hxx> +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> + + +namespace dbaccess +{ + typedef ::cppu::ImplHelper5< css::sdb::XSQLQueryComposer, + css::sdb::XParametersSupplier, + css::sdbcx::XTablesSupplier, + css::sdbcx::XColumnsSupplier, + css::lang::XServiceInfo > OQueryComposer_BASE; + + class OQueryComposer : public ::cppu::BaseMutex, + public OSubComponent, + public OQueryComposer_BASE + { + std::vector< OUString> m_aFilters; + std::vector< OUString> m_aOrders; + OUString m_sOrgFilter; + OUString m_sOrgOrder; + css::uno::Reference< css::sdb::XSingleSelectQueryComposer> m_xComposer; + css::uno::Reference< css::sdb::XSingleSelectQueryComposer> m_xComposerHelper; + + protected: + virtual void SAL_CALL disposing() override; + virtual ~OQueryComposer() override; + public: + + OQueryComposer( const css::uno::Reference< css::sdbc::XConnection>& _xConnection ); + + // css::lang::XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // css::uno::XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + // XSQLQueryComposer + virtual OUString SAL_CALL getQuery( ) override; + virtual void SAL_CALL setQuery( const OUString& command ) override; + virtual OUString SAL_CALL getComposedQuery( ) override; + virtual OUString SAL_CALL getFilter( ) override; + virtual css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > SAL_CALL getStructuredFilter( ) override; + virtual OUString SAL_CALL getOrder( ) override; + virtual void SAL_CALL appendFilterByColumn( const css::uno::Reference< css::beans::XPropertySet >& column ) override; + virtual void SAL_CALL appendOrderByColumn( const css::uno::Reference< css::beans::XPropertySet >& column, sal_Bool ascending ) override; + virtual void SAL_CALL setFilter( const OUString& filter ) override; + virtual void SAL_CALL setOrder( const OUString& order ) override; + // XTablesSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables( ) override; + // XColumnsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns( ) override; + // XParametersSupplier + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getParameters( ) override; + }; +} +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_QUERYCOMPOSER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/querycontainer.hxx b/dbaccess/source/core/inc/querycontainer.hxx new file mode 100644 index 000000000..b6797aa91 --- /dev/null +++ b/dbaccess/source/core/inc/querycontainer.hxx @@ -0,0 +1,167 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_QUERYCONTAINER_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_QUERYCONTAINER_HXX + +#include <cppuhelper/implbase5.hxx> +#include <connectivity/CommonTools.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> +#include <com/sun/star/sdbcx/XAppend.hpp> +#include <com/sun/star/sdbcx/XDrop.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/container/XContainerApproveListener.hpp> + +#include "definitioncontainer.hxx" + +namespace dbtools +{ + class WarningsContainer; +} + +namespace dbaccess +{ + + typedef ::cppu::ImplHelper5 < css::container::XContainerListener + , css::container::XContainerApproveListener + , css::sdbcx::XDataDescriptorFactory + , css::sdbcx::XAppend + , css::sdbcx::XDrop + > OQueryContainer_Base; + + // OQueryContainer + class OQueryContainer : public ODefinitionContainer + , public OQueryContainer_Base + { + private: + ::dbtools::WarningsContainer* m_pWarnings; + css::uno::Reference< css::container::XNameContainer > + m_xCommandDefinitions; + css::uno::Reference< css::sdbc::XConnection > + m_xConnection; + // possible actions on our "aggregate" + enum class AggregateAction { NONE, Inserting }; + AggregateAction m_eDoingCurrently; + + /** a class which automatically resets m_eDoingCurrently in its destructor + */ + class OAutoActionReset; // just for the following friend declaration + friend class OAutoActionReset; + class OAutoActionReset + { + OQueryContainer& m_rActor; + public: + OAutoActionReset(OQueryContainer& _rActor) : m_rActor(_rActor) { } + ~OAutoActionReset() { m_rActor.m_eDoingCurrently = AggregateAction::NONE; } + }; + + // ODefinitionContainer + virtual css::uno::Reference< css::ucb::XContent > createObject( const OUString& _rName) override; + virtual bool checkExistence(const OUString& _rName) override; + + // helper + virtual void SAL_CALL disposing() override; + virtual ~OQueryContainer() override; + + /** ctor of the container. The parent has to support the <type scope="css::sdbc">XConnection</type> + interface.<BR> + + @param _pWarnings + specifies a warnings container (May be <NULL/>) + + Any errors which occur during the lifetime of the query container, + which cannot be reported as exceptions (for instance in methods where throwing an SQLException is + not allowed) will be appended to this container.</p> + <p>The caller is responsible for ensuring the lifetime of the object pointed to by this parameter. + */ + OQueryContainer( + const css::uno::Reference< css::container::XNameContainer >& _rxCommandDefinitions, + const css::uno::Reference< css::sdbc::XConnection >& _rxConn, + const css::uno::Reference< css::uno::XComponentContext >& _rxORB, + ::dbtools::WarningsContainer* _pWarnings + ); + + void init(); + + public: + static rtl::Reference<OQueryContainer> create( + const css::uno::Reference< css::container::XNameContainer >& _rxCommandDefinitions, + const css::uno::Reference< css::sdbc::XConnection >& _rxConn, + const css::uno::Reference< css::uno::XComponentContext >& _rxORB, + ::dbtools::WarningsContainer* _pWarnings + ); + + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + DECLARE_SERVICE_INFO(); + + // css::container::XContainerListener + virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override; + + // XContainerApproveListener + virtual css::uno::Reference< css::util::XVeto > SAL_CALL approveInsertElement( const css::container::ContainerEvent& Event ) override; + virtual css::uno::Reference< css::util::XVeto > SAL_CALL approveReplaceElement( const css::container::ContainerEvent& Event ) override; + virtual css::uno::Reference< css::util::XVeto > SAL_CALL approveRemoveElement( const css::container::ContainerEvent& Event ) override; + + // css::lang::XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // css::sdbcx::XDataDescriptorFactory + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor( ) override; + + // css::sdbcx::XAppend + virtual void SAL_CALL appendByDescriptor( const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; + + // css::sdbcx::XDrop + virtual void SAL_CALL dropByName( const OUString& elementName ) override; + virtual void SAL_CALL dropByIndex( sal_Int32 index ) override; + + // css::container::XElementAccess + virtual sal_Bool SAL_CALL hasElements( ) override; + // css::container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount( ) override; + // css::container::XNameAccess + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; + + private: + // OContentHelper overridables + virtual OUString determineContentType() const override; + + // helper + /** create a query object wrapping a CommandDefinition given by name. To retrieve the object, the CommandDescription + container will be asked for the given name.<BR> + The returned object is acquired once. + */ + css::uno::Reference< css::ucb::XContent > implCreateWrapper(const OUString& _rName); + /// create a query object wrapping a CommandDefinition. The returned object is acquired once. + css::uno::Reference< css::ucb::XContent > implCreateWrapper(const css::uno::Reference< css::ucb::XContent >& _rxCommandDesc); + + }; +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_QUERYCONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx b/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx new file mode 100644 index 000000000..c5dadce45 --- /dev/null +++ b/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_RECOVERY_DBDOCRECOVERY_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_RECOVERY_DBDOCRECOVERY_HXX + +#include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <vector> +#include <memory> + +namespace dbaccess +{ + + // DatabaseDocumentRecovery + struct DatabaseDocumentRecovery_Data; + class DatabaseDocumentRecovery + { + public: + DatabaseDocumentRecovery( + const css::uno::Reference< css::uno::XComponentContext >& i_rContext + ); + ~DatabaseDocumentRecovery(); + + /** saves the modified sub components of the given controller(s) to the "recovery" sub storage of the document + storage. + + @throws css::uno::Exception + in case of an error. + */ + void saveModifiedSubComponents( + const css::uno::Reference< css::embed::XStorage >& i_rTargetStorage, + const std::vector< css::uno::Reference< css::frame::XController > >& i_rControllers + ); + + /** recovery sub components from the given document storage, if applicable + + If the given document storage does not contain a recovery folder, the method silently returns. + + @throws css::uno::Exception + in case of an error. + */ + void recoverSubDocuments( + const css::uno::Reference< css::embed::XStorage >& i_rDocumentStorage, + const css::uno::Reference< css::frame::XController >& i_rTargetController + ); + + private: + const std::unique_ptr< DatabaseDocumentRecovery_Data > m_pData; + }; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_RECOVERY_DBDOCRECOVERY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/sdbcoretools.hxx b/dbaccess/source/core/inc/sdbcoretools.hxx new file mode 100644 index 000000000..41097c676 --- /dev/null +++ b/dbaccess/source/core/inc/sdbcoretools.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_SDBCORETOOLS_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_SDBCORETOOLS_HXX + +#include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +namespace dbaccess +{ + + void notifyDataSourceModified(const css::uno::Reference< css::uno::XInterface >& _rxObject); + + css::uno::Reference< css::uno::XInterface > + getDataSource( const css::uno::Reference< css::uno::XInterface >& _rxDependentObject ); + + /** retrieves a to-be-displayed string for a given caught exception; + */ + OUString extractExceptionMessage( const css::uno::Reference< css::uno::XComponentContext >& _rContext, const css::uno::Any& _rError ); + + namespace tools + { + namespace stor + { + bool storageIsWritable_nothrow( + const css::uno::Reference< css::embed::XStorage >& _rxStorage + ); + + /// commits a given storage if it's not readonly + bool commitStorageIfWriteable( + const css::uno::Reference< css::embed::XStorage >& _rxStorage + ); + } + + } + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_SDBCORETOOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/statement.hxx b/dbaccess/source/core/inc/statement.hxx new file mode 100644 index 000000000..2024bb0de --- /dev/null +++ b/dbaccess/source/core/inc/statement.hxx @@ -0,0 +1,182 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_STATEMENT_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_STATEMENT_HXX + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/sdbc/XStatement.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/util/XCancellable.hpp> +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#include <com/sun/star/sdbc/XCloseable.hpp> +#include <com/sun/star/sdbc/XMultipleResults.hpp> +#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp> +#include <com/sun/star/sdbc/XBatchExecution.hpp> +#include <com/sun/star/sdbc/XGeneratedResultSet.hpp> +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#include <cppuhelper/propshlp.hxx> +#include <comphelper/proparrhlp.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/implbase3.hxx> +#include <apitools.hxx> + + +// OStatementBase + +class OStatementBase : public cppu::BaseMutex, + public OSubComponent, + public ::cppu::OPropertySetHelper, + public ::comphelper::OPropertyArrayUsageHelper < OStatementBase >, + public css::util::XCancellable, + public css::sdbc::XWarningsSupplier, + public css::sdbc::XPreparedBatchExecution, + public css::sdbc::XMultipleResults, + public css::sdbc::XCloseable, + public css::sdbc::XGeneratedResultSet +{ +protected: + ::osl::Mutex m_aCancelMutex; + + css::uno::WeakReferenceHelper m_aResultSet; + css::uno::Reference< css::beans::XPropertySet > m_xAggregateAsSet; + css::uno::Reference< css::util::XCancellable > m_xAggregateAsCancellable; + bool m_bUseBookmarks; + bool m_bEscapeProcessing; + + virtual ~OStatementBase() override; + +public: + OStatementBase(const css::uno::Reference< css::sdbc::XConnection > & _xConn, + const css::uno::Reference< css::uno::XInterface > & _xStatement); + + +// css::lang::XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + +// css::uno::XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + +// OComponentHelper + virtual void SAL_CALL disposing() override; + +// css::beans::XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + +// comphelper::OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override; + +// cppu::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any & rConvertedValue, + css::uno::Any & rOldValue, + sal_Int32 nHandle, + const css::uno::Any& rValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const css::uno::Any& rValue + ) override; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override; + +// css::sdbc::XWarningsSupplier + virtual css::uno::Any SAL_CALL getWarnings( ) override; + virtual void SAL_CALL clearWarnings( ) override; + +// css::util::XCancellable + virtual void SAL_CALL cancel( ) override; + +// css::sdbc::XCloseable + virtual void SAL_CALL close( ) override; + +// css::sdbc::XMultipleResults + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( ) override; + virtual sal_Int32 SAL_CALL getUpdateCount( ) override; + virtual sal_Bool SAL_CALL getMoreResults( ) override; + +// css::sdbc::XPreparedBatchExecution + virtual void SAL_CALL addBatch( ) override; + virtual void SAL_CALL clearBatch( ) override; + virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) override; +// css::sdbc::XGeneratedResultSet + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getGeneratedValues( ) override; + +// Helper + void disposeResultSet(); + +protected: + using ::cppu::OPropertySetHelper::getFastPropertyValue; +}; + + +// OStatement + +typedef ::cppu::ImplHelper3 < css::sdbc::XStatement + , css::lang::XServiceInfo + , css::sdbc::XBatchExecution + > OStatement_IFACE; +class OStatement :public OStatementBase + ,public OStatement_IFACE +{ +private: + css::uno::Reference< css::sdbc::XStatement > m_xAggregateStatement; + css::uno::Reference< css::sdb::XSingleSelectQueryComposer > m_xComposer; + bool m_bAttemptedComposerCreation; + +public: + OStatement(const css::uno::Reference< css::sdbc::XConnection > & _xConn, + const css::uno::Reference< css::uno::XInterface > & _xStatement); + + DECLARE_XINTERFACE() + DECLARE_XTYPEPROVIDER() + +// css::lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + +// css::sdbc::XStatement + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) override; + virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) override; + virtual sal_Bool SAL_CALL execute( const OUString& sql ) override; + virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + + // XBatchExecution + virtual void SAL_CALL addBatch( const OUString& sql ) override; + virtual void SAL_CALL clearBatch( ) override; + virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) override; + + using OStatementBase::addBatch; + +private: + /** does escape processing for the given SQL command, if the our EscapeProcessing + property allows so. + */ + OUString impl_doEscapeProcessing_nothrow( const OUString& _rSQL ) const; + bool impl_ensureComposer_nothrow() const; +}; + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_STATEMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/table.hxx b/dbaccess/source/core/inc/table.hxx new file mode 100644 index 000000000..ec851f3b5 --- /dev/null +++ b/dbaccess/source/core/inc/table.hxx @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_TABLE_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_TABLE_HXX + +#include <com/sun/star/sdbc/XConnection.hpp> + +#include "datasettings.hxx" +#include "column.hxx" +#include <connectivity/CommonTools.hxx> +#include <connectivity/TTableHelper.hxx> +#include <comphelper/IdPropArrayHelper.hxx> + +namespace dbaccess +{ + + // OTables + class ODBTable; + class OContainerMediator; + typedef ::comphelper::OIdPropertyArrayUsageHelper< ODBTable > ODBTable_PROP; + typedef ::connectivity::OTableHelper OTable_Base; + + class ODBTable :public ODataSettings_Base + ,public ODBTable_PROP + ,public OTable_Base + ,public IColumnFactory + { + private: + ::rtl::Reference< OContainerMediator > m_pColumnMediator; + + protected: + css::uno::Reference< css::container::XNameAccess > m_xColumnDefinitions; + css::uno::Reference< css::container::XNameAccess > m_xDriverColumns; + + // <properties> + sal_Int32 m_nPrivileges; + // </properties> + + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const override; + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + // IColumnFactory + virtual OColumn* createColumn(const OUString& _rName) const override; + virtual css::uno::Reference< css::beans::XPropertySet > createColumnDescriptor() override; + virtual void columnAppended( const css::uno::Reference< css::beans::XPropertySet >& _rxSourceDescriptor ) override; + virtual void columnDropped(const OUString& _sName) override; + + /** creates the column collection for the table + @param _rNames + The column names. + */ + virtual ::connectivity::sdbcx::OCollection* createColumns(const ::std::vector< OUString>& _rNames) override; + + /** creates the key collection for the table + @param _rNames + The key names. + */ + virtual ::connectivity::sdbcx::OCollection* createKeys(const ::std::vector< OUString>& _rNames) override; + + /** creates the index collection for the table + @param _rNames + The index names. + */ + virtual ::connectivity::sdbcx::OCollection* createIndexes(const ::std::vector< OUString>& _rNames) override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + public: + /** constructs a wrapper supporting the com.sun.star.sdb.Table service.<BR> + @param _rxConn the connection the table belongs to + @param _rxTable the table from the driver can be null + @param _rCatalog the name of the catalog the table belongs to. May be empty. + @param _rSchema the name of the schema the table belongs to. May be empty. + @param _rName the name of the table + @param _rType the type of the table, as supplied by the driver + @param _rDesc the description of the table, as supplied by the driver + @throws css::sdbc::SQLException + */ + ODBTable(connectivity::sdbcx::OCollection* _pTables + ,const css::uno::Reference< css::sdbc::XConnection >& _rxConn + ,const OUString& _rCatalog + , const OUString& _rSchema + , const OUString& _rName + ,const OUString& _rType + , const OUString& _rDesc + ,const css::uno::Reference< css::container::XNameAccess >& _rxColumnDefinitions); + + /// @throws css::sdbc::SQLException + ODBTable(connectivity::sdbcx::OCollection* _pTables + ,const css::uno::Reference< css::sdbc::XConnection >& _rxConn); + virtual ~ODBTable() override; + + // ODescriptor + virtual void construct() override; + + //XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + static css::uno::Sequence< sal_Int8 > getUnoTunnelId(); + + // css::lang::XServiceInfo + DECLARE_SERVICE_INFO(); + + // css::beans::XPropertySet + virtual void SAL_CALL getFastPropertyValue(css::uno::Any& rValue, sal_Int32 nHandle) const override; + + // css::sdbcx::XRename, + virtual void SAL_CALL rename( const OUString& _rNewName ) override; + + // css::sdbcx::XAlterTable, + virtual void SAL_CALL alterColumnByName( const OUString& _rName, const css::uno::Reference< css::beans::XPropertySet >& _rxDescriptor ) override; + + // css::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; + + private: + using OTable_Base::createArrayHelper; + using OTable_Base::getFastPropertyValue; + }; +} +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_TABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/tablecontainer.hxx b/dbaccess/source/core/inc/tablecontainer.hxx new file mode 100644 index 000000000..d2a70af2b --- /dev/null +++ b/dbaccess/source/core/inc/tablecontainer.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_TABLECONTAINER_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_TABLECONTAINER_HXX + +#include <sal/config.h> + +#include <atomic> +#include <cstddef> + +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include "FilteredContainer.hxx" +#include "RefreshListener.hxx" + +namespace dbaccess +{ + // OTableContainer + class OContainerMediator; + + class OTableContainer : public OFilteredContainer, + public ::cppu::ImplHelper1< css::container::XContainerListener> + { + css::uno::Reference< css::container::XNameContainer > m_xTableDefinitions; + ::rtl::Reference< OContainerMediator > m_pTableMediator; + + // OFilteredContainer + virtual void addMasterContainerListener() override; + virtual void removeMasterContainerListener() override; + virtual OUString getTableTypeRestriction() const override; + + // ::connectivity::sdbcx::OCollection + virtual connectivity::sdbcx::ObjectType createObject(const OUString& _rName) override; + virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; + virtual connectivity::sdbcx::ObjectType appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; + virtual void dropObject(sal_Int32 _nPos, const OUString& _sElementName) override; + + virtual void disposing() override; + + // css::lang::XServiceInfo + DECLARE_SERVICE_INFO(); + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + // XContainerListener + virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override; + + public: + virtual void SAL_CALL acquire() throw() override { OFilteredContainer::acquire();} + virtual void SAL_CALL release() throw() override { OFilteredContainer::release();} + + /** ctor of the container. The parent has to support the <type scope="css::sdbc">XConnection</type> + interface.<BR> + @param _rParent the object which acts as parent for the container. + all refcounting is rerouted to this object + @param _rMutex the access safety object of the parent + @param _rTableFilter restricts the visible tables by name + @param _rTableTypeFilter restricts the visible tables by type + @see construct + */ + OTableContainer( ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const css::uno::Reference< css::sdbc::XConnection >& _xCon, + bool _bCase, + const css::uno::Reference< css::container::XNameContainer >& _xTableDefinitions, + IRefreshListener* _pRefreshListener, + std::atomic<std::size_t>& _nInAppend + ); + + virtual ~OTableContainer() override; + }; +} +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_TABLECONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/veto.hxx b/dbaccess/source/core/inc/veto.hxx new file mode 100644 index 000000000..63a0748b2 --- /dev/null +++ b/dbaccess/source/core/inc/veto.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_VETO_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_VETO_HXX + +#include <com/sun/star/util/XVeto.hpp> + +#include <cppuhelper/implbase.hxx> + +namespace dbaccess +{ + + // Veto + typedef ::cppu::WeakImplHelper< css::util::XVeto + > Veto_Base; + /** implements css::util::XVeto + */ + class Veto : public Veto_Base + { + private: + const css::uno::Any m_aDetails; + + public: + Veto( const css::uno::Any& _rDetails ); + + virtual OUString SAL_CALL getReason() override; + virtual css::uno::Any SAL_CALL getDetails() override; + + protected: + virtual ~Veto() override; + + private: + Veto( const Veto& ) = delete; + Veto& operator=( const Veto& ) = delete; + }; + +} // namespace dbaccess + +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_VETO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dbaccess/source/core/inc/viewcontainer.hxx b/dbaccess/source/core/inc/viewcontainer.hxx new file mode 100644 index 000000000..12d7f7480 --- /dev/null +++ b/dbaccess/source/core/inc/viewcontainer.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DBACCESS_SOURCE_CORE_INC_VIEWCONTAINER_HXX +#define INCLUDED_DBACCESS_SOURCE_CORE_INC_VIEWCONTAINER_HXX + +#include <sal/config.h> + +#include <atomic> +#include <cstddef> + +#include <cppuhelper/implbase1.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XContainerListener.hpp> + +#include "FilteredContainer.hxx" + +namespace dbtools +{ + class WarningsContainer; +} + +namespace dbaccess +{ + // OViewContainer + class OViewContainer : public OFilteredContainer, + public ::cppu::ImplHelper1< css::container::XContainerListener> + { + public: + /** ctor of the container. The parent has to support the <type scope="css::sdbc">XConnection</type> + interface.<BR> + @param _rParent the object which acts as parent for the container. + all refcounting is rerouted to this object + @param _rMutex the access safety object of the parent + @param _rTableFilter restricts the visible tables by name + @param _rTableTypeFilter restricts the visible tables by type + @see construct + */ + OViewContainer( ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const css::uno::Reference< css::sdbc::XConnection >& _xCon, + bool _bCase, + IRefreshListener* _pRefreshListener, + std::atomic<std::size_t>& _nInAppend + ); + + virtual ~OViewContainer() override; + + protected: + // OFilteredContainer overridables + virtual OUString getTableTypeRestriction() const override; + + private: + virtual void SAL_CALL acquire() throw() override { OFilteredContainer::acquire();} + virtual void SAL_CALL release() throw() override { OFilteredContainer::release();} + // css::lang::XServiceInfo + DECLARE_SERVICE_INFO(); + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + // XContainerListener + virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override; + + // ::connectivity::sdbcx::OCollection + virtual ::connectivity::sdbcx::ObjectType createObject(const OUString& _rName) override; + virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; + virtual connectivity::sdbcx::ObjectType appendObject( const OUString& _rForName, const css::uno::Reference< css::beans::XPropertySet >& descriptor ) override; + virtual void dropObject(sal_Int32 _nPos, const OUString& _sElementName) override; + + using OFilteredContainer::disposing; + + bool m_bInElementRemoved; + }; +} +#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_VIEWCONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |