summaryrefslogtreecommitdiff
path: root/dbaccess/source/core/misc
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/core/misc')
-rw-r--r--dbaccess/source/core/misc/ContainerListener.cxx131
-rw-r--r--dbaccess/source/core/misc/ContainerMediator.cxx281
-rw-r--r--dbaccess/source/core/misc/DatabaseDataProvider.cxx1009
-rw-r--r--dbaccess/source/core/misc/PropertyForward.cxx173
-rw-r--r--dbaccess/source/core/misc/apitools.cxx155
-rw-r--r--dbaccess/source/core/misc/dbastrings.cxx49
-rw-r--r--dbaccess/source/core/misc/dsntypes.cxx629
-rw-r--r--dbaccess/source/core/misc/makefile.mk60
-rw-r--r--dbaccess/source/core/misc/module_dba.cxx43
-rw-r--r--dbaccess/source/core/misc/objectnameapproval.cxx116
-rw-r--r--dbaccess/source/core/misc/sdbcoretools.cxx175
-rw-r--r--dbaccess/source/core/misc/services.cxx138
-rw-r--r--dbaccess/source/core/misc/userinformation.cxx59
-rw-r--r--dbaccess/source/core/misc/veto.cxx78
14 files changed, 3096 insertions, 0 deletions
diff --git a/dbaccess/source/core/misc/ContainerListener.cxx b/dbaccess/source/core/misc/ContainerListener.cxx
new file mode 100644
index 000000000000..efdd32c1fee3
--- /dev/null
+++ b/dbaccess/source/core/misc/ContainerListener.cxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBA_CONTAINERLISTENER_HXX
+#include "ContainerListener.hxx"
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::container::ContainerEvent;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::container::XContainerApproveListener;
+ using ::com::sun::star::container::XContainerListener;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::util::XVeto;
+ using ::com::sun::star::uno::Reference;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= OContainerListener
+ //====================================================================
+ //--------------------------------------------------------------------
+ OContainerListener::~OContainerListener()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XVeto > SAL_CALL OContainerListener::approveInsertElement( const ContainerEvent& _Event ) throw (WrappedTargetException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return NULL;
+
+ return dynamic_cast< XContainerApproveListener& >( m_rDestination ).approveInsertElement( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XVeto > SAL_CALL OContainerListener::approveReplaceElement( const ContainerEvent& _Event ) throw (WrappedTargetException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return NULL;
+
+ return dynamic_cast< XContainerApproveListener& >( m_rDestination ).approveReplaceElement( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XVeto > SAL_CALL OContainerListener::approveRemoveElement( const ContainerEvent& _Event ) throw (WrappedTargetException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return NULL;
+
+ return dynamic_cast< XContainerApproveListener& >( m_rDestination ).approveRemoveElement( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OContainerListener::elementInserted( const ContainerEvent& _Event ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return;
+
+ dynamic_cast< XContainerListener& >( m_rDestination ).elementInserted( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OContainerListener::elementRemoved( const ContainerEvent& _Event ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return;
+
+ dynamic_cast< XContainerListener& >( m_rDestination ).elementRemoved( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OContainerListener::elementReplaced( const ContainerEvent& _Event ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return;
+
+ dynamic_cast< XContainerListener& >( m_rDestination ).elementReplaced( _Event );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OContainerListener::disposing( const EventObject& _Source ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return;
+
+ dynamic_cast< XContainerListener& >( m_rDestination ).disposing( _Source );
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/misc/ContainerMediator.cxx b/dbaccess/source/core/misc/ContainerMediator.cxx
new file mode 100644
index 000000000000..7d7ea80f558a
--- /dev/null
+++ b/dbaccess/source/core/misc/ContainerMediator.cxx
@@ -0,0 +1,281 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBA_CONTAINERMEDIATOR_HXX
+#include "ContainerMediator.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef DBA_PROPERTYSETFORWARD_HXX
+#include "PropertyForward.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#include <com/sun/star/sdbcx/XRename.hpp>
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+
+DBG_NAME(OContainerMediator)
+OContainerMediator::OContainerMediator( const Reference< XContainer >& _xContainer, const Reference< XNameAccess >& _xSettings,
+ const Reference< XConnection >& _rxConnection, ContainerType _eType )
+ : m_xSettings( _xSettings )
+ , m_xContainer( _xContainer )
+ , m_aConnection( _rxConnection )
+ , m_eType( _eType )
+{
+ DBG_CTOR(OContainerMediator,NULL);
+
+ if ( _xSettings.is() && _xContainer.is() )
+ {
+ osl_incrementInterlockedCount(&m_refCount);
+ try
+ {
+ m_xContainer->addContainerListener(this);
+ Reference< XContainer > xContainer(_xSettings, UNO_QUERY);
+ if ( xContainer.is() )
+ xContainer->addContainerListener(this);
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "OContainerMediator::OContainerMediator: caught an exception!");
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+ else
+ {
+ m_xSettings.clear();
+ m_xContainer.clear();
+ }
+}
+// -----------------------------------------------------------------------------
+OContainerMediator::~OContainerMediator()
+{
+ DBG_DTOR(OContainerMediator,NULL);
+ acquire();
+ impl_cleanup_nothrow();
+}
+
+// -----------------------------------------------------------------------------
+void OContainerMediator::impl_cleanup_nothrow()
+{
+ try
+ {
+ Reference< XContainer > xContainer( m_xSettings, UNO_QUERY );
+ if ( xContainer.is() )
+ xContainer->removeContainerListener( this );
+ m_xSettings.clear();
+
+ xContainer = m_xContainer;
+ if ( xContainer.is() )
+ xContainer->removeContainerListener( this );
+ m_xContainer.clear();
+
+ m_aForwardList.clear();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OContainerMediator::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if ( _rEvent.Source == m_xSettings && m_xSettings.is() )
+ {
+ ::rtl::OUString sElementName;
+ _rEvent.Accessor >>= sElementName;
+ PropertyForwardList::iterator aFind = m_aForwardList.find(sElementName);
+ if ( aFind != m_aForwardList.end() )
+ {
+ Reference< XPropertySet> xDest(_rEvent.Element,UNO_QUERY);
+ aFind->second->setDefinition( xDest );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OContainerMediator::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ Reference< XContainer > xContainer = m_xContainer;
+ if ( _rEvent.Source == xContainer && xContainer.is() )
+ {
+ ::rtl::OUString sElementName;
+ _rEvent.Accessor >>= sElementName;
+ m_aForwardList.erase(sElementName);
+ try
+ {
+ Reference<XNameContainer> xNameContainer( m_xSettings, UNO_QUERY );
+ if ( xNameContainer.is() && m_xSettings->hasByName( sElementName ) )
+ xNameContainer->removeByName( sElementName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OContainerMediator::elementReplaced( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ Reference< XContainer > xContainer = m_xContainer;
+ if ( _rEvent.Source == xContainer && xContainer.is() )
+ {
+ ::rtl::OUString sElementName;
+ _rEvent.ReplacedElement >>= sElementName;
+
+ PropertyForwardList::iterator aFind = m_aForwardList.find(sElementName);
+ if ( aFind != m_aForwardList.end() )
+ {
+ ::rtl::OUString sNewName;
+ _rEvent.Accessor >>= sNewName;
+ try
+ {
+ Reference<XNameContainer> xNameContainer( m_xSettings, UNO_QUERY_THROW );
+ if ( xNameContainer.is() && m_xSettings->hasByName( sElementName ) )
+ {
+ Reference<XRename> xSource(m_xSettings->getByName(sElementName),UNO_QUERY_THROW);
+ xSource->rename(sNewName);
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ aFind->second->setName(sNewName);
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OContainerMediator::disposing( const EventObject& /*Source*/ ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ impl_cleanup_nothrow();
+}
+
+// -----------------------------------------------------------------------------
+void OContainerMediator::impl_initSettings_nothrow( const ::rtl::OUString& _rName, const Reference< XPropertySet >& _rxDestination )
+{
+ try
+ {
+ if ( m_xSettings.is() && m_xSettings->hasByName( _rName ) )
+ {
+ Reference< XPropertySet > xSettings( m_xSettings->getByName( _rName ), UNO_QUERY_THROW );
+ ::comphelper::copyProperties( xSettings, _rxDestination );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OContainerMediator::notifyElementCreated( const ::rtl::OUString& _sName, const Reference< XPropertySet >& _xDest )
+{
+ if ( !m_xSettings.is() )
+ return;
+
+ PropertyForwardList::iterator aFind = m_aForwardList.find( _sName );
+ if ( aFind != m_aForwardList.end()
+ && aFind->second->getDefinition().is()
+ )
+ {
+ OSL_ENSURE( false, "OContainerMediator::notifyElementCreated: is this really a valid case?" );
+ return;
+ }
+
+ ::std::vector< ::rtl::OUString > aPropertyList;
+ try
+ {
+ // initially copy from the settings object (if existent) to the newly created object
+ impl_initSettings_nothrow( _sName, _xDest );
+
+ // collect the to-be-monitored properties
+ Reference< XPropertySetInfo > xPSI( _xDest->getPropertySetInfo(), UNO_QUERY_THROW );
+ Sequence< Property > aProperties( xPSI->getProperties() );
+ const Property* property = aProperties.getConstArray();
+ const Property* propertyEnd = aProperties.getConstArray() + aProperties.getLength();
+ for ( ; property != propertyEnd; ++property )
+ {
+ if ( ( property->Attributes & PropertyAttribute::READONLY ) != 0 )
+ continue;
+ if ( ( property->Attributes & PropertyAttribute::BOUND ) == 0 )
+ continue;
+
+ aPropertyList.push_back( property->Name );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ ::rtl::Reference< OPropertyForward > pForward( new OPropertyForward( _xDest, m_xSettings, _sName, aPropertyList ) );
+ m_aForwardList[ _sName ] = pForward;
+}
+// -----------------------------------------------------------------------------
+//........................................................................
+} // namespace dbaccess
+//........................................................................
diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
new file mode 100644
index 000000000000..a83b04d93471
--- /dev/null
+++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
@@ -0,0 +1,1009 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "DatabaseDataProvider.hxx"
+#include "dbastrings.hrc"
+#include "cppuhelper/implbase1.hxx"
+#include <comphelper/types.hxx>
+#include <connectivity/FValue.hxx>
+#include <connectivity/dbtools.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/math.hxx>
+
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/sdb/XCompletedExecution.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart/XChartDataArray.hpp>
+
+#include <vector>
+#include <list>
+
+namespace dbaccess
+{
+using namespace ::com::sun::star;
+using ::com::sun::star::sdbc::SQLException;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::RuntimeException;
+// -----------------------------------------------------------------------------
+DatabaseDataProvider::DatabaseDataProvider(uno::Reference< uno::XComponentContext > const & context) :
+ TDatabaseDataProvider(m_aMutex),
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >(
+ context, static_cast< Implements >(
+ IMPLEMENTS_PROPERTY_SET), uno::Sequence< ::rtl::OUString >()),
+ m_aParameterManager( m_aMutex, uno::Reference< lang::XMultiServiceFactory >(context->getServiceManager(),uno::UNO_QUERY) ),
+ m_aFilterManager( uno::Reference< lang::XMultiServiceFactory >(context->getServiceManager(),uno::UNO_QUERY) ),
+ m_xContext(context),
+ m_CommandType(sdb::CommandType::COMMAND), // #i94114
+ m_RowLimit(0),
+ m_EscapeProcessing(sal_True),
+ m_ApplyFilter(sal_True)
+{
+ m_xInternal.set( m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart.InternalDataProvider")),m_xContext ), uno::UNO_QUERY );
+ m_xRangeConversion.set(m_xInternal,uno::UNO_QUERY);
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ m_xRowSet.set( m_xContext->getServiceManager()->createInstanceWithContext(SERVICE_SDB_ROWSET,m_xContext ), uno::UNO_QUERY );
+ m_xAggregate.set(m_xRowSet,uno::UNO_QUERY);
+ m_xAggregateSet.set(m_xRowSet,uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xProp(static_cast< ::cppu::OWeakObject* >( this ),uno::UNO_QUERY);
+ m_aFilterManager.initialize( m_xAggregateSet );
+ m_aParameterManager.initialize( xProp, m_xAggregate );
+ m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND_TYPE,uno::makeAny(m_CommandType));
+ m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,uno::makeAny(m_EscapeProcessing));
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::disposing()
+{
+ lang::EventObject aEvt(static_cast<XWeak*>(this));
+ m_aParameterManager.disposing( aEvt );
+
+ m_aParameterManager.dispose(); // (to free any references it may have to me)
+ m_aFilterManager.dispose(); // (dito)
+
+ m_xParent.clear();
+ m_xAggregateSet.clear();
+ m_xAggregate.clear();
+ m_xRangeConversion.clear();
+ ::comphelper::disposeComponent(m_xRowSet);
+ ::comphelper::disposeComponent(m_xInternal);
+ m_xActiveConnection.clear();
+}
+// -----------------------------------------------------------------------------
+uno::Any DatabaseDataProvider::queryInterface(uno::Type const & type) throw (uno::RuntimeException)
+{
+ return TDatabaseDataProvider::queryInterface(type);
+}
+// -----------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+rtl::OUString DatabaseDataProvider::getImplementationName_Static( ) throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.chart2.data.DatabaseDataProvider");
+}
+// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+// XServiceInfo
+::rtl::OUString SAL_CALL DatabaseDataProvider::getImplementationName( ) throw(uno::RuntimeException)
+{
+ return getImplementationName_Static();
+}
+// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::supportsService( const ::rtl::OUString& _rServiceName ) throw(uno::RuntimeException)
+{
+ return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
+}
+// -----------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+uno::Sequence< ::rtl::OUString > DatabaseDataProvider::getSupportedServiceNames_Static( ) throw (uno::RuntimeException)
+{
+ uno::Sequence< rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DatabaseDataProvider"));
+ return aSNS;
+}
+// -----------------------------------------------------------------------------
+uno::Sequence< ::rtl::OUString > SAL_CALL DatabaseDataProvider::getSupportedServiceNames( ) throw(uno::RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// -----------------------------------------------------------------------------
+uno::Reference< uno::XInterface > DatabaseDataProvider::Create(uno::Reference< uno::XComponentContext > const & context)
+{
+ return *(new DatabaseDataProvider(context)) ;
+}
+// -----------------------------------------------------------------------------
+// lang::XInitialization:
+void SAL_CALL DatabaseDataProvider::initialize(const uno::Sequence< uno::Any > & aArguments) throw (uno::RuntimeException, uno::Exception)
+{
+ osl::MutexGuard g(m_aMutex);
+ const uno::Any* pIter = aArguments.getConstArray();
+ const uno::Any* pEnd = pIter + aArguments.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( !m_xActiveConnection.is() )
+ (*pIter) >>= m_xActiveConnection;
+ else if ( !m_xHandler.is() )
+ (*pIter) >>= m_xHandler;
+ }
+ m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, uno::makeAny( m_xActiveConnection ) );
+}
+// -----------------------------------------------------------------------------
+
+// chart2::data::XDataProvider:
+::sal_Bool SAL_CALL DatabaseDataProvider::createDataSourcePossible(const uno::Sequence< beans::PropertyValue > & _aArguments) throw (uno::RuntimeException)
+{
+ //::osl::ResettableMutexGuard aClearForNotifies(m_aMutex);
+ const beans::PropertyValue* pArgIter = _aArguments.getConstArray();
+ const beans::PropertyValue* pArgEnd = pArgIter + _aArguments.getLength();
+ for(;pArgIter != pArgEnd;++pArgIter)
+ {
+ if ( pArgIter->Name.equalsAscii("DataRowSource") )
+ {
+ ::com::sun::star::chart::ChartDataRowSource eRowSource = ::com::sun::star::chart::ChartDataRowSource_COLUMNS;
+ pArgIter->Value >>= eRowSource;
+ if ( eRowSource != ::com::sun::star::chart::ChartDataRowSource_COLUMNS )
+ return sal_False;
+ } // if ( pArgIter->Name.equalsAscii("DataRowSource") )
+ else if ( pArgIter->Name.equalsAscii("CellRangeRepresentation") )
+ {
+ ::rtl::OUString sRange;
+ pArgIter->Value >>= sRange;
+ if ( !sRange.equalsAscii("all") )
+ return sal_False;
+ }
+ else if ( pArgIter->Name.equalsAscii("FirstCellAsLabel") )
+ {
+ sal_Bool bFirstCellAsLabel = sal_True;
+ pArgIter->Value >>= bFirstCellAsLabel;
+ if ( !bFirstCellAsLabel )
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::createDataSource(const uno::Sequence< beans::PropertyValue > & _aArguments) throw (uno::RuntimeException, lang::IllegalArgumentException)
+{
+ osl::ResettableMutexGuard aClearForNotifies(m_aMutex);
+ if ( createDataSourcePossible(_aArguments) )
+ {
+ sal_Bool bHasCategories = sal_True;
+ uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames;
+ const beans::PropertyValue* pArgIter = _aArguments.getConstArray();
+ const beans::PropertyValue* pArgEnd = pArgIter + _aArguments.getLength();
+ for(;pArgIter != pArgEnd;++pArgIter)
+ {
+ if ( pArgIter->Name.equalsAscii("HasCategories") )
+ {
+ pArgIter->Value >>= bHasCategories;
+
+ }
+ else if ( pArgIter->Name.equalsAscii("ComplexColumnDescriptions") )
+ {
+ pArgIter->Value >>= aColumnNames;
+ }
+ }
+ bool bRet = false;
+ if ( m_Command.getLength() != 0 && m_xActiveConnection.is() )
+ {
+ try
+ {
+ impl_fillRowSet_throw();
+ impl_executeRowSet_throw(aClearForNotifies);
+ impl_fillInternalDataProvider_throw(bHasCategories,aColumnNames);
+ bRet = true;
+ }
+ catch(const uno::Exception& /*e*/)
+ {
+ }
+ }
+ if ( !bRet ) // no command set or an error occured, use Internal data handler
+ {
+ uno::Reference< lang::XInitialization> xIni(m_xInternal,uno::UNO_QUERY);
+ if ( xIni.is() )
+ {
+ uno::Sequence< uno::Any > aArgs(1);
+ beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True));
+ aArgs[0] <<= aParam;
+ xIni->initialize(aArgs);
+ }
+ }
+
+ }
+ return m_xInternal->createDataSource(_aArguments);
+}
+// -----------------------------------------------------------------------------
+
+uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArguments(const uno::Reference< chart2::data::XDataSource > & _xDataSource) throw (uno::RuntimeException)
+{
+ uno::Sequence< beans::PropertyValue > aArguments( 4 );
+ aArguments[0] = beans::PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellRangeRepresentation")), -1, uno::Any(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ),
+ beans::PropertyState_DIRECT_VALUE );
+ aArguments[1] = beans::PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataRowSource")), -1, uno::makeAny( chart::ChartDataRowSource_COLUMNS ),
+ beans::PropertyState_DIRECT_VALUE );
+ // internal data always contains labels and categories
+ aArguments[2] = beans::PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FirstCellAsLabel")), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
+ sal_Bool bHasCategories = sal_False;
+ if( _xDataSource.is())
+ {
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(_xDataSource->getDataSequences());
+ const sal_Int32 nCount( aSequences.getLength());
+ for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
+ {
+ if( aSequences[nIdx].is() )
+ {
+ uno::Reference< beans::XPropertySet > xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY );
+ ::rtl::OUString aRole;
+ if( xSeqProp.is() &&
+ (xSeqProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Role"))) >>= aRole) &&
+ aRole.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("categories")) )
+ {
+ bHasCategories = sal_True;
+ break;
+ }
+ }
+ }
+ }
+
+ aArguments[3] = beans::PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasCategories")), -1, uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE );
+ return aArguments;
+}
+// -----------------------------------------------------------------------------
+
+::sal_Bool SAL_CALL DatabaseDataProvider::createDataSequenceByRangeRepresentationPossible(const ::rtl::OUString & /*aRangeRepresentation*/) throw (uno::RuntimeException)
+{
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+uno::Any DatabaseDataProvider::impl_getNumberFormatKey_nothrow(const ::rtl::OUString & _sRangeRepresentation) const
+{
+ ::std::map< ::rtl::OUString,com::sun::star::uno::Any>::const_iterator aFind = m_aNumberFormats.find(_sRangeRepresentation);
+ if ( aFind != m_aNumberFormats.end() )
+ return aFind->second;
+ return uno::makeAny(sal_Int32(0));
+}
+// -----------------------------------------------------------------------------
+uno::Reference< chart2::data::XDataSequence > SAL_CALL DatabaseDataProvider::createDataSequenceByRangeRepresentation(const ::rtl::OUString & _sRangeRepresentation) throw (uno::RuntimeException, lang::IllegalArgumentException)
+{
+ osl::MutexGuard g(m_aMutex);
+ uno::Reference< chart2::data::XDataSequence > xData = m_xInternal->createDataSequenceByRangeRepresentation(_sRangeRepresentation);;
+ uno::Reference<beans::XPropertySet> xProp(xData,uno::UNO_QUERY);
+ const static ::rtl::OUString s_sNumberFormatKey(RTL_CONSTASCII_USTRINGPARAM("NumberFormatKey"));
+ if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(s_sNumberFormatKey) )
+ {
+ xProp->setPropertyValue(s_sNumberFormatKey,impl_getNumberFormatKey_nothrow(_sRangeRepresentation));
+ }
+ return xData;
+}
+// -----------------------------------------------------------------------------
+
+uno::Reference< sheet::XRangeSelection > SAL_CALL DatabaseDataProvider::getRangeSelection() throw (uno::RuntimeException)
+{
+ // TODO: Exchange the default return implementation for "getRangeSelection" !!!
+ // Exchange the default return implementation.
+ // NOTE: Default initialized polymorphic structs can cause problems because of
+ // missing default initialization of primitive types of some C++ compilers or
+ // different Any initialization in Java and C++ polymorphic structs.
+ return uno::Reference< sheet::XRangeSelection >();
+}
+// -----------------------------------------------------------------------------
+// chart2::data::XRangeXMLConversion:
+::rtl::OUString SAL_CALL DatabaseDataProvider::convertRangeToXML(const ::rtl::OUString & _sRangeRepresentation) throw (uno::RuntimeException, lang::IllegalArgumentException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_xRangeConversion->convertRangeToXML(_sRangeRepresentation);
+}
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL DatabaseDataProvider::convertRangeFromXML(const ::rtl::OUString & _sXMLRange) throw (uno::RuntimeException, lang::IllegalArgumentException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_xRangeConversion->convertRangeFromXML(_sXMLRange);
+}
+// -----------------------------------------------------------------------------
+
+// com.sun.star.beans.XPropertySet:
+uno::Reference< beans::XPropertySetInfo > SAL_CALL DatabaseDataProvider::getPropertySetInfo() throw (uno::RuntimeException)
+{
+ return ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::getPropertySetInfo();
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setPropertyValue(const ::rtl::OUString & aPropertyName, const uno::Any & aValue) throw (uno::RuntimeException, beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException)
+{
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::setPropertyValue(aPropertyName, aValue);
+}
+// -----------------------------------------------------------------------------
+
+uno::Any SAL_CALL DatabaseDataProvider::getPropertyValue(const ::rtl::OUString & aPropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException)
+{
+ return ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::getPropertyValue(aPropertyName);
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::addPropertyChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XPropertyChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException)
+{
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::addPropertyChangeListener(aPropertyName, xListener);
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::removePropertyChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XPropertyChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException)
+{
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::removePropertyChangeListener(aPropertyName, xListener);
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::addVetoableChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XVetoableChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException)
+{
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::addVetoableChangeListener(aPropertyName, xListener);
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::removeVetoableChangeListener(const ::rtl::OUString & aPropertyName, const uno::Reference< beans::XVetoableChangeListener > & xListener) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::WrappedTargetException)
+{
+ ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >::removeVetoableChangeListener(aPropertyName, xListener);
+}
+// -----------------------------------------------------------------------------
+
+// chart2::data::XDatabaseDataProvider:
+uno::Sequence< ::rtl::OUString > SAL_CALL DatabaseDataProvider::getMasterFields() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_MasterFields;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setMasterFields(const uno::Sequence< ::rtl::OUString > & the_value) throw (uno::RuntimeException)
+{
+ impl_invalidateParameter_nothrow();
+ set(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MasterFields")),the_value,m_MasterFields);
+}
+// -----------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL DatabaseDataProvider::getDetailFields() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_DetailFields;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setDetailFields(const uno::Sequence< ::rtl::OUString > & the_value) throw (uno::RuntimeException)
+{
+ set(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DetailFields")),the_value,m_DetailFields);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL DatabaseDataProvider::getCommand() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_Command;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setCommand(const ::rtl::OUString & the_value) throw (uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ impl_invalidateParameter_nothrow();
+ m_xAggregateSet->setPropertyValue( PROPERTY_COMMAND, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_COMMAND,the_value,m_Command);
+}
+// -----------------------------------------------------------------------------
+
+::sal_Int32 SAL_CALL DatabaseDataProvider::getCommandType() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_CommandType;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setCommandType(::sal_Int32 the_value) throw (uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_xAggregateSet->setPropertyValue( PROPERTY_COMMAND_TYPE, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_COMMAND_TYPE,the_value,m_CommandType);
+}
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL DatabaseDataProvider::getFilter() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_aFilterManager.getFilterComponent( dbtools::FilterManager::fcPublicFilter );
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setFilter(const ::rtl::OUString & the_value) throw (uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_aFilterManager.setFilterComponent( dbtools::FilterManager::fcPublicFilter, the_value );
+ }
+ set(PROPERTY_FILTER,the_value,m_Filter);
+}
+// -----------------------------------------------------------------------------
+::sal_Bool SAL_CALL DatabaseDataProvider::getApplyFilter() throw (RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_ApplyFilter;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setApplyFilter( ::sal_Bool the_value ) throw (RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_xAggregateSet->setPropertyValue( PROPERTY_APPLYFILTER, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_APPLYFILTER,the_value,m_ApplyFilter);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL DatabaseDataProvider::getHavingClause() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_HavingClause;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setHavingClause( const ::rtl::OUString& the_value ) throw (beans::UnknownPropertyException, uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_xAggregateSet->setPropertyValue( PROPERTY_HAVING_CLAUSE, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_HAVING_CLAUSE,the_value,m_HavingClause);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL DatabaseDataProvider::getGroupBy() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_GroupBy;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setGroupBy( const ::rtl::OUString& the_value ) throw (beans::UnknownPropertyException, uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_xAggregateSet->setPropertyValue( PROPERTY_GROUP_BY, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_GROUP_BY,the_value,m_GroupBy);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL DatabaseDataProvider::getOrder() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_Order;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setOrder( const ::rtl::OUString& the_value ) throw (uno::RuntimeException)
+{
+ {
+ osl::MutexGuard g(m_aMutex);
+ m_xAggregateSet->setPropertyValue( PROPERTY_ORDER, uno::makeAny( the_value ) );
+ }
+ set(PROPERTY_ORDER,the_value,m_Order);
+}
+// -----------------------------------------------------------------------------
+::sal_Bool SAL_CALL DatabaseDataProvider::getEscapeProcessing() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_EscapeProcessing;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setEscapeProcessing(::sal_Bool the_value) throw (uno::RuntimeException)
+{
+ set(PROPERTY_ESCAPE_PROCESSING,the_value,m_EscapeProcessing);
+}
+// -----------------------------------------------------------------------------
+::sal_Int32 SAL_CALL DatabaseDataProvider::getRowLimit() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_RowLimit;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setRowLimit(::sal_Int32 the_value) throw (uno::RuntimeException)
+{
+ set(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RowLimit")),the_value,m_RowLimit);
+}
+// -----------------------------------------------------------------------------
+uno::Reference< sdbc::XConnection > SAL_CALL DatabaseDataProvider::getActiveConnection() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_xActiveConnection;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setActiveConnection(const uno::Reference< sdbc::XConnection > & the_value) throw (uno::RuntimeException, lang::IllegalArgumentException)
+{
+ if ( !the_value.is() )
+ throw lang::IllegalArgumentException();
+ set(PROPERTY_ACTIVE_CONNECTION,the_value,m_xActiveConnection);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL DatabaseDataProvider::getDataSourceName() throw (uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_DataSourceName;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL DatabaseDataProvider::setDataSourceName(const ::rtl::OUString& the_value) throw (uno::RuntimeException)
+{
+ set(PROPERTY_DATASOURCENAME,the_value,m_DataSourceName);
+}
+// -----------------------------------------------------------------------------
+void DatabaseDataProvider::impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies)
+{
+ if ( impl_fillParameters_nothrow(_rClearForNotifies) )
+ m_xRowSet->execute();
+}
+// -----------------------------------------------------------------------------
+void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const uno::Sequence< uno::Sequence< ::rtl::OUString > >& i_aColumnNames)
+{
+ // clear the data before fill the new one
+ uno::Reference< chart::XChartDataArray> xChartData(m_xInternal,uno::UNO_QUERY);
+ if ( xChartData.is() )
+ {
+ xChartData->setData(uno::Sequence< uno::Sequence<double> >());
+ xChartData->setColumnDescriptions(uno::Sequence< ::rtl::OUString >());
+ if ( m_xInternal->hasDataByRangeRepresentation(::rtl::OUString::valueOf(sal_Int32(0))) )
+ m_xInternal->deleteSequence(0);
+ }
+
+ uno::Reference< sdbcx::XColumnsSupplier> xColSup(m_xRowSet,uno::UNO_QUERY_THROW);
+ uno::Reference< container::XNameAccess > xColumns = xColSup->getColumns();
+ uno::Sequence< ::rtl::OUString > aColumns;
+ if ( i_aColumnNames.getLength() )
+ {
+ aColumns.realloc(1);
+ aColumns[0] = xColumns->getElementNames()[0];
+ for(sal_Int32 i = 0 ; i < i_aColumnNames.getLength();++i)
+ {
+ if ( i_aColumnNames[i].getLength() )
+ {
+ sal_Int32 nCount = aColumns.getLength();
+ aColumns.realloc(nCount+1);
+ aColumns[nCount] = i_aColumnNames[i][0];
+ }
+ }
+ }
+ else
+ {
+ aColumns = xColumns->getElementNames();
+ }
+ // fill the data
+ uno::Reference< sdbc::XResultSet> xRes(m_xRowSet,uno::UNO_QUERY_THROW);
+ uno::Reference< sdbc::XRow> xRow(m_xRowSet,uno::UNO_QUERY_THROW);
+ uno::Reference< sdbc::XResultSetMetaData> xResultSetMetaData = uno::Reference< sdbc::XResultSetMetaDataSupplier>(m_xRowSet,uno::UNO_QUERY)->getMetaData();
+
+ ::std::vector<sal_Int32> aColumnTypes;
+ uno::Sequence< uno::Any > aLabelArgs(1);
+ const sal_Int32 nCount = aColumns.getLength();
+ if ( nCount )
+ aColumnTypes.push_back(xResultSetMetaData->getColumnType(1));
+ for (sal_Int32 i = 1; i < nCount; ++i)
+ {
+ aColumnTypes.push_back(xResultSetMetaData->getColumnType(i+1));
+ } // for (sal_Int32 i = 1; i < nCount; ++i)
+
+ const ::rtl::OUString* pIter = aColumns.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aColumns.getLength();
+ for(sal_Int32 k = 0;pIter != pEnd;++pIter,++k)
+ {
+ uno::Reference< beans::XPropertySet> xColumn(xColumns->getByName(*pIter),uno::UNO_QUERY);
+ if ( xColumn.is() )
+ {
+ m_aNumberFormats.insert( ::std::map< ::rtl::OUString,uno::Any>::value_type(::rtl::OUString::valueOf(k),xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT)));
+ }
+ }
+
+ ::std::vector< ::rtl::OUString > aRowLabels;
+ ::std::vector< ::std::vector< double > > aDataValues;
+ sal_Int32 nRowCount = 0;
+ ::connectivity::ORowSetValue aValue;
+ while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) )
+ {
+ ++nRowCount;
+
+ aValue.fill(1,aColumnTypes[0],xRow);
+ aRowLabels.push_back(aValue.getString());
+ ::std::vector< double > aRow;
+ for (sal_Int32 j = _bHasCategories ? 2 : 1,i = 0; j <= nCount; ++j,++i)
+ {
+ aValue.fill(j,aColumnTypes[j-1],xRow);
+ if ( aValue.isNull() )
+ {
+ double nValue;
+ ::rtl::math::setNan( &nValue );
+ aRow.push_back(nValue);
+ }
+ else
+ aRow.push_back(aValue.getDouble());
+ } // for (sal_Int32 j = 2,i = 0; j <= nCount; ++j,++i)
+ aDataValues.push_back(aRow);
+ } // while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) )
+
+ // insert default data when no rows exist
+ if ( !nRowCount )
+ {
+ nRowCount = 3;
+ const double fDefaultData[ ] =
+ { 9.10, 3.20, 4.54,
+ 2.40, 8.80, 9.65,
+ 3.10, 1.50, 3.70,
+ 4.30, 9.02, 6.20 };
+ for(sal_Int32 h = 0,k = 0; h < nRowCount; ++h,++k )
+ {
+ aRowLabels.push_back(::rtl::OUString::valueOf(h+1));
+ ::std::vector< double > aRow;
+ const sal_Int32 nSize = sizeof(fDefaultData)/sizeof(fDefaultData[0]);
+ for (sal_Int32 j = 0; j < (nCount-1); ++j,++k)
+ {
+ if ( k >= nSize )
+ k = 0;
+ aRow.push_back(fDefaultData[k]);
+ } // for (sal_Int32 j = 0,k = 0; j < (nCount-1); ++j,++k)
+ aDataValues.push_back(aRow);
+ }
+ } // if ( !nRowCount )
+
+ uno::Reference< chart::XChartDataArray> xData(m_xInternal,uno::UNO_QUERY);
+ xData->setRowDescriptions(uno::Sequence< ::rtl::OUString >(&(*aRowLabels.begin()),aRowLabels.size()));
+ xData->setColumnDescriptions(uno::Sequence< ::rtl::OUString >(aColumns.getArray()+ (_bHasCategories ? 1 : 0),aColumns.getLength() - (_bHasCategories ? 1 : 0) ));
+ uno::Sequence< uno::Sequence< double > > aData(aDataValues.size());
+ uno::Sequence< double >* pDataIter = aData.getArray();
+ uno::Sequence< double >* pDataEnd = pDataIter + aData.getLength();
+ for(sal_Int32 i= 0;pDataIter != pDataEnd; ++pDataIter,++i )
+ {
+ if ( !aDataValues[i].empty() )
+ *pDataIter = uno::Sequence< double >(&(*(aDataValues[i]).begin()),(aDataValues[i]).size());
+ }
+ xData->setData(aData);
+}
+// -----------------------------------------------------------------------------
+void DatabaseDataProvider::impl_fillRowSet_throw()
+{
+ m_xAggregateSet->setPropertyValue( PROPERTY_FILTER, uno::makeAny( getFilter() ) );
+ uno::Reference< sdbc::XParameters> xParam(m_xRowSet,uno::UNO_QUERY_THROW);
+ xParam->clearParameters( );
+}
+// -----------------------------------------------------------------------------
+bool DatabaseDataProvider::impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies)
+{
+ // do we have to fill the parameters again?
+ if ( !m_aParameterManager.isUpToDate() )
+ m_aParameterManager.updateParameterInfo( m_aFilterManager );
+
+ if ( m_aParameterManager.isUpToDate() )
+ return m_aParameterManager.fillParameterValues( m_xHandler, _rClearForNotifies );
+
+ return true;
+}
+// com::sun::star::sdbc::XParameters
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setNull(parameterIndex, sqlType);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setObjectNull(parameterIndex, sqlType, typeName);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setBoolean(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setByte(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setShort(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setInt(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setLong(sal_Int32 parameterIndex, sal_Int64 x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setLong(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setFloat(sal_Int32 parameterIndex, float x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setFloat(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setDouble(sal_Int32 parameterIndex, double x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setDouble(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setString(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setBytes(sal_Int32 parameterIndex, const uno::Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setBytes(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setDate(sal_Int32 parameterIndex, const util::Date& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setDate(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setTime(sal_Int32 parameterIndex, const util::Time& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setTime(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setTimestamp(sal_Int32 parameterIndex, const util::DateTime& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setTimestamp(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setBinaryStream(sal_Int32 parameterIndex, const uno::Reference<io::XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setBinaryStream(parameterIndex, x, length);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setCharacterStream(sal_Int32 parameterIndex, const uno::Reference<io::XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setCharacterStream(parameterIndex, x, length);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setObjectWithInfo(sal_Int32 parameterIndex, const uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setObjectWithInfo(parameterIndex, x, targetSqlType, scale);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setObject(sal_Int32 parameterIndex, const uno::Any& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setObject(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setRef(sal_Int32 parameterIndex, const uno::Reference<sdbc::XRef>& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setRef(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setBlob(sal_Int32 parameterIndex, const uno::Reference<sdbc::XBlob>& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setBlob(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setClob(sal_Int32 parameterIndex, const uno::Reference<sdbc::XClob>& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setClob(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setArray(sal_Int32 parameterIndex, const Reference<sdbc::XArray>& x) throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.setArray(parameterIndex, x);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::clearParameters() throw( SQLException, RuntimeException )
+{
+ m_aParameterManager.clearParameters();
+}
+//==============================================================================
+// com::sun::star::sdbc::XRowSet
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::execute() throw( SQLException, RuntimeException )
+{
+ uno::Sequence< beans::PropertyValue > aEmpty;
+ createDataSource(aEmpty);
+}
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::addRowSetListener(const uno::Reference<sdbc::XRowSetListener>& _rListener) throw( RuntimeException )
+{
+ if (m_xRowSet.is())
+ m_xRowSet->addRowSetListener(_rListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::removeRowSetListener(const uno::Reference<sdbc::XRowSetListener>& _rListener) throw( RuntimeException )
+{
+ if (m_xRowSet.is())
+ m_xRowSet->removeRowSetListener(_rListener);
+}
+//==============================================================================
+// com::sun::star::sdbc::XResultSet
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::next() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->next();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::isBeforeFirst() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->isBeforeFirst();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::isAfterLast() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->isAfterLast();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::isFirst() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->isFirst();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::isLast() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->isLast();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::beforeFirst() throw( SQLException, RuntimeException )
+{
+ m_xRowSet->beforeFirst();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::afterLast() throw( SQLException, RuntimeException )
+{
+ m_xRowSet->afterLast();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::first() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->first();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::last() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->last();
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL DatabaseDataProvider::getRow() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->getRow();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::absolute(sal_Int32 row) throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->absolute(row);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::relative(sal_Int32 rows) throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->relative(rows);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::previous() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->previous();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::refreshRow() throw( SQLException, RuntimeException )
+{
+ m_xRowSet->refreshRow();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::rowUpdated() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->rowUpdated();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::rowInserted() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->rowInserted();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL DatabaseDataProvider::rowDeleted() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->rowDeleted();
+}
+
+//------------------------------------------------------------------------------
+uno::Reference< uno::XInterface > SAL_CALL DatabaseDataProvider::getStatement() throw( SQLException, RuntimeException )
+{
+ return m_xRowSet->getStatement();
+}
+// -----------------------------------------------------------------------------
+uno::Reference< uno::XInterface > SAL_CALL DatabaseDataProvider::getParent( ) throw (uno::RuntimeException)
+{
+ return m_xParent;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL DatabaseDataProvider::setParent( const uno::Reference< uno::XInterface >& _xParent ) throw (lang::NoSupportException, uno::RuntimeException)
+{
+ osl::MutexGuard g(m_aMutex);
+ m_xParent = _xParent;
+}
+// -----------------------------------------------------------------------------
+void DatabaseDataProvider::impl_invalidateParameter_nothrow()
+{
+ osl::MutexGuard g(m_aMutex);
+ m_aParameterManager.clearAllParameterInformation();
+}
+// -----------------------------------------------------------------------------
+} // namespace dbaccess
diff --git a/dbaccess/source/core/misc/PropertyForward.cxx b/dbaccess/source/core/misc/PropertyForward.cxx
new file mode 100644
index 000000000000..4f9aa81ab28c
--- /dev/null
+++ b/dbaccess/source/core/misc/PropertyForward.cxx
@@ -0,0 +1,173 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "PropertyForward.hxx"
+#include "dbastrings.hrc"
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+
+#include <comphelper/property.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::lang;
+
+ DBG_NAME(OPropertyForward)
+
+ //------------------------------------------------------------------------
+ OPropertyForward::OPropertyForward( const Reference< XPropertySet>& _xSource, const Reference< XNameAccess>& _xDestContainer,
+ const ::rtl::OUString& _sName, const ::std::vector< ::rtl::OUString>& _aPropertyList )
+ :m_xSource( _xSource, UNO_SET_THROW )
+ ,m_xDestContainer( _xDestContainer, UNO_SET_THROW )
+ ,m_sName( _sName )
+ ,m_bInInsert( sal_False )
+ {
+ DBG_CTOR(OPropertyForward,NULL);
+
+ osl_incrementInterlockedCount(&m_refCount);
+ try
+ {
+ if ( _aPropertyList.empty() )
+ _xSource->addPropertyChangeListener( ::rtl::OUString(), this );
+ else
+ {
+ ::std::vector< ::rtl::OUString >::const_iterator aIter = _aPropertyList.begin();
+ ::std::vector< ::rtl::OUString >::const_iterator aEnd = _aPropertyList.end();
+ for (; aIter != aEnd ; ++aIter )
+ _xSource->addPropertyChangeListener( *aIter, this );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ // -----------------------------------------------------------------------------
+ OPropertyForward::~OPropertyForward()
+ {
+ DBG_DTOR(OPropertyForward,NULL);
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OPropertyForward::propertyChange( const PropertyChangeEvent& evt ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_xDestContainer.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ try
+ {
+ if ( !m_xDest.is() )
+ {
+ if ( m_xDestContainer->hasByName( m_sName ) )
+ {
+ m_xDest.set( m_xDestContainer->getByName( m_sName ), UNO_QUERY_THROW );
+ }
+ else
+ {
+ Reference< XDataDescriptorFactory > xFactory( m_xDestContainer, UNO_QUERY_THROW );
+ m_xDest.set( xFactory->createDataDescriptor(), UNO_SET_THROW );
+
+ ::comphelper::copyProperties( m_xSource, m_xDest );
+
+ m_bInInsert = sal_True;
+ Reference< XAppend > xAppend( m_xDestContainer, UNO_QUERY_THROW );
+ xAppend->appendByDescriptor( m_xDest );
+ m_bInInsert = sal_False;
+ }
+
+ m_xDestInfo.set( m_xDest->getPropertySetInfo(), UNO_SET_THROW );
+ }
+
+ if ( m_xDestInfo->hasPropertyByName( evt.PropertyName ) )
+ {
+ m_xDest->setPropertyValue( evt.PropertyName, evt.NewValue );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OPropertyForward::disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if ( !m_xSource.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ m_xSource->removePropertyChangeListener( ::rtl::OUString(), this );
+ m_xSource = NULL;
+ m_xDestContainer = NULL;
+ m_xDestInfo = NULL;
+ m_xDest = NULL;
+ }
+
+ // -----------------------------------------------------------------------------
+ void OPropertyForward::setDefinition( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDest )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_bInInsert )
+ return;
+
+ OSL_ENSURE( !m_xDest.is(), "OPropertyForward::setDefinition: definition object is already set!" );
+ try
+ {
+ m_xDest.set( _xDest, UNO_SET_THROW );
+ m_xDestInfo.set( m_xDest->getPropertySetInfo(), UNO_SET_THROW );
+ ::comphelper::copyProperties( m_xDest, m_xSource );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/misc/apitools.cxx b/dbaccess/source/core/misc/apitools.cxx
new file mode 100644
index 000000000000..c53f936df234
--- /dev/null
+++ b/dbaccess/source/core/misc/apitools.cxx
@@ -0,0 +1,155 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace cppu;
+using namespace osl;
+using namespace dbaccess;
+
+//==================================================================================
+//= various helper functions
+//==================================================================================
+//============================================================
+//= OSubComponent
+//============================================================
+DBG_NAME(OSubComponent)
+//--------------------------------------------------------------------------
+OSubComponent::OSubComponent(Mutex& _rMutex, const Reference< XInterface > & xParent)
+ :OComponentHelper(_rMutex)
+ ,m_xParent(xParent)
+{
+ DBG_CTOR(OSubComponent,NULL);
+
+}
+// -----------------------------------------------------------------------------
+OSubComponent::~OSubComponent()
+{
+ m_xParent = NULL;
+
+ DBG_DTOR(OSubComponent,NULL);
+}
+
+// com::sun::star::lang::XTypeProvider
+//--------------------------------------------------------------------------
+Sequence< Type > OSubComponent::getTypes() throw (RuntimeException)
+{
+ OTypeCollection aTypes(::getCppuType( (const Reference< XComponent > *)0 ),
+ ::getCppuType( (const Reference< XTypeProvider > *)0 ),
+ ::getCppuType( (const Reference< XWeak > *)0 ));
+
+ return aTypes.getTypes();
+}
+
+// XInterface
+//--------------------------------------------------------------------------
+void OSubComponent::acquire() throw ( )
+{
+ OComponentHelper::acquire();
+}
+
+//--------------------------------------------------------------------------
+void OSubComponent::release() throw ( )
+{
+ Reference< XInterface > x( xDelegator );
+ if (! x.is())
+ {
+ if (osl_decrementInterlockedCount( &m_refCount ) == 0 )
+ {
+ if (! rBHelper.bDisposed)
+ {
+ // *before* again incrementing our ref count, ensure that our weak connection point
+ // will not create references to us anymore (via XAdapter::queryAdapted)
+ disposeWeakConnectionPoint();
+
+ Reference< XInterface > xHoldAlive( *this );
+ // remember the parent
+ Reference< XInterface > xParent;
+ {
+ MutexGuard aGuard( rBHelper.rMutex );
+ xParent = m_xParent;
+ m_xParent = NULL;
+ }
+
+ OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count (before dispose)!" );
+
+ // First dispose
+ dispose();
+
+ // only the alive ref holds the object
+ OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count (after dispose)!" );
+
+ // release the parent in the ~
+ if (xParent.is())
+ {
+ MutexGuard aGuard( rBHelper.rMutex );
+ m_xParent = xParent;
+ }
+
+ // destroy the object if xHoldAlive decrement the refcount to 0
+ return;
+ }
+ }
+ // restore the reference count
+ osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ // as we cover the job of the componenthelper we use the ...
+ OWeakAggObject::release();
+}
+
+//--------------------------------------------------------------------------
+Any OSubComponent::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aReturn;
+ if (!rType.equals(::getCppuType(static_cast< Reference< XAggregation >* >(NULL))))
+ aReturn = OComponentHelper::queryInterface(rType);
+
+ return aReturn;
+}
+
+
diff --git a/dbaccess/source/core/misc/dbastrings.cxx b/dbaccess/source/core/misc/dbastrings.cxx
new file mode 100644
index 000000000000..80f1427842e8
--- /dev/null
+++ b/dbaccess/source/core/misc/dbastrings.cxx
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+
+namespace dbaccess
+{
+
+#include "stringconstants.inc"
+ //============================================================
+ //= SQLSTATE
+ //============================================================
+ IMPLEMENT_CONSTASCII_USTRING(SQLSTATE_GENERAL, "01000");
+
+ //============================================================
+ //= Properties
+ //============================================================
+ IMPLEMENT_CONSTASCII_USTRING( PROPERTY_APPLYFORMDESIGNMODE, "ApplyFormDesignMode" );
+ IMPLEMENT_CONSTASCII_USTRING( PROPERTY_IS_FORM, "IsForm" );
+ IMPLEMENT_CONSTASCII_USTRING( PROPERTY_PERSISTENT_PATH, "PersistentPath" );
+}
diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx
new file mode 100644
index 000000000000..b21707cb3add
--- /dev/null
+++ b/dbaccess/source/core/misc/dsntypes.cxx
@@ -0,0 +1,629 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "dsntypes.hxx"
+#include "dbamiscres.hrc"
+#include <unotools/confignode.hxx>
+#include <tools/debug.hxx>
+#include <tools/wldcrd.hxx>
+#include <osl/file.hxx>
+#include "dbastrings.hrc"
+#include "core_resource.hxx"
+#include "core_resource.hrc"
+#include <comphelper/documentconstants.hxx>
+
+//.........................................................................
+namespace dbaccess
+{
+//.........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ //using namespace ::com::sun::star::sdbc;
+
+ namespace
+ {
+ void lcl_extractHostAndPort(const String& _sUrl,String& _sHostname,sal_Int32& _nPortNumber)
+ {
+ if ( _sUrl.GetTokenCount(':') >= 2 )
+ {
+ _sHostname = _sUrl.GetToken(0,':');
+ _nPortNumber = _sUrl.GetToken(1,':').ToInt32();
+ }
+ }
+ }
+//=========================================================================
+//= ODsnTypeCollection
+//=========================================================================
+DBG_NAME(ODsnTypeCollection)
+//-------------------------------------------------------------------------
+ODsnTypeCollection::ODsnTypeCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory)
+:m_aDriverConfig(_xFactory)
+,m_xFactory(_xFactory)
+#ifdef DBG_UTIL
+,m_nLivingIterators(0)
+#endif
+{
+ DBG_CTOR(ODsnTypeCollection,NULL);
+ const uno::Sequence< ::rtl::OUString > aURLs = m_aDriverConfig.getURLs();
+ const ::rtl::OUString* pIter = aURLs.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aURLs.getLength();
+ for(;pIter != pEnd;++pIter )
+ {
+ m_aDsnPrefixes.push_back(*pIter);
+ m_aDsnTypesDisplayNames.push_back(m_aDriverConfig.getDriverTypeDisplayName(*pIter));
+ }
+
+ DBG_ASSERT(m_aDsnTypesDisplayNames.size() == m_aDsnPrefixes.size(),
+ "ODsnTypeCollection::ODsnTypeCollection : invalid resources !");
+}
+
+//-------------------------------------------------------------------------
+ODsnTypeCollection::~ODsnTypeCollection()
+{
+ DBG_DTOR(ODsnTypeCollection,NULL);
+ DBG_ASSERT(0 == m_nLivingIterators, "ODsnTypeCollection::~ODsnTypeCollection : there are still living iterator objects!");
+}
+//-------------------------------------------------------------------------
+String ODsnTypeCollection::getTypeDisplayName(const ::rtl::OUString& _sURL) const
+{
+ return m_aDriverConfig.getDriverTypeDisplayName(_sURL);
+}
+//-------------------------------------------------------------------------
+String ODsnTypeCollection::cutPrefix(const ::rtl::OUString& _sURL) const
+{
+ String sURL( _sURL);
+ String sRet;
+ String sOldPattern;
+ StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
+ StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ WildCard aWildCard(*aIter);
+ if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(_sURL) )
+ {
+ if ( aIter->Len() < sURL.Len() )
+ sRet = sURL.Copy(sURL.Match(*aIter));
+ else
+ sRet = sURL.Copy(aIter->Match(sURL));
+ sOldPattern = *aIter;
+ }
+ }
+
+ return sRet;
+}
+
+//-------------------------------------------------------------------------
+String ODsnTypeCollection::getPrefix(const ::rtl::OUString& _sURL) const
+{
+ String sURL( _sURL);
+ String sRet;
+ String sOldPattern;
+ StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
+ StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ WildCard aWildCard(*aIter);
+ if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(sURL) )
+ {
+ if ( aIter->Len() < sURL.Len() )
+ sRet = aIter->Copy(0,sURL.Match(*aIter));
+ else
+ sRet = sURL.Copy(0,aIter->Match(sURL));
+ sRet.EraseTrailingChars('*');
+ sOldPattern = *aIter;
+ }
+ }
+
+ return sRet;
+}
+
+//-------------------------------------------------------------------------
+bool ODsnTypeCollection::hasDriver( const sal_Char* _pAsciiPattern ) const
+{
+ String sPrefix( getPrefix( ::rtl::OUString::createFromAscii( _pAsciiPattern ) ) );
+ return ( sPrefix.Len() > 0 );
+}
+
+// -----------------------------------------------------------------------------
+bool ODsnTypeCollection::isConnectionUrlRequired(const ::rtl::OUString& _sURL) const
+{
+ String sURL( _sURL);
+ String sRet;
+ String sOldPattern;
+ StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
+ StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ WildCard aWildCard(*aIter);
+ if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(sURL) )
+ {
+ sRet = *aIter;
+ sOldPattern = *aIter;
+ }
+ } // for(;aIter != aEnd;++aIter)
+ return sRet.GetChar(sRet.Len()-1) == '*';
+}
+// -----------------------------------------------------------------------------
+String ODsnTypeCollection::getMediaType(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("MediaType",::rtl::OUString());
+}
+// -----------------------------------------------------------------------------
+String ODsnTypeCollection::getDatasourcePrefixFromMediaType(const ::rtl::OUString& _sMediaType,const ::rtl::OUString& _sExtension)
+{
+ String sURL, sFallbackURL;
+ const uno::Sequence< ::rtl::OUString > aURLs = m_aDriverConfig.getURLs();
+ const ::rtl::OUString* pIter = aURLs.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aURLs.getLength();
+ for(;pIter != pEnd;++pIter )
+ {
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(*pIter);
+ if ( aFeatures.getOrDefault("MediaType",::rtl::OUString()) == _sMediaType )
+ {
+ const ::rtl::OUString sFileExtension = aFeatures.getOrDefault("Extension",::rtl::OUString());
+ if ( _sExtension == sFileExtension )
+ {
+ sURL = *pIter;
+ break;
+ }
+ if ( !sFileExtension.getLength() && _sExtension.getLength() )
+ sFallbackURL = *pIter;
+ }
+ } // for(;pIter != pEnd;++pIter )
+
+ if ( !sURL.Len() && sFallbackURL.Len() )
+ sURL = sFallbackURL;
+
+ sURL.EraseTrailingChars('*');
+ return sURL;
+}
+// -----------------------------------------------------------------------------
+bool ODsnTypeCollection::isShowPropertiesEnabled( const ::rtl::OUString& _sURL ) const
+{
+ return !( _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:embedded:hsqldb",sizeof("sdbc:embedded:hsqldb")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:outlook",sizeof("sdbc:address:outlook")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:outlookexp",sizeof("sdbc:address:outlookexp")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:mozilla:",sizeof("sdbc:address:mozilla:")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:kab",sizeof("sdbc:address:kab")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:local",sizeof("sdbc:address:evolution:local")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:groupwise",sizeof("sdbc:address:evolution:groupwise")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:ldap",sizeof("sdbc:address:evolution:ldap")-1)
+ || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:macab",sizeof("sdbc:address:macab")-1) );
+}
+// -----------------------------------------------------------------------------
+void ODsnTypeCollection::extractHostNamePort(const ::rtl::OUString& _rDsn,String& _sDatabaseName,String& _rsHostname,sal_Int32& _nPortNumber) const
+{
+ String sUrl = cutPrefix(_rDsn);
+ if ( _rDsn.matchIgnoreAsciiCaseAsciiL("jdbc:oracle:thin:",sizeof("jdbc:oracle:thin:")-1) )
+ {
+ lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber);
+ if ( !_rsHostname.Len() && sUrl.GetTokenCount(':') == 2 )
+ {
+ _nPortNumber = -1;
+ _rsHostname = sUrl.GetToken(0,':');
+ }
+ if ( _rsHostname.Len() )
+ _rsHostname = _rsHostname.GetToken(_rsHostname.GetTokenCount('@') - 1,'@');
+ _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount(':') - 1,':');
+ } // if ( _rDsn.matchIgnoreAsciiCaseAsciiL("jdbc:oracle:thin:",sizeof("jdbc:oracle:thin:")-1) )
+ else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:address:ldap:",sizeof("sdbc:address:ldap:")-1) )
+ {
+ lcl_extractHostAndPort(sUrl,_sDatabaseName,_nPortNumber);
+ }
+ else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:adabas:",sizeof("sdbc:adabas:")-1) )
+ {
+ if ( sUrl.GetTokenCount(':') == 2 )
+ _rsHostname = sUrl.GetToken(0,':');
+ _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount(':') - 1,':');
+ }
+ else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:mysql:mysqlc:",sizeof("sdbc:mysql:mysqlc:")-1) || _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:mysql:jdbc:",sizeof("sdbc:mysql:jdbc:")-1) )
+ {
+ lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber);
+
+ if ( _nPortNumber == -1 && !_rsHostname.Len() && sUrl.GetTokenCount('/') == 2 )
+ _rsHostname = sUrl.GetToken(0,'/');
+ _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount('/') - 1,'/');
+ }
+ else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=",sizeof("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=")-1)
+ || _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=",sizeof("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=")-1))
+ {
+ ::rtl::OUString sNewFileName;
+ if ( ::osl::FileBase::getFileURLFromSystemPath( sUrl, sNewFileName ) == ::osl::FileBase::E_None )
+ {
+ _sDatabaseName = sNewFileName;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+String ODsnTypeCollection::getJavaDriverClass(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getProperties(_sURL);
+ return aFeatures.getOrDefault("JavaDriverClass",::rtl::OUString());
+}
+//-------------------------------------------------------------------------
+sal_Bool ODsnTypeCollection::isFileSystemBased(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("FileSystemBased",sal_False);
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODsnTypeCollection::supportsTableCreation(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("SupportsTableCreation",sal_False);
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODsnTypeCollection::supportsColumnDescription(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("SupportsColumnDescription",sal_False);
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODsnTypeCollection::supportsBrowsing(const ::rtl::OUString& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("SupportsBrowsing",sal_False);
+}
+// -----------------------------------------------------------------------------
+bool ODsnTypeCollection::needsJVM(const String& _sURL) const
+{
+ const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
+ return aFeatures.getOrDefault("UseJava",sal_False);
+}
+// -----------------------------------------------------------------------------
+Sequence<PropertyValue> ODsnTypeCollection::getDefaultDBSettings( const ::rtl::OUString& _sURL ) const
+{
+ const ::comphelper::NamedValueCollection& aProperties = m_aDriverConfig.getProperties(_sURL);
+ return aProperties.getPropertyValues();
+}
+
+//-------------------------------------------------------------------------
+bool ODsnTypeCollection::isEmbeddedDatabase( const ::rtl::OUString& _sURL ) const
+{
+ const ::rtl::OUString sEmbeddedDatabaseURL = getEmbeddedDatabase();
+ WildCard aWildCard(sEmbeddedDatabaseURL);
+ return aWildCard.Matches(_sURL);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODsnTypeCollection::getEmbeddedDatabase() const
+{
+ ::rtl::OUString sEmbeddedDatabaseURL;
+ static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess")); ///Installed
+ const ::utl::OConfigurationTreeRoot aInstalled = ::utl::OConfigurationTreeRoot::createWithServiceFactory(m_xFactory, s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY);
+ if ( aInstalled.isValid() )
+ {
+ if ( aInstalled.hasByName("EmbeddedDatabases/DefaultEmbeddedDatabase/Value") )
+ {
+ static const ::rtl::OUString s_sValue(RTL_CONSTASCII_USTRINGPARAM("EmbeddedDatabases/DefaultEmbeddedDatabase/Value"));
+
+ aInstalled.getNodeValue(s_sValue) >>= sEmbeddedDatabaseURL;
+ if ( sEmbeddedDatabaseURL.getLength() )
+ aInstalled.getNodeValue(s_sValue + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sEmbeddedDatabaseURL + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/URL"))) >>= sEmbeddedDatabaseURL;
+ }
+ } // if ( aInstalled.isValid() )
+ if ( !sEmbeddedDatabaseURL.getLength() )
+ sEmbeddedDatabaseURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:embedded:hsqldb"));
+ return sEmbeddedDatabaseURL;
+}
+//-------------------------------------------------------------------------
+ODsnTypeCollection::TypeIterator ODsnTypeCollection::begin() const
+{
+ return TypeIterator(this, 0);
+}
+
+//-------------------------------------------------------------------------
+ODsnTypeCollection::TypeIterator ODsnTypeCollection::end() const
+{
+ return TypeIterator(this, m_aDsnTypesDisplayNames.size());
+}
+//-------------------------------------------------------------------------
+DATASOURCE_TYPE ODsnTypeCollection::determineType(const String& _rDsn) const
+{
+ String sDsn(_rDsn);
+ sDsn.EraseTrailingChars('*');
+ sal_uInt16 nSeparator = sDsn.Search((sal_Unicode)':');
+ if (STRING_NOTFOUND == nSeparator)
+ {
+ // there should be at least one such separator
+ DBG_ERROR("ODsnTypeCollection::implDetermineType : missing the colon !");
+ return DST_UNKNOWN;
+ }
+ // find first :
+ sal_uInt16 nOracleSeparator = sDsn.Search((sal_Unicode)':', nSeparator + 1);
+ if ( nOracleSeparator != STRING_NOTFOUND )
+ {
+ nOracleSeparator = sDsn.Search((sal_Unicode)':', nOracleSeparator + 1);
+ if (nOracleSeparator != STRING_NOTFOUND && sDsn.EqualsIgnoreCaseAscii("jdbc:oracle:thin", 0, nOracleSeparator))
+ return DST_ORACLE_JDBC;
+ }
+
+ if (sDsn.EqualsIgnoreCaseAscii("jdbc", 0, nSeparator))
+ return DST_JDBC;
+
+ if (sDsn.EqualsIgnoreCaseAscii("sdbc:embedded:hsqldb", 0, sDsn.Len()))
+ return DST_EMBEDDED_HSQLDB;
+
+ // find second :
+ nSeparator = sDsn.Search((sal_Unicode)':', nSeparator + 1);
+ if (STRING_NOTFOUND == nSeparator)
+ {
+ // at the moment only jdbc is allowed to have just one separator
+ DBG_ERROR("ODsnTypeCollection::implDetermineType : missing the second colon !");
+ return DST_UNKNOWN;
+ }
+
+ if (sDsn.EqualsIgnoreCaseAscii("sdbc:ado:", 0, nSeparator))
+ {
+ nSeparator = sDsn.Search((sal_Unicode)':', nSeparator + 1);
+ if (STRING_NOTFOUND != nSeparator && sDsn.EqualsIgnoreCaseAscii("sdbc:ado:access",0, nSeparator) )
+ {
+ nSeparator = sDsn.Search((sal_Unicode)';', nSeparator + 1);
+ if (STRING_NOTFOUND != nSeparator && sDsn.EqualsIgnoreCaseAscii("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0",0, nSeparator) )
+ return DST_MSACCESS_2007;
+
+ return DST_MSACCESS;
+ }
+ return DST_ADO;
+ }
+
+ struct KnownPrefix
+ {
+ const sal_Char* pAsciiPrefix;
+ const DATASOURCE_TYPE eType;
+ const bool bMatchComplete;
+
+ KnownPrefix()
+ :pAsciiPrefix( NULL )
+ ,eType( DST_UNKNOWN )
+ ,bMatchComplete( false )
+ {
+ }
+ KnownPrefix( const sal_Char* _p, const DATASOURCE_TYPE _t, const bool _m )
+ :pAsciiPrefix( _p )
+ ,eType ( _t )
+ ,bMatchComplete( _m )
+ {
+ }
+ };
+ KnownPrefix aKnowPrefixes[] =
+ {
+ KnownPrefix( "sdbc:calc:", DST_CALC, false ),
+ KnownPrefix( "sdbc:flat:", DST_FLAT, false ),
+ KnownPrefix( "sdbc:adabas:", DST_ADABAS, false ),
+ KnownPrefix( "sdbc:odbc:", DST_ODBC, false ),
+ KnownPrefix( "sdbc:dbase:", DST_DBASE, false ),
+ KnownPrefix( "sdbc:mysql:odbc:", DST_MYSQL_ODBC, false ),
+ KnownPrefix( "sdbc:mysql:jdbc:", DST_MYSQL_JDBC, false ),
+ KnownPrefix( "sdbc:mysql:mysqlc:", DST_MYSQL_NATIVE, false ),
+ KnownPrefix( "sdbc:mysqlc:", DST_MYSQL_NATIVE_DIRECT,false ),
+
+ KnownPrefix( "sdbc:address:mozilla:", DST_MOZILLA, true ),
+ KnownPrefix( "sdbc:address:thunderbird:", DST_THUNDERBIRD, true ),
+ KnownPrefix( "sdbc:address:ldap:", DST_LDAP, true ),
+ KnownPrefix( "sdbc:address:outlook", DST_OUTLOOK, true ),
+ KnownPrefix( "sdbc:address:outlookexp", DST_OUTLOOKEXP, true ),
+ KnownPrefix( "sdbc:address:evolution:ldap", DST_EVOLUTION_LDAP, true ),
+ KnownPrefix( "sdbc:address:evolution:groupwise",DST_EVOLUTION_GROUPWISE,true ),
+ KnownPrefix( "sdbc:address:evolution:local", DST_EVOLUTION, true ),
+ KnownPrefix( "sdbc:address:kab", DST_KAB, true ),
+ KnownPrefix( "sdbc:address:macab", DST_MACAB, true )
+ };
+
+ for ( size_t i=0; i < sizeof( aKnowPrefixes ) / sizeof( aKnowPrefixes[0] ); ++i )
+ {
+ USHORT nMatchLen = aKnowPrefixes[i].bMatchComplete ? sDsn.Len() : (USHORT)rtl_str_getLength( aKnowPrefixes[i].pAsciiPrefix );
+ if ( sDsn.EqualsIgnoreCaseAscii( aKnowPrefixes[i].pAsciiPrefix, 0, nMatchLen ) )
+ return aKnowPrefixes[i].eType;
+ }
+
+ return DST_UNKNOWN;
+}
+// -----------------------------------------------------------------------------
+void ODsnTypeCollection::fillPageIds(const ::rtl::OUString& _sURL,::std::vector<sal_Int16>& _rOutPathIds) const
+{
+ DATASOURCE_TYPE eType = determineType(_sURL);
+ switch(eType)
+ {
+ case DST_ADO:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ADO);
+ break;
+ case DST_DBASE:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_DBASE);
+ break;
+ case DST_FLAT:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_TEXT);
+ break;
+ case DST_CALC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_SPREADSHEET);
+ break;
+ case DST_ODBC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ODBC);
+ break;
+ case DST_JDBC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_JDBC);
+ break;
+ case DST_MYSQL_ODBC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO);
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_ODBC);
+ break;
+ case DST_MYSQL_JDBC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO);
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_JDBC);
+ break;
+ case DST_MYSQL_NATIVE:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO);
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_NATIVE);
+ break;
+ case DST_ORACLE_JDBC:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ORACLE);
+ break;
+ case DST_ADABAS:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ADABAS);
+ break;
+ case DST_LDAP:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_LDAP);
+ break;
+ case DST_MSACCESS:
+ case DST_MSACCESS_2007:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MSACCESS);
+ break;
+ case DST_OUTLOOKEXP:
+ case DST_OUTLOOK:
+ case DST_MOZILLA:
+ case DST_THUNDERBIRD:
+ case DST_EVOLUTION:
+ case DST_EVOLUTION_GROUPWISE:
+ case DST_EVOLUTION_LDAP:
+ case DST_KAB:
+ case DST_MACAB:
+ case DST_EMBEDDED_HSQLDB:
+ break;
+ default:
+ _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_USERDEFINED);
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODsnTypeCollection::getType(const ::rtl::OUString& _sURL) const
+{
+ ::rtl::OUString sOldPattern;
+ StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
+ StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ WildCard aWildCard(*aIter);
+ if ( sOldPattern.getLength() < aIter->Len() && aWildCard.Matches(_sURL) )
+ {
+ sOldPattern = *aIter;
+ }
+ } // for(sal_Int32 i = 0;aIter != aEnd;++aIter,++i)
+ return sOldPattern;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ODsnTypeCollection::getIndexOf(const ::rtl::OUString& _sURL) const
+{
+ sal_Int32 nRet = -1;
+ String sURL( _sURL);
+ String sOldPattern;
+ StringVector::const_iterator aIter = m_aDsnPrefixes.begin();
+ StringVector::const_iterator aEnd = m_aDsnPrefixes.end();
+ for(sal_Int32 i = 0;aIter != aEnd;++aIter,++i)
+ {
+ WildCard aWildCard(*aIter);
+ if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(sURL) )
+ {
+ nRet = i;
+ sOldPattern = *aIter;
+ }
+ }
+
+ return nRet;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ODsnTypeCollection::size() const
+{
+ return m_aDsnPrefixes.size();
+}
+//=========================================================================
+//= ODsnTypeCollection::TypeIterator
+//=========================================================================
+//-------------------------------------------------------------------------
+ODsnTypeCollection::TypeIterator::TypeIterator(const ODsnTypeCollection* _pContainer, sal_Int32 _nInitialPos)
+ :m_pContainer(_pContainer)
+ ,m_nPosition(_nInitialPos)
+{
+ DBG_ASSERT(m_pContainer, "ODsnTypeCollection::TypeIterator::TypeIterator : invalid container!");
+#ifdef DBG_UTIL
+ ++const_cast<ODsnTypeCollection*>(m_pContainer)->m_nLivingIterators;
+#endif
+}
+
+//-------------------------------------------------------------------------
+ODsnTypeCollection::TypeIterator::TypeIterator(const TypeIterator& _rSource)
+ :m_pContainer(_rSource.m_pContainer)
+ ,m_nPosition(_rSource.m_nPosition)
+{
+#ifdef DBG_UTIL
+ ++const_cast<ODsnTypeCollection*>(m_pContainer)->m_nLivingIterators;
+#endif
+}
+
+//-------------------------------------------------------------------------
+ODsnTypeCollection::TypeIterator::~TypeIterator()
+{
+#ifdef DBG_UTIL
+ --const_cast<ODsnTypeCollection*>(m_pContainer)->m_nLivingIterators;
+#endif
+}
+
+//-------------------------------------------------------------------------
+String ODsnTypeCollection::TypeIterator::getDisplayName() const
+{
+ DBG_ASSERT(m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypesDisplayNames.size(), "ODsnTypeCollection::TypeIterator::getDisplayName : invalid position!");
+ return m_pContainer->m_aDsnTypesDisplayNames[m_nPosition];
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODsnTypeCollection::TypeIterator::getURLPrefix() const
+{
+ DBG_ASSERT(m_nPosition < (sal_Int32)m_pContainer->m_aDsnPrefixes.size(), "ODsnTypeCollection::TypeIterator::getDisplayName : invalid position!");
+ return m_pContainer->m_aDsnPrefixes[m_nPosition];
+}
+//-------------------------------------------------------------------------
+const ODsnTypeCollection::TypeIterator& ODsnTypeCollection::TypeIterator::operator++()
+{
+ DBG_ASSERT(m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypesDisplayNames.size(), "ODsnTypeCollection::TypeIterator::operator++ : invalid position!");
+ if (m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypesDisplayNames.size())
+ ++m_nPosition;
+ return *this;
+}
+
+//-------------------------------------------------------------------------
+const ODsnTypeCollection::TypeIterator& ODsnTypeCollection::TypeIterator::operator--()
+{
+ DBG_ASSERT(m_nPosition >= 0, "ODsnTypeCollection::TypeIterator::operator-- : invalid position!");
+ if (m_nPosition >= 0)
+ --m_nPosition;
+ return *this;
+}
+
+//-------------------------------------------------------------------------
+bool operator==(const ODsnTypeCollection::TypeIterator& lhs, const ODsnTypeCollection::TypeIterator& rhs)
+{
+ return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_nPosition == rhs.m_nPosition);
+}
+
+//.........................................................................
+} // namespace dbaccess
+//.........................................................................
+
diff --git a/dbaccess/source/core/misc/makefile.mk b/dbaccess/source/core/misc/makefile.mk
new file mode 100644
index 000000000000..3f41bbf80fe8
--- /dev/null
+++ b/dbaccess/source/core/misc/makefile.mk
@@ -0,0 +1,60 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=misc
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/dba.pmk
+
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(SLO)$/sdbcoretools.obj \
+ $(SLO)$/services.obj \
+ $(SLO)$/PropertyForward.obj \
+ $(SLO)$/ContainerMediator.obj \
+ $(SLO)$/userinformation.obj \
+ $(SLO)$/ContainerListener.obj \
+ $(SLO)$/objectnameapproval.obj \
+ $(SLO)$/DatabaseDataProvider.obj \
+ $(SLO)$/module_dba.obj \
+ $(SLO)$/dsntypes.obj \
+ $(SLO)$/veto.obj \
+ $(SLO)$/apitools.obj \
+ $(SLO)$/dbastrings.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/core/misc/module_dba.cxx b/dbaccess/source/core/misc/module_dba.cxx
new file mode 100644
index 000000000000..0010927f733c
--- /dev/null
+++ b/dbaccess/source/core/misc/module_dba.cxx
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "module_dba.hxx"
+
+//........................................................................
+namespace dba
+{
+//........................................................................
+
+ IMPLEMENT_MODULE( DbaModule, "dba" )
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/core/misc/objectnameapproval.cxx b/dbaccess/source/core/misc/objectnameapproval.cxx
new file mode 100644
index 000000000000..50b78e386d98
--- /dev/null
+++ b/dbaccess/source/core/misc/objectnameapproval.cxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_OBJECTNAMEAPPROVAL_HXX
+#include "objectnameapproval.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XCONNECTIONTOOLS_HPP_
+#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
+#include <com/sun/star/sdb/CommandType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
+#include <com/sun/star/sdbc/SQLException.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _CPPUHELPER_WEAKREF_HXX_
+#include <cppuhelper/weakref.hxx>
+#endif
+#ifndef _CPPUHELPER_EXC_HLP_HXX_
+#include <cppuhelper/exc_hlp.hxx>
+#endif
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::uno::WeakReference;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::sdb::tools::XConnectionTools;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::sdb::tools::XObjectNames;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::sdbc::SQLException;
+ /** === end UNO using === **/
+
+ namespace CommandType = com::sun::star::sdb::CommandType;
+
+ //====================================================================
+ //= ObjectNameApproval_Impl
+ //====================================================================
+ struct ObjectNameApproval_Impl
+ {
+ WeakReference< XConnection > aConnection;
+ sal_Int32 nCommandType;
+ };
+
+ //====================================================================
+ //= ObjectNameApproval
+ //====================================================================
+ //--------------------------------------------------------------------
+ ObjectNameApproval::ObjectNameApproval( const Reference< XConnection >& _rxConnection, ObjectType _eType )
+ :m_pImpl( new ObjectNameApproval_Impl )
+ {
+ m_pImpl->aConnection = _rxConnection;
+ m_pImpl->nCommandType = _eType == TypeQuery ? CommandType::QUERY : CommandType::TABLE;
+ }
+
+ //--------------------------------------------------------------------
+ ObjectNameApproval::~ObjectNameApproval()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ObjectNameApproval::approveElement( const ::rtl::OUString& _rName, const Reference< XInterface >& /*_rxElement*/ )
+ {
+ Reference< XConnection > xConnection( m_pImpl->aConnection );
+ if ( !xConnection.is() )
+ throw DisposedException();
+
+ Reference< XConnectionTools > xConnectionTools( xConnection, UNO_QUERY_THROW );
+ Reference< XObjectNames > xObjectNames( xConnectionTools->getObjectNames(), UNO_QUERY_THROW );
+ xObjectNames->checkNameForCreate( m_pImpl->nCommandType, _rName );
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
diff --git a/dbaccess/source/core/misc/sdbcoretools.cxx b/dbaccess/source/core/misc/sdbcoretools.cxx
new file mode 100644
index 000000000000..dea2328dc907
--- /dev/null
+++ b/dbaccess/source/core/misc/sdbcoretools.cxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "sdbcoretools.hxx"
+#include "dbastrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/task/XInteractionRequestStringResolver.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+#include <tools/debug.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/interaction.hxx>
+#include <rtl/ref.hxx>
+#include <rtl/ustrbuf.hxx>
+
+//.........................................................................
+namespace dbaccess
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::io;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::embed;
+ using namespace ::com::sun::star::container;
+
+ // =========================================================================
+ // -------------------------------------------------------------------------
+ void notifyDataSourceModified(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject,sal_Bool _bModified)
+ {
+ Reference< XInterface > xDs = getDataSource( _rxObject );
+ Reference<XDocumentDataSource> xDocumentDataSource(xDs,UNO_QUERY);
+ if ( xDocumentDataSource.is() )
+ xDs = xDocumentDataSource->getDatabaseDocument();
+ Reference< XModifiable > xModi( xDs, UNO_QUERY );
+ if ( xModi.is() )
+ xModi->setModified(_bModified);
+ }
+
+ // -------------------------------------------------------------------------
+ Reference< XInterface > getDataSource( const Reference< XInterface >& _rxDependentObject )
+ {
+ Reference< XInterface > xParent = _rxDependentObject;
+ Reference< XInterface > xReturn;
+ while( xParent.is() )
+ {
+ xReturn = xParent;
+ Reference<XChild> xChild(xParent,UNO_QUERY);
+ xParent.set(xChild.is() ? xChild->getParent() : Reference< XInterface >(),UNO_QUERY);
+ }
+ return xReturn;
+ }
+
+// -----------------------------------------------------------------------------
+ ::rtl::OUString extractExceptionMessage( const ::comphelper::ComponentContext& _rContext, const Any& _rError )
+ {
+ ::rtl::OUString sDisplayMessage;
+
+ try
+ {
+ Reference< XInteractionRequestStringResolver > xStringResolver;
+ if ( _rContext.createComponent( "com.sun.star.task.InteractionRequestStringResolver", xStringResolver ) )
+ {
+ ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new ::comphelper::OInteractionRequest( _rError ) );
+ ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove );
+ pRequest->addContinuation( pApprove.get() );
+ Optional< ::rtl::OUString > aMessage = xStringResolver->getStringFromInformationalRequest( pRequest.get() );
+ if ( aMessage.IsPresent )
+ sDisplayMessage = aMessage.Value;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( !sDisplayMessage.getLength() )
+ {
+ Exception aExcept;
+ _rError >>= aExcept;
+
+ ::rtl::OUStringBuffer aBuffer;
+ aBuffer.append( _rError.getValueTypeName() );
+ aBuffer.appendAscii( ":\n" );
+ aBuffer.append( aExcept.Message );
+
+ sDisplayMessage = aBuffer.makeStringAndClear();
+ }
+
+ return sDisplayMessage;
+ }
+
+ namespace tools { namespace stor {
+
+ // -----------------------------------------------------------------------------
+ bool storageIsWritable_nothrow( const Reference< XStorage >& _rxStorage )
+ {
+ if ( !_rxStorage.is() )
+ return false;
+
+ sal_Int32 nMode = ElementModes::READ;
+ try
+ {
+ Reference< XPropertySet > xStorageProps( _rxStorage, UNO_QUERY_THROW );
+ xStorageProps->getPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" ) ) ) >>= nMode;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return ( nMode & ElementModes::WRITE ) != 0;
+ }
+
+ // -----------------------------------------------------------------------------
+ bool commitStorageIfWriteable( const Reference< XStorage >& _rxStorage ) SAL_THROW(( IOException, WrappedTargetException, RuntimeException ))
+ {
+ bool bSuccess = false;
+ Reference< XTransactedObject > xTrans( _rxStorage, UNO_QUERY );
+ if ( xTrans.is() )
+ {
+ if ( storageIsWritable_nothrow( _rxStorage ) )
+ xTrans->commit();
+ bSuccess = true;
+ }
+ return bSuccess;
+ }
+
+ } } // tools::stor
+
+//.........................................................................
+} // namespace dbaccess
+//.........................................................................
+
diff --git a/dbaccess/source/core/misc/services.cxx b/dbaccess/source/core/misc/services.cxx
new file mode 100644
index 000000000000..5c427d1eb57e
--- /dev/null
+++ b/dbaccess/source/core/misc/services.cxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
+#include "module_dba.hxx"
+#include <osl/diagnose.h>
+#include "DatabaseDataProvider.hxx"
+#include "dbadllapi.hxx"
+
+/********************************************************************************************/
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+//***************************************************************************************
+//
+// registry functions
+extern "C" void SAL_CALL createRegistryInfo_ODatabaseContext();
+extern "C" void SAL_CALL createRegistryInfo_OCommandDefinition();
+extern "C" void SAL_CALL createRegistryInfo_OComponentDefinition();
+extern "C" void SAL_CALL createRegistryInfo_ORowSet();
+extern "C" void SAL_CALL createRegistryInfo_ODatabaseDocument();
+extern "C" void SAL_CALL createRegistryInfo_ODatabaseSource();
+extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptorFactory();
+
+namespace dba{
+//--------------------------------------------------------------------------
+ ::cppu::ImplementationEntry entries[] = {
+ { &::dbaccess::DatabaseDataProvider::Create, &::dbaccess::DatabaseDataProvider::getImplementationName_Static, &::dbaccess::DatabaseDataProvider::getSupportedServiceNames_Static,
+ &cppu::createSingleComponentFactory, 0, 0 },
+ { 0, 0, 0, 0, 0, 0 }
+ };
+}
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+extern "C" void SAL_CALL createRegistryInfo_DBA()
+{
+ static sal_Bool bInit = sal_False;
+ if (!bInit)
+ {
+ createRegistryInfo_ODatabaseContext();
+ createRegistryInfo_OCommandDefinition();
+ createRegistryInfo_OComponentDefinition();
+ createRegistryInfo_ORowSet();
+ createRegistryInfo_ODatabaseDocument();
+ createRegistryInfo_ODatabaseSource();
+ createRegistryInfo_DataAccessDescriptorFactory();
+ bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" OOO_DLLPUBLIC_DBA void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **
+ )
+{
+ createRegistryInfo_DBA();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" OOO_DLLPUBLIC_DBA sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ return ::dba::DbaModule::getInstance().writeComponentInfos(
+ static_cast< XMultiServiceFactory* >( pServiceManager ),
+ static_cast< XRegistryKey* >( pRegistryKey ) )
+ && cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, dba::entries);
+ }
+ catch (InvalidRegistryException& )
+ {
+ OSL_ENSURE( false, "DBA::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !" );
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" OOO_DLLPUBLIC_DBA void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* pRegistryKey)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::dba::DbaModule::getInstance().getComponentFactory(
+ ::rtl::OUString::createFromAscii( pImplementationName ),
+ static_cast< XMultiServiceFactory* >( pServiceManager ) );
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ else
+ return cppu::component_getFactoryHelper(
+ pImplementationName, pServiceManager, pRegistryKey, dba::entries);
+ return xRet.get();
+};
diff --git a/dbaccess/source/core/misc/userinformation.cxx b/dbaccess/source/core/misc/userinformation.cxx
new file mode 100644
index 000000000000..9143b123899b
--- /dev/null
+++ b/dbaccess/source/core/misc/userinformation.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBA_CORE_USERINFORMATION_HXX_
+#include "userinformation.hxx"
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef INCLUDED_I18NPOOL_MSLANGID_HXX
+#include <i18npool/mslangid.hxx>
+#endif
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+
+using namespace ::utl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+//--------------------------------------------------------------------------
+UserInformation::UserInformation()
+{
+ Any aValue = ConfigManager::GetDirectConfigProperty(ConfigManager::LOCALE);
+ LanguageType eLanguage = MsLangId::convertIsoStringToLanguage(comphelper::getString(aValue),'-');
+ m_aUserLocale = MsLangId::convertLanguageToLocale(eLanguage);
+}
+
diff --git a/dbaccess/source/core/misc/veto.cxx b/dbaccess/source/core/misc/veto.cxx
new file mode 100644
index 000000000000..b3ab20bf9beb
--- /dev/null
+++ b/dbaccess/source/core/misc/veto.cxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_VETO_HXX
+#include "veto.hxx"
+#endif
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::RuntimeException;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= Veto
+ //====================================================================
+ //--------------------------------------------------------------------
+ Veto::Veto( const ::rtl::OUString& _rReason, const Any& _rDetails )
+ :m_sReason( _rReason )
+ ,m_aDetails( _rDetails )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ Veto::~Veto()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL Veto::getReason() throw (RuntimeException)
+ {
+ return m_sReason;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL Veto::getDetails() throw (RuntimeException)
+ {
+ return m_aDetails;
+ }
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+