summaryrefslogtreecommitdiff
path: root/ucbhelper/source
diff options
context:
space:
mode:
Diffstat (limited to 'ucbhelper/source')
-rw-r--r--ucbhelper/source/client/activedatasink.cxx93
-rw-r--r--ucbhelper/source/client/activedatastreamer.cxx92
-rw-r--r--ucbhelper/source/client/commandenvironment.cxx139
-rw-r--r--ucbhelper/source/client/content.cxx1972
-rw-r--r--ucbhelper/source/client/contentbroker.cxx380
-rw-r--r--ucbhelper/source/client/fileidentifierconverter.cxx107
-rw-r--r--ucbhelper/source/client/interceptedinteraction.cxx201
-rw-r--r--ucbhelper/source/client/makefile.mk60
-rw-r--r--ucbhelper/source/client/proxydecider.cxx861
-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
31 files changed, 12894 insertions, 0 deletions
diff --git a/ucbhelper/source/client/activedatasink.cxx b/ucbhelper/source/client/activedatasink.cxx
new file mode 100644
index 000000000000..029fb60e616f
--- /dev/null
+++ b/ucbhelper/source/client/activedatasink.cxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * 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 "ucbhelper/activedatasink.hxx"
+
+using namespace com::sun::star;
+
+namespace ucbhelper
+{
+
+//=========================================================================
+//=========================================================================
+//
+// ActiveDataSink Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+//=========================================================================
+//
+// XInterface methods
+//
+//=========================================================================
+
+XINTERFACE_IMPL_2( ActiveDataSink,
+ lang::XTypeProvider,
+ io::XActiveDataSink );
+
+//=========================================================================
+//
+// XTypeProvider methods
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_2( ActiveDataSink,
+ lang::XTypeProvider,
+ io::XActiveDataSink );
+
+//=========================================================================
+//
+// XActiveDataSink methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ActiveDataSink::setInputStream(
+ const uno::Reference< io::XInputStream >& aStream )
+ throw( uno::RuntimeException )
+{
+ m_xStream = aStream;
+}
+
+//=========================================================================
+// virtual
+uno::Reference< io::XInputStream > SAL_CALL ActiveDataSink::getInputStream()
+ throw( uno::RuntimeException )
+{
+ return m_xStream;
+}
+
+} // namespace ucbhelper
diff --git a/ucbhelper/source/client/activedatastreamer.cxx b/ucbhelper/source/client/activedatastreamer.cxx
new file mode 100644
index 000000000000..5f26334ab376
--- /dev/null
+++ b/ucbhelper/source/client/activedatastreamer.cxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * 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 "ucbhelper/activedatastreamer.hxx"
+
+using namespace com::sun::star;
+
+namespace ucbhelper
+{
+
+//=========================================================================
+//=========================================================================
+//
+// ActiveDataStreamer Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+//=========================================================================
+//
+// XInterface methods
+//
+//=========================================================================
+
+XINTERFACE_IMPL_2( ActiveDataStreamer,
+ lang::XTypeProvider,
+ io::XActiveDataStreamer );
+
+//=========================================================================
+//
+// XTypeProvider methods
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_2( ActiveDataStreamer,
+ lang::XTypeProvider,
+ io::XActiveDataStreamer );
+
+//=========================================================================
+//
+// XActiveDataStreamer methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ActiveDataStreamer::setStream( const uno::Reference< io::XStream >& xStream )
+ throw( uno::RuntimeException )
+{
+ m_xStream = xStream;
+}
+
+//=========================================================================
+// virtual
+uno::Reference< io::XStream > SAL_CALL ActiveDataStreamer::getStream()
+ throw( uno::RuntimeException )
+{
+ return m_xStream;
+}
+
+} // namespace ucbhelper
diff --git a/ucbhelper/source/client/commandenvironment.cxx b/ucbhelper/source/client/commandenvironment.cxx
new file mode 100644
index 000000000000..75a137faeb5b
--- /dev/null
+++ b/ucbhelper/source/client/commandenvironment.cxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// 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 <ucbhelper/commandenvironment.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 CommandEnvironment_Impl.
+//
+//=========================================================================
+//=========================================================================
+
+struct CommandEnvironment_Impl
+{
+ Reference< XInteractionHandler > m_xInteractionHandler;
+ Reference< XProgressHandler > m_xProgressHandler;
+
+ CommandEnvironment_Impl(
+ const Reference< XInteractionHandler >& rxInteractionHandler,
+ const Reference< XProgressHandler >& rxProgressHandler )
+ : m_xInteractionHandler( rxInteractionHandler ),
+ m_xProgressHandler( rxProgressHandler ) {}
+};
+
+//=========================================================================
+//=========================================================================
+//
+// CommandEnvironment Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+CommandEnvironment::CommandEnvironment(
+ const Reference< XInteractionHandler >& rxInteractionHandler,
+ const Reference< XProgressHandler >& rxProgressHandler )
+{
+ m_pImpl = new CommandEnvironment_Impl( rxInteractionHandler,
+ rxProgressHandler );
+}
+
+//=========================================================================
+// virtual
+CommandEnvironment::~CommandEnvironment()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+//
+// XInterface methods
+//
+//=========================================================================
+
+XINTERFACE_IMPL_2( CommandEnvironment,
+ XTypeProvider,
+ XCommandEnvironment );
+
+//=========================================================================
+//
+// XTypeProvider methods
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_2( CommandEnvironment,
+ XTypeProvider,
+ XCommandEnvironment );
+
+//=========================================================================
+//
+// XCommandEnvironemnt methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XInteractionHandler > SAL_CALL
+CommandEnvironment::getInteractionHandler()
+ throw ( RuntimeException )
+{
+ return m_pImpl->m_xInteractionHandler;
+}
+
+//=========================================================================
+// virtual
+Reference< XProgressHandler > SAL_CALL
+CommandEnvironment::getProgressHandler()
+ throw ( RuntimeException )
+{
+ return m_pImpl->m_xProgressHandler;
+}
+
+} /* namespace ucbhelper */
+
diff --git a/ucbhelper/source/client/content.cxx b/ucbhelper/source/client/content.cxx
new file mode 100644
index 000000000000..4debb1728bfe
--- /dev/null
+++ b/ucbhelper/source/client/content.cxx
@@ -0,0 +1,1972 @@
+/*************************************************************************
+ *
+ * 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 <osl/mutex.hxx>
+#include <salhelper/simplereferenceobject.hxx>
+#include <cppuhelper/weak.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/ucb/ContentCreationError.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <com/sun/star/ucb/XCommandInfo.hpp>
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#include <com/sun/star/ucb/Command.hpp>
+#include <com/sun/star/ucb/CommandInfo.hpp>
+#include <com/sun/star/ucb/ContentAction.hpp>
+#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
+#include <com/sun/star/ucb/InsertCommandArgument.hpp>
+#include <com/sun/star/ucb/GlobalTransferCommandArgument.hpp>
+#include <com/sun/star/ucb/NameClash.hpp>
+#include <com/sun/star/ucb/OpenMode.hpp>
+#include <com/sun/star/ucb/XContentCreator.hpp>
+#include <com/sun/star/ucb/XContentEventListener.hpp>
+#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/ucb/XContentProviderManager.hpp>
+#include <com/sun/star/ucb/XDynamicResultSet.hpp>
+#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/beans/UnknownPropertyException.hpp>
+#include <ucbhelper/macros.hxx>
+#include <ucbhelper/content.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <ucbhelper/activedatasink.hxx>
+#include <ucbhelper/activedatastreamer.hxx>
+#include <ucbhelper/interactionrequest.hxx>
+#include <ucbhelper/cancelcommandexecution.hxx>
+
+using namespace com::sun::star::container;
+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::task;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+
+namespace ucbhelper
+{
+
+class EmptyInputStream : public ::cppu::WeakImplHelper1< XInputStream >
+{
+public:
+ virtual sal_Int32 SAL_CALL readBytes(
+ Sequence< sal_Int8 > & data, sal_Int32 nBytesToRead )
+ throw (IOException, RuntimeException);
+ virtual sal_Int32 SAL_CALL readSomeBytes(
+ Sequence< sal_Int8 > & data, sal_Int32 nMaxBytesToRead )
+ throw (IOException, RuntimeException);
+ virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
+ throw (IOException, RuntimeException);
+ virtual sal_Int32 SAL_CALL available()
+ throw (IOException, RuntimeException);
+ virtual void SAL_CALL closeInput()
+ throw (IOException, RuntimeException);
+};
+
+sal_Int32 EmptyInputStream::readBytes(
+ Sequence< sal_Int8 > & data, sal_Int32 )
+ throw (IOException, RuntimeException)
+{
+ data.realloc( 0 );
+ return 0;
+}
+
+sal_Int32 EmptyInputStream::readSomeBytes(
+ Sequence< sal_Int8 > & data, sal_Int32 )
+ throw (IOException, RuntimeException)
+{
+ data.realloc( 0 );
+ return 0;
+}
+
+void EmptyInputStream::skipBytes( sal_Int32 )
+ throw (IOException, RuntimeException)
+{
+}
+
+sal_Int32 EmptyInputStream::available()
+ throw (IOException, RuntimeException)
+{
+ return 0;
+}
+
+void EmptyInputStream::closeInput()
+ throw (IOException, RuntimeException)
+{
+}
+
+
+//=========================================================================
+//=========================================================================
+//
+// class ContentEventListener_Impl.
+//
+//=========================================================================
+//=========================================================================
+
+class ContentEventListener_Impl : public cppu::OWeakObject,
+ public XContentEventListener
+{
+ Content_Impl& m_rContent;
+
+public:
+ ContentEventListener_Impl( Content_Impl& rContent )
+ : m_rContent( rContent ) {}
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XContentEventListener
+ virtual void SAL_CALL contentEvent( const ContentEvent& evt )
+ throw( RuntimeException );
+
+ // XEventListener ( base of XContentEventListener )
+ virtual void SAL_CALL disposing( const EventObject& Source )
+ throw( RuntimeException );
+};
+
+//=========================================================================
+//=========================================================================
+//
+// class Content_Impl.
+//
+//=========================================================================
+//=========================================================================
+
+class Content_Impl : public salhelper::SimpleReferenceObject
+{
+friend class ContentEventListener_Impl;
+
+ mutable rtl::OUString m_aURL;
+ Reference< XMultiServiceFactory > m_xSMgr;
+ Reference< XContent > m_xContent;
+ Reference< XCommandProcessor > m_xCommandProcessor;
+ Reference< XCommandEnvironment > m_xEnv;
+ Reference< XContentEventListener > m_xContentEventListener;
+ mutable osl::Mutex m_aMutex;
+ sal_Int32 m_nCommandId;
+
+private:
+ void reinit( const Reference< XContent >& xContent );
+ void disposing(const EventObject& Source);
+
+public:
+ Content_Impl() : m_nCommandId( 0 ) {};
+ Content_Impl( const Reference< XMultiServiceFactory >& rSMgr,
+ const Reference< XContent >& rContent,
+ const Reference< XCommandEnvironment >& rEnv );
+
+ virtual ~Content_Impl();
+
+ const rtl::OUString& getURL() const;
+ Reference< XContent > getContent();
+ Reference< XCommandProcessor > getCommandProcessor();
+ sal_Int32 getCommandId();
+ Reference< XMultiServiceFactory > getServiceManager() { return m_xSMgr; }
+
+ Any executeCommand( const Command& rCommand );
+ void abortCommand();
+
+ inline const Reference< XCommandEnvironment >& getEnvironment() const;
+ inline void setEnvironment(
+ const Reference< XCommandEnvironment >& xNewEnv );
+
+ void inserted();
+};
+
+//=========================================================================
+// Helpers.
+//=========================================================================
+
+static void ensureContentProviderForURL( const ContentBroker & rBroker,
+ const rtl::OUString & rURL )
+ throw ( ContentCreationException, RuntimeException )
+{
+ Reference< XContentProviderManager > xMgr
+ = rBroker.getContentProviderManagerInterface();
+ if ( !xMgr.is() )
+ {
+ throw RuntimeException(
+ rtl::OUString::createFromAscii(
+ "UCB does not implement mandatory interface "
+ "XContentProviderManager!" ),
+ Reference< XInterface >() );
+ }
+ else
+ {
+ Reference< XContentProvider > xProv
+ = xMgr->queryContentProvider( rURL );
+ if ( !xProv.is() )
+ {
+ throw ContentCreationException(
+ rtl::OUString::createFromAscii(
+ "No Content Provider available for given URL!" ),
+ Reference< XInterface >(),
+ ContentCreationError_NO_CONTENT_PROVIDER );
+ }
+ }
+}
+
+//=========================================================================
+static ContentBroker* getContentBroker( bool bThrow )
+ throw ( ContentCreationException, RuntimeException )
+{
+ ContentBroker* pBroker = ContentBroker::get();
+
+ if ( !pBroker )
+ {
+ if ( bThrow )
+ throw RuntimeException(
+ rtl::OUString::createFromAscii( "No Content Broker!" ),
+ Reference< XInterface >() );
+ }
+ else
+ {
+#if OSL_DEBUG_LEVEL > 1
+ Reference< XContentProviderManager > xMgr
+ = pBroker->getContentProviderManagerInterface();
+ if ( !xMgr.is() )
+ {
+ if ( bThrow )
+ throw RuntimeException(
+ rtl::OUString::createFromAscii(
+ "UCB does not implement mandatory interface "
+ "XContentProviderManager!" ),
+ Reference< XInterface >() );
+ }
+ else
+ {
+ OSL_ENSURE( xMgr->queryContentProviders().getLength(),
+ "Content Broker not configured (no providers)!" );
+ }
+#endif
+ }
+
+ return pBroker;
+}
+
+//=========================================================================
+static Reference< XContentIdentifier > getContentIdentifier(
+ const ContentBroker & rBroker,
+ const rtl::OUString & rURL,
+ bool bThrow )
+ throw ( ContentCreationException, RuntimeException )
+{
+ Reference< XContentIdentifierFactory > xIdFac
+ = rBroker.getContentIdentifierFactoryInterface();
+ if ( xIdFac.is() )
+ {
+ Reference< XContentIdentifier > xId
+ = xIdFac->createContentIdentifier( rURL );
+
+ if ( xId.is() )
+ return xId;
+
+ if ( bThrow )
+ {
+ ensureContentProviderForURL( rBroker, rURL );
+
+ throw ContentCreationException(
+ rtl::OUString::createFromAscii(
+ "Unable to create Content Identifier!" ),
+ Reference< XInterface >(),
+ ContentCreationError_IDENTIFIER_CREATION_FAILED );
+ }
+ }
+ else
+ {
+ if ( bThrow )
+ throw RuntimeException(
+ rtl::OUString::createFromAscii(
+ "UCB does not implement mandatory interface "
+ "XContentIdentifierFactory!" ),
+ Reference< XInterface >() );
+ }
+
+ return Reference< XContentIdentifier >();
+}
+
+//=========================================================================
+static Reference< XContent > getContent(
+ const ContentBroker & rBroker,
+ const Reference< XContentIdentifier > & xId,
+ bool bThrow )
+ throw ( ContentCreationException, RuntimeException )
+{
+ Reference< XContentProvider > xProvider
+ = rBroker.getContentProviderInterface();
+ if ( xProvider.is() )
+ {
+ Reference< XContent > xContent;
+ rtl::OUString msg;
+ try
+ {
+ xContent = xProvider->queryContent( xId );
+ }
+ catch ( IllegalIdentifierException const & e )
+ {
+ msg = e.Message;
+ // handled below.
+ }
+
+ if ( xContent.is() )
+ return xContent;
+
+ if ( bThrow )
+ {
+ ensureContentProviderForURL( rBroker, xId->getContentIdentifier() );
+
+ throw ContentCreationException(
+ rtl::OUString::createFromAscii(
+ "Unable to create Content! " ) + msg,
+ Reference< XInterface >(),
+ ContentCreationError_CONTENT_CREATION_FAILED );
+ }
+ }
+ else
+ {
+ if ( bThrow )
+ throw RuntimeException(
+ rtl::OUString::createFromAscii(
+ "UCB does not implement mandatory interface "
+ "XContentProvider!" ),
+ Reference< XInterface >() );
+ }
+
+ return Reference< XContent >();
+}
+
+//=========================================================================
+//=========================================================================
+//
+// Content Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+Content::Content()
+: m_xImpl( new Content_Impl )
+{
+}
+
+//=========================================================================
+Content::Content( const rtl::OUString& rURL,
+ const Reference< XCommandEnvironment >& rEnv )
+ throw ( ContentCreationException, RuntimeException )
+{
+ ContentBroker* pBroker = getContentBroker( true );
+
+ Reference< XContentIdentifier > xId
+ = getContentIdentifier( *pBroker, rURL, true );
+
+ Reference< XContent > xContent = getContent( *pBroker, xId, true );
+
+ m_xImpl = new Content_Impl( pBroker->getServiceManager(), xContent, rEnv );
+}
+
+//=========================================================================
+Content::Content( const Reference< XContentIdentifier >& rId,
+ const Reference< XCommandEnvironment >& rEnv )
+ throw ( ContentCreationException, RuntimeException )
+{
+ ContentBroker* pBroker = getContentBroker( true );
+
+ Reference< XContent > xContent = getContent( *pBroker, rId, true );
+
+ m_xImpl = new Content_Impl( pBroker->getServiceManager(), xContent, rEnv );
+}
+
+//=========================================================================
+Content::Content( const Reference< XContent >& rContent,
+ const Reference< XCommandEnvironment >& rEnv )
+ throw ( ContentCreationException, RuntimeException )
+{
+ ContentBroker* pBroker = getContentBroker( true );
+
+ m_xImpl = new Content_Impl( pBroker->getServiceManager(), rContent, rEnv );
+}
+
+//=========================================================================
+Content::Content( const Content& rOther )
+{
+ m_xImpl = rOther.m_xImpl;
+}
+
+//=========================================================================
+// static
+sal_Bool Content::create( const rtl::OUString& rURL,
+ const Reference< XCommandEnvironment >& rEnv,
+ Content& rContent )
+{
+ ContentBroker* pBroker = getContentBroker( false );
+ if ( !pBroker )
+ return sal_False;
+
+ Reference< XContentIdentifier > xId
+ = getContentIdentifier( *pBroker, rURL, false );
+ if ( !xId.is() )
+ return sal_False;
+
+ Reference< XContent > xContent = getContent( *pBroker, xId, false );
+ if ( !xContent.is() )
+ return sal_False;
+
+ rContent.m_xImpl
+ = new Content_Impl( pBroker->getServiceManager(), xContent, rEnv );
+
+ return sal_True;
+}
+
+//=========================================================================
+// static
+sal_Bool Content::create( const Reference< XContentIdentifier >& rId,
+ const Reference< XCommandEnvironment >& rEnv,
+ Content& rContent )
+{
+ ContentBroker* pBroker = getContentBroker( false );
+ if ( !pBroker )
+ return sal_False;
+
+ Reference< XContent > xContent = getContent( *pBroker, rId, false );
+ if ( !xContent.is() )
+ return sal_False;
+
+ rContent.m_xImpl
+ = new Content_Impl( pBroker->getServiceManager(), xContent, rEnv );
+
+ return sal_True;
+}
+
+//=========================================================================
+// static
+sal_Bool Content::create( const Reference< XContent >& xContent,
+ const Reference< XCommandEnvironment >& rEnv,
+ Content& rContent )
+{
+ ContentBroker* pBroker = getContentBroker( false );
+ if ( !pBroker )
+ return sal_False;
+
+ rContent.m_xImpl
+ = new Content_Impl( pBroker->getServiceManager(), xContent, rEnv );
+
+ return sal_True;
+}
+
+//=========================================================================
+Content::~Content()
+{
+}
+
+//=========================================================================
+Content& Content::operator=( const Content& rOther )
+{
+ m_xImpl = rOther.m_xImpl;
+ return *this;
+}
+
+//=========================================================================
+Reference< XContent > Content::get() const
+{
+ return m_xImpl->getContent();
+}
+
+//=========================================================================
+const rtl::OUString& Content::getURL() const
+{
+ return m_xImpl->getURL();
+}
+
+//=========================================================================
+const Reference< XCommandEnvironment >& Content::getCommandEnvironment() const
+{
+ return m_xImpl->getEnvironment();
+}
+
+//=========================================================================
+void Content::setCommandEnvironment(
+ const Reference< XCommandEnvironment >& xNewEnv )
+{
+ m_xImpl->setEnvironment( xNewEnv );
+}
+
+//=========================================================================
+Reference< XCommandInfo > Content::getCommands()
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "getCommandInfo" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument = Any();
+
+ Any aResult = m_xImpl->executeCommand( aCommand );
+
+ Reference< XCommandInfo > xInfo;
+ aResult >>= xInfo;
+ return xInfo;
+}
+
+//=========================================================================
+Reference< XPropertySetInfo > Content::getProperties()
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "getPropertySetInfo" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument = Any();
+
+ Any aResult = m_xImpl->executeCommand( aCommand );
+
+ Reference< XPropertySetInfo > xInfo;
+ aResult >>= xInfo;
+ return xInfo;
+}
+
+//=========================================================================
+Any Content::getPropertyValue( const rtl::OUString& rPropertyName )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Sequence< rtl::OUString > aNames( 1 );
+ aNames.getArray()[ 0 ] = rPropertyName;
+
+ Sequence< Any > aRet = getPropertyValues( aNames );
+ return aRet.getConstArray()[ 0 ];
+}
+
+//=========================================================================
+Any Content::getPropertyValue( sal_Int32 nPropertyHandle )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Sequence< sal_Int32 > aHandles( 1 );
+ aHandles.getArray()[ 0 ] = nPropertyHandle;
+
+ Sequence< Any > aRet = getPropertyValues( aHandles );
+ return aRet.getConstArray()[ 0 ];
+}
+
+//=========================================================================
+Any Content::setPropertyValue( const rtl::OUString& rName,
+ const Any& rValue )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Sequence< rtl::OUString > aNames( 1 );
+ aNames.getArray()[ 0 ] = rName;
+
+ Sequence< Any > aValues( 1 );
+ aValues.getArray()[ 0 ] = rValue;
+
+ Sequence< Any > aErrors = setPropertyValues( aNames, aValues );
+ return aErrors.getConstArray()[ 0 ];
+}
+
+//=========================================================================
+Any Content::setPropertyValue( const sal_Int32 nPropertyHandle,
+ const Any& rValue )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Sequence< sal_Int32 > aHandles( 1 );
+ aHandles.getArray()[ 0 ] = nPropertyHandle;
+
+ Sequence< Any > aValues( 1 );
+ aValues.getArray()[ 0 ] = rValue;
+
+ Sequence< Any > aErrors = setPropertyValues( aHandles, aValues );
+ return aErrors.getConstArray()[ 0 ];
+}
+
+//=========================================================================
+Sequence< Any > Content::getPropertyValues(
+ const Sequence< rtl::OUString >& rPropertyNames )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XRow > xRow = getPropertyValuesInterface( rPropertyNames );
+
+ sal_Int32 nCount = rPropertyNames.getLength();
+ Sequence< Any > aValues( nCount );
+
+ if ( xRow.is() )
+ {
+ Any* pValues = aValues.getArray();
+
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ pValues[ n ] = xRow->getObject( n + 1, Reference< XNameAccess >() );
+ }
+
+ return aValues;
+}
+
+//=========================================================================
+Sequence< Any > Content::getPropertyValues(
+ const Sequence< sal_Int32 >& nPropertyHandles )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XRow > xRow = getPropertyValuesInterface( nPropertyHandles );
+
+ sal_Int32 nCount = nPropertyHandles.getLength();
+ Sequence< Any > aValues( nCount );
+
+ if ( xRow.is() )
+ {
+ Any* pValues = aValues.getArray();
+
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ pValues[ n ] = xRow->getObject( n + 1, Reference< XNameAccess >() );
+ }
+
+ return aValues;
+}
+
+//=========================================================================
+Reference< XRow > Content::getPropertyValuesInterface(
+ const Sequence< rtl::OUString >& rPropertyNames )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ sal_Int32 nCount = rPropertyNames.getLength();
+ Sequence< Property > aProps( nCount );
+ Property* pProps = aProps.getArray();
+
+ const rtl::OUString* pNames = rPropertyNames.getConstArray();
+
+ for ( sal_Int32 n = 0; n< nCount; ++n )
+ {
+ Property& rProp = pProps[ n ];
+
+ rProp.Name = pNames[ n ];
+ rProp.Handle = -1; // n/a
+// rProp.Type =
+// rProp.Attributes = ;
+ }
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "getPropertyValues" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aProps;
+
+ Any aResult = m_xImpl->executeCommand( aCommand );
+
+ Reference< XRow > xRow;
+ aResult >>= xRow;
+ return xRow;
+}
+
+//=========================================================================
+Reference< XRow > Content::getPropertyValuesInterface(
+ const Sequence< sal_Int32 >& nPropertyHandles )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ sal_Int32 nCount = nPropertyHandles.getLength();
+ Sequence< Property > aProps( nCount );
+ Property* pProps = aProps.getArray();
+
+ const sal_Int32* pHandles = nPropertyHandles.getConstArray();
+
+ for ( sal_Int32 n = 0; n< nCount; ++n )
+ {
+ Property& rProp = pProps[ n ];
+
+ rProp.Name = rtl::OUString(); // n/a
+ rProp.Handle = pHandles[ n ];
+// rProp.Type =
+// rProp.Attributes = ;
+ }
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "getPropertyValues" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aProps;
+
+ Any aResult = m_xImpl->executeCommand( aCommand );
+
+ Reference< XRow > xRow;
+ aResult >>= xRow;
+ return xRow;
+}
+
+//=========================================================================
+Sequence< Any > Content::setPropertyValues(
+ const Sequence< rtl::OUString >& rPropertyNames,
+ const Sequence< Any >& rValues )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ if ( rPropertyNames.getLength() != rValues.getLength() )
+ {
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Length of property names sequence and value "
+ "sequence are unequal!" ),
+ get(),
+ -1 ) ),
+ m_xImpl->getEnvironment() );
+ // Unreachable
+ }
+
+ sal_Int32 nCount = rValues.getLength();
+ Sequence< PropertyValue > aProps( nCount );
+ PropertyValue* pProps = aProps.getArray();
+
+ const rtl::OUString* pNames = rPropertyNames.getConstArray();
+ const Any* pValues = rValues.getConstArray();
+
+ for ( sal_Int32 n = 0; n< nCount; ++n )
+ {
+ PropertyValue& rProp = pProps[ n ];
+
+ rProp.Name = pNames[ n ];
+ rProp.Handle = -1; // n/a
+ rProp.Value = pValues[ n ];
+// rProp.State = ;
+ }
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "setPropertyValues" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aProps;
+
+ Any aResult = m_xImpl->executeCommand( aCommand );
+
+ Sequence< Any > aErrors;
+ aResult >>= aErrors;
+ return aErrors;
+}
+
+//=========================================================================
+Sequence< Any > Content::setPropertyValues(
+ const Sequence< sal_Int32 >& nPropertyHandles,
+ const Sequence< Any >& rValues )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ if ( nPropertyHandles.getLength() != rValues.getLength() )
+ {
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Length of property handles sequence and value "
+ "sequence are unequal!" ),
+ get(),
+ -1 ) ),
+ m_xImpl->getEnvironment() );
+ // Unreachable
+ }
+
+ sal_Int32 nCount = rValues.getLength();
+ Sequence< PropertyValue > aProps( nCount );
+ PropertyValue* pProps = aProps.getArray();
+
+ const sal_Int32* pHandles = nPropertyHandles.getConstArray();
+ const Any* pValues = rValues.getConstArray();
+
+ for ( sal_Int32 n = 0; n< nCount; ++n )
+ {
+ PropertyValue& rProp = pProps[ n ];
+
+ rProp.Name = rtl::OUString(); // n/a
+ rProp.Handle = pHandles[ n ];
+ rProp.Value = pValues[ n ];
+// rProp.State = ;
+ }
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "setPropertyValues" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aProps;
+
+ Any aResult = m_xImpl->executeCommand( aCommand );
+
+ Sequence< Any > aErrors;
+ aResult >>= aErrors;
+ return aErrors;
+}
+
+//=========================================================================
+Any Content::executeCommand( const rtl::OUString& rCommandName,
+ const Any& rCommandArgument )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Command aCommand;
+ aCommand.Name = rCommandName;
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument = rCommandArgument;
+
+ return m_xImpl->executeCommand( aCommand );
+}
+
+//=========================================================================
+Any Content::executeCommand( sal_Int32 nCommandHandle,
+ const Any& rCommandArgument )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Command aCommand;
+ aCommand.Name = rtl::OUString(); // n/a
+ aCommand.Handle = nCommandHandle;
+ aCommand.Argument = rCommandArgument;
+
+ return m_xImpl->executeCommand( aCommand );
+}
+
+//=========================================================================
+void Content::abortCommand()
+{
+ m_xImpl->abortCommand();
+}
+
+//=========================================================================
+Any Content::createCursorAny( const Sequence< rtl::OUString >& rPropertyNames,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ sal_Int32 nCount = rPropertyNames.getLength();
+ Sequence< Property > aProps( nCount );
+ Property* pProps = aProps.getArray();
+ const rtl::OUString* pNames = rPropertyNames.getConstArray();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ Property& rProp = pProps[ n ];
+ rProp.Name = pNames[ n ];
+ rProp.Handle = -1; // n/a
+ }
+
+ OpenCommandArgument2 aArg;
+ aArg.Mode = ( eMode == INCLUDE_FOLDERS_ONLY )
+ ? OpenMode::FOLDERS
+ : ( eMode == INCLUDE_DOCUMENTS_ONLY )
+ ? OpenMode::DOCUMENTS : OpenMode::ALL;
+ aArg.Priority = 0; // unused
+ aArg.Sink = Reference< XInterface >(); // unused
+ aArg.Properties = aProps;
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "open" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aArg;
+
+ return m_xImpl->executeCommand( aCommand );
+}
+
+//=========================================================================
+Any Content::createCursorAny( const Sequence< sal_Int32 >& rPropertyHandles,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ sal_Int32 nCount = rPropertyHandles.getLength();
+ Sequence< Property > aProps( nCount );
+ Property* pProps = aProps.getArray();
+ const sal_Int32* pHandles = rPropertyHandles.getConstArray();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ Property& rProp = pProps[ n ];
+ rProp.Name = rtl::OUString(); // n/a
+ rProp.Handle = pHandles[ n ];
+ }
+
+ OpenCommandArgument2 aArg;
+ aArg.Mode = ( eMode == INCLUDE_FOLDERS_ONLY )
+ ? OpenMode::FOLDERS
+ : ( eMode == INCLUDE_DOCUMENTS_ONLY )
+ ? OpenMode::DOCUMENTS : OpenMode::ALL;
+ aArg.Priority = 0; // unused
+ aArg.Sink = Reference< XInterface >(); // unused
+ aArg.Properties = aProps;
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "open" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aArg;
+
+ return m_xImpl->executeCommand( aCommand );
+}
+
+//=========================================================================
+Reference< XResultSet > Content::createCursor(
+ const Sequence< rtl::OUString >& rPropertyNames,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Any aCursorAny = createCursorAny( rPropertyNames, eMode );
+
+ Reference< XDynamicResultSet > xDynSet;
+ Reference< XResultSet > aResult;
+
+ aCursorAny >>= xDynSet;
+ if ( xDynSet.is() )
+ aResult = xDynSet->getStaticResultSet();
+
+ OSL_ENSURE( aResult.is(), "Content::createCursor - no cursor!" );
+
+ if ( !aResult.is() )
+ {
+ // Former, the open command directly returned a XResultSet.
+ aCursorAny >>= aResult;
+
+ OSL_ENSURE( !aResult.is(),
+ "Content::createCursor - open-Command must "
+ "return a Reference< XDynnamicResultSet >!" );
+ }
+
+ return aResult;
+}
+
+//=========================================================================
+Reference< XResultSet > Content::createCursor(
+ const Sequence< sal_Int32 >& rPropertyHandles,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Any aCursorAny = createCursorAny( rPropertyHandles, eMode );
+
+ Reference< XDynamicResultSet > xDynSet;
+ Reference< XResultSet > aResult;
+
+ aCursorAny >>= xDynSet;
+ if ( xDynSet.is() )
+ aResult = xDynSet->getStaticResultSet();
+
+ OSL_ENSURE( aResult.is(), "Content::createCursor - no cursor!" );
+
+ if ( !aResult.is() )
+ {
+ // Former, the open command directly returned a XResultSet.
+ aCursorAny >>= aResult;
+
+ OSL_ENSURE( !aResult.is(),
+ "Content::createCursor - open-Command must "
+ "return a Reference< XDynnamicResultSet >!" );
+ }
+
+ return aResult;
+}
+
+//=========================================================================
+Reference< XDynamicResultSet > Content::createDynamicCursor(
+ const Sequence< rtl::OUString >& rPropertyNames,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XDynamicResultSet > aResult;
+ createCursorAny( rPropertyNames, eMode ) >>= aResult;
+
+ OSL_ENSURE( aResult.is(), "Content::createDynamicCursor - no cursor!" );
+
+ return aResult;
+}
+
+//=========================================================================
+Reference< XDynamicResultSet > Content::createDynamicCursor(
+ const Sequence< sal_Int32 >& rPropertyHandles,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XDynamicResultSet > aResult;
+ createCursorAny( rPropertyHandles, eMode ) >>= aResult;
+
+ OSL_ENSURE( aResult.is(), "Content::createDynamicCursor - no cursor!" );
+
+ return aResult;
+}
+
+//=========================================================================
+Reference< XDynamicResultSet > Content::createSortedDynamicCursor(
+ const Sequence< rtl::OUString >& rPropertyNames,
+ const Sequence< NumberedSortingInfo >& rSortInfo,
+ Reference< XAnyCompareFactory > rAnyCompareFactory,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XDynamicResultSet > aResult;
+ Reference< XDynamicResultSet > aOrigCursor = createDynamicCursor( rPropertyNames, eMode );
+
+ if( aOrigCursor.is() )
+ {
+ Reference< XMultiServiceFactory > aServiceManager = m_xImpl->getServiceManager();
+
+ if( aServiceManager.is() )
+ {
+ Reference< XSortedDynamicResultSetFactory > aSortFactory( aServiceManager->createInstance(
+ rtl::OUString::createFromAscii( "com.sun.star.ucb.SortedDynamicResultSetFactory" )),
+ UNO_QUERY );
+
+ aResult = aSortFactory->createSortedDynamicResultSet( aOrigCursor,
+ rSortInfo,
+ rAnyCompareFactory );
+ }
+
+ OSL_ENSURE( aResult.is(), "Content::createSortedDynamicCursor - no sorted cursor!\n" );
+
+ if( !aResult.is() )
+ aResult = aOrigCursor;
+ }
+
+ return aResult;
+}
+
+//=========================================================================
+Reference< XDynamicResultSet > Content::createSortedDynamicCursor(
+ const Sequence< sal_Int32 >& rPropertyHandles,
+ const Sequence< NumberedSortingInfo >& rSortInfo,
+ Reference< XAnyCompareFactory > rAnyCompareFactory,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XDynamicResultSet > aResult;
+ Reference< XDynamicResultSet > aOrigCursor = createDynamicCursor( rPropertyHandles, eMode );
+
+ if( aOrigCursor.is() )
+ {
+ Reference< XMultiServiceFactory > aServiceManager = m_xImpl->getServiceManager();
+
+ if( aServiceManager.is() )
+ {
+ Reference< XSortedDynamicResultSetFactory > aSortFactory( aServiceManager->createInstance(
+ rtl::OUString::createFromAscii( "com.sun.star.ucb.SortedDynamicResultSetFactory" )),
+ UNO_QUERY );
+
+ aResult = aSortFactory->createSortedDynamicResultSet( aOrigCursor,
+ rSortInfo,
+ rAnyCompareFactory );
+ }
+
+ OSL_ENSURE( aResult.is(), "Content::createSortedDynamicCursor - no sorted cursor!\n" );
+
+ if( !aResult.is() )
+ aResult = aOrigCursor;
+ }
+
+ return aResult;
+}
+
+//=========================================================================
+Reference< XResultSet > Content::createSortedCursor(
+ const Sequence< rtl::OUString >& rPropertyNames,
+ const Sequence< NumberedSortingInfo >& rSortInfo,
+ Reference< XAnyCompareFactory > rAnyCompareFactory,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XResultSet > aResult;
+ Reference< XDynamicResultSet > aDynSet;
+
+ Any aCursorAny = createCursorAny( rPropertyNames, eMode );
+
+ aCursorAny >>= aDynSet;
+
+ if( aDynSet.is() )
+ {
+ Reference< XDynamicResultSet > aDynResult;
+ Reference< XMultiServiceFactory > aServiceManager = m_xImpl->getServiceManager();
+
+ if( aServiceManager.is() )
+ {
+ Reference< XSortedDynamicResultSetFactory > aSortFactory( aServiceManager->createInstance(
+ rtl::OUString::createFromAscii( "com.sun.star.ucb.SortedDynamicResultSetFactory" )),
+ UNO_QUERY );
+
+ aDynResult = aSortFactory->createSortedDynamicResultSet( aDynSet,
+ rSortInfo,
+ rAnyCompareFactory );
+ }
+
+ OSL_ENSURE( aDynResult.is(), "Content::createSortedCursor - no sorted cursor!\n" );
+
+ if( aDynResult.is() )
+ aResult = aDynResult->getStaticResultSet();
+ else
+ aResult = aDynSet->getStaticResultSet();
+ }
+
+ OSL_ENSURE( aResult.is(), "Content::createSortedCursor - no cursor!" );
+
+ if ( !aResult.is() )
+ {
+ // Former, the open command directly returned a XResultSet.
+ aCursorAny >>= aResult;
+
+ OSL_ENSURE( !aResult.is(),
+ "Content::createCursor - open-Command must "
+ "return a Reference< XDynnamicResultSet >!" );
+ }
+
+ return aResult;
+}
+
+//=========================================================================
+Reference< XResultSet > Content::createSortedCursor(
+ const Sequence< sal_Int32 >& rPropertyHandles,
+ const Sequence< NumberedSortingInfo >& rSortInfo,
+ Reference< XAnyCompareFactory > rAnyCompareFactory,
+ ResultSetInclude eMode )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ Reference< XResultSet > aResult;
+ Reference< XDynamicResultSet > aDynSet;
+
+ Any aCursorAny = createCursorAny( rPropertyHandles, eMode );
+
+ aCursorAny >>= aDynSet;
+
+ if( aDynSet.is() )
+ {
+ Reference< XDynamicResultSet > aDynResult;
+ Reference< XMultiServiceFactory > aServiceManager = m_xImpl->getServiceManager();
+
+ if( aServiceManager.is() )
+ {
+ Reference< XSortedDynamicResultSetFactory > aSortFactory( aServiceManager->createInstance(
+ rtl::OUString::createFromAscii( "com.sun.star.ucb.SortedDynamicResultSetFactory" )),
+ UNO_QUERY );
+
+ aDynResult = aSortFactory->createSortedDynamicResultSet( aDynSet,
+ rSortInfo,
+ rAnyCompareFactory );
+ }
+
+ OSL_ENSURE( aDynResult.is(), "Content::createSortedCursor - no sorted cursor!\n" );
+
+ if( aDynResult.is() )
+ aResult = aDynResult->getStaticResultSet();
+ else
+ aResult = aDynSet->getStaticResultSet();
+ }
+
+ OSL_ENSURE( aResult.is(), "Content::createSortedCursor - no cursor!" );
+
+ if ( !aResult.is() )
+ {
+ // Former, the open command directly returned a XResultSet.
+ aCursorAny >>= aResult;
+
+ OSL_ENSURE( !aResult.is(),
+ "Content::createCursor - open-Command must "
+ "return a Reference< XDynnamicResultSet >!" );
+ }
+
+ return aResult;
+}
+
+//=========================================================================
+Reference< XInputStream > Content::openStream()
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ if ( !isDocument() )
+ return Reference< XInputStream >();
+
+ Reference< XActiveDataSink > xSink = new ActiveDataSink;
+
+ OpenCommandArgument2 aArg;
+ aArg.Mode = OpenMode::DOCUMENT;
+ aArg.Priority = 0; // unused
+ aArg.Sink = xSink;
+ aArg.Properties = Sequence< Property >( 0 ); // unused
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "open" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aArg;
+
+ m_xImpl->executeCommand( aCommand );
+
+ return xSink->getInputStream();
+}
+
+//=========================================================================
+Reference< XInputStream > Content::openStreamNoLock()
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ if ( !isDocument() )
+ return Reference< XInputStream >();
+
+ Reference< XActiveDataSink > xSink = new ActiveDataSink;
+
+ OpenCommandArgument2 aArg;
+ aArg.Mode = OpenMode::DOCUMENT_SHARE_DENY_NONE;
+ aArg.Priority = 0; // unused
+ aArg.Sink = xSink;
+ aArg.Properties = Sequence< Property >( 0 ); // unused
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "open" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aArg;
+
+ m_xImpl->executeCommand( aCommand );
+
+ return xSink->getInputStream();
+}
+
+//=========================================================================
+Reference< XStream > Content::openWriteableStream()
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ if ( !isDocument() )
+ return Reference< XStream >();
+
+ Reference< XActiveDataStreamer > xStreamer = new ActiveDataStreamer;
+
+ OpenCommandArgument2 aArg;
+ aArg.Mode = OpenMode::DOCUMENT;
+ aArg.Priority = 0; // unused
+ aArg.Sink = xStreamer;
+ aArg.Properties = Sequence< Property >( 0 ); // unused
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "open" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aArg;
+
+ m_xImpl->executeCommand( aCommand );
+
+ return xStreamer->getStream();
+}
+
+//=========================================================================
+Reference< XStream > Content::openWriteableStreamNoLock()
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ if ( !isDocument() )
+ return Reference< XStream >();
+
+ Reference< XActiveDataStreamer > xStreamer = new ActiveDataStreamer;
+
+ OpenCommandArgument2 aArg;
+ aArg.Mode = OpenMode::DOCUMENT_SHARE_DENY_NONE;
+ aArg.Priority = 0; // unused
+ aArg.Sink = xStreamer;
+ aArg.Properties = Sequence< Property >( 0 ); // unused
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "open" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aArg;
+
+ m_xImpl->executeCommand( aCommand );
+
+ return xStreamer->getStream();
+}
+
+//=========================================================================
+sal_Bool Content::openStream( const Reference< XActiveDataSink >& rSink )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ if ( !isDocument() )
+ return sal_False;
+
+ OpenCommandArgument2 aArg;
+ aArg.Mode = OpenMode::DOCUMENT;
+ aArg.Priority = 0; // unused
+ aArg.Sink = rSink;
+ aArg.Properties = Sequence< Property >( 0 ); // unused
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "open" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aArg;
+
+ m_xImpl->executeCommand( aCommand );
+
+ return sal_True;
+}
+
+//=========================================================================
+sal_Bool Content::openStream( const Reference< XOutputStream >& rStream )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ if ( !isDocument() )
+ return sal_False;
+
+ OpenCommandArgument2 aArg;
+ aArg.Mode = OpenMode::DOCUMENT;
+ aArg.Priority = 0; // unused
+ aArg.Sink = rStream;
+ aArg.Properties = Sequence< Property >( 0 ); // unused
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "open" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aArg;
+
+ m_xImpl->executeCommand( aCommand );
+
+ return sal_True;
+}
+
+//=========================================================================
+void Content::writeStream( const Reference< XInputStream >& rStream,
+ sal_Bool bReplaceExisting )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ InsertCommandArgument aArg;
+ aArg.Data = rStream.is() ? rStream : new EmptyInputStream;
+ aArg.ReplaceExisting = bReplaceExisting;
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "insert" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aArg;
+
+ m_xImpl->executeCommand( aCommand );
+
+ m_xImpl->inserted();
+}
+
+//=========================================================================
+Sequence< ContentInfo > Content::queryCreatableContentsInfo()
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ // First, try it using "CreatableContentsInfo" property -> the "new" way.
+ Sequence< ContentInfo > aInfo;
+ if ( getPropertyValue(
+ rtl::OUString::createFromAscii( "CreatableContentsInfo" ) )
+ >>= aInfo )
+ return aInfo;
+
+ // Second, try it using XContentCreator interface -> the "old" way (not
+ // providing the chance to supply an XCommandEnvironment.
+ Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY );
+ if ( xCreator.is() )
+ aInfo = xCreator->queryCreatableContentsInfo();
+
+ return aInfo;
+}
+
+//=========================================================================
+sal_Bool Content::insertNewContent( const rtl::OUString& rContentType,
+ const Sequence< rtl::OUString >&
+ rPropertyNames,
+ const Sequence< Any >& rPropertyValues,
+ Content& rNewContent )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ return insertNewContent( rContentType,
+ rPropertyNames,
+ rPropertyValues,
+ new EmptyInputStream,
+ rNewContent );
+}
+
+//=========================================================================
+sal_Bool Content::insertNewContent( const rtl::OUString& rContentType,
+ const Sequence< sal_Int32 >&
+ nPropertyHandles,
+ const Sequence< Any >& rPropertyValues,
+ Content& rNewContent )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ return insertNewContent( rContentType,
+ nPropertyHandles,
+ rPropertyValues,
+ new EmptyInputStream,
+ rNewContent );
+}
+
+//=========================================================================
+sal_Bool Content::insertNewContent( const rtl::OUString& rContentType,
+ const Sequence< rtl::OUString >&
+ rPropertyNames,
+ const Sequence< Any >& rPropertyValues,
+ const Reference< XInputStream >& rData,
+ Content& rNewContent )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ if ( rContentType.getLength() == 0 )
+ return sal_False;
+
+ // First, try it using "createNewContent" command -> the "new" way.
+ ContentInfo aInfo;
+ aInfo.Type = rContentType;
+ aInfo.Attributes = 0;
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "createNewContent" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aInfo;
+
+ Reference< XContent > xNew;
+ try
+ {
+ m_xImpl->executeCommand( aCommand ) >>= xNew;
+ }
+ catch ( RuntimeException const & )
+ {
+ throw;
+ }
+ catch ( Exception const & )
+ {
+ }
+
+ if ( !xNew.is() )
+ {
+ // Second, try it using XContentCreator interface -> the "old"
+ // way (not providing the chance to supply an XCommandEnvironment.
+ Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY );
+
+ if ( !xCreator.is() )
+ return sal_False;
+
+ xNew = xCreator->createNewContent( aInfo );
+
+ if ( !xNew.is() )
+ return sal_False;
+ }
+
+ Content aNewContent( xNew, m_xImpl->getEnvironment() );
+ aNewContent.setPropertyValues( rPropertyNames, rPropertyValues );
+ aNewContent.executeCommand( rtl::OUString::createFromAscii( "insert" ),
+ makeAny(
+ InsertCommandArgument(
+ rData.is() ? rData : new EmptyInputStream,
+ sal_False /* ReplaceExisting */ ) ) );
+ aNewContent.m_xImpl->inserted();
+
+ rNewContent = aNewContent;
+ return sal_True;
+}
+
+//=========================================================================
+sal_Bool Content::insertNewContent( const rtl::OUString& rContentType,
+ const Sequence< sal_Int32 >&
+ nPropertyHandles,
+ const Sequence< Any >& rPropertyValues,
+ const Reference< XInputStream >& rData,
+ Content& rNewContent )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ if ( rContentType.getLength() == 0 )
+ return sal_False;
+
+ // First, try it using "createNewContent" command -> the "new" way.
+ ContentInfo aInfo;
+ aInfo.Type = rContentType;
+ aInfo.Attributes = 0;
+
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "createNewContent" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aInfo;
+
+ Reference< XContent > xNew;
+ try
+ {
+ m_xImpl->executeCommand( aCommand ) >>= xNew;
+ }
+ catch ( RuntimeException const & )
+ {
+ throw;
+ }
+ catch ( Exception const & )
+ {
+ }
+
+ if ( !xNew.is() )
+ {
+ // Second, try it using XContentCreator interface -> the "old"
+ // way (not providing the chance to supply an XCommandEnvironment.
+ Reference< XContentCreator > xCreator( m_xImpl->getContent(), UNO_QUERY );
+
+ if ( !xCreator.is() )
+ return sal_False;
+
+ xNew = xCreator->createNewContent( aInfo );
+
+ if ( !xNew.is() )
+ return sal_False;
+ }
+
+ Content aNewContent( xNew, m_xImpl->getEnvironment() );
+ aNewContent.setPropertyValues( nPropertyHandles, rPropertyValues );
+ aNewContent.executeCommand( rtl::OUString::createFromAscii( "insert" ),
+ makeAny(
+ InsertCommandArgument(
+ rData.is() ? rData : new EmptyInputStream,
+ sal_False /* ReplaceExisting */ ) ) );
+ aNewContent.m_xImpl->inserted();
+
+ rNewContent = aNewContent;
+ return sal_True;
+}
+
+//=========================================================================
+sal_Bool Content::transferContent( const Content& rSourceContent,
+ InsertOperation eOperation,
+ const rtl::OUString & rTitle,
+ const sal_Int32 nNameClashAction )
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ ContentBroker* pBroker = ContentBroker::get();
+ if ( !pBroker )
+ {
+ OSL_ENSURE( sal_False,
+ "Content::transferContent - No Content Broker!" );
+ return sal_False;
+ }
+
+ Reference< XCommandProcessor > xCmdProc(
+ pBroker->getCommandProcessorInterface() );
+ if ( !xCmdProc.is() )
+ {
+ OSL_ENSURE( sal_False,
+ "Content::transferContent - No XCommandProcessor!" );
+ return sal_False;
+ }
+
+ // Execute command "globalTransfer" at UCB.
+
+ TransferCommandOperation eTransOp = TransferCommandOperation();
+ switch ( eOperation )
+ {
+ case InsertOperation_COPY:
+ eTransOp = TransferCommandOperation_COPY;
+ break;
+
+ case InsertOperation_MOVE:
+ eTransOp = TransferCommandOperation_MOVE;
+ break;
+
+ case InsertOperation_LINK:
+ eTransOp = TransferCommandOperation_LINK;
+ break;
+
+ default:
+ ucbhelper::cancelCommandExecution(
+ makeAny( IllegalArgumentException(
+ rtl::OUString::createFromAscii(
+ "Unknown transfer operation!" ),
+ get(),
+ -1 ) ),
+ m_xImpl->getEnvironment() );
+ // Unreachable
+ }
+
+ GlobalTransferCommandArgument aTransferArg(
+ eTransOp,
+ rSourceContent.getURL(), // SourceURL
+ getURL(), // TargetFolderURL,
+ rTitle,
+ nNameClashAction );
+ Command aCommand;
+ aCommand.Name = rtl::OUString::createFromAscii( "globalTransfer" );
+ aCommand.Handle = -1; // n/a
+ aCommand.Argument <<= aTransferArg;
+
+ xCmdProc->execute( aCommand, 0, m_xImpl->getEnvironment() );
+ return sal_True;
+}
+
+//=========================================================================
+sal_Bool Content::isFolder()
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ sal_Bool bFolder = sal_False;
+ if ( getPropertyValue( rtl::OUString::createFromAscii( "IsFolder" ) )
+ >>= bFolder )
+ return bFolder;
+
+ ucbhelper::cancelCommandExecution(
+ makeAny( UnknownPropertyException(
+ rtl::OUString::createFromAscii(
+ "Unable to retreive value of property 'IsFolder'!" ),
+ get() ) ),
+ m_xImpl->getEnvironment() );
+
+ // Unreachable - cancelCommandExecution always throws an exception.
+ // But some compilers complain...
+ return sal_False;
+}
+
+//=========================================================================
+sal_Bool Content::isDocument()
+ throw( CommandAbortedException, RuntimeException, Exception )
+{
+ sal_Bool bDoc = sal_False;
+ if ( getPropertyValue( rtl::OUString::createFromAscii( "IsDocument" ) )
+ >>= bDoc )
+ return bDoc;
+
+ ucbhelper::cancelCommandExecution(
+ makeAny( UnknownPropertyException(
+ rtl::OUString::createFromAscii(
+ "Unable to retreive value of property 'IsDocument'!" ),
+ get() ) ),
+ m_xImpl->getEnvironment() );
+
+ // Unreachable - cancelCommandExecution always throws an exception,
+ // But some compilers complain...
+ return sal_False;
+}
+
+//=========================================================================
+//=========================================================================
+//
+// Content_Impl Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+Content_Impl::Content_Impl( const Reference< XMultiServiceFactory >& rSMgr,
+ const Reference< XContent >& rContent,
+ const Reference< XCommandEnvironment >& rEnv )
+: m_xSMgr( rSMgr ),
+ m_xContent( rContent ),
+ m_xEnv( rEnv ),
+ m_nCommandId( 0 )
+{
+ if ( m_xContent.is() )
+ {
+ m_xContentEventListener = new ContentEventListener_Impl( *this );
+ m_xContent->addContentEventListener( m_xContentEventListener );
+
+#if OSL_DEBUG_LEVEL > 1
+ // Only done on demand in product version for performance reasons,
+ // but a nice debug helper.
+ getURL();
+#endif
+ }
+}
+
+//=========================================================================
+void Content_Impl::reinit( const Reference< XContent >& xContent )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ m_xCommandProcessor = 0;
+ m_nCommandId = 0;
+
+ // #92581# - Don't reset m_aURL!!!
+
+ if ( m_xContent.is() )
+ {
+ try
+ {
+ m_xContent->removeContentEventListener( m_xContentEventListener );
+ }
+ catch ( RuntimeException const & )
+ {
+ }
+ }
+
+ if ( xContent.is() )
+ {
+ m_xContent = xContent;
+ m_xContent->addContentEventListener( m_xContentEventListener );
+
+#if OSL_DEBUG_LEVEL > 1
+ // Only done on demand in product version for performance reasons,
+ // but a nice debug helper.
+ getURL();
+#endif
+ }
+ else
+ {
+ // We need m_xContent's URL in order to be able to create the
+ // content object again if demanded ( --> Content_Impl::getContent() )
+ getURL();
+
+ m_xContent = 0;
+ }
+}
+
+//=========================================================================
+// virtual
+Content_Impl::~Content_Impl()
+{
+ if ( m_xContent.is() )
+ {
+ try
+ {
+ m_xContent->removeContentEventListener( m_xContentEventListener );
+ }
+ catch ( RuntimeException const & )
+ {
+ }
+ }
+}
+
+//=========================================================================
+void Content_Impl::disposing( const EventObject& Source )
+{
+ Reference<XContent> xContent;
+
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+ if(Source.Source != m_xContent)
+ return;
+
+ xContent = m_xContent;
+
+ m_nCommandId = 0;
+ m_aURL = rtl::OUString();
+ m_xCommandProcessor = 0;
+ m_xContent = 0;
+ }
+
+ if ( xContent.is() )
+ {
+ try
+ {
+ xContent->removeContentEventListener( m_xContentEventListener );
+ }
+ catch ( RuntimeException const & )
+ {
+ }
+ }
+}
+
+//=========================================================================
+const rtl::OUString& Content_Impl::getURL() const
+{
+ if ( !m_aURL.getLength() && m_xContent.is() )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_aURL.getLength() && m_xContent.is() )
+ {
+ Reference< XContentIdentifier > xId = m_xContent->getIdentifier();
+ if ( xId.is() )
+ m_aURL = xId->getContentIdentifier();
+ }
+ }
+
+ return m_aURL;
+}
+
+//=========================================================================
+Reference< XContent > Content_Impl::getContent()
+{
+ if ( !m_xContent.is() && m_aURL.getLength() )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_xContent.is() && m_aURL.getLength() )
+ {
+ ContentBroker* pBroker = ContentBroker::get();
+
+ OSL_ENSURE( pBroker, "No Content Broker!" );
+
+ if ( pBroker )
+ {
+ OSL_ENSURE( pBroker->getContentProviderManagerInterface()
+ ->queryContentProviders().getLength(),
+ "Content Broker not configured (no providers)!" );
+
+ Reference< XContentIdentifierFactory > xIdFac
+ = pBroker->getContentIdentifierFactoryInterface();
+
+ OSL_ENSURE( xIdFac.is(), "No Content Identifier factory!" );
+
+ if ( xIdFac.is() )
+ {
+ Reference< XContentIdentifier > xId
+ = xIdFac->createContentIdentifier( m_aURL );
+
+ OSL_ENSURE( xId.is(), "No Content Identifier!" );
+
+ if ( xId.is() )
+ {
+ Reference< XContentProvider > xProvider
+ = pBroker->getContentProviderInterface();
+
+ OSL_ENSURE( xProvider.is(), "No Content Provider!" );
+
+ if ( xProvider.is() )
+ {
+ try
+ {
+ m_xContent = xProvider->queryContent( xId );
+ }
+ catch ( IllegalIdentifierException const & )
+ {
+ }
+
+ if ( m_xContent.is() )
+ m_xContent->addContentEventListener(
+ m_xContentEventListener );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return m_xContent;
+}
+
+//=========================================================================
+Reference< XCommandProcessor > Content_Impl::getCommandProcessor()
+{
+ if ( !m_xCommandProcessor.is() )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_xCommandProcessor.is() )
+ m_xCommandProcessor
+ = Reference< XCommandProcessor >( getContent(), UNO_QUERY );
+ }
+
+ return m_xCommandProcessor;
+}
+
+//=========================================================================
+sal_Int32 Content_Impl::getCommandId()
+{
+ if ( m_nCommandId == 0 )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_nCommandId == 0 )
+ {
+ Reference< XCommandProcessor > xProc = getCommandProcessor();
+ if ( xProc.is() )
+ m_nCommandId = xProc->createCommandIdentifier();
+ }
+ }
+
+ return m_nCommandId;
+}
+
+//=========================================================================
+Any Content_Impl::executeCommand( const Command& rCommand )
+{
+ Reference< XCommandProcessor > xProc = getCommandProcessor();
+ if ( !xProc.is() )
+ return Any();
+
+ // Execute command
+ return xProc->execute( rCommand, getCommandId(), m_xEnv );
+}
+
+//=========================================================================
+void Content_Impl::abortCommand()
+{
+ sal_Int32 nCommandId;
+ Reference< XCommandProcessor > xCommandProcessor;
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+ nCommandId = m_nCommandId;
+ xCommandProcessor = m_xCommandProcessor;
+ }
+
+ if ( ( nCommandId != 0 ) && xCommandProcessor.is() )
+ xCommandProcessor->abort( nCommandId );
+}
+
+//=========================================================================
+inline const Reference< XCommandEnvironment >&
+ Content_Impl::getEnvironment() const
+{
+ return m_xEnv;
+}
+
+//=========================================================================
+inline void Content_Impl::setEnvironment(
+ const Reference< XCommandEnvironment >& xNewEnv )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+ m_xEnv = xNewEnv;
+}
+
+//=========================================================================
+void Content_Impl::inserted()
+{
+ // URL might have changed during 'insert' => recalculate in next getURL()
+ osl::MutexGuard aGuard( m_aMutex );
+ m_aURL = ::rtl::OUString();
+}
+
+//=========================================================================
+//=========================================================================
+//
+// ContentEventListener_Impl Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_2( ContentEventListener_Impl,
+ XContentEventListener,
+ XEventListener ); /* base of XContentEventListener */
+
+//=========================================================================
+//
+// XContentEventListener methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ContentEventListener_Impl::contentEvent( const ContentEvent& evt )
+ throw( RuntimeException )
+{
+ if ( evt.Source == m_rContent.m_xContent )
+ {
+ switch ( evt.Action )
+ {
+ case ContentAction::DELETED:
+ m_rContent.reinit( Reference< XContent >() );
+ break;
+
+ case ContentAction::EXCHANGED:
+ m_rContent.reinit( evt.Content );
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+//=========================================================================
+//
+// XEventListenr methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL ContentEventListener_Impl::disposing( const EventObject& Source )
+ throw( RuntimeException )
+{
+ m_rContent.disposing(Source);
+}
+
+} /* namespace ucbhelper */
+
diff --git a/ucbhelper/source/client/contentbroker.cxx b/ucbhelper/source/client/contentbroker.cxx
new file mode 100644
index 000000000000..408ff6af0dee
--- /dev/null
+++ b/ucbhelper/source/client/contentbroker.cxx
@@ -0,0 +1,380 @@
+/*************************************************************************
+ *
+ * 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 <osl/mutex.hxx>
+#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 <com/sun/star/ucb/XCommandProcessor.hpp>
+#include <ucbhelper/contentbroker.hxx>
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace rtl;
+
+namespace
+{
+ osl::Mutex globalContentBrokerMutex;
+ osl::Mutex & getGlobalContentBrokerMutex() { return globalContentBrokerMutex; }
+
+} // namespace
+
+namespace ucbhelper
+{
+
+//=========================================================================
+//=========================================================================
+//
+// class ContentBroker_Impl.
+//
+//=========================================================================
+//=========================================================================
+
+class ContentBroker_Impl
+{
+ Reference< XMultiServiceFactory > m_xSMgr;
+ Reference< XContentIdentifierFactory > m_xIdFac;
+ Reference< XContentProvider > m_xProvider;
+ Reference< XContentProviderManager > m_xProviderMgr;
+ Reference< XCommandProcessor > m_xCommandProc;
+ osl::Mutex m_aMutex;
+ Sequence< Any > m_aArguments;
+ ContentProviderDataList m_aProvData;
+ bool m_bInitDone;
+
+public:
+ ContentBroker_Impl( const Reference< XMultiServiceFactory >& rSMgr,
+ const Sequence< Any >& rArguments )
+ : m_xSMgr( rSMgr ), m_aArguments( rArguments ), m_bInitDone( sal_False )
+ {}
+
+ ContentBroker_Impl( const Reference< XMultiServiceFactory >& rSMgr,
+ const ContentProviderDataList & rData )
+ : m_xSMgr( rSMgr ), m_aProvData( rData ), m_bInitDone( sal_False )
+ {}
+
+ ~ContentBroker_Impl();
+
+ bool initialize();
+
+ const Reference< XMultiServiceFactory >& getServiceManager() const
+ { return m_xSMgr; }
+
+ const Reference< XContentIdentifierFactory >& getIdFactory() const
+ { return m_xIdFac; }
+
+ const Reference< XContentProvider >& getProvider() const
+ { return m_xProvider; }
+
+ const Reference< XContentProviderManager >& getProviderManager() const
+ { return m_xProviderMgr; }
+
+ const Reference< XCommandProcessor >& getCommandProcessor() const
+ { return m_xCommandProc; }
+};
+
+//=========================================================================
+//=========================================================================
+//
+// ContentBroker Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+// static member!
+ContentBroker* ContentBroker::m_pTheBroker = 0;
+
+//=========================================================================
+ContentBroker::ContentBroker( const Reference< XMultiServiceFactory >& rSMgr,
+ const Sequence< Any >& rArguments )
+{
+ m_pImpl = new ContentBroker_Impl( rSMgr, rArguments );
+}
+
+//=========================================================================
+ContentBroker::ContentBroker( const Reference< XMultiServiceFactory >& rSMgr,
+ const ContentProviderDataList & rData )
+{
+ m_pImpl = new ContentBroker_Impl( rSMgr, rData );
+}
+
+//=========================================================================
+ContentBroker::~ContentBroker()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+Reference< XMultiServiceFactory > ContentBroker::getServiceManager() const
+{
+ return m_pImpl->getServiceManager();
+}
+
+//=========================================================================
+Reference< XContentIdentifierFactory >
+ ContentBroker::getContentIdentifierFactoryInterface() const
+{
+ return m_pImpl->getIdFactory();
+}
+
+//=========================================================================
+Reference< XContentProvider >
+ ContentBroker::getContentProviderInterface() const
+{
+ return m_pImpl->getProvider();
+}
+
+//=========================================================================
+Reference< XContentProviderManager >
+ ContentBroker::getContentProviderManagerInterface() const
+{
+ return m_pImpl->getProviderManager();
+}
+
+//=========================================================================
+Reference< XCommandProcessor >
+ ContentBroker::getCommandProcessorInterface() const
+{
+ return m_pImpl->getCommandProcessor();
+}
+
+//=========================================================================
+// static
+sal_Bool ContentBroker::initialize(
+ const Reference< XMultiServiceFactory >& rSMgr,
+ const Sequence< Any >& rArguments )
+{
+ OSL_ENSURE( !m_pTheBroker,
+ "ContentBroker::initialize - already initialized!" );
+
+ if ( !m_pTheBroker )
+ {
+ osl::Guard< osl::Mutex > aGuard( getGlobalContentBrokerMutex() );
+
+ if ( !m_pTheBroker )
+ {
+ ContentBroker * pBroker = new ContentBroker( rSMgr, rArguments );
+
+ // Force init to be able to detect UCB init trouble immediately.
+ if ( pBroker->m_pImpl->initialize() )
+ m_pTheBroker = pBroker;
+ else
+ delete pBroker;
+ }
+ }
+
+ return m_pTheBroker != 0;
+}
+
+//=========================================================================
+// static
+sal_Bool ContentBroker::initialize(
+ const Reference< XMultiServiceFactory >& rSMgr,
+ const ContentProviderDataList & rData )
+{
+ OSL_ENSURE( !m_pTheBroker,
+ "ContentBroker::initialize - already initialized!" );
+
+ if ( !m_pTheBroker )
+ {
+ osl::Guard< osl::Mutex > aGuard( getGlobalContentBrokerMutex() );
+
+ if ( !m_pTheBroker )
+ {
+ ContentBroker * pBroker = new ContentBroker( rSMgr, rData );
+
+ // Force init to be able to detect UCB init trouble immediately.
+ if ( pBroker->m_pImpl->initialize() )
+ m_pTheBroker = pBroker;
+ else
+ delete pBroker;
+ }
+ }
+
+ return m_pTheBroker != 0;
+}
+
+//=========================================================================
+// static
+void ContentBroker::deinitialize()
+{
+ osl::MutexGuard aGuard( getGlobalContentBrokerMutex() );
+
+ delete m_pTheBroker;
+ m_pTheBroker = 0;
+}
+
+//=========================================================================
+// static
+ContentBroker* ContentBroker::get()
+{
+ return m_pTheBroker;
+}
+
+//=========================================================================
+//=========================================================================
+//
+// ContentBroker_Impl Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+ContentBroker_Impl::~ContentBroker_Impl()
+{
+ Reference< XComponent > xComponent( m_xProvider, UNO_QUERY );
+ if ( xComponent.is() )
+ {
+ m_xIdFac = 0;
+ m_xProvider = 0;
+ m_xProviderMgr = 0;
+
+ xComponent->dispose();
+ }
+}
+
+//=========================================================================
+bool ContentBroker_Impl::initialize()
+{
+ if ( !m_bInitDone )
+ {
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_bInitDone )
+ {
+ Reference< XInterface > xIfc;
+
+ if ( m_aProvData.size() > 0 )
+ {
+ try
+ {
+ xIfc = m_xSMgr->createInstance(
+ OUString::createFromAscii(
+ "com.sun.star.ucb.UniversalContentBroker" ) );
+ }
+ catch ( Exception const & )
+ {
+ }
+
+ if ( xIfc.is() )
+ {
+ m_xProviderMgr
+ = Reference< XContentProviderManager >( xIfc, UNO_QUERY );
+
+ if ( m_xProviderMgr.is() )
+ {
+ ContentProviderDataList::const_iterator aEnd(m_aProvData.end());
+ for (ContentProviderDataList::const_iterator aIt(m_aProvData.begin());
+ aIt != aEnd; ++aIt)
+ {
+ registerAtUcb(m_xProviderMgr,
+ m_xSMgr,
+ aIt->ServiceName,
+ aIt->Arguments,
+ aIt->URLTemplate,
+ 0);
+ }
+
+ }
+ }
+ }
+ else
+ {
+ try
+ {
+ xIfc = m_xSMgr->createInstanceWithArguments(
+ OUString::createFromAscii(
+ "com.sun.star.ucb.UniversalContentBroker" ),
+ m_aArguments );
+ }
+ catch ( Exception const & )
+ {
+ }
+ }
+
+ OSL_ENSURE( xIfc.is(), "Error creating UCB service!" );
+
+ if ( !xIfc.is() )
+ return false;
+
+
+ m_xIdFac
+ = Reference< XContentIdentifierFactory >( xIfc, UNO_QUERY );
+
+ OSL_ENSURE( m_xIdFac.is(),
+ "UCB without required interface XContentIdentifierFactory!" );
+
+ if ( !m_xIdFac.is() )
+ return false;
+
+ m_xProvider = Reference< XContentProvider >( xIfc, UNO_QUERY );
+
+ OSL_ENSURE( m_xProvider.is(),
+ "UCB without required interface XContentProvider!" );
+
+ if ( !m_xProvider.is() )
+ return false;
+
+ if ( !m_xProviderMgr.is() )
+ m_xProviderMgr
+ = Reference< XContentProviderManager >( xIfc, UNO_QUERY );
+
+ OSL_ENSURE( m_xProviderMgr.is(),
+ "UCB without required interface XContentProviderManager!" );
+
+ if ( !m_xProviderMgr.is() )
+ return false;
+
+ m_xCommandProc = Reference< XCommandProcessor >( xIfc, UNO_QUERY );
+
+ OSL_ENSURE( m_xCommandProc.is(),
+ "UCB without required interface XCommandProcessor!" );
+
+ if ( !m_xCommandProc.is() )
+ return false;
+
+ // Everything okay.
+ m_bInitDone = sal_True;
+ }
+ }
+
+ return true;
+}
+
+} /* namespace ucbhelper */
+
diff --git a/ucbhelper/source/client/fileidentifierconverter.cxx b/ucbhelper/source/client/fileidentifierconverter.cxx
new file mode 100644
index 000000000000..64bc428a9934
--- /dev/null
+++ b/ucbhelper/source/client/fileidentifierconverter.cxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * 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/fileidentifierconverter.hxx>
+#include <com/sun/star/ucb/ContentProviderInfo.hpp>
+#include <com/sun/star/ucb/XContentProviderManager.hpp>
+#include <com/sun/star/ucb/XFileIdentifierConverter.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <osl/diagnose.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+using namespace com::sun::star;
+
+namespace ucbhelper {
+
+//============================================================================
+//
+// getLocalFileURL
+//
+//============================================================================
+
+rtl::OUString
+getLocalFileURL(
+ uno::Reference< ucb::XContentProviderManager > const &)
+ SAL_THROW((uno::RuntimeException))
+{
+ // If there were more file systems than just "file:///" (e.g., the obsolete
+ // "vnd.sun.star.wfs:///"), this code should query all relevant UCPs for
+ // their com.sun.star.ucb.XFileIdentifierConverter.getFileProviderLocality
+ // and return the most local one:
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file:///"));
+}
+
+//============================================================================
+//
+// getFileURLFromSystemPath
+//
+//============================================================================
+
+rtl::OUString
+getFileURLFromSystemPath(
+ uno::Reference< ucb::XContentProviderManager > const & rManager,
+ rtl::OUString const & rBaseURL,
+ rtl::OUString const & rSystemPath)
+ SAL_THROW((uno::RuntimeException))
+{
+ OSL_ASSERT(rManager.is());
+
+ uno::Reference< ucb::XFileIdentifierConverter >
+ xConverter(rManager->queryContentProvider(rBaseURL), uno::UNO_QUERY);
+ if (xConverter.is())
+ return xConverter->getFileURLFromSystemPath(rBaseURL, rSystemPath);
+ else
+ return rtl::OUString();
+}
+
+//============================================================================
+//
+// getSystemPathFromFileURL
+//
+//============================================================================
+
+rtl::OUString
+getSystemPathFromFileURL(
+ uno::Reference< ucb::XContentProviderManager > const & rManager,
+ rtl::OUString const & rURL)
+ SAL_THROW((uno::RuntimeException))
+{
+ OSL_ASSERT(rManager.is());
+
+ uno::Reference< ucb::XFileIdentifierConverter >
+ xConverter(rManager->queryContentProvider(rURL), uno::UNO_QUERY);
+ if (xConverter.is())
+ return xConverter->getSystemPathFromFileURL(rURL);
+ else
+ return rtl::OUString();
+}
+
+}
diff --git a/ucbhelper/source/client/interceptedinteraction.cxx b/ucbhelper/source/client/interceptedinteraction.cxx
new file mode 100644
index 000000000000..a23206f615f3
--- /dev/null
+++ b/ucbhelper/source/client/interceptedinteraction.cxx
@@ -0,0 +1,201 @@
+/*************************************************************************
+ *
+ * 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/interceptedinteraction.hxx>
+
+//_______________________________________________
+// includes
+
+//_______________________________________________
+// namespace
+
+namespace ucbhelper{
+
+namespace css = ::com::sun::star;
+
+//_______________________________________________
+// definitions
+
+/*-----------------------------------------------
+ 17.03.2004 11:00
+-----------------------------------------------*/
+InterceptedInteraction::InterceptedInteraction()
+{
+}
+
+/*-----------------------------------------------
+ 17.03.2004 14:55
+-----------------------------------------------*/
+void InterceptedInteraction::setInterceptedHandler(const css::uno::Reference< css::task::XInteractionHandler >& xInterceptedHandler)
+{
+ m_xInterceptedHandler = xInterceptedHandler;
+}
+
+/*-----------------------------------------------
+ 17.03.2004 14:55
+-----------------------------------------------*/
+void InterceptedInteraction::setInterceptions(const ::std::vector< InterceptedRequest >& lInterceptions)
+{
+ m_lInterceptions = lInterceptions;
+}
+
+/*-----------------------------------------------
+ 18.03.2004 10:10
+-----------------------------------------------*/
+InterceptedInteraction::EInterceptionState InterceptedInteraction::intercepted(
+ const InterceptedRequest&,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >&)
+{
+ // default behaviour! see impl_interceptRequest() for further informations ...
+ return E_NOT_INTERCEPTED;
+}
+
+/*-----------------------------------------------
+ 18.03.2004 09:46
+-----------------------------------------------*/
+css::uno::Reference< css::task::XInteractionContinuation > InterceptedInteraction::extractContinuation(const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >& lContinuations,
+ const css::uno::Type& aType )
+{
+ const css::uno::Reference< css::task::XInteractionContinuation >* pContinuations = lContinuations.getConstArray();
+
+ sal_Int32 c = lContinuations.getLength();
+ sal_Int32 i = 0;
+
+ for (i=0; i<c; ++i)
+ {
+ css::uno::Reference< css::uno::XInterface > xCheck(pContinuations[i], css::uno::UNO_QUERY);
+ if (xCheck->queryInterface(aType).hasValue())
+ return pContinuations[i];
+ }
+
+ return css::uno::Reference< css::task::XInteractionContinuation >();
+}
+
+/*-----------------------------------------------
+ 18.03.2004 10:03
+-----------------------------------------------*/
+void SAL_CALL InterceptedInteraction::handle(const css::uno::Reference< css::task::XInteractionRequest >& xRequest)
+ throw(css::uno::RuntimeException)
+{
+ impl_handleDefault(xRequest);
+}
+
+/*-----------------------------------------------
+ 18.03.2004 10:02
+-----------------------------------------------*/
+void InterceptedInteraction::impl_handleDefault(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest)
+{
+ EInterceptionState eState = impl_interceptRequest(xRequest);
+
+ switch(eState)
+ {
+ case E_NOT_INTERCEPTED:
+ {
+ // Non of the intercepted requests match to the given one.
+ // => forward request to the internal wrapped handler - if there is one.
+ if (m_xInterceptedHandler.is())
+ m_xInterceptedHandler->handle(xRequest);
+ }
+ break;
+
+ case E_NO_CONTINUATION_FOUND:
+ {
+ // Runtime error! The defined continuation could not be located
+ // inside the set of available containuations of the incoming request.
+ // Whats wrong - the interception list or the request?
+ OSL_ENSURE(sal_False, "InterceptedInteraction::handle()\nCould intercept this interaction request - but cant locate the right continuation!");
+ }
+ break;
+
+ case E_INTERCEPTED:
+ break;
+ }
+}
+
+/*-----------------------------------------------
+ 18.03.2004 09:48
+-----------------------------------------------*/
+InterceptedInteraction::EInterceptionState InterceptedInteraction::impl_interceptRequest(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest)
+{
+ css::uno::Any aRequest = xRequest->getRequest();
+ css::uno::Type aRequestType = aRequest.getValueType();
+ css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations();
+
+ // check against the list of static requests
+ sal_Int32 nHandle = 0;
+ ::std::vector< InterceptedRequest >::const_iterator pIt;
+ for ( pIt = m_lInterceptions.begin();
+ pIt != m_lInterceptions.end() ;
+ ++pIt )
+ {
+ const InterceptedRequest& rInterception = *pIt;
+ css::uno::Type aInterceptedType = rInterception.Request.getValueType();
+
+ // check the request
+ sal_Bool bMatch = sal_False;
+ if (rInterception.MatchExact)
+ bMatch = aInterceptedType.equals(aRequestType);
+ else
+ bMatch = aInterceptedType.isAssignableFrom(aRequestType); // dont change intercepted and request type here -> it will check the wrong direction!
+
+ // intercepted ...
+ // Call they might existing derived class, so they can handle that by its own.
+ // If its not interested on that (may be its not overwritten and the default implementation
+ // returns E_NOT_INTERCEPTED as default) -> break this loop and search for the right continuation.
+ if (bMatch)
+ {
+ EInterceptionState eState = intercepted(rInterception, xRequest);
+ if (eState == E_NOT_INTERCEPTED)
+ break;
+ return eState;
+ }
+
+ ++nHandle;
+ }
+
+ if (pIt != m_lInterceptions.end()) // => can be true only if bMatch=TRUE!
+ {
+ // match -> search required continuation
+ const InterceptedRequest& rInterception = *pIt;
+ css::uno::Reference< css::task::XInteractionContinuation > xContinuation = InterceptedInteraction::extractContinuation(lContinuations, rInterception.Continuation);
+ if (xContinuation.is())
+ {
+ xContinuation->select();
+ return E_INTERCEPTED;
+ }
+
+ // Can be reached only, if the request does not support the given continuation!
+ // => RuntimeError!?
+ return E_NO_CONTINUATION_FOUND;
+ }
+
+ return E_NOT_INTERCEPTED;
+}
+
+} // namespace ucbhelper
diff --git a/ucbhelper/source/client/makefile.mk b/ucbhelper/source/client/makefile.mk
new file mode 100644
index 000000000000..b8a535ba429c
--- /dev/null
+++ b/ucbhelper/source/client/makefile.mk
@@ -0,0 +1,60 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME= ucbhelper
+TARGET= client
+AUTOSEG= TRUE
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(header)" == ""
+
+SLOFILES=\
+ $(SLO)$/content.obj \
+ $(SLO)$/contentbroker.obj \
+ $(SLO)$/commandenvironment.obj \
+ $(SLO)$/fileidentifierconverter.obj \
+ $(SLO)$/activedatasink.obj \
+ $(SLO)$/activedatastreamer.obj \
+ $(SLO)$/proxydecider.obj \
+ $(SLO)$/interceptedinteraction.obj
+
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/ucbhelper/source/client/proxydecider.cxx b/ucbhelper/source/client/proxydecider.cxx
new file mode 100644
index 000000000000..8505472e1b1f
--- /dev/null
+++ b/ucbhelper/source/client/proxydecider.cxx
@@ -0,0 +1,861 @@
+/*************************************************************************
+ *
+ * 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 <utility>
+#include <vector>
+#include <list>
+#include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
+#include <osl/socket.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/XChangesListener.hpp>
+#include <com/sun/star/util/XChangesNotifier.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include "ucbhelper/proxydecider.hxx"
+
+using namespace com::sun::star;
+using namespace ucbhelper;
+
+#define CONFIG_ROOT_KEY "org.openoffice.Inet/Settings"
+#define PROXY_TYPE_KEY "ooInetProxyType"
+#define NO_PROXY_LIST_KEY "ooInetNoProxy"
+#define HTTP_PROXY_NAME_KEY "ooInetHTTPProxyName"
+#define HTTP_PROXY_PORT_KEY "ooInetHTTPProxyPort"
+#define FTP_PROXY_NAME_KEY "ooInetFTPProxyName"
+#define FTP_PROXY_PORT_KEY "ooInetFTPProxyPort"
+
+//=========================================================================
+namespace ucbhelper
+{
+
+//=========================================================================
+namespace proxydecider_impl
+{
+
+// A simple case ignoring wildcard matcher.
+class WildCard
+{
+private:
+ rtl::OString m_aWildString;
+
+public:
+ WildCard( const rtl::OUString& rWildCard )
+ : m_aWildString(
+ rtl::OUStringToOString(
+ rWildCard, RTL_TEXTENCODING_UTF8 ).toAsciiLowerCase() ) {}
+
+ bool Matches( const rtl::OUString & rStr ) const;
+};
+
+//=========================================================================
+typedef std::pair< WildCard, WildCard > NoProxyListEntry;
+
+//=========================================================================
+
+class HostnameCache
+{
+ typedef std::pair< rtl::OUString, rtl::OUString > HostListEntry;
+
+ std::list< HostListEntry > m_aHostList;
+ sal_uInt32 m_nCapacity;
+
+public:
+ explicit HostnameCache( sal_uInt32 nCapacity )
+ : m_nCapacity( nCapacity ) {}
+
+ bool get( const rtl::OUString & rKey, rtl::OUString & rValue ) const
+ {
+ std::list< HostListEntry >::const_iterator it
+ = m_aHostList.begin();
+ const std::list< HostListEntry >::const_iterator end
+ = m_aHostList.end();
+
+ while ( it != end )
+ {
+ if ( (*it).first == rKey )
+ {
+ rValue = (*it).second;
+ return true;
+ }
+ it++;
+ }
+ return false;
+ }
+
+ void put( const rtl::OUString & rKey, const rtl::OUString & rValue )
+ {
+ if ( m_aHostList.size() == m_nCapacity )
+ m_aHostList.resize( m_nCapacity / 2 );
+
+ m_aHostList.push_front( HostListEntry( rKey, rValue ) );
+ }
+};
+
+//=========================================================================
+class InternetProxyDecider_Impl :
+ public cppu::WeakImplHelper1< util::XChangesListener >
+{
+ mutable osl::Mutex m_aMutex;
+ InternetProxyServer m_aHttpProxy;
+ InternetProxyServer m_aFtpProxy;
+ const InternetProxyServer m_aEmptyProxy;
+ sal_Int32 m_nProxyType;
+ uno::Reference< util::XChangesNotifier > m_xNotifier;
+ std::vector< NoProxyListEntry > m_aNoProxyList;
+ mutable HostnameCache m_aHostnames;
+
+private:
+ bool shouldUseProxy( const rtl::OUString & rHost,
+ sal_Int32 nPort,
+ bool bUseFullyQualified ) const;
+public:
+ InternetProxyDecider_Impl(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr );
+ virtual ~InternetProxyDecider_Impl();
+
+ static rtl::Reference< InternetProxyDecider_Impl > createInstance(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr );
+
+ void dispose();
+
+ const InternetProxyServer & getProxy( const rtl::OUString & rProtocol,
+ const rtl::OUString & rHost,
+ sal_Int32 nPort ) const;
+
+ // XChangesListener
+ virtual void SAL_CALL changesOccurred( const util::ChangesEvent& Event )
+ throw( uno::RuntimeException );
+
+ // XEventListener ( base of XChangesLisetenr )
+ virtual void SAL_CALL disposing( const lang::EventObject& Source )
+ throw( uno::RuntimeException );
+
+private:
+ void setNoProxyList( const rtl::OUString & rNoProxyList );
+};
+
+//=========================================================================
+//=========================================================================
+//
+// WildCard Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+bool WildCard::Matches( const rtl::OUString& rString ) const
+{
+ rtl::OString aString
+ = rtl::OUStringToOString(
+ rString, RTL_TEXTENCODING_UTF8 ).toAsciiLowerCase();
+ const char * pStr = aString.getStr();
+ const char * pWild = m_aWildString.getStr();
+
+ int pos = 0;
+ int flag = 0;
+
+ while ( *pWild || flag )
+ {
+ switch ( *pWild )
+ {
+ case '?':
+ if ( *pStr == '\0' )
+ return 0;
+ break;
+
+ default:
+ if ( ( *pWild == '\\' ) && ( ( *( pWild + 1 ) == '?' )
+ || ( *( pWild + 1 ) == '*') ) )
+ pWild++;
+ if ( *pWild != *pStr )
+ if ( !pos )
+ return 0;
+ else
+ pWild += pos;
+ else
+ break;
+
+ // Note: fall-thru's are intended!
+
+ case '*':
+ while ( *pWild == '*' )
+ pWild++;
+ if ( *pWild == '\0' )
+ return 1;
+ flag = 1;
+ pos = 0;
+ if ( *pStr == '\0' )
+ return ( *pWild == '\0' );
+ while ( *pStr && *pStr != *pWild )
+ {
+ if ( *pWild == '?' ) {
+ pWild++;
+ while ( *pWild == '*' )
+ pWild++;
+ }
+ pStr++;
+ if ( *pStr == '\0' )
+ return ( *pWild == '\0' );
+ }
+ break;
+ }
+ if ( *pWild != '\0' )
+ pWild++;
+ if ( *pStr != '\0' )
+ pStr++;
+ else
+ flag = 0;
+ if ( flag )
+ pos--;
+ }
+ return ( *pStr == '\0' ) && ( *pWild == '\0' );
+}
+
+//=========================================================================
+//=========================================================================
+//
+// InternetProxyDecider_Impl Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+InternetProxyDecider_Impl::InternetProxyDecider_Impl(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr )
+ : m_nProxyType( 0 ),
+ m_aHostnames( 256 ) // cache size
+{
+ try
+ {
+ //////////////////////////////////////////////////////////////
+ // Read proxy configuration from config db.
+ //////////////////////////////////////////////////////////////
+
+ uno::Reference< lang::XMultiServiceFactory > xConfigProv(
+ rxSMgr->createInstance(
+ rtl::OUString::createFromAscii(
+ "com.sun.star.configuration.ConfigurationProvider" ) ),
+ uno::UNO_QUERY );
+
+ uno::Sequence< uno::Any > aArguments( 1 );
+ aArguments[ 0 ] <<= rtl::OUString::createFromAscii( CONFIG_ROOT_KEY );
+
+ uno::Reference< uno::XInterface > xInterface(
+ xConfigProv->createInstanceWithArguments(
+ rtl::OUString::createFromAscii(
+ "com.sun.star.configuration.ConfigurationAccess" ),
+ aArguments ) );
+
+ OSL_ENSURE( xInterface.is(),
+ "InternetProxyDecider - No config access!" );
+
+ if ( xInterface.is() )
+ {
+ uno::Reference< container::XNameAccess > xNameAccess(
+ xInterface, uno::UNO_QUERY );
+ OSL_ENSURE( xNameAccess.is(),
+ "InternetProxyDecider - No name access!" );
+
+ if ( xNameAccess.is() )
+ {
+ try
+ {
+ if ( !( xNameAccess->getByName(
+ rtl::OUString::createFromAscii(
+ PROXY_TYPE_KEY ) ) >>= m_nProxyType ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - "
+ "Error getting config item value!" );
+ }
+ }
+ catch ( lang::WrappedTargetException const & )
+ {
+ }
+ catch ( container::NoSuchElementException const & )
+ {
+ }
+
+ rtl::OUString aNoProxyList;
+ try
+ {
+ if ( !( xNameAccess->getByName(
+ rtl::OUString::createFromAscii(
+ NO_PROXY_LIST_KEY ) ) >>= aNoProxyList ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - "
+ "Error getting config item value!" );
+ }
+ }
+ catch ( lang::WrappedTargetException const & )
+ {
+ }
+ catch ( container::NoSuchElementException const & )
+ {
+ }
+
+ setNoProxyList( aNoProxyList );
+
+ try
+ {
+ if ( !( xNameAccess->getByName(
+ rtl::OUString::createFromAscii(
+ HTTP_PROXY_NAME_KEY ) )
+ >>= m_aHttpProxy.aName ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - "
+ "Error getting config item value!" );
+ }
+ }
+ catch ( lang::WrappedTargetException const & )
+ {
+ }
+ catch ( container::NoSuchElementException const & )
+ {
+ }
+
+ m_aHttpProxy.nPort = -1;
+ try
+ {
+ uno::Any aValue = xNameAccess->getByName(
+ rtl::OUString::createFromAscii(
+ HTTP_PROXY_PORT_KEY ) );
+ if ( aValue.hasValue() &&
+ !( aValue >>= m_aHttpProxy.nPort ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - "
+ "Error getting config item value!" );
+ }
+ }
+ catch ( lang::WrappedTargetException const & )
+ {
+ }
+ catch ( container::NoSuchElementException const & )
+ {
+ }
+
+ if ( m_aHttpProxy.nPort == -1 )
+ m_aHttpProxy.nPort = 80; // standard HTTP port.
+
+ try
+ {
+ if ( !( xNameAccess->getByName(
+ rtl::OUString::createFromAscii(
+ FTP_PROXY_NAME_KEY ) )
+ >>= m_aFtpProxy.aName ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - "
+ "Error getting config item value!" );
+ }
+ }
+ catch ( lang::WrappedTargetException const & )
+ {
+ }
+ catch ( container::NoSuchElementException const & )
+ {
+ }
+
+ m_aFtpProxy.nPort = -1;
+ try
+ {
+ uno::Any aValue = xNameAccess->getByName(
+ rtl::OUString::createFromAscii(
+ FTP_PROXY_PORT_KEY ) );
+ if ( aValue.hasValue() &&
+ !( aValue >>= m_aFtpProxy.nPort ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - "
+ "Error getting config item value!" );
+ }
+ }
+ catch ( lang::WrappedTargetException const & )
+ {
+ }
+ catch ( container::NoSuchElementException const & )
+ {
+ }
+ }
+
+ // Register as listener for config changes.
+
+ m_xNotifier = uno::Reference< util::XChangesNotifier >(
+ xInterface, uno::UNO_QUERY );
+
+ OSL_ENSURE( m_xNotifier.is(),
+ "InternetProxyDecider - No notifier!" );
+
+ if ( m_xNotifier.is() )
+ m_xNotifier->addChangesListener( this );
+ }
+ }
+ catch ( uno::Exception const & )
+ {
+ // createInstance, createInstanceWithArguments
+ OSL_ENSURE( sal_False, "InternetProxyDecider - Exception!" );
+ }
+}
+
+//=========================================================================
+// virtual
+InternetProxyDecider_Impl::~InternetProxyDecider_Impl()
+{
+}
+
+//=========================================================================
+void InternetProxyDecider_Impl::dispose()
+{
+ uno::Reference< util::XChangesNotifier > xNotifier;
+
+ if ( m_xNotifier.is() )
+ {
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+
+ if ( m_xNotifier.is() )
+ {
+ xNotifier = m_xNotifier;
+ m_xNotifier.clear();
+ }
+ }
+
+ // Do this unguarded!
+ if ( xNotifier.is() )
+ xNotifier->removeChangesListener( this );
+}
+
+//=========================================================================
+bool InternetProxyDecider_Impl::shouldUseProxy( const rtl::OUString & rHost,
+ sal_Int32 nPort,
+ bool bUseFullyQualified ) const
+{
+ rtl::OUStringBuffer aBuffer;
+
+ if ( ( rHost.indexOf( ':' ) != -1 ) &&
+ ( rHost[ 0 ] != sal_Unicode( '[' ) ) )
+ {
+ // host is given as numeric IPv6 address
+ aBuffer.appendAscii( "[" );
+ aBuffer.append( rHost );
+ aBuffer.appendAscii( "]" );
+ }
+ else
+ {
+ // host is given either as numeric IPv4 address or non-numeric hostname
+ aBuffer.append( rHost );
+ }
+
+ aBuffer.append( sal_Unicode( ':' ) );
+ aBuffer.append( rtl::OUString::valueOf( nPort ) );
+ const rtl::OUString aHostAndPort( aBuffer.makeStringAndClear() );
+
+ std::vector< NoProxyListEntry >::const_iterator it
+ = m_aNoProxyList.begin();
+ const std::vector< NoProxyListEntry >::const_iterator end
+ = m_aNoProxyList.end();
+
+ while ( it != end )
+ {
+ if ( bUseFullyQualified )
+ {
+ if ( (*it).second.Matches( aHostAndPort ) )
+ return false;
+ }
+ else
+ {
+ if ( (*it).first.Matches( aHostAndPort ) )
+ return false;
+ }
+ it++;
+ }
+
+ return true;
+}
+
+//=========================================================================
+const InternetProxyServer & InternetProxyDecider_Impl::getProxy(
+ const rtl::OUString & rProtocol,
+ const rtl::OUString & rHost,
+ sal_Int32 nPort ) const
+{
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+
+ if ( m_nProxyType == 0 )
+ {
+ // Never use proxy.
+ return m_aEmptyProxy;
+ }
+
+ if ( rHost.getLength() && m_aNoProxyList.size() )
+ {
+ //////////////////////////////////////////////////////////////////
+ // First, try direct hostname match - #110515#
+ //////////////////////////////////////////////////////////////////
+
+ if ( !shouldUseProxy( rHost, nPort, false ) )
+ return m_aEmptyProxy;
+
+ //////////////////////////////////////////////////////////////////
+ // Second, try match against full qualified hostname - #104401#
+ //////////////////////////////////////////////////////////////////
+
+ rtl::OUString aHost;
+
+ if ( ( rHost[ 0 ] == sal_Unicode( '[' ) ) &&
+ ( rHost.getLength() > 1 ) )
+ {
+ // host is given as numeric IPv6 address. name resolution
+ // functions need hostname without square brackets.
+ aHost = rHost.copy( 1, rHost.getLength() - 2 );
+ }
+ else
+ {
+ aHost = rHost;
+ }
+
+ rtl::OUString aFullyQualifiedHost;
+ if ( !m_aHostnames.get( aHost, aFullyQualifiedHost ) )
+ {
+ // This might be quite expensive (DNS lookup).
+ const osl::SocketAddr aAddr( aHost, nPort );
+ aFullyQualifiedHost = aAddr.getHostname().toAsciiLowerCase();
+ m_aHostnames.put( aHost, aFullyQualifiedHost );
+ }
+
+ // Error resolving name? -> fallback.
+ if ( !aFullyQualifiedHost.getLength() )
+ aFullyQualifiedHost = aHost;
+
+ if ( aFullyQualifiedHost != aHost )
+ {
+ if ( !shouldUseProxy( aFullyQualifiedHost, nPort, false ) )
+ return m_aEmptyProxy;
+ }
+
+ //////////////////////////////////////////////////////////////////
+ // Third, try match of fully qualified entries in no-proxy list
+ // against full qualified hostname
+ //
+ // Example:
+ // list: staroffice-doc -> full: xyz.germany.sun.com
+ // in: staroffice-doc.germany.sun.com -> full: xyz.germany.sun.com
+ //
+ //////////////////////////////////////////////////////////////////
+
+ if ( !shouldUseProxy( aFullyQualifiedHost, nPort, true ) )
+ return m_aEmptyProxy;
+ }
+
+ if ( rProtocol.toAsciiLowerCase()
+ .equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ftp" ) ) )
+ {
+ if ( m_aFtpProxy.aName.getLength() > 0 && m_aFtpProxy.nPort >= 0 )
+ return m_aFtpProxy;
+ }
+ else if ( m_aHttpProxy.aName.getLength() )
+ {
+ // All other protocols use the HTTP proxy.
+ return m_aHttpProxy;
+ }
+ return m_aEmptyProxy;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InternetProxyDecider_Impl::changesOccurred(
+ const util::ChangesEvent& Event )
+ throw( uno::RuntimeException )
+{
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+
+ sal_Int32 nCount = Event.Changes.getLength();
+ if ( nCount )
+ {
+ const util::ElementChange* pElementChanges
+ = Event.Changes.getConstArray();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const util::ElementChange& rElem = pElementChanges[ n ];
+ rtl::OUString aKey;
+ if ( ( rElem.Accessor >>= aKey ) && aKey.getLength() )
+ {
+ if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ PROXY_TYPE_KEY ) ) )
+ {
+ if ( !( rElem.Element >>= m_nProxyType ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - changesOccurred - "
+ "Error getting config item value!" );
+ }
+ }
+ else if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ NO_PROXY_LIST_KEY ) ) )
+ {
+ rtl::OUString aNoProxyList;
+ if ( !( rElem.Element >>= aNoProxyList ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - changesOccurred - "
+ "Error getting config item value!" );
+ }
+
+ setNoProxyList( aNoProxyList );
+ }
+ else if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ HTTP_PROXY_NAME_KEY ) ) )
+ {
+ if ( !( rElem.Element >>= m_aHttpProxy.aName ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - changesOccurred - "
+ "Error getting config item value!" );
+ }
+ }
+ else if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ HTTP_PROXY_PORT_KEY ) ) )
+ {
+ if ( !( rElem.Element >>= m_aHttpProxy.nPort ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - changesOccurred - "
+ "Error getting config item value!" );
+ }
+
+ if ( m_aHttpProxy.nPort == -1 )
+ m_aHttpProxy.nPort = 80; // standard HTTP port.
+ }
+ else if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ FTP_PROXY_NAME_KEY ) ) )
+ {
+ if ( !( rElem.Element >>= m_aFtpProxy.aName ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - changesOccurred - "
+ "Error getting config item value!" );
+ }
+ }
+ else if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ FTP_PROXY_PORT_KEY ) ) )
+ {
+ if ( !( rElem.Element >>= m_aFtpProxy.nPort ) )
+ {
+ OSL_ENSURE( sal_False,
+ "InternetProxyDecider - changesOccurred - "
+ "Error getting config item value!" );
+ }
+ }
+ }
+ }
+ }
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL InternetProxyDecider_Impl::disposing(const lang::EventObject&)
+ throw( uno::RuntimeException )
+{
+ if ( m_xNotifier.is() )
+ {
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+
+ if ( m_xNotifier.is() )
+ m_xNotifier.clear();
+ }
+}
+
+//=========================================================================
+void InternetProxyDecider_Impl::setNoProxyList(
+ const rtl::OUString & rNoProxyList )
+{
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+
+ m_aNoProxyList.clear();
+
+ if ( rNoProxyList.getLength() )
+ {
+ // List of connection endpoints hostname[:port],
+ // separated by semicolon. Wilcards allowed.
+
+ sal_Int32 nPos = 0;
+ sal_Int32 nEnd = rNoProxyList.indexOf( ';' );
+ sal_Int32 nLen = rNoProxyList.getLength();
+
+ do
+ {
+ if ( nEnd == -1 )
+ nEnd = nLen;
+
+ rtl::OUString aToken = rNoProxyList.copy( nPos, nEnd - nPos );
+
+ if ( aToken.getLength() )
+ {
+ rtl::OUString aServer;
+ rtl::OUString aPort;
+
+ // numerical IPv6 address?
+ bool bIPv6Address = false;
+ sal_Int32 nClosedBracketPos = aToken.indexOf( ']' );
+ if ( nClosedBracketPos == -1 )
+ nClosedBracketPos = 0;
+ else
+ bIPv6Address = true;
+
+ sal_Int32 nColonPos = aToken.indexOf( ':', nClosedBracketPos );
+ if ( nColonPos == -1 )
+ {
+ // No port given, server pattern equals current token
+ aPort = rtl::OUString::createFromAscii( "*" );
+ if ( aToken.indexOf( '*' ) == -1 )
+ {
+ // pattern describes exactly one server
+ aServer = aToken;
+ }
+
+ aToken += rtl::OUString::createFromAscii( ":*" );
+ }
+ else
+ {
+ // Port given, extract server pattern
+ sal_Int32 nAsterixPos = aToken.indexOf( '*' );
+ aPort = aToken.copy( nColonPos + 1 );
+ if ( nAsterixPos < nColonPos )
+ {
+ // pattern describes exactly one server
+ aServer = aToken.copy( 0, nColonPos );
+ }
+ }
+
+ rtl::OUStringBuffer aFullyQualifiedHost;
+ if ( aServer.getLength() )
+ {
+ // Remember fully qualified server name if current list
+ // entry specifies exactly one non-fully qualified server
+ // name.
+
+ // remove square brackets from host name in case it's
+ // a numerical IPv6 address.
+ if ( bIPv6Address )
+ aServer = aServer.copy( 1, aServer.getLength() - 2 );
+
+ // This might be quite expensive (DNS lookup).
+ const osl::SocketAddr aAddr( aServer, 0 );
+ rtl::OUString aTmp = aAddr.getHostname().toAsciiLowerCase();
+ if ( aTmp != aServer.toAsciiLowerCase() )
+ {
+ if ( bIPv6Address )
+ {
+ aFullyQualifiedHost.appendAscii( "[" );
+ aFullyQualifiedHost.append( aTmp );
+ aFullyQualifiedHost.appendAscii( "]" );
+ }
+ else
+ {
+ aFullyQualifiedHost.append( aTmp );
+ }
+ aFullyQualifiedHost.appendAscii( ":" );
+ aFullyQualifiedHost.append( aPort );
+ }
+ }
+
+ m_aNoProxyList.push_back(
+ NoProxyListEntry( WildCard( aToken ),
+ WildCard(
+ aFullyQualifiedHost
+ .makeStringAndClear() ) ) );
+ }
+
+ if ( nEnd != nLen )
+ {
+ nPos = nEnd + 1;
+ nEnd = rNoProxyList.indexOf( ';', nPos );
+ }
+ }
+ while ( nEnd != nLen );
+ }
+}
+
+} // namespace proxydecider_impl
+
+//=========================================================================
+//=========================================================================
+//
+// InternetProxyDecider Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+InternetProxyDecider::InternetProxyDecider(
+ const uno::Reference< lang::XMultiServiceFactory >& rxSMgr )
+: m_pImpl( new proxydecider_impl::InternetProxyDecider_Impl( rxSMgr ) )
+{
+ m_pImpl->acquire();
+}
+
+//=========================================================================
+InternetProxyDecider::~InternetProxyDecider()
+{
+ // Break circular reference between config listener and notifier.
+ m_pImpl->dispose();
+
+ // Let him go...
+ m_pImpl->release();
+}
+
+//=========================================================================
+bool InternetProxyDecider::shouldUseProxy( const rtl::OUString & rProtocol,
+ const rtl::OUString & rHost,
+ sal_Int32 nPort ) const
+{
+ const InternetProxyServer & rData = m_pImpl->getProxy( rProtocol,
+ rHost,
+ nPort );
+ return ( rData.aName.getLength() > 0 );
+}
+
+//=========================================================================
+const InternetProxyServer & InternetProxyDecider::getProxy(
+ const rtl::OUString & rProtocol,
+ const rtl::OUString & rHost,
+ sal_Int32 nPort ) const
+{
+ return m_pImpl->getProxy( rProtocol, rHost, nPort );
+}
+
+} // namespace ucbhelper
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 );
+}
+