diff options
Diffstat (limited to 'dbaccess/source/core/inc')
36 files changed, 5168 insertions, 0 deletions
diff --git a/dbaccess/source/core/inc/ContainerListener.hxx b/dbaccess/source/core/inc/ContainerListener.hxx new file mode 100644 index 000000000000..2a6b976504e5 --- /dev/null +++ b/dbaccess/source/core/inc/ContainerListener.hxx @@ -0,0 +1,97 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBA_CONTAINERLISTENER_HXX +#define DBA_CONTAINERLISTENER_HXX + +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_ +#include <com/sun/star/container/XContainerListener.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERAPPROVELISTENER_HPP_ +#include <com/sun/star/container/XContainerApproveListener.hpp> +#endif + +#ifndef _CPPUHELPER_WEAK_HXX_ +#include <cppuhelper/weak.hxx> +#endif + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + //========================================================================== + //= OContainerListener + //========================================================================== + typedef ::cppu::WeakImplHelper2 < ::com::sun::star::container::XContainerListener + , ::com::sun::star::container::XContainerApproveListener + > OContainerListener_BASE; + + /** is helper class to avoid a cycle in refcount + */ + class OContainerListener : public OContainerListener_BASE + { + ::osl::Mutex& m_rMutex; + OWeakObject& m_rDestination; + bool m_bDisposed; + + public: + OContainerListener( OWeakObject& _rDestination, ::osl::Mutex& _rMutex ) + :m_rMutex( _rMutex ) + ,m_rDestination( _rDestination ) + ,m_bDisposed( false ) + { + } + + // XContainerApproveListener + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveInsertElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveReplaceElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveRemoveElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XContainerListener + virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + + void SAL_CALL dispose() + { + m_bDisposed = true; + } + + protected: + virtual ~OContainerListener(); + }; +//........................................................................ +} // namespace dbaccess +//........................................................................ +#endif // DBA_CONTAINERLISTENER_HXX + diff --git a/dbaccess/source/core/inc/ContainerMediator.hxx b/dbaccess/source/core/inc/ContainerMediator.hxx new file mode 100644 index 000000000000..f35a0bfca58b --- /dev/null +++ b/dbaccess/source/core/inc/ContainerMediator.hxx @@ -0,0 +1,123 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBA_CONTAINERMEDIATOR_HXX +#define DBA_CONTAINERMEDIATOR_HXX + +#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_ +#include <com/sun/star/container/XContainerListener.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_ +#include <com/sun/star/container/XContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif + +#ifndef _COMPHELPER_BROADCASTHELPER_HXX_ +#include <comphelper/broadcasthelper.hxx> +#endif +#ifndef _COMPHELPER_BROADCASTHELPER_HXX_ +#include <comphelper/broadcasthelper.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> +#endif + +#include <map> + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + class OPropertyForward; + + class OContainerMediator : public ::comphelper::OBaseMutex + ,public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener > + { + public: + enum ContainerType + { + eColumns, + eTables + }; + + private: + typedef ::rtl::Reference< OPropertyForward > TPropertyForward; + typedef ::std::map< ::rtl::OUString, TPropertyForward > PropertyForwardList; + PropertyForwardList m_aForwardList; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xSettings; // can not be weak + ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer > m_xContainer; // can not be weak + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > m_aConnection; + ContainerType m_eType; + + protected: + virtual ~OContainerMediator(); + + public: + OContainerMediator( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _xContainer, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xSettings, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + ContainerType _eType + ); + + virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + + void notifyElementCreated(const ::rtl::OUString& _sElementName + ,const ::com::sun::star::uno::Reference< ::com::sun::star::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 ::rtl::OUString& _rName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDestination + ); + }; +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // DBA_CONTAINERMEDIATOR_HXX diff --git a/dbaccess/source/core/inc/ContentHelper.hxx b/dbaccess/source/core/inc/ContentHelper.hxx new file mode 100644 index 000000000000..10c5df0cd5f3 --- /dev/null +++ b/dbaccess/source/core/inc/ContentHelper.hxx @@ -0,0 +1,249 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBA_CONTENTHELPER_HXX +#define DBA_CONTENTHELPER_HXX + +#ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_ +#include <com/sun/star/ucb/XContent.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_XCOMMANDPROCESSOR_HPP_ +#include <com/sun/star/ucb/XCommandProcessor.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTIESCHANGENOTIFIER_HPP_ +#include <com/sun/star/beans/XPropertiesChangeNotifier.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HPP_ +#include <com/sun/star/beans/XPropertyContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include <com/sun/star/lang/XInitialization.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_ +#include <com/sun/star/embed/XStorage.hpp> +#endif +#ifndef _COM_SUN_STAR_EMBED_XEMBEDDEDOBJECT_HPP_ +#include <com/sun/star/embed/XEmbeddedObject.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE9_HXX_ +#include <cppuhelper/compbase9.hxx> +#endif +#ifndef _COMPHELPER_BROADCASTHELPER_HXX_ +#include <comphelper/broadcasthelper.hxx> +#endif +#ifndef COMPHELPER_COMPONENTCONTEXT_HXX +#include <comphelper/componentcontext.hxx> +#endif +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include <comphelper/stl_types.hxx> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_ +#include <com/sun/star/beans/Property.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ +#include <com/sun/star/container/XChild.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_ +#include <com/sun/star/sdbcx/XRename.hpp> +#endif +#ifndef CONNECTIVITY_SQLERROR_HXX +#include <connectivity/sqlerror.hxx> +#endif +#ifndef BOOST_SHARED_PTR_HPP_INCLUDED +#include <boost/shared_ptr.hpp> +#endif + +namespace dbaccess +{ + class ODatabaseModelImpl; + struct ContentProperties + { + ::rtl::OUString aTitle; // Title + ::boost::optional< ::rtl::OUString > + aContentType; // ContentType (aka MediaType aka MimeType) + sal_Bool bIsDocument; // IsDocument + sal_Bool bIsFolder; // IsFolder + sal_Bool bAsTemplate; // AsTemplate + ::rtl::OUString sPersistentName;// persistent name of the document + + ContentProperties() + :bIsDocument( sal_True ) + ,bIsFolder( sal_False ) + ,bAsTemplate( sal_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 ::boost::shared_ptr<OContentHelper_Impl> TContentPtr; + + + typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString, + ::comphelper::UStringHash, + ::comphelper::UStringEqual + > PropertyChangeListenerContainer; + typedef ::comphelper::OBaseMutex OContentHelper_MBASE; + typedef ::cppu::WeakComponentImplHelper9 < ::com::sun::star::ucb::XContent + , ::com::sun::star::ucb::XCommandProcessor + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::beans::XPropertiesChangeNotifier + , ::com::sun::star::beans::XPropertyContainer + , ::com::sun::star::lang::XInitialization + , ::com::sun::star::lang::XUnoTunnel + , ::com::sun::star::container::XChild + , ::com::sun::star::sdbcx::XRename + > OContentHelper_COMPBASE; + + class OContentHelper : public OContentHelper_MBASE + ,public OContentHelper_COMPBASE + { + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + setPropertyValues( const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& rValues, + const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XCommandEnvironment >& xEnv ); + com::sun::star::uno::Sequence< com::sun::star::beans::Property > + getProperties( const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & xEnv ); + + void impl_rename_throw(const ::rtl::OUString& _sNewName,bool _bNotify = true); + + protected: + ::cppu::OInterfaceContainerHelper m_aContentListeners; + PropertyChangeListenerContainer m_aPropertyChangeListeners; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + m_xParentContainer; + const ::comphelper::ComponentContext m_aContext; + const ::connectivity::SQLError m_aErrorHelper; + TContentPtr m_pImpl; + sal_uInt32 m_nCommandId; + + // helper + virtual void SAL_CALL disposing(); + + virtual 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 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyChangeEvent >& evt ) const; + + ::rtl::OUString impl_getHierarchicalName( bool _includingRootContainer ) const; + + public: + + OContentHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB + ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer + ,const TContentPtr& _pImpl + ); + + // com::sun::star::lang::XTypeProvider + virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + // ::com::sun::star::lang::XServiceInfo + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + + // XContent + virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier > SAL_CALL getIdentifier( ) throw (::com::sun::star::uno::RuntimeException) ; + virtual ::rtl::OUString SAL_CALL getContentType( ) throw (::com::sun::star::uno::RuntimeException) ; + virtual void SAL_CALL addContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ; + virtual void SAL_CALL removeContentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentEventListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ; + + // XCommandProcessor + virtual sal_Int32 SAL_CALL createCommandIdentifier( ) throw (::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::ucb::Command& aCommand, sal_Int32 CommandId, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw (::com::sun::star::uno::Exception, ::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::RuntimeException) ; + virtual void SAL_CALL abort( sal_Int32 CommandId ) throw (::com::sun::star::uno::RuntimeException) ; + + // XPropertiesChangeNotifier + virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ; + virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) throw (::com::sun::star::uno::RuntimeException) ; + + // XPropertyContainer + virtual void SAL_CALL addProperty( const ::rtl::OUString& Name, sal_Int16 Attributes, const ::com::sun::star::uno::Any& DefaultValue ) throw (::com::sun::star::beans::PropertyExistException, ::com::sun::star::beans::IllegalTypeException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) ; + virtual void SAL_CALL removeProperty( const ::rtl::OUString& Name ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::NotRemoveableException, ::com::sun::star::uno::RuntimeException) ; + + // XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static OContentHelper* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent ); + + // ::com::sun::star::container::XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + + // XRename + virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + + inline const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; } + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > + getPropertyValues( const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::Property >& rProperties ); + + const ::comphelper::ComponentContext& getContext() const { return m_aContext; } + + inline TContentPtr getImpl() const { return m_pImpl; } + + protected: + virtual ::rtl::OUString determineContentType() const = 0; + }; + +//........................................................................ +} // namespace dbaccess +//........................................................................ +#endif // DBA_CONTENTHELPER_HXX diff --git a/dbaccess/source/core/inc/DatabaseDataProvider.hxx b/dbaccess/source/core/inc/DatabaseDataProvider.hxx new file mode 100644 index 000000000000..5d7a4a4e368e --- /dev/null +++ b/dbaccess/source/core/inc/DatabaseDataProvider.hxx @@ -0,0 +1,278 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBA_DATABASEDATAPROVIDER_HXX_INCLUDED +#define DBA_DATABASEDATAPROVIDER_HXX_INCLUDED + +#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/sdbc/XParameters.hpp> +#include <com/sun/star/container/XChild.hpp> + +#include "cppuhelper/compbase4.hxx" +#include "cppuhelper/basemutex.hxx" +#include "cppuhelper/propertysetmixin.hxx" +#include <cppuhelper/implementationentry.hxx> + +#include <comphelper/sequence.hxx> + +#include "connectivity/parameters.hxx" +#include "connectivity/filtermanager.hxx" + + +namespace dbaccess +{ + +class DatabaseDataSource; +typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::chart2::data::XDatabaseDataProvider + , ::com::sun::star::container::XChild + , ::com::sun::star::chart::XComplexDescriptionAccess + , ::com::sun::star::lang::XServiceInfo > TDatabaseDataProvider; + +class DatabaseDataProvider: private ::cppu::BaseMutex, + public TDatabaseDataProvider, + public ::cppu::PropertySetMixin< ::com::sun::star::chart2::data::XDatabaseDataProvider > +{ +public: + explicit DatabaseDataProvider(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context); + + // ::com::sun::star::lang::XServiceInfo - static methods + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + SAL_CALL Create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context); + +private: + // ::com::sun::star::uno::XInterface: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(::com::sun::star::uno::Type const & type) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw () + { TDatabaseDataProvider::acquire(); } + virtual void SAL_CALL release() throw () + { TDatabaseDataProvider::release(); } + + // ::com::sun::star::lang::XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::chart2::data::XDataProvider: + virtual ::sal_Bool SAL_CALL createDataSourcePossible(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & aArguments) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > SAL_CALL createDataSource(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & aArguments) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL detectArguments(const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > & xDataSource) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(const ::rtl::OUString & aRangeRepresentation) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(const ::rtl::OUString & aRangeRepresentation) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection() throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::chart2::data::XRangeXMLConversion: + virtual ::rtl::OUString SAL_CALL convertRangeToXML(const ::rtl::OUString & aRangeRepresentation) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException); + virtual ::rtl::OUString SAL_CALL convertRangeFromXML(const ::rtl::OUString & aXMLRange) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException); + + // ::com::sun::star::lang::XInitialization: + virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception); + + // ::com::sun::star::beans::XPropertySet: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue(const ::rtl::OUString & aPropertyName, const ::com::sun::star::uno::Any & aValue) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString & PropertyName) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException); + virtual void SAL_CALL addPropertyChangeListener(const ::rtl::OUString & aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & xListener) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException); + virtual void SAL_CALL removePropertyChangeListener(const ::rtl::OUString & aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & aListener) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException); + virtual void SAL_CALL addVetoableChangeListener(const ::rtl::OUString & PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException); + virtual void SAL_CALL removeVetoableChangeListener(const ::rtl::OUString & PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException); + + // ::com::sun::star::chart2::data::XDatabaseDataProvider: + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getMasterFields() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMasterFields(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getDetailFields() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDetailFields(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCommand() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCommand(const ::rtl::OUString & the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getCommandType() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCommandType(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getFilter() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFilter(const ::rtl::OUString & the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getApplyFilter() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setApplyFilter( ::sal_Bool _applyfilter ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getHavingClause() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setHavingClause( const ::rtl::OUString& _havingclause ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getGroupBy() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setGroupBy( const ::rtl::OUString& _groupby ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getOrder() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setOrder( const ::rtl::OUString& _order ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getEscapeProcessing() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setEscapeProcessing(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getRowLimit() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRowLimit( ::sal_Int32 _rowlimit ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getActiveConnection() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setActiveConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & the_value) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException); + virtual ::rtl::OUString SAL_CALL getDataSourceName() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDataSourceName( const ::rtl::OUString& _datasourcename ) throw (::com::sun::star::uno::RuntimeException); + + // com::sun::star::sdbc::XParameters + virtual void SAL_CALL setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setByte(sal_Int32 parameterIndex, sal_Int8 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setShort(sal_Int32 parameterIndex, sal_Int16 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInt(sal_Int32 parameterIndex, sal_Int32 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLong(sal_Int32 parameterIndex, sal_Int64 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFloat(sal_Int32 parameterIndex, float x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDouble(sal_Int32 parameterIndex, double x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBytes(sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDate(sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTime(sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTimestamp(sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBinaryStream(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, sal_Int32 length) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCharacterStream(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, sal_Int32 length) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObject(sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectWithInfo(sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRef(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef>& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBlob(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob>& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setClob(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob>& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setArray(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray>& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearParameters() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // com::sun::star::sdbc::XRowSet + virtual void SAL_CALL execute() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addRowSetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeRowSetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException); + + // com::sun::star::sdbc::XResultSet + virtual sal_Bool SAL_CALL next() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isBeforeFirst() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAfterLast() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isFirst() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLast() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL beforeFirst() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL afterLast() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL first() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL last() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRow() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL absolute(sal_Int32 row) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL relative(sal_Int32 rows) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL previous() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL refreshRow() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowUpdated() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowInserted() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowDeleted() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // conatiner::XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + + // ____ XComplexDescriptionAccess ____ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setComplexRowDescriptions( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setComplexColumnDescriptions( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aColumnDescriptions ) throw (::com::sun::star::uno::RuntimeException); + + // ____ XChartDataArray (base of XComplexDescriptionAccess) ____ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL getData() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& aData ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRowDescriptions( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRowDescriptions ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getColumnDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setColumnDescriptions( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aColumnDescriptions ) throw (::com::sun::star::uno::RuntimeException); + + // ____ XChartData (base of XChartDataArray) ____ + virtual void SAL_CALL addChartDataChangeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeChartDataChangeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )throw (::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getNotANumber()throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isNotANumber(double nNumber )throw (::com::sun::star::uno::RuntimeException); +private: + DatabaseDataProvider(DatabaseDataProvider &); // not defined + void operator =(DatabaseDataProvider &); // not defined + + virtual ~DatabaseDataProvider() {} + + // 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(); + + void impl_fillRowSet_throw(); + void impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies); + bool impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies); + void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const ::com::sun::star::uno::Sequence< ::rtl::OUString >& i_aColumnNames); + void impl_invalidateParameter_nothrow(); + ::com::sun::star::uno::Any impl_getNumberFormatKey_nothrow(const ::rtl::OUString & _sRangeRepresentation) const; + + template <typename T> void set( const ::rtl::OUString& _sProperty + ,const T& _Value + ,T& _member) + { + BoundListeners l; + { + ::osl::MutexGuard aGuard(m_aMutex); + if ( _member != _Value ) + { + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } + } + l.notify(); + } + + ::dbtools::ParameterManager m_aParameterManager; + ::dbtools::FilterManager m_aFilterManager; + ::std::map< ::rtl::OUString, ::com::sun::star::uno::Any> m_aNumberFormats; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xActiveConnection; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xRowSet; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > m_xInternal; + ::com::sun::star::uno::Reference< ::com::sun::star::chart::XComplexDescriptionAccess > m_xComplexDescriptionAccess; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XRangeXMLConversion> m_xRangeConversion; + ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> m_xHandler; + // the object doin' most of the work - an SDB-rowset + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xAggregateSet; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xParent; + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_MasterFields; + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_DetailFields; + + ::rtl::OUString m_Command; + ::rtl::OUString m_DataSourceName; + ::sal_Int32 m_CommandType; + sal_Int32 m_RowLimit; + ::rtl::OUString m_Filter; + ::rtl::OUString m_HavingClause; + ::rtl::OUString m_Order; + ::rtl::OUString m_GroupBy; + ::sal_Bool m_EscapeProcessing; + ::sal_Bool m_ApplyFilter; +}; + +} // namespace dbaccess + +#endif // DBA_DATABASEDATAPROVIDER_HXX_INCLUDED diff --git a/dbaccess/source/core/inc/FilteredContainer.hxx b/dbaccess/source/core/inc/FilteredContainer.hxx new file mode 100644 index 000000000000..f02c3da87d19 --- /dev/null +++ b/dbaccess/source/core/inc/FilteredContainer.hxx @@ -0,0 +1,144 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBACCESS_CORE_FILTERED_CONTAINER_HXX +#define DBACCESS_CORE_FILTERED_CONTAINER_HXX + +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> + +#include <connectivity/sdbcx/VCollection.hxx> + +namespace dbtools +{ + class IWarningsContainer; +} + +namespace dbaccess +{ + class IRefreshListener; + + class OFilteredContainer : public ::connectivity::sdbcx::OCollection + { + private: + mutable sal_Bool m_bConstructed; // late ctor called + + protected: + ::dbtools::IWarningsContainer* m_pWarningsContainer; + IRefreshListener* m_pRefreshListener; + oslInterlockedCount& m_nInAppend; + + // holds the original container which where set in construct but they can be null + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xMasterContainer; + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > m_xConnection; + ::com::sun::star::uno::Reference< ::com::sun::star::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 ::rtl::OUString getTableTypeRestriction() const = 0; + + inline virtual void addMasterContainerListener(){} + inline virtual void removeMasterContainerListener(){} + + // ::connectivity::sdbcx::OCollection + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + + virtual ::rtl::OUString getNameForObject(const ::connectivity::sdbcx::ObjectType& _xObject); + + /** 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>constrcuct</code> methods. + */ + virtual void SAL_CALL disposing(); + + class EnsureReset + { + public: + EnsureReset( oslInterlockedCount& _rValueLocation) + :m_rValue( _rValueLocation ) + { + osl_incrementInterlockedCount(&m_rValue); + } + + ~EnsureReset() + { + osl_decrementInterlockedCount(&m_rValue); + } + + private: + oslInterlockedCount& m_rValue; + }; + + /** retrieve a table type filter to pass to <member scope="com::sun::star::sdbc">XDatabaseMetaData::getTables</member>, + according to the current data source settings + */ + void getAllTableTypeFilter( ::com::sun::star::uno::Sequence< ::rtl::OUString >& /* [out] */ _rFilter ) const; + + public: + /** ctor of the container. The parent has to support the <type scope="com::sun::star::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 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xCon, + sal_Bool _bCase, + IRefreshListener* _pRefreshListener, + ::dbtools::IWarningsContainer* _pWarningsContainer, + oslInterlockedCount& _nInAppend + ); + + inline 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 ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableFilter, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableTypeFilter + ); + + /** late ctor. The container will fill itself with wrapper objects for the tables returned by the given + name container. + */ + void construct( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxMasterContainer, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableFilter, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableTypeFilter + ); + + inline sal_Bool isInitialized() const { return m_bConstructed; } + }; +// .............................................................................. +} // namespace +// .............................................................................. + +#endif // DBACCESS_CORE_FILTERED_CONTAINER_HXX diff --git a/dbaccess/source/core/inc/PropertyForward.hxx b/dbaccess/source/core/inc/PropertyForward.hxx new file mode 100644 index 000000000000..b0e5696387b4 --- /dev/null +++ b/dbaccess/source/core/inc/PropertyForward.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBA_PROPERTYSETFORWARD_HXX +#define DBA_PROPERTYSETFORWARD_HXX + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_ +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_ +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _COMPHELPER_BROADCASTHELPER_HXX_ +#include <comphelper/broadcasthelper.hxx> +#endif + +#include <vector> + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + // =================================================================== + // = OPropertyForward + // =================================================================== + typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener + > OPropertyForward_Base; + class OPropertyForward :public ::comphelper::OBaseMutex + ,public OPropertyForward_Base + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSource; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDest; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xDestInfo; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xDestContainer; + ::rtl::OUString m_sName; + sal_Bool m_bInInsert; + + protected: + virtual ~OPropertyForward(); + + public: + OPropertyForward( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xSource, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xDestContainer, + const ::rtl::OUString& _sName, + const ::std::vector< ::rtl::OUString >& _aPropertyList + ); + + // ::com::sun::star::beans::XPropertyChangeListener + virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException); + + inline void setName( const ::rtl::OUString& _sName ) { m_sName = _sName; } + void setDefinition( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDest); + inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getDefinition() const { return m_xDest; } + }; + +//........................................................................ +} // namespace dbaccess +//........................................................................ +#endif // DBA_PROPERTYSETFORWARD_HXX + diff --git a/dbaccess/source/core/inc/RefreshListener.hxx b/dbaccess/source/core/inc/RefreshListener.hxx new file mode 100644 index 000000000000..2b4bdda0f5a0 --- /dev/null +++ b/dbaccess/source/core/inc/RefreshListener.hxx @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBA_CORE_REFRESHLISTENER_HXX +#define DBA_CORE_REFRESHLISTENER_HXX + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif + +namespace com { namespace sun { namespace star { namespace container +{ + class XNameAccess; +} +}}} + +//......................................................................... +namespace dbaccess +{ +//......................................................................... + + //===================================================================== + //= IRefreshListener + //===================================================================== + class SAL_NO_VTABLE IRefreshListener + { + public: + virtual void refresh(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rToBeRefreshed) = 0; + }; +//......................................................................... +} // namespace dbaccess +//......................................................................... + +#endif // DBA_CORE_REFRESHLISTENER_HXX + diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx new file mode 100644 index 000000000000..7c0d2ba4cea3 --- /dev/null +++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx @@ -0,0 +1,283 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX +#define DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX + +#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ +#include <com/sun/star/sdb/XParametersSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_ +#include <com/sun/star/script/XTypeConverter.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE5_HXX_ +#include <cppuhelper/implbase5.hxx> +#endif +#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ +#include <connectivity/sqliterator.hxx> +#endif +#ifndef _CONNECTIVITY_SQLPARSE_HXX +#include <connectivity/sqlparse.hxx> +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif +#ifndef _COMPHELPER_BROADCASTHELPER_HXX_ +#include <comphelper/broadcasthelper.hxx> +#endif +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif +#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_ +#include <comphelper/proparrhlp.hxx> +#endif +#ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_ +#include <comphelper/propertycontainer.hxx> +#endif +#ifndef COMPHELPER_COMPONENTCONTEXT_HXX +#include <comphelper/componentcontext.hxx> +#endif + +#include <memory> + +namespace com { namespace sun { namespace star { namespace util { + class XNumberFormatsSupplier; + class XNumberFormatter; +}}}} + +namespace dbaccess +{ + typedef ::cppu::ImplHelper5< ::com::sun::star::sdb::XSingleSelectQueryComposer, + ::com::sun::star::sdb::XParametersSupplier, + ::com::sun::star::sdbcx::XColumnsSupplier, + ::com::sun::star::sdbcx::XTablesSupplier, + ::com::sun::star::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 + }; + inline void incSQLPart( SQLPart& e ) { e = (SQLPart)(1 + (size_t)e); } + enum EColumnType + { + SelectColumns = 0, + GroupByColumns = 1, + OrderColumns = 2, + ParameterColumns = 3 + }; + typedef ::std::const_mem_fun_t< const ::connectivity::OSQLParseNode*, ::connectivity::OSQLParseTreeIterator > + TGetParseNode; + ::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<OPrivateColumns*> m_aColumnsCollection; // used for columns and parameters of old queries + ::std::vector<OPrivateTables*> m_aTablesCollection; + + ::std::vector< ::rtl::OUString > m_aElementaryParts; // the filter/groupby/having/order of the elementary statement + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xMetaData; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xConnectionTables; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xConnectionQueries; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xNumberFormatsSupplier; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColumns; + ::comphelper::ComponentContext m_aContext; + ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter; + + ::std::vector<OPrivateColumns*> m_aCurrentColumns; + OPrivateTables* m_pTables; // currently used tables + + ::rtl::OUString m_aPureSelectSQL; // the pure select statement, without filter/order/groupby/having + ::rtl::OUString m_sDecimalSep; + ::rtl::OUString m_sCommand; + ::com::sun::star::lang::Locale m_aLocale; + sal_Int32 m_nBoolCompareMode; // how to compare bool values + sal_Int32 m_nCommandType; + + // <properties> + ::rtl::OUString m_sOrignal; + // </properties> + + + sal_Bool setORCriteria(::connectivity::OSQLParseNode* pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator, + ::std::vector< ::std::vector < ::com::sun::star::beans::PropertyValue > >& rFilters, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter) const; + sal_Bool setANDCriteria(::connectivity::OSQLParseNode* pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator, + ::std::vector < ::com::sun::star::beans::PropertyValue > & rFilters, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter) const; + sal_Bool setComparsionPredicate(::connectivity::OSQLParseNode* pCondition, ::connectivity::OSQLParseTreeIterator& _rIterator, + ::std::vector < ::com::sun::star::beans::PropertyValue > & rFilters, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter) const; + + ::rtl::OUString getColumnName(::connectivity::OSQLParseNode* pColumnRef,::connectivity::OSQLParseTreeIterator& _rIterator) const; + ::rtl::OUString getTableAlias(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column ) const; + sal_Int32 getPredicateType(::connectivity::OSQLParseNode * _pPredicate) const; + // 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. + */ + ::rtl::OUString getStatementPart( TGetParseNode& _aGetFunctor, ::connectivity::OSQLParseTreeIterator& _rIterator ); + void setQuery_Impl( const ::rtl::OUString& command ); + + void setConditionByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column + , sal_Bool andCriteria + ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _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 + */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > + getStructuredCondition( TGetParseNode& _aGetFunctor ); + + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > + setCurrentColumns( EColumnType _eType, const ::vos::ORef< ::connectivity::OSQLColumns >& _rCols ); + + //helper methods for mem_fun_t + inline bool implSetFilter(::rtl::OUString _sFilter) { setFilter(_sFilter); return true;} + inline bool implSetHavingClause(::rtl::OUString _sFilter) { setHavingClause(_sFilter); return true;} + + /** returns the part of the seelect 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. + */ + ::rtl::OUString getSQLPart( SQLPart _ePart, ::connectivity::OSQLParseTreeIterator& _rIterator, sal_Bool _bWithKeyword ); + + /** retrieves the keyword for the given SQLPart + */ + ::rtl::OUString getKeyword( SQLPart _ePart ) const; + + /** sets a single "additive" clause, means a filter/groupby/having/order clause + */ + void setSingleAdditiveClause( SQLPart _ePart, const ::rtl::OUString& _rClause ); + + /** composes a statement from m_aPureSelectSQL and the 4 usual clauses + */ + ::rtl::OUString composeStatementFromParts( const ::std::vector< ::rtl::OUString >& _rParts ); + + /** return the name of the column. + */ + ::rtl::OUString impl_getColumnName_throw(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column); + + protected: + virtual ~OSingleSelectQueryComposer(); + public: + + OSingleSelectQueryComposer( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xTableSupplier, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection, + const ::comphelper::ComponentContext& _rContext); + + + void SAL_CALL disposing(void); + // ::com::sun::star::lang::XTypeProvider + DECLARE_TYPEPROVIDER( ); + + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::uno::XInterface + DECLARE_XINTERFACE( ) + + // XServiceInfo + DECLARE_SERVICE_INFO(); + + DECLARE_PROPERTYCONTAINER_DEFAULTS(); + + // ::com::sun::star::sdb::XSingleSelectQueryComposer + virtual ::rtl::OUString SAL_CALL getElementaryQuery() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setElementaryQuery( const ::rtl::OUString& _rElementary ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFilter( const ::rtl::OUString& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setStructuredFilter( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendFilterByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendGroupByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setGroup( const ::rtl::OUString& group ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setHavingClause( const ::rtl::OUString& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setStructuredHavingClause( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendHavingClauseByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendOrderByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool ascending ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setOrder( const ::rtl::OUString& order ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // XSingleSelectQueryAnalyzer + virtual ::rtl::OUString SAL_CALL getQuery( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setQuery( const ::rtl::OUString& command ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCommand( const ::rtl::OUString& command,sal_Int32 CommandType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getFilter( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getStructuredFilter( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getGroup( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getGroupColumns( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getHavingClause( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getStructuredHavingClause( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getOrder( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getOrderColumns( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getQueryWithSubstitution( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // XColumnsSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException); + // XTablesSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException); + // XParametersSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getParameters( ) throw(::com::sun::star::uno::RuntimeException); + }; +} +#endif // DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX diff --git a/dbaccess/source/core/inc/TableDeco.hxx b/dbaccess/source/core/inc/TableDeco.hxx new file mode 100644 index 000000000000..8f8ec5bf9652 --- /dev/null +++ b/dbaccess/source/core/inc/TableDeco.hxx @@ -0,0 +1,220 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_CORE_TABLEDECORATOR_HXX_ +#define _DBA_CORE_TABLEDECORATOR_HXX_ + +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_ +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XIndexesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XKeysSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_ +#include <com/sun/star/sdbcx/XRename.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_ +#include <com/sun/star/sdbcx/XAlterTable.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _CPPUHELPER_COMPBASE9_HXX_ +#include <cppuhelper/compbase9.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE5_HXX_ +#include <cppuhelper/implbase5.hxx> +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif +#ifndef _DBA_CORE_DATASETTINGS_HXX_ +#include "datasettings.hxx" +#endif +#ifndef _DBA_COREAPI_COLUMN_HXX_ +#include "column.hxx" +#endif + +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include <connectivity/CommonTools.hxx> +#endif +#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ +#include <connectivity/sdbcx/IRefreshable.hxx> +#endif +#ifndef COMPHELPER_IDPROPERTYARRAYUSAGEHELPER_HXX +#include <comphelper/IdPropArrayHelper.hxx> +#endif + +namespace dbaccess +{ + typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::sdbcx::XColumnsSupplier, + ::com::sun::star::sdbcx::XKeysSupplier, + ::com::sun::star::container::XNamed, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::sdbcx::XDataDescriptorFactory, + ::com::sun::star::sdbcx::XIndexesSupplier, + ::com::sun::star::sdbcx::XRename, + ::com::sun::star::lang::XUnoTunnel, + ::com::sun::star::sdbcx::XAlterTable> OTableDescriptor_BASE; + //========================================================================== + //= OTables + //========================================================================== + class ODBTableDecorator; + typedef ::comphelper::OIdPropertyArrayUsageHelper< ODBTableDecorator > ODBTableDecorator_PROP; + + class ODBTableDecorator :public comphelper::OBaseMutex + ,public OTableDescriptor_BASE + ,public ODataSettings //ODataSettings_Base + ,public IColumnFactory + ,public ::connectivity::sdbcx::IRefreshableColumns + ,public ODBTableDecorator_PROP + { + void fillPrivileges() const; + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xColumnMediator; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier > m_xTable; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xColumnDefinitions; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xNumberFormats; + + // <properties> + mutable sal_Int32 m_nPrivileges; + // </properties> + ::connectivity::sdbcx::OCollection* m_pColumns; + ::connectivity::sdbcx::OCollection* m_pTables; + + // IColumnFactory + virtual OColumn* createColumn(const ::rtl::OUString& _rName) const; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor(); + virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor ); + virtual void columnDropped(const ::rtl::OUString& _sName); + + virtual void refreshColumns(); + + virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 _nId) const; + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + + throw (::com::sun::star::uno::Exception); + + virtual ~ODBTableDecorator(); + 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/> + */ + ODBTableDecorator( + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& _rxTable, + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& _rxNumberFormats, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumnDefinitions + ) throw(::com::sun::star::sdbc::SQLException); + + + + // ODescriptor + virtual void construct(); + + //XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + + // ::com::sun::star::lang::XServiceInfo + DECLARE_SERVICE_INFO(); + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::sdbcx::XRename, + virtual void SAL_CALL rename( const ::rtl::OUString& _rNewName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::sdbcx::XAlterTable, + virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL alterColumnByIndex( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException); + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const { return m_xMetaData; } + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() const { return m_xMetaData.is() ? m_xMetaData->getConnection() : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>(); } + + // XColumnsSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw (::com::sun::star::uno::RuntimeException); + // XKeysSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getKeys( ) throw (::com::sun::star::uno::RuntimeException); + // XIndexesSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getIndexes( ) throw (::com::sun::star::uno::RuntimeException); + // XDataDescriptorFactory + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException); + + protected: + using ODataSettings::getFastPropertyValue; + }; +} +#endif // _DBA_CORE_TABLEDECORATOR_HXX_ + + diff --git a/dbaccess/source/core/inc/View.hxx b/dbaccess/source/core/inc/View.hxx new file mode 100644 index 000000000000..4e96a1882423 --- /dev/null +++ b/dbaccess/source/core/inc/View.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: View.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACCESS_VIEW_HXX +#define DBACCESS_VIEW_HXX + +#include "connectivity/sdbcx/VView.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/sdbcx/XAlterView.hpp> +#include <com/sun/star/sdb/tools/XViewAccess.hpp> +/** === end UNO includes === **/ + +#include <comphelper/uno3.hxx> +#include <cppuhelper/implbase1.hxx> + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + //==================================================================== + //= View + //==================================================================== + typedef ::connectivity::sdbcx::OView View_Base; + typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XAlterView > View_IBASE; + class View :public View_Base + ,public View_IBASE + { + public: + View( + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + sal_Bool _bCaseSensitive, + const ::rtl::OUString& _rCatalogName, + const ::rtl::OUString& _rSchemaName, + const ::rtl::OUString& _rName + ); + + // UNO + DECLARE_XINTERFACE() + DECLARE_XTYPEPROVIDER() + + // XAlterView + virtual void SAL_CALL alterCommand( const ::rtl::OUString& NewCommand ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + protected: + virtual ~View(); + + protected: + // OPropertyContainer + virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& _rValue, sal_Int32 _nHandle ) const; + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XViewAccess> m_xViewAccess; + sal_Int32 m_nCommandHandle; + private: + using View_Base::getFastPropertyValue; + }; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // DBACCESS_VIEW_HXX diff --git a/dbaccess/source/core/inc/callablestatement.hxx b/dbaccess/source/core/inc/callablestatement.hxx new file mode 100644 index 000000000000..64f281e7b6aa --- /dev/null +++ b/dbaccess/source/core/inc/callablestatement.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _DBA_COREAPI_CALLABLESTATEMENT_HXX_ +#define _DBA_COREAPI_CALLABLESTATEMENT_HXX_ + +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XOUTPARAMETERS_HPP_ +#include <com/sun/star/sdbc/XOutParameters.hpp> +#endif +#ifndef _DBA_COREAPI_PREPAREDSTATEMENT_HXX_ +#include <preparedstatement.hxx> +#endif + +namespace dbaccess +{ + //************************************************************ + // OCallableStatement + //************************************************************ + class OCallableStatement : public OPreparedStatement, + public ::com::sun::star::sdbc::XRow, + public ::com::sun::star::sdbc::XOutParameters + { + public: + OCallableStatement(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement) + :OPreparedStatement(_xConn, _xStatement){} + + // ::com::sun::star::lang::XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::uno::XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + + // ::com::sun::star::lang::XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::sdbc::XOutParameters + virtual void SAL_CALL registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::sdbc::XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _DBA_COREAPI_CALLABLESTATEMENT_HXX_ + diff --git a/dbaccess/source/core/inc/column.hxx b/dbaccess/source/core/inc/column.hxx new file mode 100644 index 000000000000..543e999f715f --- /dev/null +++ b/dbaccess/source/core/inc/column.hxx @@ -0,0 +1,258 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_COREAPI_COLUMN_HXX_ +#define _DBA_COREAPI_COLUMN_HXX_ + +#include "columnsettings.hxx" + +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/io/IOException.hpp> +#include <com/sun/star/io/XObjectInputStream.hpp> +#include <com/sun/star/io/XObjectOutputStream.hpp> +#include <com/sun/star/lang/WrappedTargetException.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbcx/XAppend.hpp> +#include <com/sun/star/sdbcx/XDrop.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> + +#include <comphelper/broadcasthelper.hxx> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/propertycontainer.hxx> +#include <comphelper/stl_types.hxx> +#include <connectivity/CommonTools.hxx> +#include <connectivity/FValue.hxx> +#include <connectivity/TColumnsHelper.hxx> +#include <connectivity/sdbcx/IRefreshable.hxx> +#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/compbase4.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/propshlp.hxx> +#include <osl/diagnose.h> + +#include <hash_map> + +namespace dbaccess +{ + + //************************************************************ + // OColumn + //************************************************************ + typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::container::XNamed + > OColumnBase; + + //------------------------------------------------------------ + class OColumn :public comphelper::OBaseMutex + ,public OColumnBase + ,public ::comphelper::OPropertyContainer + ,public IPropertyContainer // convenience for the derived class which also derive from OColumnSettings + { + friend class OColumns; + + protected: + // <properties> + ::rtl::OUString m_sName; + // </properties> + + protected: + OColumn( const bool _bNameIsReadOnly ); + + public: + virtual ~OColumn(); + + // com::sun::star::lang::XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) = 0; + + // com::sun::star::uno::XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + + // com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + + // cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + + // ::com::sun::star::lang::XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName( const ::rtl::OUString& _rName ) throw(::com::sun::star::uno::RuntimeException); + + virtual void fireValueChange( const ::connectivity::ORowSetValue& _rOldValue ); + + protected: + // IPropertyContainer + virtual void registerProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void* _pPointerToMember, const ::com::sun::star::uno::Type& _rMemberType ); + virtual void registerMayBeVoidProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, ::com::sun::star::uno::Any* _pPointerToMember, const ::com::sun::star::uno::Type& _rExpectedType ); + virtual void registerPropertyNoMember( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const ::com::sun::star::uno::Type& _rType, const void* _pInitialValue ); + }; + + //============================================================ + //= IColumnFactory - used by OColumns for creating new columns + //============================================================ + class SAL_NO_VTABLE IColumnFactory + { + public: + /** creates a OColumn object which should represent the column with a given name + */ + virtual OColumn* + createColumn( const ::rtl::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 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor() = 0; + + /** notifies that a column, created from a column descriptor, has been appended + */ + virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor ) = 0; + + /** notifies that a column with a given name has been dropped + */ + virtual void columnDropped( const ::rtl::OUString& _sName ) = 0; + }; + + //============================================================ + //= OColumns + //= general columns map, could be used for readonly access + //= no appending and dropping is supported + //============================================================ + typedef ::std::hash_map<rtl::OUString, OColumn*, ::comphelper::UStringMixHash, ::comphelper::UStringMixEqual> OColumnMap; + typedef ::std::vector<OColumn*> OColumnArray; + + class OContainerMediator; + typedef ::cppu::ImplHelper1< ::com::sun::star::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 + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xDrvColumns; + ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > m_xParent; + IColumnFactory* m_pColFactoryImpl; + ::connectivity::sdbcx::IRefreshableColumns* m_pRefreshColumns; + + sal_Bool m_bInitialized : 1; + sal_Bool m_bAddColumn : 1; + sal_Bool m_bDropColumn : 1; + + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor(); + virtual connectivity::sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ); + virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName); + + public: + connectivity::sdbcx::ObjectType createBaseObject(const ::rtl::OUString& _rName) + { + return OColumns_BASE::createObject(_rName); + } + /** flag which determines whether the container is filled or not + */ + inline sal_Bool isInitialized() const { return m_bInitialized; } + inline void setInitialized() {m_bInitialized = sal_True;} + inline 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, + sal_Bool _bCaseSensitive, + const ::std::vector< ::rtl::OUString>& _rVector, + IColumnFactory* _pColFactory, + ::connectivity::sdbcx::IRefreshableColumns* _pRefresh, + sal_Bool _bAddColumn = sal_False, + sal_Bool _bDropColumn = sal_False, + sal_Bool _bUseHardRef = sal_True); + + OColumns( + ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxDrvColumns, + sal_Bool _bCaseSensitive, + const ::std::vector< ::rtl::OUString> &_rVector, + IColumnFactory* _pColFactory, + ::connectivity::sdbcx::IRefreshableColumns* _pRefresh, + sal_Bool _bAddColumn = sal_False, + sal_Bool _bDropColumn = sal_False, + sal_Bool _bUseHardRef = sal_True); + virtual ~OColumns(); + + //XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw() { OColumns_BASE::acquire(); } + virtual void SAL_CALL release() throw() { OColumns_BASE::release(); } + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::lang::XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::container::XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + + void append(const ::rtl::OUString& rName, OColumn*); + void clearColumns(); + // only the name is identical to ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + + private: + using OColumns_BASE::setParent; + }; +} +#endif // _DBA_COREAPI_COLUMN_HXX_ + diff --git a/dbaccess/source/core/inc/columnsettings.hxx b/dbaccess/source/core/inc/columnsettings.hxx new file mode 100644 index 000000000000..c9f6fa5b1cda --- /dev/null +++ b/dbaccess/source/core/inc/columnsettings.hxx @@ -0,0 +1,109 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef COLUMNSETTINGS_HXX +#define COLUMNSETTINGS_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/beans/XPropertySet.hpp> +/** === end UNO includes === **/ + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + // TODO: move the following to comphelper/propertycontainerhelper.hxx + class IPropertyContainer + { + public: + virtual void registerProperty( + const ::rtl::OUString& _rName, + sal_Int32 _nHandle, + sal_Int32 _nAttributes, + void* _pPointerToMember, + const ::com::sun::star::uno::Type& _rMemberType + ) = 0; + + virtual void registerMayBeVoidProperty( + const ::rtl::OUString& _rName, + sal_Int32 _nHandle, + sal_Int32 _nAttributes, + ::com::sun::star::uno::Any* _pPointerToMember, + const ::com::sun::star::uno::Type& _rExpectedType + ) = 0; + + virtual void registerPropertyNoMember( + const ::rtl::OUString& _rName, + sal_Int32 _nHandle, + sal_Int32 _nAttributes, + const ::com::sun::star::uno::Type& _rType, + const void* _pInitialValue + ) = 0; + }; + + //==================================================================== + //= OColumnSettings + //==================================================================== + class OColumnSettings + { + // <properties> + ::com::sun::star::uno::Any m_aWidth; // sal_Int32 or void + ::com::sun::star::uno::Any m_aFormatKey; // sal_Int32 or void + ::com::sun::star::uno::Any m_aRelativePosition; // sal_Int32 or void + ::com::sun::star::uno::Any m_aAlignment; // sal_Int32 (::com::sun::star::awt::TextAlign) or void + ::com::sun::star::uno::Any m_aHelpText; // the description of the column which is visible in the helptext of the column + ::com::sun::star::uno::Any m_aControlDefault; // the default value which should be displayed as by a control when moving to a new row + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + m_xControlModel; + sal_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 ::com::sun::star::uno::Any& _rPropertyValue ); + + public: + /** check if the persistent settings have their default value + */ + static bool hasDefaultSettings( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn ); + }; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // COLUMNSETTINGS_HXX diff --git a/dbaccess/source/core/inc/commandbase.hxx b/dbaccess/source/core/inc/commandbase.hxx new file mode 100644 index 000000000000..ea0e9644c714 --- /dev/null +++ b/dbaccess/source/core/inc/commandbase.hxx @@ -0,0 +1,71 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_CORE_COMMANDBASE_HXX_ +#define _DBA_CORE_COMMANDBASE_HXX_ + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ +#include <com/sun/star/beans/PropertyValue.hpp> +#endif + +//........................................................................ +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> + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> + m_aLayoutInformation; + ::rtl::OUString m_sCommand; + sal_Bool m_bEscapeProcessing; // no BitField ! so it can be used with a OPropertyStateContainer + ::rtl::OUString m_sUpdateTableName; + ::rtl::OUString m_sUpdateSchemaName; + ::rtl::OUString m_sUpdateCatalogName; +// </properties> + +protected: + OCommandBase() : m_bEscapeProcessing(sal_True) { } + +}; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // _DBA_CORE_COMMANDBASE_HXX_ + + diff --git a/dbaccess/source/core/inc/composertools.hxx b/dbaccess/source/core/inc/composertools.hxx new file mode 100644 index 000000000000..4f7c4b7f66ef --- /dev/null +++ b/dbaccess/source/core/inc/composertools.hxx @@ -0,0 +1,142 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX +#define DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +#include <functional> + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + //==================================================================== + //= TokenComposer + //==================================================================== + struct TokenComposer : public ::std::unary_function< ::rtl::OUString, void > + { + private: + #ifdef DBG_UTIL + bool m_bUsed; + #endif + + protected: + ::rtl::OUStringBuffer m_aBuffer; + + public: + ::rtl::OUString getComposedAndClear() + { + #ifdef DBG_UTIL + m_bUsed = true; + #endif + return m_aBuffer.makeStringAndClear(); + } + + void clear() + { + #ifdef DBG_UTIL + m_bUsed = false; + #endif + m_aBuffer.makeStringAndClear(); + } + + public: + TokenComposer() + #ifdef DBG_UTIL + :m_bUsed( false ) + #endif + { + } + + virtual ~TokenComposer() + { + } + + void operator() (const ::rtl::OUString& lhs) + { + append(lhs); + } + + void append( const ::rtl::OUString& lhs ) + { + #ifdef DBG_UTIL + OSL_ENSURE( !m_bUsed, "FilterCreator::append: already used up!" ); + #endif + if ( lhs.getLength() ) + { + if ( m_aBuffer.getLength() ) + 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 ::rtl::OUString& lhs ) = 0; + }; + + //==================================================================== + //= FilterCreator + //==================================================================== + struct FilterCreator : public TokenComposer + { + virtual void appendNonEmptyToNonEmpty( const ::rtl::OUString& lhs ) + { + m_aBuffer.insert( 0, (sal_Unicode)' ' ); + m_aBuffer.insert( 0, (sal_Unicode)'(' ); + m_aBuffer.appendAscii( " ) AND ( " ); + m_aBuffer.append( lhs ); + m_aBuffer.appendAscii( " )" ); + } + }; + + //==================================================================== + //= FilterCreator + //==================================================================== + struct OrderCreator : public TokenComposer + { + virtual void appendNonEmptyToNonEmpty( const ::rtl::OUString& lhs ) + { + m_aBuffer.appendAscii( ", " ); + m_aBuffer.append( lhs ); + } + }; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX + diff --git a/dbaccess/source/core/inc/containerapprove.hxx b/dbaccess/source/core/inc/containerapprove.hxx new file mode 100644 index 000000000000..0f27559201d7 --- /dev/null +++ b/dbaccess/source/core/inc/containerapprove.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACCESS_CONTAINERAPPROVE_HXX +#define DBACCESS_CONTAINERAPPROVE_HXX + +/** === begin UNO includes === **/ +#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_ +#include <com/sun/star/uno/XInterface.hpp> +#endif +/** === end UNO includes === **/ + +#include <boost/shared_ptr.hpp> + +//........................................................................ +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: + /** approves a given element for insertion into the container + @param _rName + specifies the name under which the element is going to be inserted + @param _rxElement + specifies the element which 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 SAL_CALL approveElement( + const ::rtl::OUString& _rName, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxElement + ) = 0; + }; + + typedef ::boost::shared_ptr< IContainerApprove > PContainerApprove; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // DBACCESS_CONTAINERAPPROVE_HXX + diff --git a/dbaccess/source/core/inc/core_resource.hrc b/dbaccess/source/core/inc/core_resource.hrc new file mode 100644 index 000000000000..fb6320f38932 --- /dev/null +++ b/dbaccess/source/core/inc/core_resource.hrc @@ -0,0 +1,113 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_CORE_RESOURCE_HRC_ +#define _DBA_CORE_RESOURCE_HRC_ + +#ifndef _SOLAR_HRC +#include <svl/solar.hrc> +#endif + +//------------------------------------------------------------------------------ +#define RID_CORE_STRINGS_START RID_DBACCESS_START + +//------------------------------------------------------------------------------ +//- String-IDs +#define RID_STR_TRIED_OPEN_TABLE ( RID_CORE_STRINGS_START + 0 ) +#define RID_STR_CONNECTION_INVALID ( RID_CORE_STRINGS_START + 1 ) +#define RID_STR_TABLE_IS_FILTERED ( RID_CORE_STRINGS_START + 2 ) +#define RID_STR_NEED_CONFIG_WRITE_ACCESS ( RID_CORE_STRINGS_START + 3 ) +#define RID_STR_COULDNOTCONNECT_NODRIVER ( RID_CORE_STRINGS_START + 4 ) +#define RID_STR_COULDNOTCONNECT_UNSPECIFIED ( RID_CORE_STRINGS_START + 5 ) +#define RID_STR_COULDNOTLOAD_MANAGER ( RID_CORE_STRINGS_START + 6 ) +#define RID_STR_ONLY_QUERY ( RID_CORE_STRINGS_START + 7 ) +#define RID_STR_NO_VALUE_CHANGED ( RID_CORE_STRINGS_START + 8 ) +#define RID_STR_NO_XROWUPDATE ( RID_CORE_STRINGS_START + 9 ) +#define RID_STR_NO_XRESULTSETUPDATE ( RID_CORE_STRINGS_START + 10 ) +#define RID_STR_NO_UPDATE_MISSING_CONDITION ( RID_CORE_STRINGS_START + 11 ) +#define RID_STR_NO_COLUMN_ADD ( RID_CORE_STRINGS_START + 12 ) +#define RID_STR_NO_COLUMN_DROP ( RID_CORE_STRINGS_START + 13 ) +#define RID_STR_NO_CONDITION_FOR_PK ( RID_CORE_STRINGS_START + 14 ) +#define RID_STR_NO_XQUERIESSUPPLIER ( RID_CORE_STRINGS_START + 15 ) +#define RID_STR_NO_ABS_ZERO ( RID_CORE_STRINGS_START + 16 ) +#define RID_STR_NO_RELATIVE ( RID_CORE_STRINGS_START + 17 ) +#define RID_STR_NO_REFESH_AFTERLAST ( RID_CORE_STRINGS_START + 18 ) +#define RID_STR_NO_MOVETOINSERTROW_CALLED ( RID_CORE_STRINGS_START + 19 ) +#define RID_STR_NO_UPDATEROW ( RID_CORE_STRINGS_START + 20 ) +#define RID_STR_NO_DELETEROW ( RID_CORE_STRINGS_START + 21 ) +#define RID_STR_COLUMN_MUST_VISIBLE ( RID_CORE_STRINGS_START + 22 ) +#define RID_STR_COLUMN_NOT_VALID ( RID_CORE_STRINGS_START + 23 ) +#define RID_STR_COLUMN_NOT_SEARCHABLE ( RID_CORE_STRINGS_START + 24 ) +#define RID_STR_NOT_SEQUENCE_INT8 ( RID_CORE_STRINGS_START + 25 ) +#define RID_STR_NOT_SUPPORTED_BY_DRIVER ( RID_CORE_STRINGS_START + 26 ) +#define RID_STR_NO_TABLE_RENAME ( RID_CORE_STRINGS_START + 27 ) +#define RID_STR_COLUMN_ALTER_BY_NAME ( RID_CORE_STRINGS_START + 28 ) +#define RID_STR_COLUMN_ALTER_BY_INDEX ( RID_CORE_STRINGS_START + 29 ) +#define RID_STR_NO_ALTER_COLUMN_DEF ( RID_CORE_STRINGS_START + 30 ) +#define RID_STR_COLUMN_UNKNOWN_PROP ( RID_CORE_STRINGS_START + 31 ) +#define RID_STR_FORM ( RID_CORE_STRINGS_START + 32 ) +#define RID_STR_REPORT ( RID_CORE_STRINGS_START + 33 ) +#define RID_STR_DATASOURCE_NOT_STORED ( RID_CORE_STRINGS_START + 34 ) +#define RID_STR_FILE_DOES_NOT_EXIST ( RID_CORE_STRINGS_START + 35 ) +#define RID_STR_TABLE_DOES_NOT_EXIST ( RID_CORE_STRINGS_START + 36 ) +#define RID_STR_CONFLICTING_NAMES ( RID_CORE_STRINGS_START + 37 ) +#define RID_STR_COMMAND_LEADING_TO_ERROR ( RID_CORE_STRINGS_START + 38 ) +#define RID_STR_STATEMENT_WITHOUT_RESULT_SET ( RID_CORE_STRINGS_START + 39 ) +#define RID_STR_NAME_MUST_NOT_BE_EMPTY ( RID_CORE_STRINGS_START + 40 ) +#define RID_STR_NO_NULL_OBJECTS_IN_CONTAINER ( RID_CORE_STRINGS_START + 41 ) +#define RID_STR_NAME_ALREADY_USED ( RID_CORE_STRINGS_START + 42 ) +#define RID_STR_OBJECT_CONTAINER_MISMATCH ( RID_CORE_STRINGS_START + 43 ) +#define RID_STR_OBJECT_ALREADY_CONTAINED ( RID_CORE_STRINGS_START + 44 ) +#define RID_STR_NAME_NOT_FOUND ( RID_CORE_STRINGS_START + 45 ) +#define RID_STR_QUERY_DOES_NOT_EXIST ( RID_CORE_STRINGS_START + 46 ) +#define RID_STR_ERROR_WHILE_SAVING ( RID_CORE_STRINGS_START + 47 ) +#define RID_STR_NO_SUB_FOLDER ( RID_CORE_STRINGS_START + 48 ) + +#define RID_STR_NO_DELETE_BEFORE_AFTER ( RID_CORE_STRINGS_START + 49 ) +#define RID_STR_NO_DELETE_INSERT_ROW ( RID_CORE_STRINGS_START + 50 ) +#define RID_STR_RESULT_IS_READONLY ( RID_CORE_STRINGS_START + 51 ) +#define RID_STR_NO_DELETE_PRIVILEGE ( RID_CORE_STRINGS_START + 52 ) +#define RID_STR_ROW_ALREADY_DELETED ( RID_CORE_STRINGS_START + 53 ) +#define RID_STR_UPDATE_FAILED ( RID_CORE_STRINGS_START + 54 ) + +#define RID_STR_INVALID_INDEX ( RID_CORE_STRINGS_START + 55 ) +#define RID_STR_NO_INSERT_PRIVILEGE ( RID_CORE_STRINGS_START + 56 ) +#define RID_STR_INTERNAL_ERROR ( RID_CORE_STRINGS_START + 57 ) +#define RID_STR_EXPRESSION1 ( RID_CORE_STRINGS_START + 58 ) +#define RID_STR_NO_SQL_COMMAND ( RID_CORE_STRINGS_START + 59 ) +#define RID_STR_INVALID_CURSOR_STATE ( RID_CORE_STRINGS_START + 60 ) +#define RID_STR_CURSOR_BEFORE_OR_AFTER ( RID_CORE_STRINGS_START + 61 ) +#define RID_STR_NO_BOOKMARK_BEFORE_OR_AFTER ( RID_CORE_STRINGS_START + 62 ) +#define RID_STR_NO_BOOKMARK_DELETED ( RID_CORE_STRINGS_START + 63 ) +#define RID_STR_NO_EMBEDDING ( RID_CORE_STRINGS_START + 64 ) +#define RID_STR_CONNECTION_REQUEST ( RID_CORE_STRINGS_START + 65 ) +#define RID_STR_MISSING_EXTENSION ( RID_CORE_STRINGS_START + 66 ) + +#define RID_NO_SUCH_DATA_SOURCE ( RID_CORE_STRINGS_START + 67 ) + +#endif // _DBA_CORE_RESOURCE_HRC_ + diff --git a/dbaccess/source/core/inc/core_resource.hxx b/dbaccess/source/core/inc/core_resource.hxx new file mode 100644 index 000000000000..fd8023e15322 --- /dev/null +++ b/dbaccess/source/core/inc/core_resource.hxx @@ -0,0 +1,130 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_CORE_RESOURCE_HXX_ +#define _DBA_CORE_RESOURCE_HXX_ + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif +#include <osl/mutex.hxx> + +class ResMgr; +//......................................................................... +namespace dbaccess +{ + +#define DBA_RES( id ) ResourceManager::loadString( id ) +#define DBA_RES_PARAM( id, ascii, replace ) ResourceManager::loadString( id, ascii, replace ) + +#define DBACORE_RESSTRING( id ) DBA_RES( id ) + // (compatibility) + + //================================================================== + //= ResourceManager + //= handling ressources within the DBA-Core library + //================================================================== + class ResourceManager + { + friend class OModuleClient; + static ::osl::Mutex s_aMutex; /// access safety + static sal_Int32 s_nClients; /// number of registered clients + static ResMgr* m_pImpl; + + private: + // no instantiation allowed + ResourceManager() { } + ~ResourceManager() { } + + protected: + static void ensureImplExists(); + /// register a client for the module + static void registerClient(); + /// revoke a client for the module + static void revokeClient(); + + public: + /** loads the string with the specified resource id + */ + static ::rtl::OUString loadString(sal_uInt16 _nResId); + + /** loads a string from the resource file, substituting a placeholder with a given string + + @param _nResId + the resource ID of the string to load + @param _pPlaceholderAscii + the ASCII representation of the placeholder string + @param _rReplace + the string which should substitute the placeholder + */ + static ::rtl::OUString loadString( + sal_uInt16 _nResId, + const sal_Char* _pPlaceholderAscii, + const ::rtl::OUString& _rReplace + ); + + /** loads a string from the resource file, substituting two placeholders with given strings + + @param _nResId + the resource ID of the string to load + @param _pPlaceholderAscii1 + the ASCII representation of the first placeholder string + @param _rReplace1 + the string which should substitute the first placeholder + @param _pPlaceholderAscii2 + the ASCII representation of the second placeholder string + @param _rReplace2 + the string which should substitute the second placeholder + */ + static ::rtl::OUString loadString( + sal_uInt16 _nResId, + const sal_Char* _pPlaceholderAscii1, + const ::rtl::OUString& _rReplace1, + const sal_Char* _pPlaceholderAscii2, + const ::rtl::OUString& _rReplace2 + ); + }; + + //========================================================================= + //= OModuleClient + //========================================================================= + /** base class for objects which uses any global module-specific ressources + */ + class OModuleClient + { + public: + OModuleClient() { ResourceManager::registerClient(); } + ~OModuleClient() { ResourceManager::revokeClient(); } + }; + + +//......................................................................... +} +//......................................................................... + +#endif // _DBA_CORE_RESOURCE_HXX_ + diff --git a/dbaccess/source/core/inc/datasettings.hxx b/dbaccess/source/core/inc/datasettings.hxx new file mode 100644 index 000000000000..9b42c7d57cf9 --- /dev/null +++ b/dbaccess/source/core/inc/datasettings.hxx @@ -0,0 +1,109 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_CORE_DATASETTINGS_HXX_ +#define _DBA_CORE_DATASETTINGS_HXX_ + +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_ +#include <com/sun/star/beans/Property.hpp> +#endif +#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ +#include <com/sun/star/awt/FontDescriptor.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#endif +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif +#ifndef COMPHELPER_PROPERTYSTATECONTAINER_HXX +#include <comphelper/propertystatecontainer.hxx> +#endif + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + +//========================================================================== +//= ODataSettings_Base - a base class which implements the property member +//= for an object implementing the sdb::DataSettings +//= service +//= the properties have to to be registered when used +//========================================================================== +class ODataSettings_Base +{ +public: +// <properties> + ::rtl::OUString m_sFilter; + ::rtl::OUString m_sHavingClause; + ::rtl::OUString m_sGroupBy; + ::rtl::OUString m_sOrder; + sal_Bool m_bApplyFilter; // no BitField ! the base class needs a pointer to this member ! + ::com::sun::star::awt::FontDescriptor m_aFont; + ::com::sun::star::uno::Any m_aRowHeight; + ::com::sun::star::uno::Any m_aTextColor; + ::com::sun::star::uno::Any m_aTextLineColor; + sal_Int16 m_nFontEmphasis; + sal_Int16 m_nFontRelief; +// </properties> + +protected: + ODataSettings_Base(); + ODataSettings_Base(const ODataSettings_Base& _rSource); + ~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 +{ + sal_Bool m_bQuery; +protected: + ODataSettings(::cppu::OBroadcastHelper& _rBHelper,sal_Bool _bQuery = sal_False); + virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const; + + /** register the properties from the param given. The parameter instance must be alive as long as tis object live. + @param _pItem + The database settings, can be <br>this</br> + */ + void registerPropertiesFor(ODataSettings_Base* _pItem); +}; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // _DBA_CORE_DATASETTINGS_HXX_ + diff --git a/dbaccess/source/core/inc/dbamiscres.hrc b/dbaccess/source/core/inc/dbamiscres.hrc new file mode 100644 index 000000000000..a383ed4189d2 --- /dev/null +++ b/dbaccess/source/core/inc/dbamiscres.hrc @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_MISCRES_HRC_ +#define _DBA_MISCRES_HRC_ + +//======================================================================== +// string ids (relative to other resources, that's why not unique) +#define STR_MYSQL_ODBC 1 +#define STR_MYSQL_JDBC 2 +#define STR_ADABAS 3 +#define STR_ORACLE_JDBC 4 +#define STR_JDBC 5 +#define STR_ODBC 6 +#define STR_DBASE 7 +#define STR_MSACCESS 8 +#define STR_MSACCESS2007 9 +#define STR_ADO 10 +#define STR_FLAT 11 +#define STR_CALC 12 +#define STR_MOZILLA 13 +#define STR_LDAP 14 +#define STR_OUTLOOK 15 +#define STR_OUTLOOKEXP 16 +#define STR_EVOLUTION 17 +#define STR_EVOLUTION_GROUPWISE 18 +#define STR_EVOLUTION_LDAP 19 +#define STR_KAB 20 +#define STR_MACAB 21 +#define STR_EMBEDDED_HSQLDB 22 +#define STR_THUNDERBIRD 23 +#define STR_MYSQL_NATIVE 24 + +#define STR_END STR_MYSQL_NATIVE + 1 + + +#endif // _DBA_MISCRES_HRC_ + diff --git a/dbaccess/source/core/inc/definitioncolumn.hxx b/dbaccess/source/core/inc/definitioncolumn.hxx new file mode 100644 index 000000000000..185e7d1426d8 --- /dev/null +++ b/dbaccess/source/core/inc/definitioncolumn.hxx @@ -0,0 +1,318 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _DBACORE_DEFINITIONCOLUMN_HXX_ +#define _DBACORE_DEFINITIONCOLUMN_HXX_ + +#include "apitools.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/container/XChild.hpp> + +#include <comphelper/IdPropArrayHelper.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/implbase1.hxx> + + +namespace dbaccess +{ + + typedef ::cppu::ImplHelper1< ::com::sun::star::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 + { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent; + const bool m_bActAsDescriptor; + + protected: + // <properties> + rtl::OUString m_aTypeName; + rtl::OUString m_aDescription; + rtl::OUString m_aDefaultValue; + rtl::OUString m_aAutoIncrementValue; + sal_Int32 m_nType; + sal_Int32 m_nPrecision; + sal_Int32 m_nScale; + sal_Int32 m_nIsNullable; + sal_Bool m_bAutoIncrement; + sal_Bool m_bRowVersion; + sal_Bool m_bCurrency; + // </properties> + + public: + OTableColumnDescriptor( const bool _bActAsDescriptor ) + :OColumn( !_bActAsDescriptor ) + ,m_bActAsDescriptor( _bActAsDescriptor ) + ,m_nType( ::com::sun::star::sdbc::DataType::SQLNULL ) + ,m_nPrecision( 0 ) + ,m_nScale( 0 ) + ,m_nIsNullable( ::com::sun::star::sdbc::ColumnValue::NULLABLE_UNKNOWN ) + ,m_bAutoIncrement( sal_False ) + ,m_bRowVersion( sal_False ) + ,m_bCurrency( sal_False ) + { + impl_registerProperties(); + } + + DECLARE_XINTERFACE( ) + + // com::sun::star::lang::XTypeProvider + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::lang::XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::container::XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + + // ::comphelper::OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; + + // ::cppu::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception); + + 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(); + + public: + OTableColumn(const ::rtl::OUString& _rName); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; + }; + + // ========================================================================= + // = 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> + ::rtl::OUString m_sCatalogName; + ::rtl::OUString m_sSchemaName; + ::rtl::OUString m_sTableName; + ::rtl::OUString m_sRealName; + ::rtl::OUString m_sLabel; + // </properties> + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xOriginalTableColumn; + + protected: + ~OQueryColumn(); + + public: + OQueryColumn( + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxParserColumn, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + const ::rtl::OUString i_sLabel + ); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + + // *Property* + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; + virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + impl_determineOriginalTableColumn( + const ::com::sun::star::uno::Reference< ::com::sun::star::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! + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + m_xAggregate; + + sal_Int32 m_nColTypeID; + + protected: + OColumnWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rCol, const bool _bNameIsReadOnly ); + virtual ~OColumnWrapper(); + + public: + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const; + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + + protected: + ::rtl::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 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol, + const bool _bPureWrap, const bool _bIsDescriptor ); + + // com::sun::star::lang::XTypeProvider + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::lang::XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // OIdPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const; + + // cppu::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle + ) const; + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + + 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: + ~OTableColumnWrapper(); + + public: + OTableColumnWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rCol, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rColDefintion, + const bool _bPureWrap ); + + // ::com::sun::star::lang::XTypeProvider + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::lang::XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // OIdPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const; + }; +} +#endif // _DBACORE_DEFINITIONCOLUMN_HXX_ + diff --git a/dbaccess/source/core/inc/definitioncontainer.hxx b/dbaccess/source/core/inc/definitioncontainer.hxx new file mode 100644 index 000000000000..d70a0813e18c --- /dev/null +++ b/dbaccess/source/core/inc/definitioncontainer.hxx @@ -0,0 +1,375 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_CORE_DEFINITIONCONTAINER_HXX_ +#define _DBA_CORE_DEFINITIONCONTAINER_HXX_ + +#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_ +#include <cppuhelper/interfacecontainer.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE7_HXX_ +#include <cppuhelper/implbase7.hxx> +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include <comphelper/stl_types.hxx> +#endif +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ +#include <com/sun/star/container/XChild.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_ +#include <com/sun/star/container/XContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_ +#include <com/sun/star/container/XEnumerationAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_ +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XVETOABLECHANGELISTENER_HPP_ +#include <com/sun/star/beans/XVetoableChangeListener.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERAPPROVEBROADCASTER_HPP_ +#include <com/sun/star/container/XContainerApproveBroadcaster.hpp> +#endif +#ifndef DBA_CONTENTHELPER_HXX +#include "ContentHelper.hxx" +#endif +#ifndef DBACCESS_CONTAINERAPPROVE_HXX +#include "containerapprove.hxx" +#endif +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif +#ifndef _RTL_REF_HXX_ +#include <rtl/ref.hxx> +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif +//........................................................................ +namespace dbaccess +{ +//........................................................................ + +class ODefinitionContainer_Impl : public OContentHelper_Impl +{ +public: + typedef ::std::map< ::rtl::OUString, TContentPtr > NamedDefinitions; + typedef NamedDefinitions::iterator iterator; + typedef NamedDefinitions::const_iterator const_iterator; + +private: + NamedDefinitions m_aDefinitions; + +public: + inline size_t size() const { return m_aDefinitions.size(); } + + inline const_iterator begin() const { return m_aDefinitions.begin(); } + inline const_iterator end() const { return m_aDefinitions.end(); } + + inline const_iterator find( const ::rtl::OUString& _rName ) const { return m_aDefinitions.find( _rName ); } + const_iterator find( TContentPtr _pDefinition ) const; + + inline void erase( const ::rtl::OUString& _rName ) { m_aDefinitions.erase( _rName ); } + void erase( TContentPtr _pDefinition ); + + inline void insert( const ::rtl::OUString& _rName, TContentPtr _pDefinition ) + { + m_aDefinitions.insert( NamedDefinitions::value_type( _rName, _pDefinition ) ); + } + +private: + iterator find( 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 < ::com::sun::star::container::XIndexAccess + , ::com::sun::star::container::XNameContainer + , ::com::sun::star::container::XEnumerationAccess + , ::com::sun::star::container::XContainer + , ::com::sun::star::container::XContainerApproveBroadcaster + , ::com::sun::star::beans::XPropertyChangeListener + , ::com::sun::star::beans::XVetoableChangeListener + > ODefinitionContainer_Base; + +class ODefinitionContainer + :public OContentHelper + ,public ODefinitionContainer_Base +{ +protected: + DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::WeakReference< ::com::sun::star::ucb::XContent >, Documents); + DECLARE_STL_VECTOR(Documents::iterator, DocumentsIndexAccess); + + 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 + DocumentsIndexAccess m_aDocuments; // for a efficient index access + Documents m_aDocumentMap; // for a efficient name access + + ::cppu::OInterfaceContainerHelper + m_aApproveListeners; + ::cppu::OInterfaceContainerHelper + m_aContainerListeners; + + sal_Bool m_bInPropertyChange; + bool m_bCheckSlash; + +protected: + /** Additionally to our own approvals which new elements must pass, derived classes + can specifiy 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; } + PContainerApprove getElementApproval() const { return m_pElementApproval; } + +protected: + virtual ~ODefinitionContainer(); + + inline const ODefinitionContainer_Impl& getDefinitions() const + { + return dynamic_cast< const ODefinitionContainer_Impl& >( *m_pImpl.get() ); + } + + inline ODefinitionContainer_Impl& getDefinitions() + { + return dynamic_cast< ODefinitionContainer_Impl& >( *m_pImpl.get() ); + } +public: + /** constructs the container. + */ + ODefinitionContainer( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB + , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer + , const TContentPtr& _pImpl + , bool _bCheckSlash = true + ); + +// ::com::sun::star::uno::XInterface + DECLARE_XINTERFACE( ) +// com::sun::star::lang::XTypeProvider + DECLARE_TYPEPROVIDER( ); + +// ::com::sun::star::lang::XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::container::XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::container::XEnumerationAccess + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 _nIndex ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::container::XNameContainer + virtual void SAL_CALL insertByName( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByName( const ::rtl::OUString& _rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::container::XNameReplace + virtual void SAL_CALL replaceByName( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::container::XNameAccess + virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::container::XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); + + // XContainerApproveBroadcaster + virtual void SAL_CALL addContainerApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerApproveListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerApproveListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + + // XPropertyChangeListener + virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException); + // XVetoableChangeListener + virtual void SAL_CALL vetoableChange( const ::com::sun::star::beans::PropertyChangeEvent& aEvent ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException); + +protected: + // helper + virtual void SAL_CALL disposing(); + + /** create a object from it's 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 somthing went wrong + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > createObject( + const ::rtl::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 _bReadIfNeccessary 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 + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > + implGetByName(const ::rtl::OUString& _rName, sal_Bool _bCreateIfNecessary) throw (::com::sun::star::container::NoSuchElementException); + + /** quickly checks if there already is an element with a given name. No access to the configuration occures, 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 sal_Bool checkExistence(const ::rtl::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 ::rtl::OUString& _rName, + const ::com::sun::star::uno::Reference< ::com::sun::star::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 ::rtl::OUString& _rName); + + /** remove a 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 informations 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 ::rtl::OUString& _rName, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _rxNewObject + ); + + /** notifies our container/approve listeners + */ + void notifyByName( + ::osl::ResettableMutexGuard& _rGuard, + const ::rtl::OUString& _rName, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xNewElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& xOldElement, + ContainerOperation _eOperation, + ListenerType _eType + ); + + inline SAL_CALL operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > () const + { + return const_cast< XContainer* >( static_cast< const XContainer* >( this ) ); + } + +private: + void addObjectListener(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xNewObject); + void removeObjectListener(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xNewObject); + + /** approve that the object given may be inserted into the container. Should be overloaded 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 occures which prevents insertion of the object into the container + */ + void approveNewObject( + const ::rtl::OUString& _sName, + const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _rxObject + ) const; + + inline bool impl_haveAnyListeners_nothrow() const + { + return ( m_aContainerListeners.getLength() > 0 ) || ( m_aApproveListeners.getLength() > 0 ); + } +}; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // _DBA_CORE_DEFINITIONCONTAINER_HXX_ + diff --git a/dbaccess/source/core/inc/module_dba.hxx b/dbaccess/source/core/inc/module_dba.hxx new file mode 100644 index 000000000000..03a5faefa1d2 --- /dev/null +++ b/dbaccess/source/core/inc/module_dba.hxx @@ -0,0 +1,45 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACCESS_MODULE_DBA_HXX +#define DBACCESS_MODULE_DBA_HXX + +#include <unotools/componentresmodule.hxx> + +//........................................................................ +namespace dba +{ +//........................................................................ + + DEFINE_MODULE( DbaModule, DbaClient, DbaRes ) + +//........................................................................ +} // namespace sdbtools +//........................................................................ + +#endif // DBACCESS_MODULE_DBA_HXX + diff --git a/dbaccess/source/core/inc/object.hxx b/dbaccess/source/core/inc/object.hxx new file mode 100644 index 000000000000..917cc9e05e42 --- /dev/null +++ b/dbaccess/source/core/inc/object.hxx @@ -0,0 +1,40 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_OBJECT_HXX_ +#define _DBA_OBJECT_HXX_ + +enum ObjectType +{ + dbaTable, + dbaQuery, + dbaForm, + dbaReport +}; + +#endif // _DBA_OBJECT_HXX_ + diff --git a/dbaccess/source/core/inc/objectnameapproval.hxx b/dbaccess/source/core/inc/objectnameapproval.hxx new file mode 100644 index 000000000000..bea104c77443 --- /dev/null +++ b/dbaccess/source/core/inc/objectnameapproval.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACCESS_OBJECTNAMEAPPROVAL_HXX +#define DBACCESS_OBJECTNAMEAPPROVAL_HXX + +#ifndef DBACCESS_CONTAINERAPPROVE_HXX +#include "containerapprove.hxx" +#endif + +/** === begin UNO includes === **/ +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +/** === end UNO includes === **/ + +//........................................................................ +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::auto_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 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + ObjectType _eType + ); + virtual ~ObjectNameApproval(); + + // IContainerApprove + virtual void SAL_CALL approveElement( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxElement ); + + }; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // DBACCESS_OBJECTNAMEAPPROVAL_HXX diff --git a/dbaccess/source/core/inc/preparedstatement.hxx b/dbaccess/source/core/inc/preparedstatement.hxx new file mode 100644 index 000000000000..e0df114b22af --- /dev/null +++ b/dbaccess/source/core/inc/preparedstatement.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _DBA_COREAPI_PREPAREDSTATEMENT_HXX_ +#define _DBA_COREAPI_PREPAREDSTATEMENT_HXX_ + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_ +#include <com/sun/star/sdbc/XPreparedStatement.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_ +#include <com/sun/star/sdbc/XParameters.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_ +#include <com/sun/star/sdbc/XParameters.hpp> +#endif +#ifndef _DBA_COREAPI_STATEMENT_HXX_ +#include <statement.hxx> +#endif +#ifndef _DBA_COREAPI_COLUMN_HXX_ +#include <column.hxx> +#endif + +namespace dbaccess +{ + //************************************************************ + // OPreparedStatement + //************************************************************ + class OPreparedStatement : public OStatementBase, + public ::com::sun::star::sdbc::XPreparedStatement, + public ::com::sun::star::sdbc::XParameters, + public ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + public ::com::sun::star::sdbcx::XColumnsSupplier, + public ::com::sun::star::lang::XServiceInfo + { + protected: + OColumns* m_pColumns; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters > m_xAggregateAsParameters; + + public: + OPreparedStatement(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement); + virtual ~OPreparedStatement(); + + // ::com::sun::star::lang::XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::uno::XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + + // ::com::sun::star::lang::XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + + // ::com::sun::star::sdbc::XPreparedStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::sdbcx::XColumnsSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::sdbc::XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::sdbc::XParameters + virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} +#endif // _DBA_COREAPI_PREPAREDSTATEMENT_HXX_ + diff --git a/dbaccess/source/core/inc/querycomposer.hxx b/dbaccess/source/core/inc/querycomposer.hxx new file mode 100644 index 000000000000..839e5e39a772 --- /dev/null +++ b/dbaccess/source/core/inc/querycomposer.hxx @@ -0,0 +1,139 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX +#define DBACCESS_CORE_API_QUERYCOMPOSER_HXX + +#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ +#include <connectivity/CommonTools.hxx> +#endif +#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSER_HPP_ +#include <com/sun/star/sdb/XSQLQueryComposer.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ +#include <com/sun/star/sdb/XParametersSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_ +#include <com/sun/star/script/XTypeConverter.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE5_HXX_ +#include <cppuhelper/implbase5.hxx> +#endif +#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ +#include <connectivity/sqliterator.hxx> +#endif +#ifndef _CONNECTIVITY_SQLPARSE_HXX +#include <connectivity/sqlparse.hxx> +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif +#ifndef _COMPHELPER_BROADCASTHELPER_HXX_ +#include <comphelper/broadcasthelper.hxx> +#endif +#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#endif + + + +namespace com { namespace sun { namespace star { namespace util { + class XNumberFormatsSupplier; + class XNumberFormatter; +}}}} + +namespace dbaccess +{ + typedef ::cppu::ImplHelper5< ::com::sun::star::sdb::XSQLQueryComposer, + ::com::sun::star::sdb::XParametersSupplier, + ::com::sun::star::sdbcx::XTablesSupplier, + ::com::sun::star::sdbcx::XColumnsSupplier, + ::com::sun::star::lang::XServiceInfo > OQueryComposer_BASE; + + class OPrivateColumns; + class OPrivateTables; + + class OQueryComposer : public ::comphelper::OBaseMutex, + public OSubComponent, + public OQueryComposer_BASE + { + ::std::vector< ::rtl::OUString> m_aFilters; + ::std::vector< ::rtl::OUString> m_aOrders; + ::rtl::OUString m_sOrgFilter; + ::rtl::OUString m_sOrgOrder; + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer> m_xComposer; + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer> m_xComposerHelper; + + protected: + virtual void SAL_CALL disposing(); + virtual ~OQueryComposer(); + public: + + OQueryComposer( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection ); + + // ::com::sun::star::lang::XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::uno::XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) + throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + // XSQLQueryComposer + virtual ::rtl::OUString SAL_CALL getQuery( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setQuery( const ::rtl::OUString& command ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getComposedQuery( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getFilter( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getStructuredFilter( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getOrder( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendFilterByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendOrderByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool ascending ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFilter( const ::rtl::OUString& filter ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setOrder( const ::rtl::OUString& order ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XTablesSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException); + // XColumnsSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException); + // XParametersSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getParameters( ) throw(::com::sun::star::uno::RuntimeException); + }; +} +#endif // DBACCESS_CORE_API_QUERYCOMPOSER_HXX diff --git a/dbaccess/source/core/inc/querycontainer.hxx b/dbaccess/source/core/inc/querycontainer.hxx new file mode 100644 index 000000000000..9502a7002aa7 --- /dev/null +++ b/dbaccess/source/core/inc/querycontainer.hxx @@ -0,0 +1,234 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_CORE_QUERYCONTAINER_HXX_ +#define _DBA_CORE_QUERYCONTAINER_HXX_ + +#ifndef _CPPUHELPER_IMPLBASE5_HXX_ +#include <cppuhelper/implbase5.hxx> +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include <comphelper/stl_types.hxx> +#endif +#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_ +#include <cppuhelper/interfacecontainer.hxx> +#endif + +/** === begin UNO includes == **/ +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_ +#include <com/sun/star/container/XEnumerationAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_ +#include <com/sun/star/container/XContainerListener.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_ +#include <com/sun/star/container/XContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_ +#include <com/sun/star/util/XRefreshable.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ +#include <com/sun/star/sdbcx/XAppend.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_ +#include <com/sun/star/sdbcx/XDrop.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_ +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERAPPROVELISTENER_HPP_ +#include <com/sun/star/container/XContainerApproveListener.hpp> +#endif +/** === end UNO includes === **/ + +#ifndef _DBA_CORE_DEFINITIONCONTAINER_HXX_ +#include "definitioncontainer.hxx" +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif + +namespace dbtools +{ + class IWarningsContainer; +} + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + typedef ::cppu::ImplHelper5 < ::com::sun::star::container::XContainerListener + , ::com::sun::star::container::XContainerApproveListener + , ::com::sun::star::sdbcx::XDataDescriptorFactory + , ::com::sun::star::sdbcx::XAppend + , ::com::sun::star::sdbcx::XDrop + > OQueryContainer_Base; + + //========================================================================== + //= OQueryContainer + //========================================================================== + class OQueryContainer; + class OContainerListener; + class OQuery; + class OQueryContainer : public ODefinitionContainer + , public OQueryContainer_Base + { + protected: + ::dbtools::IWarningsContainer* m_pWarnings; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + m_xCommandDefinitions; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > + m_xConnection; + // possible actions on our "aggregate" + enum AGGREGATE_ACTION { NONE, INSERTING, FLUSHING }; + AGGREGATE_ACTION m_eDoingCurrently; + + OContainerListener* m_pCommandsListener; + + // ------------------------------------------------------------------------ + /** a class which automatically resets m_eDoingCurrently in it's destructor + */ + class OAutoActionReset; // just for the following friend declaration + friend class OAutoActionReset; + class OAutoActionReset + { + OQueryContainer* m_pActor; + public: + OAutoActionReset(OQueryContainer* _pActor) : m_pActor(_pActor) { } + ~OAutoActionReset() { m_pActor->m_eDoingCurrently = NONE; } + }; + + // ODefinitionContainer + virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > createObject( const ::rtl::OUString& _rName); + virtual sal_Bool checkExistence(const ::rtl::OUString& _rName); + + // helper + virtual void SAL_CALL disposing(); + virtual ~OQueryContainer(); + public: + /** ctor of the container. The parent has to support the <type scope="com::sun::star::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 exceptionts (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 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxCommandDefinitions, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, + ::dbtools::IWarningsContainer* _pWarnings + ); + + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + DECLARE_SERVICE_INFO(); + + // ::com::sun::star::container::XContainerListener + virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); + + // XContainerApproveListener + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveInsertElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveReplaceElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XVeto > SAL_CALL approveRemoveElement( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::sdbcx::XDataDescriptorFactory + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::sdbcx::XAppend + virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::sdbcx::XDrop + virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::container::XElementAccess + virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::container::XNameAccess + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException); + + protected: + // OContentHelper overridables + virtual ::rtl::OUString determineContentType() const; + + private: + // 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. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > implCreateWrapper(const ::rtl::OUString& _rName); + /// create a query object wrapping a CommandDefinition. The returned object is acquired once. + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > implCreateWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _rxCommandDesc); + + }; +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // _DBA_CORE_QUERYCONTAINER_HXX_ + + diff --git a/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx b/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx new file mode 100644 index 000000000000..4aa124dc7015 --- /dev/null +++ b/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx @@ -0,0 +1,92 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +#ifndef DBACCESS_DBDOCRECOVERY_HXX +#define DBACCESS_DBDOCRECOVERY_HXX + +#include "dbaccessdllapi.h" + +/** === begin UNO includes === **/ +#include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/frame/XController.hpp> +/** === end UNO includes === **/ + +#include <vector> +#include <memory> + +namespace comphelper +{ + class ComponentContext; +} + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + //==================================================================== + //= DatabaseDocumentRecovery + //==================================================================== + struct DatabaseDocumentRecovery_Data; + class DBACCESS_DLLPRIVATE DatabaseDocumentRecovery + { + public: + DatabaseDocumentRecovery( + const ::comphelper::ComponentContext& i_rContext + ); + ~DatabaseDocumentRecovery(); + + /** saves the modified sub components of the given controller(s) to the "recovery" sub storage of the document + storage. + + @throws ::com::sun::star::uno::Exception + in case of an error. + */ + void saveModifiedSubComponents( + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rTargetStorage, + const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::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 ::com::sun::star::uno::Exception + in case of an error. + */ + void recoverSubDocuments( + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& i_rDocumentStorage, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& i_rTargetController + ); + + private: + const ::std::auto_ptr< DatabaseDocumentRecovery_Data > m_pData; + }; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // DBACCESS_DBDOCRECOVERY_HXX diff --git a/dbaccess/source/core/inc/sdbcoretools.hxx b/dbaccess/source/core/inc/sdbcoretools.hxx new file mode 100644 index 000000000000..d6044a6b9110 --- /dev/null +++ b/dbaccess/source/core/inc/sdbcoretools.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACORE_SDBCORETOOLS_HXX +#define DBACORE_SDBCORETOOLS_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/io/IOException.hpp> +#include <com/sun/star/lang/WrappedTargetException.hpp> +#include <com/sun/star/uno/RuntimeException.hpp> +/** === end UNO includes === **/ + +namespace comphelper +{ + class ComponentContext; +} + +//......................................................................... +namespace dbaccess +{ +//......................................................................... + + // ----------------------------------------------------------------------------- + void notifyDataSourceModified(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject,sal_Bool _bModified); + + // ----------------------------------------------------------------------------- + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + getDataSource( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDependentObject ); + + // ----------------------------------------------------------------------------- + + // ----------------------------------------------------------------------------- + /** retrieves a to-be-displayed string for a given caught exception; + */ + ::rtl::OUString extractExceptionMessage( const ::comphelper::ComponentContext& _rContext, const ::com::sun::star::uno::Any& _rError ); + + namespace tools + { + namespace stor + { + bool storageIsWritable_nothrow( + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage + ); + + /// commits a given storage if it's not readonly + bool commitStorageIfWriteable( + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxStorage + ) + SAL_THROW(( + ::com::sun::star::io::IOException, + ::com::sun::star::lang::WrappedTargetException + )); + } + + } + +} // namespace dbaccess +//......................................................................... + +#endif // DBACORE_SDBCORETOOLS_HXX + diff --git a/dbaccess/source/core/inc/statement.hxx b/dbaccess/source/core/inc/statement.hxx new file mode 100644 index 000000000000..ae821c7a516b --- /dev/null +++ b/dbaccess/source/core/inc/statement.hxx @@ -0,0 +1,220 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _DBA_COREAPI_STATEMENT_HXX_ +#define _DBA_COREAPI_STATEMENT_HXX_ + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XSTATEMENT_HPP_ +#include <com/sun/star/sdbc/XStatement.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_ +#include <com/sun/star/util/XCancellable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_ +#include <com/sun/star/sdbc/XCloseable.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XMULTIPLERESULTS_HDL_ +#include <com/sun/star/sdbc/XMultipleResults.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HDL_ +#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp> +#endif +#include <com/sun/star/sdbc/XBatchExecution.hpp> +#ifndef _COM_SUN_STAR_SDBC_XGENERATEDRESULTSET_HPP_ +#include <com/sun/star/sdbc/XGeneratedResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#endif +#ifndef _CPPUHELPER_PROPSHLP_HXX +#include <cppuhelper/propshlp.hxx> +#endif +#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_ +#include <comphelper/proparrhlp.hxx> +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif +#ifndef _COMPHELPER_BROADCASTHELPER_HXX_ +#include <comphelper/broadcasthelper.hxx> +#endif + +#include <cppuhelper/implbase3.hxx> + +//************************************************************ +// OStatementBase +//************************************************************ +class OStatementBase : public comphelper::OBaseMutex, + public OSubComponent, + public ::cppu::OPropertySetHelper, + public ::comphelper::OPropertyArrayUsageHelper < OStatementBase >, + public ::com::sun::star::util::XCancellable, + public ::com::sun::star::sdbc::XWarningsSupplier, + public ::com::sun::star::sdbc::XPreparedBatchExecution, + public ::com::sun::star::sdbc::XMultipleResults, + public ::com::sun::star::sdbc::XCloseable, + public ::com::sun::star::sdbc::XGeneratedResultSet +{ +protected: + ::osl::Mutex m_aCancelMutex; + + ::com::sun::star::uno::WeakReferenceHelper m_aResultSet; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xAggregateAsSet; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XCancellable > m_xAggregateAsCancellable; + sal_Bool m_bUseBookmarks; + sal_Bool m_bEscapeProcessing; + + virtual ~OStatementBase(); + +public: + OStatementBase(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement); + + +// ::com::sun::star::lang::XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::uno::XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + +// OComponentHelper + virtual void SAL_CALL disposing(void); + +// com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + +// comphelper::OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + +// cppu::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue + ) + throw (::com::sun::star::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; + +// ::com::sun::star::sdbc::XWarningsSupplier + virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::util::XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::sdbc::XCloseable + virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::sdbc::XMultipleResults + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::sdbc::XPreparedBatchExecution + virtual void SAL_CALL addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); +// ::com::sun::star::sdbc::XGeneratedResultSet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getGeneratedValues( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + +// Helper + void disposeResultSet(); + +protected: + using ::cppu::OPropertySetHelper::getFastPropertyValue; +}; + +//************************************************************ +// OStatement +//************************************************************ +typedef ::cppu::ImplHelper3 < ::com::sun::star::sdbc::XStatement + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::sdbc::XBatchExecution + > OStatement_IFACE; +class OStatement :public OStatementBase + ,public OStatement_IFACE +{ +private: + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > m_xAggregateStatement; + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer; + bool m_bAttemptedComposerCreation; + +public: + OStatement(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _xConn, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & _xStatement); + + DECLARE_XINTERFACE() + DECLARE_XTYPEPROVIDER() + +// ::com::sun::star::lang::XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + +// ::com::sun::star::sdbc::XStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // XBatchExecution + virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + using OStatementBase::addBatch; + +private: + /** does escape processing for the given SQL command, if the our EscapeProcessing + property allows so. + */ + ::rtl::OUString impl_doEscapeProcessing_nothrow( const ::rtl::OUString& _rSQL ) const; + bool impl_ensureComposer_nothrow() const; +}; + +#endif // _DBA_COREAPI_STATEMENT_HXX_ + diff --git a/dbaccess/source/core/inc/table.hxx b/dbaccess/source/core/inc/table.hxx new file mode 100644 index 000000000000..95e984949619 --- /dev/null +++ b/dbaccess/source/core/inc/table.hxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_CORE_TABLE_HXX_ +#define _DBA_CORE_TABLE_HXX_ + +#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/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> + +#include <cppuhelper/compbase7.hxx> +#include "apitools.hxx" +#include "datasettings.hxx" +#include <column.hxx> +#include <connectivity/CommonTools.hxx> +#include <connectivity/TTableHelper.hxx> +#include <comphelper/uno3.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: + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xColumnDefinitions; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xDriverColumns; + + // <properties> + sal_Int32 m_nPrivileges; + // </properties> + + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const; + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + // IColumnFactory + virtual OColumn* createColumn(const ::rtl::OUString& _rName) const; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor(); + virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor ); + virtual void columnDropped(const ::rtl::OUString& _sName); + + /** creates the column collection for the table + @param _rNames + The column names. + */ + virtual ::connectivity::sdbcx::OCollection* createColumns(const ::connectivity::TStringVector& _rNames); + + /** creates the key collection for the table + @param _rNames + The key names. + */ + virtual ::connectivity::sdbcx::OCollection* createKeys(const ::connectivity::TStringVector& _rNames); + + /** creates the index collection for the table + @param _rNames + The index names. + */ + virtual ::connectivity::sdbcx::OCollection* createIndexes(const ::connectivity::TStringVector& _rNames); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + 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 + */ + ODBTable(connectivity::sdbcx::OCollection* _pTables + ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn + ,const ::rtl::OUString& _rCatalog + , const ::rtl::OUString& _rSchema + , const ::rtl::OUString& _rName + ,const ::rtl::OUString& _rType + , const ::rtl::OUString& _rDesc + ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumnDefinitions) + throw(::com::sun::star::sdbc::SQLException); + + ODBTable(connectivity::sdbcx::OCollection* _pTables + ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn) + throw(::com::sun::star::sdbc::SQLException); + virtual ~ODBTable(); + + // ODescriptor + virtual void construct(); + + //XInterface + DECLARE_XINTERFACE() + //XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); + + // ::com::sun::star::lang::XServiceInfo + DECLARE_SERVICE_INFO(); + + // com::sun::star::beans::XPropertySet + // virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const; + + // ::com::sun::star::sdbcx::XRename, + virtual void SAL_CALL rename( const ::rtl::OUString& _rNewName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::sdbcx::XAlterTable, + virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + + // com::sun::star::lang::XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + + private: + using OTable_Base::createArrayHelper; + using OTable_Base::getFastPropertyValue; + }; +} +#endif // _DBA_CORE_TABLE_HXX_ + + diff --git a/dbaccess/source/core/inc/tablecontainer.hxx b/dbaccess/source/core/inc/tablecontainer.hxx new file mode 100644 index 000000000000..5e64e8896d55 --- /dev/null +++ b/dbaccess/source/core/inc/tablecontainer.hxx @@ -0,0 +1,149 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_CORE_TABLECONTAINER_HXX_ +#define _DBA_CORE_TABLECONTAINER_HXX_ + +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include <comphelper/stl_types.hxx> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_ +#include <com/sun/star/container/XEnumerationAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_ +#include <com/sun/star/util/XRefreshable.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdbc/XConnection.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_ +#include <com/sun/star/container/XContainerListener.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef DBACCESS_CORE_FILTERED_CONTAINER_HXX +#include "FilteredContainer.hxx" +#endif +#ifndef DBTOOLS_WARNINGSCONTAINER_HXX +#include <connectivity/warningscontainer.hxx> +#endif +#ifndef DBA_CORE_REFRESHLISTENER_HXX +#include "RefreshListener.hxx" +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif + +namespace dbaccess +{ + typedef ::cppu::ImplHelper1< ::com::sun::star::container::XContainerListener> OTableContainer_Base; + + //========================================================================== + //= OTableContainer + //========================================================================== + class OTable; + class OTableContainer; + class OContainerMediator; + + class OTableContainer : public OFilteredContainer, + public OTableContainer_Base + { + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xTableDefinitions; + ::rtl::Reference< OContainerMediator > m_pTableMediator; + sal_Bool m_bInDrop; // set when we are in the drop method + + + // OFilteredContainer + virtual void addMasterContainerListener(); + virtual void removeMasterContainerListener(); + virtual ::rtl::OUString getTableTypeRestriction() const; + + // ::connectivity::sdbcx::OCollection + virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor(); + virtual connectivity::sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ); + virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName); + + virtual void SAL_CALL disposing(); + + inline virtual void SAL_CALL acquire() throw(){ OFilteredContainer::acquire();} + inline virtual void SAL_CALL release() throw(){ OFilteredContainer::release();} + // ::com::sun::star::lang::XServiceInfo + DECLARE_SERVICE_INFO(); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + // XContainerListener + virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + public: + /** ctor of the container. The parent has to support the <type scope="com::sun::star::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 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xCon, + sal_Bool _bCase, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _xTableDefinitions, + IRefreshListener* _pRefreshListener, + ::dbtools::IWarningsContainer* _pWarningsContainer, + oslInterlockedCount& _nInAppend + ); + + virtual ~OTableContainer(); + }; +} +#endif // _DBA_CORE_TABLECONTAINER_HXX_ + + diff --git a/dbaccess/source/core/inc/userinformation.hxx b/dbaccess/source/core/inc/userinformation.hxx new file mode 100644 index 000000000000..24dbbb206f2c --- /dev/null +++ b/dbaccess/source/core/inc/userinformation.hxx @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_CORE_USERINFORMATION_HXX_ +#define _DBA_CORE_USERINFORMATION_HXX_ + +#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ +#include <com/sun/star/lang/Locale.hpp> +#endif + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif + +class UserInformation +{ + ::com::sun::star::lang::Locale m_aUserLocale; + +public: + UserInformation(); + + ::com::sun::star::lang::Locale getUserLanguage() const { return m_aUserLocale; } +}; + +#endif // _DBA_CORE_USERINFORMATION_HXX_ + diff --git a/dbaccess/source/core/inc/veto.hxx b/dbaccess/source/core/inc/veto.hxx new file mode 100644 index 000000000000..00de76c7b73e --- /dev/null +++ b/dbaccess/source/core/inc/veto.hxx @@ -0,0 +1,79 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACCESS_VETO_HXX +#define DBACCESS_VETO_HXX + +/** === begin UNO includes === **/ +#ifndef _COM_SUN_STAR_UTIL_XVETO_HPP_ +#include <com/sun/star/util/XVeto.hpp> +#endif +/** === end UNO includes === **/ + +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + //==================================================================== + //= Veto + //==================================================================== + typedef ::cppu::WeakImplHelper1 < ::com::sun::star::util::XVeto + > Veto_Base; + /** implements ::com::sun::star::util::XVeto + */ + class Veto : public Veto_Base + { + private: + const ::rtl::OUString m_sReason; + const ::com::sun::star::uno::Any m_aDetails; + + public: + Veto( const ::rtl::OUString& _rReason, const ::com::sun::star::uno::Any& _rDetails ); + + virtual ::rtl::OUString SAL_CALL getReason() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getDetails() throw (::com::sun::star::uno::RuntimeException); + + protected: + ~Veto(); + + private: + Veto(); // never implemented + Veto( const Veto& ); // never implemented + Veto& operator=( const Veto& ); // never implemented + }; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // DBACCESS_VETO_HXX + diff --git a/dbaccess/source/core/inc/viewcontainer.hxx b/dbaccess/source/core/inc/viewcontainer.hxx new file mode 100644 index 000000000000..beb5c08e6350 --- /dev/null +++ b/dbaccess/source/core/inc/viewcontainer.hxx @@ -0,0 +1,139 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DBA_CORE_VIEWCONTAINER_HXX_ +#define _DBA_CORE_VIEWCONTAINER_HXX_ + +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include <comphelper/stl_types.hxx> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_ +#include <com/sun/star/container/XEnumerationAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_ +#include <com/sun/star/util/XRefreshable.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ +#include <com/sun/star/sdbc/SQLWarning.hpp> +#endif +#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ +#include <com/sun/star/sdb/SQLContext.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTAINERLISTENER_HPP_ +#include <com/sun/star/container/XContainerListener.hpp> +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif + +#ifndef DBACCESS_CORE_FILTERED_CONTAINER_HXX +#include "FilteredContainer.hxx" +#endif + +namespace dbtools +{ + class IWarningsContainer; +} + +namespace dbaccess +{ + typedef ::cppu::ImplHelper1< ::com::sun::star::container::XContainerListener> OViewContainer_Base; + + //========================================================================== + //= OViewContainer + //========================================================================== + class OViewContainer : public OFilteredContainer, + public OViewContainer_Base + { + public: + /** ctor of the container. The parent has to support the <type scope="com::sun::star::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 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xCon, + sal_Bool _bCase, + IRefreshListener* _pRefreshListener, + ::dbtools::IWarningsContainer* _pWarningsContainer, + oslInterlockedCount& _nInAppend + ); + + virtual ~OViewContainer(); + + protected: + // OFilteredContainer overridables + virtual ::rtl::OUString getTableTypeRestriction() const; + + private: + inline virtual void SAL_CALL acquire() throw(){ OFilteredContainer::acquire();} + inline virtual void SAL_CALL release() throw(){ OFilteredContainer::release();} + // ::com::sun::star::lang::XServiceInfo + DECLARE_SERVICE_INFO(); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + // XContainerListener + virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + // ::connectivity::sdbcx::OCollection + virtual ::connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor(); + virtual connectivity::sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ); + virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName); + + using OFilteredContainer::disposing; + + bool m_bInElementRemoved; + }; +} +#endif // _DBA_CORE_VIEWCONTAINER_HXX_ + + |