summaryrefslogtreecommitdiff
path: root/ucbhelper/source/provider
diff options
context:
space:
mode:
Diffstat (limited to 'ucbhelper/source/provider')
-rw-r--r--ucbhelper/source/provider/cancelcommandexecution.cxx130
-rw-r--r--ucbhelper/source/provider/commandenvironmentproxy.cxx167
-rw-r--r--ucbhelper/source/provider/configureucb.cxx242
-rw-r--r--ucbhelper/source/provider/contenthelper.cxx1127
-rw-r--r--ucbhelper/source/provider/contentidentifier.cxx221
-rw-r--r--ucbhelper/source/provider/contentinfo.cxx423
-rw-r--r--ucbhelper/source/provider/handleinteractionrequest.cxx164
-rw-r--r--ucbhelper/source/provider/interactionrequest.cxx1151
-rw-r--r--ucbhelper/source/provider/makefile.mk70
-rw-r--r--ucbhelper/source/provider/propertyvalueset.cxx924
-rw-r--r--ucbhelper/source/provider/provconf.cxx266
-rw-r--r--ucbhelper/source/provider/provconf.hxx52
-rw-r--r--ucbhelper/source/provider/providerhelper.cxx672
-rw-r--r--ucbhelper/source/provider/registerucb.cxx164
-rw-r--r--ucbhelper/source/provider/resultset.cxx1695
-rw-r--r--ucbhelper/source/provider/resultsethelper.cxx329
-rw-r--r--ucbhelper/source/provider/resultsetmetadata.cxx602
-rw-r--r--ucbhelper/source/provider/simpleauthenticationrequest.cxx243
-rwxr-xr-xucbhelper/source/provider/simplecertificatevalidationrequest.cxx88
-rw-r--r--ucbhelper/source/provider/simpleinteractionrequest.cxx132
-rw-r--r--ucbhelper/source/provider/simpleioerrorrequest.cxx60
-rw-r--r--ucbhelper/source/provider/simplenameclashresolverequest.cxx67
22 files changed, 8989 insertions, 0 deletions
diff --git a/ucbhelper/source/provider/cancelcommandexecution.cxx b/ucbhelper/source/provider/cancelcommandexecution.cxx
new file mode 100644
index 000000000000..8be75ee8aabd
--- /dev/null
+++ b/ucbhelper/source/provider/cancelcommandexecution.cxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_ucbhelper.hxx"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+#include <osl/diagnose.h>
+#include <cppuhelper/exc_hlp.hxx>
+#include <com/sun/star/ucb/CommandFailedException.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#ifndef _UCBHELPER_INTERACTIONREQUEST_HXX
+#include <ucbhelper/interactionrequest.hxx>
+#endif
+#include <ucbhelper/cancelcommandexecution.hxx>
+#include <ucbhelper/simpleioerrorrequest.hxx>
+
+using namespace com::sun::star;
+
+namespace ucbhelper
+{
+
+//=========================================================================
+void cancelCommandExecution( const uno::Any & rException,
+ const uno::Reference<
+ ucb::XCommandEnvironment > & xEnv )
+ throw( uno::Exception )
+{
+ if ( xEnv.is() )
+ {
+ uno::Reference<
+ task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
+ if ( xIH.is() )
+ {
+ rtl::Reference< ucbhelper::InteractionRequest > xRequest
+ = new ucbhelper::InteractionRequest( rException );
+
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > >
+ aContinuations( 1 );
+ aContinuations[ 0 ]
+ = new ucbhelper::InteractionAbort( xRequest.get() );
+
+ xRequest->setContinuations( aContinuations );
+
+ xIH->handle( xRequest.get() );
+
+ rtl::Reference< ucbhelper::InteractionContinuation > xSelection
+ = xRequest->getSelection();
+
+ if ( xSelection.is() )
+ throw ucb::CommandFailedException(
+ rtl::OUString(),
+ uno::Reference< uno::XInterface >(),
+ rException );
+ }
+ }
+
+ cppu::throwException( rException );
+
+ OSL_ENSURE( sal_False, "Return from cppu::throwException call!!!" );
+ throw uno::RuntimeException();
+}
+
+
+//=========================================================================
+void cancelCommandExecution( const ucb::IOErrorCode eError,
+ const uno::Sequence< uno::Any > & rArgs,
+ const uno::Reference<
+ ucb::XCommandEnvironment > & xEnv,
+ const rtl::OUString & rMessage,
+ const uno::Reference<
+ ucb::XCommandProcessor > & xContext )
+ throw( uno::Exception )
+{
+ rtl::Reference< ucbhelper::SimpleIOErrorRequest > xRequest
+ = new ucbhelper::SimpleIOErrorRequest(
+ eError, rArgs, rMessage, xContext );
+ if ( xEnv.is() )
+ {
+ uno::Reference<
+ task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
+ if ( xIH.is() )
+ {
+ xIH->handle( xRequest.get() );
+
+ rtl::Reference< ucbhelper::InteractionContinuation > xSelection
+ = xRequest->getSelection();
+
+ if ( xSelection.is() )
+ throw ucb::CommandFailedException( rtl::OUString(),
+ xContext,
+ xRequest->getRequest() );
+ }
+ }
+
+ cppu::throwException( xRequest->getRequest() );
+
+ OSL_ENSURE( sal_False, "Return from cppu::throwException call!!!" );
+ throw uno::RuntimeException();
+}
+
+}
diff --git a/ucbhelper/source/provider/commandenvironmentproxy.cxx b/ucbhelper/source/provider/commandenvironmentproxy.cxx
new file mode 100644
index 000000000000..33b8dd3fdfca
--- /dev/null
+++ b/ucbhelper/source/provider/commandenvironmentproxy.cxx
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/ucb/XContentProviderManager.hpp>
+#include <osl/mutex.hxx>
+#include <ucbhelper/commandenvironmentproxy.hxx>
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::task;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace rtl;
+
+namespace ucbhelper
+{
+
+//=========================================================================
+//=========================================================================
+//
+// struct CommandEnvironmentProxy_Impl.
+//
+//=========================================================================
+//=========================================================================
+
+struct CommandEnvironmentProxy_Impl
+{
+ osl::Mutex m_aMutex;
+ Reference< XCommandEnvironment > m_xEnv;
+ Reference< XInteractionHandler > m_xInteractionHandler;
+ Reference< XProgressHandler > m_xProgressHandler;
+ sal_Bool m_bGotInteractionHandler;
+ sal_Bool m_bGotProgressHandler;
+
+ CommandEnvironmentProxy_Impl(
+ const Reference< XCommandEnvironment >& rxEnv )
+ : m_xEnv( rxEnv ), m_bGotInteractionHandler( sal_False ),
+ m_bGotProgressHandler( sal_False ) {}
+};
+
+//=========================================================================
+//=========================================================================
+//
+// CommandEnvironmentProxy Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+CommandEnvironmentProxy::CommandEnvironmentProxy(
+ const Reference< XCommandEnvironment >& rxEnv )
+{
+ m_pImpl = new CommandEnvironmentProxy_Impl( rxEnv );
+}
+
+//=========================================================================
+// virtual
+CommandEnvironmentProxy::~CommandEnvironmentProxy()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+//
+// XInterface methods
+//
+//=========================================================================
+
+XINTERFACE_IMPL_2( CommandEnvironmentProxy,
+ XTypeProvider,
+ XCommandEnvironment );
+
+//=========================================================================
+//
+// XTypeProvider methods
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_2( CommandEnvironmentProxy,
+ XTypeProvider,
+ XCommandEnvironment );
+
+//=========================================================================
+//
+// XCommandEnvironemnt methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XInteractionHandler > SAL_CALL
+CommandEnvironmentProxy::getInteractionHandler()
+ throw ( RuntimeException )
+{
+ if ( m_pImpl->m_xEnv.is() )
+ {
+ if ( !m_pImpl->m_bGotInteractionHandler )
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ if ( !m_pImpl->m_bGotInteractionHandler )
+ {
+ m_pImpl->m_xInteractionHandler
+ = m_pImpl->m_xEnv->getInteractionHandler();
+ m_pImpl->m_bGotInteractionHandler = sal_True;
+ }
+ }
+ }
+ return m_pImpl->m_xInteractionHandler;
+}
+
+//=========================================================================
+// virtual
+Reference< XProgressHandler > SAL_CALL
+CommandEnvironmentProxy::getProgressHandler()
+ throw ( RuntimeException )
+{
+ if ( m_pImpl->m_xEnv.is() )
+ {
+ if ( !m_pImpl->m_bGotProgressHandler )
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ if ( !m_pImpl->m_bGotProgressHandler )
+ {
+ m_pImpl->m_xProgressHandler
+ = m_pImpl->m_xEnv->getProgressHandler();
+ m_pImpl->m_bGotProgressHandler = sal_True;
+ }
+ }
+ }
+ return m_pImpl->m_xProgressHandler;
+}
+
+} /* namespace ucbhelper */
+
diff --git a/ucbhelper/source/provider/configureucb.cxx b/ucbhelper/source/provider/configureucb.cxx
new file mode 100644
index 000000000000..ee881c97ecbf
--- /dev/null
+++ b/ucbhelper/source/provider/configureucb.cxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+#include <ucbhelper/configureucb.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/ucb/XContentProviderManager.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <rtl/ustrbuf.hxx>
+
+#include "osl/diagnose.h"
+
+#ifndef _UCBHELPER_PROVCONF_HXX_
+#include <provconf.hxx>
+#endif
+#include <registerucb.hxx>
+
+using namespace com::sun::star;
+
+namespace {
+
+bool fillPlaceholders(rtl::OUString const & rInput,
+ uno::Sequence< uno::Any > const & rReplacements,
+ rtl::OUString * pOutput)
+{
+ sal_Unicode const * p = rInput.getStr();
+ sal_Unicode const * pEnd = p + rInput.getLength();
+ sal_Unicode const * pCopy = p;
+ rtl::OUStringBuffer aBuffer;
+ while (p != pEnd)
+ switch (*p++)
+ {
+ case '&':
+ if (pEnd - p >= 4
+ && p[0] == 'a' && p[1] == 'm' && p[2] == 'p'
+ && p[3] == ';')
+ {
+ aBuffer.append(pCopy, p - 1 - pCopy);
+ aBuffer.append(sal_Unicode('&'));
+ p += 4;
+ pCopy = p;
+ }
+ else if (pEnd - p >= 3
+ && p[0] == 'l' && p[1] == 't' && p[2] == ';')
+ {
+ aBuffer.append(pCopy, p - 1 - pCopy);
+ aBuffer.append(sal_Unicode('<'));
+ p += 3;
+ pCopy = p;
+ }
+ else if (pEnd - p >= 3
+ && p[0] == 'g' && p[1] == 't' && p[2] == ';')
+ {
+ aBuffer.append(pCopy, p - 1 - pCopy);
+ aBuffer.append(sal_Unicode('>'));
+ p += 3;
+ pCopy = p;
+ }
+ break;
+
+ case '<':
+ sal_Unicode const * q = p;
+ while (q != pEnd && *q != '>')
+ ++q;
+ if (q == pEnd)
+ break;
+ rtl::OUString aKey(p, q - p);
+ rtl::OUString aValue;
+ bool bFound = false;
+ for (sal_Int32 i = 2; i + 1 < rReplacements.getLength();
+ i += 2)
+ {
+ rtl::OUString aReplaceKey;
+ if ((rReplacements[i] >>= aReplaceKey)
+ && aReplaceKey == aKey
+ && (rReplacements[i + 1] >>= aValue))
+ {
+ bFound = true;
+ break;
+ }
+ }
+ if (!bFound)
+ return false;
+ aBuffer.append(pCopy, p - 1 - pCopy);
+ aBuffer.append(aValue);
+ p = q + 1;
+ pCopy = p;
+ break;
+ }
+ aBuffer.append(pCopy, pEnd - pCopy);
+ *pOutput = aBuffer.makeStringAndClear();
+ return true;
+}
+
+}
+
+namespace ucbhelper {
+
+//============================================================================
+//
+// configureUcb
+//
+//============================================================================
+
+bool
+configureUcb(
+ uno::Reference< ucb::XContentProviderManager > const & rManager,
+ uno::Reference< lang::XMultiServiceFactory > const & rServiceFactory,
+ ContentProviderDataList const & rData,
+ ContentProviderRegistrationInfoList * pInfos)
+ throw (uno::RuntimeException)
+{
+ ContentProviderDataList::const_iterator aEnd(rData.end());
+ for (ContentProviderDataList::const_iterator aIt(rData.begin());
+ aIt != aEnd; ++aIt)
+ {
+ ContentProviderRegistrationInfo aInfo;
+ bool bSuccess = registerAtUcb(rManager,
+ rServiceFactory,
+ aIt->ServiceName,
+ aIt->Arguments,
+ aIt->URLTemplate,
+ &aInfo);
+
+ if (bSuccess && pInfos)
+ pInfos->push_back(aInfo);
+ }
+
+ return true;
+}
+
+//============================================================================
+//
+// configureUcb
+//
+//============================================================================
+
+bool
+configureUcb(
+ uno::Reference< ucb::XContentProviderManager > const & rManager,
+ uno::Reference< lang::XMultiServiceFactory > const & rServiceFactory,
+ uno::Sequence< uno::Any > const & rArguments,
+ std::vector< ContentProviderRegistrationInfo > * pInfos)
+ throw (uno::RuntimeException)
+{
+ rtl::OUString aKey1;
+ rtl::OUString aKey2;
+ if (rArguments.getLength() < 2
+ || !(rArguments[0] >>= aKey1) || !(rArguments[1] >>= aKey2))
+ {
+ OSL_ENSURE(false, "ucb::configureUcb(): Bad arguments");
+ return false;
+ }
+
+ ContentProviderDataList aData;
+ if (!getContentProviderData(rServiceFactory, aKey1, aKey2, aData))
+ {
+ OSL_ENSURE(false, "ucb::configureUcb(): No configuration");
+ return false;
+ }
+
+ ContentProviderDataList::const_iterator aEnd(aData.end());
+ for (ContentProviderDataList::const_iterator aIt(aData.begin());
+ aIt != aEnd; ++aIt)
+ {
+ rtl::OUString aProviderArguments;
+ if (fillPlaceholders(aIt->Arguments,
+ rArguments,
+ &aProviderArguments))
+ {
+ ContentProviderRegistrationInfo aInfo;
+ bool bSuccess = registerAtUcb(rManager,
+ rServiceFactory,
+ aIt->ServiceName,
+ aProviderArguments,
+ aIt->URLTemplate,
+ &aInfo);
+ OSL_ENSURE(bSuccess, "ucb::configureUcb(): Bad content provider");
+
+ if (bSuccess && pInfos)
+ pInfos->push_back(aInfo);
+ }
+ else
+ OSL_ENSURE(false,
+ "ucb::configureUcb(): Bad argument placeholders");
+ }
+
+ return true;
+}
+
+}
+
+//============================================================================
+//
+// unconfigureUcb
+//
+//============================================================================
+
+namespace ucbhelper {
+
+void
+unconfigureUcb(
+ uno::Reference< ucb::XContentProviderManager > const & rManager,
+ std::vector< ContentProviderRegistrationInfo > const & rInfos)
+ throw (uno::RuntimeException)
+{
+ std::vector< ContentProviderRegistrationInfo >::const_iterator
+ aEnd(rInfos.end());
+ for (std::vector< ContentProviderRegistrationInfo >::const_iterator
+ aIt(rInfos.begin());
+ aIt != aEnd; ++aIt)
+ deregisterFromUcb(rManager, *aIt);
+}
+
+}
diff --git a/ucbhelper/source/provider/contenthelper.cxx b/ucbhelper/source/provider/contenthelper.cxx
new file mode 100644
index 000000000000..17b494e00437
--- /dev/null
+++ b/ucbhelper/source/provider/contenthelper.cxx
@@ -0,0 +1,1127 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+
+#include <hash_map>
+#include <com/sun/star/ucb/ContentAction.hpp>
+#include <com/sun/star/ucb/CommandInfoChange.hpp>
+#include <com/sun/star/ucb/XPersistentPropertySet.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/PropertySetInfoChange.hpp>
+#include <cppuhelper/interfacecontainer.hxx>
+
+#include "osl/diagnose.h"
+#include "osl/mutex.hxx"
+#include "rtl/ref.hxx"
+#include <ucbhelper/contentidentifier.hxx>
+#include <ucbhelper/contenthelper.hxx>
+#include <ucbhelper/providerhelper.hxx>
+#include <ucbhelper/contentinfo.hxx>
+
+using namespace com::sun::star;
+
+namespace ucbhelper_impl
+{
+
+//=========================================================================
+//
+// class PropertyEventSequence.
+//
+//=========================================================================
+
+class PropertyEventSequence
+{
+ uno::Sequence< beans::PropertyChangeEvent > m_aSeq;
+ sal_uInt32 m_nPos;
+
+public:
+ PropertyEventSequence( sal_uInt32 nSize )
+ : m_aSeq( nSize ), m_nPos( 0 ) {};
+
+ void append( const beans::PropertyChangeEvent& rEvt )
+ { m_aSeq.getArray()[ m_nPos ] = rEvt; ++m_nPos; }
+
+ const uno::Sequence< beans::PropertyChangeEvent >& getEvents()
+ { m_aSeq.realloc( m_nPos ); return m_aSeq; }
+};
+
+//=========================================================================
+//
+// PropertiesEventListenerMap.
+//
+//=========================================================================
+
+typedef void* XPropertiesChangeListenerPtr; // -> Compiler problems!
+
+struct equalPtr
+{
+ bool operator()( const XPropertiesChangeListenerPtr& rp1,
+ const XPropertiesChangeListenerPtr& rp2 ) const
+ {
+ return ( rp1 == rp2 );
+ }
+};
+
+struct hashPtr
+{
+ size_t operator()( const XPropertiesChangeListenerPtr& rp ) const
+ {
+ return (size_t)rp;
+ }
+};
+
+typedef std::hash_map
+<
+ XPropertiesChangeListenerPtr,
+ PropertyEventSequence*,
+ hashPtr,
+ equalPtr
+>
+PropertiesEventListenerMap;
+
+//=========================================================================
+//
+// PropertyChangeListenerContainer.
+//
+//=========================================================================
+
+struct equalStr
+{
+ bool operator()( const rtl::OUString& s1, const rtl::OUString& s2 ) const
+ {
+ return !!( s1 == s2 );
+ }
+};
+
+struct hashStr
+{
+ size_t operator()( const rtl::OUString& rName ) const
+ {
+ return rName.hashCode();
+ }
+};
+
+typedef cppu::OMultiTypeInterfaceContainerHelperVar
+<
+ rtl::OUString,
+ hashStr,
+ equalStr
+> PropertyChangeListeners;
+
+//=========================================================================
+//
+// struct ContentImplHelper_Impl
+//
+//=========================================================================
+
+struct ContentImplHelper_Impl
+{
+ rtl::Reference< ::ucbhelper::PropertySetInfo > m_xPropSetInfo;
+ rtl::Reference< ::ucbhelper::CommandProcessorInfo > m_xCommandsInfo;
+ cppu::OInterfaceContainerHelper* m_pDisposeEventListeners;
+ cppu::OInterfaceContainerHelper* m_pContentEventListeners;
+ cppu::OInterfaceContainerHelper* m_pPropSetChangeListeners;
+ cppu::OInterfaceContainerHelper* m_pCommandChangeListeners;
+ PropertyChangeListeners* m_pPropertyChangeListeners;
+
+ ContentImplHelper_Impl()
+ : m_pDisposeEventListeners( 0 ),
+ m_pContentEventListeners( 0 ),
+ m_pPropSetChangeListeners( 0 ),
+ m_pCommandChangeListeners( 0 ),
+ m_pPropertyChangeListeners( 0 ) {}
+
+ ~ContentImplHelper_Impl()
+ {
+ delete m_pDisposeEventListeners;
+ delete m_pContentEventListeners;
+ delete m_pPropSetChangeListeners;
+ delete m_pCommandChangeListeners;
+ delete m_pPropertyChangeListeners;
+ }
+};
+
+} // namespace ucbhelper_impl
+
+using namespace ucbhelper_impl;
+
+//=========================================================================
+//=========================================================================
+//
+// ContentImplHelper Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+namespace ucbhelper {
+
+ContentImplHelper::ContentImplHelper(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
+ const rtl::Reference< ContentProviderImplHelper >& rxProvider,
+ const uno::Reference<
+ com::sun::star::ucb::XContentIdentifier >& Identifier )
+: m_pImpl( new ContentImplHelper_Impl ),
+ m_xSMgr( rxSMgr ),
+ m_xIdentifier( Identifier ),
+ m_xProvider( rxProvider ),
+ m_nCommandId( 0 )
+{
+}
+
+//=========================================================================
+// virtual
+ContentImplHelper::~ContentImplHelper()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+void SAL_CALL ContentImplHelper::acquire()
+ throw()
+{
+ cppu::OWeakObject::acquire();
+}
+
+void SAL_CALL ContentImplHelper::release()
+ throw()
+{
+ // #144882# - Call to OWeakObject::release may destroy m_xProvider.
+ // Prevent this.
+ rtl::Reference< ContentProviderImplHelper > xKeepProviderAlive(
+ m_xProvider );
+
+ {
+ osl::MutexGuard aGuard( m_xProvider->m_aMutex );
+ OWeakObject::release();
+ }
+}
+
+uno::Any SAL_CALL ContentImplHelper::queryInterface( const uno::Type & rType )
+ throw( uno::RuntimeException )
+{
+ com::sun::star::uno::Any aRet = cppu::queryInterface( rType,
+ static_cast< lang::XTypeProvider * >(this),
+ static_cast< lang::XServiceInfo * >(this),
+ static_cast< lang::XComponent * >(this),
+ static_cast< com::sun::star::ucb::XContent * >(this),
+ static_cast< com::sun::star::ucb::XCommandProcessor * >(this),
+ static_cast< beans::XPropertiesChangeNotifier * >(this),
+ static_cast< com::sun::star::ucb::XCommandInfoChangeNotifier * >(this),
+ static_cast< beans::XPropertyContainer * >(this),
+ static_cast< beans::XPropertySetInfoChangeNotifier * >(this),
+ static_cast< container::XChild * >(this));
+ return aRet.hasValue() ? aRet : cppu::OWeakObject::queryInterface( rType );
+}
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_10( ContentImplHelper,
+ lang::XTypeProvider,
+ lang::XServiceInfo,
+ lang::XComponent,
+ com::sun::star::ucb::XContent,
+ com::sun::star::ucb::XCommandProcessor,
+ beans::XPropertiesChangeNotifier,
+ com::sun::star::ucb::XCommandInfoChangeNotifier,
+ beans::XPropertyContainer,
+ beans::XPropertySetInfoChangeNotifier,
+ container::XChild );
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+// virtual
+sal_Bool SAL_CALL ContentImplHelper::supportsService(
+ const rtl::OUString& ServiceName )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
+ const rtl::OUString* pArray = aSNL.getConstArray();
+ for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ {
+ if ( pArray[ i ] == ServiceName )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+//=========================================================================
+//
+// XComponent methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ContentImplHelper::dispose()
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pImpl->m_pDisposeEventListeners &&
+ m_pImpl->m_pDisposeEventListeners->getLength() )
+ {
+ lang::EventObject aEvt;
+ aEvt.Source = static_cast< lang::XComponent * >( this );
+ m_pImpl->m_pDisposeEventListeners->disposeAndClear( aEvt );
+ }
+
+ if ( m_pImpl->m_pContentEventListeners &&
+ m_pImpl->m_pContentEventListeners->getLength() )
+ {
+ lang::EventObject aEvt;
+ aEvt.Source = static_cast< com::sun::star::ucb::XContent * >( this );
+ m_pImpl->m_pContentEventListeners->disposeAndClear( aEvt );
+ }
+
+ if ( m_pImpl->m_pPropSetChangeListeners &&
+ m_pImpl->m_pPropSetChangeListeners->getLength() )
+ {
+ lang::EventObject aEvt;
+ aEvt.Source
+ = static_cast< beans::XPropertySetInfoChangeNotifier * >( this );
+ m_pImpl->m_pPropSetChangeListeners->disposeAndClear( aEvt );
+ }
+
+ if ( m_pImpl->m_pCommandChangeListeners &&
+ m_pImpl->m_pCommandChangeListeners->getLength() )
+ {
+ lang::EventObject aEvt;
+ aEvt.Source = static_cast< com::sun::star::ucb::XCommandInfoChangeNotifier * >( this );
+ m_pImpl->m_pCommandChangeListeners->disposeAndClear( aEvt );
+ }
+
+ if ( m_pImpl->m_pPropertyChangeListeners )
+ {
+ lang::EventObject aEvt;
+ aEvt.Source
+ = static_cast< beans::XPropertiesChangeNotifier * >( this );
+ m_pImpl->m_pPropertyChangeListeners->disposeAndClear( aEvt );
+ }
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ContentImplHelper::addEventListener(
+ const uno::Reference< lang::XEventListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl->m_pDisposeEventListeners )
+ m_pImpl->m_pDisposeEventListeners
+ = new cppu::OInterfaceContainerHelper( m_aMutex );
+
+ m_pImpl->m_pDisposeEventListeners->addInterface( Listener );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ContentImplHelper::removeEventListener(
+ const uno::Reference< lang::XEventListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pImpl->m_pDisposeEventListeners )
+ m_pImpl->m_pDisposeEventListeners->removeInterface( Listener );
+}
+
+//=========================================================================
+//
+// XContent methods.
+//
+//=========================================================================
+
+// virtual
+uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL
+ContentImplHelper::getIdentifier()
+ throw( uno::RuntimeException )
+{
+ return m_xIdentifier;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ContentImplHelper::addContentEventListener(
+ const uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl->m_pContentEventListeners )
+ m_pImpl->m_pContentEventListeners
+ = new cppu::OInterfaceContainerHelper( m_aMutex );
+
+ m_pImpl->m_pContentEventListeners->addInterface( Listener );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ContentImplHelper::removeContentEventListener(
+ const uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pImpl->m_pContentEventListeners )
+ m_pImpl->m_pContentEventListeners->removeInterface( Listener );
+}
+
+//=========================================================================
+//
+// XCommandProcessor methods.
+//
+//=========================================================================
+
+// virtual
+sal_Int32 SAL_CALL ContentImplHelper::createCommandIdentifier()
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ // Just increase counter on every call to generate an identifier.
+ return ++m_nCommandId;
+}
+
+//=========================================================================
+//
+// XPropertiesChangeNotifier methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ContentImplHelper::addPropertiesChangeListener(
+ const uno::Sequence< rtl::OUString >& PropertyNames,
+ const uno::Reference< beans::XPropertiesChangeListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl->m_pPropertyChangeListeners )
+ m_pImpl->m_pPropertyChangeListeners
+ = new PropertyChangeListeners( m_aMutex );
+
+ sal_Int32 nCount = PropertyNames.getLength();
+ if ( !nCount )
+ {
+ // Note: An empty sequence means a listener for "all" properties.
+ m_pImpl->m_pPropertyChangeListeners->addInterface(
+ rtl::OUString(), Listener );
+ }
+ else
+ {
+ const rtl::OUString* pSeq = PropertyNames.getConstArray();
+
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const rtl::OUString& rName = pSeq[ n ];
+ if ( rName.getLength() )
+ m_pImpl->m_pPropertyChangeListeners->addInterface(
+ rName, Listener );
+ }
+ }
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ContentImplHelper::removePropertiesChangeListener(
+ const uno::Sequence< rtl::OUString >& PropertyNames,
+ const uno::Reference< beans::XPropertiesChangeListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl->m_pPropertyChangeListeners )
+ return;
+
+ sal_Int32 nCount = PropertyNames.getLength();
+ if ( !nCount )
+ {
+ // Note: An empty sequence means a listener for "all" properties.
+ m_pImpl->m_pPropertyChangeListeners->removeInterface(
+ rtl::OUString(), Listener );
+ }
+ else
+ {
+ const rtl::OUString* pSeq = PropertyNames.getConstArray();
+
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const rtl::OUString& rName = pSeq[ n ];
+ if ( rName.getLength() )
+ m_pImpl->m_pPropertyChangeListeners->removeInterface(
+ rName, Listener );
+ }
+ }
+}
+
+//=========================================================================
+//
+// XCommandInfoChangeNotifier methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ContentImplHelper::addCommandInfoChangeListener(
+ const uno::Reference< com::sun::star::ucb::XCommandInfoChangeListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl->m_pCommandChangeListeners )
+ m_pImpl->m_pCommandChangeListeners
+ = new cppu::OInterfaceContainerHelper( m_aMutex );
+
+ m_pImpl->m_pCommandChangeListeners->addInterface( Listener );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ContentImplHelper::removeCommandInfoChangeListener(
+ const uno::Reference< com::sun::star::ucb::XCommandInfoChangeListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pImpl->m_pCommandChangeListeners )
+ m_pImpl->m_pCommandChangeListeners->removeInterface( Listener );
+}
+
+//=========================================================================
+//
+// XPropertyContainer methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ContentImplHelper::addProperty(
+ const rtl::OUString& Name,
+ sal_Int16 Attributes,
+ const uno::Any& DefaultValue )
+ throw( beans::PropertyExistException,
+ beans::IllegalTypeException,
+ lang::IllegalArgumentException,
+ uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ //////////////////////////////////////////////////////////////////////
+ // Make sure a property with the requested name does not already
+ // exist in dynamic and static(!) properties.
+ //////////////////////////////////////////////////////////////////////
+
+ // @@@ Need real command environment here, but where to get it from?
+ // XPropertyContainer interface should be replaced by
+ // XCommandProcessor commands!
+ uno::Reference< com::sun::star::ucb::XCommandEnvironment > xEnv;
+
+ if ( getPropertySetInfo( xEnv )->hasPropertyByName( Name ) )
+ {
+ // Property does already exist.
+ throw beans::PropertyExistException();
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Add a new dynamic property.
+ //////////////////////////////////////////////////////////////////////
+
+ // Open/create persistent property set.
+ uno::Reference< com::sun::star::ucb::XPersistentPropertySet > xSet(
+ getAdditionalPropertySet( sal_True ) );
+
+ OSL_ENSURE( xSet.is(),
+ "ContentImplHelper::addProperty - No property set!" );
+
+ if ( xSet.is() )
+ {
+ uno::Reference< beans::XPropertyContainer > xContainer(
+ xSet, uno::UNO_QUERY );
+
+ OSL_ENSURE(
+ xContainer.is(),
+ "ContentImplHelper::addProperty - No property container!" );
+
+ if ( xContainer.is() )
+ {
+ // Property is always removeable.
+ Attributes |= beans::PropertyAttribute::REMOVEABLE;
+
+ try
+ {
+ xContainer->addProperty( Name, Attributes, DefaultValue );
+ }
+ catch ( beans::PropertyExistException const & )
+ {
+ OSL_ENSURE( sal_False,
+ "ContentImplHelper::addProperty - Exists!" );
+ throw;
+ }
+ catch ( beans::IllegalTypeException const & )
+ {
+ OSL_ENSURE( sal_False,
+ "ContentImplHelper::addProperty - Wrong Type!" );
+ throw;
+ }
+ catch ( lang::IllegalArgumentException const & )
+ {
+ OSL_ENSURE( sal_False,
+ "ContentImplHelper::addProperty - Illegal Arg!" );
+ throw;
+ }
+
+ // Success!
+
+ if ( m_pImpl->m_xPropSetInfo.is() )
+ {
+ // Info cached in propertyset info is invalid now!
+ m_pImpl->m_xPropSetInfo->reset();
+ }
+
+ // Notify propertyset info change listeners.
+ if ( m_pImpl->m_pPropSetChangeListeners &&
+ m_pImpl->m_pPropSetChangeListeners->getLength() )
+ {
+ beans::PropertySetInfoChangeEvent evt(
+ static_cast< cppu::OWeakObject * >( this ),
+ Name,
+ -1, // No handle available
+ beans::PropertySetInfoChange::PROPERTY_INSERTED );
+ notifyPropertySetInfoChange( evt );
+ }
+ }
+ }
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ContentImplHelper::removeProperty( const rtl::OUString& Name )
+ throw( beans::UnknownPropertyException,
+ beans::NotRemoveableException,
+ uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ try
+ {
+ // @@@ Need real command environment here, but where to get it from?
+ // XPropertyContainer interface should be replaced by
+ // XCommandProcessor commands!
+ uno::Reference< com::sun::star::ucb::XCommandEnvironment > xEnv;
+
+ beans::Property aProp
+ = getPropertySetInfo( xEnv )->getPropertyByName( Name );
+
+ if ( !( aProp.Attributes & beans::PropertyAttribute::REMOVEABLE ) )
+ {
+ // Not removeable!
+ throw beans::NotRemoveableException();
+ }
+ }
+ catch ( beans::UnknownPropertyException const & )
+ {
+ OSL_ENSURE( sal_False, "ContentImplHelper::removeProperty - Unknown!" );
+ throw;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Try to remove property from dynamic property set.
+ //////////////////////////////////////////////////////////////////////
+
+ // Open persistent property set, if exists.
+ uno::Reference< com::sun::star::ucb::XPersistentPropertySet > xSet(
+ getAdditionalPropertySet( sal_False ) );
+ if ( xSet.is() )
+ {
+ uno::Reference< beans::XPropertyContainer > xContainer(
+ xSet, uno::UNO_QUERY );
+
+ OSL_ENSURE(
+ xContainer.is(),
+ "ContentImplHelper::removeProperty - No property container!" );
+
+ if ( xContainer.is() )
+ {
+ try
+ {
+ xContainer->removeProperty( Name );
+ }
+ catch ( beans::UnknownPropertyException const & )
+ {
+ OSL_ENSURE( sal_False,
+ "ContentImplHelper::removeProperty - Unknown!" );
+ throw;
+ }
+ catch ( beans::NotRemoveableException const & )
+ {
+ OSL_ENSURE(
+ sal_False,
+ "ContentImplHelper::removeProperty - Unremoveable!" );
+ throw;
+ }
+
+ xContainer = 0;
+
+ // Success!
+
+ if ( xSet->getPropertySetInfo()->getProperties().getLength() == 0 )
+ {
+ // Remove empty propertyset from registry.
+ uno::Reference< com::sun::star::ucb::XPropertySetRegistry >
+ xReg = xSet->getRegistry();
+ if ( xReg.is() )
+ {
+ rtl::OUString aKey( xSet->getKey() );
+ xSet = 0;
+ xReg->removePropertySet( aKey );
+ }
+ }
+
+ if ( m_pImpl->m_xPropSetInfo.is() )
+ {
+ // Info cached in propertyset info is invalid now!
+ m_pImpl->m_xPropSetInfo->reset();
+ }
+
+ // Notify propertyset info change listeners.
+ if ( m_pImpl->m_pPropSetChangeListeners &&
+ m_pImpl->m_pPropSetChangeListeners->getLength() )
+ {
+ beans::PropertySetInfoChangeEvent evt(
+ static_cast< cppu::OWeakObject * >( this ),
+ Name,
+ -1, // No handle available
+ beans::PropertySetInfoChange::PROPERTY_REMOVED );
+ notifyPropertySetInfoChange( evt );
+ }
+ }
+ }
+}
+
+//=========================================================================
+//
+// XPropertySetInfoChangeNotifier methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ContentImplHelper::addPropertySetInfoChangeListener(
+ const uno::Reference< beans::XPropertySetInfoChangeListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl->m_pPropSetChangeListeners )
+ m_pImpl->m_pPropSetChangeListeners
+ = new cppu::OInterfaceContainerHelper( m_aMutex );
+
+ m_pImpl->m_pPropSetChangeListeners->addInterface( Listener );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ContentImplHelper::removePropertySetInfoChangeListener(
+ const uno::Reference< beans::XPropertySetInfoChangeListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pImpl->m_pPropSetChangeListeners )
+ m_pImpl->m_pPropSetChangeListeners->removeInterface( Listener );
+}
+
+//=========================================================================
+//
+// XChild methods.
+//
+//=========================================================================
+
+// virtual
+uno::Reference< uno::XInterface > SAL_CALL ContentImplHelper::getParent()
+ throw( uno::RuntimeException )
+{
+ uno::Reference< uno::XInterface > xParent;
+ rtl::OUString aURL = getParentURL();
+
+ if ( aURL.getLength() )
+ {
+ uno::Reference< com::sun::star::ucb::XContentIdentifier > xId(
+ new ContentIdentifier( m_xSMgr, aURL ) );
+ try
+ {
+ xParent.set( m_xProvider->queryContent( xId ) );
+ }
+ catch ( com::sun::star::ucb::IllegalIdentifierException const & )
+ {
+ }
+ }
+
+ return xParent;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ContentImplHelper::setParent(
+ const uno::Reference< uno::XInterface >& )
+ throw( lang::NoSupportException, uno::RuntimeException )
+{
+ throw lang::NoSupportException();
+}
+
+//=========================================================================
+//
+// Non-interface methods
+//
+//=========================================================================
+
+uno::Reference< com::sun::star::ucb::XPersistentPropertySet >
+ContentImplHelper::getAdditionalPropertySet( sal_Bool bCreate )
+{
+ // Get propertyset from provider.
+ return m_xProvider->getAdditionalPropertySet(
+ m_xIdentifier->getContentIdentifier(), bCreate );
+}
+
+//=========================================================================
+sal_Bool ContentImplHelper::renameAdditionalPropertySet(
+ const rtl::OUString& rOldKey,
+ const rtl::OUString& rNewKey,
+ sal_Bool bRecursive )
+{
+ return m_xProvider->renameAdditionalPropertySet(
+ rOldKey, rNewKey, bRecursive );
+}
+
+//=========================================================================
+sal_Bool ContentImplHelper::copyAdditionalPropertySet(
+ const rtl::OUString& rSourceKey,
+ const rtl::OUString& rTargetKey,
+ sal_Bool bRecursive )
+{
+ return m_xProvider->copyAdditionalPropertySet(
+ rSourceKey, rTargetKey, bRecursive );
+}
+
+//=========================================================================
+sal_Bool ContentImplHelper::removeAdditionalPropertySet( sal_Bool bRecursive )
+{
+ return m_xProvider->removeAdditionalPropertySet(
+ m_xIdentifier->getContentIdentifier(), bRecursive );
+}
+
+//=========================================================================
+void ContentImplHelper::notifyPropertiesChange(
+ const uno::Sequence< beans::PropertyChangeEvent >& evt ) const
+{
+ if ( !m_pImpl->m_pPropertyChangeListeners )
+ return;
+
+ sal_Int32 nCount = evt.getLength();
+ if ( nCount )
+ {
+ // First, notify listeners interested in changes of every property.
+ cppu::OInterfaceContainerHelper* pAllPropsContainer
+ = m_pImpl->m_pPropertyChangeListeners->getContainer(
+ rtl::OUString() );
+ if ( pAllPropsContainer )
+ {
+ cppu::OInterfaceIteratorHelper aIter( *pAllPropsContainer );
+ while ( aIter.hasMoreElements() )
+ {
+ // Propagate event.
+ uno::Reference< beans::XPropertiesChangeListener > xListener(
+ aIter.next(), uno::UNO_QUERY );
+ if ( xListener.is() )
+ xListener->propertiesChange( evt );
+ }
+ }
+
+ PropertiesEventListenerMap aListeners;
+
+ const beans::PropertyChangeEvent* pEvents = evt.getConstArray();
+
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const beans::PropertyChangeEvent& rEvent = pEvents[ n ];
+ const rtl::OUString& rName = rEvent.PropertyName;
+
+ cppu::OInterfaceContainerHelper* pPropsContainer
+ = m_pImpl->m_pPropertyChangeListeners->getContainer( rName );
+ if ( pPropsContainer )
+ {
+ cppu::OInterfaceIteratorHelper aIter( *pPropsContainer );
+ while ( aIter.hasMoreElements() )
+ {
+ PropertyEventSequence* p = NULL;
+
+ beans::XPropertiesChangeListener* pListener =
+ static_cast< beans::XPropertiesChangeListener * >(
+ aIter.next() );
+ PropertiesEventListenerMap::iterator it =
+ aListeners.find( pListener );
+ if ( it == aListeners.end() )
+ {
+ // Not in map - create and insert new entry.
+ p = new PropertyEventSequence( nCount );
+ aListeners[ pListener ] = p;
+ }
+ else
+ p = (*it).second;
+
+ if ( p )
+ p->append( rEvent );
+ }
+ }
+ }
+
+ // Notify listeners.
+ PropertiesEventListenerMap::iterator it = aListeners.begin();
+ while ( !aListeners.empty() )
+ {
+ beans::XPropertiesChangeListener* pListener =
+ static_cast< beans::XPropertiesChangeListener * >( (*it).first );
+ PropertyEventSequence* pSeq = (*it).second;
+
+ // Remove current element.
+ aListeners.erase( it );
+
+ // Propagate event.
+ pListener->propertiesChange( pSeq->getEvents() );
+
+ delete pSeq;
+
+ it = aListeners.begin();
+ }
+ }
+}
+
+//=========================================================================
+void ContentImplHelper::notifyPropertySetInfoChange(
+ const beans::PropertySetInfoChangeEvent& evt ) const
+{
+ if ( !m_pImpl->m_pPropSetChangeListeners )
+ return;
+
+ // Notify event listeners.
+ cppu::OInterfaceIteratorHelper aIter( *m_pImpl->m_pPropSetChangeListeners );
+ while ( aIter.hasMoreElements() )
+ {
+ // Propagate event.
+ uno::Reference< beans::XPropertySetInfoChangeListener >
+ xListener( aIter.next(), uno::UNO_QUERY );
+ if ( xListener.is() )
+ xListener->propertySetInfoChange( evt );
+ }
+}
+
+//=========================================================================
+void ContentImplHelper::notifyCommandInfoChange(
+ const com::sun::star::ucb::CommandInfoChangeEvent& evt ) const
+{
+ if ( !m_pImpl->m_pCommandChangeListeners )
+ return;
+
+ // Notify event listeners.
+ cppu::OInterfaceIteratorHelper aIter(
+ *m_pImpl->m_pCommandChangeListeners );
+ while ( aIter.hasMoreElements() )
+ {
+ // Propagate event.
+ uno::Reference< com::sun::star::ucb::XCommandInfoChangeListener >
+ xListener( aIter.next(), uno::UNO_QUERY );
+ if ( xListener.is() )
+ xListener->commandInfoChange( evt );
+ }
+}
+
+//=========================================================================
+void ContentImplHelper::notifyContentEvent(
+ const com::sun::star::ucb::ContentEvent& evt ) const
+{
+ if ( !m_pImpl->m_pContentEventListeners )
+ return;
+
+ // Notify event listeners.
+ cppu::OInterfaceIteratorHelper aIter( *m_pImpl->m_pContentEventListeners );
+ while ( aIter.hasMoreElements() )
+ {
+ // Propagate event.
+ uno::Reference<
+ com::sun::star::ucb::XContentEventListener > xListener(
+ aIter.next(), uno::UNO_QUERY );
+ if ( xListener.is() )
+ xListener->contentEvent( evt );
+ }
+}
+
+//=========================================================================
+void ContentImplHelper::inserted()
+{
+ // Content is not yet registered at provider.
+ m_xProvider->registerNewContent( this );
+
+ // If the parent content is currently not instanciated, there can be
+ // no listeners interested in changes ;-)
+
+ rtl::Reference< ContentImplHelper > xParent
+ = m_xProvider->queryExistingContent( getParentURL() );
+
+ if ( xParent.is() )
+ {
+ com::sun::star::ucb::ContentEvent aEvt(
+ static_cast< cppu::OWeakObject * >( xParent.get() ), // Source
+ com::sun::star::ucb::ContentAction::INSERTED, // Action
+ this, // Content
+ xParent->getIdentifier() ); // Id
+ xParent->notifyContentEvent( aEvt );
+ }
+}
+
+//=========================================================================
+void ContentImplHelper::deleted()
+{
+ uno::Reference< com::sun::star::ucb::XContent > xThis = this;
+
+ rtl::Reference< ContentImplHelper > xParent
+ = m_xProvider->queryExistingContent( getParentURL() );
+
+ if ( xParent.is() )
+ {
+ // Let parent notify "REMOVED" event.
+ com::sun::star::ucb::ContentEvent aEvt(
+ static_cast< cppu::OWeakObject * >( xParent.get() ),
+ com::sun::star::ucb::ContentAction::REMOVED,
+ this,
+ xParent->getIdentifier() );
+ xParent->notifyContentEvent( aEvt );
+ }
+
+ // Notify "DELETED" event.
+ com::sun::star::ucb::ContentEvent aEvt1(
+ static_cast< cppu::OWeakObject * >( this ),
+ com::sun::star::ucb::ContentAction::DELETED,
+ this,
+ getIdentifier() );
+ notifyContentEvent( aEvt1 );
+
+ m_xProvider->removeContent( this );
+}
+
+//=========================================================================
+sal_Bool ContentImplHelper::exchange(
+ const uno::Reference< com::sun::star::ucb::XContentIdentifier >& rNewId )
+{
+ uno::Reference< com::sun::star::ucb::XContent > xThis = this;
+
+ osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ rtl::Reference< ContentImplHelper > xContent
+ = m_xProvider->queryExistingContent( rNewId );
+ if ( xContent.is() )
+ {
+ // @@@
+ // Big trouble. Another object with the new identity exists.
+ // How shall I mutate to / merge with the other object?
+ return sal_False;
+ }
+
+ uno::Reference< com::sun::star::ucb::XContentIdentifier > xOldId
+ = getIdentifier();
+
+ // Re-insert at provider.
+ m_xProvider->removeContent( this );
+ m_xIdentifier = rNewId;
+ m_xProvider->registerNewContent( this );
+
+ aGuard.clear();
+
+ // Notify "EXCHANGED" event.
+ com::sun::star::ucb::ContentEvent aEvt(
+ static_cast< cppu::OWeakObject * >( this ),
+ com::sun::star::ucb::ContentAction::EXCHANGED,
+ this,
+ xOldId );
+ notifyContentEvent( aEvt );
+ return sal_True;
+}
+
+//=========================================================================
+uno::Reference< com::sun::star::ucb::XCommandInfo >
+ContentImplHelper::getCommandInfo(
+ const uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv,
+ sal_Bool bCache )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl->m_xCommandsInfo.is() )
+ m_pImpl->m_xCommandsInfo
+ = new CommandProcessorInfo( m_xSMgr, xEnv, this );
+ else if ( !bCache )
+ m_pImpl->m_xCommandsInfo->reset();
+
+ return uno::Reference< com::sun::star::ucb::XCommandInfo >(
+ m_pImpl->m_xCommandsInfo.get() );
+}
+
+//=========================================================================
+uno::Reference< beans::XPropertySetInfo >
+ContentImplHelper::getPropertySetInfo(
+ const uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv,
+ sal_Bool bCache )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl->m_xPropSetInfo.is() )
+ m_pImpl->m_xPropSetInfo
+ = new PropertySetInfo( m_xSMgr, xEnv, this );
+ else if ( !bCache )
+ m_pImpl->m_xPropSetInfo->reset();
+
+ return uno::Reference< beans::XPropertySetInfo >(
+ m_pImpl->m_xPropSetInfo.get() );
+}
+
+} // namespace ucbhelper
diff --git a/ucbhelper/source/provider/contentidentifier.cxx b/ucbhelper/source/provider/contentidentifier.cxx
new file mode 100644
index 000000000000..7324c2cd5835
--- /dev/null
+++ b/ucbhelper/source/provider/contentidentifier.cxx
@@ -0,0 +1,221 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <ucbhelper/contentidentifier.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <osl/mutex.hxx>
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::ucb;
+
+namespace ucbhelper
+{
+
+//=========================================================================
+//=========================================================================
+//
+// struct ContentIdentifier_Impl.
+//
+//=========================================================================
+//=========================================================================
+
+struct ContentIdentifier_Impl
+{
+ Reference< XMultiServiceFactory > m_xSMgr;
+ OUString m_aContentId;
+ OUString m_aProviderScheme;
+ osl::Mutex m_aMutex;
+
+ ContentIdentifier_Impl( const Reference< XMultiServiceFactory >& rSMgr,
+ const OUString& rURL );
+};
+
+//=========================================================================
+//
+// ContentIdentifier_Impl Implementation.
+//
+//=========================================================================
+
+ContentIdentifier_Impl::ContentIdentifier_Impl(
+ const Reference< XMultiServiceFactory >& rSMgr,
+ const OUString& rURL )
+: m_xSMgr( rSMgr )
+{
+ // Normalize URL scheme ( it's case insensitive ).
+
+ // The content provider scheme is the part before the first ':'
+ // within the content id.
+ sal_Int32 nPos = rURL.indexOf( ':', 0 );
+ if ( nPos != -1 )
+ {
+ OUString aScheme( rURL.copy( 0, nPos ) );
+ m_aProviderScheme = aScheme.toAsciiLowerCase();
+ m_aContentId = rURL.replaceAt( 0, nPos, aScheme );
+ }
+}
+
+//=========================================================================
+//
+// ContentIdentifier Implementation.
+//
+//=========================================================================
+
+ContentIdentifier::ContentIdentifier(
+ const Reference< XMultiServiceFactory >& rxSMgr,
+ const OUString& rURL )
+{
+ m_pImpl = new ContentIdentifier_Impl( rxSMgr, rURL );
+}
+
+//=========================================================================
+ContentIdentifier::ContentIdentifier( const OUString& rURL )
+{
+ m_pImpl = new ContentIdentifier_Impl(
+ Reference< XMultiServiceFactory >(), rURL );
+}
+
+//=========================================================================
+// virtual
+ContentIdentifier::~ContentIdentifier()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+//=========================================================================
+// virtual
+void SAL_CALL ContentIdentifier::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ContentIdentifier::release() throw()
+{
+ OWeakObject::release();
+}
+
+//=========================================================================
+// virtual
+Any SAL_CALL
+ContentIdentifier::queryInterface( const Type & rType )
+ throw ( RuntimeException )
+{
+ Any aRet = cppu::queryInterface( rType,
+ static_cast< XTypeProvider * >( this ),
+ static_cast< XContentIdentifier * >( this ) );
+
+ return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
+}
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+// virtual
+Sequence< sal_Int8 > SAL_CALL
+ContentIdentifier::getImplementationId()
+ throw( RuntimeException )
+{
+ static cppu::OImplementationId* pId = NULL;
+ if ( !pId )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static cppu::OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+//=========================================================================
+// virtual
+Sequence< com::sun::star::uno::Type > SAL_CALL
+ContentIdentifier::getTypes()
+ throw( RuntimeException )
+{
+ static cppu::OTypeCollection* pCollection = NULL;
+ if ( !pCollection )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pCollection )
+ {
+ static cppu::OTypeCollection collection(
+ getCppuType( static_cast<
+ Reference < XTypeProvider > * >( 0 ) ),
+ getCppuType( static_cast<
+ Reference< XContentIdentifier > * >( 0 ) ) );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+}
+
+//=========================================================================
+//
+// XContentIdentifier methods.
+//
+//=========================================================================
+
+// virtual
+OUString SAL_CALL ContentIdentifier::getContentIdentifier()
+ throw( RuntimeException )
+{
+ return m_pImpl->m_aContentId;
+}
+
+//=========================================================================
+// virtual
+OUString SAL_CALL ContentIdentifier::getContentProviderScheme()
+ throw( RuntimeException )
+{
+ return m_pImpl->m_aProviderScheme;
+}
+
+} /* namespace ucbhelper */
+
diff --git a/ucbhelper/source/provider/contentinfo.cxx b/ucbhelper/source/provider/contentinfo.cxx
new file mode 100644
index 000000000000..72dc633bd274
--- /dev/null
+++ b/ucbhelper/source/provider/contentinfo.cxx
@@ -0,0 +1,423 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/ucb/XPropertySetRegistry.hpp>
+
+#include "osl/diagnose.h"
+#include "osl/mutex.hxx"
+#include <ucbhelper/contenthelper.hxx>
+#include <ucbhelper/contentinfo.hxx>
+
+using namespace com::sun::star;
+
+//=========================================================================
+//=========================================================================
+//
+// PropertySetInfo Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+namespace ucbhelper {
+
+PropertySetInfo::PropertySetInfo(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
+ const uno::Reference< com::sun::star::ucb::XCommandEnvironment >& rxEnv,
+ ContentImplHelper* pContent )
+: m_xSMgr( rxSMgr ),
+ m_xEnv( rxEnv ),
+ m_pProps( 0 ),
+ m_pContent( pContent )
+{
+}
+
+//=========================================================================
+// virtual
+PropertySetInfo::~PropertySetInfo()
+{
+ delete m_pProps;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_2( PropertySetInfo,
+ lang::XTypeProvider,
+ beans::XPropertySetInfo );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_2( PropertySetInfo,
+ lang::XTypeProvider,
+ beans::XPropertySetInfo );
+
+//=========================================================================
+//
+// XPropertySetInfo methods.
+//
+//=========================================================================
+
+// virtual
+uno::Sequence< beans::Property > SAL_CALL PropertySetInfo::getProperties()
+ throw( uno::RuntimeException )
+{
+ if ( !m_pProps )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pProps )
+ {
+ //////////////////////////////////////////////////////////////
+ // Get info for core ( native) properties.
+ //////////////////////////////////////////////////////////////
+
+ try
+ {
+ uno::Sequence< beans::Property > aProps
+ = m_pContent->getProperties( m_xEnv );
+ m_pProps = new uno::Sequence< beans::Property >( aProps );
+ }
+ catch ( uno::RuntimeException const & )
+ {
+ throw;
+ }
+ catch ( uno::Exception const & )
+ {
+ m_pProps = new uno::Sequence< beans::Property >( 0 );
+ }
+
+ //////////////////////////////////////////////////////////////
+ // Get info for additional properties.
+ //////////////////////////////////////////////////////////////
+
+ uno::Reference< com::sun::star::ucb::XPersistentPropertySet >
+ xSet ( m_pContent->getAdditionalPropertySet( sal_False ) );
+
+ if ( xSet.is() )
+ {
+ // Get property set info.
+ uno::Reference< beans::XPropertySetInfo > xInfo(
+ xSet->getPropertySetInfo() );
+ if ( xInfo.is() )
+ {
+ const uno::Sequence< beans::Property >& rAddProps
+ = xInfo->getProperties();
+ sal_Int32 nAddProps = rAddProps.getLength();
+ if ( nAddProps > 0 )
+ {
+ sal_Int32 nPos = m_pProps->getLength();
+ m_pProps->realloc( nPos + nAddProps );
+
+ beans::Property* pProps = m_pProps->getArray();
+ const beans::Property* pAddProps
+ = rAddProps.getConstArray();
+
+ for ( sal_Int32 n = 0; n < nAddProps; ++n, ++nPos )
+ pProps[ nPos ] = pAddProps[ n ];
+ }
+ }
+ }
+ }
+ }
+ return *m_pProps;
+}
+
+//=========================================================================
+// virtual
+beans::Property SAL_CALL PropertySetInfo::getPropertyByName(
+ const rtl::OUString& aName )
+ throw( beans::UnknownPropertyException, uno::RuntimeException )
+{
+ beans::Property aProp;
+ if ( queryProperty( aName, aProp ) )
+ return aProp;
+
+ throw beans::UnknownPropertyException();
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName(
+ const rtl::OUString& Name )
+ throw( uno::RuntimeException )
+{
+ beans::Property aProp;
+ return queryProperty( Name, aProp );
+}
+
+//=========================================================================
+//
+// Non-Interface methods.
+//
+//=========================================================================
+
+void PropertySetInfo::reset()
+{
+ osl::MutexGuard aGuard( m_aMutex );
+ delete m_pProps;
+ m_pProps = 0;
+}
+
+//=========================================================================
+sal_Bool PropertySetInfo::queryProperty(
+ const rtl::OUString& rName, beans::Property& rProp )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ getProperties();
+
+ const beans::Property* pProps = m_pProps->getConstArray();
+ sal_Int32 nCount = m_pProps->getLength();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const beans::Property& rCurrProp = pProps[ n ];
+ if ( rCurrProp.Name == rName )
+ {
+ rProp = rCurrProp;
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+//=========================================================================
+//=========================================================================
+//
+// CommandProcessorInfo Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+CommandProcessorInfo::CommandProcessorInfo(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
+ const uno::Reference< com::sun::star::ucb::XCommandEnvironment >& rxEnv,
+ ContentImplHelper* pContent )
+: m_xSMgr( rxSMgr ),
+ m_xEnv( rxEnv ),
+ m_pCommands( 0 ),
+ m_pContent( pContent )
+{
+}
+
+//=========================================================================
+// virtual
+CommandProcessorInfo::~CommandProcessorInfo()
+{
+ delete m_pCommands;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_2( CommandProcessorInfo,
+ lang::XTypeProvider,
+ com::sun::star::ucb::XCommandInfo );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_2( CommandProcessorInfo,
+ lang::XTypeProvider,
+ com::sun::star::ucb::XCommandInfo );
+
+//=========================================================================
+//
+// XCommandInfo methods.
+//
+//=========================================================================
+
+// virtual
+uno::Sequence< com::sun::star::ucb::CommandInfo > SAL_CALL
+CommandProcessorInfo::getCommands()
+ throw( uno::RuntimeException )
+{
+ if ( !m_pCommands )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pCommands )
+ {
+ //////////////////////////////////////////////////////////////
+ // Get info for commands.
+ //////////////////////////////////////////////////////////////
+
+ try
+ {
+ uno::Sequence< com::sun::star::ucb::CommandInfo > aCmds
+ = m_pContent->getCommands( m_xEnv );
+ m_pCommands
+ = new uno::Sequence< com::sun::star::ucb::CommandInfo >(
+ aCmds );
+ }
+ catch ( uno::RuntimeException const & )
+ {
+ throw;
+ }
+ catch ( uno::Exception const & )
+ {
+ m_pCommands
+ = new uno::Sequence< com::sun::star::ucb::CommandInfo >(
+ 0 );
+ }
+ }
+ }
+ return *m_pCommands;
+}
+
+//=========================================================================
+// virtual
+com::sun::star::ucb::CommandInfo SAL_CALL
+CommandProcessorInfo::getCommandInfoByName(
+ const rtl::OUString& Name )
+ throw( com::sun::star::ucb::UnsupportedCommandException,
+ uno::RuntimeException )
+{
+ com::sun::star::ucb::CommandInfo aInfo;
+ if ( queryCommand( Name, aInfo ) )
+ return aInfo;
+
+ throw com::sun::star::ucb::UnsupportedCommandException();
+}
+
+//=========================================================================
+// virtual
+com::sun::star::ucb::CommandInfo SAL_CALL
+CommandProcessorInfo::getCommandInfoByHandle( sal_Int32 Handle )
+ throw( com::sun::star::ucb::UnsupportedCommandException,
+ uno::RuntimeException )
+{
+ com::sun::star::ucb::CommandInfo aInfo;
+ if ( queryCommand( Handle, aInfo ) )
+ return aInfo;
+
+ throw com::sun::star::ucb::UnsupportedCommandException();
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByName(
+ const rtl::OUString& Name )
+ throw( uno::RuntimeException )
+{
+ com::sun::star::ucb::CommandInfo aInfo;
+ return queryCommand( Name, aInfo );
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByHandle( sal_Int32 Handle )
+ throw( uno::RuntimeException )
+{
+ com::sun::star::ucb::CommandInfo aInfo;
+ return queryCommand( Handle, aInfo );
+}
+
+//=========================================================================
+//
+// Non-Interface methods.
+//
+//=========================================================================
+
+void CommandProcessorInfo::reset()
+{
+ osl::MutexGuard aGuard( m_aMutex );
+ delete m_pCommands;
+ m_pCommands = 0;
+}
+
+
+//=========================================================================
+sal_Bool CommandProcessorInfo::queryCommand(
+ const rtl::OUString& rName,
+ com::sun::star::ucb::CommandInfo& rCommand )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ getCommands();
+
+ const com::sun::star::ucb::CommandInfo* pCommands
+ = m_pCommands->getConstArray();
+ sal_Int32 nCount = m_pCommands->getLength();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const com::sun::star::ucb::CommandInfo& rCurrCommand = pCommands[ n ];
+ if ( rCurrCommand.Name == rName )
+ {
+ rCommand = rCurrCommand;
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+//=========================================================================
+sal_Bool CommandProcessorInfo::queryCommand(
+ sal_Int32 nHandle,
+ com::sun::star::ucb::CommandInfo& rCommand )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ getCommands();
+
+ const com::sun::star::ucb::CommandInfo* pCommands
+ = m_pCommands->getConstArray();
+ sal_Int32 nCount = m_pCommands->getLength();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const com::sun::star::ucb::CommandInfo& rCurrCommand = pCommands[ n ];
+ if ( rCurrCommand.Handle == nHandle )
+ {
+ rCommand = rCurrCommand;
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+} // namespace ucbhelper
diff --git a/ucbhelper/source/provider/handleinteractionrequest.cxx b/ucbhelper/source/provider/handleinteractionrequest.cxx
new file mode 100644
index 000000000000..395a81c36fed
--- /dev/null
+++ b/ucbhelper/source/provider/handleinteractionrequest.cxx
@@ -0,0 +1,164 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_ucbhelper.hxx"
+#include "ucbhelper/handleinteractionrequest.hxx"
+#include "com/sun/star/task/XInteractionAbort.hpp"
+#include "com/sun/star/task/XInteractionHandler.hpp"
+#include "com/sun/star/task/XInteractionRetry.hpp"
+#include "com/sun/star/ucb/CommandFailedException.hpp"
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "cppuhelper/exc_hlp.hxx"
+#include "osl/diagnose.h"
+#include "rtl/ustring.hxx"
+#ifndef _UCBHELPER_INTERACTIONREQUEST_HXX
+#include "ucbhelper/interactionrequest.hxx"
+#endif
+#include "ucbhelper/simpleauthenticationrequest.hxx"
+#include "ucbhelper/simpleinteractionrequest.hxx"
+#include "ucbhelper/simplecertificatevalidationrequest.hxx"
+#ifndef INCLUDED_UTILITY
+#include <utility>
+#define INCLUDED_UTILITY
+#endif
+
+using namespace com::sun::star;
+
+namespace {
+
+void
+handle(uno::Reference< task::XInteractionRequest > const & rRequest,
+ uno::Reference< ucb::XCommandEnvironment > const & rEnvironment)
+ SAL_THROW((uno::Exception))
+{
+ OSL_ENSURE(rRequest.is(), "specification violation");
+ uno::Reference< task::XInteractionHandler > xHandler;
+ if (rEnvironment.is())
+ xHandler = rEnvironment->getInteractionHandler();
+ if (!xHandler.is())
+ cppu::throwException(rRequest->getRequest());
+ xHandler->handle(rRequest.get());
+}
+
+}
+
+namespace ucbhelper {
+
+sal_Int32
+handleInteractionRequest(
+ rtl::Reference< ucbhelper::SimpleInteractionRequest > const & rRequest,
+ uno::Reference< ucb::XCommandEnvironment > const & rEnvironment,
+ bool bThrowOnAbort)
+ SAL_THROW((uno::Exception))
+{
+ handle(rRequest.get(), rEnvironment);
+ sal_Int32 nResponse = rRequest->getResponse();
+ switch (nResponse)
+ {
+ case ucbhelper::CONTINUATION_UNKNOWN:
+ cppu::throwException(rRequest->getRequest());
+ break;
+
+ case ucbhelper::CONTINUATION_ABORT:
+ if (bThrowOnAbort)
+ throw ucb::CommandFailedException(
+ rtl::OUString(), 0, rRequest->getRequest());
+ break;
+ }
+ return nResponse;
+}
+
+std::pair< sal_Int32,
+ rtl::Reference< ucbhelper::InteractionSupplyAuthentication > >
+handleInteractionRequest(
+ rtl::Reference< ucbhelper::SimpleAuthenticationRequest > const & rRequest,
+ uno::Reference< ucb::XCommandEnvironment > const & rEnvironment,
+ bool bThrowOnAbort)
+ SAL_THROW((uno::Exception))
+{
+ handle(rRequest.get(), rEnvironment);
+ rtl::Reference< ucbhelper::InteractionContinuation >
+ xContinuation(rRequest->getSelection());
+ if (uno::Reference< task::XInteractionAbort >(
+ xContinuation.get(), uno::UNO_QUERY).
+ is())
+ if (bThrowOnAbort)
+ throw ucb::CommandFailedException(
+ rtl::OUString(), 0, rRequest->getRequest());
+ else
+ return std::make_pair(
+ ucbhelper::CONTINUATION_ABORT,
+ rtl::Reference<
+ ucbhelper::InteractionSupplyAuthentication >());
+ else if (uno::Reference< task::XInteractionRetry >(
+ xContinuation.get(), uno::UNO_QUERY).
+ is())
+ return std::make_pair(
+ ucbhelper::CONTINUATION_ABORT,
+ rtl::Reference<
+ ucbhelper::InteractionSupplyAuthentication >());
+ else
+ return std::make_pair(
+ ucbhelper::CONTINUATION_UNKNOWN,
+ rtl::Reference<
+ ucbhelper::InteractionSupplyAuthentication >(
+ rRequest->getAuthenticationSupplier()));
+}
+
+}
+
+namespace ucbhelper {
+
+sal_Int32
+handleInteractionRequest(
+ rtl::Reference< ucbhelper::SimpleCertificateValidationRequest > const & rRequest,
+ uno::Reference< ucb::XCommandEnvironment > const & rEnvironment,
+ bool bThrowOnAbort)
+ SAL_THROW((uno::Exception))
+{
+ handle(rRequest.get(), rEnvironment);
+ sal_Int32 nResponse = rRequest->getResponse();
+ switch (nResponse)
+ {
+ case ucbhelper::CONTINUATION_UNKNOWN:
+ cppu::throwException(rRequest->getRequest());
+ break;
+
+ case ucbhelper::CONTINUATION_ABORT:
+ if (bThrowOnAbort)
+ throw ucb::CommandFailedException(
+ rtl::OUString(), 0, rRequest->getRequest());
+ break;
+ }
+ return nResponse;
+}
+
+}
+
diff --git a/ucbhelper/source/provider/interactionrequest.cxx b/ucbhelper/source/provider/interactionrequest.cxx
new file mode 100644
index 000000000000..3704a0f1546c
--- /dev/null
+++ b/ucbhelper/source/provider/interactionrequest.cxx
@@ -0,0 +1,1151 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+#include <osl/mutex.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <ucbhelper/interactionrequest.hxx>
+
+using namespace com::sun::star;
+using namespace ucbhelper;
+
+//=========================================================================
+//=========================================================================
+//
+// InteractionRequest Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+namespace ucbhelper
+{
+
+struct InteractionRequest_Impl
+{
+ rtl::Reference< InteractionContinuation > m_xSelection;
+ com::sun::star::uno::Any m_aRequest;
+ com::sun::star::uno::Sequence<
+ com::sun::star::uno::Reference<
+ com::sun::star::task::XInteractionContinuation > > m_aContinuations;
+
+ InteractionRequest_Impl() {}
+ InteractionRequest_Impl( const uno::Any & rRequest )
+ : m_aRequest( rRequest ) {}
+};
+
+}
+
+//=========================================================================
+InteractionRequest::InteractionRequest()
+: m_pImpl( new InteractionRequest_Impl )
+{
+}
+
+//=========================================================================
+InteractionRequest::InteractionRequest( const uno::Any & rRequest )
+: m_pImpl( new InteractionRequest_Impl( rRequest ) )
+{
+}
+
+//=========================================================================
+// virtual
+InteractionRequest::~InteractionRequest()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+void InteractionRequest::setRequest( const uno::Any & rRequest )
+{
+ m_pImpl->m_aRequest = rRequest;
+}
+
+//=========================================================================
+void InteractionRequest::setContinuations(
+ const uno::Sequence< uno::Reference<
+ task::XInteractionContinuation > > & rContinuations )
+{
+ m_pImpl->m_aContinuations = rContinuations;
+}
+
+//=========================================================================
+rtl::Reference< InteractionContinuation >
+InteractionRequest::getSelection() const
+{
+ return m_pImpl->m_xSelection;
+}
+
+//=========================================================================
+void InteractionRequest::setSelection(
+ const rtl::Reference< InteractionContinuation > & rxSelection )
+{
+ m_pImpl->m_xSelection = rxSelection;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionRequest::acquire()
+ throw()
+{
+ OWeakObject::acquire();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InteractionRequest::release()
+ throw()
+{
+ OWeakObject::release();
+}
+
+//=========================================================================
+// virtual
+uno::Any SAL_CALL
+InteractionRequest::queryInterface( const uno::Type & rType )
+ throw ( uno::RuntimeException )
+{
+ uno::Any aRet = cppu::queryInterface( rType,
+ static_cast< lang::XTypeProvider * >( this ),
+ static_cast< task::XInteractionRequest * >( this ) );
+
+ return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
+}
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+// virtual
+uno::Sequence< sal_Int8 > SAL_CALL InteractionRequest::getImplementationId()
+ throw( uno::RuntimeException )
+{
+ static cppu::OImplementationId* pId = NULL;
+ if ( !pId )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static cppu::OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< uno::Type > SAL_CALL InteractionRequest::getTypes()
+ throw( uno::RuntimeException )
+{
+ static cppu::OTypeCollection* pCollection = 0;
+ if ( !pCollection )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pCollection )
+ {
+ static cppu::OTypeCollection collection(
+ getCppuType( static_cast<
+ uno::Reference< lang::XTypeProvider > * >( 0 ) ),
+ getCppuType( static_cast<
+ uno::Reference< task::XInteractionRequest > * >( 0 ) ) );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+}
+
+//=========================================================================
+//
+// XInteractionRequest methods.
+//
+//=========================================================================
+
+// virtual
+uno::Any SAL_CALL InteractionRequest::getRequest()
+ throw( uno::RuntimeException )
+{
+ return m_pImpl->m_aRequest;
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< uno::Reference< task::XInteractionContinuation > > SAL_CALL
+InteractionRequest::getContinuations()
+ throw( uno::RuntimeException )
+{
+ return m_pImpl->m_aContinuations;
+}
+
+//=========================================================================
+//=========================================================================
+//
+// InteractionContinuation Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+namespace ucbhelper
+{
+
+struct InteractionContinuation_Impl
+{
+ InteractionRequest * m_pRequest;
+
+ InteractionContinuation_Impl( InteractionRequest * pRequest )
+ : m_pRequest( pRequest ) {}
+};
+
+}
+
+//=========================================================================
+InteractionContinuation::InteractionContinuation(
+ InteractionRequest * pRequest )
+: m_pImpl( new InteractionContinuation_Impl( pRequest ) )
+{
+}
+
+//=========================================================================
+// virtual
+InteractionContinuation::~InteractionContinuation()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+void InteractionContinuation::recordSelection()
+{
+ m_pImpl->m_pRequest->setSelection( this );
+}
+
+//=========================================================================
+//=========================================================================
+//
+// InteractionAbort Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionAbort::acquire()
+ throw()
+{
+ OWeakObject::acquire();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InteractionAbort::release()
+ throw()
+{
+ OWeakObject::release();
+}
+
+//=========================================================================
+// virtual
+uno::Any SAL_CALL
+InteractionAbort::queryInterface( const uno::Type & rType )
+ throw ( uno::RuntimeException )
+{
+ uno::Any aRet = cppu::queryInterface( rType,
+ static_cast< lang::XTypeProvider * >( this ),
+ static_cast< task::XInteractionContinuation * >( this ),
+ static_cast< task::XInteractionAbort * >( this ) );
+
+ return aRet.hasValue()
+ ? aRet : InteractionContinuation::queryInterface( rType );
+}
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+// virtual
+uno::Sequence< sal_Int8 > SAL_CALL InteractionAbort::getImplementationId()
+ throw( uno::RuntimeException )
+{
+ static cppu::OImplementationId* pId = NULL;
+ if ( !pId )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static cppu::OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< uno::Type > SAL_CALL InteractionAbort::getTypes()
+ throw( uno::RuntimeException )
+{
+ static cppu::OTypeCollection* pCollection = 0;
+ if ( !pCollection )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pCollection )
+ {
+ static cppu::OTypeCollection collection(
+ getCppuType( static_cast<
+ uno::Reference< lang::XTypeProvider > * >( 0 ) ),
+ getCppuType( static_cast<
+ uno::Reference< task::XInteractionAbort > * >( 0 ) ) );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+}
+
+//=========================================================================
+//
+// XInteractionContinuation methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionAbort::select()
+ throw( uno::RuntimeException )
+{
+ recordSelection();
+}
+
+//=========================================================================
+//=========================================================================
+//
+// InteractionRetry Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionRetry::acquire()
+ throw()
+{
+ OWeakObject::acquire();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InteractionRetry::release()
+ throw()
+{
+ OWeakObject::release();
+}
+
+//=========================================================================
+// virtual
+uno::Any SAL_CALL
+InteractionRetry::queryInterface( const uno::Type & rType )
+ throw ( uno::RuntimeException )
+{
+ uno::Any aRet = cppu::queryInterface( rType,
+ static_cast< lang::XTypeProvider * >( this ),
+ static_cast< task::XInteractionContinuation * >( this ),
+ static_cast< task::XInteractionRetry * >( this ) );
+
+ return aRet.hasValue()
+ ? aRet : InteractionContinuation::queryInterface( rType );
+}
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+// virtual
+uno::Sequence< sal_Int8 > SAL_CALL InteractionRetry::getImplementationId()
+ throw( uno::RuntimeException )
+{
+ static cppu::OImplementationId* pId = NULL;
+ if ( !pId )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static cppu::OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< uno::Type > SAL_CALL InteractionRetry::getTypes()
+ throw( uno::RuntimeException )
+{
+ static cppu::OTypeCollection* pCollection = 0;
+ if ( !pCollection )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pCollection )
+ {
+ static cppu::OTypeCollection collection(
+ getCppuType( static_cast<
+ uno::Reference< lang::XTypeProvider > * >( 0 ) ),
+ getCppuType( static_cast<
+ uno::Reference< task::XInteractionRetry > * >( 0 ) ) );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+}
+
+//=========================================================================
+//
+// XInteractionContinuation methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionRetry::select()
+ throw( uno::RuntimeException )
+{
+ recordSelection();
+}
+
+//=========================================================================
+//=========================================================================
+//
+// InteractionApprove Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionApprove::acquire()
+ throw()
+{
+ OWeakObject::acquire();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InteractionApprove::release()
+ throw()
+{
+ OWeakObject::release();
+}
+
+//=========================================================================
+// virtual
+uno::Any SAL_CALL
+InteractionApprove::queryInterface( const uno::Type & rType )
+ throw ( uno::RuntimeException )
+{
+ uno::Any aRet = cppu::queryInterface( rType,
+ static_cast< lang::XTypeProvider * >( this ),
+ static_cast< task::XInteractionContinuation * >( this ),
+ static_cast< task::XInteractionApprove * >( this ) );
+
+ return aRet.hasValue()
+ ? aRet : InteractionContinuation::queryInterface( rType );
+}
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+// virtual
+uno::Sequence< sal_Int8 > SAL_CALL InteractionApprove::getImplementationId()
+ throw( uno::RuntimeException )
+{
+ static cppu::OImplementationId* pId = NULL;
+ if ( !pId )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static cppu::OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< uno::Type > SAL_CALL InteractionApprove::getTypes()
+ throw( uno::RuntimeException )
+{
+ static cppu::OTypeCollection* pCollection = 0;
+ if ( !pCollection )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pCollection )
+ {
+ static cppu::OTypeCollection collection(
+ getCppuType( static_cast<
+ uno::Reference< lang::XTypeProvider > * >( 0 ) ),
+ getCppuType( static_cast<
+ uno::Reference< task::XInteractionApprove > * >( 0 ) ) );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+}
+
+//=========================================================================
+//
+// XInteractionContinuation methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionApprove::select()
+ throw( uno::RuntimeException )
+{
+ recordSelection();
+}
+
+//=========================================================================
+//=========================================================================
+//
+// InteractionDisapprove Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionDisapprove::acquire()
+ throw()
+{
+ OWeakObject::acquire();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InteractionDisapprove::release()
+ throw()
+{
+ OWeakObject::release();
+}
+
+//=========================================================================
+// virtual
+uno::Any SAL_CALL
+InteractionDisapprove::queryInterface( const uno::Type & rType )
+ throw ( uno::RuntimeException )
+{
+ uno::Any aRet = cppu::queryInterface( rType,
+ static_cast< lang::XTypeProvider * >( this ),
+ static_cast< task::XInteractionContinuation * >( this ),
+ static_cast< task::XInteractionDisapprove * >( this ) );
+
+ return aRet.hasValue()
+ ? aRet : InteractionContinuation::queryInterface( rType );
+}
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+// virtual
+uno::Sequence< sal_Int8 > SAL_CALL InteractionDisapprove::getImplementationId()
+ throw( uno::RuntimeException )
+{
+ static cppu::OImplementationId* pId = NULL;
+ if ( !pId )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static cppu::OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< uno::Type > SAL_CALL InteractionDisapprove::getTypes()
+ throw( uno::RuntimeException )
+{
+ static cppu::OTypeCollection* pCollection = 0;
+ if ( !pCollection )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pCollection )
+ {
+ static cppu::OTypeCollection collection(
+ getCppuType( static_cast<
+ uno::Reference< lang::XTypeProvider > * >( 0 ) ),
+ getCppuType( static_cast<
+ uno::Reference< task::XInteractionDisapprove > * >( 0 ) ) );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+}
+
+//=========================================================================
+//
+// XInteractionContinuation methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionDisapprove::select()
+ throw( uno::RuntimeException )
+{
+ recordSelection();
+}
+
+//=========================================================================
+//=========================================================================
+//
+// InteractionSupplyAuthentication Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionSupplyAuthentication::acquire()
+ throw()
+{
+ OWeakObject::acquire();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InteractionSupplyAuthentication::release()
+ throw()
+{
+ OWeakObject::release();
+}
+
+//=========================================================================
+// virtual
+uno::Any SAL_CALL
+InteractionSupplyAuthentication::queryInterface( const uno::Type & rType )
+ throw ( uno::RuntimeException )
+{
+ uno::Any aRet = cppu::queryInterface( rType,
+ static_cast< lang::XTypeProvider * >( this ),
+ static_cast< task::XInteractionContinuation * >( this ),
+ static_cast< ucb::XInteractionSupplyAuthentication * >( this ),
+ static_cast< ucb::XInteractionSupplyAuthentication2 * >( this ));
+
+ return aRet.hasValue()
+ ? aRet : InteractionContinuation::queryInterface( rType );
+}
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+// virtual
+uno::Sequence< sal_Int8 > SAL_CALL
+InteractionSupplyAuthentication::getImplementationId()
+ throw( uno::RuntimeException )
+{
+ static cppu::OImplementationId* pId = NULL;
+ if ( !pId )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static cppu::OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< uno::Type > SAL_CALL InteractionSupplyAuthentication::getTypes()
+ throw( uno::RuntimeException )
+{
+ static cppu::OTypeCollection* pCollection = 0;
+ if ( !pCollection )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pCollection )
+ {
+ static cppu::OTypeCollection collection(
+ getCppuType( static_cast<
+ uno::Reference< lang::XTypeProvider > * >( 0 ) ),
+ getCppuType( static_cast<
+ uno::Reference<
+ ucb::XInteractionSupplyAuthentication2 > * >( 0 ) ) );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+}
+
+//=========================================================================
+//
+// XInteractionContinuation methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionSupplyAuthentication::select()
+ throw( uno::RuntimeException )
+{
+ recordSelection();
+}
+
+//=========================================================================
+//
+// XInteractionSupplyAuthentication methods.
+//
+//=========================================================================
+
+// virtual
+sal_Bool SAL_CALL
+InteractionSupplyAuthentication::canSetRealm()
+ throw( uno::RuntimeException )
+{
+ return m_bCanSetRealm;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL
+InteractionSupplyAuthentication::setRealm( const rtl::OUString& Realm )
+ throw( uno::RuntimeException )
+{
+ OSL_ENSURE( m_bCanSetPassword,
+ "InteractionSupplyAuthentication::setRealm - Not supported!" );
+
+ if ( m_bCanSetRealm )
+ m_aRealm = Realm;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL
+InteractionSupplyAuthentication::canSetUserName()
+ throw( uno::RuntimeException )
+{
+ return m_bCanSetUserName;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL
+InteractionSupplyAuthentication::setUserName( const rtl::OUString& UserName )
+ throw( uno::RuntimeException )
+{
+ OSL_ENSURE( m_bCanSetUserName,
+ "InteractionSupplyAuthentication::setUserName - Not supported!" );
+
+ if ( m_bCanSetUserName )
+ m_aUserName = UserName;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL
+InteractionSupplyAuthentication::canSetPassword()
+ throw( uno::RuntimeException )
+{
+ return m_bCanSetPassword;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL
+InteractionSupplyAuthentication::setPassword( const rtl::OUString& Password )
+ throw( uno::RuntimeException )
+{
+ OSL_ENSURE( m_bCanSetPassword,
+ "InteractionSupplyAuthentication::setPassword - Not supported!" );
+
+ if ( m_bCanSetPassword )
+ m_aPassword = Password;
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< ucb::RememberAuthentication > SAL_CALL
+InteractionSupplyAuthentication::getRememberPasswordModes(
+ ucb::RememberAuthentication& Default )
+ throw( uno::RuntimeException )
+{
+ Default = m_eDefaultRememberPasswordMode;
+ return m_aRememberPasswordModes;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL
+InteractionSupplyAuthentication::setRememberPassword(
+ ucb::RememberAuthentication Remember )
+ throw( uno::RuntimeException )
+{
+ m_eRememberPasswordMode = Remember;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL
+InteractionSupplyAuthentication::canSetAccount()
+ throw( uno::RuntimeException )
+{
+ return m_bCanSetAccount;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL
+InteractionSupplyAuthentication::setAccount( const rtl::OUString& Account )
+ throw( uno::RuntimeException )
+{
+ OSL_ENSURE( m_bCanSetAccount,
+ "InteractionSupplyAuthentication::setAccount - Not supported!" );
+
+ if ( m_bCanSetAccount )
+ m_aAccount = Account;
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< ucb::RememberAuthentication > SAL_CALL
+InteractionSupplyAuthentication::getRememberAccountModes(
+ ucb::RememberAuthentication& Default )
+ throw( uno::RuntimeException )
+{
+ Default = m_eDefaultRememberAccountMode;
+ return m_aRememberAccountModes;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InteractionSupplyAuthentication::setRememberAccount(
+ ucb::RememberAuthentication Remember )
+ throw( uno::RuntimeException )
+{
+ m_eRememberAccountMode = Remember;
+}
+
+//=========================================================================
+//
+// XInteractionSupplyAuthentication2 methods.
+//
+//=========================================================================
+
+// virtual
+::sal_Bool SAL_CALL
+InteractionSupplyAuthentication::canUseSystemCredentials(
+ ::sal_Bool& Default )
+ throw ( uno::RuntimeException )
+{
+ Default = m_bDefaultUseSystemCredentials;
+ return m_bCanUseSystemCredentials;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InteractionSupplyAuthentication::setUseSystemCredentials(
+ ::sal_Bool UseSystemCredentials )
+ throw ( uno::RuntimeException )
+{
+ if ( m_bCanUseSystemCredentials )
+ m_bUseSystemCredentials = UseSystemCredentials;
+}
+
+
+//=========================================================================
+//=========================================================================
+//
+// InteractionSupplyName Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionSupplyName::acquire()
+ throw()
+{
+ OWeakObject::acquire();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InteractionSupplyName::release()
+ throw()
+{
+ OWeakObject::release();
+}
+
+//=========================================================================
+// virtual
+uno::Any SAL_CALL
+InteractionSupplyName::queryInterface( const uno::Type & rType )
+ throw ( uno::RuntimeException )
+{
+ uno::Any aRet = cppu::queryInterface( rType,
+ static_cast< lang::XTypeProvider * >( this ),
+ static_cast< task::XInteractionContinuation * >( this ),
+ static_cast< ucb::XInteractionSupplyName * >( this ) );
+
+ return aRet.hasValue()
+ ? aRet : InteractionContinuation::queryInterface( rType );
+}
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+// virtual
+uno::Sequence< sal_Int8 > SAL_CALL InteractionSupplyName::getImplementationId()
+ throw( uno::RuntimeException )
+{
+ static cppu::OImplementationId* pId = NULL;
+ if ( !pId )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static cppu::OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< uno::Type > SAL_CALL InteractionSupplyName::getTypes()
+ throw( uno::RuntimeException )
+{
+ static cppu::OTypeCollection* pCollection = 0;
+ if ( !pCollection )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pCollection )
+ {
+ static cppu::OTypeCollection collection(
+ getCppuType( static_cast<
+ uno::Reference< lang::XTypeProvider > * >( 0 ) ),
+ getCppuType( static_cast<
+ uno::Reference< ucb::XInteractionSupplyName > * >( 0 ) ) );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+}
+
+//=========================================================================
+//
+// XInteractionContinuation methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionSupplyName::select()
+ throw( uno::RuntimeException )
+{
+ recordSelection();
+}
+
+//=========================================================================
+//
+// XInteractionSupplyName methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL
+InteractionSupplyName::setName( const rtl::OUString& Name )
+ throw( uno::RuntimeException )
+{
+ m_aName = Name;
+}
+
+//=========================================================================
+//=========================================================================
+//
+// InteractionReplaceExistingData Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionReplaceExistingData::acquire()
+ throw()
+{
+ OWeakObject::acquire();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InteractionReplaceExistingData::release()
+ throw()
+{
+ OWeakObject::release();
+}
+
+//=========================================================================
+// virtual
+uno::Any SAL_CALL
+InteractionReplaceExistingData::queryInterface( const uno::Type & rType )
+ throw ( uno::RuntimeException )
+{
+ uno::Any aRet = cppu::queryInterface( rType,
+ static_cast< lang::XTypeProvider * >( this ),
+ static_cast< task::XInteractionContinuation * >( this ),
+ static_cast< ucb::XInteractionReplaceExistingData * >( this ) );
+
+ return aRet.hasValue()
+ ? aRet : InteractionContinuation::queryInterface( rType );
+}
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+// virtual
+uno::Sequence< sal_Int8 > SAL_CALL
+InteractionReplaceExistingData::getImplementationId()
+ throw( uno::RuntimeException )
+{
+ static cppu::OImplementationId* pId = NULL;
+ if ( !pId )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static cppu::OImplementationId id( sal_False );
+ pId = &id;
+ }
+ }
+ return (*pId).getImplementationId();
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< uno::Type > SAL_CALL InteractionReplaceExistingData::getTypes()
+ throw( uno::RuntimeException )
+{
+ static cppu::OTypeCollection* pCollection = 0;
+ if ( !pCollection )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pCollection )
+ {
+ static cppu::OTypeCollection collection(
+ getCppuType( static_cast<
+ uno::Reference< lang::XTypeProvider > * >( 0 ) ),
+ getCppuType( static_cast<
+ uno::Reference<
+ ucb::XInteractionReplaceExistingData > * >( 0 ) ) );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+}
+
+//=========================================================================
+//
+// XInteractionContinuation methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL InteractionReplaceExistingData::select()
+ throw( uno::RuntimeException )
+{
+ recordSelection();
+}
+
diff --git a/ucbhelper/source/provider/makefile.mk b/ucbhelper/source/provider/makefile.mk
new file mode 100644
index 000000000000..5999192f7bdb
--- /dev/null
+++ b/ucbhelper/source/provider/makefile.mk
@@ -0,0 +1,70 @@
+#*************************************************************************
+#
+# 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=..$/..
+
+PRJNAME= ucbhelper
+TARGET= provider
+AUTOSEG= TRUE
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(header)" == ""
+
+SLOFILES=\
+ $(SLO)$/contentidentifier.obj \
+ $(SLO)$/providerhelper.obj \
+ $(SLO)$/contenthelper.obj \
+ $(SLO)$/contentinfo.obj \
+ $(SLO)$/propertyvalueset.obj \
+ $(SLO)$/registerucb.obj \
+ $(SLO)$/resultsetmetadata.obj \
+ $(SLO)$/resultset.obj \
+ $(SLO)$/resultsethelper.obj \
+ $(SLO)$/commandenvironmentproxy.obj \
+ $(SLO)$/interactionrequest.obj \
+ $(SLO)$/simpleinteractionrequest.obj \
+ $(SLO)$/simpleauthenticationrequest.obj \
+ $(SLO)$/simplenameclashresolverequest.obj \
+ $(SLO)$/simpleioerrorrequest.obj \
+ $(SLO)$/cancelcommandexecution.obj \
+ $(SLO)$/handleinteractionrequest.obj \
+ $(SLO)$/simplecertificatevalidationrequest.obj
+
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/ucbhelper/source/provider/propertyvalueset.cxx b/ucbhelper/source/provider/propertyvalueset.cxx
new file mode 100644
index 000000000000..1c857ca467f0
--- /dev/null
+++ b/ucbhelper/source/provider/propertyvalueset.cxx
@@ -0,0 +1,924 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+
+#ifndef __VECTOR__
+#include <vector>
+#endif
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+
+#include "osl/diagnose.h"
+#include "osl/mutex.hxx"
+#include <ucbhelper/propertyvalueset.hxx>
+
+using namespace com::sun::star::beans;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::script;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::util;
+using namespace rtl;
+
+namespace ucbhelper_impl
+{
+
+//=========================================================================
+//
+// PropertyValue.
+//
+//=========================================================================
+
+const sal_uInt32 NO_VALUE_SET = 0x00000000;
+const sal_uInt32 STRING_VALUE_SET = 0x00000001;
+const sal_uInt32 BOOLEAN_VALUE_SET = 0x00000002;
+const sal_uInt32 BYTE_VALUE_SET = 0x00000004;
+const sal_uInt32 SHORT_VALUE_SET = 0x00000008;
+const sal_uInt32 INT_VALUE_SET = 0x00000010;
+const sal_uInt32 LONG_VALUE_SET = 0x00000020;
+const sal_uInt32 FLOAT_VALUE_SET = 0x00000040;
+const sal_uInt32 DOUBLE_VALUE_SET = 0x00000080;
+const sal_uInt32 BYTES_VALUE_SET = 0x00000100;
+const sal_uInt32 DATE_VALUE_SET = 0x00000200;
+const sal_uInt32 TIME_VALUE_SET = 0x00000400;
+const sal_uInt32 TIMESTAMP_VALUE_SET = 0x00000800;
+const sal_uInt32 BINARYSTREAM_VALUE_SET = 0x00001000;
+const sal_uInt32 CHARACTERSTREAM_VALUE_SET = 0x00002000;
+const sal_uInt32 REF_VALUE_SET = 0x00004000;
+const sal_uInt32 BLOB_VALUE_SET = 0x00008000;
+const sal_uInt32 CLOB_VALUE_SET = 0x00010000;
+const sal_uInt32 ARRAY_VALUE_SET = 0x00020000;
+const sal_uInt32 OBJECT_VALUE_SET = 0x00040000;
+
+struct PropertyValue
+{
+ ::rtl::OUString
+ sPropertyName;
+
+ sal_uInt32 nPropsSet;
+ sal_uInt32 nOrigValue;
+
+ OUString aString; // getString
+ sal_Bool bBoolean; // getBoolean
+ sal_Int8 nByte; // getByte
+ sal_Int16 nShort; // getShort
+ sal_Int32 nInt; // getInt
+ sal_Int64 nLong; // getLong
+ float nFloat; // getFloat
+ double nDouble; // getDouble
+
+ Sequence< sal_Int8 > aBytes; // getBytes
+ Date aDate; // getDate
+ Time aTime; // getTime
+ DateTime aTimestamp; // getTimestamp
+ Reference< XInputStream > xBinaryStream; // getBinaryStream
+ Reference< XInputStream > xCharacterStream; // getCharacterStream
+ Reference< XRef > xRef; // getRef
+ Reference< XBlob > xBlob; // getBlob
+ Reference< XClob > xClob; // getClob
+ Reference< XArray > xArray; // getArray
+ Any aObject; // getObject
+
+ inline PropertyValue()
+ : nPropsSet( NO_VALUE_SET ), nOrigValue( NO_VALUE_SET ),
+ bBoolean(false),
+ nByte(0),
+ nShort(0),
+ nInt(0),
+ nLong(0),
+ nFloat(0.0),
+ nDouble(0.0)
+ {}
+};
+} // namespace ucbhelper_impl
+
+using namespace ucbhelper_impl;
+
+namespace ucbhelper
+{
+
+//=========================================================================
+//
+// class PropertyValues.
+//
+//=========================================================================
+
+typedef std::vector< ucbhelper_impl::PropertyValue > PropertyValuesVector;
+
+class PropertyValues : public PropertyValuesVector {};
+
+} // namespace ucbhelper
+
+//=========================================================================
+//
+// Welcome to the macro hell...
+//
+//=========================================================================
+
+#define GETVALUE_IMPL_TYPE( _type_, _type_name_, _member_name_, _cppu_type_ ) \
+ \
+ osl::MutexGuard aGuard( m_aMutex ); \
+ \
+ _type_ aValue = _type_(); /* default ctor */ \
+ \
+ m_bWasNull = sal_True; \
+ \
+ if ( ( columnIndex < 1 ) \
+ || ( columnIndex > sal_Int32( m_pValues->size() ) ) ) \
+ { \
+ OSL_ENSURE( sal_False, "PropertyValueSet - index out of range!" ); \
+ } \
+ else \
+ { \
+ ucbhelper_impl::PropertyValue& rValue \
+ = (*m_pValues)[ columnIndex - 1 ]; \
+ \
+ if ( rValue.nOrigValue != NO_VALUE_SET ) \
+ { \
+ if ( rValue.nPropsSet & _type_name_ ) \
+ { \
+ /* Values is present natively... */ \
+ aValue = rValue._member_name_; \
+ m_bWasNull = sal_False; \
+ } \
+ else \
+ { \
+ if ( !(rValue.nPropsSet & OBJECT_VALUE_SET) ) \
+ { \
+ /* Value is not (yet) available as Any. Create it. */ \
+ getObject( columnIndex, Reference< XNameAccess >() ); \
+ } \
+ \
+ if ( rValue.nPropsSet & OBJECT_VALUE_SET ) \
+ { \
+ /* Value is available as Any. */ \
+ \
+ if ( rValue.aObject.hasValue() ) \
+ { \
+ /* Try to convert into native value. */ \
+ if ( rValue.aObject >>= aValue ) \
+ { \
+ rValue._member_name_ = aValue; \
+ rValue.nPropsSet |= _type_name_; \
+ m_bWasNull = sal_False; \
+ } \
+ else \
+ { \
+ /* Last chance. Try type converter service... */ \
+ \
+ Reference< XTypeConverter > xConverter \
+ = getTypeConverter(); \
+ if ( xConverter.is() ) \
+ { \
+ try \
+ { \
+ Any aConvAny = xConverter->convertTo( \
+ rValue.aObject, \
+ _cppu_type_ ); \
+ \
+ if ( aConvAny >>= aValue ) \
+ { \
+ rValue._member_name_ = aValue; \
+ rValue.nPropsSet |= _type_name_; \
+ m_bWasNull = sal_False; \
+ } \
+ } \
+ catch ( IllegalArgumentException ) \
+ { \
+ } \
+ catch ( CannotConvertException ) \
+ { \
+ } \
+ } \
+ } \
+ } \
+ } \
+ } \
+ } \
+ } \
+ return aValue;
+
+#define GETVALUE_IMPL( _type_, _type_name_, _member_name_ ) \
+ GETVALUE_IMPL_TYPE( _type_, \
+ _type_name_, \
+ _member_name_, \
+ getCppuType( static_cast< const _type_ * >( 0 ) ) )
+
+#define SETVALUE_IMPL( _prop_name_, _type_name_, _member_name_, _value_ ) \
+ \
+ osl::MutexGuard aGuard( m_aMutex ); \
+ \
+ ucbhelper_impl::PropertyValue aNewValue; \
+ aNewValue.sPropertyName = _prop_name_; \
+ aNewValue.nPropsSet = _type_name_; \
+ aNewValue.nOrigValue = _type_name_; \
+ aNewValue._member_name_ = _value_; \
+ \
+ m_pValues->push_back( aNewValue );
+
+namespace ucbhelper {
+
+//=========================================================================
+//=========================================================================
+//
+// PropertyValueSet Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+#define PROPERTYVALUESET_INIT() \
+ m_xSMgr( rxSMgr ), \
+ m_pValues( new PropertyValues ), \
+ m_bWasNull( sal_False ), \
+ m_bTriedToGetTypeConverter( sal_False )
+
+//=========================================================================
+PropertyValueSet::PropertyValueSet(
+ const Reference< XMultiServiceFactory >& rxSMgr )
+: PROPERTYVALUESET_INIT()
+{
+}
+
+//=========================================================================
+PropertyValueSet::PropertyValueSet(
+ const Reference< XMultiServiceFactory >& rxSMgr,
+ const Sequence< com::sun::star::beans::PropertyValue >& rValues )
+: PROPERTYVALUESET_INIT()
+{
+ sal_Int32 nCount = rValues.getLength();
+ if ( nCount )
+ {
+ const com::sun::star::beans::PropertyValue* pValues
+ = rValues.getConstArray();
+
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const com::sun::star::beans::PropertyValue& rValue = pValues[ n ];
+ appendObject( Property( rValue.Name,
+ rValue.Handle,
+ rValue.Value.getValueType(),
+ 0 ),
+ rValue.Value );
+ }
+ }
+}
+
+//=========================================================================
+// virtual
+PropertyValueSet::~PropertyValueSet()
+{
+ delete m_pValues;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_3( PropertyValueSet,
+ XTypeProvider,
+ XRow,
+ XColumnLocate );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_3( PropertyValueSet,
+ XTypeProvider,
+ XRow,
+ XColumnLocate );
+
+//=========================================================================
+//
+// XRow methods.
+//
+//=========================================================================
+
+// virtual
+sal_Bool SAL_CALL PropertyValueSet::wasNull()
+ throw( SQLException, RuntimeException )
+{
+ // This method can not be implemented correctly!!! Imagine different
+ // threads doing a getXYZ - wasNull calling sequence on the same
+ // implementation object...
+ return m_bWasNull;
+}
+
+//=========================================================================
+// virtual
+OUString SAL_CALL PropertyValueSet::getString( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( OUString, STRING_VALUE_SET, aString );
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL PropertyValueSet::getBoolean( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL_TYPE(
+ sal_Bool, BOOLEAN_VALUE_SET, bBoolean, getCppuBooleanType() );
+}
+
+//=========================================================================
+// virtual
+sal_Int8 SAL_CALL PropertyValueSet::getByte( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( sal_Int8, BYTE_VALUE_SET, nByte );
+}
+
+//=========================================================================
+// virtual
+sal_Int16 SAL_CALL PropertyValueSet::getShort( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( sal_Int16, SHORT_VALUE_SET, nShort );
+}
+
+//=========================================================================
+// virtual
+sal_Int32 SAL_CALL PropertyValueSet::getInt( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( sal_Int32, INT_VALUE_SET, nInt );
+}
+
+//=========================================================================
+// virtual
+sal_Int64 SAL_CALL PropertyValueSet::getLong( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( sal_Int64, LONG_VALUE_SET, nLong );
+}
+
+//=========================================================================
+// virtual
+float SAL_CALL PropertyValueSet::getFloat( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( float, FLOAT_VALUE_SET, nFloat );
+}
+
+//=========================================================================
+// virtual
+double SAL_CALL PropertyValueSet::getDouble( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( double, DOUBLE_VALUE_SET, nDouble );
+}
+
+//=========================================================================
+// virtual
+Sequence< sal_Int8 > SAL_CALL
+PropertyValueSet::getBytes( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( Sequence< sal_Int8 >, BYTES_VALUE_SET, aBytes );
+}
+
+//=========================================================================
+// virtual
+Date SAL_CALL PropertyValueSet::getDate( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( Date, DATE_VALUE_SET, aDate );
+}
+
+//=========================================================================
+// virtual
+Time SAL_CALL PropertyValueSet::getTime( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( Time, TIME_VALUE_SET, aTime );
+}
+
+//=========================================================================
+// virtual
+DateTime SAL_CALL PropertyValueSet::getTimestamp( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( DateTime, TIMESTAMP_VALUE_SET, aTimestamp );
+}
+
+//=========================================================================
+// virtual
+Reference< XInputStream > SAL_CALL
+PropertyValueSet::getBinaryStream( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL(
+ Reference< XInputStream >, BINARYSTREAM_VALUE_SET, xBinaryStream );
+}
+
+//=========================================================================
+// virtual
+Reference< XInputStream > SAL_CALL
+PropertyValueSet::getCharacterStream( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL(
+ Reference< XInputStream >, CHARACTERSTREAM_VALUE_SET, xCharacterStream );
+}
+
+//=========================================================================
+// virtual
+Any SAL_CALL PropertyValueSet::getObject(
+ sal_Int32 columnIndex,
+ const Reference< XNameAccess >& )
+ throw( SQLException, RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ Any aValue;
+
+ m_bWasNull = sal_True;
+
+ if ( ( columnIndex < 1 )
+ || ( columnIndex > sal_Int32( m_pValues->size() ) ) )
+ {
+ OSL_ENSURE( sal_False, "PropertyValueSet - index out of range!" );
+ }
+ else
+ {
+ ucbhelper_impl::PropertyValue& rValue
+ = (*m_pValues)[ columnIndex - 1 ];
+
+ if ( rValue.nPropsSet & OBJECT_VALUE_SET )
+ {
+ // Values is present natively...
+ aValue = rValue.aObject;
+ m_bWasNull = sal_False;
+ }
+ else
+ {
+ // Make Any from original value.
+
+ switch ( rValue.nOrigValue )
+ {
+ case NO_VALUE_SET:
+ break;
+
+ case STRING_VALUE_SET:
+ aValue <<= rValue.aString;
+ break;
+
+ case BOOLEAN_VALUE_SET:
+ aValue <<= rValue.bBoolean;
+ break;
+
+ case BYTE_VALUE_SET:
+ aValue <<= rValue.nByte;
+ break;
+
+ case SHORT_VALUE_SET:
+ aValue <<= rValue.nShort;
+ break;
+
+ case INT_VALUE_SET:
+ aValue <<= rValue.nInt;
+ break;
+
+ case LONG_VALUE_SET:
+ aValue <<= rValue.nLong;
+ break;
+
+ case FLOAT_VALUE_SET:
+ aValue <<= rValue.nFloat;
+ break;
+
+ case DOUBLE_VALUE_SET:
+ aValue <<= rValue.nDouble;
+ break;
+
+ case BYTES_VALUE_SET:
+ aValue <<= rValue.aBytes;
+ break;
+
+ case DATE_VALUE_SET:
+ aValue <<= rValue.aDate;
+ break;
+
+ case TIME_VALUE_SET:
+ aValue <<= rValue.aTime;
+ break;
+
+ case TIMESTAMP_VALUE_SET:
+ aValue <<= rValue.aTimestamp;
+ break;
+
+ case BINARYSTREAM_VALUE_SET:
+ aValue <<= rValue.xBinaryStream;
+ break;
+
+ case CHARACTERSTREAM_VALUE_SET:
+ aValue <<= rValue.xCharacterStream;
+ break;
+
+ case REF_VALUE_SET:
+ aValue <<= rValue.xRef;
+ break;
+
+ case BLOB_VALUE_SET:
+ aValue <<= rValue.xBlob;
+ break;
+
+ case CLOB_VALUE_SET:
+ aValue <<= rValue.xClob;
+ break;
+
+ case ARRAY_VALUE_SET:
+ aValue <<= rValue.xArray;
+ break;
+
+ case OBJECT_VALUE_SET:
+ // Fall-through is intended!
+ default:
+ OSL_ENSURE( sal_False,
+ "PropertyValueSet::getObject - "
+ "Wrong original type" );
+ break;
+ }
+
+ if ( aValue.hasValue() )
+ {
+ rValue.aObject = aValue;
+ rValue.nPropsSet |= OBJECT_VALUE_SET;
+ m_bWasNull = sal_False;
+ }
+ }
+ }
+
+ return aValue;
+}
+
+//=========================================================================
+// virtual
+Reference< XRef > SAL_CALL PropertyValueSet::getRef( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( Reference< XRef >, REF_VALUE_SET, xRef );
+}
+
+//=========================================================================
+// virtual
+Reference< XBlob > SAL_CALL PropertyValueSet::getBlob( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( Reference< XBlob >, BLOB_VALUE_SET, xBlob );
+}
+
+//=========================================================================
+// virtual
+Reference< XClob > SAL_CALL PropertyValueSet::getClob( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( Reference< XClob >, CLOB_VALUE_SET, xClob );
+}
+
+//=========================================================================
+// virtual
+Reference< XArray > SAL_CALL PropertyValueSet::getArray( sal_Int32 columnIndex )
+ throw( SQLException, RuntimeException )
+{
+ GETVALUE_IMPL( Reference< XArray >, ARRAY_VALUE_SET, xArray );
+}
+
+//=========================================================================
+//
+// XColumnLocate methods.
+//
+//=========================================================================
+
+// virtual
+sal_Int32 SAL_CALL PropertyValueSet::findColumn( const OUString& columnName )
+ throw( SQLException, RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( columnName.getLength() )
+ {
+ sal_Int32 nCount = m_pValues->size();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ if ( (*m_pValues)[ n ].sPropertyName.equals( columnName ) )
+ return sal_Int32( n + 1 ); // Index is 1-based.
+ }
+ }
+ return 0;
+}
+
+//=========================================================================
+//
+// Non-interface methods.
+//
+//=========================================================================
+
+const Reference< XTypeConverter >& PropertyValueSet::getTypeConverter()
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_bTriedToGetTypeConverter && !m_xTypeConverter.is() )
+ {
+ m_bTriedToGetTypeConverter = sal_True;
+ m_xTypeConverter = Reference< XTypeConverter >(
+ m_xSMgr->createInstance(
+ OUString::createFromAscii(
+ "com.sun.star.script.Converter" ) ),
+ UNO_QUERY );
+
+ OSL_ENSURE( m_xTypeConverter.is(),
+ "PropertyValueSet::getTypeConverter() - "
+ "Service 'com.sun.star.script.Converter' n/a!" );
+ }
+ return m_xTypeConverter;
+}
+
+//=========================================================================
+sal_Int32 PropertyValueSet::getLength() const
+{
+ return m_pValues->size();
+}
+
+//=========================================================================
+void PropertyValueSet::appendString( const ::rtl::OUString& rPropName,
+ const OUString& rValue )
+{
+ SETVALUE_IMPL( rPropName, STRING_VALUE_SET, aString, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendBoolean( const ::rtl::OUString& rPropName,
+ sal_Bool bValue )
+{
+ SETVALUE_IMPL( rPropName, BOOLEAN_VALUE_SET, bBoolean, bValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendByte( const ::rtl::OUString& rPropName,
+ sal_Int8 nValue )
+{
+ SETVALUE_IMPL( rPropName, BYTE_VALUE_SET, nByte, nValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendShort( const ::rtl::OUString& rPropName,
+ sal_Int16 nValue )
+{
+ SETVALUE_IMPL( rPropName, SHORT_VALUE_SET, nShort, nValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendInt( const ::rtl::OUString& rPropName,
+ sal_Int32 nValue )
+{
+ SETVALUE_IMPL( rPropName, INT_VALUE_SET, nInt, nValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendLong( const ::rtl::OUString& rPropName,
+ sal_Int64 nValue )
+{
+ SETVALUE_IMPL( rPropName, LONG_VALUE_SET, nLong, nValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendFloat( const ::rtl::OUString& rPropName,
+ float nValue )
+{
+ SETVALUE_IMPL( rPropName, FLOAT_VALUE_SET, nFloat, nValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendDouble( const ::rtl::OUString& rPropName,
+ double nValue )
+{
+ SETVALUE_IMPL( rPropName, DOUBLE_VALUE_SET, nDouble, nValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendBytes( const ::rtl::OUString& rPropName,
+ const Sequence< sal_Int8 >& rValue )
+{
+ SETVALUE_IMPL( rPropName, BYTES_VALUE_SET, aBytes, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendDate( const ::rtl::OUString& rPropName,
+ const Date& rValue )
+{
+ SETVALUE_IMPL( rPropName, DATE_VALUE_SET, aDate, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendTime( const ::rtl::OUString& rPropName,
+ const Time& rValue )
+{
+ SETVALUE_IMPL( rPropName, TIME_VALUE_SET, aTime, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendTimestamp( const ::rtl::OUString& rPropName,
+ const DateTime& rValue )
+{
+ SETVALUE_IMPL( rPropName, TIMESTAMP_VALUE_SET, aTimestamp, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendBinaryStream(
+ const ::rtl::OUString& rPropName,
+ const Reference< XInputStream >& rValue )
+{
+ SETVALUE_IMPL( rPropName, BINARYSTREAM_VALUE_SET, xBinaryStream, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendCharacterStream(
+ const ::rtl::OUString& rPropName,
+ const Reference< XInputStream >& rValue )
+{
+ SETVALUE_IMPL( rPropName, CHARACTERSTREAM_VALUE_SET, xCharacterStream, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendObject( const ::rtl::OUString& rPropName,
+ const Any& rValue )
+{
+ SETVALUE_IMPL( rPropName, OBJECT_VALUE_SET, aObject, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendRef( const ::rtl::OUString& rPropName,
+ const Reference< XRef >& rValue )
+{
+ SETVALUE_IMPL( rPropName, REF_VALUE_SET, xRef, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendBlob( const ::rtl::OUString& rPropName,
+ const Reference< XBlob >& rValue )
+{
+ SETVALUE_IMPL( rPropName, BLOB_VALUE_SET, xBlob, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendClob( const ::rtl::OUString& rPropName,
+ const Reference< XClob >& rValue )
+{
+ SETVALUE_IMPL( rPropName, CLOB_VALUE_SET, xClob, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendArray( const ::rtl::OUString& rPropName,
+ const Reference< XArray >& rValue )
+{
+ SETVALUE_IMPL( rPropName, ARRAY_VALUE_SET, xArray, rValue );
+}
+
+//=========================================================================
+void PropertyValueSet::appendVoid( const ::rtl::OUString& rPropName )
+{
+ SETVALUE_IMPL( rPropName, NO_VALUE_SET, aObject, Any() );
+}
+
+//=========================================================================
+void PropertyValueSet::appendPropertySet(
+ const Reference< XPropertySet >& rxSet )
+{
+ if ( rxSet.is() )
+ {
+ Reference< XPropertySetInfo > xInfo = rxSet->getPropertySetInfo();
+ if ( xInfo.is() )
+ {
+ Sequence< Property > aProps = xInfo->getProperties();
+ const Property* pProps = aProps.getConstArray();
+ sal_Int32 nPropsCount = aProps.getLength();
+
+ Reference< XPropertyAccess > xPropertyAccess( rxSet, UNO_QUERY );
+ if ( xPropertyAccess.is() )
+ {
+ // Efficient: Get all prop values with one ( remote) call.
+
+ Sequence< ::com::sun::star::beans::PropertyValue > aPropValues
+ = xPropertyAccess->getPropertyValues();
+
+ const ::com::sun::star::beans::PropertyValue* pPropValues
+ = aPropValues.getConstArray();
+
+ sal_Int32 nValuesCount = aPropValues.getLength();
+ for ( sal_Int32 n = 0; n < nValuesCount; ++n )
+ {
+ const ::com::sun::star::beans::PropertyValue& rPropValue
+ = pPropValues[ n ];
+
+ // Find info for current property value.
+ for ( sal_Int32 m = 0; m < nPropsCount; ++m )
+ {
+ const Property& rProp = pProps[ m ];
+ if ( rProp.Name == rPropValue.Name )
+ {
+ // Found!
+ appendObject( rProp, rPropValue.Value );
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ // Get every single prop value with one ( remote) call.
+
+ for ( sal_Int32 n = 0; n < nPropsCount; ++n )
+ {
+ const Property& rProp = pProps[ n ];
+
+ try
+ {
+ Any aValue = rxSet->getPropertyValue( rProp.Name );
+
+ if ( aValue.hasValue() )
+ appendObject( rProp, aValue );
+ }
+ catch ( UnknownPropertyException )
+ {
+ }
+ catch ( WrappedTargetException )
+ {
+ }
+ }
+ }
+ }
+ }
+}
+
+//=========================================================================
+sal_Bool PropertyValueSet::appendPropertySetValue(
+ const Reference< XPropertySet >& rxSet,
+ const Property& rProperty )
+{
+ if ( rxSet.is() )
+ {
+ try
+ {
+ Any aValue = rxSet->getPropertyValue( rProperty.Name );
+ if ( aValue.hasValue() )
+ {
+ appendObject( rProperty, aValue );
+ return sal_True;
+ }
+ }
+ catch ( UnknownPropertyException )
+ {
+ }
+ catch ( WrappedTargetException )
+ {
+ }
+ }
+
+ // Error.
+ return sal_False;
+}
+
+} // namespace ucbhelper
diff --git a/ucbhelper/source/provider/provconf.cxx b/ucbhelper/source/provider/provconf.cxx
new file mode 100644
index 000000000000..df1917b45413
--- /dev/null
+++ b/ucbhelper/source/provider/provconf.cxx
@@ -0,0 +1,266 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+
+#ifndef _UCBHELPER_PROVCONF_HXX_
+#include <provconf.hxx>
+#endif
+#include <osl/diagnose.h>
+#include <rtl/ustrbuf.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+using namespace com::sun::star;
+
+//=========================================================================
+
+#define CONFIG_CONTENTPROVIDERS_KEY \
+ "/org.openoffice.ucb.Configuration/ContentProviders"
+
+//=========================================================================
+
+namespace ucbhelper {
+
+void makeAndAppendXMLName(
+ rtl::OUStringBuffer & rBuffer, const rtl::OUString & rIn )
+{
+ sal_Int32 nCount = rIn.getLength();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const sal_Unicode c = rIn.getStr()[ n ];
+ switch ( c )
+ {
+ case '&':
+ rBuffer.appendAscii( "&amp;" );
+ break;
+
+ case '"':
+ rBuffer.appendAscii( "&quot;" );
+ break;
+
+ case '\'':
+ rBuffer.appendAscii( "&apos;" );
+ break;
+
+ case '<':
+ rBuffer.appendAscii( "&lt;" );
+ break;
+
+ case '>':
+ rBuffer.appendAscii( "&gt;" );
+ break;
+
+ default:
+ rBuffer.append( c );
+ break;
+ }
+ }
+}
+
+//=========================================================================
+bool getContentProviderData(
+ const uno::Reference< lang::XMultiServiceFactory > & rServiceMgr,
+ const rtl::OUString & rKey1,
+ const rtl::OUString & rKey2,
+ ContentProviderDataList & rListToFill )
+{
+ if ( !rServiceMgr.is() || !rKey1.getLength() || !rKey2.getLength() )
+ {
+ OSL_ENSURE( false,
+ "getContentProviderData - Invalid argument!" );
+ return false;
+ }
+
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xConfigProv(
+ rServiceMgr->createInstance(
+ rtl::OUString::createFromAscii(
+ "com.sun.star.configuration.ConfigurationProvider" ) ),
+ uno::UNO_QUERY );
+
+ if ( !xConfigProv.is() )
+ {
+ OSL_ENSURE( false,
+ "getContentProviderData - No config provider!" );
+ return false;
+ }
+
+ rtl::OUStringBuffer aFullPath;
+ aFullPath.appendAscii( CONFIG_CONTENTPROVIDERS_KEY "/['" );
+ makeAndAppendXMLName( aFullPath, rKey1 );
+ aFullPath.appendAscii( "']/SecondaryKeys/['" );
+ makeAndAppendXMLName( aFullPath, rKey2 );
+ aFullPath.appendAscii( "']/ProviderData" );
+
+ uno::Sequence< uno::Any > aArguments( 1 );
+ beans::PropertyValue aProperty;
+ aProperty.Name
+ = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
+ aProperty.Value <<= aFullPath.makeStringAndClear();
+ aArguments[ 0 ] <<= aProperty;
+
+ uno::Reference< uno::XInterface > xInterface(
+ xConfigProv->createInstanceWithArguments(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationAccess" ) ),
+ aArguments ) );
+
+ if ( !xInterface.is() )
+ {
+ OSL_ENSURE( false,
+ "getContentProviderData - No config access!" );
+ return false;
+ }
+
+ uno::Reference< container::XNameAccess > xNameAccess(
+ xInterface, uno::UNO_QUERY );
+
+ if ( !xNameAccess.is() )
+ {
+ OSL_ENSURE( false,
+ "getContentProviderData - No XNameAccess!" );
+ return false;
+ }
+
+ uno::Sequence< rtl::OUString > aElems = xNameAccess->getElementNames();
+ const rtl::OUString* pElems = aElems.getConstArray();
+ sal_Int32 nCount = aElems.getLength();
+
+ if ( nCount > 0 )
+ {
+ uno::Reference< container::XHierarchicalNameAccess >
+ xHierNameAccess( xInterface, uno::UNO_QUERY );
+
+ if ( !xHierNameAccess.is() )
+ {
+ OSL_ENSURE( false,
+ "getContentProviderData - "
+ "No XHierarchicalNameAccess!" );
+ return false;
+ }
+
+ // Iterate over children.
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ rtl::OUStringBuffer aElemBuffer;
+ aElemBuffer.appendAscii( "['" );
+ makeAndAppendXMLName( aElemBuffer, pElems[ n ] );
+
+ try
+ {
+ ContentProviderData aInfo;
+
+ // Obtain service name.
+ rtl::OUStringBuffer aKeyBuffer = aElemBuffer;
+ aKeyBuffer.appendAscii( "']/ServiceName" );
+
+ rtl::OUString aValue;
+ if ( !( xHierNameAccess->getByHierarchicalName(
+ aKeyBuffer.makeStringAndClear() ) >>= aValue ) )
+ {
+ OSL_ENSURE( false,
+ "getContentProviderData - "
+ "Error getting item value!" );
+ continue;
+ }
+
+ aInfo.ServiceName = aValue;
+
+ // Obtain URL Template.
+ aKeyBuffer = aElemBuffer;
+ aKeyBuffer.appendAscii( "']/URLTemplate" );
+
+ if ( !( xHierNameAccess->getByHierarchicalName(
+ aKeyBuffer.makeStringAndClear() ) >>= aValue ) )
+ {
+ OSL_ENSURE( false,
+ "getContentProviderData - "
+ "Error getting item value!" );
+ continue;
+ }
+
+ aInfo.URLTemplate = aValue;
+
+ // Obtain Arguments.
+ aKeyBuffer = aElemBuffer;
+ aKeyBuffer.appendAscii( "']/Arguments" );
+
+ if ( !( xHierNameAccess->getByHierarchicalName(
+ aKeyBuffer.makeStringAndClear() ) >>= aValue ) )
+ {
+ OSL_ENSURE( false,
+ "getContentProviderData - "
+ "Error getting item value!" );
+ continue;
+ }
+
+ aInfo.Arguments = aValue;
+
+ // Append info to list.
+ rListToFill.push_back( aInfo );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ // getByHierarchicalName
+
+ OSL_ENSURE( false,
+ "getContentProviderData - "
+ "caught NoSuchElementException!" );
+ }
+ }
+ }
+ }
+ catch ( uno::RuntimeException& )
+ {
+ OSL_ENSURE( false,
+ "getContentProviderData - caught RuntimeException!" );
+ return false;
+ }
+ catch ( uno::Exception& )
+ {
+ // createInstance, createInstanceWithArguments
+
+ OSL_ENSURE( false,
+ "getContentProviderData - caught Exception!" );
+ return false;
+ }
+
+ return true;
+}
+
+}
diff --git a/ucbhelper/source/provider/provconf.hxx b/ucbhelper/source/provider/provconf.hxx
new file mode 100644
index 000000000000..66d6a63d47b8
--- /dev/null
+++ b/ucbhelper/source/provider/provconf.hxx
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _UCBHELPER_PROVCONF_HXX_
+#define _UCBHELPER_PROFCONF_HXX_
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <ucbhelper/configureucb.hxx>
+
+namespace com { namespace sun { namespace star { namespace lang {
+ class XMultiServiceFactory;
+} } } }
+
+//=========================================================================
+
+namespace ucbhelper {
+
+bool getContentProviderData( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >
+ & rServiceMgr,
+ const rtl::OUString & rKey1,
+ const rtl::OUString & rKey2,
+ ContentProviderDataList & rListToFill );
+
+}
+
+#endif /* !_UCBHELPER_PROVCONF_HXX_ */
diff --git a/ucbhelper/source/provider/providerhelper.cxx b/ucbhelper/source/provider/providerhelper.cxx
new file mode 100644
index 000000000000..ac35df0e3420
--- /dev/null
+++ b/ucbhelper/source/provider/providerhelper.cxx
@@ -0,0 +1,672 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+
+#include <hash_map>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp>
+#include <com/sun/star/ucb/XPropertySetRegistry.hpp>
+
+#include "osl/diagnose.h"
+#include "osl/mutex.hxx"
+#include "cppuhelper/weakref.hxx"
+#include <ucbhelper/contentidentifier.hxx>
+#include <ucbhelper/providerhelper.hxx>
+#include <ucbhelper/contenthelper.hxx>
+
+using namespace com::sun::star;
+
+namespace ucbhelper_impl
+{
+
+//=========================================================================
+//
+// Contents.
+//
+//=========================================================================
+
+struct equalString
+{
+ bool operator()(
+ const rtl::OUString& rKey11, const rtl::OUString& rKey22 ) const
+ {
+ return !!( rKey11 == rKey22 );
+ }
+};
+
+struct hashString
+{
+ size_t operator()( const rtl::OUString & rName ) const
+ {
+ return rName.hashCode();
+ }
+};
+
+typedef std::hash_map
+<
+ rtl::OUString,
+ uno::WeakReference< ucb::XContent >,
+ hashString,
+ equalString
+>
+Contents;
+
+//=========================================================================
+//
+// struct ContentProviderImplHelper_Impl.
+//
+//=========================================================================
+
+struct ContentProviderImplHelper_Impl
+{
+ uno::Reference< com::sun::star::ucb::XPropertySetRegistry >
+ m_xPropertySetRegistry;
+ Contents
+ m_aContents;
+};
+
+} // namespace ucbhelper_impl
+
+//=========================================================================
+//=========================================================================
+//
+// ContentProviderImplHelper Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+namespace ucbhelper {
+
+ContentProviderImplHelper::ContentProviderImplHelper(
+ const uno::Reference< lang::XMultiServiceFactory >& rXSMgr )
+: m_pImpl( new ucbhelper_impl::ContentProviderImplHelper_Impl ),
+ m_xSMgr( rXSMgr )
+{
+}
+
+//=========================================================================
+// virtual
+ContentProviderImplHelper::~ContentProviderImplHelper()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_3( ContentProviderImplHelper,
+ lang::XTypeProvider,
+ lang::XServiceInfo,
+ com::sun::star::ucb::XContentProvider );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_3( ContentProviderImplHelper,
+ lang::XTypeProvider,
+ lang::XServiceInfo,
+ com::sun::star::ucb::XContentProvider );
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+// virtual
+sal_Bool SAL_CALL ContentProviderImplHelper::supportsService(
+ const rtl::OUString& ServiceName )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
+ const rtl::OUString* pArray = aSNL.getConstArray();
+ for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ {
+ if ( pArray[ i ] == ServiceName )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+//=========================================================================
+//
+// XContentProvider methods.
+//
+//=========================================================================
+
+// virtual
+sal_Int32 SAL_CALL ContentProviderImplHelper::compareContentIds(
+ const uno::Reference< com::sun::star::ucb::XContentIdentifier >& Id1,
+ const uno::Reference< com::sun::star::ucb::XContentIdentifier >& Id2 )
+ throw( uno::RuntimeException )
+{
+ // Simply do a string compare.
+
+ rtl::OUString aURL1( Id1->getContentIdentifier() );
+ rtl::OUString aURL2( Id2->getContentIdentifier() );
+
+ return aURL1.compareTo( aURL2 );;
+}
+
+//=========================================================================
+//
+// Non-interface methods
+//
+//=========================================================================
+
+void ContentProviderImplHelper::cleanupRegisteredContents()
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ ucbhelper_impl::Contents::iterator it
+ = m_pImpl->m_aContents.begin();
+ while( it != m_pImpl->m_aContents.end() )
+ {
+ uno::Reference< ucb::XContent > xContent( (*it).second );
+ if ( !xContent.is() )
+ {
+ ucbhelper_impl::Contents::iterator tmp = it;
+ ++it;
+ m_pImpl->m_aContents.erase( tmp );
+ }
+ else
+ {
+ ++it;
+ }
+ }
+}
+
+//=========================================================================
+
+void ContentProviderImplHelper::removeContent( ContentImplHelper* pContent )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ cleanupRegisteredContents();
+
+ const rtl::OUString aURL(
+ pContent->getIdentifier()->getContentIdentifier() );
+
+ ucbhelper_impl::Contents::iterator it = m_pImpl->m_aContents.find( aURL );
+
+ if ( it != m_pImpl->m_aContents.end() )
+ m_pImpl->m_aContents.erase( it );
+}
+
+//=========================================================================
+rtl::Reference< ContentImplHelper >
+ContentProviderImplHelper::queryExistingContent(
+ const uno::Reference< com::sun::star::ucb::XContentIdentifier >&
+ Identifier )
+{
+ return queryExistingContent( Identifier->getContentIdentifier() );
+}
+
+//=========================================================================
+rtl::Reference< ContentImplHelper >
+ContentProviderImplHelper::queryExistingContent( const rtl::OUString& rURL )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ cleanupRegisteredContents();
+
+ // Check, if a content with given id already exists...
+
+ ucbhelper_impl::Contents::const_iterator it
+ = m_pImpl->m_aContents.find( rURL );
+ if ( it != m_pImpl->m_aContents.end() )
+ {
+ uno::Reference< ucb::XContent > xContent( (*it).second );
+ if ( xContent.is() )
+ {
+ return rtl::Reference< ContentImplHelper >(
+ static_cast< ContentImplHelper * >( xContent.get() ) );
+ }
+ }
+ return rtl::Reference< ContentImplHelper >();
+}
+
+//=========================================================================
+void ContentProviderImplHelper::queryExistingContents(
+ ContentRefList& rContents )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ cleanupRegisteredContents();
+
+ ucbhelper_impl::Contents::const_iterator it
+ = m_pImpl->m_aContents.begin();
+ ucbhelper_impl::Contents::const_iterator end
+ = m_pImpl->m_aContents.end();
+
+ while ( it != end )
+ {
+ uno::Reference< ucb::XContent > xContent( (*it).second );
+ if ( xContent.is() )
+ {
+ rContents.push_back(
+ rtl::Reference< ContentImplHelper >(
+ static_cast< ContentImplHelper * >( xContent.get() ) ) );
+ }
+ ++it;
+ }
+}
+
+//=========================================================================
+void ContentProviderImplHelper::registerNewContent(
+ const uno::Reference< ucb::XContent > & xContent )
+{
+ if ( xContent.is() )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+
+ cleanupRegisteredContents();
+
+ const rtl::OUString aURL(
+ xContent->getIdentifier()->getContentIdentifier() );
+ ucbhelper_impl::Contents::const_iterator it
+ = m_pImpl->m_aContents.find( aURL );
+ if ( it == m_pImpl->m_aContents.end() )
+ m_pImpl->m_aContents[ aURL ] = xContent;
+ }
+}
+
+//=========================================================================
+uno::Reference< com::sun::star::ucb::XPropertySetRegistry >
+ContentProviderImplHelper::getAdditionalPropertySetRegistry()
+{
+ // Get propertyset registry.
+
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pImpl->m_xPropertySetRegistry.is() )
+ {
+ uno::Reference< com::sun::star::ucb::XPropertySetRegistryFactory >
+ xRegFac(
+ m_xSMgr->createInstance(
+ rtl::OUString::createFromAscii(
+ "com.sun.star.ucb.Store" ) ),
+ uno::UNO_QUERY );
+
+ OSL_ENSURE( xRegFac.is(),
+ "ContentProviderImplHelper::getAdditionalPropertySet - "
+ "No UCB-Store service!" );
+
+ if ( xRegFac.is() )
+ {
+ // Open/create a registry.
+ m_pImpl->m_xPropertySetRegistry
+ = xRegFac->createPropertySetRegistry( rtl::OUString() );
+
+ OSL_ENSURE( m_pImpl->m_xPropertySetRegistry.is(),
+ "ContentProviderImplHelper::getAdditionalPropertySet - "
+ "Error opening registry!" );
+ }
+ }
+
+ return m_pImpl->m_xPropertySetRegistry;
+}
+
+
+//=========================================================================
+uno::Reference< com::sun::star::ucb::XPersistentPropertySet >
+ContentProviderImplHelper::getAdditionalPropertySet(
+ const rtl::OUString& rKey, sal_Bool bCreate )
+{
+ // Get propertyset registry.
+ getAdditionalPropertySetRegistry();
+
+ if ( m_pImpl->m_xPropertySetRegistry.is() )
+ {
+ // Open/create persistent property set.
+ return uno::Reference< com::sun::star::ucb::XPersistentPropertySet >(
+ m_pImpl->m_xPropertySetRegistry->openPropertySet(
+ rKey, bCreate ) );
+ }
+
+ return uno::Reference< com::sun::star::ucb::XPersistentPropertySet >();
+}
+
+//=========================================================================
+sal_Bool ContentProviderImplHelper::renameAdditionalPropertySet(
+ const rtl::OUString& rOldKey,
+ const rtl::OUString& rNewKey,
+ sal_Bool bRecursive )
+{
+ if ( rOldKey == rNewKey )
+ return sal_True;
+
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( bRecursive )
+ {
+ // Get propertyset registry.
+ getAdditionalPropertySetRegistry();
+
+ if ( m_pImpl->m_xPropertySetRegistry.is() )
+ {
+ uno::Reference< container::XNameAccess > xNameAccess(
+ m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
+ if ( xNameAccess.is() )
+ {
+ uno::Sequence< rtl::OUString > aKeys
+ = xNameAccess->getElementNames();
+ sal_Int32 nCount = aKeys.getLength();
+ if ( nCount > 0 )
+ {
+ rtl::OUString aOldKeyWithSlash = rOldKey;
+ rtl::OUString aOldKeyWithoutSlash;
+ if ( aOldKeyWithSlash.lastIndexOf(
+ sal_Unicode('/')
+ != aOldKeyWithSlash.getLength() - 1 ) )
+ {
+ aOldKeyWithSlash += rtl::OUString( sal_Unicode('/') );
+ aOldKeyWithoutSlash = rOldKey;
+ }
+ else if ( rOldKey.getLength() )
+ aOldKeyWithoutSlash
+ = rOldKey.copy( 0, rOldKey.getLength() - 1 );
+
+ const rtl::OUString* pKeys = aKeys.getConstArray();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const rtl::OUString& rKey = pKeys[ n ];
+ if ( rKey.compareTo(
+ aOldKeyWithSlash,
+ aOldKeyWithSlash.getLength() ) == 0
+ || rKey.equals( aOldKeyWithoutSlash ) )
+ {
+ rtl::OUString aNewKey
+ = rKey.replaceAt(
+ 0, rOldKey.getLength(), rNewKey );
+ if ( !renameAdditionalPropertySet(
+ rKey, aNewKey, sal_False ) )
+ return sal_False;
+ }
+ }
+ }
+ }
+ else
+ return sal_False;
+ }
+ else
+ return sal_False;
+ }
+ else
+ {
+ // Get old property set, if exists.
+ uno::Reference< com::sun::star::ucb::XPersistentPropertySet > xOldSet
+ = getAdditionalPropertySet( rOldKey, sal_False );
+ if ( xOldSet.is() )
+ {
+ // Rename property set.
+ uno::Reference< container::XNamed > xNamed(
+ xOldSet, uno::UNO_QUERY );
+ if ( xNamed.is() )
+ {
+ // ??? throws no exceptions and has no return value ???
+ xNamed->setName( rNewKey );
+ }
+ else
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+
+//=========================================================================
+sal_Bool ContentProviderImplHelper::copyAdditionalPropertySet(
+ const rtl::OUString& rSourceKey,
+ const rtl::OUString& rTargetKey,
+ sal_Bool bRecursive )
+{
+ if ( rSourceKey == rTargetKey )
+ return sal_True;
+
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( bRecursive )
+ {
+ // Get propertyset registry.
+ getAdditionalPropertySetRegistry();
+
+ if ( m_pImpl->m_xPropertySetRegistry.is() )
+ {
+ uno::Reference< container::XNameAccess > xNameAccess(
+ m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
+ if ( xNameAccess.is() )
+ {
+ uno::Sequence< rtl::OUString > aKeys
+ = xNameAccess->getElementNames();
+ sal_Int32 nCount = aKeys.getLength();
+ if ( nCount > 0 )
+ {
+ rtl::OUString aSrcKeyWithSlash = rSourceKey;
+ rtl::OUString aSrcKeyWithoutSlash;
+ if ( aSrcKeyWithSlash.lastIndexOf(
+ sal_Unicode('/')
+ != aSrcKeyWithSlash.getLength() - 1 ) )
+ {
+ aSrcKeyWithSlash += rtl::OUString( sal_Unicode('/') );
+ aSrcKeyWithoutSlash = rSourceKey;
+ }
+ else if ( rSourceKey.getLength() )
+ aSrcKeyWithoutSlash = rSourceKey.copy(
+ 0, rSourceKey.getLength() - 1 );
+
+ const rtl::OUString* pKeys = aKeys.getConstArray();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const rtl::OUString& rKey = pKeys[ n ];
+ if ( rKey.compareTo(
+ aSrcKeyWithSlash,
+ aSrcKeyWithSlash.getLength() ) == 0
+ || rKey.equals( aSrcKeyWithoutSlash ) )
+ {
+ rtl::OUString aNewKey
+ = rKey.replaceAt(
+ 0, rSourceKey.getLength(), rTargetKey );
+ if ( !copyAdditionalPropertySet(
+ rKey, aNewKey, sal_False ) )
+ return sal_False;
+ }
+ }
+ }
+ }
+ else
+ return sal_False;
+ }
+ else
+ return sal_False;
+ }
+ else
+ {
+ // Get old property set, if exists.
+ uno::Reference< com::sun::star::ucb::XPersistentPropertySet >
+ xOldPropSet = getAdditionalPropertySet( rSourceKey, sal_False );
+ if ( !xOldPropSet.is() )
+ return sal_False;
+
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo
+ = xOldPropSet->getPropertySetInfo();
+ if ( !xPropSetInfo.is() )
+ return sal_False;
+
+ uno::Reference< beans::XPropertyAccess > xOldPropAccess(
+ xOldPropSet, uno::UNO_QUERY );
+ if ( !xOldPropAccess.is() )
+ return sal_False;
+
+ // Obtain all values from old set.
+ uno::Sequence< beans::PropertyValue > aValues
+ = xOldPropAccess->getPropertyValues();
+ sal_Int32 nCount = aValues.getLength();
+
+ uno::Sequence< beans::Property > aProps
+ = xPropSetInfo->getProperties();
+
+ if ( nCount )
+ {
+ // Fail, if property set with new key already exists.
+ uno::Reference< com::sun::star::ucb::XPersistentPropertySet >
+ xNewPropSet
+ = getAdditionalPropertySet( rTargetKey, sal_False );
+ if ( xNewPropSet.is() )
+ return sal_False;
+
+ // Create new, empty set.
+ xNewPropSet = getAdditionalPropertySet( rTargetKey, sal_True );
+ if ( !xNewPropSet.is() )
+ return sal_False;
+
+ uno::Reference< beans::XPropertyContainer > xNewPropContainer(
+ xNewPropSet, uno::UNO_QUERY );
+ if ( !xNewPropContainer.is() )
+ return sal_False;
+
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const beans::PropertyValue& rValue = aValues[ n ];
+
+ sal_Int16 nAttribs = 0;
+ for ( sal_Int32 m = 0; m < aProps.getLength(); ++m )
+ {
+ if ( aProps[ m ].Name == rValue.Name )
+ {
+ nAttribs = aProps[ m ].Attributes;
+ break;
+ }
+ }
+
+ try
+ {
+ xNewPropContainer->addProperty(
+ rValue.Name, nAttribs, rValue.Value );
+ }
+ catch ( beans::PropertyExistException & )
+ {
+ }
+ catch ( beans::IllegalTypeException & )
+ {
+ }
+ catch ( lang::IllegalArgumentException & )
+ {
+ }
+ }
+ }
+ }
+ return sal_True;
+}
+
+//=========================================================================
+sal_Bool ContentProviderImplHelper::removeAdditionalPropertySet(
+ const rtl::OUString& rKey, sal_Bool bRecursive )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( bRecursive )
+ {
+ // Get propertyset registry.
+ getAdditionalPropertySetRegistry();
+
+ if ( m_pImpl->m_xPropertySetRegistry.is() )
+ {
+ uno::Reference< container::XNameAccess > xNameAccess(
+ m_pImpl->m_xPropertySetRegistry, uno::UNO_QUERY );
+ if ( xNameAccess.is() )
+ {
+ uno::Sequence< rtl::OUString > aKeys
+ = xNameAccess->getElementNames();
+ sal_Int32 nCount = aKeys.getLength();
+ if ( nCount > 0 )
+ {
+ rtl::OUString aKeyWithSlash = rKey;
+ rtl::OUString aKeyWithoutSlash;
+ if ( aKeyWithSlash.lastIndexOf(
+ sal_Unicode('/')
+ != aKeyWithSlash.getLength() - 1 ) )
+ {
+ aKeyWithSlash += rtl::OUString( (sal_Unicode)'/' );
+ aKeyWithoutSlash = rKey;
+ }
+ else if ( rKey.getLength() )
+ aKeyWithoutSlash
+ = rKey.copy( 0, rKey.getLength() - 1 );
+
+ const rtl::OUString* pKeys = aKeys.getConstArray();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const rtl::OUString& rCurrKey = pKeys[ n ];
+ if ( rCurrKey.compareTo(
+ aKeyWithSlash,
+ aKeyWithSlash.getLength() ) == 0
+ || rCurrKey.equals( aKeyWithoutSlash ) )
+ {
+ if ( !removeAdditionalPropertySet(
+ rCurrKey, sal_False ) )
+ return sal_False;
+ }
+ }
+ }
+ }
+ else
+ return sal_False;
+ }
+ else
+ return sal_False;
+ }
+ else
+ {
+ // Get propertyset registry.
+ getAdditionalPropertySetRegistry();
+
+ if ( m_pImpl->m_xPropertySetRegistry.is() )
+ m_pImpl->m_xPropertySetRegistry->removePropertySet( rKey );
+ else
+ return sal_False;
+ }
+ return sal_True;
+}
+
+} // namespace ucbhelper
diff --git a/ucbhelper/source/provider/registerucb.cxx b/ucbhelper/source/provider/registerucb.cxx
new file mode 100644
index 000000000000..e6ccaf4743a8
--- /dev/null
+++ b/ucbhelper/source/provider/registerucb.cxx
@@ -0,0 +1,164 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_ucbhelper.hxx"
+#include <ucbhelper/registerucb.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/XContentProviderManager.hpp>
+#include <com/sun/star/ucb/XParameterizedContentProvider.hpp>
+#include <com/sun/star/ucb/XContentProviderFactory.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+
+#include "osl/diagnose.h"
+
+using namespace com::sun::star;
+
+namespace ucbhelper {
+
+//============================================================================
+//
+// registerAtUcb
+//
+//============================================================================
+
+bool
+registerAtUcb(
+ uno::Reference< ucb::XContentProviderManager > const & rManager,
+ uno::Reference< lang::XMultiServiceFactory > const & rServiceFactory,
+ rtl::OUString const & rName,
+ rtl::OUString const & rArguments,
+ rtl::OUString const & rTemplate,
+ ContentProviderRegistrationInfo * pInfo)
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE(rServiceFactory.is(),
+ "ucb::registerAtUcb(): No service factory");
+
+ bool bNoProxy
+ = rArguments.compareToAscii(RTL_CONSTASCII_STRINGPARAM("{noproxy}"))
+ == 0;
+ rtl::OUString
+ aProviderArguments(bNoProxy ?
+ rArguments.
+ copy(RTL_CONSTASCII_LENGTH("{noproxy}")) :
+ rArguments);
+
+ // First, try to instantiate proxy for provider:
+ uno::Reference< ucb::XContentProvider > xProvider;
+ if (!bNoProxy)
+ {
+ uno::Reference< ucb::XContentProviderFactory > xProxyFactory;
+ try
+ {
+ xProxyFactory
+ = uno::Reference< ucb::XContentProviderFactory >(
+ rServiceFactory->
+ createInstance(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.ucb.ContentProviderProxyFactory"))),
+ uno::UNO_QUERY);
+ }
+ catch (uno::Exception const &) {}
+ OSL_ENSURE(xProxyFactory.is(), "No ContentProviderProxyFactory");
+ if (xProxyFactory.is())
+ xProvider = xProxyFactory->createContentProvider(rName);
+ }
+
+ // Then, try to instantiate provider directly:
+ if (!xProvider.is())
+ try
+ {
+ xProvider = uno::Reference< ucb::XContentProvider >(
+ rServiceFactory->createInstance(rName),
+ uno::UNO_QUERY);
+ }
+ catch (uno::RuntimeException const &) { throw; }
+ catch (uno::Exception const &) {}
+
+ uno::Reference< ucb::XContentProvider >
+ xOriginalProvider(xProvider);
+ uno::Reference< ucb::XParameterizedContentProvider >
+ xParameterized(xProvider, uno::UNO_QUERY);
+ if (xParameterized.is())
+ {
+ uno::Reference< ucb::XContentProvider > xInstance;
+ try
+ {
+ xInstance = xParameterized->registerInstance(rTemplate,
+ aProviderArguments,
+ true);
+ //@@@ if this call replaces an old instance, the commit-or-
+ // rollback code below will not work
+ }
+ catch (lang::IllegalArgumentException const &) {}
+
+ if (xInstance.is())
+ xProvider = xInstance;
+ }
+
+ bool bSuccess = false;
+ if (rManager.is() && xProvider.is())
+ try
+ {
+ rManager->registerContentProvider(xProvider, rTemplate, true);
+ bSuccess = true;
+ }
+ catch (ucb::DuplicateProviderException const &)
+ {
+ if (xParameterized.is())
+ try
+ {
+ xParameterized->deregisterInstance(rTemplate,
+ aProviderArguments);
+ }
+ catch (lang::IllegalArgumentException const &) {}
+ }
+ catch (...)
+ {
+ if (xParameterized.is())
+ try
+ {
+ xParameterized->deregisterInstance(rTemplate,
+ aProviderArguments);
+ }
+ catch (lang::IllegalArgumentException const &) {}
+ catch (uno::RuntimeException const &) {}
+ throw;
+ }
+
+ if (bSuccess && pInfo)
+ {
+ pInfo->m_xProvider = xOriginalProvider;
+ pInfo->m_aArguments = aProviderArguments;
+ pInfo->m_aTemplate = rTemplate;
+ }
+ return bSuccess;
+}
+
+}
diff --git a/ucbhelper/source/provider/resultset.cxx b/ucbhelper/source/provider/resultset.cxx
new file mode 100644
index 000000000000..47825f15c6b1
--- /dev/null
+++ b/ucbhelper/source/provider/resultset.cxx
@@ -0,0 +1,1695 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+#include <cppuhelper/interfacecontainer.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <ucbhelper/resultset.hxx>
+#include <ucbhelper/resultsetmetadata.hxx>
+
+using namespace com::sun::star;
+
+//=========================================================================
+
+namespace ucbhelper_impl
+{
+
+struct PropertyInfo
+{
+ const char* pName;
+ sal_Int32 nHandle;
+ sal_Int16 nAttributes;
+ const uno::Type& (*pGetCppuType)();
+};
+
+static const uno::Type& sal_Int32_getCppuType()
+{
+ return getCppuType( static_cast< const sal_Int32 * >( 0 ) );
+}
+
+static const uno::Type& sal_Bool_getCppuType()
+{
+ return getCppuBooleanType();
+}
+
+static const PropertyInfo aPropertyTable[] =
+{
+ { "IsRowCountFinal",
+ 1000,
+ beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY,
+ &sal_Bool_getCppuType
+ },
+ { "RowCount",
+ 1001,
+ beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY,
+ &sal_Int32_getCppuType
+ },
+ { 0,
+ 0,
+ 0,
+ 0
+ }
+};
+
+#define RESULTSET_PROPERTY_COUNT 2
+
+//=========================================================================
+//
+// class PropertySetInfo
+//
+//=========================================================================
+
+class PropertySetInfo :
+ public cppu::OWeakObject,
+ public lang::XTypeProvider,
+ public beans::XPropertySetInfo
+{
+ uno::Reference< lang::XMultiServiceFactory > m_xSMgr;
+ uno::Sequence< beans::Property >* m_pProps;
+
+private:
+ sal_Bool queryProperty(
+ const rtl::OUString& aName, beans::Property& rProp );
+
+public:
+ PropertySetInfo(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
+ const PropertyInfo* pProps,
+ sal_Int32 nProps );
+ virtual ~PropertySetInfo();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XPropertySetInfo
+ virtual uno::Sequence< beans::Property > SAL_CALL getProperties()
+ throw( uno::RuntimeException );
+ virtual beans::Property SAL_CALL getPropertyByName(
+ const rtl::OUString& aName )
+ throw( beans::UnknownPropertyException, uno::RuntimeException );
+ virtual sal_Bool SAL_CALL hasPropertyByName( const rtl::OUString& Name )
+ throw( uno::RuntimeException );
+};
+
+//=========================================================================
+//
+// PropertyChangeListenerContainer.
+//
+//=========================================================================
+
+struct equalStr_Impl
+{
+ bool operator()( const rtl::OUString& s1, const rtl::OUString& s2 ) const
+ {
+ return !!( s1 == s2 );
+ }
+};
+
+struct hashStr_Impl
+{
+ size_t operator()( const rtl::OUString& rName ) const
+ {
+ return rName.hashCode();
+ }
+};
+
+typedef cppu::OMultiTypeInterfaceContainerHelperVar
+<
+ rtl::OUString,
+ hashStr_Impl,
+ equalStr_Impl
+> PropertyChangeListenerContainer;
+
+//=========================================================================
+//
+// class PropertyChangeListeners.
+//
+//=========================================================================
+
+class PropertyChangeListeners : public PropertyChangeListenerContainer
+{
+public:
+ PropertyChangeListeners( osl::Mutex& rMtx )
+ : PropertyChangeListenerContainer( rMtx ) {}
+};
+
+} // namespace ucbhelper_impl
+
+using namespace ucbhelper_impl;
+
+namespace ucbhelper
+{
+
+//=========================================================================
+//
+// struct ResultSet_Impl.
+//
+//=========================================================================
+
+struct ResultSet_Impl
+{
+ uno::Reference< lang::XMultiServiceFactory > m_xSMgr;
+ uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xEnv;
+ uno::Reference< beans::XPropertySetInfo > m_xPropSetInfo;
+ uno::Reference< sdbc::XResultSetMetaData > m_xMetaData;
+ uno::Sequence< beans::Property > m_aProperties;
+ rtl::Reference< ResultSetDataSupplier > m_xDataSupplier;
+ osl::Mutex m_aMutex;
+ cppu::OInterfaceContainerHelper* m_pDisposeEventListeners;
+ PropertyChangeListeners* m_pPropertyChangeListeners;
+ sal_Int32 m_nPos;
+ sal_Bool m_bWasNull;
+ sal_Bool m_bAfterLast;
+
+ inline ResultSet_Impl(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
+ const uno::Sequence< beans::Property >& rProperties,
+ const rtl::Reference< ResultSetDataSupplier >& rDataSupplier,
+ const uno::Reference< com::sun::star::ucb::XCommandEnvironment >&
+ rxEnv );
+ inline ~ResultSet_Impl();
+};
+
+inline ResultSet_Impl::ResultSet_Impl(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
+ const uno::Sequence< beans::Property >& rProperties,
+ const rtl::Reference< ResultSetDataSupplier >& rDataSupplier,
+ const uno::Reference< com::sun::star::ucb::XCommandEnvironment >& rxEnv )
+: m_xSMgr( rxSMgr ),
+ m_xEnv( rxEnv ),
+ m_aProperties( rProperties ),
+ m_xDataSupplier( rDataSupplier ),
+ m_pDisposeEventListeners( 0 ),
+ m_pPropertyChangeListeners( 0 ),
+ m_nPos( 0 ), // Position is one-based. Zero means: before first element.
+ m_bWasNull( sal_False ),
+ m_bAfterLast( sal_False )
+{
+}
+
+//=========================================================================
+inline ResultSet_Impl::~ResultSet_Impl()
+{
+ delete m_pDisposeEventListeners;
+ delete m_pPropertyChangeListeners;
+}
+
+//=========================================================================
+//=========================================================================
+//
+// ResultSet Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+ResultSet::ResultSet(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
+ const uno::Sequence< beans::Property >& rProperties,
+ const rtl::Reference< ResultSetDataSupplier >& rDataSupplier )
+: m_pImpl( new ResultSet_Impl(
+ rxSMgr,
+ rProperties,
+ rDataSupplier,
+ uno::Reference< com::sun::star::ucb::XCommandEnvironment >() ) )
+{
+ rDataSupplier->m_pResultSet = this;
+}
+
+//=========================================================================
+ResultSet::ResultSet(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
+ const uno::Sequence< beans::Property >& rProperties,
+ const rtl::Reference< ResultSetDataSupplier >& rDataSupplier,
+ const uno::Reference< com::sun::star::ucb::XCommandEnvironment >& rxEnv )
+: m_pImpl( new ResultSet_Impl( rxSMgr, rProperties, rDataSupplier, rxEnv ) )
+{
+ rDataSupplier->m_pResultSet = this;
+}
+
+//=========================================================================
+// virtual
+ResultSet::~ResultSet()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_9( ResultSet,
+ lang::XTypeProvider,
+ lang::XServiceInfo,
+ lang::XComponent,
+ com::sun::star::ucb::XContentAccess,
+ sdbc::XResultSet,
+ sdbc::XResultSetMetaDataSupplier,
+ sdbc::XRow,
+ sdbc::XCloseable,
+ beans::XPropertySet );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_9( ResultSet,
+ lang::XTypeProvider,
+ lang::XServiceInfo,
+ lang::XComponent,
+ com::sun::star::ucb::XContentAccess,
+ sdbc::XResultSet,
+ sdbc::XResultSetMetaDataSupplier,
+ sdbc::XRow,
+ sdbc::XCloseable,
+ beans::XPropertySet );
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+XSERVICEINFO_NOFACTORY_IMPL_1( ResultSet,
+ rtl::OUString::createFromAscii( "ResultSet" ),
+ rtl::OUString::createFromAscii( RESULTSET_SERVICE_NAME ) );
+
+//=========================================================================
+//
+// XComponent methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ResultSet::dispose()
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+
+ if ( m_pImpl->m_pDisposeEventListeners &&
+ m_pImpl->m_pDisposeEventListeners->getLength() )
+ {
+ lang::EventObject aEvt;
+ aEvt.Source = static_cast< lang::XComponent * >( this );
+ m_pImpl->m_pDisposeEventListeners->disposeAndClear( aEvt );
+ }
+
+ if ( m_pImpl->m_pPropertyChangeListeners )
+ {
+ lang::EventObject aEvt;
+ aEvt.Source = static_cast< beans::XPropertySet * >( this );
+ m_pImpl->m_pPropertyChangeListeners->disposeAndClear( aEvt );
+ }
+
+ m_pImpl->m_xDataSupplier->close();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSet::addEventListener(
+ const uno::Reference< lang::XEventListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+
+ if ( !m_pImpl->m_pDisposeEventListeners )
+ m_pImpl->m_pDisposeEventListeners =
+ new cppu::OInterfaceContainerHelper( m_pImpl->m_aMutex );
+
+ m_pImpl->m_pDisposeEventListeners->addInterface( Listener );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSet::removeEventListener(
+ const uno::Reference< lang::XEventListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+
+ if ( m_pImpl->m_pDisposeEventListeners )
+ m_pImpl->m_pDisposeEventListeners->removeInterface( Listener );
+}
+
+//=========================================================================
+//
+// XResultSetMetaDataSupplier methods.
+//
+//=========================================================================
+
+// virtual
+uno::Reference< sdbc::XResultSetMetaData > SAL_CALL ResultSet::getMetaData()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+
+ if ( !m_pImpl->m_xMetaData.is() )
+ m_pImpl->m_xMetaData = new ResultSetMetaData( m_pImpl->m_xSMgr,
+ m_pImpl->m_aProperties );
+
+ return m_pImpl->m_xMetaData;
+}
+
+//=========================================================================
+//
+// XResultSet methods.
+//
+//=========================================================================
+
+// virtual
+sal_Bool SAL_CALL ResultSet::next()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ // Note: Cursor is initially positioned before the first row.
+ // First call to 'next()' moves it to first row.
+
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+
+ if ( m_pImpl->m_bAfterLast )
+ {
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+ }
+
+ // getResult works zero-based!
+ if ( !m_pImpl->m_xDataSupplier->getResult( m_pImpl->m_nPos ) )
+ {
+ m_pImpl->m_bAfterLast = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+ }
+
+ m_pImpl->m_nPos++;
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_True;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::isBeforeFirst()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_bAfterLast )
+ {
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+ }
+
+ // getResult works zero-based!
+ if ( !m_pImpl->m_xDataSupplier->getResult( 0 ) )
+ {
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+ }
+
+ m_pImpl->m_xDataSupplier->validate();
+ return ( m_pImpl->m_nPos == 0 );
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::isAfterLast()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ m_pImpl->m_xDataSupplier->validate();
+ return m_pImpl->m_bAfterLast;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::isFirst()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_bAfterLast )
+ {
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+ }
+
+ m_pImpl->m_xDataSupplier->validate();
+ return ( m_pImpl->m_nPos == 1 );
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::isLast()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_bAfterLast )
+ {
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+ }
+
+ sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
+ if ( !nCount )
+ {
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+ }
+
+ m_pImpl->m_xDataSupplier->validate();
+ return ( m_pImpl->m_nPos == nCount );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSet::beforeFirst()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_False;
+ m_pImpl->m_nPos = 0;
+ m_pImpl->m_xDataSupplier->validate();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSet::afterLast()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::first()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ // getResult works zero-based!
+ if ( m_pImpl->m_xDataSupplier->getResult( 0 ) )
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_False;
+ m_pImpl->m_nPos = 1;
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_True;
+ }
+
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::last()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
+ if ( nCount )
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_False;
+ m_pImpl->m_nPos = nCount;
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_True;
+ }
+
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+}
+
+//=========================================================================
+// virtual
+sal_Int32 SAL_CALL ResultSet::getRow()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_bAfterLast )
+ {
+ m_pImpl->m_xDataSupplier->validate();
+ return 0;
+ }
+
+ m_pImpl->m_xDataSupplier->validate();
+ return m_pImpl->m_nPos;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::absolute( sal_Int32 row )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+/*
+ If the row number is positive, the cursor moves to the given row number
+ with respect to the beginning of the result set. The first row is row 1,
+ the second is row 2, and so on.
+
+ If the given row number is negative, the cursor moves to an absolute row
+ position with respect to the end of the result set. For example, calling
+ absolaute( -1 ) positions the cursor on the last row, absolaute( -2 )
+ indicates the next-to-last row, and so on.
+
+ An attempt to position the cursor beyond the first/last row in the result
+ set leaves the cursor before/after the first/last row, respectively.
+
+ Calling absolute( 1 ) is the same as calling first().
+
+ Calling absolute( -1 ) is the same as calling last().
+*/
+ if ( row < 0 )
+ {
+ sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
+
+ if ( ( row * -1 ) > nCount )
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_False;
+ m_pImpl->m_nPos = 0;
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+ }
+ else // |row| <= nCount
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_False;
+ m_pImpl->m_nPos = ( nCount + row + 1 );
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_True;
+ }
+ }
+ else if ( row == 0 )
+ {
+ // @throws SQLException
+ // ... if row is 0 ...
+ throw sdbc::SQLException();
+ }
+ else // row > 0
+ {
+ sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
+
+ if ( row <= nCount )
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_False;
+ m_pImpl->m_nPos = row;
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_True;
+ }
+ else // row > nCount
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+ }
+ }
+
+ // unreachable...
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::relative( sal_Int32 rows )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+/*
+ Attempting to move beyond the first/last row in the result set
+ positions the cursor before/after the the first/last row.
+
+ Calling relative( 0 ) is valid, but does not change the cursor position.
+
+ Calling relative( 1 ) is different from calling next() because it makes
+ sense to call next() when there is no current row, for example, when
+ the cursor is positioned before the first row or after the last row of
+ the result set.
+*/
+ if ( m_pImpl->m_bAfterLast || ( m_pImpl->m_nPos == 0 ) )
+ {
+ // "No current row".
+ throw sdbc::SQLException();
+ }
+
+ if ( rows < 0 )
+ {
+ if ( ( m_pImpl->m_nPos + rows ) > 0 )
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_False;
+ m_pImpl->m_nPos = ( m_pImpl->m_nPos + rows );
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_True;
+ }
+ else
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_False;
+ m_pImpl->m_nPos = 0;
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+ }
+ }
+ else if ( rows == 0 )
+ {
+ // nop.
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_True;
+ }
+ else // rows > 0
+ {
+ sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
+ if ( ( m_pImpl->m_nPos + rows ) <= nCount )
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_False;
+ m_pImpl->m_nPos = ( m_pImpl->m_nPos + rows );
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_True;
+ }
+ else
+ {
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ m_pImpl->m_bAfterLast = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+ }
+ }
+
+ // unreachable...
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::previous()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+/*
+ previous() is not the same as relative( -1 ) because it makes sense
+ to call previous() when there is no current row.
+*/
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+
+ if ( m_pImpl->m_bAfterLast )
+ {
+ m_pImpl->m_bAfterLast = sal_False;
+ sal_Int32 nCount = m_pImpl->m_xDataSupplier->totalCount();
+ m_pImpl->m_nPos = nCount;
+ }
+ else if ( m_pImpl->m_nPos )
+ m_pImpl->m_nPos--;
+
+ if ( m_pImpl->m_nPos )
+ {
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_True;
+ }
+
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSet::refreshRow()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+ if ( m_pImpl->m_bAfterLast || ( m_pImpl->m_nPos == 0 ) )
+ return;
+
+ m_pImpl->m_xDataSupplier->releasePropertyValues( m_pImpl->m_nPos );
+ m_pImpl->m_xDataSupplier->validate();
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::rowUpdated()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::rowInserted()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::rowDeleted()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+}
+
+//=========================================================================
+// virtual
+uno::Reference< uno::XInterface > SAL_CALL ResultSet::getStatement()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+/*
+ returns the Statement that produced this ResultSet object. If the
+ result set was generated some other way, ... this method returns null.
+*/
+ m_pImpl->m_xDataSupplier->validate();
+ return uno::Reference< uno::XInterface >();
+}
+
+//=========================================================================
+//
+// XRow methods.
+//
+//=========================================================================
+
+// virtual
+sal_Bool SAL_CALL ResultSet::wasNull()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ // This method can not be implemented correctly!!! Imagine different
+ // threads doing a getXYZ - wasNull calling sequence on the same
+ // implementation object...
+
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->wasNull();
+ }
+ }
+
+ m_pImpl->m_xDataSupplier->validate();
+ return m_pImpl->m_bWasNull;
+}
+
+//=========================================================================
+// virtual
+rtl::OUString SAL_CALL ResultSet::getString( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getString( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return rtl::OUString();
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSet::getBoolean( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getBoolean( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return sal_False;
+}
+
+//=========================================================================
+// virtual
+sal_Int8 SAL_CALL ResultSet::getByte( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getByte( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return 0;
+}
+
+//=========================================================================
+// virtual
+sal_Int16 SAL_CALL ResultSet::getShort( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getShort( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return 0;
+}
+
+//=========================================================================
+// virtual
+sal_Int32 SAL_CALL ResultSet::getInt( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getInt( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return 0;
+}
+
+//=========================================================================
+// virtual
+sal_Int64 SAL_CALL ResultSet::getLong( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getLong( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return 0;
+}
+
+//=========================================================================
+// virtual
+float SAL_CALL ResultSet::getFloat( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getFloat( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return 0;
+}
+
+//=========================================================================
+// virtual
+double SAL_CALL ResultSet::getDouble( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getDouble( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return 0;
+}
+
+//=========================================================================
+// virtual
+uno::Sequence< sal_Int8 > SAL_CALL
+ResultSet::getBytes( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getBytes( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return uno::Sequence< sal_Int8 >();
+}
+
+//=========================================================================
+// virtual
+util::Date SAL_CALL ResultSet::getDate( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getDate( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return util::Date();
+}
+
+//=========================================================================
+// virtual
+util::Time SAL_CALL ResultSet::getTime( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getTime( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return util::Time();
+}
+
+//=========================================================================
+// virtual
+util::DateTime SAL_CALL
+ResultSet::getTimestamp( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getTimestamp( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return util::DateTime();
+}
+
+//=========================================================================
+// virtual
+uno::Reference< io::XInputStream > SAL_CALL
+ResultSet::getBinaryStream( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getBinaryStream( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return uno::Reference< io::XInputStream >();
+}
+
+//=========================================================================
+// virtual
+uno::Reference< io::XInputStream > SAL_CALL
+ResultSet::getCharacterStream( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getCharacterStream( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return uno::Reference< io::XInputStream >();
+}
+
+//=========================================================================
+// virtual
+uno::Any SAL_CALL ResultSet::getObject(
+ sal_Int32 columnIndex,
+ const uno::Reference< container::XNameAccess >& typeMap )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getObject( columnIndex, typeMap );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return uno::Any();
+}
+
+//=========================================================================
+// virtual
+uno::Reference< sdbc::XRef > SAL_CALL
+ResultSet::getRef( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getRef( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return uno::Reference< sdbc::XRef >();
+}
+
+//=========================================================================
+// virtual
+uno::Reference< sdbc::XBlob > SAL_CALL
+ResultSet::getBlob( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getBlob( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return uno::Reference< sdbc::XBlob >();
+}
+
+//=========================================================================
+// virtual
+uno::Reference< sdbc::XClob > SAL_CALL
+ResultSet::getClob( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getClob( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return uno::Reference< sdbc::XClob >();
+}
+
+//=========================================================================
+// virtual
+uno::Reference< sdbc::XArray > SAL_CALL
+ResultSet::getArray( sal_Int32 columnIndex )
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ {
+ uno::Reference< sdbc::XRow > xValues
+ = m_pImpl->m_xDataSupplier->queryPropertyValues(
+ m_pImpl->m_nPos - 1 );
+ if ( xValues.is() )
+ {
+ m_pImpl->m_bWasNull = sal_False;
+ m_pImpl->m_xDataSupplier->validate();
+ return xValues->getArray( columnIndex );
+ }
+ }
+
+ m_pImpl->m_bWasNull = sal_True;
+ m_pImpl->m_xDataSupplier->validate();
+ return uno::Reference< sdbc::XArray >();
+}
+
+//=========================================================================
+//
+// XCloseable methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ResultSet::close()
+ throw( sdbc::SQLException, uno::RuntimeException )
+{
+ m_pImpl->m_xDataSupplier->close();
+ m_pImpl->m_xDataSupplier->validate();
+}
+
+//=========================================================================
+//
+// XContentAccess methods.
+//
+//=========================================================================
+
+// virtual
+rtl::OUString SAL_CALL ResultSet::queryContentIdentifierString()
+ throw( uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ return m_pImpl->m_xDataSupplier->queryContentIdentifierString(
+ m_pImpl->m_nPos - 1 );
+
+ return rtl::OUString();
+}
+
+//=========================================================================
+// virtual
+uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL
+ResultSet::queryContentIdentifier()
+ throw( uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ return m_pImpl->m_xDataSupplier->queryContentIdentifier(
+ m_pImpl->m_nPos - 1 );
+
+ return uno::Reference< com::sun::star::ucb::XContentIdentifier >();
+}
+
+//=========================================================================
+// virtual
+uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
+ResultSet::queryContent()
+ throw( uno::RuntimeException )
+{
+ if ( m_pImpl->m_nPos && !m_pImpl->m_bAfterLast )
+ return m_pImpl->m_xDataSupplier->queryContent( m_pImpl->m_nPos - 1 );
+
+ return uno::Reference< com::sun::star::ucb::XContent >();
+}
+
+//=========================================================================
+//
+// XPropertySet methods.
+//
+//=========================================================================
+
+// virtual
+uno::Reference< beans::XPropertySetInfo > SAL_CALL
+ResultSet::getPropertySetInfo()
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+
+ if ( !m_pImpl->m_xPropSetInfo.is() )
+ m_pImpl->m_xPropSetInfo
+ = new PropertySetInfo( m_pImpl->m_xSMgr,
+ aPropertyTable,
+ RESULTSET_PROPERTY_COUNT );
+ return m_pImpl->m_xPropSetInfo;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSet::setPropertyValue( const rtl::OUString& aPropertyName,
+ const uno::Any& )
+ throw( beans::UnknownPropertyException,
+ beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ if ( !aPropertyName.getLength() )
+ throw beans::UnknownPropertyException();
+
+ if ( aPropertyName.equals(
+ rtl::OUString::createFromAscii( "RowCount" ) ) )
+ {
+ // property is read-only.
+ throw lang::IllegalArgumentException();
+ }
+ else if ( aPropertyName.equals(
+ rtl::OUString::createFromAscii( "IsRowCountFinal" ) ) )
+ {
+ // property is read-only.
+ throw lang::IllegalArgumentException();
+ }
+ else
+ {
+ throw beans::UnknownPropertyException();
+ }
+}
+
+//=========================================================================
+// virtual
+uno::Any SAL_CALL ResultSet::getPropertyValue(
+ const rtl::OUString& PropertyName )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ if ( !PropertyName.getLength() )
+ throw beans::UnknownPropertyException();
+
+ uno::Any aValue;
+
+ if ( PropertyName.equals(
+ rtl::OUString::createFromAscii( "RowCount" ) ) )
+ {
+ aValue <<= m_pImpl->m_xDataSupplier->currentCount();
+ }
+ else if ( PropertyName.equals(
+ rtl::OUString::createFromAscii( "IsRowCountFinal" ) ) )
+ {
+ aValue <<= m_pImpl->m_xDataSupplier->isCountFinal();
+ }
+ else
+ {
+ throw beans::UnknownPropertyException();
+ }
+
+ return aValue;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSet::addPropertyChangeListener(
+ const rtl::OUString& aPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& xListener )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ // Note: An empty property name means a listener for "all" properties.
+
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+
+ if ( aPropertyName.getLength() &&
+ !aPropertyName.equals(
+ rtl::OUString::createFromAscii( "RowCount" ) ) &&
+ !aPropertyName.equals(
+ rtl::OUString::createFromAscii( "IsRowCountFinal" ) ) )
+ throw beans::UnknownPropertyException();
+
+ if ( !m_pImpl->m_pPropertyChangeListeners )
+ m_pImpl->m_pPropertyChangeListeners
+ = new PropertyChangeListeners( m_pImpl->m_aMutex );
+
+ m_pImpl->m_pPropertyChangeListeners->addInterface(
+ aPropertyName, xListener );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSet::removePropertyChangeListener(
+ const rtl::OUString& aPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& xListener )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_pImpl->m_aMutex );
+
+ if ( aPropertyName.getLength() &&
+ !aPropertyName.equals(
+ rtl::OUString::createFromAscii( "RowCount" ) ) &&
+ !aPropertyName.equals(
+ rtl::OUString::createFromAscii( "IsRowCountFinal" ) ) )
+ throw beans::UnknownPropertyException();
+
+ if ( m_pImpl->m_pPropertyChangeListeners )
+ m_pImpl->m_pPropertyChangeListeners->removeInterface(
+ aPropertyName, xListener );
+
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSet::addVetoableChangeListener(
+ const rtl::OUString&,
+ const uno::Reference< beans::XVetoableChangeListener >& )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ // No constrained props, at the moment.
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSet::removeVetoableChangeListener(
+ const rtl::OUString&,
+ const uno::Reference< beans::XVetoableChangeListener >& )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ // No constrained props, at the moment.
+}
+
+//=========================================================================
+//
+// Non-interface methods.
+//
+//=========================================================================
+
+void ResultSet::propertyChanged( const beans::PropertyChangeEvent& rEvt )
+{
+ if ( !m_pImpl->m_pPropertyChangeListeners )
+ return;
+
+ // Notify listeners interested especially in the changed property.
+ cppu::OInterfaceContainerHelper* pPropsContainer
+ = m_pImpl->m_pPropertyChangeListeners->getContainer(
+ rEvt.PropertyName );
+ if ( pPropsContainer )
+ {
+ cppu::OInterfaceIteratorHelper aIter( *pPropsContainer );
+ while ( aIter.hasMoreElements() )
+ {
+ uno::Reference< beans::XPropertyChangeListener > xListener(
+ aIter.next(), uno::UNO_QUERY );
+ if ( xListener.is() )
+ xListener->propertyChange( rEvt );
+ }
+ }
+
+ // Notify listeners interested in all properties.
+ pPropsContainer
+ = m_pImpl->m_pPropertyChangeListeners->getContainer( rtl::OUString() );
+ if ( pPropsContainer )
+ {
+ cppu::OInterfaceIteratorHelper aIter( *pPropsContainer );
+ while ( aIter.hasMoreElements() )
+ {
+ uno::Reference< beans::XPropertyChangeListener > xListener(
+ aIter.next(), uno::UNO_QUERY );
+ if ( xListener.is() )
+ xListener->propertyChange( rEvt );
+ }
+ }
+}
+
+//=========================================================================
+void ResultSet::rowCountChanged( sal_uInt32 nOld, sal_uInt32 nNew )
+{
+ OSL_ENSURE( nOld < nNew, "ResultSet::rowCountChanged - nOld >= nNew!" );
+
+ if ( !m_pImpl->m_pPropertyChangeListeners )
+ return;
+
+ propertyChanged(
+ beans::PropertyChangeEvent(
+ static_cast< cppu::OWeakObject * >( this ),
+ rtl::OUString::createFromAscii( "RowCount" ),
+ sal_False,
+ 1001,
+ uno::makeAny( nOld ), // old value
+ uno::makeAny( nNew ) ) ); // new value
+}
+
+//=========================================================================
+void ResultSet::rowCountFinal()
+{
+ if ( !m_pImpl->m_pPropertyChangeListeners )
+ return;
+
+ propertyChanged(
+ beans::PropertyChangeEvent(
+ static_cast< cppu::OWeakObject * >( this ),
+ rtl::OUString::createFromAscii( "IsRowCountFinal" ),
+ sal_False,
+ 1000,
+ uno:: makeAny( sal_False ), // old value
+ uno::makeAny( sal_True ) ) ); // new value
+}
+
+//=========================================================================
+const uno::Sequence< beans::Property >& ResultSet::getProperties()
+{
+ return m_pImpl->m_aProperties;
+}
+
+//=========================================================================
+const uno::Reference< com::sun::star::ucb::XCommandEnvironment >&
+ResultSet::getEnvironment()
+{
+ return m_pImpl->m_xEnv;
+}
+
+} // namespace ucbhelper
+
+namespace ucbhelper_impl {
+
+//=========================================================================
+//=========================================================================
+//
+// PropertySetInfo Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+PropertySetInfo::PropertySetInfo(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
+ const PropertyInfo* pProps,
+ sal_Int32 nProps )
+: m_xSMgr( rxSMgr )
+{
+ m_pProps = new uno::Sequence< beans::Property >( nProps );
+
+ if ( nProps )
+ {
+ const PropertyInfo* pEntry = pProps;
+ beans::Property* pProperties = m_pProps->getArray();
+
+ for ( sal_Int32 n = 0; n < nProps; ++n )
+ {
+ beans::Property& rProp = pProperties[ n ];
+
+ rProp.Name = rtl::OUString::createFromAscii( pEntry->pName );
+ rProp.Handle = pEntry->nHandle;
+ rProp.Type = pEntry->pGetCppuType();
+ rProp.Attributes = pEntry->nAttributes;
+
+ pEntry++;
+ }
+ }
+}
+
+//=========================================================================
+// virtual
+PropertySetInfo::~PropertySetInfo()
+{
+ delete m_pProps;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_2( PropertySetInfo,
+ lang::XTypeProvider,
+ beans::XPropertySetInfo );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_2( PropertySetInfo,
+ lang::XTypeProvider,
+ beans::XPropertySetInfo );
+
+//=========================================================================
+//
+// XPropertySetInfo methods.
+//
+//=========================================================================
+
+// virtual
+uno::Sequence< beans::Property > SAL_CALL PropertySetInfo::getProperties()
+ throw( uno::RuntimeException )
+{
+ return uno::Sequence< beans::Property >( *m_pProps );
+}
+
+//=========================================================================
+// virtual
+beans::Property SAL_CALL PropertySetInfo::getPropertyByName(
+ const rtl::OUString& aName )
+ throw( beans::UnknownPropertyException, uno::RuntimeException )
+{
+ beans::Property aProp;
+ if ( queryProperty( aName, aProp ) )
+ return aProp;
+
+ throw beans::UnknownPropertyException();
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName(
+ const rtl::OUString& Name )
+ throw( uno::RuntimeException )
+{
+ beans::Property aProp;
+ return queryProperty( Name, aProp );
+}
+
+//=========================================================================
+sal_Bool PropertySetInfo::queryProperty(
+ const rtl::OUString& aName, beans::Property& rProp )
+{
+ sal_Int32 nCount = m_pProps->getLength();
+ const beans::Property* pProps = m_pProps->getConstArray();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const beans::Property& rCurr = pProps[ n ];
+ if ( rCurr.Name == aName )
+ {
+ rProp = rCurr;
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+} // namespace ucbhelper_impl
diff --git a/ucbhelper/source/provider/resultsethelper.cxx b/ucbhelper/source/provider/resultsethelper.cxx
new file mode 100644
index 000000000000..a10f527b2ba9
--- /dev/null
+++ b/ucbhelper/source/provider/resultsethelper.cxx
@@ -0,0 +1,329 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ - This implementation is far away from completion. It has no interface
+ for changes notifications etc.
+
+ *************************************************************************/
+#include <com/sun/star/ucb/ListActionType.hpp>
+#include <com/sun/star/ucb/WelcomeDynamicResultSetStruct.hpp>
+#include <com/sun/star/ucb/XCachedDynamicResultSetStubFactory.hpp>
+#include <com/sun/star/ucb/XSourceInitialization.hpp>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <ucbhelper/resultsethelper.hxx>
+
+#include "osl/diagnose.h"
+
+using namespace com::sun::star;
+
+//=========================================================================
+//=========================================================================
+//
+// ResultSetImplHelper Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+namespace ucbhelper {
+
+//=========================================================================
+ResultSetImplHelper::ResultSetImplHelper(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr )
+: m_pDisposeEventListeners( 0 ),
+ m_bStatic( sal_False ),
+ m_bInitDone( sal_False ),
+ m_xSMgr( rxSMgr )
+{
+}
+
+//=========================================================================
+ResultSetImplHelper::ResultSetImplHelper(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
+ const com::sun::star::ucb::OpenCommandArgument2& rCommand )
+: m_pDisposeEventListeners( 0 ),
+ m_bStatic( sal_False ),
+ m_bInitDone( sal_False ),
+ m_aCommand( rCommand ),
+ m_xSMgr( rxSMgr )
+{
+}
+
+//=========================================================================
+// virtual
+ResultSetImplHelper::~ResultSetImplHelper()
+{
+ delete m_pDisposeEventListeners;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_4( ResultSetImplHelper,
+ lang::XTypeProvider,
+ lang::XServiceInfo,
+ lang::XComponent, /* base of XDynamicResultSet */
+ com::sun::star::ucb::XDynamicResultSet );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_3( ResultSetImplHelper,
+ lang::XTypeProvider,
+ lang::XServiceInfo,
+ com::sun::star::ucb::XDynamicResultSet );
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+XSERVICEINFO_NOFACTORY_IMPL_1( ResultSetImplHelper,
+ rtl::OUString::createFromAscii(
+ "ResultSetImplHelper" ),
+ rtl::OUString::createFromAscii(
+ DYNAMICRESULTSET_SERVICE_NAME ) );
+
+//=========================================================================
+//
+// XComponent methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ResultSetImplHelper::dispose()
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
+ {
+ lang::EventObject aEvt;
+ aEvt.Source = static_cast< lang::XComponent * >( this );
+ m_pDisposeEventListeners->disposeAndClear( aEvt );
+ }
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSetImplHelper::addEventListener(
+ const uno::Reference< lang::XEventListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_pDisposeEventListeners )
+ m_pDisposeEventListeners
+ = new cppu::OInterfaceContainerHelper( m_aMutex );
+
+ m_pDisposeEventListeners->addInterface( Listener );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSetImplHelper::removeEventListener(
+ const uno::Reference< lang::XEventListener >& Listener )
+ throw( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pDisposeEventListeners )
+ m_pDisposeEventListeners->removeInterface( Listener );
+}
+
+//=========================================================================
+//
+// XDynamicResultSet methods.
+//
+//=========================================================================
+
+// virtual
+uno::Reference< sdbc::XResultSet > SAL_CALL
+ResultSetImplHelper::getStaticResultSet()
+ throw( com::sun::star::ucb::ListenerAlreadySetException,
+ uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xListener.is() )
+ throw com::sun::star::ucb::ListenerAlreadySetException();
+
+ init( sal_True );
+ return m_xResultSet1;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSetImplHelper::setListener(
+ const uno::Reference< com::sun::star::ucb::XDynamicResultSetListener >&
+ Listener )
+ throw( com::sun::star::ucb::ListenerAlreadySetException,
+ uno::RuntimeException )
+{
+ osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ if ( m_bStatic || m_xListener.is() )
+ throw com::sun::star::ucb::ListenerAlreadySetException();
+
+ m_xListener = Listener;
+
+ //////////////////////////////////////////////////////////////////////
+ // Create "welcome event" and send it to listener.
+ //////////////////////////////////////////////////////////////////////
+
+ // Note: We only have the implementation for a static result set at the
+ // moment (src590). The dynamic result sets passed to the listener
+ // are a fake. This implementation will never call "notify" at the
+ // listener to propagate any changes!!!
+
+ init( sal_False );
+
+ uno::Any aInfo;
+ aInfo <<= com::sun::star::ucb::WelcomeDynamicResultSetStruct(
+ m_xResultSet1 /* "old" */,
+ m_xResultSet2 /* "new" */ );
+
+ uno::Sequence< com::sun::star::ucb::ListAction > aActions( 1 );
+ aActions.getArray()[ 0 ]
+ = com::sun::star::ucb::ListAction(
+ 0, // Position; not used
+ 0, // Count; not used
+ com::sun::star::ucb::ListActionType::WELCOME,
+ aInfo );
+ aGuard.clear();
+
+ Listener->notify(
+ com::sun::star::ucb::ListEvent(
+ static_cast< cppu::OWeakObject * >( this ), aActions ) );
+}
+
+//=========================================================================
+// virtual
+sal_Int16 SAL_CALL ResultSetImplHelper::getCapabilities()
+ throw( uno::RuntimeException )
+{
+ // ! com::sun::star::ucb::ContentResultSetCapability::SORTED
+ return 0;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL ResultSetImplHelper::connectToCache(
+ const uno::Reference< com::sun::star::ucb::XDynamicResultSet > &
+ xCache )
+ throw( com::sun::star::ucb::ListenerAlreadySetException,
+ com::sun::star::ucb::AlreadyInitializedException,
+ com::sun::star::ucb::ServiceNotFoundException,
+ uno::RuntimeException )
+{
+ if ( m_xListener.is() )
+ throw com::sun::star::ucb::ListenerAlreadySetException();
+
+ if ( m_bStatic )
+ throw com::sun::star::ucb::ListenerAlreadySetException();
+
+ uno::Reference< com::sun::star::ucb::XSourceInitialization >
+ xTarget( xCache, uno::UNO_QUERY );
+ if ( xTarget.is() )
+ {
+ uno::Reference<
+ com::sun::star::ucb::XCachedDynamicResultSetStubFactory >
+ xStubFactory;
+ try
+ {
+ xStubFactory
+ = uno::Reference<
+ com::sun::star::ucb::XCachedDynamicResultSetStubFactory >(
+ m_xSMgr->createInstance(
+ rtl::OUString::createFromAscii(
+ "com.sun.star.ucb.CachedDynamicResultSetStubFactory" ) ),
+ uno::UNO_QUERY );
+ }
+ catch ( uno::Exception const & )
+ {
+ }
+
+ if ( xStubFactory.is() )
+ {
+ xStubFactory->connectToCache(
+ this, xCache, m_aCommand.SortingInfo, 0 );
+ return;
+ }
+ }
+ throw com::sun::star::ucb::ServiceNotFoundException();
+}
+
+//=========================================================================
+//
+// Non-interface methods.
+//
+//=========================================================================
+
+void ResultSetImplHelper::init( sal_Bool bStatic )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_bInitDone )
+ {
+ if ( bStatic )
+ {
+ // virtual... derived class fills m_xResultSet1
+ initStatic();
+
+ OSL_ENSURE( m_xResultSet1.is(),
+ "ResultSetImplHelper::init - No 1st result set!" );
+ m_bStatic = sal_True;
+ }
+ else
+ {
+ // virtual... derived class fills m_xResultSet1 and m_xResultSet2
+ initDynamic();
+
+ OSL_ENSURE( m_xResultSet1.is(),
+ "ResultSetImplHelper::init - No 1st result set!" );
+ OSL_ENSURE( m_xResultSet2.is(),
+ "ResultSetImplHelper::init - No 2nd result set!" );
+ m_bStatic = sal_False;
+ }
+ m_bInitDone = sal_True;
+ }
+}
+
+} // namespace ucbhelper
diff --git a/ucbhelper/source/provider/resultsetmetadata.cxx b/ucbhelper/source/provider/resultsetmetadata.cxx
new file mode 100644
index 000000000000..30ba735943bc
--- /dev/null
+++ b/ucbhelper/source/provider/resultsetmetadata.cxx
@@ -0,0 +1,602 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+
+#include "osl/diagnose.h"
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XArray.hpp>
+#include <com/sun/star/sdbc/XBlob.hpp>
+#include <com/sun/star/sdbc/XClob.hpp>
+#include <com/sun/star/sdbc/XRef.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <ucbhelper/resultsetmetadata.hxx>
+
+using namespace com::sun::star::beans;
+using namespace com::sun::star::io;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::util;
+using namespace rtl;
+
+namespace ucbhelper_impl {
+
+struct ResultSetMetaData_Impl
+{
+ osl::Mutex m_aMutex;
+ std::vector< ::ucbhelper::ResultSetColumnData > m_aColumnData;
+ sal_Bool m_bObtainedTypes;
+ sal_Bool m_bGlobalReadOnlyValue;
+
+ ResultSetMetaData_Impl( sal_Int32 nSize )
+ : m_aColumnData( nSize ), m_bObtainedTypes( sal_False ),
+ m_bGlobalReadOnlyValue( sal_True ) {}
+
+ ResultSetMetaData_Impl(
+ const std::vector< ::ucbhelper::ResultSetColumnData >& rColumnData )
+ : m_aColumnData( rColumnData ), m_bObtainedTypes( sal_False ),
+ m_bGlobalReadOnlyValue( sal_False ) {}
+};
+
+}
+
+using namespace ucbhelper_impl;
+
+namespace ucbhelper {
+
+//=========================================================================
+//=========================================================================
+//
+// ResultSetMetaData Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+ResultSetMetaData::ResultSetMetaData(
+ const Reference< XMultiServiceFactory >& rxSMgr,
+ const Sequence< Property >& rProps,
+ sal_Bool bReadOnly )
+: m_pImpl( new ResultSetMetaData_Impl( rProps.getLength() ) ),
+ m_xSMgr( rxSMgr ),
+ m_aProps( rProps ),
+ m_bReadOnly( bReadOnly )
+{
+}
+
+//=========================================================================
+ResultSetMetaData::ResultSetMetaData(
+ const Reference< XMultiServiceFactory >& rxSMgr,
+ const Sequence< Property >& rProps,
+ const std::vector< ResultSetColumnData >& rColumnData )
+: m_pImpl( new ResultSetMetaData_Impl( rColumnData ) ),
+ m_xSMgr( rxSMgr ),
+ m_aProps( rProps ),
+ m_bReadOnly( sal_True )
+{
+ OSL_ENSURE( rColumnData.size() == sal_uInt32( rProps.getLength() ),
+ "ResultSetMetaData ctor - different array sizes!" );
+}
+
+//=========================================================================
+// virtual
+ResultSetMetaData::~ResultSetMetaData()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_2( ResultSetMetaData,
+ XTypeProvider,
+ XResultSetMetaData );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_2( ResultSetMetaData,
+ XTypeProvider,
+ XResultSetMetaData );
+
+//=========================================================================
+//
+// XResultSetMetaData methods.
+//
+//=========================================================================
+
+// virtual
+sal_Int32 SAL_CALL ResultSetMetaData::getColumnCount()
+ throw( SQLException, RuntimeException )
+{
+ return m_aProps.getLength();
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSetMetaData::isAutoIncrement( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Checks whether column is automatically numbered, which makes it
+ read-only.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return sal_False;
+
+ return m_pImpl->m_aColumnData[ column - 1 ].isAutoIncrement;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSetMetaData::isCaseSensitive( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return sal_False;
+
+ return m_pImpl->m_aColumnData[ column - 1 ].isCaseSensitive;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSetMetaData::isSearchable( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Checks whether the value stored in column can be used in a
+ WHERE clause.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return sal_False;
+
+ return m_pImpl->m_aColumnData[ column - 1 ].isSearchable;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSetMetaData::isCurrency( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Checks whether column is a cash value.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return sal_False;
+
+ return m_pImpl->m_aColumnData[ column - 1 ].isCurrency;
+}
+
+//=========================================================================
+// virtual
+sal_Int32 SAL_CALL ResultSetMetaData::isNullable( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Checks whether a NULL can be stored in column.
+ Possible values: see com/sun/star/sdbc/ColumnValue.idl
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return ColumnValue::NULLABLE;
+
+ return m_pImpl->m_aColumnData[ column - 1 ].isNullable;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSetMetaData::isSigned( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Checks whether the value stored in column is a signed number.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return sal_False;
+
+ return m_pImpl->m_aColumnData[ column - 1 ].isSigned;
+}
+
+//=========================================================================
+// virtual
+sal_Int32 SAL_CALL ResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Gets the normal maximum width in characters for column.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return 16;
+
+ return m_pImpl->m_aColumnData[ column - 1 ].columnDisplaySize;
+}
+
+//=========================================================================
+// virtual
+OUString SAL_CALL ResultSetMetaData::getColumnLabel( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Gets the suggested column title for column, to be used in print-
+ outs and displays.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return OUString();
+
+ OUString aLabel = m_pImpl->m_aColumnData[ column - 1 ].columnLabel;
+ if ( aLabel.getLength() )
+ return aLabel;
+
+ return m_aProps.getConstArray()[ column - 1 ].Name;
+}
+
+//=========================================================================
+// virtual
+OUString SAL_CALL ResultSetMetaData::getColumnName( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Gets the name of column.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return OUString();
+
+ return m_aProps.getConstArray()[ column - 1 ].Name;
+}
+
+//=========================================================================
+// virtual
+OUString SAL_CALL ResultSetMetaData::getSchemaName( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Gets the schema name for the table from which column of this
+ result set was derived.
+ Because this feature is not widely supported, the return value
+ for many DBMSs will be an empty string.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return OUString();
+
+ return m_pImpl->m_aColumnData[ column - 1 ].schemaName;
+}
+
+//=========================================================================
+// virtual
+sal_Int32 SAL_CALL ResultSetMetaData::getPrecision( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ For number types, getprecision gets the number of decimal digits
+ in column.
+ For character types, it gets the maximum length in characters for
+ column.
+ For binary types, it gets the maximum length in bytes for column.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return -1;
+
+ return m_pImpl->m_aColumnData[ column - 1 ].precision;
+}
+
+//=========================================================================
+// virtual
+sal_Int32 SAL_CALL ResultSetMetaData::getScale( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Gets the number of digits to the right of the decimal point for
+ values in column.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return 0;
+
+ return m_pImpl->m_aColumnData[ column - 1 ].scale;
+}
+
+//=========================================================================
+// virtual
+OUString SAL_CALL ResultSetMetaData::getTableName( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Gets the name of the table from which column of this result set
+ was derived or "" if there is none (for example, for a join).
+ Because this feature is not widely supported, the return value
+ for many DBMSs will be an empty string.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return OUString();
+
+ return m_pImpl->m_aColumnData[ column - 1 ].tableName;
+}
+
+//=========================================================================
+// virtual
+OUString SAL_CALL ResultSetMetaData::getCatalogName( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Gets the catalog name for the table from which column of this
+ result set was derived.
+ Because this feature is not widely supported, the return value
+ for many DBMSs will be an empty string.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return OUString();
+
+ return m_pImpl->m_aColumnData[ column - 1 ].catalogName;
+}
+
+//=========================================================================
+// virtual
+sal_Int32 SAL_CALL ResultSetMetaData::getColumnType( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Gets the JDBC type for the value stored in column. ... The STRUCT
+ and DISTINCT type codes are always returned for structured and
+ distinct types, regardless of whether the value will be mapped
+ according to the standard mapping or be a custom mapping.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return DataType::SQLNULL;
+
+ if ( m_aProps.getConstArray()[ column - 1 ].Type
+ == getCppuVoidType() )
+ {
+ // No type given. Try UCB's Properties Manager...
+
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ if ( !m_pImpl->m_bObtainedTypes )
+ {
+ try
+ {
+ Reference< XPropertySetInfo > xInfo(
+ m_xSMgr->createInstance(
+ OUString::createFromAscii(
+ "com.sun.star.ucb.PropertiesManager" ) ),
+ UNO_QUERY );
+ if ( xInfo.is() )
+ {
+#if 0
+ // Convenient...
+
+ sal_Int32 nCount = m_pImpl->m_aProps.getLength();
+ Property* pProps = m_pImpl->m_aProps.getArray();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ Property& rProp = pProps[ n ];
+
+ try
+ {
+ Property aProp
+ = xInfo->getPropertyByName( rProp.Name );
+ rProp.Type = aProp.Type;
+ }
+ catch ( UnknownPropertyException& )
+ {
+ // getPropertyByName
+ }
+ }
+#else
+ // Less (remote) calls...
+
+ Sequence< Property > aProps = xInfo->getProperties();
+ const Property* pProps1 = aProps.getConstArray();
+ sal_Int32 nCount1 = aProps.getLength();
+
+ sal_Int32 nCount = m_aProps.getLength();
+ Property* pProps = m_aProps.getArray();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ Property& rProp = pProps[ n ];
+
+ for ( sal_Int32 m = 0; m < nCount1; ++m )
+ {
+ const Property& rProp1 = pProps1[ m ];
+ if ( rProp.Name == rProp1.Name )
+ {
+ // Found...
+ rProp.Type = rProp1.Type;
+ break;
+ }
+ }
+ }
+#endif
+ }
+ }
+ catch ( RuntimeException& )
+ {
+ throw;
+ }
+ catch ( Exception& )
+ {
+ // createInstance
+ }
+
+ m_pImpl->m_bObtainedTypes = sal_True;
+ }
+ }
+
+ const Type& rType = m_aProps.getConstArray()[ column - 1 ].Type;
+ sal_Int32 nType = DataType::OTHER;
+
+ if ( rType == getCppuType( static_cast< const rtl::OUString * >( 0 ) ) )
+ nType = DataType::VARCHAR; // XRow::getString
+ else if ( rType == getCppuBooleanType() )
+ nType = DataType::BIT; // XRow::getBoolean
+ else if ( rType == getCppuType( static_cast< const sal_Int32 * >( 0 ) ) )
+ nType = DataType::INTEGER; // XRow::getInt
+ else if ( rType == getCppuType( static_cast< const sal_Int64 * >( 0 ) ) )
+ nType = DataType::BIGINT; // XRow::getLong
+ else if ( rType == getCppuType( static_cast< const sal_Int16 * >( 0 ) ) )
+ nType = DataType::SMALLINT; // XRow::getShort
+ else if ( rType == getCppuType( static_cast< const sal_Int8 * >( 0 ) ) )
+ nType = DataType::TINYINT; // XRow::getByte
+ else if ( rType == getCppuType( static_cast< const float * >( 0 ) ) )
+ nType = DataType::REAL; // XRow::getFloat
+ else if ( rType == getCppuType( static_cast< const double * >( 0 ) ) )
+ nType = DataType::DOUBLE; // XRow::getDouble
+ else if ( rType == getCppuType( static_cast< const Sequence< sal_Int8 > * >( 0 ) ) )
+ nType = DataType::VARBINARY;// XRow::getBytes
+ else if ( rType == getCppuType( static_cast< const Date * >( 0 ) ) )
+ nType = DataType::DATE; // XRow::getDate
+ else if ( rType == getCppuType( static_cast< const Time * >( 0 ) ) )
+ nType = DataType::TIME; // XRow::getTime
+ else if ( rType == getCppuType( static_cast< const DateTime * >( 0 ) ) )
+ nType = DataType::TIMESTAMP;// XRow::getTimestamp
+ else if ( rType == getCppuType( static_cast< Reference< XInputStream > * >( 0 ) ) )
+ nType = DataType::LONGVARBINARY; // XRow::getBinaryStream
+// nType = DataType::LONGVARCHAR; // XRow::getCharacterStream
+ else if ( rType == getCppuType( static_cast< Reference< XClob > * >( 0 ) ) )
+ nType = DataType::CLOB; // XRow::getClob
+ else if ( rType == getCppuType( static_cast< Reference< XBlob > * >( 0 ) ) )
+ nType = DataType::BLOB; // XRow::getBlob
+ else if ( rType == getCppuType( static_cast< Reference< XArray > * >( 0 ) ) )
+ nType = DataType::ARRAY;// XRow::getArray
+ else if ( rType == getCppuType( static_cast< Reference< XRef > * >( 0 ) ) )
+ nType = DataType::REF;// XRow::getRef
+ else
+ nType = DataType::OBJECT;// XRow::getObject
+
+ return nType;
+}
+
+//=========================================================================
+// virtual
+OUString SAL_CALL ResultSetMetaData::getColumnTypeName( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Gets the type name used by this particular data source for the
+ values stored in column. If the type code for the type of value
+ stored in column is STRUCT, DISTINCT or JAVA_OBJECT, this method
+ returns a fully-qualified SQL type name.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return OUString();
+
+ return m_pImpl->m_aColumnData[ column - 1 ].columnTypeName;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSetMetaData::isReadOnly( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ if ( m_pImpl->m_bGlobalReadOnlyValue )
+ return m_bReadOnly;
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return sal_True;
+
+ // autoincrement==true => readonly
+ return m_pImpl->m_aColumnData[ column - 1 ].isAutoIncrement ||
+ m_pImpl->m_aColumnData[ column - 1 ].isReadOnly;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSetMetaData::isWritable( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ if ( m_pImpl->m_bGlobalReadOnlyValue )
+ return !m_bReadOnly;
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return sal_False;
+
+ return m_pImpl->m_aColumnData[ column - 1 ].isWritable;
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL ResultSetMetaData::isDefinitelyWritable( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ if ( m_pImpl->m_bGlobalReadOnlyValue )
+ return !m_bReadOnly;
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return sal_False;
+
+ return m_pImpl->m_aColumnData[ column - 1 ].isDefinitelyWritable;
+}
+
+//=========================================================================
+// virtual
+OUString SAL_CALL ResultSetMetaData::getColumnServiceName( sal_Int32 column )
+ throw( SQLException, RuntimeException )
+{
+ /*
+ Returns the fully-qualified name of the service whose instances
+ are manufactured if XResultSet::getObject is called to retrieve
+ a value from the column.
+ */
+
+ if ( ( column < 1 ) || ( column > m_aProps.getLength() ) )
+ return OUString();
+
+ return m_pImpl->m_aColumnData[ column - 1 ].columnServiceName;
+}
+
+} // namespace ucbhelper
diff --git a/ucbhelper/source/provider/simpleauthenticationrequest.cxx b/ucbhelper/source/provider/simpleauthenticationrequest.cxx
new file mode 100644
index 000000000000..8fc94cf88438
--- /dev/null
+++ b/ucbhelper/source/provider/simpleauthenticationrequest.cxx
@@ -0,0 +1,243 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+#include <com/sun/star/task/XMasterPasswordHandling.hpp>
+#include <com/sun/star/ucb/URLAuthenticationRequest.hpp>
+#include <ucbhelper/simpleauthenticationrequest.hxx>
+
+using namespace com::sun::star;
+using namespace ucbhelper;
+
+//=========================================================================
+SimpleAuthenticationRequest::SimpleAuthenticationRequest(
+ const rtl::OUString & rURL,
+ const rtl::OUString & rServerName,
+ const rtl::OUString & rRealm,
+ const rtl::OUString & rUserName,
+ const rtl::OUString & rPassword,
+ const rtl::OUString & rAccount )
+{
+ // Fill request...
+ ucb::URLAuthenticationRequest aRequest;
+// aRequest.Message = // OUString
+// aRequest.Context = // XInterface
+ aRequest.Classification = task::InteractionClassification_ERROR;
+ aRequest.ServerName = rServerName;
+// aRequest.Diagnostic = // OUString
+ aRequest.HasRealm = ( rRealm.getLength() > 0 );
+ if ( aRequest.HasRealm )
+ aRequest.Realm = rRealm;
+ aRequest.HasUserName = sal_True;
+ aRequest.UserName = rUserName;
+ aRequest.HasPassword = sal_True;
+ aRequest.Password = rPassword;
+ aRequest.HasAccount = ( rAccount.getLength() > 0 );
+ if ( aRequest.HasAccount )
+ aRequest.Account = rAccount;
+ aRequest.URL = rURL;
+
+ initialize(aRequest,
+ sal_False,
+ sal_True,
+ sal_True,
+ aRequest.HasAccount,
+ sal_True,
+ sal_False );
+}
+//=========================================================================
+SimpleAuthenticationRequest::SimpleAuthenticationRequest(
+ const rtl::OUString & rURL,
+ const rtl::OUString & rServerName,
+ const rtl::OUString & rRealm,
+ const rtl::OUString & rUserName,
+ const rtl::OUString & rPassword,
+ const rtl::OUString & rAccount,
+ sal_Bool bAllowPersistentStoring,
+ sal_Bool bAllowUseSystemCredentials )
+{
+
+ // Fill request...
+ ucb::URLAuthenticationRequest aRequest;
+// aRequest.Message = // OUString
+// aRequest.Context = // XInterface
+ aRequest.Classification = task::InteractionClassification_ERROR;
+ aRequest.ServerName = rServerName;
+// aRequest.Diagnostic = // OUString
+ aRequest.HasRealm = ( rRealm.getLength() > 0 );
+ if ( aRequest.HasRealm )
+ aRequest.Realm = rRealm;
+ aRequest.HasUserName = sal_True;
+ aRequest.UserName = rUserName;
+ aRequest.HasPassword = sal_True;
+ aRequest.Password = rPassword;
+ aRequest.HasAccount = ( rAccount.getLength() > 0 );
+ if ( aRequest.HasAccount )
+ aRequest.Account = rAccount;
+ aRequest.URL = rURL;
+
+ initialize(aRequest,
+ sal_False,
+ sal_True,
+ sal_True,
+ aRequest.HasAccount,
+ bAllowPersistentStoring,
+ bAllowUseSystemCredentials );
+}
+
+//=========================================================================
+SimpleAuthenticationRequest::SimpleAuthenticationRequest(
+ const rtl::OUString & rURL,
+ const rtl::OUString & rServerName,
+ EntityType eRealmType,
+ const rtl::OUString & rRealm,
+ EntityType eUserNameType,
+ const rtl::OUString & rUserName,
+ EntityType ePasswordType,
+ const rtl::OUString & rPassword,
+ EntityType eAccountType,
+ const rtl::OUString & rAccount )
+{
+ // Fill request...
+ ucb::URLAuthenticationRequest aRequest;
+// aRequest.Message = // OUString
+// aRequest.Context = // XInterface
+ aRequest.Classification = task::InteractionClassification_ERROR;
+ aRequest.ServerName = rServerName;
+// aRequest.Diagnostic = // OUString
+ aRequest.HasRealm = eRealmType != ENTITY_NA;
+ if ( aRequest.HasRealm )
+ aRequest.Realm = rRealm;
+ aRequest.HasUserName = eUserNameType != ENTITY_NA;
+ if ( aRequest.HasUserName )
+ aRequest.UserName = rUserName;
+ aRequest.HasPassword = ePasswordType != ENTITY_NA;
+ if ( aRequest.HasPassword )
+ aRequest.Password = rPassword;
+ aRequest.HasAccount = eAccountType != ENTITY_NA;
+ if ( aRequest.HasAccount )
+ aRequest.Account = rAccount;
+ aRequest.URL = rURL;
+
+ initialize(aRequest,
+ eRealmType == ENTITY_MODIFY,
+ eUserNameType == ENTITY_MODIFY,
+ ePasswordType == ENTITY_MODIFY,
+ eAccountType == ENTITY_MODIFY,
+ sal_True,
+ sal_False );
+}
+
+//=========================================================================
+SimpleAuthenticationRequest::SimpleAuthenticationRequest(
+ const rtl::OUString & rURL,
+ const rtl::OUString & rServerName,
+ EntityType eRealmType,
+ const rtl::OUString & rRealm,
+ EntityType eUserNameType,
+ const rtl::OUString & rUserName,
+ EntityType ePasswordType,
+ const rtl::OUString & rPassword,
+ EntityType eAccountType,
+ const rtl::OUString & rAccount,
+ sal_Bool bAllowPersistentStoring,
+ sal_Bool bAllowUseSystemCredentials )
+{
+ // Fill request...
+ ucb::URLAuthenticationRequest aRequest;
+// aRequest.Message = // OUString
+// aRequest.Context = // XInterface
+ aRequest.Classification = task::InteractionClassification_ERROR;
+ aRequest.ServerName = rServerName;
+// aRequest.Diagnostic = // OUString
+ aRequest.HasRealm = eRealmType != ENTITY_NA;
+ if ( aRequest.HasRealm )
+ aRequest.Realm = rRealm;
+ aRequest.HasUserName = eUserNameType != ENTITY_NA;
+ if ( aRequest.HasUserName )
+ aRequest.UserName = rUserName;
+ aRequest.HasPassword = ePasswordType != ENTITY_NA;
+ if ( aRequest.HasPassword )
+ aRequest.Password = rPassword;
+ aRequest.HasAccount = eAccountType != ENTITY_NA;
+ if ( aRequest.HasAccount )
+ aRequest.Account = rAccount;
+ aRequest.URL = rURL;
+
+ initialize(aRequest,
+ eRealmType == ENTITY_MODIFY,
+ eUserNameType == ENTITY_MODIFY,
+ ePasswordType == ENTITY_MODIFY,
+ eAccountType == ENTITY_MODIFY,
+ bAllowPersistentStoring,
+ bAllowUseSystemCredentials );
+}
+
+//=========================================================================
+void SimpleAuthenticationRequest::initialize(
+ const ucb::URLAuthenticationRequest & rRequest,
+ sal_Bool bCanSetRealm,
+ sal_Bool bCanSetUserName,
+ sal_Bool bCanSetPassword,
+ sal_Bool bCanSetAccount,
+ sal_Bool bAllowPersistentStoring,
+ sal_Bool bAllowUseSystemCredentials )
+{
+ setRequest( uno::makeAny( rRequest ) );
+
+ // Fill continuations...
+ uno::Sequence< ucb::RememberAuthentication > aRememberModes(
+ bAllowPersistentStoring ? 3 : 2 );
+ aRememberModes[ 0 ] = ucb::RememberAuthentication_NO;
+ aRememberModes[ 1 ] = ucb::RememberAuthentication_SESSION;
+ if (bAllowPersistentStoring)
+ aRememberModes[ 2 ] = ucb::RememberAuthentication_PERSISTENT;
+
+ m_xAuthSupplier
+ = new InteractionSupplyAuthentication(
+ this,
+ bCanSetRealm,
+ bCanSetUserName,
+ bCanSetPassword,
+ bCanSetAccount,
+ aRememberModes, // rRememberPasswordModes
+ ucb::RememberAuthentication_SESSION, // eDefaultRememberPasswordMode
+ aRememberModes, // rRememberAccountModes
+ ucb::RememberAuthentication_SESSION, // eDefaultRememberAccountMode
+ bAllowUseSystemCredentials, // bCanUseSystemCredentials,
+ false // bDefaultUseSystemCredentials
+ );
+
+ uno::Sequence<
+ uno::Reference< task::XInteractionContinuation > > aContinuations( 3 );
+ aContinuations[ 0 ] = new InteractionAbort( this );
+ aContinuations[ 1 ] = new InteractionRetry( this );
+ aContinuations[ 2 ] = m_xAuthSupplier.get();
+
+ setContinuations( aContinuations );
+}
diff --git a/ucbhelper/source/provider/simplecertificatevalidationrequest.cxx b/ucbhelper/source/provider/simplecertificatevalidationrequest.cxx
new file mode 100755
index 000000000000..8a34dc3c4e13
--- /dev/null
+++ b/ucbhelper/source/provider/simplecertificatevalidationrequest.cxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_ucbhelper.hxx"
+#include <com/sun/star/ucb/CertificateValidationRequest.hpp>
+#include <ucbhelper/simplecertificatevalidationrequest.hxx>
+
+using namespace com::sun::star;
+using namespace ucbhelper;
+
+//=========================================================================
+SimpleCertificateValidationRequest::SimpleCertificateValidationRequest( const sal_Int32 & lCertificateValidity,
+ const com::sun::star::uno::Reference<com::sun::star::security::XCertificate> pCertificate,
+ const rtl::OUString & hostname)
+{
+ // Fill request...
+ ucb::CertificateValidationRequest aRequest;
+ aRequest.CertificateValidity = lCertificateValidity;
+ aRequest.Certificate = pCertificate;
+ aRequest.HostName = hostname;
+
+ setRequest( uno::makeAny( aRequest ) );
+
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 2 );
+ aContinuations[ 0 ] = new InteractionAbort( this );
+ aContinuations[ 1 ] = new InteractionApprove( this );
+
+ setContinuations( aContinuations );
+ pCertificate.get();
+}
+
+//=========================================================================
+sal_Int32 SimpleCertificateValidationRequest::getResponse() const
+{
+ rtl::Reference< InteractionContinuation > xSelection = getSelection();
+ if ( xSelection.is() )
+ {
+ InteractionContinuation * pSelection = xSelection.get();
+
+ uno::Reference< task::XInteractionAbort > xAbort(
+ pSelection, uno::UNO_QUERY );
+ if ( xAbort.is() )
+ return 1;
+
+ uno::Reference< task::XInteractionRetry > xRetry(
+ pSelection, uno::UNO_QUERY );
+ if ( xRetry.is() )
+ return 2;
+
+ uno::Reference< task::XInteractionApprove > xApprove(
+ pSelection, uno::UNO_QUERY );
+ if ( xApprove.is() )
+ return 4;
+
+ uno::Reference< task::XInteractionDisapprove > xDisapprove(
+ pSelection, uno::UNO_QUERY );
+ if ( xDisapprove.is() )
+ return 8;
+
+ OSL_ENSURE( sal_False, "CertificateValidationRequest - Unknown continuation!" );
+ }
+ return 0;
+}
diff --git a/ucbhelper/source/provider/simpleinteractionrequest.cxx b/ucbhelper/source/provider/simpleinteractionrequest.cxx
new file mode 100644
index 000000000000..6f5fb5d4e820
--- /dev/null
+++ b/ucbhelper/source/provider/simpleinteractionrequest.cxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_ucbhelper.hxx"
+#include <ucbhelper/simpleinteractionrequest.hxx>
+
+using namespace com::sun::star;
+using namespace ucbhelper;
+
+//=========================================================================
+SimpleInteractionRequest::SimpleInteractionRequest(
+ const uno::Any & rRequest,
+ const sal_Int32 nContinuations )
+: InteractionRequest( rRequest )
+{
+ // Set continuations.
+ OSL_ENSURE( nContinuations != CONTINUATION_UNKNOWN,
+ "SimpleInteractionRequest - No continuation!" );
+
+ sal_Int32 nLength = 0;
+
+ uno::Reference< task::XInteractionContinuation > xAbort;
+ uno::Reference< task::XInteractionContinuation > xRetry;
+ uno::Reference< task::XInteractionContinuation > xApprove;
+ uno::Reference< task::XInteractionContinuation > xDisapprove;
+
+ if ( nContinuations & CONTINUATION_ABORT )
+ {
+ ++nLength;
+ xAbort = new InteractionAbort( this );
+ }
+
+ if ( nContinuations & CONTINUATION_RETRY )
+ {
+ ++nLength;
+ xRetry = new InteractionRetry( this );
+ }
+
+ if ( nContinuations & CONTINUATION_APPROVE )
+ {
+ ++nLength;
+ xApprove = new InteractionApprove( this );
+ }
+
+ if ( nContinuations & CONTINUATION_DISAPPROVE )
+ {
+ ++nLength;
+ xDisapprove = new InteractionDisapprove( this );
+ }
+
+ OSL_ENSURE( nLength > 0,
+ "SimpleInteractionRequest - No continuation!" );
+
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > >
+ aContinuations( nLength );
+
+ nLength = 0;
+
+ if ( xAbort.is() )
+ aContinuations[ nLength++ ] = xAbort;
+
+ if ( xRetry.is() )
+ aContinuations[ nLength++ ] = xRetry;
+
+ if ( xApprove.is() )
+ aContinuations[ nLength++ ] = xApprove;
+
+ if ( xDisapprove.is() )
+ aContinuations[ nLength++ ] = xDisapprove;
+
+ setContinuations( aContinuations );
+}
+
+//=========================================================================
+sal_Int32 SimpleInteractionRequest::getResponse() const
+{
+ rtl::Reference< InteractionContinuation > xSelection = getSelection();
+ if ( xSelection.is() )
+ {
+ InteractionContinuation * pSelection = xSelection.get();
+
+ uno::Reference< task::XInteractionAbort > xAbort(
+ pSelection, uno::UNO_QUERY );
+ if ( xAbort.is() )
+ return CONTINUATION_ABORT;
+
+ uno::Reference< task::XInteractionRetry > xRetry(
+ pSelection, uno::UNO_QUERY );
+ if ( xRetry.is() )
+ return CONTINUATION_RETRY;
+
+ uno::Reference< task::XInteractionApprove > xApprove(
+ pSelection, uno::UNO_QUERY );
+ if ( xApprove.is() )
+ return CONTINUATION_APPROVE;
+
+ uno::Reference< task::XInteractionDisapprove > xDisapprove(
+ pSelection, uno::UNO_QUERY );
+ if ( xDisapprove.is() )
+ return CONTINUATION_DISAPPROVE;
+
+ OSL_ENSURE( sal_False,
+ "SimpleInteractionRequest::getResponse - Unknown continuation!" );
+ }
+ return CONTINUATION_UNKNOWN;
+}
+
diff --git a/ucbhelper/source/provider/simpleioerrorrequest.cxx b/ucbhelper/source/provider/simpleioerrorrequest.cxx
new file mode 100644
index 000000000000..da6eea06cda0
--- /dev/null
+++ b/ucbhelper/source/provider/simpleioerrorrequest.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_ucbhelper.hxx"
+#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
+#include <ucbhelper/simpleioerrorrequest.hxx>
+
+using namespace com::sun::star;
+using namespace ucbhelper;
+
+//=========================================================================
+SimpleIOErrorRequest::SimpleIOErrorRequest(
+ const ucb::IOErrorCode eError,
+ const uno::Sequence< uno::Any > & rArgs,
+ const rtl::OUString & rMessage,
+ const uno::Reference< ucb::XCommandProcessor > & xContext )
+{
+ // Fill request...
+ ucb::InteractiveAugmentedIOException aRequest;
+ aRequest.Message = rMessage;
+ aRequest.Context = xContext;
+ aRequest.Classification = task::InteractionClassification_ERROR;
+ aRequest.Code = eError;
+ aRequest.Arguments = rArgs;
+
+ setRequest( uno::makeAny( aRequest ) );
+
+ // Fill continuations...
+ uno::Sequence< uno::Reference<
+ task::XInteractionContinuation > > aContinuations( 1 );
+ aContinuations[ 0 ] = new InteractionAbort( this );
+
+ setContinuations( aContinuations );
+}
+
diff --git a/ucbhelper/source/provider/simplenameclashresolverequest.cxx b/ucbhelper/source/provider/simplenameclashresolverequest.cxx
new file mode 100644
index 000000000000..3c3c69d93b3e
--- /dev/null
+++ b/ucbhelper/source/provider/simplenameclashresolverequest.cxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * 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_ucbhelper.hxx"
+#include <com/sun/star/ucb/NameClashResolveRequest.hpp>
+#include <ucbhelper/simplenameclashresolverequest.hxx>
+
+using namespace com::sun::star;
+using namespace ucbhelper;
+
+//=========================================================================
+SimpleNameClashResolveRequest::SimpleNameClashResolveRequest(
+ const rtl::OUString & rTargetFolderURL,
+ const rtl::OUString & rClashingName,
+ const rtl::OUString & rProposedNewName,
+ sal_Bool bSupportsOverwriteData )
+{
+ // Fill request...
+ ucb::NameClashResolveRequest aRequest;
+// aRequest.Message = // OUString
+// aRequest.Context = // XInterface
+ aRequest.Classification = task::InteractionClassification_QUERY;
+ aRequest.TargetFolderURL = rTargetFolderURL;
+ aRequest.ClashingName = rClashingName;
+ aRequest.ProposedNewName = rProposedNewName;
+
+ setRequest( uno::makeAny( aRequest ) );
+
+ // Fill continuations...
+ m_xNameSupplier = new InteractionSupplyName( this );
+
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > >
+ aContinuations( bSupportsOverwriteData ? 3 : 2 );
+ aContinuations[ 0 ] = new InteractionAbort( this );
+ aContinuations[ 1 ] = m_xNameSupplier.get();
+
+ if ( bSupportsOverwriteData )
+ aContinuations[ 2 ] = new InteractionReplaceExistingData( this );
+
+ setContinuations( aContinuations );
+}
+