summaryrefslogtreecommitdiff
path: root/ucb/source
diff options
context:
space:
mode:
authorKai Sommerfeld <kso@openoffice.org>2000-10-16 13:56:13 +0000
committerKai Sommerfeld <kso@openoffice.org>2000-10-16 13:56:13 +0000
commitd3329bacd8a925ec070ad06ea3d9a6a026a3696b (patch)
treecd3503c80360b6d21e0cf4a615967f3357a4d3c8 /ucb/source
parent4ab353132a0d57510151f9844d8c2012feca0dad (diff)
Moved here from module 'chaos'.
Diffstat (limited to 'ucb/source')
-rw-r--r--ucb/source/cacher/cachedcontentresultset.cxx2221
-rw-r--r--ucb/source/cacher/cachedcontentresultset.hxx560
-rw-r--r--ucb/source/cacher/cachedcontentresultsetstub.cxx450
-rw-r--r--ucb/source/cacher/cachedcontentresultsetstub.hxx229
-rw-r--r--ucb/source/cacher/cacheddynamicresultset.cxx242
-rw-r--r--ucb/source/cacher/cacheddynamicresultset.hxx179
-rw-r--r--ucb/source/cacher/cacheddynamicresultsetstub.cxx278
-rw-r--r--ucb/source/cacher/cacheddynamicresultsetstub.hxx175
-rw-r--r--ucb/source/cacher/cacheserv.cxx235
-rw-r--r--ucb/source/cacher/contentresultsetwrapper.cxx1472
-rw-r--r--ucb/source/cacher/contentresultsetwrapper.hxx649
-rw-r--r--ucb/source/cacher/dynamicresultsetwrapper.cxx566
-rw-r--r--ucb/source/cacher/dynamicresultsetwrapper.hxx295
-rw-r--r--ucb/source/cacher/makefile.mk131
-rw-r--r--ucb/source/core/identify.cxx149
-rw-r--r--ucb/source/core/identify.hxx116
-rw-r--r--ucb/source/core/makefile.mk132
-rw-r--r--ucb/source/core/providermap.hxx117
-rw-r--r--ucb/source/core/provprox.cxx409
-rw-r--r--ucb/source/core/provprox.hxx221
-rw-r--r--ucb/source/core/ucb.cxx631
-rw-r--r--ucb/source/core/ucb.hxx198
-rw-r--r--ucb/source/core/ucbprops.cxx539
-rw-r--r--ucb/source/core/ucbprops.hxx143
-rw-r--r--ucb/source/core/ucbserv.cxx279
-rw-r--r--ucb/source/core/ucbstore.cxx2346
-rw-r--r--ucb/source/core/ucbstore.hxx427
-rw-r--r--ucb/source/inc/regexp.hxx123
-rw-r--r--ucb/source/inc/regexpmap.hxx226
-rw-r--r--ucb/source/inc/regexpmap.tpt597
-rw-r--r--ucb/source/regexp/makefile.mk76
-rw-r--r--ucb/source/regexp/regexp.cxx509
-rw-r--r--ucb/source/sorter/makefile.mk135
-rw-r--r--ucb/source/sorter/sortdynres.cxx665
-rw-r--r--ucb/source/sorter/sortdynres.hxx325
-rw-r--r--ucb/source/sorter/sortmain.cxx172
-rw-r--r--ucb/source/sorter/sortresult.cxx2027
-rw-r--r--ucb/source/sorter/sortresult.hxx497
-rw-r--r--ucb/source/ucp/file/bc.cxx1286
-rw-r--r--ucb/source/ucp/file/bc.hxx414
-rw-r--r--ucb/source/ucp/file/filglob.hxx92
-rw-r--r--ucb/source/ucp/file/filid.cxx192
-rw-r--r--ucb/source/ucp/file/filid.hxx144
-rw-r--r--ucb/source/ucp/file/filinl.hxx115
-rw-r--r--ucb/source/ucp/file/filnot.cxx324
-rw-r--r--ucb/source/ucp/file/filnot.hxx183
-rw-r--r--ucb/source/ucp/file/filprp.cxx179
-rw-r--r--ucb/source/ucp/file/filprp.hxx131
-rw-r--r--ucb/source/ucp/file/filrow.cxx453
-rw-r--r--ucb/source/ucp/file/filrow.hxx239
-rw-r--r--ucb/source/ucp/file/filrset.cxx959
-rw-r--r--ucb/source/ucp/file/filrset.hxx736
-rw-r--r--ucb/source/ucp/file/filtask.cxx138
-rw-r--r--ucb/source/ucp/file/filtask.hxx150
-rw-r--r--ucb/source/ucp/file/makefile.mk130
-rw-r--r--ucb/source/ucp/file/prov.cxx780
-rw-r--r--ucb/source/ucp/file/prov.hxx254
-rw-r--r--ucb/source/ucp/file/shell.cxx3121
-rw-r--r--ucb/source/ucp/file/shell.hxx526
-rw-r--r--ucb/source/ucp/hierarchy/dynamicresultset.cxx129
-rw-r--r--ucb/source/ucp/hierarchy/dynamicresultset.hxx96
-rw-r--r--ucb/source/ucp/hierarchy/hierarchycontent.cxx1641
-rw-r--r--ucb/source/ucp/hierarchy/hierarchycontent.hxx299
-rw-r--r--ucb/source/ucp/hierarchy/hierarchycontentcaps.cxx509
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydata.cxx1129
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydata.hxx165
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydatasupplier.cxx490
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydatasupplier.hxx119
-rw-r--r--ucb/source/ucp/hierarchy/hierarchyprovider.cxx196
-rw-r--r--ucb/source/ucp/hierarchy/hierarchyprovider.hxx125
-rw-r--r--ucb/source/ucp/hierarchy/hierarchyservices.cxx173
-rw-r--r--ucb/source/ucp/hierarchy/makefile.mk126
-rw-r--r--ucb/source/ucp/hierarchy/ucphier.map8
-rw-r--r--ucb/source/ucp/webdav/DAVAuthListener.hxx95
-rw-r--r--ucb/source/ucp/webdav/DAVException.hxx88
-rw-r--r--ucb/source/ucp/webdav/DAVProperties.cxx86
-rw-r--r--ucb/source/ucp/webdav/DAVProperties.hxx86
-rw-r--r--ucb/source/ucp/webdav/DAVResource.hxx89
-rw-r--r--ucb/source/ucp/webdav/DAVSession.hxx151
-rw-r--r--ucb/source/ucp/webdav/DAVSessionFactory.cxx113
-rw-r--r--ucb/source/ucp/webdav/DAVSessionFactory.hxx89
-rw-r--r--ucb/source/ucp/webdav/DAVTypes.hxx96
-rw-r--r--ucb/source/ucp/webdav/DateTimeHelper.cxx207
-rw-r--r--ucb/source/ucp/webdav/DateTimeHelper.hxx87
-rw-r--r--ucb/source/ucp/webdav/NeonInputStream.cxx181
-rw-r--r--ucb/source/ucp/webdav/NeonInputStream.hxx143
-rw-r--r--ucb/source/ucp/webdav/NeonPropFindRequest.cxx270
-rw-r--r--ucb/source/ucp/webdav/NeonPropFindRequest.hxx106
-rw-r--r--ucb/source/ucp/webdav/NeonSession.cxx543
-rw-r--r--ucb/source/ucp/webdav/NeonSession.hxx202
-rw-r--r--ucb/source/ucp/webdav/NeonTypes.hxx90
-rw-r--r--ucb/source/ucp/webdav/NeonUri.cxx141
-rw-r--r--ucb/source/ucp/webdav/NeonUri.hxx117
-rw-r--r--ucb/source/ucp/webdav/exports.map8
-rw-r--r--ucb/source/ucp/webdav/makefile.mk169
-rw-r--r--ucb/source/ucp/webdav/webdavcontent.cxx1574
-rw-r--r--ucb/source/ucp/webdav/webdavcontent.hxx292
-rw-r--r--ucb/source/ucp/webdav/webdavcontentcaps.cxx373
-rw-r--r--ucb/source/ucp/webdav/webdavdatasupplier.cxx426
-rw-r--r--ucb/source/ucp/webdav/webdavdatasupplier.hxx115
-rw-r--r--ucb/source/ucp/webdav/webdavprovider.cxx216
-rw-r--r--ucb/source/ucp/webdav/webdavprovider.hxx128
-rw-r--r--ucb/source/ucp/webdav/webdavresultset.cxx130
-rw-r--r--ucb/source/ucp/webdav/webdavresultset.hxx102
-rw-r--r--ucb/source/ucp/webdav/webdavservices.cxx173
105 files changed, 41178 insertions, 0 deletions
diff --git a/ucb/source/cacher/cachedcontentresultset.cxx b/ucb/source/cacher/cachedcontentresultset.cxx
new file mode 100644
index 000000000000..bced7b5dba08
--- /dev/null
+++ b/ucb/source/cacher/cachedcontentresultset.cxx
@@ -0,0 +1,2221 @@
+/*************************************************************************
+ *
+ * $RCSfile: cachedcontentresultset.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <cachedcontentresultset.hxx>
+
+#ifndef _COM_SUN_STAR_SDBC_FETCHDIRECTION_HPP_
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_FETCHERROR_HPP_
+#include <com/sun/star/ucb/FetchError.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::util;
+using namespace cppu;
+using namespace rtl;
+
+#define COMSUNSTARUCBCCRS_DEFAULT_FETCH_SIZE 256
+#define COMSUNSTARUCBCCRS_DEFAULT_FETCH_DIRECTION FetchDirection::FORWARD
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+//define for getXXX methods of interface XRow
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+//if you change this macro please pay attention to
+//function ::getObject, where this is similar implemented
+
+#define XROW_GETXXX( getXXX, Type ) \
+impl_EnsureNotDisposed(); \
+ReacquireableGuard aGuard( m_aMutex ); \
+sal_Int32 nRow = m_nRow; \
+sal_Int32 nFetchSize = m_nFetchSize; \
+sal_Int32 nFetchDirection = m_nFetchDirection; \
+if( !m_aCache.hasRow( nRow ) ) \
+{ \
+ if( !m_aCache.hasCausedException( nRow ) ) \
+{ \
+ if( !m_xFetchProvider.is() ) \
+ { \
+ DBG_ERROR( "broadcaster was disposed already" ); \
+ throw SQLException(); \
+ } \
+ aGuard.clear(); \
+ if( impl_isForwardOnly() ) \
+ applyPositionToOrigin( nRow ); \
+ \
+ impl_fetchData( nRow, nFetchSize, nFetchDirection ); \
+ } \
+ aGuard.reacquire(); \
+ if( !m_aCache.hasRow( nRow ) ) \
+ { \
+ m_bLastReadWasFromCache = sal_False; \
+ aGuard.clear(); \
+ applyPositionToOrigin( nRow ); \
+ return m_xRowOrigin->getXXX( columnIndex ); \
+ } \
+} \
+const Any& rValue = m_aCache.getAny( nRow, columnIndex );\
+Type aRet; \
+m_bLastReadWasFromCache = sal_True; \
+m_bLastCachedReadWasNull = !( rValue >>= aRet ); \
+return aRet;
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// CCRS_Cache methoeds.
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+CachedContentResultSet::CCRS_Cache::CCRS_Cache(
+ const Reference< XContentIdentifierMapping > & xMapping )
+ : m_pResult( NULL )
+ , m_xContentIdentifierMapping( xMapping )
+ , m_pMappedReminder( NULL )
+{
+}
+
+CachedContentResultSet::CCRS_Cache::~CCRS_Cache()
+{
+ delete m_pResult;
+}
+
+void SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::clear()
+{
+ if( m_pResult )
+ {
+ delete m_pResult;
+ m_pResult = NULL;
+ }
+ clearMappedReminder();
+}
+
+void SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::loadData( const FetchResult& rResult )
+{
+ clear();
+ m_pResult = new FetchResult( rResult );
+}
+
+sal_Bool SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::hasRow( sal_Int32 row )
+{
+ if( !m_pResult )
+ return FALSE;
+ long nStart = m_pResult->StartIndex;
+ long nEnd = nStart;
+ if( m_pResult->Orientation )
+ nEnd += m_pResult->Rows.getLength() - 1;
+ else
+ nStart -= m_pResult->Rows.getLength() + 1;
+
+ return nStart <= row && row <= nEnd;
+}
+
+sal_Int32 SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::getMaxRow()
+{
+ if( !m_pResult )
+ return 0;
+ long nEnd = m_pResult->StartIndex;
+ if( m_pResult->Orientation )
+ return nEnd += m_pResult->Rows.getLength() - 1;
+ else
+ return nEnd;
+}
+
+sal_Bool SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::hasKnownLast()
+{
+ if( !m_pResult )
+ return sal_False;
+
+ if( ( m_pResult->FetchError & FetchError::ENDOFDATA )
+ && m_pResult->Orientation
+ && m_pResult->Rows.getLength() )
+ return sal_True;
+
+ return sal_False;
+}
+
+sal_Bool SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::hasCausedException( sal_Int32 nRow )
+{
+ if( !m_pResult )
+ return FALSE;
+ if( !( m_pResult->FetchError & FetchError::EXCEPTION ) )
+ return FALSE;
+
+ long nEnd = m_pResult->StartIndex;
+ if( m_pResult->Orientation )
+ nEnd += m_pResult->Rows.getLength();
+
+ return nRow == nEnd+1;
+}
+
+Any& SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::getRowAny( sal_Int32 nRow )
+ throw( SQLException,
+ RuntimeException )
+{
+ if( !nRow )
+ throw SQLException();
+ if( !m_pResult )
+ throw SQLException();
+ if( !hasRow( nRow ) )
+ throw SQLException();
+
+ long nDiff = nRow - m_pResult->StartIndex;
+ if( nDiff < 0 )
+ nDiff *= -1;
+
+ return (m_pResult->Rows)[nDiff];
+}
+
+void SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::remindMapped( sal_Int32 nRow )
+{
+ //remind that this row was mapped
+ if( !m_pResult )
+ return;
+ long nDiff = nRow - m_pResult->StartIndex;
+ if( nDiff < 0 )
+ nDiff *= -1;
+ Sequence< sal_Bool >* pMappedReminder = getMappedReminder();
+ if( nDiff < pMappedReminder->getLength() )
+ (*pMappedReminder)[nDiff] = sal_True;
+}
+
+sal_Bool SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::isRowMapped( sal_Int32 nRow )
+{
+ if( !m_pMappedReminder || !m_pResult )
+ return sal_False;
+ long nDiff = nRow - m_pResult->StartIndex;
+ if( nDiff < 0 )
+ nDiff *= -1;
+ if( nDiff < m_pMappedReminder->getLength() )
+ return (*m_pMappedReminder)[nDiff];
+ return sal_False;
+}
+
+void SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::clearMappedReminder()
+{
+ delete m_pMappedReminder;
+ m_pMappedReminder = NULL;
+}
+
+Sequence< sal_Bool >* SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::getMappedReminder()
+{
+ if( !m_pMappedReminder )
+ {
+ sal_Int32 nCount = m_pResult->Rows.getLength();
+ m_pMappedReminder = new Sequence< sal_Bool >( nCount );
+ for( nCount; nCount--; )
+ (*m_pMappedReminder)[nCount] = sal_False;
+ }
+ return m_pMappedReminder;
+}
+
+const Any& SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::getAny( sal_Int32 nRow, sal_Int32 nColumnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ if( !nColumnIndex )
+ throw SQLException();
+ if( m_xContentIdentifierMapping.is() && !isRowMapped( nRow ) )
+ {
+ Any& rRow = getRowAny( nRow );
+ Sequence< Any > aValue;
+ rRow >>= aValue;
+ if( m_xContentIdentifierMapping->mapRow( aValue ) )
+ {
+ rRow <<= aValue;
+ remindMapped( nRow );
+ }
+ else
+ m_xContentIdentifierMapping.clear();
+ }
+ const Sequence< Any >& rRow =
+ (* reinterpret_cast< const Sequence< Any > * >
+ (getRowAny( nRow ).getValue() ));
+
+ sal_Int32 nTest = rRow.getLength();
+ if( nColumnIndex > rRow.getLength() )
+ throw SQLException();
+ return rRow[nColumnIndex-1];
+}
+
+const rtl::OUString& SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::getContentIdentifierString( sal_Int32 nRow )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ try
+ {
+ if( m_xContentIdentifierMapping.is() && !isRowMapped( nRow ) )
+ {
+ Any& rRow = getRowAny( nRow );
+ rtl::OUString aValue;
+ rRow >>= aValue;
+ rRow <<= m_xContentIdentifierMapping->mapContentIdentifierString( aValue );
+ remindMapped( nRow );
+ }
+ return (* reinterpret_cast< const rtl::OUString * >
+ (getRowAny( nRow ).getValue() ));
+ }
+ catch( SQLException )
+ {
+ throw RuntimeException();
+ }
+}
+
+const Reference< XContentIdentifier >& SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::getContentIdentifier( sal_Int32 nRow )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ try
+ {
+ if( m_xContentIdentifierMapping.is() && !isRowMapped( nRow ) )
+ {
+ Any& rRow = getRowAny( nRow );
+ Reference< XContentIdentifier > aValue;
+ rRow >>= aValue;
+ rRow <<= m_xContentIdentifierMapping->mapContentIdentifier( aValue );
+ remindMapped( nRow );
+ }
+ return (* reinterpret_cast< const Reference< XContentIdentifier > * >
+ (getRowAny( nRow ).getValue() ));
+ }
+ catch( SQLException )
+ {
+ throw RuntimeException();
+ }
+}
+
+const Reference< XContent >& SAL_CALL CachedContentResultSet::CCRS_Cache
+ ::getContent( sal_Int32 nRow )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ try
+ {
+ if( m_xContentIdentifierMapping.is() && !isRowMapped( nRow ) )
+ {
+ Any& rRow = getRowAny( nRow );
+ Reference< XContent > aValue;
+ rRow >>= aValue;
+ rRow <<= m_xContentIdentifierMapping->mapContent( aValue );
+ remindMapped( nRow );
+ }
+ return (* reinterpret_cast< const Reference< XContent > * >
+ (getRowAny( nRow ).getValue() ));
+ }
+ catch( SQLException )
+ {
+ throw RuntimeException();
+ }
+}
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// class CCRS_PropertySetInfo
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+class CCRS_PropertySetInfo :
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XTypeProvider,
+ public com::sun::star::beans::XPropertySetInfo
+{
+friend CachedContentResultSet;
+ //my Properties
+ Sequence< com::sun::star::beans::Property >*
+ m_pProperties;
+
+ //some helping variables ( names for my special properties )
+ static rtl::OUString m_aPropertyNameForCount;
+ static rtl::OUString m_aPropertyNameForFinalCount;
+ static rtl::OUString m_aPropertyNameForFetchSize;
+ static rtl::OUString m_aPropertyNameForFetchDirection;
+
+ long m_nFetchSizePropertyHandle;
+ long m_nFetchDirectionPropertyHandle;
+
+private:
+ sal_Int32 SAL_CALL
+ impl_getRemainedHandle() const;
+
+ sal_Bool SAL_CALL
+ impl_queryProperty(
+ const rtl::OUString& rName
+ , com::sun::star::beans::Property& rProp ) const;
+ sal_Int32 SAL_CALL
+ impl_getPos( const rtl::OUString& rName ) const;
+
+ static sal_Bool SAL_CALL
+ impl_isMyPropertyName( const rtl::OUString& rName );
+
+public:
+ CCRS_PropertySetInfo( Reference<
+ XPropertySetInfo > xPropertySetInfoOrigin );
+
+ virtual ~CCRS_PropertySetInfo();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XPropertySetInfo
+ virtual Sequence< com::sun::star::beans::Property > SAL_CALL
+ getProperties()
+ throw( RuntimeException );
+
+ virtual com::sun::star::beans::Property SAL_CALL
+ getPropertyByName( const rtl::OUString& aName )
+ throw( com::sun::star::beans::UnknownPropertyException, RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ hasPropertyByName( const rtl::OUString& Name )
+ throw( RuntimeException );
+};
+
+OUString CCRS_PropertySetInfo::m_aPropertyNameForCount( OUString::createFromAscii( "RowCount" ) );
+OUString CCRS_PropertySetInfo::m_aPropertyNameForFinalCount( OUString::createFromAscii( "IsRowCountFinal" ) );
+OUString CCRS_PropertySetInfo::m_aPropertyNameForFetchSize( OUString::createFromAscii( "FetchSize" ) );
+OUString CCRS_PropertySetInfo::m_aPropertyNameForFetchDirection( OUString::createFromAscii( "FetchDirection" ) );
+
+CCRS_PropertySetInfo::CCRS_PropertySetInfo(
+ Reference< XPropertySetInfo > xInfo )
+ : m_pProperties( NULL )
+ , m_nFetchSizePropertyHandle( -1 )
+ , m_nFetchDirectionPropertyHandle( -1 )
+{
+ //initialize list of properties:
+
+ // it is required, that the received xInfo contains the two
+ // properties with names 'm_aPropertyNameForCount' and
+ // 'm_aPropertyNameForFinalCount'
+
+ if( xInfo.is() )
+ {
+ Sequence<Property> aProps = xInfo->getProperties();
+ m_pProperties = new Sequence<Property> ( aProps );
+ }
+ else
+ {
+ DBG_ERROR( "The received XPropertySetInfo doesn't contain required properties" );
+ m_pProperties = new Sequence<Property>;
+ }
+
+ //ensure, that we haven't got the Properties 'FetchSize' and 'Direction' twice:
+ sal_Int32 nFetchSize = impl_getPos( m_aPropertyNameForFetchSize );
+ sal_Int32 nFetchDirection = impl_getPos( m_aPropertyNameForFetchDirection );
+ sal_Int32 nDeleted = 0;
+ if( nFetchSize != -1 )
+ nDeleted++;
+ if( nFetchDirection != -1 )
+ nDeleted++;
+
+ Sequence< Property >* pOrigProps = new Sequence<Property> ( *m_pProperties );
+ sal_Int32 nOrigProps = pOrigProps->getLength();
+
+ m_pProperties->realloc( nOrigProps + 2 - nDeleted );//note that nDeleted is <= 2
+ for( sal_Int32 n = 0, m = 0; n < nOrigProps; n++, m++ )
+ {
+ if( n == nFetchSize || n == nFetchDirection )
+ m--;
+ else
+ (*m_pProperties)[ m ] = (*pOrigProps)[ n ];
+ }
+ {
+ Property& rMyProp = (*m_pProperties)[ nOrigProps - nDeleted ];
+ rMyProp.Name = m_aPropertyNameForFetchSize;
+ rMyProp.Type = getCppuType( static_cast< const sal_Int32 * >( 0 ) );
+ rMyProp.Attributes = PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT;
+
+ if( nFetchSize != -1 )
+ m_nFetchSizePropertyHandle = (*pOrigProps)[nFetchSize].Handle;
+ else
+ m_nFetchSizePropertyHandle = impl_getRemainedHandle();
+
+ rMyProp.Handle = m_nFetchSizePropertyHandle;
+
+ }
+ {
+ Property& rMyProp = (*m_pProperties)[ nOrigProps - nDeleted + 1 ];
+ rMyProp.Name = m_aPropertyNameForFetchDirection;
+ rMyProp.Type = getCppuType( static_cast< const sal_Bool * >( 0 ) );
+ rMyProp.Attributes = PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT;
+
+ if( nFetchSize != -1 )
+ m_nFetchDirectionPropertyHandle = (*pOrigProps)[nFetchDirection].Handle;
+ else
+ m_nFetchDirectionPropertyHandle = impl_getRemainedHandle();
+
+ m_nFetchDirectionPropertyHandle = rMyProp.Handle;
+ }
+ delete pOrigProps;
+}
+
+CCRS_PropertySetInfo::~CCRS_PropertySetInfo()
+{
+ delete m_pProperties;
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods.
+//--------------------------------------------------------------------------
+//list all interfaces inclusive baseclasses of interfaces
+XINTERFACE_IMPL_2( CCRS_PropertySetInfo
+ , XTypeProvider
+ , XPropertySetInfo
+ );
+
+//--------------------------------------------------------------------------
+// XTypeProvider methods.
+//--------------------------------------------------------------------------
+//list all interfaces exclusive baseclasses
+XTYPEPROVIDER_IMPL_2( CCRS_PropertySetInfo
+ , XTypeProvider
+ , XPropertySetInfo
+ );
+//--------------------------------------------------------------------------
+// XPropertySetInfo methods.
+//--------------------------------------------------------------------------
+//virtual
+Sequence< Property > SAL_CALL CCRS_PropertySetInfo
+ ::getProperties() throw( RuntimeException )
+{
+ return *m_pProperties;
+}
+
+//virtual
+Property SAL_CALL CCRS_PropertySetInfo
+ ::getPropertyByName( const rtl::OUString& aName )
+ throw( UnknownPropertyException, RuntimeException )
+{
+ if ( !aName.getLength() )
+ throw UnknownPropertyException();
+
+ Property aProp;
+ if ( impl_queryProperty( aName, aProp ) )
+ return aProp;
+
+ throw UnknownPropertyException();
+}
+
+//virtual
+sal_Bool SAL_CALL CCRS_PropertySetInfo
+ ::hasPropertyByName( const rtl::OUString& Name )
+ throw( RuntimeException )
+{
+ return ( impl_getPos( Name ) != -1 );
+}
+
+//--------------------------------------------------------------------------
+// impl_ methods.
+//--------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL CCRS_PropertySetInfo
+ ::impl_getPos( const OUString& rName ) const
+{
+ for( sal_Int32 nN = m_pProperties->getLength(); nN--; )
+ {
+ const Property& rMyProp = (*m_pProperties)[nN];
+ if( rMyProp.Name == rName )
+ return nN;
+ }
+ return -1;
+}
+
+sal_Bool SAL_CALL CCRS_PropertySetInfo
+ ::impl_queryProperty( const OUString& rName, Property& rProp ) const
+{
+ for( sal_Int32 nN = m_pProperties->getLength(); nN--; )
+ {
+ const Property& rMyProp = (*m_pProperties)[nN];
+ if( rMyProp.Name == rName )
+ {
+ rProp.Name = rMyProp.Name;
+ rProp.Handle = rMyProp.Handle;
+ rProp.Type = rMyProp.Type;
+ rProp.Attributes = rMyProp.Attributes;
+
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+//static
+sal_Bool SAL_CALL CCRS_PropertySetInfo
+ ::impl_isMyPropertyName( const OUString& rPropertyName )
+{
+ return ( rPropertyName == m_aPropertyNameForCount
+ || rPropertyName == m_aPropertyNameForFinalCount
+ || rPropertyName == m_aPropertyNameForFetchSize
+ || rPropertyName == m_aPropertyNameForFetchDirection );
+}
+
+sal_Int32 SAL_CALL CCRS_PropertySetInfo
+ ::impl_getRemainedHandle( ) const
+{
+ sal_Int32 nHandle = 1;
+
+ if( !m_pProperties )
+ {
+ DBG_ERROR( "Properties not initialized yet" );
+ return nHandle;
+ }
+ sal_Bool bFound = TRUE;
+ while( bFound )
+ {
+ bFound = FALSE;
+ for( sal_Int32 nN = m_pProperties->getLength(); nN--; )
+ {
+ if( nHandle == (*m_pProperties)[nN].Handle )
+ {
+ bFound = TRUE;
+ nHandle++;
+ break;
+ }
+ }
+ }
+ return nHandle;
+}
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// class CachedContentResultSet
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+CachedContentResultSet::CachedContentResultSet( Reference< XResultSet > xOrigin
+ , Reference< XContentIdentifierMapping >
+ xContentIdentifierMapping )
+ : ContentResultSetWrapper( xOrigin )
+
+ , m_xFetchProvider( NULL )
+ , m_xFetchProviderForContentAccess( NULL )
+ , m_xContentIdentifierMapping( xContentIdentifierMapping )
+
+ , m_pMyPropSetInfo( NULL )
+ , m_xMyPropertySetInfo( NULL )
+
+ , m_nRow( 0 ) // Position is one-based. Zero means: before first element.
+ , m_nLastAppliedPos( 0 )
+ , m_bAfterLast( sal_False )
+ , m_bAfterLastApplied( sal_False )
+ , m_nKnownCount( 0 )
+ , m_bFinalCount( sal_False )
+ , m_nFetchSize(
+ COMSUNSTARUCBCCRS_DEFAULT_FETCH_SIZE )
+ , m_nFetchDirection(
+ COMSUNSTARUCBCCRS_DEFAULT_FETCH_DIRECTION )
+
+ , m_bLastReadWasFromCache( sal_False )
+ , m_bLastCachedReadWasNull( sal_True )
+ , m_aCache( m_xContentIdentifierMapping )
+ , m_aCacheContentIdentifierString( m_xContentIdentifierMapping )
+ , m_aCacheContentIdentifier( m_xContentIdentifierMapping )
+ , m_aCacheContent( m_xContentIdentifierMapping )
+{
+ m_xFetchProvider = Reference< XFetchProvider >( m_xResultSetOrigin, UNO_QUERY );
+ DBG_ASSERT( m_xFetchProvider.is(), "interface XFetchProvider is required" );
+
+ m_xFetchProviderForContentAccess = Reference< XFetchProviderForContentAccess >( m_xResultSetOrigin, UNO_QUERY );
+ DBG_ASSERT( m_xFetchProviderForContentAccess.is(), "interface XFetchProviderForContentAccess is required" );
+
+ impl_init();
+};
+
+CachedContentResultSet::~CachedContentResultSet()
+{
+ impl_deinit();
+ //do not delete m_pMyPropSetInfo, cause it is hold via reference
+};
+
+//--------------------------------------------------------------------------
+// impl_ methods.
+//--------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CachedContentResultSet
+ ::applyPositionToOrigin( sal_Int32 nRow )
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ //-------------------------------------------------------------------------
+ /**
+ @returns
+ <TRUE/> if the cursor is on a valid row; <FALSE/> if it is off
+ the result set.
+ */
+
+ ReacquireableGuard aGuard( m_aMutex );
+ DBG_ASSERT( nRow >= 0, "only positive values supported" );
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return sal_False;
+ }
+// DBG_ASSERT( nRow <= m_nKnownCount, "don't step into regions you don't know with this method" );
+
+ sal_Int32 nLastAppliedPos = m_nLastAppliedPos;
+ sal_Bool bAfterLastApplied = m_bAfterLastApplied;
+ sal_Bool bAfterLast = m_bAfterLast;
+ sal_Int32 nForwardOnly = m_nForwardOnly;
+
+ aGuard.clear();
+
+ if( bAfterLastApplied || nLastAppliedPos != nRow )
+ {
+ if( nForwardOnly == 1 )
+ {
+ if( bAfterLastApplied || bAfterLast || !nRow || nRow < nLastAppliedPos )
+ throw SQLException();
+
+ sal_Int32 nN = nRow - nLastAppliedPos;
+ for( sal_Int32 nM = 0; nN--; nM++ )
+ {
+ if( !m_xResultSetOrigin->next() )
+ break;
+ }
+
+ aGuard.reacquire();
+ m_nLastAppliedPos += nM;
+ m_bAfterLastApplied = nRow != m_nLastAppliedPos;
+ return nRow == m_nLastAppliedPos;
+ }
+
+ if( !nRow ) //absolute( 0 ) will throw exception
+ {
+ m_xResultSetOrigin->beforeFirst();
+
+ aGuard.reacquire();
+ m_nLastAppliedPos = 0;
+ m_bAfterLastApplied = sal_False;
+ return sal_False;
+ }
+ try
+ {
+ //move absolute, if !nLastAppliedPos
+ //because move relative would throw exception
+ if( !nLastAppliedPos || bAfterLast || bAfterLastApplied )
+ {
+ sal_Bool bValid = m_xResultSetOrigin->absolute( nRow );
+
+ aGuard.reacquire();
+ m_nLastAppliedPos = nRow;
+ m_bAfterLastApplied = !bValid;
+ return bValid;
+ }
+ else
+ {
+ sal_Bool bValid = m_xResultSetOrigin->relative( nRow - nLastAppliedPos );
+
+ aGuard.reacquire();
+ m_nLastAppliedPos += ( nRow - nLastAppliedPos );
+ m_bAfterLastApplied = !bValid;
+ return bValid;
+ }
+ }
+ catch( SQLException& rEx )
+ {
+ if( !bAfterLastApplied && !bAfterLast && nRow > nLastAppliedPos && impl_isForwardOnly() )
+ {
+ sal_Int32 nN = nRow - nLastAppliedPos;
+ for( sal_Int32 nM = 0; nN--; nM++ )
+ {
+ if( !m_xResultSetOrigin->next() )
+ break;
+ }
+
+ aGuard.reacquire();
+ m_nLastAppliedPos += nM;
+ m_bAfterLastApplied = nRow != m_nLastAppliedPos;
+ return nRow == m_nLastAppliedPos;
+ }
+ else
+ throw rEx;
+ }
+ }
+ else
+ return sal_True;
+};
+
+sal_Bool SAL_CALL CachedContentResultSet
+ ::applyPositionToOrigin()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ sal_Int32 nRow;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( m_bAfterLast )
+ throw SQLException();
+ nRow = m_nRow;
+ if( !nRow )
+ throw SQLException();
+ }
+ return applyPositionToOrigin( nRow );
+};
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+//define for fetching data
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+#define FETCH_XXX( aCache, fetchInterface, fetchMethod ) \
+sal_Bool bDirection = !!( \
+ nFetchDirection != FetchDirection::REVERSE ); \
+FetchResult aResult = \
+ fetchInterface->fetchMethod( nRow, nFetchSize, bDirection ); \
+vos::OClearableGuard aGuard( m_aMutex ); \
+aCache.loadData( aResult ); \
+sal_Int32 nMax = aCache.getMaxRow(); \
+sal_Int32 nCurCount = m_nKnownCount; \
+sal_Bool bIsFinalCount = aCache.hasKnownLast(); \
+sal_Bool bCurIsFinalCount = m_bFinalCount; \
+aGuard.clear(); \
+if( nMax > nCurCount ) \
+ impl_changeRowCount( nCurCount, nMax ); \
+if( bIsFinalCount && !bCurIsFinalCount ) \
+ impl_changeIsRowCountFinal( bCurIsFinalCount, bIsFinalCount );
+
+void SAL_CALL CachedContentResultSet
+ ::impl_fetchData( sal_Int32 nRow
+ , sal_Int32 nFetchSize, sal_Int32 nFetchDirection )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ FETCH_XXX( m_aCache, m_xFetchProvider, fetch );
+}
+
+void SAL_CALL CachedContentResultSet
+ ::impl_changeRowCount( sal_Int32 nOld, sal_Int32 nNew )
+{
+ DBG_ASSERT( nNew > nOld, "RowCount only can grow" );
+ if( nNew <= nOld )
+ return;
+
+ //create PropertyChangeEvent and set value
+ PropertyChangeEvent aEvt;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ aEvt.Source = static_cast< XPropertySet * >( this );
+ aEvt.Further = FALSE;
+ aEvt.OldValue <<= nOld;
+ aEvt.NewValue <<= nNew;
+
+ m_nKnownCount = nNew;
+ }
+
+ //send PropertyChangeEvent to listeners
+ impl_notifyPropertyChangeListeners( aEvt );
+}
+
+void SAL_CALL CachedContentResultSet
+ ::impl_changeIsRowCountFinal( sal_Bool bOld, sal_Bool bNew )
+{
+ DBG_ASSERT( !bOld && bNew, "This change is not allowed for IsRowCountFinal" );
+ if( ! (!bOld && bNew ) )
+ return;
+
+ //create PropertyChangeEvent and set value
+ PropertyChangeEvent aEvt;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ aEvt.Source = static_cast< XPropertySet * >( this );
+ aEvt.Further = FALSE;
+ aEvt.OldValue <<= bOld;
+ aEvt.NewValue <<= bNew;
+
+ m_bFinalCount = bNew;
+ }
+
+ //send PropertyChangeEvent to listeners
+ impl_notifyPropertyChangeListeners( aEvt );
+}
+
+sal_Bool SAL_CALL CachedContentResultSet
+ ::impl_isKnownValidPosition( sal_Int32 nRow )
+{
+ return m_nKnownCount && nRow
+ && nRow <= m_nKnownCount;
+}
+
+sal_Bool SAL_CALL CachedContentResultSet
+ ::impl_isKnownInvalidPosition( sal_Int32 nRow )
+{
+ if( !nRow )
+ return sal_True;
+ if( !m_bFinalCount )
+ return sal_False;
+ return nRow > m_nKnownCount;
+}
+
+
+//virtual
+void SAL_CALL CachedContentResultSet
+ ::impl_initPropertySetInfo()
+{
+ ContentResultSetWrapper::impl_initPropertySetInfo();
+
+ vos::OGuard aGuard( m_aMutex );
+ if( m_pMyPropSetInfo )
+ return;
+ m_pMyPropSetInfo = new CCRS_PropertySetInfo( m_xPropertySetInfo );
+ m_xMyPropertySetInfo = m_pMyPropSetInfo;
+ m_xPropertySetInfo = m_xMyPropertySetInfo;
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods. ( inherited )
+//--------------------------------------------------------------------------
+XINTERFACE_COMMON_IMPL( CachedContentResultSet )
+
+Any SAL_CALL CachedContentResultSet
+ ::queryInterface( const Type& rType )
+ throw ( RuntimeException )
+{
+ //list all interfaces inclusive baseclasses of interfaces
+
+ Any aRet = ContentResultSetWrapper::queryInterface( rType );
+ if( aRet.hasValue() )
+ return aRet;
+
+ aRet = cppu::queryInterface( rType,
+ static_cast< XTypeProvider* >( this ),
+ static_cast< XServiceInfo* >( this ) );
+
+ return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
+}
+
+//--------------------------------------------------------------------------
+// XTypeProvider methods.
+//--------------------------------------------------------------------------
+//list all interfaces exclusive baseclasses
+XTYPEPROVIDER_IMPL_11( CachedContentResultSet
+ , XTypeProvider
+ , XServiceInfo
+ , XComponent
+ , XCloseable
+ , XResultSetMetaDataSupplier
+ , XPropertySet
+
+ , XPropertyChangeListener
+ , XVetoableChangeListener
+
+ , XContentAccess
+
+ , XResultSet
+ , XRow );
+
+//--------------------------------------------------------------------------
+// XServiceInfo methods.
+//--------------------------------------------------------------------------
+
+XSERVICEINFO_NOFACTORY_IMPL_1( CachedContentResultSet,
+ OUString::createFromAscii( "CachedContentResultSet" ),
+ OUString::createFromAscii( CACHED_CONTENT_RESULTSET_SERVICE_NAME ) );
+
+//--------------------------------------------------------------------------
+// XPropertySet methods. ( inherited )
+//--------------------------------------------------------------------------
+
+// virtual
+void SAL_CALL CachedContentResultSet
+ ::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
+ throw( UnknownPropertyException,
+ PropertyVetoException,
+ IllegalArgumentException,
+ WrappedTargetException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !getPropertySetInfo().is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw UnknownPropertyException();
+ }
+
+ Property aProp = m_pMyPropSetInfo->getPropertyByName( aPropertyName );
+ //throws UnknownPropertyException, if so
+
+ if( aProp.Attributes & PropertyAttribute::READONLY )
+ {
+ //It is assumed, that the properties
+ //'RowCount' and 'IsRowCountFinal' are readonly!
+ throw IllegalArgumentException();
+ }
+ if( aProp.Name == CCRS_PropertySetInfo
+ ::m_aPropertyNameForFetchDirection )
+ {
+ //check value
+ sal_Int32 nNew;
+ if( !( aValue >>= nNew ) )
+ {
+ throw IllegalArgumentException();
+ }
+
+ if( nNew == FetchDirection::UNKNOWN )
+ {
+ nNew = COMSUNSTARUCBCCRS_DEFAULT_FETCH_DIRECTION;
+ }
+ else if( !( nNew == FetchDirection::FORWARD
+ || nNew == FetchDirection::REVERSE ) )
+ {
+ throw IllegalArgumentException();
+ }
+
+ //create PropertyChangeEvent and set value
+ PropertyChangeEvent aEvt;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ aEvt.Source = static_cast< XPropertySet * >( this );
+ aEvt.PropertyName = aPropertyName;
+ aEvt.Further = FALSE;
+ aEvt.PropertyHandle = m_pMyPropSetInfo->
+ m_nFetchDirectionPropertyHandle;
+ aEvt.OldValue <<= m_nFetchDirection;
+ aEvt.NewValue <<= nNew;
+
+ m_nFetchDirection = nNew;
+ }
+
+ //send PropertyChangeEvent to listeners
+ impl_notifyPropertyChangeListeners( aEvt );
+ }
+ else if( aProp.Name == CCRS_PropertySetInfo
+ ::m_aPropertyNameForFetchSize )
+ {
+ //check value
+ sal_Int32 nNew;
+ if( !( aValue >>= nNew ) )
+ {
+ throw IllegalArgumentException();
+ }
+
+ if( nNew < 0 )
+ {
+ nNew = COMSUNSTARUCBCCRS_DEFAULT_FETCH_SIZE;
+ }
+
+ //create PropertyChangeEvent and set value
+ PropertyChangeEvent aEvt;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ aEvt.Source = static_cast< XPropertySet * >( this );
+ aEvt.PropertyName = aPropertyName;
+ aEvt.Further = FALSE;
+ aEvt.PropertyHandle = m_pMyPropSetInfo->
+ m_nFetchSizePropertyHandle;
+ aEvt.OldValue <<= m_nFetchSize;
+ aEvt.NewValue <<= nNew;
+
+ m_nFetchSize = nNew;
+ }
+
+ //send PropertyChangeEvent to listeners
+ impl_notifyPropertyChangeListeners( aEvt );
+ }
+ else
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( !m_xPropertySetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return;
+ }
+ m_xPropertySetOrigin->setPropertyValue( aPropertyName, aValue );
+ }
+}
+
+//--------------------------------------------------------------------------
+// virtual
+Any SAL_CALL CachedContentResultSet
+ ::getPropertyValue( const OUString& rPropertyName )
+ throw( UnknownPropertyException,
+ WrappedTargetException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !getPropertySetInfo().is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw UnknownPropertyException();
+ }
+
+ Property aProp = m_pMyPropSetInfo->getPropertyByName( rPropertyName );
+ //throws UnknownPropertyException, if so
+
+ Any aValue;
+ if( rPropertyName == CCRS_PropertySetInfo
+ ::m_aPropertyNameForCount )
+ {
+ vos::OGuard aGuard( m_aMutex );
+ aValue <<= m_nKnownCount;
+ }
+ else if( rPropertyName == CCRS_PropertySetInfo
+ ::m_aPropertyNameForFinalCount )
+ {
+ vos::OGuard aGuard( m_aMutex );
+ aValue <<= m_bFinalCount;
+ }
+ else if( rPropertyName == CCRS_PropertySetInfo
+ ::m_aPropertyNameForFetchSize )
+ {
+ vos::OGuard aGuard( m_aMutex );
+ aValue <<= m_nFetchSize;
+ }
+ else if( rPropertyName == CCRS_PropertySetInfo
+ ::m_aPropertyNameForFetchDirection )
+ {
+ vos::OGuard aGuard( m_aMutex );
+ aValue <<= m_nFetchDirection;
+ }
+ else
+ {
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( !m_xPropertySetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw UnknownPropertyException();
+ }
+ }
+ aValue = m_xPropertySetOrigin->getPropertyValue( rPropertyName );
+ }
+ return aValue;
+}
+
+//--------------------------------------------------------------------------
+// own methods. ( inherited )
+//--------------------------------------------------------------------------
+
+//virtual
+void SAL_CALL CachedContentResultSet
+ ::impl_disposing( const EventObject& rEventObject )
+ throw( RuntimeException )
+{
+ {
+ impl_EnsureNotDisposed();
+ vos::OGuard aGuard( m_aMutex );
+ //release all references to the broadcaster:
+ m_xFetchProvider.clear();
+ m_xFetchProviderForContentAccess.clear();
+ }
+ ContentResultSetWrapper::impl_disposing( rEventObject );
+}
+
+//virtual
+void SAL_CALL CachedContentResultSet
+ ::impl_propertyChange( const PropertyChangeEvent& rEvt )
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ PropertyChangeEvent aEvt( rEvt );
+ aEvt.Source = static_cast< XPropertySet * >( this );
+ aEvt.Further = FALSE;
+ //---------
+
+ if( CCRS_PropertySetInfo
+ ::impl_isMyPropertyName( rEvt.PropertyName ) )
+ {
+ //don't notify foreign events on fetchsize and fetchdirection
+ if( aEvt.PropertyName == CCRS_PropertySetInfo
+ ::m_aPropertyNameForFetchSize
+ || aEvt.PropertyName == CCRS_PropertySetInfo
+ ::m_aPropertyNameForFetchDirection )
+ return;
+
+ //adjust my props 'RowCount' and 'IsRowCountFinal'
+ if( aEvt.PropertyName == CCRS_PropertySetInfo
+ ::m_aPropertyNameForCount )
+ {//RowCount changed
+
+ //check value
+ sal_Int32 nNew;
+ if( !( aEvt.NewValue >>= nNew ) )
+ {
+ DBG_ERROR( "PropertyChangeEvent contains wrong data" );
+ return;
+ }
+
+ impl_changeRowCount( m_nKnownCount, nNew );
+ }
+ else if( aEvt.PropertyName == CCRS_PropertySetInfo
+ ::m_aPropertyNameForFinalCount )
+ {//IsRowCountFinal changed
+
+ //check value
+ sal_Bool bNew;
+ if( !( aEvt.NewValue >>= bNew ) )
+ {
+ DBG_ERROR( "PropertyChangeEvent contains wrong data" );
+ return;
+ }
+ impl_changeIsRowCountFinal( m_bFinalCount, bNew );
+ }
+ return;
+ }
+
+ //-----------
+ impl_notifyPropertyChangeListeners( aEvt );
+}
+
+
+//virtual
+void SAL_CALL CachedContentResultSet
+ ::impl_vetoableChange( const PropertyChangeEvent& rEvt )
+ throw( PropertyVetoException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ //don't notify events on my properties, cause they are not vetoable
+ if( CCRS_PropertySetInfo
+ ::impl_isMyPropertyName( rEvt.PropertyName ) )
+ {
+ return;
+ }
+
+
+ PropertyChangeEvent aEvt( rEvt );
+ aEvt.Source = static_cast< XPropertySet * >( this );
+ aEvt.Further = FALSE;
+
+ impl_notifyVetoableChangeListeners( aEvt );
+}
+
+//--------------------------------------------------------------------------
+// XContentAccess methods. ( inherited ) ( -- position dependent )
+//--------------------------------------------------------------------------
+
+#define XCONTENTACCESS_queryXXX( queryXXX, XXX, TYPE ) \
+impl_EnsureNotDisposed(); \
+ReacquireableGuard aGuard( m_aMutex ); \
+sal_Int32 nRow = m_nRow; \
+sal_Int32 nFetchSize = m_nFetchSize; \
+sal_Int32 nFetchDirection = m_nFetchDirection; \
+if( !m_aCache##XXX.hasRow( nRow ) ) \
+{ \
+ if( !m_aCache##XXX.hasCausedException( nRow ) ) \
+{ \
+ if( !m_xFetchProviderForContentAccess.is() ) \
+ { \
+ DBG_ERROR( "broadcaster was disposed already" );\
+ throw RuntimeException(); \
+ } \
+ aGuard.clear(); \
+ if( impl_isForwardOnly() ) \
+ applyPositionToOrigin( nRow ); \
+ \
+ FETCH_XXX( m_aCache##XXX, m_xFetchProviderForContentAccess, fetch##XXX##s ); \
+ } \
+ aGuard.reacquire(); \
+ if( !m_aCache##XXX.hasRow( nRow ) ) \
+ { \
+ aGuard.clear(); \
+ applyPositionToOrigin( nRow ); \
+ TYPE aRet = ContentResultSetWrapper::queryXXX(); \
+ if( m_xContentIdentifierMapping.is() ) \
+ return m_xContentIdentifierMapping->map##XXX( aRet );\
+ return aRet; \
+ } \
+} \
+return m_aCache##XXX.get##XXX( nRow );
+
+//--------------------------------------------------------------------------
+// virtual
+OUString SAL_CALL CachedContentResultSet
+ ::queryContentIdentfierString()
+ throw( RuntimeException )
+{
+ XCONTENTACCESS_queryXXX( queryContentIdentfierString, ContentIdentifierString, OUString )
+}
+
+//--------------------------------------------------------------------------
+// virtual
+Reference< XContentIdentifier > SAL_CALL CachedContentResultSet
+ ::queryContentIdentifier()
+ throw( RuntimeException )
+{
+ XCONTENTACCESS_queryXXX( queryContentIdentifier, ContentIdentifier, Reference< XContentIdentifier > )
+}
+
+//--------------------------------------------------------------------------
+// virtual
+Reference< XContent > SAL_CALL CachedContentResultSet
+ ::queryContent()
+ throw( RuntimeException )
+{
+ XCONTENTACCESS_queryXXX( queryContent, Content, Reference< XContent > )
+}
+
+//-----------------------------------------------------------------
+// XResultSet methods. ( inherited )
+//-----------------------------------------------------------------
+//virtual
+
+sal_Bool SAL_CALL CachedContentResultSet
+ ::next()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ ReacquireableGuard aGuard( m_aMutex );
+ //after last
+ if( m_bAfterLast )
+ return sal_False;
+ //last
+ aGuard.clear();
+ if( isLast() )
+ {
+ aGuard.reacquire();
+ m_nRow++;
+ m_bAfterLast = sal_True;
+ return sal_False;
+ }
+ aGuard.reacquire();
+ //known valid position
+ if( impl_isKnownValidPosition( m_nRow + 1 ) )
+ {
+ m_nRow++;
+ return sal_True;
+ }
+
+ //unknown position
+ sal_Int32 nRow = m_nRow;
+ aGuard.clear();
+
+ sal_Bool bValid = applyPositionToOrigin( nRow + 1 );
+
+ aGuard.reacquire();
+ m_nRow = nRow + 1;
+ m_bAfterLast = !bValid;
+ return bValid;
+}
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::previous()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( impl_isForwardOnly() )
+ throw SQLException();
+
+ ReacquireableGuard aGuard( m_aMutex );
+ //before first ?:
+ if( !m_bAfterLast && !m_nRow )
+ return sal_False;
+ //first ?:
+ if( !m_bAfterLast && m_nKnownCount && m_nRow == 1 )
+ {
+ m_nRow--;
+ m_bAfterLast = sal_False;
+ return sal_False;
+ }
+ //known valid position ?:
+ if( impl_isKnownValidPosition( m_nRow - 1 ) )
+ {
+ m_nRow--;
+ m_bAfterLast = sal_False;
+ return sal_True;
+ }
+ //unknown position:
+ sal_Int32 nRow = m_nRow;
+ aGuard.clear();
+
+ sal_Bool bValid = applyPositionToOrigin( nRow - 1 );
+
+ aGuard.reacquire();
+ m_nRow = nRow - 1;
+ m_bAfterLast = sal_False;
+ return bValid;
+}
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::absolute( sal_Int32 row )
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !row )
+ throw SQLException();
+
+ if( impl_isForwardOnly() )
+ throw SQLException();
+
+ ReacquireableGuard aGuard( m_aMutex );
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return sal_False;
+ }
+ if( row < 0 )
+ {
+ if( m_bFinalCount )
+ {
+ sal_Int32 nNewRow = m_nKnownCount + 1 + row;
+ sal_Bool bValid = sal_True;
+ if( nNewRow <= 0 )
+ {
+ nNewRow = 0;
+ bValid = sal_False;
+ }
+ m_nRow = nNewRow;
+ m_bAfterLast = sal_False;
+ return bValid;
+ }
+ //unknown final count:
+ aGuard.clear();
+
+ sal_Bool bValid = m_xResultSetOrigin->absolute( row );
+
+ aGuard.reacquire();
+ if( m_bFinalCount )
+ {
+ sal_Int32 nNewRow = m_nKnownCount + 1 + row;
+ if( nNewRow < 0 )
+ nNewRow = 0;
+ m_nLastAppliedPos = nNewRow;
+ m_nRow = nNewRow;
+ m_bAfterLastApplied = m_bAfterLast = sal_False;
+ return bValid;
+ }
+ aGuard.clear();
+
+ sal_Int32 nCurRow = m_xResultSetOrigin->getRow();
+
+ aGuard.reacquire();
+ m_nLastAppliedPos = nCurRow;
+ m_nRow = nCurRow;
+ m_bAfterLast = sal_False;
+ return nCurRow;
+ }
+ //row > 0:
+ if( m_bFinalCount )
+ {
+ if( row > m_nKnownCount )
+ {
+ m_nRow = m_nKnownCount + 1;
+ m_bAfterLast = sal_True;
+ return sal_False;
+ }
+ m_nRow = row;
+ m_bAfterLast = sal_False;
+ return sal_True;
+ }
+ //unknown new position:
+ aGuard.clear();
+
+ sal_Bool bValid = m_xResultSetOrigin->absolute( row );
+
+ aGuard.reacquire();
+ if( m_bFinalCount )
+ {
+ sal_Int32 nNewRow = row;
+ if( nNewRow > m_nKnownCount )
+ {
+ nNewRow = m_nKnownCount + 1;
+ m_bAfterLastApplied = m_bAfterLast = sal_True;
+ }
+ else
+ m_bAfterLastApplied = m_bAfterLast = sal_False;
+
+ m_nLastAppliedPos = nNewRow;
+ m_nRow = nNewRow;
+ return bValid;
+ }
+ aGuard.clear();
+
+ sal_Int32 nCurRow = m_xResultSetOrigin->getRow();
+ sal_Bool bIsAfterLast = m_xResultSetOrigin->isAfterLast();
+
+ aGuard.reacquire();
+ m_nLastAppliedPos = nCurRow;
+ m_nRow = nCurRow;
+ m_bAfterLastApplied = m_bAfterLast = bIsAfterLast;
+ return nCurRow && !bIsAfterLast;
+}
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::relative( sal_Int32 rows )
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( impl_isForwardOnly() )
+ throw SQLException();
+
+ ReacquireableGuard aGuard( m_aMutex );
+ if( m_bAfterLast || impl_isKnownInvalidPosition( m_nRow ) )
+ throw SQLException();
+
+ if( !rows )
+ return sal_True;
+
+ sal_Int32 nNewRow = m_nRow + rows;
+ if( nNewRow < 0 )
+ nNewRow = 0;
+
+ if( impl_isKnownValidPosition( nNewRow ) )
+ {
+ m_nRow = nNewRow;
+ m_bAfterLast = sal_False;
+ return sal_True;
+ }
+ else
+ {
+ //known invalid new position:
+ if( nNewRow == 0 )
+ {
+ m_bAfterLast = sal_False;
+ m_nRow = 0;
+ return sal_False;
+ }
+ if( m_bFinalCount && nNewRow > m_nKnownCount )
+ {
+ m_bAfterLast = sal_True;
+ m_nRow = m_nKnownCount + 1;
+ return sal_False;
+ }
+ //unknown new position:
+ aGuard.clear();
+ sal_Bool bValid = applyPositionToOrigin( nNewRow );
+
+ aGuard.reacquire();
+ m_nRow = nNewRow;
+ m_bAfterLast = !bValid && nNewRow > 0;
+ return bValid;
+ }
+}
+
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::first()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( impl_isForwardOnly() )
+ throw SQLException();
+
+ ReacquireableGuard aGuard( m_aMutex );
+ if( impl_isKnownValidPosition( 1 ) )
+ {
+ m_nRow = 1;
+ m_bAfterLast = sal_False;
+ return sal_True;
+ }
+ if( impl_isKnownInvalidPosition( 1 ) )
+ {
+ m_nRow = 1;
+ m_bAfterLast = sal_False;
+ return sal_False;
+ }
+ //unknown position
+ aGuard.clear();
+
+ sal_Bool bValid = applyPositionToOrigin( 1 );
+
+ aGuard.reacquire();
+ m_nRow = 1;
+ m_bAfterLast = sal_False;
+ return bValid;
+}
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::last()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( impl_isForwardOnly() )
+ throw SQLException();
+
+ ReacquireableGuard aGuard( m_aMutex );
+ if( m_bFinalCount )
+ {
+ m_nRow = m_nKnownCount;
+ m_bAfterLast = sal_False;
+ return m_nKnownCount;
+ }
+ //unknown position
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return sal_False;
+ }
+ aGuard.clear();
+
+ sal_Bool bValid = m_xResultSetOrigin->last();
+
+ aGuard.reacquire();
+ m_bAfterLastApplied = m_bAfterLast = sal_False;
+ if( m_bFinalCount )
+ {
+ m_nLastAppliedPos = m_nKnownCount;
+ m_nRow = m_nKnownCount;
+ return bValid;
+ }
+ aGuard.clear();
+
+ sal_Int32 nCurRow = m_xResultSetOrigin->getRow();
+
+ aGuard.reacquire();
+ m_nLastAppliedPos = nCurRow;
+ m_nRow = nCurRow;
+ DBG_ASSERT( nCurRow >= m_nKnownCount, "position of last row < known Count, that could not be" );
+ m_nKnownCount = nCurRow;
+ m_bFinalCount = sal_True;
+ return nCurRow;
+}
+
+//virtual
+void SAL_CALL CachedContentResultSet
+ ::beforeFirst()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( impl_isForwardOnly() )
+ throw SQLException();
+
+ vos::OGuard aGuard( m_aMutex );
+ m_nRow = 0;
+ m_bAfterLast = sal_False;
+}
+
+//virtual
+void SAL_CALL CachedContentResultSet
+ ::afterLast()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( impl_isForwardOnly() )
+ throw SQLException();
+
+ vos::OGuard aGuard( m_aMutex );
+ m_nRow = 1;
+ m_bAfterLast = sal_True;
+}
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::isAfterLast()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ ReacquireableGuard aGuard( m_aMutex );
+ if( !m_bAfterLast )
+ return sal_False;
+ if( m_nKnownCount )
+ return m_bAfterLast;
+ if( m_bFinalCount )
+ return sal_False;
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return sal_False;
+ }
+ aGuard.clear();
+
+ //find out whethter the original resultset contains rows or not
+ m_xResultSetOrigin->afterLast();
+
+ aGuard.reacquire();
+ m_bAfterLastApplied = sal_True;
+ aGuard.clear();
+
+ return m_xResultSetOrigin->isAfterLast();
+}
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::isBeforeFirst()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ ReacquireableGuard aGuard( m_aMutex );
+ if( m_bAfterLast )
+ return sal_False;
+ if( m_nRow )
+ return sal_False;
+ if( m_nKnownCount )
+ return !m_nRow;
+ if( m_bFinalCount )
+ return sal_False;
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return sal_False;
+ }
+ aGuard.clear();
+
+ //find out whethter the original resultset contains rows or not
+ m_xResultSetOrigin->beforeFirst();
+
+ aGuard.reacquire();
+ m_bAfterLastApplied = sal_False;
+ m_nLastAppliedPos = 0;
+ aGuard.clear();
+
+ return m_xResultSetOrigin->isBeforeFirst();
+}
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::isFirst()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ sal_Int32 nRow;
+ Reference< XResultSet > xResultSetOrigin;
+
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( m_bAfterLast )
+ return sal_False;
+ if( m_nRow != 1 )
+ return sal_False;
+ if( m_nKnownCount )
+ return m_nRow == 1;
+ if( m_bFinalCount )
+ return sal_False;
+
+ nRow = m_nRow;
+ xResultSetOrigin = m_xResultSetOrigin;
+ }
+
+ //need to ask origin
+ {
+ if( applyPositionToOrigin( nRow ) )
+ return xResultSetOrigin->isFirst();
+ else
+ return sal_False;
+ }
+}
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::isLast()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ sal_Int32 nRow;
+ Reference< XResultSet > xResultSetOrigin;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( m_bAfterLast )
+ return sal_False;
+ if( m_nRow < m_nKnownCount )
+ return sal_False;
+ if( m_bFinalCount )
+ return m_nKnownCount && m_nRow == m_nKnownCount;
+
+ nRow = m_nRow;
+ xResultSetOrigin = m_xResultSetOrigin;
+ }
+
+ //need to ask origin
+ {
+ if( applyPositionToOrigin( nRow ) )
+ return xResultSetOrigin->isLast();
+ else
+ return sal_False;
+ }
+}
+
+
+//virtual
+sal_Int32 SAL_CALL CachedContentResultSet
+ ::getRow()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ vos::OGuard aGuard( m_aMutex );
+ if( m_bAfterLast )
+ return 0;
+ return m_nRow;
+}
+
+//virtual
+void SAL_CALL CachedContentResultSet
+ ::refreshRow()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ //the ContentResultSet is static and will not change
+ //therefore we don't need to reload anything
+}
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::rowUpdated()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ //the ContentResultSet is static and will not change
+ return sal_False;
+}
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::rowInserted()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ //the ContentResultSet is static and will not change
+ return sal_False;
+}
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::rowDeleted()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ //the ContentResultSet is static and will not change
+ return sal_False;
+}
+
+//virtual
+Reference< XInterface > SAL_CALL CachedContentResultSet
+ ::getStatement()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ //@todo ?return anything
+ return Reference< XInterface >();
+}
+
+//-----------------------------------------------------------------
+// XRow methods. ( inherited )
+//-----------------------------------------------------------------
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::wasNull()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( m_bLastReadWasFromCache )
+ return m_bLastCachedReadWasNull;
+ if( !m_xRowOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return sal_False;
+ }
+ }
+ return m_xRowOrigin->wasNull();
+}
+
+//virtual
+rtl::OUString SAL_CALL CachedContentResultSet
+ ::getString( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getString, OUString );
+}
+
+//virtual
+sal_Bool SAL_CALL CachedContentResultSet
+ ::getBoolean( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getBoolean, sal_Bool );
+}
+
+//virtual
+sal_Int8 SAL_CALL CachedContentResultSet
+ ::getByte( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getByte, sal_Int8 );
+}
+
+//virtual
+sal_Int16 SAL_CALL CachedContentResultSet
+ ::getShort( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getShort, sal_Int16 );
+}
+
+//virtual
+sal_Int32 SAL_CALL CachedContentResultSet
+ ::getInt( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getInt, sal_Int32 );
+}
+
+//virtual
+sal_Int64 SAL_CALL CachedContentResultSet
+ ::getLong( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getLong, sal_Int64 );
+}
+
+//virtual
+float SAL_CALL CachedContentResultSet
+ ::getFloat( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getFloat, float );
+}
+
+//virtual
+double SAL_CALL CachedContentResultSet
+ ::getDouble( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getDouble, double );
+}
+
+//virtual
+Sequence< sal_Int8 > SAL_CALL CachedContentResultSet
+ ::getBytes( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getBytes, Sequence< sal_Int8 > );
+}
+
+//virtual
+Date SAL_CALL CachedContentResultSet
+ ::getDate( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getDate, Date );
+}
+
+//virtual
+Time SAL_CALL CachedContentResultSet
+ ::getTime( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getTime, Time );
+}
+
+//virtual
+DateTime SAL_CALL CachedContentResultSet
+ ::getTimestamp( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getTimestamp, DateTime );
+}
+
+//virtual
+Reference< com::sun::star::io::XInputStream >
+ SAL_CALL CachedContentResultSet
+ ::getBinaryStream( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getBinaryStream, Reference< com::sun::star::io::XInputStream > );
+}
+
+//virtual
+Reference< com::sun::star::io::XInputStream >
+ SAL_CALL CachedContentResultSet
+ ::getCharacterStream( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getCharacterStream, Reference< com::sun::star::io::XInputStream > );
+}
+
+//virtual
+Any SAL_CALL CachedContentResultSet
+ ::getObject( sal_Int32 columnIndex,
+ const Reference<
+ com::sun::star::container::XNameAccess >& typeMap )
+ throw( SQLException,
+ RuntimeException )
+{
+ //if you change this macro please pay attention to
+ //define XROW_GETXXX, where this is similar implemented
+
+ ReacquireableGuard aGuard( m_aMutex );
+ sal_Int32 nRow = m_nRow;
+ sal_Int32 nFetchSize = m_nFetchSize;
+ sal_Int32 nFetchDirection = m_nFetchDirection;
+ if( !m_aCache.hasRow( nRow ) )
+ {
+ if( !m_aCache.hasCausedException( nRow ) )
+ {
+ if( !m_xFetchProvider.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return Any();
+ }
+ aGuard.clear();
+
+ impl_fetchData( nRow, nFetchSize, nFetchDirection );
+ }
+ aGuard.reacquire();
+ if( !m_aCache.hasRow( nRow ) )
+ {
+ m_bLastReadWasFromCache = sal_False;
+ aGuard.clear();
+ applyPositionToOrigin( nRow );
+ return m_xRowOrigin->getObject( columnIndex, typeMap );
+ }
+ }
+ //@todo: pay attention to typeMap
+ DBG_ASSERTWARNING( !typeMap.is(), "special TypeMaps are not supported" );
+ const Any& rValue = m_aCache.getAny( nRow, columnIndex );
+ Any aRet;
+ m_bLastReadWasFromCache = sal_True;
+ m_bLastCachedReadWasNull = !( rValue >>= aRet );
+ return aRet;
+}
+
+//virtual
+Reference< XRef > SAL_CALL CachedContentResultSet
+ ::getRef( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getRef, Reference< XRef > );
+}
+
+//virtual
+Reference< XBlob > SAL_CALL CachedContentResultSet
+ ::getBlob( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getBlob, Reference< XBlob > );
+}
+
+//virtual
+Reference< XClob > SAL_CALL CachedContentResultSet
+ ::getClob( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getClob, Reference< XClob > );
+}
+
+//virtual
+Reference< XArray > SAL_CALL CachedContentResultSet
+ ::getArray( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getArray, Reference< XArray > );
+}
+
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// class CachedContentResultSetFactory
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+CachedContentResultSetFactory::CachedContentResultSetFactory(
+ const Reference< XMultiServiceFactory > & rSMgr )
+{
+ m_xSMgr = rSMgr;
+}
+
+CachedContentResultSetFactory::~CachedContentResultSetFactory()
+{
+}
+
+//--------------------------------------------------------------------------
+// CachedContentResultSetFactory XInterface methods.
+//--------------------------------------------------------------------------
+
+XINTERFACE_IMPL_3( CachedContentResultSetFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XCachedContentResultSetFactory );
+
+//--------------------------------------------------------------------------
+// CachedContentResultSetFactory XTypeProvider methods.
+//--------------------------------------------------------------------------
+
+XTYPEPROVIDER_IMPL_3( CachedContentResultSetFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XCachedContentResultSetFactory );
+
+//--------------------------------------------------------------------------
+// CachedContentResultSetFactory XServiceInfo methods.
+//--------------------------------------------------------------------------
+
+XSERVICEINFO_IMPL_1( CachedContentResultSetFactory,
+ OUString::createFromAscii( "CachedContentResultSetFactory" ),
+ OUString::createFromAscii( CACHED_CONTENT_RESULTSET_FACTORY_NAME ) );
+
+//--------------------------------------------------------------------------
+// Service factory implementation.
+//--------------------------------------------------------------------------
+
+ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedContentResultSetFactory );
+
+//--------------------------------------------------------------------------
+// CachedContentResultSetFactory XCachedContentResultSetFactory methods.
+//--------------------------------------------------------------------------
+
+ //virtual
+Reference< XResultSet > SAL_CALL CachedContentResultSetFactory
+ ::createCachedContentResultSet(
+ const Reference< XResultSet > & xSource,
+ const Reference< XContentIdentifierMapping > & xMapping )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ Reference< XResultSet > xRet;
+ xRet = new CachedContentResultSet( xSource, xMapping );
+ return xRet;
+}
+
diff --git a/ucb/source/cacher/cachedcontentresultset.hxx b/ucb/source/cacher/cachedcontentresultset.hxx
new file mode 100644
index 000000000000..0ef978b82e30
--- /dev/null
+++ b/ucb/source/cacher/cachedcontentresultset.hxx
@@ -0,0 +1,560 @@
+/*************************************************************************
+ *
+ * $RCSfile: cachedcontentresultset.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CACHED_CONTENT_RESULTSET_HXX
+#define _CACHED_CONTENT_RESULTSET_HXX
+
+#ifndef _CONTENT_RESULTSET_WRAPPER_HXX
+#include <contentresultsetwrapper.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XFETCHPROVIDER_HPP_
+#include <com/sun/star/ucb/XFetchProvider.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XFETCHPROVIDERFORCONTENTACCESS_HPP_
+#include <com/sun/star/ucb/XFetchProviderForContentAccess.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_FETCHRESULT_HPP_
+#include <com/sun/star/ucb/FetchResult.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XCONTENTIDENTIFIERMAPPING_HPP_
+#include <com/sun/star/ucb/XContentIdentifierMapping.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XCACHEDCONTENTRESULTSETFACTORY_HPP_
+#include <com/sun/star/ucb/XCachedContentResultSetFactory.hpp>
+#endif
+
+#define CACHED_CONTENT_RESULTSET_SERVICE_NAME "com.sun.star.ucb.CachedContentResultSet"
+#define CACHED_CONTENT_RESULTSET_FACTORY_NAME "com.sun.star.ucb.CachedContentResultSetFactory"
+
+//=========================================================================
+
+class CCRS_PropertySetInfo;
+class CachedContentResultSet
+ : public ContentResultSetWrapper
+ , public com::sun::star::lang::XTypeProvider
+ , public com::sun::star::lang::XServiceInfo
+{
+ //--------------------------------------------------------------------------
+ // class CCRS_Cache
+
+ class CCRS_Cache
+ {
+ private:
+ com::sun::star::ucb::FetchResult* m_pResult;
+ com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifierMapping >
+ m_xContentIdentifierMapping;
+ com::sun::star::uno::Sequence< sal_Bool >* m_pMappedReminder;
+
+ private:
+ com::sun::star::uno::Any& SAL_CALL
+ getRowAny( sal_Int32 nRow )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ void SAL_CALL clear();
+
+
+ void SAL_CALL remindMapped( sal_Int32 nRow );
+ sal_Bool SAL_CALL isRowMapped( sal_Int32 nRow );
+ void SAL_CALL clearMappedReminder();
+ com::sun::star::uno::Sequence< sal_Bool >* SAL_CALL getMappedReminder();
+
+ public:
+ CCRS_Cache( const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifierMapping > & xMapping );
+ ~CCRS_Cache();
+
+ void SAL_CALL loadData(
+ const com::sun::star::ucb::FetchResult& rResult );
+
+ sal_Bool SAL_CALL
+ hasRow( sal_Int32 nRow );
+
+ sal_Bool SAL_CALL
+ hasCausedException( sal_Int32 nRow );
+
+ sal_Int32 SAL_CALL
+ getMaxRow();
+
+ sal_Bool SAL_CALL
+ hasKnownLast();
+
+ //---
+ const com::sun::star::uno::Any& SAL_CALL
+ getAny( sal_Int32 nRow, sal_Int32 nColumnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ const rtl::OUString& SAL_CALL
+ getContentIdentifierString( sal_Int32 nRow )
+ throw( com::sun::star::uno::RuntimeException );
+
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifier >& SAL_CALL
+ getContentIdentifier( sal_Int32 nRow )
+ throw( com::sun::star::uno::RuntimeException );
+
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContent >& SAL_CALL
+ getContent( sal_Int32 nRow )
+ throw( com::sun::star::uno::RuntimeException );
+ };
+ //-----------------------------------------------------------------
+ //members
+
+ //different Interfaces from Origin:
+ com::sun::star::uno::Reference< com::sun::star::ucb::XFetchProvider >
+ m_xFetchProvider; //XFetchProvider-interface from m_xOrigin
+
+ com::sun::star::uno::Reference< com::sun::star::ucb::XFetchProviderForContentAccess >
+ m_xFetchProviderForContentAccess; //XFetchProviderForContentAccess-interface from m_xOrigin
+
+ //my PropertySetInfo
+ com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >
+ m_xMyPropertySetInfo;//holds m_pMyPropSetInfo alive
+ CCRS_PropertySetInfo* m_pMyPropSetInfo;
+
+
+ //
+ com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifierMapping >
+ m_xContentIdentifierMapping;// can be used for remote optimized ContentAccess
+
+ //some Properties and helping variables
+ sal_Int32 m_nRow;
+ sal_Bool m_bAfterLast; // TRUE, if m_nRow is after final count; can be TRUE without knowing the exact final count
+
+ sal_Int32 m_nLastAppliedPos;
+ sal_Bool m_bAfterLastApplied;
+
+ sal_Int32 m_nKnownCount; // count we know from the Origin
+ sal_Bool m_bFinalCount; // TRUE if the Origin has reached final count and we got that count in m_nKnownCount
+
+ sal_Int32 m_nFetchSize;
+ sal_Int32 m_nFetchDirection;
+
+ sal_Bool m_bLastReadWasFromCache;
+ sal_Bool m_bLastCachedReadWasNull;
+
+ //cache:
+ CCRS_Cache m_aCache;
+ CCRS_Cache m_aCacheContentIdentifierString;
+ CCRS_Cache m_aCacheContentIdentifier;
+ CCRS_Cache m_aCacheContent;
+
+
+private:
+ //-----------------------------------------------------------------
+ //helping XPropertySet methods.
+ virtual void SAL_CALL impl_initPropertySetInfo();
+
+
+ //-----------------------------------------------------------------
+ sal_Bool SAL_CALL
+ applyPositionToOrigin( sal_Int32 nRow )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ sal_Bool SAL_CALL
+ applyPositionToOrigin()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ void SAL_CALL
+ impl_fetchData( sal_Int32 nRow, sal_Int32 nCount
+ , sal_Int32 nFetchDirection )
+ throw( com::sun::star::uno::RuntimeException );
+
+ sal_Bool SAL_CALL
+ impl_isKnownValidPosition( sal_Int32 nRow );
+
+ sal_Bool SAL_CALL
+ impl_isKnownInvalidPosition( sal_Int32 nRow );
+
+ void SAL_CALL
+ impl_changeRowCount( sal_Int32 nOld, sal_Int32 nNew );
+
+ void SAL_CALL
+ impl_changeIsRowCountFinal( sal_Bool bOld, sal_Bool bNew );
+
+public:
+ CachedContentResultSet( com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet > xOrigin,
+ com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifierMapping >
+ xContentIdentifierMapping );
+
+ virtual ~CachedContentResultSet();
+
+ //-----------------------------------------------------------------
+ // XInterface inherited
+ //-----------------------------------------------------------------
+ XINTERFACE_DECL()
+ //-----------------------------------------------------------------
+ // XTypeProvider
+ //-----------------------------------------------------------------
+ XTYPEPROVIDER_DECL()
+ //-----------------------------------------------------------------
+ // XServiceInfo
+ //-----------------------------------------------------------------
+ XSERVICEINFO_NOFACTORY_DECL()
+
+ //-----------------------------------------------------------------
+ // XPropertySet inherited
+ //-----------------------------------------------------------------
+
+ virtual void SAL_CALL
+ setPropertyValue( const rtl::OUString& aPropertyName,
+ const com::sun::star::uno::Any& aValue )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::beans::PropertyVetoException,
+ com::sun::star::lang::IllegalArgumentException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Any SAL_CALL
+ getPropertyValue( const rtl::OUString& PropertyName )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // own inherited
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ impl_disposing( const com::sun::star::lang::EventObject& Source )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ impl_propertyChange( const com::sun::star::beans::PropertyChangeEvent& evt )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ impl_vetoableChange( const com::sun::star::beans::PropertyChangeEvent& aEvent )
+ throw( com::sun::star::beans::PropertyVetoException,
+ com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XContentAccess inherited
+ //-----------------------------------------------------------------
+ virtual rtl::OUString SAL_CALL
+ queryContentIdentfierString()
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifier > SAL_CALL
+ queryContentIdentifier()
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContent > SAL_CALL
+ queryContent()
+ throw( com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XResultSet inherited
+ //-----------------------------------------------------------------
+ virtual sal_Bool SAL_CALL
+ next()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ isBeforeFirst()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ isAfterLast()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ isFirst()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ isLast()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ beforeFirst()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ afterLast()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ first()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ last()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Int32 SAL_CALL
+ getRow()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ absolute( sal_Int32 row )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ relative( sal_Int32 rows )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ previous()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ refreshRow()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ rowUpdated()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ rowInserted()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ rowDeleted()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::uno::XInterface > SAL_CALL
+ getStatement()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XRow inherited
+ //-----------------------------------------------------------------
+ virtual sal_Bool SAL_CALL
+ wasNull()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual rtl::OUString SAL_CALL
+ getString( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ getBoolean( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int8 SAL_CALL
+ getByte( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int16 SAL_CALL
+ getShort( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int32 SAL_CALL
+ getInt( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int64 SAL_CALL
+ getLong( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual float SAL_CALL
+ getFloat( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual double SAL_CALL
+ getDouble( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
+ getBytes( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::util::Date SAL_CALL
+ getDate( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::util::Time SAL_CALL
+ getTime( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::util::DateTime SAL_CALL
+ getTimestamp( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::io::XInputStream > SAL_CALL
+ getBinaryStream( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::io::XInputStream > SAL_CALL
+ getCharacterStream( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Any SAL_CALL
+ getObject( sal_Int32 columnIndex,
+ const com::sun::star::uno::Reference<
+ com::sun::star::container::XNameAccess >& typeMap )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XRef > SAL_CALL
+ getRef( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XBlob > SAL_CALL
+ getBlob( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XClob > SAL_CALL
+ getClob( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XArray > SAL_CALL
+ getArray( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+};
+
+//=========================================================================
+
+class CachedContentResultSetFactory
+ : public cppu::OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public com::sun::star::lang::XServiceInfo
+ , public com::sun::star::ucb::XCachedContentResultSetFactory
+{
+protected:
+ com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+
+public:
+
+ CachedContentResultSetFactory(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > & rSMgr);
+
+ virtual ~CachedContentResultSetFactory();
+
+ //-----------------------------------------------------------------
+ // XInterface
+ XINTERFACE_DECL()
+
+ //-----------------------------------------------------------------
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ //-----------------------------------------------------------------
+ // XServiceInfo
+ XSERVICEINFO_DECL()
+
+ //-----------------------------------------------------------------
+ // XCachedContentResultSetFactory
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet > SAL_CALL
+ createCachedContentResultSet(
+ const com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet > & xSource,
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifierMapping > & xMapping )
+ throw( com::sun::star::uno::RuntimeException );
+};
+
+#endif
+
diff --git a/ucb/source/cacher/cachedcontentresultsetstub.cxx b/ucb/source/cacher/cachedcontentresultsetstub.cxx
new file mode 100644
index 000000000000..5d20d2bce5ae
--- /dev/null
+++ b/ucb/source/cacher/cachedcontentresultsetstub.cxx
@@ -0,0 +1,450 @@
+/*************************************************************************
+ *
+ * $RCSfile: cachedcontentresultsetstub.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <cachedcontentresultsetstub.hxx>
+
+#ifndef _COM_SUN_STAR_UCB_FETCHERROR_HPP_
+#include <com/sun/star/ucb/FetchError.hpp>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::util;
+using namespace cppu;
+using namespace rtl;
+
+CachedContentResultSetStub::CachedContentResultSetStub( Reference< XResultSet > xOrigin )
+ : ContentResultSetWrapper( xOrigin )
+ , m_nColumnCount( 0 )
+ , m_bColumnCountCached( sal_False )
+{
+ impl_init();
+}
+
+CachedContentResultSetStub::~CachedContentResultSetStub()
+{
+ impl_deinit();
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods.
+//--------------------------------------------------------------------------
+XINTERFACE_COMMON_IMPL( CachedContentResultSetStub )
+
+Any SAL_CALL CachedContentResultSetStub
+ ::queryInterface( const Type& rType )
+ throw ( RuntimeException )
+{
+ //list all interfaces inclusive baseclasses of interfaces
+
+ Any aRet = ContentResultSetWrapper::queryInterface( rType );
+ if( aRet.hasValue() )
+ return aRet;
+
+ aRet = cppu::queryInterface( rType
+ , static_cast< XTypeProvider* >( this )
+ , static_cast< XServiceInfo* >( this )
+ , static_cast< XFetchProvider* >( this )
+ , static_cast< XFetchProviderForContentAccess* >( this )
+ );
+
+ return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
+}
+
+//--------------------------------------------------------------------------
+// XTypeProvider methods.
+//--------------------------------------------------------------------------
+
+XTYPEPROVIDER_COMMON_IMPL( CachedContentResultSetStub )
+//list all interfaces exclusive baseclasses
+Sequence< Type > SAL_CALL CachedContentResultSetStub
+ ::getTypes()
+ throw( RuntimeException )
+{
+ static Sequence< Type >* pTypes = NULL;
+ if( !pTypes )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pTypes )
+ {
+ pTypes->realloc( 13 );
+ (*pTypes)[0] = CPPU_TYPE_REF( XTypeProvider );
+ (*pTypes)[1] = CPPU_TYPE_REF( XServiceInfo );
+ (*pTypes)[2] = CPPU_TYPE_REF( XComponent );
+ (*pTypes)[3] = CPPU_TYPE_REF( XCloseable );
+ (*pTypes)[4] = CPPU_TYPE_REF( XResultSetMetaDataSupplier );
+ (*pTypes)[5] = CPPU_TYPE_REF( XPropertySet );
+ (*pTypes)[6] = CPPU_TYPE_REF( XPropertyChangeListener );
+ (*pTypes)[7] = CPPU_TYPE_REF( XVetoableChangeListener );
+ (*pTypes)[8] = CPPU_TYPE_REF( XResultSet );
+ (*pTypes)[9] = CPPU_TYPE_REF( XContentAccess );
+ (*pTypes)[10] = CPPU_TYPE_REF( XRow );
+ (*pTypes)[11] = CPPU_TYPE_REF( XFetchProvider );
+ (*pTypes)[12] = CPPU_TYPE_REF( XFetchProviderForContentAccess );
+ }
+ }
+ return *pTypes;
+}
+
+//--------------------------------------------------------------------------
+// XServiceInfo methods.
+//--------------------------------------------------------------------------
+
+XSERVICEINFO_NOFACTORY_IMPL_1( CachedContentResultSetStub,
+ OUString::createFromAscii( "CachedContentResultSetStub" ),
+ OUString::createFromAscii( CACHED_CRS_STUB_SERVICE_NAME ) );
+
+//-----------------------------------------------------------------
+// XFetchProvider methods.
+//-----------------------------------------------------------------
+
+#define FETCH_XXX( impl_loadRow, loadInterface ) \
+impl_EnsureNotDisposed(); \
+if( !m_xResultSetOrigin.is() ) \
+{ \
+ DBG_ERROR( "broadcaster was disposed already" ); \
+ throw RuntimeException(); \
+} \
+FetchResult aRet; \
+aRet.StartIndex = nRowStartPosition; \
+aRet.Orientation = bDirection; \
+aRet.FetchError = FetchError::SUCCESS; /*ENDOFDATA, EXCEPTION*/ \
+sal_Int32 nOldOriginal_Pos = m_xResultSetOrigin->getRow(); \
+if( impl_isForwardOnly() ) \
+{ \
+ if( nOldOriginal_Pos != nRowStartPosition ) \
+ { \
+ /*@todo*/ \
+ aRet.FetchError = FetchError::EXCEPTION; \
+ return aRet; \
+ } \
+ if( nRowCount != 1 ) \
+ aRet.FetchError = FetchError::EXCEPTION; \
+ \
+ aRet.Rows.realloc( 1 ); \
+ \
+ try \
+ { \
+ impl_loadRow( aRet.Rows[0], loadInterface ); \
+ } \
+ catch( SQLException& ) \
+ { \
+ aRet.Rows.realloc( 0 ); \
+ aRet.FetchError = FetchError::EXCEPTION; \
+ return aRet; \
+ } \
+ return aRet; \
+} \
+aRet.Rows.realloc( nRowCount ); \
+sal_Bool bOldOriginal_AfterLast = sal_False; \
+if( !nOldOriginal_Pos ) \
+ bOldOriginal_AfterLast = m_xResultSetOrigin->isAfterLast(); \
+sal_Int32 nN = 1; \
+sal_Bool bValidNewPos = sal_False; \
+try \
+{ \
+ try \
+ { \
+ /*if( nOldOriginal_Pos != nRowStartPosition )*/ \
+ bValidNewPos = m_xResultSetOrigin->absolute( nRowStartPosition ); \
+ } \
+ catch( SQLException& ) \
+ { \
+ aRet.Rows.realloc( 0 ); \
+ aRet.FetchError = FetchError::EXCEPTION; \
+ return aRet; \
+ } \
+ if( !bValidNewPos ) \
+ { \
+ aRet.Rows.realloc( 0 ); \
+ aRet.FetchError = FetchError::EXCEPTION; \
+ \
+ /*restore old position*/ \
+ if( nOldOriginal_Pos ) \
+ m_xResultSetOrigin->absolute( nOldOriginal_Pos ); \
+ else if( bOldOriginal_AfterLast ) \
+ m_xResultSetOrigin->afterLast(); \
+ else \
+ m_xResultSetOrigin->beforeFirst(); \
+ \
+ return aRet; \
+ } \
+ for( ; nN <= nRowCount; ) \
+ { \
+ impl_loadRow( aRet.Rows[nN-1], loadInterface ); \
+ nN++; \
+ if( nN <= nRowCount ) \
+ { \
+ if( bDirection ) \
+ { \
+ if( !m_xResultSetOrigin->next() ) \
+ { \
+ aRet.Rows.realloc( nN-1 ); \
+ aRet.FetchError = FetchError::ENDOFDATA; \
+ break; \
+ } \
+ } \
+ else \
+ { \
+ if( !m_xResultSetOrigin->previous() ) \
+ { \
+ aRet.Rows.realloc( nN-1 ); \
+ aRet.FetchError = FetchError::ENDOFDATA; \
+ break; \
+ } \
+ } \
+ } \
+ } \
+} \
+catch( SQLException& ) \
+{ \
+ aRet.Rows.realloc( nN-1 ); \
+ aRet.FetchError = FetchError::EXCEPTION; \
+} \
+/*restore old position*/ \
+if( nOldOriginal_Pos ) \
+ m_xResultSetOrigin->absolute( nOldOriginal_Pos ); \
+else if( bOldOriginal_AfterLast ) \
+ m_xResultSetOrigin->afterLast(); \
+else \
+ m_xResultSetOrigin->beforeFirst(); \
+return aRet;
+
+FetchResult SAL_CALL CachedContentResultSetStub
+ ::fetch( sal_Int32 nRowStartPosition
+ , sal_Int32 nRowCount, sal_Bool bDirection )
+ throw( RuntimeException )
+{
+ FETCH_XXX( impl_getCurrentRowContent, m_xRowOrigin );
+}
+
+sal_Int32 SAL_CALL CachedContentResultSetStub
+ ::impl_getColumnCount()
+{
+ sal_Int32 nCount;
+ sal_Bool bCached;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ nCount = m_nColumnCount;
+ bCached = m_bColumnCountCached;
+ }
+ if( !bCached )
+ {
+ try
+ {
+ Reference< XResultSetMetaData > xMetaData = getMetaData();
+ if( xMetaData.is() )
+ nCount = xMetaData->getColumnCount();
+ }
+ catch( SQLException& )
+ {
+ DBG_ERROR( "couldn't determine the column count" );
+ nCount = 0;
+ }
+ }
+ vos::OGuard aGuard( m_aMutex );
+ m_nColumnCount = nCount;
+ m_bColumnCountCached = sal_True;
+ return m_nColumnCount;
+}
+
+void SAL_CALL CachedContentResultSetStub
+ ::impl_getCurrentRowContent( Any& rRowContent
+ , Reference< XRow > xRow )
+ throw ( SQLException, RuntimeException )
+{
+ sal_Int32 nCount = impl_getColumnCount();
+
+ Sequence< Any > aContent( nCount );
+ for( sal_Int32 nN = 1; nN <= nCount; nN++ )
+ {
+ aContent[nN-1] = xRow->getObject( nN, NULL );
+ }
+
+ rRowContent <<= aContent;
+}
+
+//-----------------------------------------------------------------
+// XFetchProviderForContentAccess methods.
+//-----------------------------------------------------------------
+
+void SAL_CALL CachedContentResultSetStub
+ ::impl_getCurrentContentIdentifierString( Any& rAny
+ , Reference< XContentAccess > xContentAccess )
+ throw ( RuntimeException )
+{
+ rAny <<= xContentAccess->queryContentIdentfierString();
+}
+
+void SAL_CALL CachedContentResultSetStub
+ ::impl_getCurrentContentIdentifier( Any& rAny
+ , Reference< XContentAccess > xContentAccess )
+ throw ( RuntimeException )
+{
+ rAny <<= xContentAccess->queryContentIdentifier();
+}
+
+void SAL_CALL CachedContentResultSetStub
+ ::impl_getCurrentContent( Any& rAny
+ , Reference< XContentAccess > xContentAccess )
+ throw ( RuntimeException )
+{
+ rAny <<= xContentAccess->queryContent();
+}
+
+//virtual
+FetchResult SAL_CALL CachedContentResultSetStub
+ ::fetchContentIdentifierStrings( sal_Int32 nRowStartPosition
+ , sal_Int32 nRowCount, sal_Bool bDirection )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ FETCH_XXX( impl_getCurrentContentIdentifierString, m_xContentAccessOrigin );
+}
+
+//virtual
+FetchResult SAL_CALL CachedContentResultSetStub
+ ::fetchContentIdentifiers( sal_Int32 nRowStartPosition
+ , sal_Int32 nRowCount, sal_Bool bDirection )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ FETCH_XXX( impl_getCurrentContentIdentifier, m_xContentAccessOrigin );
+}
+
+//virtual
+FetchResult SAL_CALL CachedContentResultSetStub
+ ::fetchContents( sal_Int32 nRowStartPosition
+ , sal_Int32 nRowCount, sal_Bool bDirection )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ FETCH_XXX( impl_getCurrentContent, m_xContentAccessOrigin );
+}
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// class CachedContentResultSetStubFactory
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+CachedContentResultSetStubFactory::CachedContentResultSetStubFactory(
+ const Reference< XMultiServiceFactory > & rSMgr )
+{
+ m_xSMgr = rSMgr;
+}
+
+CachedContentResultSetStubFactory::~CachedContentResultSetStubFactory()
+{
+}
+
+//--------------------------------------------------------------------------
+// CachedContentResultSetStubFactory XInterface methods.
+//--------------------------------------------------------------------------
+
+XINTERFACE_IMPL_3( CachedContentResultSetStubFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XCachedContentResultSetStubFactory );
+
+//--------------------------------------------------------------------------
+// CachedContentResultSetStubFactory XTypeProvider methods.
+//--------------------------------------------------------------------------
+
+XTYPEPROVIDER_IMPL_3( CachedContentResultSetStubFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XCachedContentResultSetStubFactory );
+
+//--------------------------------------------------------------------------
+// CachedContentResultSetStubFactory XServiceInfo methods.
+//--------------------------------------------------------------------------
+
+XSERVICEINFO_IMPL_1( CachedContentResultSetStubFactory,
+ OUString::createFromAscii( "CachedContentResultSetStubFactory" ),
+ OUString::createFromAscii( CACHED_CRS_STUB_FACTORY_NAME ) );
+
+//--------------------------------------------------------------------------
+// Service factory implementation.
+//--------------------------------------------------------------------------
+
+ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedContentResultSetStubFactory );
+
+//--------------------------------------------------------------------------
+// CachedContentResultSetStubFactory XCachedContentResultSetStubFactory methods.
+//--------------------------------------------------------------------------
+
+ //virtual
+Reference< XResultSet > SAL_CALL CachedContentResultSetStubFactory
+ ::createCachedContentResultSetStub(
+ const Reference< XResultSet > & xSource )
+ throw( RuntimeException )
+{
+ Reference< XResultSet > xRet;
+ xRet = new CachedContentResultSetStub( xSource );
+ return xRet;
+}
+
+
diff --git a/ucb/source/cacher/cachedcontentresultsetstub.hxx b/ucb/source/cacher/cachedcontentresultsetstub.hxx
new file mode 100644
index 000000000000..550d78b19dd7
--- /dev/null
+++ b/ucb/source/cacher/cachedcontentresultsetstub.hxx
@@ -0,0 +1,229 @@
+/*************************************************************************
+ *
+ * $RCSfile: cachedcontentresultsetstub.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CACHED_CONTENT_RESULTSET_STUB_HXX
+#define _CACHED_CONTENT_RESULTSET_STUB_HXX
+
+#ifndef _CONTENT_RESULTSET_WRAPPER_HXX
+#include <contentresultsetwrapper.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XFETCHPROVIDER_HPP_
+#include <com/sun/star/ucb/XFetchProvider.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XFETCHPROVIDERFORCONTENTACCESS_HPP_
+#include <com/sun/star/ucb/XFetchProviderForContentAccess.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XCACHEDCONTENTRESULTSETSTUBFACTORY_HPP_
+#include <com/sun/star/ucb/XCachedContentResultSetStubFactory.hpp>
+#endif
+
+#define CACHED_CRS_STUB_SERVICE_NAME "com.sun.star.ucb.CachedContentResultSetStub"
+#define CACHED_CRS_STUB_FACTORY_NAME "com.sun.star.ucb.CachedContentResultSetStubFactory"
+
+//=========================================================================
+
+class CachedContentResultSetStub
+ : public ContentResultSetWrapper
+ , public com::sun::star::lang::XTypeProvider
+ , public com::sun::star::lang::XServiceInfo
+ , public com::sun::star::ucb::XFetchProvider
+ , public com::sun::star::ucb::XFetchProviderForContentAccess
+{
+private:
+ sal_Int32 m_nColumnCount;
+ sal_Int32 m_bColumnCountCached;
+
+ void SAL_CALL
+ impl_getCurrentRowContent(
+ com::sun::star::uno::Any& rRowContent,
+ com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XRow > xRow )
+ throw ( com::sun::star::sdbc::SQLException
+ , com::sun::star::uno::RuntimeException );
+
+ sal_Int32 SAL_CALL
+ impl_getColumnCount();
+
+ void SAL_CALL
+ impl_getCurrentContentIdentifierString(
+ com::sun::star::uno::Any& rAny
+ , com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentAccess > xContentAccess )
+ throw ( com::sun::star::uno::RuntimeException );
+
+ void SAL_CALL
+ impl_getCurrentContentIdentifier(
+ com::sun::star::uno::Any& rAny
+ , com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentAccess > xContentAccess )
+ throw ( com::sun::star::uno::RuntimeException );
+
+ void SAL_CALL
+ impl_getCurrentContent(
+ com::sun::star::uno::Any& rAny
+ , com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentAccess > xContentAccess )
+ throw ( com::sun::star::uno::RuntimeException );
+
+public:
+ CachedContentResultSetStub( com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet > xOrigin );
+
+ virtual ~CachedContentResultSetStub();
+
+
+ //-----------------------------------------------------------------
+ // XInterface inherited
+ //-----------------------------------------------------------------
+ XINTERFACE_DECL()
+ //-----------------------------------------------------------------
+ // XTypeProvider
+ //-----------------------------------------------------------------
+ XTYPEPROVIDER_DECL()
+ //-----------------------------------------------------------------
+ // XServiceInfo
+ //-----------------------------------------------------------------
+ XSERVICEINFO_NOFACTORY_DECL()
+
+ //-----------------------------------------------------------------
+ // XFetchProvider
+ //-----------------------------------------------------------------
+
+ virtual com::sun::star::ucb::FetchResult SAL_CALL
+ fetch( sal_Int32 nRowStartPosition
+ , sal_Int32 nRowCount, sal_Bool bDirection )
+ throw( com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XFetchProviderForContentAccess
+ //-----------------------------------------------------------------
+ virtual com::sun::star::ucb::FetchResult SAL_CALL
+ fetchContentIdentifierStrings( sal_Int32 nRowStartPosition
+ , sal_Int32 nRowCount, sal_Bool bDirection )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::ucb::FetchResult SAL_CALL
+ fetchContentIdentifiers( sal_Int32 nRowStartPosition
+ , sal_Int32 nRowCount, sal_Bool bDirection )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::ucb::FetchResult SAL_CALL
+ fetchContents( sal_Int32 nRowStartPosition
+ , sal_Int32 nRowCount, sal_Bool bDirection )
+ throw( com::sun::star::uno::RuntimeException );
+};
+
+//=========================================================================
+
+class CachedContentResultSetStubFactory
+ : public cppu::OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public com::sun::star::lang::XServiceInfo
+ , public com::sun::star::ucb::XCachedContentResultSetStubFactory
+{
+protected:
+ com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+
+public:
+
+ CachedContentResultSetStubFactory(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > & rSMgr);
+
+ virtual ~CachedContentResultSetStubFactory();
+
+ //-----------------------------------------------------------------
+ // XInterface
+ XINTERFACE_DECL()
+
+ //-----------------------------------------------------------------
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ //-----------------------------------------------------------------
+ // XServiceInfo
+ XSERVICEINFO_DECL()
+
+ //-----------------------------------------------------------------
+ // XCachedContentResultSetStubFactory
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet > SAL_CALL
+ createCachedContentResultSetStub(
+ const com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet > & xSource )
+ throw( com::sun::star::uno::RuntimeException );
+};
+
+#endif
+
diff --git a/ucb/source/cacher/cacheddynamicresultset.cxx b/ucb/source/cacher/cacheddynamicresultset.cxx
new file mode 100644
index 000000000000..e27a1e2d7bbc
--- /dev/null
+++ b/ucb/source/cacher/cacheddynamicresultset.cxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * $RCSfile: cacheddynamicresultset.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <cacheddynamicresultset.hxx>
+
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+
+#ifndef _CACHED_CONTENT_RESULTSET_HXX
+#include <cachedcontentresultset.hxx>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace rtl;
+
+CachedDynamicResultSet::CachedDynamicResultSet(
+ Reference< XDynamicResultSet > xOrigin
+ , const Reference< XContentIdentifierMapping > & xContentMapping
+ , const Reference< XMultiServiceFactory > & xSMgr )
+ : DynamicResultSetWrapper( xOrigin, xSMgr )
+ , m_xContentIdentifierMapping( xContentMapping )
+{
+ impl_init();
+}
+
+CachedDynamicResultSet::~CachedDynamicResultSet()
+{
+ impl_deinit();
+}
+
+//virtual
+void SAL_CALL CachedDynamicResultSet
+ ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
+{
+ DynamicResultSetWrapper::impl_InitResultSetOne( xResultSet );
+ DBG_ASSERT( m_xSourceResultOne.is(), "need source resultset" )
+
+ Reference< XResultSet > xCache(
+ new CachedContentResultSet( m_xSourceResultOne, m_xContentIdentifierMapping ) );
+
+ vos::OGuard aGuard( m_aMutex );
+ m_xMyResultOne = xCache;
+}
+
+//virtual
+void SAL_CALL CachedDynamicResultSet
+ ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
+{
+ DynamicResultSetWrapper::impl_InitResultSetTwo( xResultSet );
+ DBG_ASSERT( m_xSourceResultTwo.is(), "need source resultset" )
+
+ Reference< XResultSet > xCache(
+ new CachedContentResultSet( m_xSourceResultTwo, m_xContentIdentifierMapping ) );
+
+ vos::OGuard aGuard( m_aMutex );
+ m_xMyResultTwo = xCache;
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods.
+//--------------------------------------------------------------------------
+XINTERFACE_COMMON_IMPL( CachedDynamicResultSet )
+
+Any SAL_CALL CachedDynamicResultSet
+ ::queryInterface( const Type& rType )
+ throw ( RuntimeException )
+{
+ //list all interfaces inclusive baseclasses of interfaces
+
+ Any aRet = DynamicResultSetWrapper::queryInterface( rType );
+ if( aRet.hasValue() )
+ return aRet;
+
+ aRet = cppu::queryInterface( rType,
+ static_cast< XTypeProvider* >( this )
+ , static_cast< XServiceInfo* >( this )
+ );
+ return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
+}
+
+//--------------------------------------------------------------------------
+// XTypeProvider methods.
+//--------------------------------------------------------------------------
+//list all interfaces exclusive baseclasses
+XTYPEPROVIDER_IMPL_4( CachedDynamicResultSet
+ , XTypeProvider
+ , XServiceInfo
+ , XDynamicResultSet
+ , XSourceInitialization
+ );
+
+//--------------------------------------------------------------------------
+// XServiceInfo methods.
+//--------------------------------------------------------------------------
+
+XSERVICEINFO_NOFACTORY_IMPL_1( CachedDynamicResultSet,
+ OUString::createFromAscii( "CachedDynamicResultSet" ),
+ OUString::createFromAscii( CACHED_DRS_SERVICE_NAME ) );
+
+//--------------------------------------------------------------------------
+// own methds. ( inherited )
+//--------------------------------------------------------------------------
+//virtual
+void SAL_CALL CachedDynamicResultSet
+ ::impl_disposing( const EventObject& Source )
+ throw( RuntimeException )
+{
+ DynamicResultSetWrapper::impl_disposing( Source );
+ m_xContentIdentifierMapping.clear();
+}
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// class CachedDynamicResultSetFactory
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+CachedDynamicResultSetFactory::CachedDynamicResultSetFactory(
+ const Reference< XMultiServiceFactory > & rSMgr )
+{
+ m_xSMgr = rSMgr;
+}
+
+CachedDynamicResultSetFactory::~CachedDynamicResultSetFactory()
+{
+}
+
+//--------------------------------------------------------------------------
+// CachedDynamicResultSetFactory XInterface methods.
+//--------------------------------------------------------------------------
+
+XINTERFACE_IMPL_3( CachedDynamicResultSetFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XCachedDynamicResultSetFactory );
+
+//--------------------------------------------------------------------------
+// CachedDynamicResultSetFactory XTypeProvider methods.
+//--------------------------------------------------------------------------
+
+XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XCachedDynamicResultSetFactory );
+
+//--------------------------------------------------------------------------
+// CachedDynamicResultSetFactory XServiceInfo methods.
+//--------------------------------------------------------------------------
+
+XSERVICEINFO_IMPL_1( CachedDynamicResultSetFactory,
+ OUString::createFromAscii( "CachedDynamicResultSetFactory" ),
+ OUString::createFromAscii( CACHED_DRS_FACTORY_NAME ) );
+
+//--------------------------------------------------------------------------
+// Service factory implementation.
+//--------------------------------------------------------------------------
+
+ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedDynamicResultSetFactory );
+
+//--------------------------------------------------------------------------
+// CachedDynamicResultSetFactory XCachedDynamicResultSetFactory methods.
+//--------------------------------------------------------------------------
+
+//virtual
+Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetFactory
+ ::createCachedDynamicResultSet(
+ const Reference< XDynamicResultSet > & SourceStub
+ , const Reference< XContentIdentifierMapping > & ContentIdentifierMapping )
+ throw( RuntimeException )
+{
+ Reference< XDynamicResultSet > xRet;
+ xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xSMgr );
+ return xRet;
+}
+
+
diff --git a/ucb/source/cacher/cacheddynamicresultset.hxx b/ucb/source/cacher/cacheddynamicresultset.hxx
new file mode 100644
index 000000000000..af58c47b761d
--- /dev/null
+++ b/ucb/source/cacher/cacheddynamicresultset.hxx
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * $RCSfile: cacheddynamicresultset.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CACHED_DYNAMIC_RESULTSET_HXX
+#define _CACHED_DYNAMIC_RESULTSET_HXX
+
+#ifndef _DYNAMIC_RESULTSET_WRAPPER_HXX
+#include <dynamicresultsetwrapper.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XCONTENTIDENTIFIERMAPPING_HPP_
+#include <com/sun/star/ucb/XContentIdentifierMapping.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XCACHEDDYNAMICRESULTSETFACTORY_HPP_
+#include <com/sun/star/ucb/XCachedDynamicResultSetFactory.hpp>
+#endif
+
+#define CACHED_DRS_SERVICE_NAME "com.sun.star.ucb.CachedDynamicResultSet"
+#define CACHED_DRS_FACTORY_NAME "com.sun.star.ucb.CachedDynamicResultSetFactory"
+
+//=========================================================================
+
+class CachedDynamicResultSet
+ : public DynamicResultSetWrapper
+ , public com::sun::star::lang::XTypeProvider
+ , public com::sun::star::lang::XServiceInfo
+{
+ com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifierMapping >
+ m_xContentIdentifierMapping;
+
+protected:
+ virtual void SAL_CALL
+ impl_InitResultSetOne( const com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet >& xResultSet );
+ virtual void SAL_CALL
+ impl_InitResultSetTwo( const com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet >& xResultSet );
+
+public:
+ CachedDynamicResultSet( com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDynamicResultSet > xOrigin
+ , const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifierMapping > & xContentMapping
+ , const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > & xSMgr );
+
+ virtual ~CachedDynamicResultSet();
+
+
+ //-----------------------------------------------------------------
+ // XInterface inherited
+ //-----------------------------------------------------------------
+ XINTERFACE_DECL()
+ //-----------------------------------------------------------------
+ // XTypeProvider
+ //-----------------------------------------------------------------
+ XTYPEPROVIDER_DECL()
+ //-----------------------------------------------------------------
+ // XServiceInfo
+ //-----------------------------------------------------------------
+ XSERVICEINFO_NOFACTORY_DECL()
+
+ //-----------------------------------------------------------------
+ // own methods ( inherited )
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ impl_disposing( const com::sun::star::lang::EventObject& Source )
+ throw( com::sun::star::uno::RuntimeException );
+};
+
+//=========================================================================
+
+class CachedDynamicResultSetFactory
+ : public cppu::OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public com::sun::star::lang::XServiceInfo
+ , public com::sun::star::ucb::XCachedDynamicResultSetFactory
+{
+protected:
+ com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+
+public:
+
+ CachedDynamicResultSetFactory(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > & rSMgr);
+
+ virtual ~CachedDynamicResultSetFactory();
+
+ //-----------------------------------------------------------------
+ // XInterface
+ XINTERFACE_DECL()
+
+ //-----------------------------------------------------------------
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ //-----------------------------------------------------------------
+ // XServiceInfo
+ XSERVICEINFO_DECL()
+
+ //-----------------------------------------------------------------
+ // XCachedDynamicResultSetFactory
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDynamicResultSet > SAL_CALL
+ createCachedDynamicResultSet(
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDynamicResultSet > &
+ SourceStub
+ , const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifierMapping > &
+ ContentIdentifierMapping
+ )
+ throw( com::sun::star::uno::RuntimeException );
+};
+
+#endif
+
diff --git a/ucb/source/cacher/cacheddynamicresultsetstub.cxx b/ucb/source/cacher/cacheddynamicresultsetstub.cxx
new file mode 100644
index 000000000000..8cfc093976df
--- /dev/null
+++ b/ucb/source/cacher/cacheddynamicresultsetstub.cxx
@@ -0,0 +1,278 @@
+/*************************************************************************
+ *
+ * $RCSfile: cacheddynamicresultsetstub.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <cacheddynamicresultsetstub.hxx>
+
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+
+#ifndef _CACHED_CONTENT_RESULTSET_STUB_HXX
+#include <cachedcontentresultsetstub.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_CONTENTRESULTSETCAPABILITY_HPP_
+#include <com/sun/star/ucb/ContentResultSetCapability.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XSORTEDDYNAMICRESULTSETFACTORY_HPP_
+#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace rtl;
+
+CachedDynamicResultSetStub::CachedDynamicResultSetStub(
+ Reference< XDynamicResultSet > xOrigin
+ , const Reference< XMultiServiceFactory > & xSMgr )
+ : DynamicResultSetWrapper( xOrigin, xSMgr )
+{
+ DBG_ASSERT( m_xSMgr.is(), "need Multiservicefactory to create stub" );
+ impl_init();
+}
+
+CachedDynamicResultSetStub::~CachedDynamicResultSetStub()
+{
+ impl_deinit();
+}
+
+//virtual
+void SAL_CALL CachedDynamicResultSetStub
+ ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
+{
+ DynamicResultSetWrapper::impl_InitResultSetOne( xResultSet );
+ DBG_ASSERT( m_xSourceResultOne.is(), "need source resultset" )
+
+ Reference< XResultSet > xStub(
+ new CachedContentResultSetStub( m_xSourceResultOne ) );
+
+ vos::OGuard aGuard( m_aMutex );
+ m_xMyResultOne = xStub;
+}
+
+//virtual
+void SAL_CALL CachedDynamicResultSetStub
+ ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
+{
+ DynamicResultSetWrapper::impl_InitResultSetTwo( xResultSet );
+ DBG_ASSERT( m_xSourceResultTwo.is(), "need source resultset" )
+
+ Reference< XResultSet > xStub(
+ new CachedContentResultSetStub( m_xSourceResultTwo ) );
+
+ vos::OGuard aGuard( m_aMutex );
+ m_xMyResultTwo = xStub;
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods.
+//--------------------------------------------------------------------------
+XINTERFACE_COMMON_IMPL( CachedDynamicResultSetStub )
+
+Any SAL_CALL CachedDynamicResultSetStub
+ ::queryInterface( const Type& rType )
+ throw ( RuntimeException )
+{
+ //list all interfaces inclusive baseclasses of interfaces
+
+ Any aRet = DynamicResultSetWrapper::queryInterface( rType );
+ if( aRet.hasValue() )
+ return aRet;
+
+ aRet = cppu::queryInterface( rType,
+ static_cast< XTypeProvider* >( this )
+ , static_cast< XServiceInfo* >( this )
+ );
+ return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
+}
+
+//--------------------------------------------------------------------------
+// XTypeProvider methods.
+//--------------------------------------------------------------------------
+//list all interfaces exclusive baseclasses
+XTYPEPROVIDER_IMPL_5( CachedDynamicResultSetStub
+ , XTypeProvider
+ , XServiceInfo
+ , XDynamicResultSet
+ , XDynamicResultSetListener
+ , XSourceInitialization
+ );
+
+//--------------------------------------------------------------------------
+// XServiceInfo methods.
+//--------------------------------------------------------------------------
+
+XSERVICEINFO_NOFACTORY_IMPL_1( CachedDynamicResultSetStub,
+ OUString::createFromAscii( "CachedDynamicResultSetStub" ),
+ OUString::createFromAscii( CACHED_DRS_STUB_SERVICE_NAME ) );
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// class CachedDynamicResultSetStubFactory
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+CachedDynamicResultSetStubFactory::CachedDynamicResultSetStubFactory(
+ const Reference< XMultiServiceFactory > & rSMgr )
+{
+ m_xSMgr = rSMgr;
+}
+
+CachedDynamicResultSetStubFactory::~CachedDynamicResultSetStubFactory()
+{
+}
+
+//--------------------------------------------------------------------------
+// CachedDynamicResultSetStubFactory XInterface methods.
+//--------------------------------------------------------------------------
+
+XINTERFACE_IMPL_3( CachedDynamicResultSetStubFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XCachedDynamicResultSetStubFactory );
+
+//--------------------------------------------------------------------------
+// CachedDynamicResultSetStubFactory XTypeProvider methods.
+//--------------------------------------------------------------------------
+
+XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetStubFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XCachedDynamicResultSetStubFactory );
+
+//--------------------------------------------------------------------------
+// CachedDynamicResultSetStubFactory XServiceInfo methods.
+//--------------------------------------------------------------------------
+
+XSERVICEINFO_IMPL_1( CachedDynamicResultSetStubFactory,
+ OUString::createFromAscii( "CachedDynamicResultSetStubFactory" ),
+ OUString::createFromAscii( CACHED_DRS_STUB_FACTORY_NAME ) );
+
+//--------------------------------------------------------------------------
+// Service factory implementation.
+//--------------------------------------------------------------------------
+
+ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedDynamicResultSetStubFactory );
+
+//--------------------------------------------------------------------------
+// CachedDynamicResultSetStubFactory XCachedDynamicResultSetStubFactory methods.
+//--------------------------------------------------------------------------
+
+//virtual
+Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetStubFactory
+ ::createCachedDynamicResultSetStub(
+ const Reference< XDynamicResultSet > & Source )
+ throw( RuntimeException )
+{
+ Reference< XDynamicResultSet > xRet;
+ xRet = new CachedDynamicResultSetStub( Source, m_xSMgr );
+ return xRet;
+}
+
+//virtual
+void SAL_CALL CachedDynamicResultSetStubFactory
+ ::connectToCache(
+ const Reference< XDynamicResultSet > & Source
+ , const Reference< XDynamicResultSet > & TargetCache
+ , const Sequence< NumberedSortingInfo > & SortingInfo
+ , const Reference< XAnyCompareFactory > & CompareFactory
+ )
+ throw ( ListenerAlreadySetException
+ , AlreadyInitializedException
+ , RuntimeException )
+{
+ DBG_ASSERT( Source.is(), "a Source is needed" );
+ DBG_ASSERT( TargetCache.is(), "a TargetCache is needed" );
+
+ Reference< XDynamicResultSet > xSource( Source );
+ if( SortingInfo.getLength() &&
+ !( xSource->getCapabilities() & ContentResultSetCapability::SORTED )
+ )
+ {
+ Reference< XSortedDynamicResultSetFactory > xSortFactory(
+ m_xSMgr->createInstance( OUString::createFromAscii(
+ "com.sun.star.ucb.SortedDynamicResultSetFactory" ) ), UNO_QUERY );
+ if( xSortFactory.is() )
+ {
+ Reference< XDynamicResultSet > xSorted(
+ xSortFactory->createSortedDynamicResultSet(
+ Source, SortingInfo, CompareFactory ) );
+ if( xSorted.is() )
+ xSource = xSorted;
+ }
+ }
+
+ Reference< XDynamicResultSet > xStub(
+ new CachedDynamicResultSetStub( xSource, m_xSMgr ) );
+
+ Reference< XSourceInitialization > xTarget( TargetCache, UNO_QUERY );
+ DBG_ASSERT( xTarget.is(), "Target must have interface XSourceInitialization" );
+
+ xTarget->setSource( xStub );
+}
+
diff --git a/ucb/source/cacher/cacheddynamicresultsetstub.hxx b/ucb/source/cacher/cacheddynamicresultsetstub.hxx
new file mode 100644
index 000000000000..c6f19883600d
--- /dev/null
+++ b/ucb/source/cacher/cacheddynamicresultsetstub.hxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * $RCSfile: cacheddynamicresultsetstub.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CACHED_DYNAMIC_RESULTSET_STUB_HXX
+#define _CACHED_DYNAMIC_RESULTSET_STUB_HXX
+
+#ifndef _DYNAMIC_RESULTSET_WRAPPER_HXX
+#include <dynamicresultsetwrapper.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XCACHEDDYNAMICRESULTSETSTUBFACTORY_HPP_
+#include <com/sun/star/ucb/XCachedDynamicResultSetStubFactory.hpp>
+#endif
+
+#define CACHED_DRS_STUB_SERVICE_NAME "com.sun.star.ucb.CachedDynamicResultSetStub"
+#define CACHED_DRS_STUB_FACTORY_NAME "com.sun.star.ucb.CachedDynamicResultSetStubFactory"
+
+//=========================================================================
+
+class CachedDynamicResultSetStub
+ : public DynamicResultSetWrapper
+ , public com::sun::star::lang::XTypeProvider
+ , public com::sun::star::lang::XServiceInfo
+{
+protected:
+ virtual void SAL_CALL
+ impl_InitResultSetOne( const com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet >& xResultSet );
+ virtual void SAL_CALL
+ impl_InitResultSetTwo( const com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet >& xResultSet );
+
+public:
+ CachedDynamicResultSetStub( com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDynamicResultSet > xOrigin
+ , const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > & xSMgr );
+
+ virtual ~CachedDynamicResultSetStub();
+
+
+ //-----------------------------------------------------------------
+ // XInterface inherited
+ //-----------------------------------------------------------------
+ XINTERFACE_DECL()
+ //-----------------------------------------------------------------
+ // XTypeProvider
+ //-----------------------------------------------------------------
+ XTYPEPROVIDER_DECL()
+ //-----------------------------------------------------------------
+ // XServiceInfo
+ //-----------------------------------------------------------------
+ XSERVICEINFO_NOFACTORY_DECL()
+};
+
+//=========================================================================
+
+class CachedDynamicResultSetStubFactory
+ : public cppu::OWeakObject
+ , public com::sun::star::lang::XTypeProvider
+ , public com::sun::star::lang::XServiceInfo
+ , public com::sun::star::ucb::XCachedDynamicResultSetStubFactory
+{
+protected:
+ com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+
+public:
+
+ CachedDynamicResultSetStubFactory(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > & rSMgr);
+
+ virtual ~CachedDynamicResultSetStubFactory();
+
+ //-----------------------------------------------------------------
+ // XInterface
+ XINTERFACE_DECL()
+
+ //-----------------------------------------------------------------
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ //-----------------------------------------------------------------
+ // XServiceInfo
+ XSERVICEINFO_DECL()
+
+ //-----------------------------------------------------------------
+ // XCachedDynamicResultSetStubFactory
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDynamicResultSet > SAL_CALL
+ createCachedDynamicResultSetStub(
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDynamicResultSet > & Source )
+ throw( com::sun::star::uno::RuntimeException );
+
+
+ virtual void SAL_CALL connectToCache(
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDynamicResultSet > & Source
+ , const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDynamicResultSet > & TargetCache
+ , const com::sun::star::uno::Sequence<
+ com::sun::star::ucb::NumberedSortingInfo > & SortingInfo
+ , const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XAnyCompareFactory > & CompareFactory
+ )
+ throw (
+ com::sun::star::ucb::ListenerAlreadySetException
+ , com::sun::star::ucb::AlreadyInitializedException
+ , com::sun::star::uno::RuntimeException
+ );
+};
+
+#endif
+
diff --git a/ucb/source/cacher/cacheserv.cxx b/ucb/source/cacher/cacheserv.cxx
new file mode 100644
index 000000000000..0f0574b76937
--- /dev/null
+++ b/ucb/source/cacher/cacheserv.cxx
@@ -0,0 +1,235 @@
+/*************************************************************************
+ *
+ * $RCSfile: cacheserv.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+
+#ifndef _CACHED_CONTENT_RESULTSET_HXX
+#include <cachedcontentresultset.hxx>
+#endif
+#ifndef _CACHED_CONTENT_RESULTSET_STUB_HXX
+#include <cachedcontentresultsetstub.hxx>
+#endif
+#ifndef _CACHED_DYNAMIC_RESULTSET_HXX
+#include <cacheddynamicresultset.hxx>
+#endif
+#ifndef _CACHED_DYNAMIC_RESULTSET_STUB_HXX
+#include <cacheddynamicresultsetstub.hxx>
+#endif
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+//=========================================================================
+static sal_Bool writeInfo( void * pRegistryKey,
+ const OUString & rImplementationName,
+ Sequence< OUString > const & rServiceNames )
+{
+ OUString aKeyName( OUString::createFromAscii( "/" ) );
+ aKeyName += rImplementationName;
+ aKeyName += OUString::createFromAscii( "/UNO/SERVICES" );
+
+ Reference< XRegistryKey > xKey;
+ try
+ {
+ xKey = static_cast< XRegistryKey * >(
+ pRegistryKey )->createKey( aKeyName );
+ }
+ catch ( InvalidRegistryException const & )
+ {
+ }
+
+ if ( !xKey.is() )
+ return sal_False;
+
+ sal_Bool bSuccess = sal_True;
+
+ for ( sal_Int32 n = 0; n < rServiceNames.getLength(); ++n )
+ {
+ try
+ {
+ xKey->createKey( rServiceNames[ n ] );
+ }
+ catch ( InvalidRegistryException const & )
+ {
+ bSuccess = sal_False;
+ break;
+ }
+ }
+ return bSuccess;
+}
+
+//=========================================================================
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//=========================================================================
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ return pRegistryKey &&
+
+ //////////////////////////////////////////////////////////////////////
+ // CachedContentResultSetFactory.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ CachedContentResultSetFactory::getImplementationName_Static(),
+ CachedContentResultSetFactory::getSupportedServiceNames_Static() ) &&
+
+ //////////////////////////////////////////////////////////////////////
+ // CachedContentResultSetStubFactory.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ CachedContentResultSetStubFactory::getImplementationName_Static(),
+ CachedContentResultSetStubFactory::getSupportedServiceNames_Static() ) &&
+
+ //////////////////////////////////////////////////////////////////////
+ // CachedDynamicResultSetFactory.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ CachedDynamicResultSetFactory::getImplementationName_Static(),
+ CachedDynamicResultSetFactory::getSupportedServiceNames_Static() ) &&
+
+ //////////////////////////////////////////////////////////////////////
+ // CachedDynamicResultSetStubFactory.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ CachedDynamicResultSetStubFactory::getImplementationName_Static(),
+ CachedDynamicResultSetStubFactory::getSupportedServiceNames_Static() );
+}
+
+//=========================================================================
+extern "C" void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ Reference< XMultiServiceFactory > xSMgr(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
+ Reference< XSingleServiceFactory > xFactory;
+
+ //////////////////////////////////////////////////////////////////////
+ // CachedContentResultSetFactory.
+ //////////////////////////////////////////////////////////////////////
+
+ if ( CachedContentResultSetFactory::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory = CachedContentResultSetFactory::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // CachedContentResultSetStubFactory.
+ //////////////////////////////////////////////////////////////////////
+
+ else if ( CachedContentResultSetStubFactory::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory = CachedContentResultSetStubFactory::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // CachedDynamicResultSetFactory.
+ //////////////////////////////////////////////////////////////////////
+
+ else if ( CachedDynamicResultSetFactory::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory = CachedDynamicResultSetFactory::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // CachedDynamicResultSetStubFactory.
+ //////////////////////////////////////////////////////////////////////
+
+ else if ( CachedDynamicResultSetStubFactory::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory = CachedDynamicResultSetStubFactory::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+
+ return pRet;
+}
+
diff --git a/ucb/source/cacher/contentresultsetwrapper.cxx b/ucb/source/cacher/contentresultsetwrapper.cxx
new file mode 100644
index 000000000000..8af9075790dd
--- /dev/null
+++ b/ucb/source/cacher/contentresultsetwrapper.cxx
@@ -0,0 +1,1472 @@
+/*************************************************************************
+ *
+ * $RCSfile: contentresultsetwrapper.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <contentresultsetwrapper.hxx>
+
+#ifndef _COM_SUN_STAR_SDBC_FETCHDIRECTION_HPP_
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_FETCHERROR_HPP_
+#include <com/sun/star/ucb/FetchError.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::util;
+using namespace cppu;
+using namespace rtl;
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// class ContentResultSetWrapper
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+ContentResultSetWrapper::ContentResultSetWrapper(
+ Reference< XResultSet > xOrigin )
+ : m_xResultSetOrigin( xOrigin )
+ , m_xRowOrigin( NULL )
+ , m_xContentAccessOrigin( NULL )
+ , m_xPropertySetOrigin( NULL )
+ , m_xPropertySetInfo( NULL )
+ , m_xMetaDataFromOrigin( NULL )
+
+ , m_pDisposeEventListeners( NULL )
+ , m_pPropertyChangeListeners( NULL )
+ , m_pVetoableChangeListeners( NULL )
+
+ , m_bDisposed( sal_False )
+ , m_bInDispose( sal_False )
+
+ , m_nForwardOnly( 2 )
+{
+ m_pMyListenerImpl = new ContentResultSetWrapperListener( this );
+ m_xMyListenerImpl = Reference< XPropertyChangeListener >( m_pMyListenerImpl );
+
+ DBG_ASSERT( m_xResultSetOrigin.is(), "XResultSet is required" );
+
+ m_xRowOrigin = Reference< XRow >( m_xResultSetOrigin, UNO_QUERY );
+ DBG_ASSERT( m_xRowOrigin.is(), "interface XRow is required" );
+
+ m_xContentAccessOrigin = Reference< XContentAccess >( m_xResultSetOrigin, UNO_QUERY );
+ DBG_ASSERT( m_xContentAccessOrigin.is(), "interface XContentAccess is required" );
+
+ m_xPropertySetOrigin = Reference< XPropertySet >( m_xResultSetOrigin, UNO_QUERY );
+ DBG_ASSERT( m_xPropertySetOrigin.is(), "interface XPropertySet is required" );
+
+ //call impl_init() at the end of constructor of derived class
+};
+
+void SAL_CALL ContentResultSetWrapper::impl_init()
+{
+ //call this at the end of constructor of derived class
+ //
+
+ //listen to disposing from Origin:
+ Reference< XComponent > xComponentOrigin( m_xResultSetOrigin, UNO_QUERY );
+ DBG_ASSERT( xComponentOrigin.is(), "interface XComponent is required" );
+ xComponentOrigin->addEventListener( static_cast< XPropertyChangeListener * >( m_pMyListenerImpl ) );
+}
+
+ContentResultSetWrapper::~ContentResultSetWrapper()
+{
+ //call impl_deinit() at start of destructor of derived class
+
+ delete m_pDisposeEventListeners;
+ delete m_pPropertyChangeListeners;
+ delete m_pVetoableChangeListeners;
+};
+
+void SAL_CALL ContentResultSetWrapper::impl_deinit()
+{
+ //call this at start of destructor of derived class
+ //
+ m_pMyListenerImpl->impl_OwnerDies();
+}
+
+//virtual
+void SAL_CALL ContentResultSetWrapper
+ ::impl_initPropertySetInfo()
+{
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( m_xPropertySetInfo.is() )
+ return;
+
+ if( !m_xPropertySetOrigin.is() )
+ return;
+ }
+
+ Reference< XPropertySetInfo > xOrig =
+ m_xPropertySetOrigin->getPropertySetInfo();
+
+ {
+ vos::OGuard aGuard( m_aMutex );
+ m_xPropertySetInfo = xOrig;
+ }
+}
+
+void SAL_CALL ContentResultSetWrapper
+::impl_EnsureNotDisposed()
+ throw( DisposedException, RuntimeException )
+{
+ vos::OGuard aGuard( m_aMutex );
+ if( m_bDisposed )
+ throw DisposedException();
+}
+
+ContentResultSetWrapper::PropertyChangeListenerContainer_Impl* SAL_CALL
+ ContentResultSetWrapper
+ ::impl_getPropertyChangeListenerContainer()
+{
+ vos::OGuard aGuard( m_aMutex );
+ if ( !m_pPropertyChangeListeners )
+ m_pPropertyChangeListeners =
+ new PropertyChangeListenerContainer_Impl( m_aContainerMutex );
+ return m_pPropertyChangeListeners;
+}
+
+ContentResultSetWrapper::PropertyChangeListenerContainer_Impl* SAL_CALL
+ ContentResultSetWrapper
+ ::impl_getVetoableChangeListenerContainer()
+{
+ vos::OGuard aGuard( m_aMutex );
+ if ( !m_pVetoableChangeListeners )
+ m_pVetoableChangeListeners =
+ new PropertyChangeListenerContainer_Impl( m_aContainerMutex );
+ return m_pVetoableChangeListeners;
+}
+
+void SAL_CALL ContentResultSetWrapper
+ ::impl_notifyPropertyChangeListeners(
+ const PropertyChangeEvent& rEvt )
+{
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( !m_pPropertyChangeListeners )
+ return;
+ }
+
+ // Notify listeners interested especially in the changed property.
+ OInterfaceContainerHelper* pContainer =
+ m_pPropertyChangeListeners->getContainer( rEvt.PropertyName );
+ if( pContainer )
+ {
+ OInterfaceIteratorHelper aIter( *pContainer );
+ while( aIter.hasMoreElements() )
+ {
+ Reference< XPropertyChangeListener > xListener(
+ aIter.next(), UNO_QUERY );
+ if( xListener.is() )
+ xListener->propertyChange( rEvt );
+ }
+ }
+
+ // Notify listeners interested in all properties.
+ pContainer = m_pPropertyChangeListeners->getContainer( OUString() );
+ if( pContainer )
+ {
+ OInterfaceIteratorHelper aIter( *pContainer );
+ while( aIter.hasMoreElements() )
+ {
+ Reference< XPropertyChangeListener > xListener(
+ aIter.next(), UNO_QUERY );
+ if( xListener.is() )
+ xListener->propertyChange( rEvt );
+ }
+ }
+}
+
+void SAL_CALL ContentResultSetWrapper
+ ::impl_notifyVetoableChangeListeners( const PropertyChangeEvent& rEvt )
+ throw( PropertyVetoException,
+ RuntimeException )
+{
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( !m_pVetoableChangeListeners )
+ return;
+ }
+
+ // Notify listeners interested especially in the changed property.
+ OInterfaceContainerHelper* pContainer =
+ m_pVetoableChangeListeners->getContainer( rEvt.PropertyName );
+ if( pContainer )
+ {
+ OInterfaceIteratorHelper aIter( *pContainer );
+ while( aIter.hasMoreElements() )
+ {
+ Reference< XVetoableChangeListener > xListener(
+ aIter.next(), UNO_QUERY );
+ if( xListener.is() )
+ xListener->vetoableChange( rEvt );
+ }
+ }
+
+ // Notify listeners interested in all properties.
+ pContainer = m_pVetoableChangeListeners->getContainer( OUString() );
+ if( pContainer )
+ {
+ OInterfaceIteratorHelper aIter( *pContainer );
+ while( aIter.hasMoreElements() )
+ {
+ Reference< XVetoableChangeListener > xListener(
+ aIter.next(), UNO_QUERY );
+ if( xListener.is() )
+ xListener->vetoableChange( rEvt );
+ }
+ }
+}
+
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::impl_isForwardOnly()
+{
+ //m_nForwardOnly == 2 -> don't know
+ //m_nForwardOnly == 1 -> YES
+ //m_nForwardOnly == 0 -> NO
+
+ //@todo replace this with lines in comment
+ vos::OGuard aGuard( m_aMutex );
+ m_nForwardOnly = 0;
+ return m_nForwardOnly;
+
+
+ /*
+ ReacquireableGuard aGuard( m_aMutex );
+ if( m_nForwardOnly == 2 )
+ {
+ aGuard.clear();
+ if( !getPropertySetInfo().is() )
+ {
+ aGuard.reacquire();
+ m_nForwardOnly = 0;
+ return m_nForwardOnly;
+ }
+ aGuard.reacquire();
+
+ rtl::OUString aName = OUString::createFromAscii( "ResultSetType" );
+ //find out, if we are ForwardOnly and cache the value:
+
+ if( !m_xPropertySetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ m_nForwardOnly = 0;
+ return m_nForwardOnly;
+ }
+
+ aGuard.clear();
+ Any aAny = m_xPropertySetOrigin->getPropertyValue( aName );
+
+ aGuard.reacquire();
+ long nResultSetType;
+ if( ( aAny >>= nResultSetType ) &&
+ ( nResultSetType == ResultSetType::FORWARD_ONLY ) )
+ m_nForwardOnly = 1;
+ else
+ m_nForwardOnly = 0;
+ }
+ return m_nForwardOnly;
+ */
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods.
+//--------------------------------------------------------------------------
+//list all interfaces inclusive baseclasses of interfaces
+QUERYINTERFACE_IMPL_START( ContentResultSetWrapper )
+
+ SAL_STATIC_CAST( XComponent*, this ),
+ SAL_STATIC_CAST( XCloseable*, this ),
+ SAL_STATIC_CAST( XResultSetMetaDataSupplier*, this ),
+ SAL_STATIC_CAST( XPropertySet*, this ),
+
+ SAL_STATIC_CAST( XContentAccess*, this ),
+ SAL_STATIC_CAST( XResultSet*, this ),
+ SAL_STATIC_CAST( XRow*, this )
+
+QUERYINTERFACE_IMPL_END
+
+//--------------------------------------------------------------------------
+// XComponent methods.
+//--------------------------------------------------------------------------
+// virtual
+void SAL_CALL ContentResultSetWrapper
+ ::dispose() throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ ReacquireableGuard aGuard( m_aMutex );
+ if( m_bInDispose || m_bDisposed )
+ return;
+ m_bInDispose = sal_True;
+
+ if( m_xPropertySetOrigin.is() )
+ {
+ aGuard.clear();
+ try
+ {
+ m_xPropertySetOrigin->removePropertyChangeListener(
+ OUString(), static_cast< XPropertyChangeListener * >( m_pMyListenerImpl ) );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "could not remove PropertyChangeListener" );
+ }
+ try
+ {
+ m_xPropertySetOrigin->removeVetoableChangeListener(
+ OUString(), static_cast< XVetoableChangeListener * >( m_pMyListenerImpl ) );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "could not remove VetoableChangeListener" );
+ }
+
+ Reference< XComponent > xComponentOrigin( m_xResultSetOrigin, UNO_QUERY );
+ DBG_ASSERT( xComponentOrigin.is(), "interface XComponent is required" );
+ xComponentOrigin->removeEventListener( static_cast< XPropertyChangeListener * >( m_pMyListenerImpl ) );
+ }
+
+ aGuard.reacquire();
+ if( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
+ {
+ EventObject aEvt;
+ aEvt.Source = static_cast< XComponent * >( this );
+
+ aGuard.clear();
+ m_pDisposeEventListeners->disposeAndClear( aEvt );
+ }
+
+ aGuard.reacquire();
+ if( m_pPropertyChangeListeners )
+ {
+ EventObject aEvt;
+ aEvt.Source = static_cast< XPropertySet * >( this );
+
+ aGuard.clear();
+ m_pPropertyChangeListeners->disposeAndClear( aEvt );
+ }
+
+ aGuard.reacquire();
+ if( m_pVetoableChangeListeners )
+ {
+ EventObject aEvt;
+ aEvt.Source = static_cast< XPropertySet * >( this );
+
+ aGuard.clear();
+ m_pVetoableChangeListeners->disposeAndClear( aEvt );
+ }
+
+ aGuard.reacquire();
+ m_bDisposed = sal_True;
+ m_bInDispose = sal_False;
+}
+
+//--------------------------------------------------------------------------
+// virtual
+void SAL_CALL ContentResultSetWrapper
+ ::addEventListener( const Reference< XEventListener >& Listener )
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ vos::OGuard aGuard( m_aMutex );
+
+ if ( !m_pDisposeEventListeners )
+ m_pDisposeEventListeners =
+ new OInterfaceContainerHelper( m_aContainerMutex );
+
+ m_pDisposeEventListeners->addInterface( Listener );
+}
+
+//--------------------------------------------------------------------------
+// virtual
+void SAL_CALL ContentResultSetWrapper
+ ::removeEventListener( const Reference< XEventListener >& Listener )
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ vos::OGuard aGuard( m_aMutex );
+
+ if ( m_pDisposeEventListeners )
+ m_pDisposeEventListeners->removeInterface( Listener );
+}
+
+//--------------------------------------------------------------------------
+//XCloseable methods.
+//--------------------------------------------------------------------------
+//virtual
+void SAL_CALL ContentResultSetWrapper
+ ::close()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ dispose();
+}
+
+//--------------------------------------------------------------------------
+//XResultSetMetaDataSupplier methods.
+//--------------------------------------------------------------------------
+//virtual
+Reference< XResultSetMetaData > SAL_CALL ContentResultSetWrapper
+ ::getMetaData()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ ReacquireableGuard aGuard( m_aMutex );
+ if( !m_xMetaDataFromOrigin.is() && m_xResultSetOrigin.is() )
+ {
+ Reference< XResultSetMetaDataSupplier > xMetaDataSupplier
+ = Reference< XResultSetMetaDataSupplier >(
+ m_xResultSetOrigin, UNO_QUERY );
+
+ if( xMetaDataSupplier.is() )
+ {
+ aGuard.clear();
+
+ Reference< XResultSetMetaData > xMetaData
+ = xMetaDataSupplier->getMetaData();
+
+ aGuard.reacquire();
+ m_xMetaDataFromOrigin = xMetaData;
+ }
+ }
+ return m_xMetaDataFromOrigin;
+}
+
+
+//--------------------------------------------------------------------------
+// XPropertySet methods.
+//--------------------------------------------------------------------------
+// virtual
+Reference< XPropertySetInfo > SAL_CALL ContentResultSetWrapper
+ ::getPropertySetInfo() throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( m_xPropertySetInfo.is() )
+ return m_xPropertySetInfo;
+ }
+ impl_initPropertySetInfo();
+ return m_xPropertySetInfo;
+}
+//--------------------------------------------------------------------------
+// virtual
+void SAL_CALL ContentResultSetWrapper
+ ::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
+ throw( UnknownPropertyException,
+ PropertyVetoException,
+ IllegalArgumentException,
+ WrappedTargetException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xPropertySetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw UnknownPropertyException();
+ }
+ m_xPropertySetOrigin->setPropertyValue( rPropertyName, rValue );
+}
+
+//--------------------------------------------------------------------------
+// virtual
+Any SAL_CALL ContentResultSetWrapper
+ ::getPropertyValue( const OUString& rPropertyName )
+ throw( UnknownPropertyException,
+ WrappedTargetException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xPropertySetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw UnknownPropertyException();
+ }
+ return m_xPropertySetOrigin->getPropertyValue( rPropertyName );
+}
+
+//--------------------------------------------------------------------------
+// virtual
+void SAL_CALL ContentResultSetWrapper
+ ::addPropertyChangeListener(
+ const OUString& aPropertyName,
+ const Reference< XPropertyChangeListener >& xListener )
+ throw( UnknownPropertyException,
+ WrappedTargetException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !getPropertySetInfo().is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw UnknownPropertyException();
+ }
+
+ if( aPropertyName.getLength() )
+ {
+ m_xPropertySetInfo->getPropertyByName( aPropertyName );
+ //throws UnknownPropertyException, if so
+ }
+
+ impl_getPropertyChangeListenerContainer();
+ BOOL bNeedRegister = !m_pPropertyChangeListeners->
+ getContainedTypes().getLength();
+ m_pPropertyChangeListeners->addInterface( aPropertyName, xListener );
+ if( bNeedRegister )
+ {
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( !m_xPropertySetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return;
+ }
+ }
+ try
+ {
+ m_xPropertySetOrigin->addPropertyChangeListener(
+ OUString(), static_cast< XPropertyChangeListener * >( m_pMyListenerImpl ) );
+ }
+ catch( Exception& rEx )
+ {
+ m_pPropertyChangeListeners->removeInterface( aPropertyName, xListener );
+ throw rEx;
+ }
+ }
+}
+
+//--------------------------------------------------------------------------
+// virtual
+void SAL_CALL ContentResultSetWrapper
+ ::addVetoableChangeListener(
+ const OUString& rPropertyName,
+ const Reference< XVetoableChangeListener >& xListener )
+ throw( UnknownPropertyException,
+ WrappedTargetException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !getPropertySetInfo().is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw UnknownPropertyException();
+ }
+ if( rPropertyName.getLength() )
+ {
+ m_xPropertySetInfo->getPropertyByName( rPropertyName );
+ //throws UnknownPropertyException, if so
+ }
+
+ impl_getVetoableChangeListenerContainer();
+ BOOL bNeedRegister = !m_pVetoableChangeListeners->
+ getContainedTypes().getLength();
+ m_pVetoableChangeListeners->addInterface( rPropertyName, xListener );
+ if( bNeedRegister )
+ {
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( !m_xPropertySetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return;
+ }
+ }
+ try
+ {
+ m_xPropertySetOrigin->addVetoableChangeListener(
+ OUString(), static_cast< XVetoableChangeListener * >( m_pMyListenerImpl ) );
+ }
+ catch( Exception& rEx )
+ {
+ m_pVetoableChangeListeners->removeInterface( rPropertyName, xListener );
+ throw rEx;
+ }
+ }
+}
+
+//--------------------------------------------------------------------------
+// virtual
+void SAL_CALL ContentResultSetWrapper
+ ::removePropertyChangeListener(
+ const OUString& rPropertyName,
+ const Reference< XPropertyChangeListener >& xListener )
+ throw( UnknownPropertyException,
+ WrappedTargetException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ {
+ //noop, if no listener registered
+ vos::OGuard aGuard( m_aMutex );
+ if( !m_pPropertyChangeListeners )
+ return;
+ }
+ OInterfaceContainerHelper* pContainer =
+ m_pPropertyChangeListeners->getContainer( rPropertyName );
+
+ if( !pContainer )
+ {
+ if( rPropertyName.getLength() )
+ {
+ if( !getPropertySetInfo().is() )
+ throw UnknownPropertyException();
+
+ m_xPropertySetInfo->getPropertyByName( rPropertyName );
+ //throws UnknownPropertyException, if so
+ }
+ return; //the listener was not registered
+ }
+
+ m_pPropertyChangeListeners->removeInterface( rPropertyName, xListener );
+
+ if( !m_pPropertyChangeListeners->getContainedTypes().getLength() )
+ {
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( !m_xPropertySetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return;
+ }
+ }
+ try
+ {
+ m_xPropertySetOrigin->removePropertyChangeListener(
+ OUString(), static_cast< XPropertyChangeListener * >( m_pMyListenerImpl ) );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "could not remove PropertyChangeListener" );
+ }
+ }
+}
+
+//--------------------------------------------------------------------------
+// virtual
+void SAL_CALL ContentResultSetWrapper
+ ::removeVetoableChangeListener(
+ const OUString& rPropertyName,
+ const Reference< XVetoableChangeListener >& xListener )
+ throw( UnknownPropertyException,
+ WrappedTargetException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ {
+ //noop, if no listener registered
+ vos::OGuard aGuard( m_aMutex );
+ if( !m_pVetoableChangeListeners )
+ return;
+ }
+ OInterfaceContainerHelper* pContainer =
+ m_pVetoableChangeListeners->getContainer( rPropertyName );
+
+ if( !pContainer )
+ {
+ if( rPropertyName.getLength() )
+ {
+ if( !getPropertySetInfo().is() )
+ throw UnknownPropertyException();
+
+ m_xPropertySetInfo->getPropertyByName( rPropertyName );
+ //throws UnknownPropertyException, if so
+ }
+ return; //the listener was not registered
+ }
+
+ m_pVetoableChangeListeners->removeInterface( rPropertyName, xListener );
+
+ if( !m_pVetoableChangeListeners->getContainedTypes().getLength() )
+ {
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( !m_xPropertySetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ return;
+ }
+ }
+ try
+ {
+ m_xPropertySetOrigin->removeVetoableChangeListener(
+ OUString(), static_cast< XVetoableChangeListener * >( m_pMyListenerImpl ) );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "could not remove VetoableChangeListener" );
+ }
+ }
+}
+
+//--------------------------------------------------------------------------
+// own methods.
+//--------------------------------------------------------------------------
+
+//virtual
+void SAL_CALL ContentResultSetWrapper
+ ::impl_disposing( const EventObject& rEventObject )
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ vos::OGuard aGuard( m_aMutex );
+
+ if( !m_xResultSetOrigin.is() )
+ return;
+
+ //release all references to the broadcaster:
+ m_xResultSetOrigin.clear();
+ m_xRowOrigin.clear();
+ m_xContentAccessOrigin.clear();
+ m_xPropertySetOrigin.clear();
+ m_xMetaDataFromOrigin.clear();
+ m_xPropertySetInfo.clear();
+}
+
+//virtual
+void SAL_CALL ContentResultSetWrapper
+ ::impl_propertyChange( const PropertyChangeEvent& rEvt )
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ PropertyChangeEvent aEvt( rEvt );
+ aEvt.Source = static_cast< XPropertySet * >( this );
+ aEvt.Further = FALSE;
+ impl_notifyPropertyChangeListeners( aEvt );
+}
+
+//virtual
+void SAL_CALL ContentResultSetWrapper
+ ::impl_vetoableChange( const PropertyChangeEvent& rEvt )
+ throw( PropertyVetoException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ PropertyChangeEvent aEvt( rEvt );
+ aEvt.Source = static_cast< XPropertySet * >( this );
+ aEvt.Further = FALSE;
+
+ impl_notifyVetoableChangeListeners( aEvt );
+}
+
+//--------------------------------------------------------------------------
+// XContentAccess methods. ( -- position dependent )
+//--------------------------------------------------------------------------
+
+// virtual
+OUString SAL_CALL ContentResultSetWrapper
+ ::queryContentIdentfierString()
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xContentAccessOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xContentAccessOrigin->queryContentIdentfierString();
+}
+
+//--------------------------------------------------------------------------
+// virtual
+Reference< XContentIdentifier > SAL_CALL ContentResultSetWrapper
+ ::queryContentIdentifier()
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xContentAccessOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xContentAccessOrigin->queryContentIdentifier();
+}
+
+//--------------------------------------------------------------------------
+// virtual
+Reference< XContent > SAL_CALL ContentResultSetWrapper
+ ::queryContent()
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xContentAccessOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xContentAccessOrigin->queryContent();
+}
+
+//-----------------------------------------------------------------
+// XResultSet methods.
+//-----------------------------------------------------------------
+//virtual
+
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::next()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->next();
+}
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::previous()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->previous();
+}
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::absolute( sal_Int32 row )
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->absolute( row );
+}
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::relative( sal_Int32 rows )
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->relative( rows );
+}
+
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::first()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->first();
+}
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::last()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->last();
+}
+
+//virtual
+void SAL_CALL ContentResultSetWrapper
+ ::beforeFirst()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ m_xResultSetOrigin->beforeFirst();
+}
+
+//virtual
+void SAL_CALL ContentResultSetWrapper
+ ::afterLast()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ m_xResultSetOrigin->afterLast();
+}
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::isAfterLast()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->isAfterLast();
+}
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::isBeforeFirst()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->isBeforeFirst();
+}
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::isFirst()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->isFirst();
+}
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::isLast()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->isLast();
+}
+
+
+//virtual
+sal_Int32 SAL_CALL ContentResultSetWrapper
+ ::getRow()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->getRow();
+}
+
+//virtual
+void SAL_CALL ContentResultSetWrapper
+ ::refreshRow()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ m_xResultSetOrigin->refreshRow();
+}
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::rowUpdated()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->rowUpdated();
+}
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::rowInserted()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->rowInserted();
+}
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::rowDeleted()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( !m_xResultSetOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xResultSetOrigin->rowDeleted();
+}
+
+//virtual
+Reference< XInterface > SAL_CALL ContentResultSetWrapper
+ ::getStatement()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ //@todo ?return anything
+ return Reference< XInterface >();
+}
+
+//-----------------------------------------------------------------
+// XRow methods.
+//-----------------------------------------------------------------
+
+#define XROW_GETXXX( getXXX ) \
+impl_EnsureNotDisposed(); \
+if( !m_xRowOrigin.is() ) \
+{ \
+ DBG_ERROR( "broadcaster was disposed already" );\
+ throw RuntimeException(); \
+} \
+return m_xRowOrigin->getXXX( columnIndex );
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::wasNull()
+ throw( SQLException,
+ RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ if( !m_xRowOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xRowOrigin->wasNull();
+}
+
+//virtual
+rtl::OUString SAL_CALL ContentResultSetWrapper
+ ::getString( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getString );
+}
+
+//virtual
+sal_Bool SAL_CALL ContentResultSetWrapper
+ ::getBoolean( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getBoolean );
+}
+
+//virtual
+sal_Int8 SAL_CALL ContentResultSetWrapper
+ ::getByte( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getByte );
+}
+
+//virtual
+sal_Int16 SAL_CALL ContentResultSetWrapper
+ ::getShort( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getShort );
+}
+
+//virtual
+sal_Int32 SAL_CALL ContentResultSetWrapper
+ ::getInt( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getInt );
+}
+
+//virtual
+sal_Int64 SAL_CALL ContentResultSetWrapper
+ ::getLong( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getLong );
+}
+
+//virtual
+float SAL_CALL ContentResultSetWrapper
+ ::getFloat( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getFloat );
+}
+
+//virtual
+double SAL_CALL ContentResultSetWrapper
+ ::getDouble( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getDouble );
+}
+
+//virtual
+Sequence< sal_Int8 > SAL_CALL ContentResultSetWrapper
+ ::getBytes( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getBytes );
+}
+
+//virtual
+Date SAL_CALL ContentResultSetWrapper
+ ::getDate( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getDate );
+}
+
+//virtual
+Time SAL_CALL ContentResultSetWrapper
+ ::getTime( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getTime );
+}
+
+//virtual
+DateTime SAL_CALL ContentResultSetWrapper
+ ::getTimestamp( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getTimestamp );
+}
+
+//virtual
+Reference< com::sun::star::io::XInputStream >
+ SAL_CALL ContentResultSetWrapper
+ ::getBinaryStream( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getBinaryStream );
+}
+
+//virtual
+Reference< com::sun::star::io::XInputStream >
+ SAL_CALL ContentResultSetWrapper
+ ::getCharacterStream( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getCharacterStream );
+}
+
+//virtual
+Any SAL_CALL ContentResultSetWrapper
+ ::getObject( sal_Int32 columnIndex,
+ const Reference<
+ com::sun::star::container::XNameAccess >& typeMap )
+ throw( SQLException,
+ RuntimeException )
+{
+ //if you change this macro please pay attention to
+ //define XROW_GETXXX, where this is similar implemented
+
+ impl_EnsureNotDisposed();
+ if( !m_xRowOrigin.is() )
+ {
+ DBG_ERROR( "broadcaster was disposed already" );
+ throw RuntimeException();
+ }
+ return m_xRowOrigin->getObject( columnIndex, typeMap );
+}
+
+//virtual
+Reference< XRef > SAL_CALL ContentResultSetWrapper
+ ::getRef( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getRef );
+}
+
+//virtual
+Reference< XBlob > SAL_CALL ContentResultSetWrapper
+ ::getBlob( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getBlob );
+}
+
+//virtual
+Reference< XClob > SAL_CALL ContentResultSetWrapper
+ ::getClob( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getClob );
+}
+
+//virtual
+Reference< XArray > SAL_CALL ContentResultSetWrapper
+ ::getArray( sal_Int32 columnIndex )
+ throw( SQLException,
+ RuntimeException )
+{
+ XROW_GETXXX( getArray );
+}
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// class ContentResultSetWrapperListener
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+ContentResultSetWrapperListener::ContentResultSetWrapperListener(
+ ContentResultSetWrapper* pOwner )
+ : m_pOwner( pOwner )
+{
+}
+
+ContentResultSetWrapperListener::~ContentResultSetWrapperListener()
+{
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods.
+//--------------------------------------------------------------------------
+//list all interfaces inclusive baseclasses of interfaces
+XINTERFACE_COMMON_IMPL( ContentResultSetWrapperListener )
+QUERYINTERFACE_IMPL_START( ContentResultSetWrapperListener )
+
+ static_cast< XEventListener * >(
+ static_cast< XPropertyChangeListener * >(this))
+ , SAL_STATIC_CAST( XPropertyChangeListener*, this )
+ , SAL_STATIC_CAST( XVetoableChangeListener*, this )
+
+QUERYINTERFACE_IMPL_END
+
+
+//--------------------------------------------------------------------------
+//XEventListener methods.
+//--------------------------------------------------------------------------
+
+//virtual
+void SAL_CALL ContentResultSetWrapperListener
+ ::disposing( const EventObject& rEventObject )
+ throw( RuntimeException )
+{
+ if( m_pOwner )
+ m_pOwner->impl_disposing( rEventObject );
+}
+
+//--------------------------------------------------------------------------
+//XPropertyChangeListener methods.
+//--------------------------------------------------------------------------
+
+//virtual
+void SAL_CALL ContentResultSetWrapperListener
+ ::propertyChange( const PropertyChangeEvent& rEvt )
+ throw( RuntimeException )
+{
+ if( m_pOwner )
+ m_pOwner->impl_propertyChange( rEvt );
+}
+
+//--------------------------------------------------------------------------
+//XVetoableChangeListener methods.
+//--------------------------------------------------------------------------
+//virtual
+void SAL_CALL ContentResultSetWrapperListener
+ ::vetoableChange( const PropertyChangeEvent& rEvt )
+ throw( PropertyVetoException,
+ RuntimeException )
+{
+ if( m_pOwner )
+ m_pOwner->impl_vetoableChange( rEvt );
+}
+
+void SAL_CALL ContentResultSetWrapperListener
+ ::impl_OwnerDies()
+{
+ m_pOwner = NULL;
+}
+
diff --git a/ucb/source/cacher/contentresultsetwrapper.hxx b/ucb/source/cacher/contentresultsetwrapper.hxx
new file mode 100644
index 000000000000..bd56f14b4d34
--- /dev/null
+++ b/ucb/source/cacher/contentresultsetwrapper.hxx
@@ -0,0 +1,649 @@
+/*************************************************************************
+ *
+ * $RCSfile: contentresultsetwrapper.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CONTENT_RESULTSET_WRAPPER_HXX
+#define _CONTENT_RESULTSET_WRAPPER_HXX
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _UCBHELPER_MACROS_HXX
+#include <ucbhelper/macros.hxx>
+#endif
+
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_XCLOSEABLE_HPP_
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XCONTENTACCESS_HPP_
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+//=========================================================================
+
+class ContentResultSetWrapperListener;
+class ContentResultSetWrapper
+ : public cppu::OWeakObject
+ , public com::sun::star::lang::XComponent
+ , public com::sun::star::sdbc::XCloseable
+ , public com::sun::star::sdbc::XResultSetMetaDataSupplier
+ , public com::sun::star::beans::XPropertySet
+ , public com::sun::star::ucb::XContentAccess
+ , public com::sun::star::sdbc::XResultSet
+ , public com::sun::star::sdbc::XRow
+{
+protected:
+
+ //--------------------------------------------------------------------------
+ //class PropertyChangeListenerContainer_Impl.
+
+ 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_Impl;
+ //--------------------------------------------------------------------------
+ // class ReacquireableGuard
+
+ class ReacquireableGuard
+ {
+ protected:
+ vos::OMutex* pT;
+ public:
+
+ ReacquireableGuard(vos::OMutex * pT) : pT(pT)
+ {
+ pT->acquire();
+ }
+
+ ReacquireableGuard(vos::OMutex& t) : pT(&t)
+ {
+ pT->acquire();
+ }
+
+ /** Releases mutex. */
+ ~ReacquireableGuard()
+ {
+ if (pT)
+ pT->release();
+ }
+
+ /** Releases mutex. */
+ void clear()
+ {
+ if(pT)
+ {
+ pT->release();
+ pT = NULL;
+ }
+ }
+
+ /** Reacquire mutex. */
+ void reacquire()
+ {
+ if(pT)
+ {
+ pT->acquire();
+ }
+ }
+ };
+
+ //-----------------------------------------------------------------
+ //members
+
+ //my Mutex
+ vos::OMutex m_aMutex;
+
+ //different Interfaces from Origin:
+ com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
+ m_xResultSetOrigin;
+ com::sun::star::uno::Reference< com::sun::star::sdbc::XRow >
+ m_xRowOrigin; //XRow-interface from m_xOrigin
+ com::sun::star::uno::Reference< com::sun::star::ucb::XContentAccess >
+ m_xContentAccessOrigin; //XContentAccess-interface from m_xOrigin
+ com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >
+ m_xPropertySetOrigin; //XPropertySet-interface from m_xOrigin
+
+ com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >
+ m_xPropertySetInfo;
+
+ sal_Int32 m_nForwardOnly;
+
+private:
+ com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener >
+ m_xMyListenerImpl;
+ ContentResultSetWrapperListener*
+ m_pMyListenerImpl;
+
+ com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData >
+ m_xMetaDataFromOrigin; //XResultSetMetaData from m_xOrigin
+
+ //management of listeners
+ sal_Bool m_bDisposed; ///Dispose call ready.
+ sal_Bool m_bInDispose;///In dispose call
+ osl::Mutex m_aContainerMutex;
+ cppu::OInterfaceContainerHelper*
+ m_pDisposeEventListeners;
+ PropertyChangeListenerContainer_Impl*
+ m_pPropertyChangeListeners;
+ PropertyChangeListenerContainer_Impl*
+ m_pVetoableChangeListeners;
+
+ //-----------------------------------------------------------------
+ //methods:
+private:
+ PropertyChangeListenerContainer_Impl* SAL_CALL
+ impl_getPropertyChangeListenerContainer();
+
+ PropertyChangeListenerContainer_Impl* SAL_CALL
+ impl_getVetoableChangeListenerContainer();
+
+protected:
+ //-----------------------------------------------------------------
+
+ ContentResultSetWrapper( com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet > xOrigin );
+
+ virtual ~ContentResultSetWrapper();
+
+ void SAL_CALL impl_init();
+ void SAL_CALL impl_deinit();
+
+ //--
+
+ virtual void SAL_CALL impl_initPropertySetInfo(); //helping XPropertySet
+
+ void SAL_CALL
+ impl_EnsureNotDisposed()
+ throw( com::sun::star::lang::DisposedException,
+ com::sun::star::uno::RuntimeException );
+
+ void SAL_CALL
+ impl_notifyPropertyChangeListeners(
+ const com::sun::star::beans::PropertyChangeEvent& rEvt );
+
+ void SAL_CALL
+ impl_notifyVetoableChangeListeners(
+ const com::sun::star::beans::PropertyChangeEvent& rEvt )
+ throw( com::sun::star::beans::PropertyVetoException,
+ com::sun::star::uno::RuntimeException );
+
+ sal_Bool SAL_CALL impl_isForwardOnly();
+
+public:
+
+ //-----------------------------------------------------------------
+ // XInterface
+ //-----------------------------------------------------------------
+ virtual com::sun::star::uno::Any SAL_CALL
+ queryInterface( const com::sun::star::uno::Type & rType )
+ throw( com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XComponent
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ dispose() throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ addEventListener( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XEventListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ removeEventListener( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XEventListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ //XCloseable
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ close()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ //XResultSetMetaDataSupplier
+ //-----------------------------------------------------------------
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSetMetaData > SAL_CALL
+ getMetaData()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XPropertySet
+ //-----------------------------------------------------------------
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo()
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ setPropertyValue( const rtl::OUString& aPropertyName,
+ const com::sun::star::uno::Any& aValue )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::beans::PropertyVetoException,
+ com::sun::star::lang::IllegalArgumentException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Any SAL_CALL
+ getPropertyValue( const rtl::OUString& PropertyName )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ addPropertyChangeListener( const rtl::OUString& aPropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertyChangeListener >& xListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ removePropertyChangeListener( const rtl::OUString& aPropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertyChangeListener >& aListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ addVetoableChangeListener( const rtl::OUString& PropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ removeVetoableChangeListener( const rtl::OUString& PropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // own methods
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ impl_disposing( const com::sun::star::lang::EventObject& Source )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ impl_propertyChange( const com::sun::star::beans::PropertyChangeEvent& evt )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ impl_vetoableChange( const com::sun::star::beans::PropertyChangeEvent& aEvent )
+ throw( com::sun::star::beans::PropertyVetoException,
+ com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XContentAccess
+ //-----------------------------------------------------------------
+ virtual rtl::OUString SAL_CALL
+ queryContentIdentfierString()
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentIdentifier > SAL_CALL
+ queryContentIdentifier()
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContent > SAL_CALL
+ queryContent()
+ throw( com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XResultSet
+ //-----------------------------------------------------------------
+ virtual sal_Bool SAL_CALL
+ next()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ isBeforeFirst()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ isAfterLast()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ isFirst()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ isLast()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ beforeFirst()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ afterLast()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ first()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ last()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Int32 SAL_CALL
+ getRow()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ absolute( sal_Int32 row )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ relative( sal_Int32 rows )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ previous()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ refreshRow()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ rowUpdated()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ rowInserted()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ rowDeleted()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::uno::XInterface > SAL_CALL
+ getStatement()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XRow
+ //-----------------------------------------------------------------
+ virtual sal_Bool SAL_CALL
+ wasNull()
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual rtl::OUString SAL_CALL
+ getString( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ getBoolean( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int8 SAL_CALL
+ getByte( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int16 SAL_CALL
+ getShort( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int32 SAL_CALL
+ getInt( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int64 SAL_CALL
+ getLong( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual float SAL_CALL
+ getFloat( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual double SAL_CALL
+ getDouble( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
+ getBytes( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::util::Date SAL_CALL
+ getDate( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::util::Time SAL_CALL
+ getTime( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::util::DateTime SAL_CALL
+ getTimestamp( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::io::XInputStream > SAL_CALL
+ getBinaryStream( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::io::XInputStream > SAL_CALL
+ getCharacterStream( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Any SAL_CALL
+ getObject( sal_Int32 columnIndex,
+ const com::sun::star::uno::Reference<
+ com::sun::star::container::XNameAccess >& typeMap )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XRef > SAL_CALL
+ getRef( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XBlob > SAL_CALL
+ getBlob( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XClob > SAL_CALL
+ getClob( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XArray > SAL_CALL
+ getArray( sal_Int32 columnIndex )
+ throw( com::sun::star::sdbc::SQLException,
+ com::sun::star::uno::RuntimeException );
+};
+
+//=========================================================================
+
+class ContentResultSetWrapperListener
+ : public cppu::OWeakObject
+ , public com::sun::star::beans::XPropertyChangeListener
+ , public com::sun::star::beans::XVetoableChangeListener
+{
+protected:
+ ContentResultSetWrapper* m_pOwner;
+
+public:
+ ContentResultSetWrapperListener( ContentResultSetWrapper* pOwner );
+
+ virtual ~ContentResultSetWrapperListener();
+
+ //-----------------------------------------------------------------
+ // XInterface
+ //-----------------------------------------------------------------
+ XINTERFACE_DECL()
+
+ //-----------------------------------------------------------------
+ //XEventListener
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ disposing( const com::sun::star::lang::EventObject& Source )
+ throw( com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ //XPropertyChangeListener
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ propertyChange( const com::sun::star::beans::PropertyChangeEvent& evt )
+ throw( com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ //XVetoableChangeListener
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ vetoableChange( const com::sun::star::beans::PropertyChangeEvent& aEvent )
+ throw( com::sun::star::beans::PropertyVetoException,
+ com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // own methods:
+ void SAL_CALL impl_OwnerDies();
+};
+
+#endif
+
diff --git a/ucb/source/cacher/dynamicresultsetwrapper.cxx b/ucb/source/cacher/dynamicresultsetwrapper.cxx
new file mode 100644
index 000000000000..8ace53a28d7b
--- /dev/null
+++ b/ucb/source/cacher/dynamicresultsetwrapper.cxx
@@ -0,0 +1,566 @@
+/*************************************************************************
+ *
+ * $RCSfile: dynamicresultsetwrapper.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <dynamicresultsetwrapper.hxx>
+
+#ifndef _UCBHELPER_MACROS_HXX
+#include <ucbhelper/macros.hxx>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_LISTACTIONTYPE_HPP_
+#include <com/sun/star/ucb/ListActionType.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_WELCOMEDYNAMICRESULTSETSTRUCT_HPP_
+#include <com/sun/star/ucb/WelcomeDynamicResultSetStruct.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XCACHEDDYNAMICRESULTSETSTUBFACTORY_HPP_
+#include <com/sun/star/ucb/XCachedDynamicResultSetStubFactory.hpp>
+#endif
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace cppu;
+using namespace rtl;
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// class DynamicResultSetWrapper
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+DynamicResultSetWrapper::DynamicResultSetWrapper(
+ Reference< XDynamicResultSet > xOrigin
+ , const Reference< XMultiServiceFactory > & xSMgr )
+
+ : m_xSMgr( xSMgr )
+ , m_xSource( xOrigin )
+ , m_xSourceResultOne( NULL )
+ , m_xSourceResultTwo( NULL )
+ // , m_xSourceResultCurrent( NULL )
+ // , m_bUseOne( NULL )
+ , m_xMyResultOne( NULL )
+ , m_xMyResultTwo( NULL )
+ , m_xListener( NULL )
+ , m_pDisposeEventListeners( NULL )
+ , m_bDisposed( sal_False )
+ , m_bInDispose( sal_False )
+ , m_bStatic( sal_False )
+ , m_bGotWelcome( sal_False )
+{
+ m_pMyListenerImpl = new DynamicResultSetWrapperListener( this );
+ m_xMyListenerImpl = Reference< XDynamicResultSetListener >( m_pMyListenerImpl );
+ //call impl_init() at the end of constructor of derived class
+};
+
+void SAL_CALL DynamicResultSetWrapper::impl_init()
+{
+ //call this at the end of constructor of derived class
+ //
+
+ Reference< XDynamicResultSet > xSource = NULL;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ xSource = m_xSource;
+ m_xSource = NULL;
+ }
+ if( xSource.is() )
+ setSource( xSource );
+}
+
+DynamicResultSetWrapper::~DynamicResultSetWrapper()
+{
+ //call impl_deinit() at start of destructor of derived class
+
+ delete m_pDisposeEventListeners;
+};
+
+void SAL_CALL DynamicResultSetWrapper::impl_deinit()
+{
+ //call this at start of destructor of derived class
+ //
+ m_pMyListenerImpl->impl_OwnerDies();
+}
+
+void SAL_CALL DynamicResultSetWrapper
+::impl_EnsureNotDisposed()
+ throw( DisposedException, RuntimeException )
+{
+ vos::OGuard aGuard( m_aMutex );
+ if( m_bDisposed )
+ throw DisposedException();
+}
+
+//virtual
+void SAL_CALL DynamicResultSetWrapper
+::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
+{
+ vos::OGuard aGuard( m_aMutex );
+ DBG_ASSERT( !m_xSourceResultOne.is(), "Source ResultSet One is set already" );
+ m_xSourceResultOne = xResultSet;
+ m_xMyResultOne = xResultSet;
+}
+
+//virtual
+void SAL_CALL DynamicResultSetWrapper
+::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
+{
+ vos::OGuard aGuard( m_aMutex );
+ DBG_ASSERT( !m_xSourceResultTwo.is(), "Source ResultSet Two is set already" );
+ m_xSourceResultTwo = xResultSet;
+ m_xMyResultTwo = xResultSet;
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods.
+//--------------------------------------------------------------------------
+//list all interfaces inclusive baseclasses of interfaces
+QUERYINTERFACE_IMPL_START( DynamicResultSetWrapper )
+ SAL_STATIC_CAST( XComponent*, this ) //base of XDynamicResultSet
+ , SAL_STATIC_CAST( XDynamicResultSet*, this )
+ , SAL_STATIC_CAST( XSourceInitialization*, this )
+QUERYINTERFACE_IMPL_END
+
+//--------------------------------------------------------------------------
+// XComponent methods.
+//--------------------------------------------------------------------------
+// virtual
+void SAL_CALL DynamicResultSetWrapper
+ ::dispose() throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ Reference< XComponent > xSourceComponent;
+ {
+ vos::OClearableGuard aGuard( m_aMutex );
+ if( m_bInDispose || m_bDisposed )
+ return;
+ m_bInDispose = sal_True;
+
+ xSourceComponent = Reference< XComponent >(m_xSource, UNO_QUERY);
+
+ if( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
+ {
+ EventObject aEvt;
+ aEvt.Source = static_cast< XComponent * >( this );
+
+ aGuard.clear();
+ m_pDisposeEventListeners->disposeAndClear( aEvt );
+ }
+ }
+
+ /* //@todo ?? ( only if java collection needs to long )
+ if( xSourceComponent.is() )
+ xSourceComponent->dispose();
+ */
+
+ vos::OGuard aGuard( m_aMutex );
+ m_bDisposed = sal_True;
+ m_bInDispose = sal_False;
+}
+
+//--------------------------------------------------------------------------
+// virtual
+void SAL_CALL DynamicResultSetWrapper
+ ::addEventListener( const Reference< XEventListener >& Listener )
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ vos::OGuard aGuard( m_aMutex );
+
+ if ( !m_pDisposeEventListeners )
+ m_pDisposeEventListeners =
+ new OInterfaceContainerHelper( m_aContainerMutex );
+
+ m_pDisposeEventListeners->addInterface( Listener );
+}
+
+//--------------------------------------------------------------------------
+// virtual
+void SAL_CALL DynamicResultSetWrapper
+ ::removeEventListener( const Reference< XEventListener >& Listener )
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ vos::OGuard aGuard( m_aMutex );
+
+ if ( m_pDisposeEventListeners )
+ m_pDisposeEventListeners->removeInterface( Listener );
+}
+
+//--------------------------------------------------------------------------
+// own methods
+//--------------------------------------------------------------------------
+
+//virtual
+void SAL_CALL DynamicResultSetWrapper
+ ::impl_disposing( const EventObject& rEventObject )
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ vos::OGuard aGuard( m_aMutex );
+
+ if( !m_xSource.is() )
+ return;
+
+ //release all references to the broadcaster:
+ m_xSource.clear();
+ m_xSourceResultOne.clear();//?? or only when not static??
+ m_xSourceResultTwo.clear();//??
+ //@todo m_xMyResultOne.clear(); ???
+ //@todo m_xMyResultTwo.clear(); ???
+}
+
+//virtual
+void SAL_CALL DynamicResultSetWrapper
+ ::impl_notify( const ListEvent& Changes )
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ //@todo
+ /*
+ <p>The Listener is allowed to blockade this call, until he really want to go
+ to the new version. The only situation, where the listener has to return the
+ update call at once is, while he disposes his broadcaster or while he is
+ removing himsef as listener (otherwise you deadlock)!!!
+ */
+ // handle the actions in the list
+
+ ListEvent aNewEvent;
+ aNewEvent.Source = static_cast< XDynamicResultSet * >( this );
+ aNewEvent.Changes = Changes.Changes;
+
+ {
+ vos::OGuard aGuard( m_aMutex );
+ for( long i=0; !m_bGotWelcome && i<Changes.Changes.getLength(); i++ )
+ {
+ ListAction& rAction = aNewEvent.Changes[i];
+ switch( rAction.ListActionType )
+ {
+ case ListActionType::WELCOME:
+ {
+ WelcomeDynamicResultSetStruct aWelcome;
+ if( rAction.ActionInfo >>= aWelcome )
+ {
+ impl_InitResultSetOne( aWelcome.Old );
+ impl_InitResultSetTwo( aWelcome.New );
+ m_bGotWelcome = TRUE;
+
+ aWelcome.Old = m_xMyResultOne;
+ aWelcome.New = m_xMyResultTwo;
+
+ rAction.ActionInfo <<= aWelcome;
+ }
+ else
+ {
+ DBG_ERROR( "ListActionType was WELCOME but ActionInfo didn't contain a WelcomeDynamicResultSetStruct" );
+ //throw RuntimeException();
+ }
+ break;
+ }
+ }
+ }
+ DBG_ASSERT( m_bGotWelcome, "first notification was without WELCOME" );
+ }
+
+ if( !m_xListener.is() )
+ m_aListenerSet.wait();
+ m_xListener->notify( aNewEvent );
+
+ /*
+ m_bUseOne = !m_bUseOne;
+ if( m_bUseOne )
+ m_xSourceResultCurrent = m_xSourceResultOne;
+ else
+ m_xSourceResultCurrent = m_xSourceResultTwo;
+ */
+}
+
+//--------------------------------------------------------------------------
+// XSourceInitialization
+//--------------------------------------------------------------------------
+//virtual
+void SAL_CALL DynamicResultSetWrapper
+ ::setSource( const Reference< XInterface > & Source )
+ throw( AlreadyInitializedException, RuntimeException )
+{
+ impl_EnsureNotDisposed();
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( m_xSource.is() )
+ {
+ throw AlreadyInitializedException();
+ }
+ }
+
+ Reference< XDynamicResultSet > xSourceDynamic( Source, UNO_QUERY );
+ DBG_ASSERT( xSourceDynamic.is(),
+ "the given source is not of required type XDynamicResultSet" );
+
+ Reference< XDynamicResultSetListener > xListener = NULL;
+ Reference< XDynamicResultSetListener > xMyListenerImpl = NULL;
+
+ BOOL bStatic = FALSE;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ m_xSource = xSourceDynamic;
+ xListener = m_xListener;
+ bStatic = m_bStatic;
+ xMyListenerImpl = m_xMyListenerImpl;
+ }
+ if( xListener.is() )
+ xSourceDynamic->setListener( m_xMyListenerImpl );
+ else if( bStatic )
+ {
+ Reference< XComponent > xSourceComponent( Source, UNO_QUERY );
+ xSourceComponent->addEventListener( Reference< XEventListener > ::query( xMyListenerImpl ) );
+ }
+ m_aSourceSet.set();
+}
+
+//--------------------------------------------------------------------------
+// XDynamicResultSet
+//--------------------------------------------------------------------------
+//virtual
+Reference< XResultSet > SAL_CALL DynamicResultSetWrapper
+ ::getStaticResultSet()
+ throw( ListenerAlreadySetException, RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ Reference< XDynamicResultSet > xSource = NULL;
+ Reference< XEventListener > xMyListenerImpl = NULL;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( m_xListener.is() )
+ throw ListenerAlreadySetException();
+
+ xSource = m_xSource;
+ m_bStatic = sal_True;
+ xMyListenerImpl = Reference< XEventListener > ::query( m_xMyListenerImpl );
+ }
+
+ if( xSource.is() )
+ {
+ Reference< XComponent > xSourceComponent( xSource, UNO_QUERY );
+ xSourceComponent->addEventListener( xMyListenerImpl );
+ }
+ if( !xSource.is() )
+ m_aSourceSet.wait();
+
+
+ Reference< XResultSet > xResultSet = xSource->getStaticResultSet();
+ impl_InitResultSetOne( xResultSet );
+ return m_xMyResultOne;
+}
+
+//virtual
+void SAL_CALL DynamicResultSetWrapper
+ ::setListener( const Reference<
+ XDynamicResultSetListener > & Listener )
+ throw( ListenerAlreadySetException, RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ Reference< XDynamicResultSet > xSource = NULL;
+ Reference< XDynamicResultSetListener > xMyListenerImpl = NULL;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ if( m_xListener.is() )
+ throw ListenerAlreadySetException();
+ if( m_bStatic )
+ throw ListenerAlreadySetException();
+
+ m_xListener = Listener;
+ addEventListener( Reference< XEventListener >::query( Listener ) );
+
+ xSource = m_xSource;
+ xMyListenerImpl = m_xMyListenerImpl;
+ }
+ if ( xSource.is() )
+ xSource->setListener( xMyListenerImpl );
+
+ m_aListenerSet.set();
+}
+
+//virtual
+void SAL_CALL DynamicResultSetWrapper
+ ::connectToCache( const Reference< XDynamicResultSet > & xCache )
+ throw( ListenerAlreadySetException, AlreadyInitializedException, ServiceNotFoundException, RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ if( m_xListener.is() )
+ throw ListenerAlreadySetException();
+ if( m_bStatic )
+ throw ListenerAlreadySetException();
+
+ Reference< XSourceInitialization > xTarget( xCache, UNO_QUERY );
+ DBG_ASSERT( xTarget.is(), "The given Target dosn't have the required interface 'XSourceInitialization'" );
+ if( xTarget.is() && m_xSMgr.is() )
+ {
+ //@todo m_aSourceSet.wait();?
+ Reference< XCachedDynamicResultSetStubFactory > xStubFactory(
+ m_xSMgr->createInstance( OUString::createFromAscii(
+ "com.sun.star.ucb.CachedDynamicResultSetStubFactory" ) ), UNO_QUERY );
+ if( xStubFactory.is() )
+ {
+ xStubFactory->connectToCache(
+ this, xCache, Sequence< NumberedSortingInfo > (), NULL );
+ return;
+ }
+ }
+ DBG_ERROR( "could not connect to cache" );
+ throw ServiceNotFoundException();
+}
+
+//virtual
+sal_Int16 SAL_CALL DynamicResultSetWrapper
+ ::getCapabilities()
+ throw( RuntimeException )
+{
+ impl_EnsureNotDisposed();
+
+ m_aSourceSet.wait();
+ Reference< XDynamicResultSet > xSource = NULL;
+ {
+ vos::OGuard aGuard( m_aMutex );
+ xSource = m_xSource;
+ }
+ return xSource->getCapabilities();
+}
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// class DynamicResultSetWrapperListener
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+DynamicResultSetWrapperListener::DynamicResultSetWrapperListener(
+ DynamicResultSetWrapper* pOwner )
+ : m_pOwner( pOwner )
+{
+
+}
+
+DynamicResultSetWrapperListener::~DynamicResultSetWrapperListener()
+{
+
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods.
+//--------------------------------------------------------------------------
+//list all interfaces inclusive baseclasses of interfaces
+XINTERFACE_IMPL_2( DynamicResultSetWrapperListener
+ , XDynamicResultSetListener
+ , XEventListener //base of XDynamicResultSetListener
+ );
+
+//--------------------------------------------------------------------------
+// XDynamicResultSetListener methods:
+//--------------------------------------------------------------------------
+//virtual
+void SAL_CALL DynamicResultSetWrapperListener
+ ::disposing( const EventObject& rEventObject )
+ throw( RuntimeException )
+{
+ vos::OGuard aGuard( m_aMutex );
+
+ if( m_pOwner )
+ m_pOwner->impl_disposing( rEventObject );
+}
+
+//virtual
+void SAL_CALL DynamicResultSetWrapperListener
+ ::notify( const ListEvent& Changes )
+ throw( RuntimeException )
+{
+ vos::OGuard aGuard( m_aMutex );
+
+ if( m_pOwner )
+ m_pOwner->impl_notify( Changes );
+}
+
+//--------------------------------------------------------------------------
+// own methods:
+//--------------------------------------------------------------------------
+
+void SAL_CALL DynamicResultSetWrapperListener
+ ::impl_OwnerDies()
+{
+ vos::OGuard aGuard( m_aMutex );
+
+ m_pOwner = NULL;
+}
+
diff --git a/ucb/source/cacher/dynamicresultsetwrapper.hxx b/ucb/source/cacher/dynamicresultsetwrapper.hxx
new file mode 100644
index 000000000000..58c9b4d09c96
--- /dev/null
+++ b/ucb/source/cacher/dynamicresultsetwrapper.hxx
@@ -0,0 +1,295 @@
+/*************************************************************************
+ *
+ * $RCSfile: dynamicresultsetwrapper.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DYNAMIC_RESULTSET_WRAPPER_HXX
+#define _DYNAMIC_RESULTSET_WRAPPER_HXX
+
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+
+#ifndef _VOS_CONDITN_HXX_
+#include <vos/conditn.hxx>
+#endif
+
+#ifndef _UCBHELPER_MACROS_HXX
+#include <ucbhelper/macros.hxx>
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XDYNAMICRESULTSET_HPP_
+#include <com/sun/star/ucb/XDynamicResultSet.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XSOURCEINITIALIZATION_HPP_
+#include <com/sun/star/ucb/XSourceInitialization.hpp>
+#endif
+
+#ifndef __com_sun_star_lang_DisposedException_idl__
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_XDYNAMICRESULTSETLISTENER_HPP_
+#include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
+//#define CACHED_CRS_STUB_SERVICE_NAME "com.sun.star.ucb.CachedContentResultSetStub"
+//#define CACHED_CRS_STUB_FACTORY_NAME "com.sun.star.ucb.CachedContentResultSetStubFactory"
+
+//=========================================================================
+
+class DynamicResultSetWrapperListener;
+class DynamicResultSetWrapper
+ : public cppu::OWeakObject
+ , public com::sun::star::ucb::XDynamicResultSet
+ , public com::sun::star::ucb::XSourceInitialization
+{
+private:
+ //management of listeners
+ sal_Bool m_bDisposed; ///Dispose call ready.
+ sal_Bool m_bInDispose;///In dispose call
+ osl::Mutex m_aContainerMutex;
+ cppu::OInterfaceContainerHelper*
+ m_pDisposeEventListeners;
+protected:
+ com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSetListener >
+ m_xMyListenerImpl;
+ DynamicResultSetWrapperListener*
+ m_pMyListenerImpl;
+
+ com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
+ m_xSMgr;
+
+ vos::OMutex m_aMutex;
+ sal_Bool m_bStatic;
+ sal_Bool m_bGotWelcome;
+
+ //different Interfaces from Origin:
+ com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSet >
+ m_xSource;
+ com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
+ m_xSourceResultOne;
+ com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
+ m_xSourceResultTwo;
+ //com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
+ // m_xSourceResultCurrent;
+ //sal_Bool m_bUseOne;
+ //
+ com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
+ m_xMyResultOne;
+ com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet >
+ m_xMyResultTwo;
+ //
+ com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSetListener >
+ m_xListener;
+
+ vos::OCondition m_aSourceSet;
+ vos::OCondition m_aListenerSet;
+
+protected:
+ void SAL_CALL impl_init();
+ void SAL_CALL impl_deinit();
+ void SAL_CALL
+ impl_EnsureNotDisposed()
+ throw( com::sun::star::lang::DisposedException,
+ com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ impl_InitResultSetOne( const com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet >& xResultSet );
+ virtual void SAL_CALL
+ impl_InitResultSetTwo( const com::sun::star::uno::Reference<
+ com::sun::star::sdbc::XResultSet >& xResultSet );
+
+public:
+
+ DynamicResultSetWrapper(
+ com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDynamicResultSet > xOrigin
+ , const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > & xSMgr );
+
+ virtual ~DynamicResultSetWrapper();
+
+ //-----------------------------------------------------------------
+ // XInterface
+ virtual com::sun::star::uno::Any SAL_CALL
+ queryInterface( const com::sun::star::uno::Type & rType )
+ throw( com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XDynamicResultSet
+ virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > SAL_CALL
+ getStaticResultSet()
+ throw( com::sun::star::ucb::ListenerAlreadySetException
+ , com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ setListener( const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDynamicResultSetListener > & Listener )
+ throw( com::sun::star::ucb::ListenerAlreadySetException
+ , com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ connectToCache( const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDynamicResultSet > & xCache )
+ throw( com::sun::star::ucb::ListenerAlreadySetException
+ , com::sun::star::ucb::AlreadyInitializedException
+ , com::sun::star::ucb::ServiceNotFoundException
+ , com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int16 SAL_CALL
+ getCapabilities() throw( com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XComponent ( base of XDynamicResultSet )
+ virtual void SAL_CALL
+ dispose() throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ addEventListener( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XEventListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ removeEventListener( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XEventListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // XSourceInitialization
+
+ virtual void SAL_CALL
+ setSource( const com::sun::star::uno::Reference<
+ com::sun::star::uno::XInterface > & Source )
+ throw( com::sun::star::ucb::AlreadyInitializedException
+ , com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // own methods:
+ virtual void SAL_CALL
+ impl_disposing( const com::sun::star::lang::EventObject& Source )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ impl_notify( const ::com::sun::star::ucb::ListEvent& Changes )
+ throw( com::sun::star::uno::RuntimeException );
+};
+
+//=========================================================================
+
+class DynamicResultSetWrapperListener
+ : public cppu::OWeakObject
+ , public com::sun::star::ucb::XDynamicResultSetListener
+{
+protected:
+ DynamicResultSetWrapper* m_pOwner;
+ ::vos::OMutex m_aMutex;
+
+public:
+ DynamicResultSetWrapperListener( DynamicResultSetWrapper* pOwner );
+
+ virtual ~DynamicResultSetWrapperListener();
+
+ //-----------------------------------------------------------------
+ // XInterface
+ //-----------------------------------------------------------------
+ XINTERFACE_DECL()
+
+ //-----------------------------------------------------------------
+ // XEventListener ( base of XDynamicResultSetListener )
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ disposing( const com::sun::star::lang::EventObject& Source )
+ throw( com::sun::star::uno::RuntimeException );
+ //-----------------------------------------------------------------
+ // XDynamicResultSetListener
+ virtual void SAL_CALL
+ notify( const ::com::sun::star::ucb::ListEvent& Changes )
+ throw( com::sun::star::uno::RuntimeException );
+
+ //-----------------------------------------------------------------
+ // own methods:
+ void SAL_CALL impl_OwnerDies();
+};
+
+
+#endif
+
diff --git a/ucb/source/cacher/makefile.mk b/ucb/source/cacher/makefile.mk
new file mode 100644
index 000000000000..c031d2195d35
--- /dev/null
+++ b/ucb/source/cacher/makefile.mk
@@ -0,0 +1,131 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: kso $ $Date: 2000-10-16 14:52:35 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=ucb
+TARGET=cached
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+
+# Version
+UCB_MAJOR=1
+
+.INCLUDE: svpre.mk
+.INCLUDE: settings.mk
+.INCLUDE: sv.mk
+
+#INCPRE+=$(PRJ)$/source$/inc
+
+SLOFILES=\
+ $(SLO)$/contentresultsetwrapper.obj \
+ $(SLO)$/cachedcontentresultsetstub.obj \
+ $(SLO)$/cachedcontentresultset.obj \
+ $(SLO)$/dynamicresultsetwrapper.obj \
+ $(SLO)$/cacheddynamicresultsetstub.obj \
+ $(SLO)$/cacheddynamicresultset.obj \
+ $(SLO)$/cacheserv.obj
+
+# NETBSD: somewhere we have to instantiate the static data members.
+# NETBSD-1.2.1 doesn't know about weak symbols so the default mechanism for GCC won't work.
+# SCO and MACOSX: the linker does know about weak symbols, but we can't ignore multiple defined symbols
+.IF "$(OS)"=="NETBSD" || "$(OS)"=="SCO" || "$(OS)$(COM)"=="OS2GCC" || "$(OS)"=="MACOSX"
+SLOFILES+=$(SLO)$/staticmbcacher.obj
+.ENDIF
+
+LIB1TARGET=$(SLB)$/_$(TARGET).lib
+LIB1OBJFILES=$(SLOFILES)
+
+SHL1TARGET=$(TARGET)$(UCB_MAJOR)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+SHL1STDLIBS=\
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(TOOLSLIB) \
+ $(VOSLIB)
+
+SHL1LIBS=$(LIB1TARGET)
+SHL1IMPLIB=i$(TARGET)
+
+DEF1DEPN=$(MISC)$/$(SHL1TARGET).flt
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORT1 =component_getImplementationEnvironment
+DEF1EXPORT2 =component_writeInfo
+DEF1EXPORT3 =component_getFactory
+DEF1DES=Cached Dynamic Resultset
+
+.INCLUDE: target.mk
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+# @echo Type >> $@
+ @echo cpp >> $@
+ @echo m_ >> $@
+ @echo rtl >> $@
+ @echo vos >> $@
+ @echo component_getImplementationEnvironment >> $@
+ @echo component_writeInfo >> $@
+ @echo component_getFactory >> $@
+.IF "$(COM)"=="MSC"
+ @echo ??_ >> $@
+.ENDIF # COM MSC
diff --git a/ucb/source/core/identify.cxx b/ucb/source/core/identify.cxx
new file mode 100644
index 000000000000..a93bb478df7e
--- /dev/null
+++ b/ucb/source/core/identify.cxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * $RCSfile: identify.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+
+#pragma hdrstop
+
+#include "identify.hxx"
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::ucb;
+
+//=========================================================================
+//
+// ContentIdentifier Implementation.
+//
+//=========================================================================
+
+ContentIdentifier::ContentIdentifier(
+ const Reference< XMultiServiceFactory >& rxSMgr,
+ const OUString& ContentId )
+: m_xSMgr( rxSMgr ),
+ m_aContentId( ContentId )
+{
+}
+
+//=========================================================================
+// virtual
+ContentIdentifier::~ContentIdentifier()
+{
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_2( ContentIdentifier,
+ XTypeProvider,
+ XContentIdentifier );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_2( ContentIdentifier,
+ XTypeProvider,
+ XContentIdentifier );
+
+//=========================================================================
+//
+// XContentIdentifier methods.
+//
+//=========================================================================
+
+// virtual
+OUString SAL_CALL ContentIdentifier::getContentIdentifier()
+ throw( RuntimeException )
+{
+ return m_aContentId;
+}
+
+//=========================================================================
+// virtual
+OUString SAL_CALL ContentIdentifier::getContentProviderScheme()
+ throw( RuntimeException )
+{
+ if ( !m_aProviderScheme.getLength() && m_aContentId.getLength() )
+ {
+ // The content provider scheme is the part before the first ':'
+ // within the content id.
+ sal_Int32 nPos = m_aContentId.indexOf( ':', 0 );
+ if ( nPos != -1 )
+ {
+ OUString aScheme( m_aContentId.copy( 0, nPos ) );
+ m_aProviderScheme = aScheme.toLowerCase();
+ }
+ }
+
+ return m_aProviderScheme;
+}
+
diff --git a/ucb/source/core/identify.hxx b/ucb/source/core/identify.hxx
new file mode 100644
index 000000000000..bf8f5530a817
--- /dev/null
+++ b/ucb/source/core/identify.hxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * $RCSfile: identify.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _IDENTIFY_HXX
+#define _IDENTIFY_HXX
+
+#ifndef _COM_SUN_STAR_UCB_XCONTENTIDENTIFIER_HPP_
+#include <com/sun/star/ucb/XContentIdentifier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+#ifndef _UCBHELPER_MACROS_HXX
+#include <ucbhelper/macros.hxx>
+#endif
+
+//=========================================================================
+
+class ContentIdentifier :
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XTypeProvider,
+ public com::sun::star::ucb::XContentIdentifier
+{
+public:
+ ContentIdentifier( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
+ const rtl::OUString& ContentId );
+ virtual ~ContentIdentifier();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XContentIdentifier
+ virtual rtl::OUString SAL_CALL getContentIdentifier()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual rtl::OUString SAL_CALL getContentProviderScheme()
+ throw( com::sun::star::uno::RuntimeException );
+
+private:
+ com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+ rtl::OUString m_aContentId;
+ rtl::OUString m_aProviderScheme;
+};
+
+#endif /* !_IDENTIFY_HXX */
diff --git a/ucb/source/core/makefile.mk b/ucb/source/core/makefile.mk
new file mode 100644
index 000000000000..9d58bb35ae51
--- /dev/null
+++ b/ucb/source/core/makefile.mk
@@ -0,0 +1,132 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=ucb
+TARGET=ucb
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+
+# Version
+UCB_MAJOR=1
+
+.INCLUDE: svpre.mk
+.INCLUDE: settings.mk
+.INCLUDE: sv.mk
+
+SLOFILES=\
+ $(SLO)$/flatany.obj \
+ $(SLO)$/identify.obj \
+ $(SLO)$/ucb.obj \
+ $(SLO)$/ucbcfg.obj \
+ $(SLO)$/ucbdistributor.obj \
+ $(SLO)$/ucbserv.obj \
+ $(SLO)$/ucbstore.obj \
+ $(SLO)$/ucbprops.obj \
+ $(SLO)$/provprox.obj
+
+# NETBSD: somewhere we have to instantiate the static data members.
+# NETBSD-1.2.1 doesn't know about weak symbols so the default mechanism for GCC won't work.
+# SCO and MACOSX: the linker does know about weak symbols, but we can't ignore multiple defined symbols
+.IF "$(OS)"=="NETBSD" || "$(OS)"=="SCO" || "$(OS)$(COM)"=="OS2GCC" || "$(OS)"=="MACOSX"
+SLOFILES+=$(SLO)$/staticmbucbcore.obj
+.ENDIF
+
+LIB1TARGET=$(SLB)$/_$(TARGET).lib
+LIB1OBJFILES=$(SLOFILES)
+
+SHL1TARGET=$(TARGET)$(UCB_MAJOR)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+SHL1STDLIBS=\
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(STORELIB) \
+ $(UCBHELPERLIB)
+SHL1LIBS=\
+ $(LIB1TARGET) \
+ $(SLB)$/regexp.lib
+SHL1IMPLIB=i$(TARGET)
+
+DEF1DEPN=$(MISC)$/$(SHL1TARGET).flt
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORT1 =component_getImplementationEnvironment
+DEF1EXPORT2 =component_writeInfo
+DEF1EXPORT3 =component_getFactory
+DEF1DES=Universal Content Broker
+
+.INCLUDE: target.mk
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+# @echo Type >> $@
+ @echo cpp >> $@
+ @echo m_ >> $@
+ @echo rtl >> $@
+ @echo vos >> $@
+ @echo component_getImplementationEnvironment >> $@
+ @echo component_writeInfo >> $@
+ @echo component_getFactory >> $@
+.IF "$(COM)"=="MSC"
+ @echo ??_ >> $@
+.ENDIF # COM MSC
diff --git a/ucb/source/core/providermap.hxx b/ucb/source/core/providermap.hxx
new file mode 100644
index 000000000000..160e22c6a01e
--- /dev/null
+++ b/ucb/source/core/providermap.hxx
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * $RCSfile: providermap.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _UCB_PROVIDERMAP_HXX_
+#define _UCB_PROVIDERMAP_HXX_
+
+#include <list>
+
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
+#include <com/sun/star/uno/Reference.h>
+#endif
+
+#ifndef _UCB_REGEXPMAP_HXX_
+#include <regexpmap.hxx>
+#endif
+
+namespace com { namespace sun { namespace star { namespace ucb {
+ class XContentProvider;
+} } } }
+
+//============================================================================
+class ProviderListEntry_Impl
+{
+ com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentProvider > m_xProvider;
+ mutable com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentProvider > m_xResolvedProvider;
+
+private:
+ com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentProvider > resolveProvider() const;
+
+public:
+ ProviderListEntry_Impl(
+ const com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentProvider >& xProvider )
+ : m_xProvider( xProvider ) {}
+
+ com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentProvider > getProvider() const
+ { return m_xProvider; }
+ inline com::sun::star::uno::Reference<
+ com::sun::star::ucb::XContentProvider > getResolvedProvider() const;
+};
+
+inline com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >
+ProviderListEntry_Impl::getResolvedProvider() const
+{
+ return m_xResolvedProvider.is() ? m_xResolvedProvider : resolveProvider();
+}
+
+//============================================================================
+typedef std::list< ProviderListEntry_Impl > ProviderList_Impl;
+
+//============================================================================
+typedef ucb::RegexpMap< ProviderList_Impl > ProviderMap_Impl;
+
+#endif // _UCB_PROVIDERMAP_HXX_
+
diff --git a/ucb/source/core/provprox.cxx b/ucb/source/core/provprox.cxx
new file mode 100644
index 000000000000..c5cc3c0612d7
--- /dev/null
+++ b/ucb/source/core/provprox.cxx
@@ -0,0 +1,409 @@
+/*************************************************************************
+ *
+ * $RCSfile: provprox.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _PROVPROX_HXX
+#include "provprox.hxx"
+#endif
+
+using namespace rtl;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+
+//=========================================================================
+//=========================================================================
+//
+// UcbContentProviderProxyFactory Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+UcbContentProviderProxyFactory::UcbContentProviderProxyFactory(
+ const Reference< XMultiServiceFactory >& rxSMgr )
+: m_xSMgr( rxSMgr )
+{
+}
+
+//=========================================================================
+// virtual
+UcbContentProviderProxyFactory::~UcbContentProviderProxyFactory()
+{
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_3( UcbContentProviderProxyFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XContentProviderFactory );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_3( UcbContentProviderProxyFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XContentProviderFactory );
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+XSERVICEINFO_IMPL_1( UcbContentProviderProxyFactory,
+ OUString::createFromAscii(
+ "UcbContentProviderProxyFactory" ),
+ OUString::createFromAscii(
+ PROVIDER_FACTORY_SERVICE_NAME ) );
+
+//=========================================================================
+//
+// Service factory implementation.
+//
+//=========================================================================
+
+ONE_INSTANCE_SERVICE_FACTORY_IMPL( UcbContentProviderProxyFactory );
+
+//=========================================================================
+//
+// XContentProviderFactory methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XContentProvider > SAL_CALL
+UcbContentProviderProxyFactory::createContentProvider(
+ const OUString& Service )
+ throw( RuntimeException )
+{
+ return Reference< XContentProvider >(
+ new UcbContentProviderProxy( m_xSMgr, Service ) );
+}
+
+//=========================================================================
+//=========================================================================
+//
+// UcbContentProviderProxy Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+UcbContentProviderProxy::UcbContentProviderProxy(
+ const Reference< XMultiServiceFactory >& rxSMgr,
+ const OUString& Service )
+: m_aService( Service ),
+ m_bReplace( sal_False ),
+ m_bRegister( sal_False ),
+ m_xSMgr( rxSMgr )
+{
+}
+
+//=========================================================================
+// virtual
+UcbContentProviderProxy::~UcbContentProviderProxy()
+{
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_COMMON_IMPL( UcbContentProviderProxy );
+
+//============================================================================
+// virtual
+Any SAL_CALL
+UcbContentProviderProxy::queryInterface( const Type & rType )
+ throw ( RuntimeException )
+{
+ Any aRet = cppu::queryInterface( rType,
+ static_cast< XTypeProvider * >( this ),
+ static_cast< XServiceInfo * >( this ),
+ static_cast< XContentProvider * >( this ),
+ static_cast< XParameterizedContentProvider * >( this ),
+ static_cast< XContentProviderSupplier * >( this ) );
+
+ if ( !aRet.hasValue() )
+ aRet = OWeakObject::queryInterface( rType );
+
+ if ( !aRet.hasValue() )
+ {
+ // Get original provider an forward the call...
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+ Reference< XContentProvider > xProvider = getContentProvider();
+ if ( xProvider.is() )
+ aRet = xProvider->queryInterface( rType );
+ }
+
+ return aRet;
+}
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_5( UcbContentProviderProxy,
+ XTypeProvider,
+ XServiceInfo,
+ XContentProvider,
+ XParameterizedContentProvider,
+ XContentProviderSupplier );
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+XSERVICEINFO_NOFACTORY_IMPL_1( UcbContentProviderProxy,
+ OUString::createFromAscii(
+ "UcbContentProviderProxy" ),
+ OUString::createFromAscii(
+ PROVIDER_PROXY_SERVICE_NAME ) );
+
+//=========================================================================
+//
+// XContentProvider methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XContent > SAL_CALL UcbContentProviderProxy::queryContent(
+ const Reference< XContentIdentifier >& Identifier )
+ throw( IllegalIdentifierException,
+ RuntimeException )
+{
+ // Get original provider an forward the call...
+
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+
+ Reference< XContentProvider > xProvider = getContentProvider();
+ if ( xProvider.is() )
+ return xProvider->queryContent( Identifier );
+
+ return Reference< XContent >();
+}
+
+//=========================================================================
+// virtual
+sal_Int32 SAL_CALL UcbContentProviderProxy::compareContentIds(
+ const Reference< XContentIdentifier >& Id1,
+ const Reference< XContentIdentifier >& Id2 )
+ throw( RuntimeException )
+{
+ // Get original provider an forward the call...
+
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+ Reference< XContentProvider > xProvider = getContentProvider();
+ if ( xProvider.is() )
+ return xProvider->compareContentIds( Id1, Id2 );
+
+ OSL_ENSURE( sal_False,
+ "UcbContentProviderProxy::compareContentIds - No provider!" );
+
+ // @@@ What else?
+ return 0;
+}
+
+//=========================================================================
+//
+// XParameterizedContentProvider methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XContentProvider > SAL_CALL
+UcbContentProviderProxy::registerInstance( const OUString& Template,
+ const OUString& Arguments,
+ sal_Bool ReplaceExisting )
+ throw( IllegalArgumentException,
+ RuntimeException )
+{
+ // Just remember that this method was called ( and the params ).
+
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+
+ if ( !m_bRegister )
+ {
+// m_xTargetProvider = 0;
+ m_aTemplate = Template;
+ m_aArguments = Arguments;
+ m_bReplace = ReplaceExisting;
+
+ m_bRegister = sal_True;
+ }
+ return this;
+}
+
+//=========================================================================
+// virtual
+Reference< XContentProvider > SAL_CALL
+UcbContentProviderProxy::deregisterInstance( const OUString& Template,
+ const OUString& Arguments )
+ throw( IllegalArgumentException,
+ RuntimeException )
+{
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+
+ // registerInstance called at proxy and at original?
+ if ( m_bRegister && m_xTargetProvider.is() )
+ {
+ m_bRegister = sal_False;
+ m_xTargetProvider = 0;
+
+ Reference< XParameterizedContentProvider >
+ xParamProvider( m_xProvider, UNO_QUERY );
+ if ( xParamProvider.is() )
+ {
+ try
+ {
+ return xParamProvider->deregisterInstance( Template,
+ Arguments );
+ }
+ catch ( IllegalIdentifierException const & )
+ {
+ OSL_ENSURE( sal_False,
+ "UcbContentProviderProxy::deregisterInstance - "
+ "Caught IllegalIdentifierException!" );
+ }
+ }
+ }
+
+ return this;
+}
+
+//=========================================================================
+//
+// XContentProviderSupplier methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XContentProvider > SAL_CALL
+UcbContentProviderProxy::getContentProvider()
+ throw( RuntimeException )
+{
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+ if ( !m_xProvider.is() )
+ {
+ try
+ {
+ m_xProvider
+ = Reference< XContentProvider >(
+ m_xSMgr->createInstance( m_aService ), UNO_QUERY );
+ }
+ catch ( RuntimeException const & )
+ {
+ throw;
+ }
+ catch ( Exception const & )
+ {
+ }
+
+ // registerInstance called at proxy, but not yet at original?
+ if ( m_xProvider.is() && m_bRegister )
+ {
+ Reference< XParameterizedContentProvider >
+ xParamProvider( m_xProvider, UNO_QUERY );
+ if ( xParamProvider.is() )
+ {
+ try
+ {
+ m_xTargetProvider
+ = xParamProvider->registerInstance( m_aTemplate,
+ m_aArguments,
+ m_bReplace );
+ }
+ catch ( IllegalIdentifierException const & )
+ {
+ OSL_ENSURE( sal_False,
+ "UcbContentProviderProxy::getContentProvider - "
+ "Caught IllegalIdentifierException!" );
+ }
+
+ OSL_ENSURE( m_xTargetProvider.is(),
+ "UcbContentProviderProxy::getContentProvider - "
+ "No provider!" );
+ }
+ }
+ if ( !m_xTargetProvider.is() )
+ m_xTargetProvider = m_xProvider;
+ }
+
+ OSL_ENSURE( m_xProvider.is(),
+ "UcbContentProviderProxy::getContentProvider - No provider!" );
+ return m_xTargetProvider;
+}
diff --git a/ucb/source/core/provprox.hxx b/ucb/source/core/provprox.hxx
new file mode 100644
index 000000000000..34a42a25650a
--- /dev/null
+++ b/ucb/source/core/provprox.hxx
@@ -0,0 +1,221 @@
+/*************************************************************************
+ *
+ * $RCSfile: provprox.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _PROVPROX_HXX
+#define _PROVPROX_HXX
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDERFACTORY_HPP_
+#include <com/sun/star/ucb/XContentProviderFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDER_HPP_
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XPARAMETERIZEDCONTENTPROVIDER_HPP_
+#include <com/sun/star/ucb/XParameterizedContentProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDERSUPPLIER_HPP_
+#include <com/sun/star/ucb/XContentProviderSupplier.hpp>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _UCBHELPER_MACROS_HXX
+#include <ucbhelper/macros.hxx>
+#endif
+
+//=========================================================================
+
+#define PROVIDER_FACTORY_SERVICE_NAME \
+ "com.sun.star.ucb.ContentProviderProxyFactory"
+#define PROVIDER_PROXY_SERVICE_NAME \
+ "com.sun.star.ucb.ContentProviderProxy"
+
+//============================================================================
+//
+// class UcbContentProviderProxyFactory.
+//
+//============================================================================
+
+class UcbContentProviderProxyFactory :
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XTypeProvider,
+ public com::sun::star::lang::XServiceInfo,
+ public com::sun::star::ucb::XContentProviderFactory
+{
+ com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
+ m_xSMgr;
+
+public:
+ UcbContentProviderProxyFactory(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rxSMgr );
+ virtual ~UcbContentProviderProxyFactory();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XServiceInfo
+ XSERVICEINFO_DECL()
+
+ // XContentProviderFactory
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::ucb::XContentProvider > SAL_CALL
+ createContentProvider( const ::rtl::OUString& Service )
+ throw( ::com::sun::star::uno::RuntimeException );
+};
+
+//============================================================================
+//
+// class UcbContentProviderProxy.
+//
+//============================================================================
+
+class UcbContentProviderProxy :
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XTypeProvider,
+ public com::sun::star::lang::XServiceInfo,
+ public com::sun::star::ucb::XContentProviderSupplier,
+ public com::sun::star::ucb::XContentProvider,
+ public com::sun::star::ucb::XParameterizedContentProvider
+{
+ ::osl::Mutex m_aMutex;
+ ::rtl::OUString m_aService;
+ ::rtl::OUString m_aTemplate;
+ ::rtl::OUString m_aArguments;
+ sal_Bool m_bReplace;
+ sal_Bool m_bRegister;
+
+ com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
+ m_xSMgr;
+ com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >
+ m_xProvider;
+ com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >
+ m_xTargetProvider;
+
+public:
+ UcbContentProviderProxy(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
+ const ::rtl::OUString& Service );
+ virtual ~UcbContentProviderProxy();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XServiceInfo
+ XSERVICEINFO_NOFACTORY_DECL()
+
+ // XContentProviderSupplier
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::ucb::XContentProvider > SAL_CALL
+ getContentProvider()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XContentProvider
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::ucb::XContent > SAL_CALL
+ queryContent( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::ucb::XContentIdentifier >& Identifier )
+ throw( ::com::sun::star::ucb::IllegalIdentifierException,
+ ::com::sun::star::uno::RuntimeException );
+ virtual sal_Int32 SAL_CALL
+ compareContentIds( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::ucb::XContentIdentifier >& Id1,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::ucb::XContentIdentifier >& Id2 )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XParameterizedContentProvider
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::ucb::XContentProvider > SAL_CALL
+ registerInstance( const ::rtl::OUString& Template,
+ const ::rtl::OUString& Arguments,
+ sal_Bool ReplaceExisting )
+ throw( ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::ucb::XContentProvider > SAL_CALL
+ deregisterInstance( const ::rtl::OUString& Template,
+ const ::rtl::OUString& Arguments )
+ throw( ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException );
+};
+
+#endif /* !_PROVPROX_HXX */
diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx
new file mode 100644
index 000000000000..d7182400452d
--- /dev/null
+++ b/ucb/source/core/ucb.cxx
@@ -0,0 +1,631 @@
+/*************************************************************************
+ *
+ * $RCSfile: ucb.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ *************************************************************************/
+
+#ifndef __HASH_SET__
+#include <stl/hash_set>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDER_HPP_
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDERSUPPLIER_HPP_
+#include <com/sun/star/ucb/XContentProviderSupplier.hpp>
+#endif
+#ifndef _UCBHELPER_CONFIGUREUCB_HXX_
+#include <ucbhelper/configureucb.hxx>
+#endif
+
+#ifndef _IDENTIFY_HXX
+#include "identify.hxx"
+#endif
+
+#include "ucb.hxx"
+
+// Definitions for ProviderMap_Impl (Solaris wouldn't find explicit template
+// instantiations for these in another compilation unit...):
+#ifndef _UCB_REGEXPMAP_TPT_
+#include <regexpmap.tpt>
+#endif
+
+using namespace rtl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::ucb;
+
+//=========================================================================
+//
+// ContentInfoMap_Impl.
+//
+//=========================================================================
+
+struct equalStr_Impl
+{
+ bool operator()( const ContentInfo& i1, const ContentInfo& i2 ) const
+ {
+ return !!( i1.Type == i2.Type );
+ }
+};
+
+struct hashStr_Impl
+{
+ size_t operator()( const ContentInfo& i ) const
+ {
+ return i.Type.hashCode();
+ }
+};
+
+//=========================================================================
+typedef std::hash_set
+<
+ ContentInfo,
+ hashStr_Impl,
+ equalStr_Impl
+>
+ContentInfoMap_Impl;
+
+//=========================================================================
+//
+// UniversalContentBroker Implementation.
+//
+//=========================================================================
+
+UniversalContentBroker::UniversalContentBroker(
+ const Reference< com::sun::star::lang::XMultiServiceFactory >& rXSMgr )
+: m_xSMgr( rXSMgr ),
+ m_pDisposeEventListeners( NULL ),
+ m_nInitCount( 0 ) //@@@ see initialize() method
+{
+}
+
+//=========================================================================
+// virtual
+UniversalContentBroker::~UniversalContentBroker()
+{
+ delete m_pDisposeEventListeners;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_8( UniversalContentBroker,
+ XTypeProvider,
+ XComponent,
+ XServiceInfo,
+ XInitialization,
+ XContentProviderManager,
+ XContentProvider,
+ XContentIdentifierFactory,
+ XContentCreator );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_8( UniversalContentBroker,
+ XTypeProvider,
+ XComponent,
+ XServiceInfo,
+ XInitialization,
+ XContentProviderManager,
+ XContentProvider,
+ XContentIdentifierFactory,
+ XContentCreator );
+
+//=========================================================================
+//
+// XComponent methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL UniversalContentBroker::dispose()
+ throw( com::sun::star::uno::RuntimeException )
+{
+ if ( m_pDisposeEventListeners && m_pDisposeEventListeners->getLength() )
+ {
+ EventObject aEvt;
+ aEvt.Source = SAL_STATIC_CAST( XComponent*, this );
+ m_pDisposeEventListeners->disposeAndClear( aEvt );
+ }
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL UniversalContentBroker::addEventListener(
+ const Reference< XEventListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ if ( !m_pDisposeEventListeners )
+ m_pDisposeEventListeners = new OInterfaceContainerHelper( m_aMutex );
+
+ m_pDisposeEventListeners->addInterface( Listener );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL UniversalContentBroker::removeEventListener(
+ const Reference< XEventListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ if ( m_pDisposeEventListeners )
+ m_pDisposeEventListeners->removeInterface( Listener );
+
+ // Note: Don't want to delete empty container here -> performance.
+}
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+XSERVICEINFO_IMPL_1( UniversalContentBroker,
+ OUString::createFromAscii( "UniversalContentBroker" ),
+ OUString::createFromAscii( UCB_SERVICE_NAME ) );
+
+//=========================================================================
+//
+// Service factory implementation.
+//
+//=========================================================================
+
+ONE_INSTANCE_SERVICE_FACTORY_IMPL( UniversalContentBroker );
+
+//=========================================================================
+//
+// XInitialization methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL UniversalContentBroker::initialize(
+ const com::sun::star::uno::Sequence< Any >& aArguments )
+ throw( com::sun::star::uno::Exception,
+ com::sun::star::uno::RuntimeException )
+{
+ // If exactly one boolean argument of value 'true' is supplied, the UCB is
+ // configured:
+ sal_Bool bConfigure;
+ if (aArguments.getLength() == 1
+ && (aArguments[0] >>= bConfigure)
+ && bConfigure)
+ {
+ //@@@ At the moment, there's a problem when one (non-one-instance)
+ // factory 'wraps' another (one-instance) factory, causing this method
+ // to be called several times:
+ oslInterlockedCount nCount
+ = osl_incrementInterlockedCount(&m_nInitCount);
+ if (nCount == 1)
+ ucb::configureUcb(this,
+ m_xSMgr,
+ OUString::createFromAscii(
+ UCBHELPER_CONFIGURATION_KEY_STANDARD));
+ else
+ osl_decrementInterlockedCount(&m_nInitCount);
+ // make the possibility of overflow less likely...
+ }
+}
+
+//=========================================================================
+//
+// XContentProviderManager methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XContentProvider > SAL_CALL
+UniversalContentBroker::registerContentProvider(
+ const Reference< XContentProvider >& Provider,
+ const OUString& Scheme,
+ sal_Bool ReplaceExisting )
+ throw( DuplicateProviderException, com::sun::star::uno::RuntimeException )
+{
+ osl::MutexGuard aGuard(m_aMutex);
+
+ ProviderMap_Impl::iterator aIt;
+ try
+ {
+ aIt = m_aProviders.find(Scheme);
+ }
+ catch (IllegalArgumentException const &)
+ {
+ return 0; //@@@
+ }
+
+ Reference< XContentProvider > xPrevious;
+ if (aIt == m_aProviders.end())
+ {
+ ProviderList_Impl aList;
+ aList.push_front(Provider);
+ try
+ {
+ m_aProviders.add(Scheme, aList, false);
+ }
+ catch (IllegalArgumentException const &)
+ {
+ return 0; //@@@
+ }
+ }
+ else
+ {
+ if (!ReplaceExisting)
+ throw DuplicateProviderException();
+
+ ProviderList_Impl & rList = aIt->getValue();
+ xPrevious = rList.front().getProvider();
+ rList.push_front(Provider);
+ }
+
+ return xPrevious;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL UniversalContentBroker::deregisterContentProvider(
+ const Reference< XContentProvider >& Provider,
+ const OUString& Scheme )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ osl::MutexGuard aGuard(m_aMutex);
+
+ ProviderMap_Impl::iterator aMapIt;
+ try
+ {
+ aMapIt = m_aProviders.find(Scheme);
+ }
+ catch (IllegalArgumentException const &) {}
+
+ if (aMapIt != m_aProviders.end())
+ {
+ ProviderList_Impl & rList = aMapIt->getValue();
+
+ ProviderList_Impl::iterator aListEnd(rList.end());
+ for (ProviderList_Impl::iterator aListIt(rList.begin());
+ aListIt != aListEnd; ++aListIt)
+ {
+ if ((*aListIt).getProvider() == Provider)
+ {
+ rList.erase(aListIt);
+ break;
+ }
+ }
+
+ if (rList.empty())
+ m_aProviders.erase(aMapIt);
+ }
+}
+
+//=========================================================================
+// virtual
+com::sun::star::uno::Sequence< ContentProviderInfo > SAL_CALL
+ UniversalContentBroker::queryContentProviders()
+ throw( com::sun::star::uno::RuntimeException )
+{
+ // Return a list with information about active(!) content providers.
+
+ osl::MutexGuard aGuard(m_aMutex);
+
+ com::sun::star::uno::Sequence< ContentProviderInfo > aSeq(
+ m_aProviders.size() );
+ ContentProviderInfo* pInfo = aSeq.getArray();
+
+ ProviderMap_Impl::const_iterator end = m_aProviders.end();
+ for (ProviderMap_Impl::const_iterator it(m_aProviders.begin()); it != end;
+ ++it)
+ {
+ // Note: Active provider is always the first list element.
+ pInfo->ContentProvider = it->getValue().front().getProvider();
+ pInfo->Scheme = it->getRegexp();
+ ++pInfo;
+ }
+
+ return aSeq;
+}
+
+//=========================================================================
+// virtual
+Reference< XContentProvider > SAL_CALL
+ UniversalContentBroker::queryContentProvider( const OUString& Scheme )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ return queryContentProvider( Scheme, sal_False );
+}
+
+//=========================================================================
+//
+// XContentProvider methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XContent > SAL_CALL UniversalContentBroker::queryContent(
+ const Reference< XContentIdentifier >& Identifier )
+ throw( IllegalIdentifierException, com::sun::star::uno::RuntimeException )
+{
+ //////////////////////////////////////////////////////////////////////
+ // Let the content provider for the scheme given with the content
+ // identifier create the XContent instance.
+ //////////////////////////////////////////////////////////////////////
+
+ if ( !Identifier.is() )
+ return Reference< XContent >();
+
+ Reference< XContentProvider > xProv =
+ queryContentProvider( Identifier->getContentIdentifier(), sal_True );
+ if ( xProv.is() )
+ return xProv->queryContent( Identifier );
+
+ return Reference< XContent >();
+}
+
+//=========================================================================
+// virtual
+sal_Int32 SAL_CALL UniversalContentBroker::compareContentIds(
+ const Reference< XContentIdentifier >& Id1,
+ const Reference< XContentIdentifier >& Id2 )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ OUString aURI1( Id1->getContentIdentifier() );
+ OUString aURI2( Id2->getContentIdentifier() );
+
+ Reference< XContentProvider > xProv1
+ = queryContentProvider( aURI1, sal_True );
+ Reference< XContentProvider > xProv2
+ = queryContentProvider( aURI2, sal_True );
+
+ // When both identifiers belong to the same provider, let that provider
+ // compare them; otherwise, simply compare the URI strings (which must
+ // be different):
+ if ( xProv1.is() && ( xProv1 == xProv2 ) )
+ return xProv1->compareContentIds( Id1, Id2 );
+ else
+ return aURI1.compareTo( aURI2 );
+}
+
+//=========================================================================
+//
+// XContentIdentifierFactory methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XContentIdentifier > SAL_CALL
+ UniversalContentBroker::createContentIdentifier(
+ const OUString& ContentId )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ //////////////////////////////////////////////////////////////////////
+ // Let the content provider for the scheme given with content
+ // identifier create the XContentIdentifier instance, if he supports
+ // the XContentIdentifierFactory interface. Otherwise create standard
+ // implementation object for XContentIdentifier.
+ //////////////////////////////////////////////////////////////////////
+
+ Reference< XContentIdentifier > xIdentifier;
+
+ Reference< XContentProvider > xProv
+ = queryContentProvider( ContentId, sal_True );
+ if ( xProv.is() )
+ {
+ Reference< XContentIdentifierFactory > xFac( xProv, UNO_QUERY );
+ if ( xFac.is() )
+ xIdentifier = xFac->createContentIdentifier( ContentId );
+ }
+
+ if ( !xIdentifier.is() )
+ xIdentifier = new ContentIdentifier( m_xSMgr, ContentId );
+
+ return xIdentifier;
+}
+
+//=========================================================================
+//
+// XContentCreator methods.
+//
+//=========================================================================
+
+// virtual
+com::sun::star::uno::Sequence< ContentInfo > SAL_CALL
+ UniversalContentBroker::queryCreatableContentsInfo()
+ throw( com::sun::star::uno::RuntimeException )
+{
+ //////////////////////////////////////////////////////////////////////
+ // Iterate over providers, query info there and merge results.
+ //////////////////////////////////////////////////////////////////////
+
+ ContentInfoMap_Impl aInfoMap;
+
+ osl::MutexGuard aGuard(m_aMutex);
+
+ ProviderMap_Impl::const_iterator end = m_aProviders.end();
+ for (ProviderMap_Impl::const_iterator it(m_aProviders.begin());
+ it != end; ++it)
+ {
+ Reference< XContentCreator >
+ xCreator( it->getValue().front().getResolvedProvider(), UNO_QUERY );
+ if ( xCreator.is() )
+ {
+ com::sun::star::uno::Sequence< ContentInfo > aInfo =
+ xCreator->queryCreatableContentsInfo();
+ sal_uInt32 nCount = aInfo.getLength();
+ for ( sal_uInt32 n = 0; n < nCount; ++ n )
+ {
+ const ContentInfo& rInfo = aInfo[ n ];
+
+ // Avoid duplicates.
+ if ( aInfoMap.find( rInfo ) == aInfoMap.end() )
+ aInfoMap.insert( rInfo );
+ }
+ }
+ }
+
+ // Put collected info into sequence.
+
+ sal_uInt32 nCount = aInfoMap.size();
+ com::sun::star::uno::Sequence< ContentInfo > aSeq( nCount );
+ ContentInfo* pInfo = aSeq.getArray();
+
+ ContentInfoMap_Impl::const_iterator iter = aInfoMap.begin();
+ for ( sal_uInt32 n = 0; n < nCount; n++, iter++ )
+ pInfo[ n ] = (*iter);
+
+ return aSeq;
+}
+
+//=========================================================================
+// virtual
+Reference< XContent > SAL_CALL
+ UniversalContentBroker::createNewContent( const ContentInfo& Info )
+ throw( com::sun::star::uno::RuntimeException )
+{
+ //////////////////////////////////////////////////////////////////////
+ // Find the matching content creator and delegate call.
+ //////////////////////////////////////////////////////////////////////
+
+ osl::MutexGuard aGuard(m_aMutex);
+
+ ProviderMap_Impl::const_iterator end = m_aProviders.end();
+ for (ProviderMap_Impl::const_iterator it(m_aProviders.begin()); it != end;
+ ++it)
+ {
+ // Note: Active provider is always the first list element.
+ Reference< XContentCreator >
+ xCreator( it->getValue().front().getResolvedProvider(), UNO_QUERY );
+ if ( xCreator.is() )
+ {
+ com::sun::star::uno::Sequence< ContentInfo > aInfo =
+ xCreator->queryCreatableContentsInfo();
+ sal_uInt32 nCount = aInfo.getLength();
+ for ( sal_uInt32 n = 0; n < nCount; ++ n )
+ {
+ // Compare content types.
+ if ( aInfo[ n ].Type == Info.Type )
+ {
+ // Found!
+ return xCreator->createNewContent( Info );
+ }
+ }
+ }
+ }
+
+ // No matching creator found.
+ return Reference< XContent >();
+}
+
+//=========================================================================
+//
+// Non-interface methods
+//
+//=========================================================================
+
+Reference< XContentProvider > UniversalContentBroker::queryContentProvider(
+ const OUString& Scheme, sal_Bool bResolved )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ ProviderList_Impl const * pList = m_aProviders.map( Scheme );
+ return pList ? bResolved ? pList->front().getResolvedProvider()
+ : pList->front().getProvider()
+ : Reference< XContentProvider >();
+}
+
+//=========================================================================
+//
+// ProviderListEntry_Impl implementation.
+//
+//=========================================================================
+
+Reference< XContentProvider > ProviderListEntry_Impl::resolveProvider() const
+{
+ if ( !m_xResolvedProvider.is() )
+ {
+ Reference< XContentProviderSupplier > xSupplier(
+ m_xProvider, UNO_QUERY );
+ if ( xSupplier.is() )
+ m_xResolvedProvider = xSupplier->getContentProvider();
+
+ if ( !m_xResolvedProvider.is() )
+ m_xResolvedProvider = m_xProvider;
+ }
+
+ return m_xResolvedProvider;
+}
+
diff --git a/ucb/source/core/ucb.hxx b/ucb/source/core/ucb.hxx
new file mode 100644
index 000000000000..1a9a4ab74af2
--- /dev/null
+++ b/ucb/source/core/ucb.hxx
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * $RCSfile: ucb.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _UCB_HXX
+#define _UCB_HXX
+
+#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDER_HPP_
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTIDENTIFIERFACTORY_HPP_
+#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTCREATOR_HPP_
+#include <com/sun/star/ucb/XContentCreator.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCONTENTPROVIDERMANAGER_HPP_
+#include <com/sun/star/ucb/XContentProviderManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef _OSL_INTERLOCK_H_ //@@@ see initialize() method
+#include <osl/interlck.h>
+#endif
+
+#ifndef _UCBHELPER_MACROS_HXX
+#include <ucbhelper/macros.hxx>
+#endif
+
+#ifndef _UCB_PROVIDERMAP_HXX_
+#include "providermap.hxx"
+#endif
+
+//=========================================================================
+
+#define UCB_SERVICE_NAME "com.sun.star.ucb.UniversalContentBroker"
+
+//=========================================================================
+
+namespace cppu { class OInterfaceContainerHelper; }
+
+class UniversalContentBroker :
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XTypeProvider,
+ public com::sun::star::lang::XComponent,
+ public com::sun::star::lang::XServiceInfo,
+ public com::sun::star::lang::XInitialization,
+ public com::sun::star::ucb::XContentProviderManager,
+ public com::sun::star::ucb::XContentProvider,
+ public com::sun::star::ucb::XContentIdentifierFactory,
+ public com::sun::star::ucb::XContentCreator
+{
+public:
+ UniversalContentBroker( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
+ virtual ~UniversalContentBroker();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XServiceInfo
+ XSERVICEINFO_DECL()
+
+ // XComponent
+ virtual void SAL_CALL dispose()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments )
+ throw( com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException );
+
+ // XContentProviderManager
+ virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > SAL_CALL registerContentProvider( const com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >& Provider, const rtl::OUString& Scheme, sal_Bool ReplaceExisting )
+ throw( com::sun::star::ucb::DuplicateProviderException, com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL deregisterContentProvider( const com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >& Provider, const rtl::OUString& Scheme )
+ throw( com::sun::star::uno::RuntimeException );
+ virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentProviderInfo > SAL_CALL queryContentProviders()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > SAL_CALL queryContentProvider( const rtl::OUString& Scheme )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XContentProvider
+ virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL queryContent( const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier )
+ throw( com::sun::star::ucb::IllegalIdentifierException, com::sun::star::uno::RuntimeException );
+ virtual sal_Int32 SAL_CALL compareContentIds( const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Id1, const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Id2 )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XContentIdentifierFactory
+ virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL createContentIdentifier( const rtl::OUString& ContentId )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XContentCreator
+ virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > SAL_CALL
+ queryCreatableContentsInfo()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
+ createNewContent( const com::sun::star::ucb::ContentInfo& Info )
+ throw( com::sun::star::uno::RuntimeException );
+
+private:
+ com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider >
+ queryContentProvider( const rtl::OUString& Scheme, sal_Bool bResolved );
+
+ com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+ ProviderMap_Impl m_aProviders;
+ osl::Mutex m_aMutex;
+ cppu::OInterfaceContainerHelper* m_pDisposeEventListeners;
+ oslInterlockedCount m_nInitCount; //@@@ see initialize() method
+};
+
+#endif /* !_UCB_HXX */
diff --git a/ucb/source/core/ucbprops.cxx b/ucb/source/core/ucbprops.cxx
new file mode 100644
index 000000000000..6e3da90a9ff9
--- /dev/null
+++ b/ucb/source/core/ucbprops.cxx
@@ -0,0 +1,539 @@
+/*************************************************************************
+ *
+ * $RCSfile: ucbprops.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
+#include <com/sun/star/uno/Type.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
+#include <com/sun/star/uno/Reference.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_CROSSREFERENCE_HPP_
+#include <com/sun/star/ucb/CrossReference.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
+#include <com/sun/star/util/DateTime.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_DOCUMENTHEADERFIELD_HPP_
+#include <com/sun/star/ucb/DocumentHeaderField.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_RECIPIENTINFO_HPP_
+#include <com/sun/star/ucb/RecipientInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_RULESET_HPP_
+#include <com/sun/star/ucb/RuleSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_SENDINFO_HPP_
+#include <com/sun/star/ucb/SendInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_SENDMEDIATYPES_HPP_
+#include <com/sun/star/ucb/SendMediaTypes.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XDATACONTAINER_HPP_
+#include <com/sun/star/ucb/XDataContainer.hpp>
+#endif
+
+#ifndef _UCBPROPS_HXX
+#include "ucbprops.hxx"
+#endif
+
+using namespace rtl;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::util;
+
+//=========================================================================
+//
+// struct PropertyTableEntry
+//
+//=========================================================================
+
+struct PropertyTableEntry
+{
+ const char* pName;
+ sal_Int32 nHandle;
+ sal_Int16 nAttributes;
+ const com::sun::star::uno::Type& (*pGetCppuType)();
+};
+
+//////////////////////////////////////////////////////////////////////////
+//
+// CPPU type access functions.
+//
+//////////////////////////////////////////////////////////////////////////
+
+static const com::sun::star::uno::Type& OUString_getCppuType()
+{
+ return getCppuType( static_cast< const rtl::OUString * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& sal_uInt16_getCppuType()
+{
+ // ! uInt -> Int, because of Java !!!
+ return getCppuType( static_cast< const sal_Int16 * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& sal_uInt32_getCppuType()
+{
+ // ! uInt -> Int, because of Java !!!
+ return getCppuType( static_cast< const sal_Int32 * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& sal_uInt64_getCppuType()
+{
+ // ! uInt -> Int, because of Java !!!
+ return getCppuType( static_cast< const sal_Int64 * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& enum_getCppuType()
+{
+ // ! enum -> Int, because of Java !!!
+ return getCppuType( static_cast< const sal_Int16 * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& sal_Bool_getCppuType()
+{
+ return getCppuBooleanType();
+}
+
+static const com::sun::star::uno::Type& byte_getCppuType()
+{
+ return getCppuType( static_cast< const sal_Int8 * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& Sequence_CrossReference_getCppuType()
+{
+ return getCppuType(
+ static_cast< com::sun::star::uno::Sequence<
+ com::sun::star::ucb::CrossReference > * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& DateTime_getCppuType()
+{
+ return getCppuType(
+ static_cast< com::sun::star::util::DateTime * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& Sequence_byte_getCppuType()
+{
+ return getCppuType(
+ static_cast< com::sun::star::uno::Sequence< sal_Int8 > * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& Sequence_DocumentHeaderField_getCppuType()
+{
+ return getCppuType(
+ static_cast< com::sun::star::uno::Sequence<
+ com::sun::star::ucb::DocumentHeaderField > * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& XDataContainer_getCppuType()
+{
+ return getCppuType(
+ static_cast< com::sun::star::uno::Reference<
+ com::sun::star::ucb::XDataContainer > * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& Sequence_RecipientInfo_getCppuType()
+{
+ return getCppuType(
+ static_cast< com::sun::star::uno::Sequence<
+ com::sun::star::ucb::RecipientInfo > * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& RuleSet_getCppuType()
+{
+ return getCppuType(
+ static_cast< com::sun::star::ucb::RuleSet * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& Sequence_SendInfo_getCppuType()
+{
+ return getCppuType(
+ static_cast< com::sun::star::uno::Sequence<
+ com::sun::star::ucb::SendInfo > * >( 0 ) );
+}
+
+static const com::sun::star::uno::Type& Sequence_SendMediaTypes_getCppuType()
+{
+ return getCppuType(
+ static_cast< com::sun::star::uno::Sequence<
+ com::sun::star::ucb::SendMediaTypes > * >( 0 ) );
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// A table with all well-known UCB properties.
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#define ATTR_DEFAULT ( PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID | PropertyAttribute::MAYBEDEFAULT )
+
+static PropertyTableEntry __aPropertyTable[] =
+{
+ { "Account", -1 /* WID_ACCOUNT */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "AutoUpdateInterval", -1 /* WID_AUTOUPDATE_INTERVAL */, ATTR_DEFAULT, &sal_uInt32_getCppuType },
+ { "ConfirmEmpty", -1 /* WID_TRASHCAN_FLAG_CONFIRMEMPTY */,
+ ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "ConnectionLimit", -1 /* WID_HTTP_CONNECTION_LIMIT */, ATTR_DEFAULT, &byte_getCppuType },
+ { "ConnectionMode", -1 /* WID_CONNECTION_MODE */, ATTR_DEFAULT, &enum_getCppuType },
+ { "ContentCountLimit", -1 /* WID_SHOW_MSGS_TIMELIMIT */, ATTR_DEFAULT, &sal_uInt16_getCppuType },
+ { "ContentType", -1 /* WID_CONTENT_TYPE */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "Cookie", -1 /* WID_HTTP_COOKIE */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "CrossReferences", -1 /* WID_NEWS_XREFLIST */, ATTR_DEFAULT, &Sequence_CrossReference_getCppuType },
+ { "DateCreated", -1 /* WID_DATE_CREATED */, ATTR_DEFAULT, &DateTime_getCppuType },
+ { "DateModified", -1 /* WID_DATE_MODIFIED */, ATTR_DEFAULT, &DateTime_getCppuType },
+ { "DeleteOnServer", -1 /* WID_DELETE_ON_SERVER */, ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "DocumentBody", -1 /* WID_DOCUMENT_BODY */, ATTR_DEFAULT, &Sequence_byte_getCppuType },
+ { "DocumentCount", -1 /* WID_TOTALCONTENTCOUNT */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &sal_uInt32_getCppuType },
+ { "DocumentCountMarked",
+ -1 /* WID_MARKED_DOCUMENT_COUNT */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &sal_uInt32_getCppuType },
+ { "DocumentHeader", -1 /* WID_DOCUMENT_HEADER */, ATTR_DEFAULT, &Sequence_DocumentHeaderField_getCppuType },
+ { "DocumentStoreMode", -1 /* WID_MESSAGE_STOREMODE */, ATTR_DEFAULT, &enum_getCppuType },
+ { "DocumentViewMode", -1 /* WID_MESSAGEVIEW_MODE */, ATTR_DEFAULT, &enum_getCppuType },
+ { "FTPAccount", -1 /* WID_FTP_ACCOUNT */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "Flags", -1 /* WID_FSYS_FLAGS */, ATTR_DEFAULT, &sal_uInt32_getCppuType },
+ { "FolderCount", -1 /* WID_FOLDER_COUNT */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &sal_uInt32_getCppuType },
+ { "FolderViewMode", -1 /* WID_FOLDERVIEW_MODE */, ATTR_DEFAULT, &enum_getCppuType },
+ { "FreeSpace", -1 /* WID_FSYS_DISKSPACE_LEFT */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &sal_uInt64_getCppuType },
+ { "HasDocuments", -1 /* WID_FLAG_HAS_MESSAGES */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &sal_Bool_getCppuType },
+ { "HasFolders", -1 /* WID_FLAG_HAS_FOLDER */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &sal_Bool_getCppuType },
+ { "IsAutoDelete", -1 /* WID_TRASHCAN_FLAG_AUTODELETE */,
+ ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "IsAutoUpdate", -1 /* WID_UPDATE_ENABLED */, ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "IsDocument", -1 /* WID_FLAG_IS_MESSAGE */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &sal_Bool_getCppuType },
+ { "IsFolder", -1 /* WID_FLAG_IS_FOLDER */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &sal_Bool_getCppuType },
+ { "IsKeepExpired", -1 /* WID_HTTP_KEEP_EXPIRED */, ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "IsLimitedContentCount",
+ -1 /* WID_SHOW_MSGS_HAS_TIMELIMIT */,
+ ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "IsMarked", -1 /* WID_IS_MARKED */, ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "IsRead", -1 /* WID_IS_READ */, ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "IsReadOnly", -1 /* WID_FLAG_READONLY */, ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "IsSubscribed", -1 /* WID_FLAG_SUBSCRIBED */, ATTR_DEFAULT, &sal_Bool_getCppuType },
+// { "IsThreaded", -1 /* WID_THREADED */, ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "IsTimeLimitedStore", -1 /* WID_STORE_MSGS_HAS_TIMELIMIT */,
+ ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "Keywords", -1 /* WID_KEYWORDS */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "LocalBase", -1 /* WID_LOCALBASE */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "MessageBCC", -1 /* WID_BCC */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "MessageBody", -1 /* WID_MESSAGEBODY */, ATTR_DEFAULT, &XDataContainer_getCppuType },
+ { "MessageCC", -1 /* WID_CC */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "MessageFrom", -1 /* WID_FROM */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "MessageId", -1 /* WID_MESSAGE_ID */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "MessageInReplyTo", -1 /* WID_IN_REPLY_TO */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "MessageReplyTo", -1 /* WID_REPLY_TO */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "MessageTo", -1 /* WID_TO */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "NewsGroups", -1 /* WID_NEWSGROUPS */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "NoCacheList", -1 /* WID_HTTP_NOCACHE_LIST */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "Origin", -1 /* WID_TRASH_ORIGIN */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &OUString_getCppuType },
+ { "OutgoingMessageRecipients",
+ -1 /* WID_RECIPIENTLIST */, ATTR_DEFAULT, &Sequence_RecipientInfo_getCppuType },
+ { "OutgoingMessageState",
+ -1 /* WID_OUTMSGINTERNALSTATE */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &enum_getCppuType },
+ { "OutgoingMessageViewMode",
+ -1 /* WID_SENTMESSAGEVIEW_MODE */,
+ ATTR_DEFAULT, &enum_getCppuType },
+// { "OwnURL", -1 /* WID_OWN_URL */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "Password", -1 /* WID_PASSWORD */, ATTR_DEFAULT, &OUString_getCppuType },
+// { "PresentationURL", -1 /* WID_REAL_URL */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+// &OUString_getCppuType },
+ { "Priority", -1 /* WID_PRIORITY */, ATTR_DEFAULT, &enum_getCppuType },
+ { "References", -1 /* WID_REFERENCES */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "Referer", -1 /* WID_HTTP_REFERER */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "Rules", -1 /* WID_RULES */, ATTR_DEFAULT, &RuleSet_getCppuType },
+ { "SearchCriteria", -1 /* WID_SEARCH_CRITERIA */, ATTR_DEFAULT, &RuleSet_getCppuType },
+ { "SearchIndirections", -1 /* WID_SEARCH_INDIRECTIONS */, ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "SearchLocations", -1 /* WID_SEARCH_LOCATIONS */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "SearchRecursive", -1 /* WID_SEARCH_RECURSIVE */, ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "SeenCount", -1 /* WID_SEENCONTENTCOUNT */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &sal_uInt32_getCppuType },
+ { "SendCopyTarget", -1 /* WID_SEND_COPY_TARGET */, ATTR_DEFAULT, &Sequence_SendInfo_getCppuType },
+ { "SendFormats", -1 /* WID_SEND_FORMATS */, ATTR_DEFAULT, &Sequence_SendMediaTypes_getCppuType },
+ { "SendFroms", -1 /* WID_SEND_FROM_DEFAULT */, ATTR_DEFAULT, &Sequence_SendInfo_getCppuType },
+ { "SendPasswords", -1 /* WID_SEND_PASSWORD */, ATTR_DEFAULT, &Sequence_SendInfo_getCppuType },
+ { "SendProtocolPrivate",-1 /* WID_SEND_PRIVATE_PROT_ID */, ATTR_DEFAULT, &sal_uInt16_getCppuType },
+ { "SendProtocolPublic", -1 /* WID_SEND_PUBLIC_PROT_ID */, ATTR_DEFAULT, &sal_uInt16_getCppuType },
+ { "SendReplyTos", -1 /* WID_SEND_REPLY_TO_DEFAULT */, ATTR_DEFAULT, &Sequence_SendInfo_getCppuType },
+ { "SendServerNames", -1 /* WID_SEND_SERVERNAME */, ATTR_DEFAULT, &Sequence_SendInfo_getCppuType },
+ { "SendUserNames", -1 /* WID_SEND_USERNAME */, ATTR_DEFAULT, &Sequence_SendInfo_getCppuType },
+ { "SendVIMPostOfficePath",
+ -1 /* WID_SEND_VIM_POPATH */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "ServerBase", -1 /* WID_SERVERBASE */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "ServerName", -1 /* WID_SERVERNAME */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "ServerPort", -1 /* WID_SERVERPORT */, ATTR_DEFAULT, &sal_uInt16_getCppuType },
+ { "Size", -1 /* WID_DOCUMENT_SIZE */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &sal_uInt64_getCppuType },
+ { "SizeLimit", -1 /* WID_SIZE_LIMIT */, ATTR_DEFAULT, &sal_uInt64_getCppuType },
+ { "SubscribedCount", -1 /* WID_SUBSCRNEWSGROUPCOUNT */, ATTR_DEFAULT | PropertyAttribute::READONLY,
+ &sal_uInt32_getCppuType },
+ { "SynchronizePolicy", -1 /* WID_WHO_IS_MASTER */, ATTR_DEFAULT, &enum_getCppuType },
+ { "TargetFrames", -1 /* WID_TARGET_FRAMES */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "TargetURL", -1 /* WID_TARGET_URL */, ATTR_DEFAULT, &OUString_getCppuType },
+// { "ThreadingInfo", -1 /* WID_THREADING */, ATTR_DEFAULT, &Sequence_ThreadingInfo_getCppuType },
+ { "TimeLimitStore", -1 /* WID_STORE_MSGS_TIMELIMIT */, ATTR_DEFAULT, &sal_uInt16_getCppuType },
+ { "Title", -1 /* WID_TITLE */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "UpdateOnOpen", -1 /* WID_FLAG_UPDATE_ON_OPEN */, ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "UseOutBoxPrivateProtocolSettings",
+ -1 /* WID_SEND_PRIVATE_OUTBOXPROPS */,
+ ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "UseOutBoxPublicProtocolSettings",
+ -1 /* WID_SEND_PUBLIC_OUTBOXPROPS */,
+ ATTR_DEFAULT, &sal_Bool_getCppuType },
+ { "UserName", -1 /* WID_USERNAME */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "UserSortCriterium", -1 /* WID_USER_SORT_CRITERIUM */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "VIMPostOfficePath", -1 /* WID_VIM_POPATH */, ATTR_DEFAULT, &OUString_getCppuType },
+ { "VerificationMode", -1 /* WID_HTTP_VERIFY_MODE */, ATTR_DEFAULT, &enum_getCppuType },
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // EOT.
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ { 0, 0, 0, 0 }
+};
+
+//=========================================================================
+//=========================================================================
+//
+// UcbPropertiesManager Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+UcbPropertiesManager::UcbPropertiesManager(
+ const Reference< XMultiServiceFactory >& rxSMgr )
+: /*m_xSMgr( rxSMgr ),*/
+ m_pProps( 0 )
+{
+}
+
+//=========================================================================
+// virtual
+UcbPropertiesManager::~UcbPropertiesManager()
+{
+ delete m_pProps;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_3( UcbPropertiesManager,
+ XTypeProvider,
+ XServiceInfo,
+ XPropertySetInfo );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_3( UcbPropertiesManager,
+ XTypeProvider,
+ XServiceInfo,
+ XPropertySetInfo );
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+XSERVICEINFO_IMPL_1( UcbPropertiesManager,
+ OUString::createFromAscii( "UcbPropertiesManager" ),
+ OUString::createFromAscii(
+ PROPERTIES_MANAGER_SERVICE_NAME ) );
+
+//=========================================================================
+//
+// Service factory implementation.
+//
+//=========================================================================
+
+ONE_INSTANCE_SERVICE_FACTORY_IMPL( UcbPropertiesManager );
+
+//=========================================================================
+//
+// XPropertySetInfo methods.
+//
+//=========================================================================
+
+// virtual
+Sequence< Property > SAL_CALL UcbPropertiesManager::getProperties()
+ throw( RuntimeException )
+{
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+
+ if ( !m_pProps )
+ {
+ m_pProps = new Sequence< Property >( 128 );
+ Property* pProps = m_pProps->getArray();
+ sal_Int32 nPos = 0;
+ sal_Int32 nSize = m_pProps->getLength();
+
+ //////////////////////////////////////////////////////////////////
+ // Get info for well-known properties.
+ //////////////////////////////////////////////////////////////////
+
+ const PropertyTableEntry* pCurr = &__aPropertyTable[ 0 ];
+ while ( pCurr->pName )
+ {
+ if ( nSize <= nPos )
+ {
+ OSL_ENSURE( sal_False,
+ "UcbPropertiesManager::getProperties - "
+ "Initial size of property sequence too small!" );
+
+ m_pProps->realloc( 128 );
+ nSize += 128;
+ }
+
+ Property& rProp = pProps[ nPos ];
+
+ rProp.Name = OUString::createFromAscii( pCurr->pName );
+ rProp.Handle = pCurr->nHandle;
+ rProp.Type = pCurr->pGetCppuType();
+ rProp.Attributes = pCurr->nAttributes;
+
+ nPos++;
+ pCurr++;
+ }
+
+ if ( nPos > 0 )
+ {
+ m_pProps->realloc( nPos );
+ nSize = m_pProps->getLength();
+ }
+ }
+ return *m_pProps;
+}
+
+//=========================================================================
+// virtual
+Property SAL_CALL UcbPropertiesManager::getPropertyByName( const OUString& aName )
+ throw( UnknownPropertyException, RuntimeException )
+{
+ Property aProp;
+ if ( queryProperty( aName, aProp ) )
+ return aProp;
+
+ throw UnknownPropertyException();
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL UcbPropertiesManager::hasPropertyByName( const OUString& Name )
+ throw( RuntimeException )
+{
+ Property aProp;
+ return queryProperty( Name, aProp );
+}
+
+//=========================================================================
+//
+// Non-Interface methods.
+//
+//=========================================================================
+
+sal_Bool UcbPropertiesManager::queryProperty(
+ const OUString& rName, Property& rProp )
+{
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+
+ getProperties();
+
+ const Property* pProps = m_pProps->getConstArray();
+ sal_Int32 nCount = m_pProps->getLength();
+ for ( sal_Int32 n = 0; n < nCount; ++n )
+ {
+ const Property& rCurrProp = pProps[ n ];
+ if ( rCurrProp.Name == rName )
+ {
+ rProp = rCurrProp;
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
diff --git a/ucb/source/core/ucbprops.hxx b/ucb/source/core/ucbprops.hxx
new file mode 100644
index 000000000000..66f501603f38
--- /dev/null
+++ b/ucb/source/core/ucbprops.hxx
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * $RCSfile: ucbprops.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _UCBPROPS_HXX
+#define _UCBPROPS_HXX
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#endif
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _UCBHELPER_MACROS_HXX
+#include <ucbhelper/macros.hxx>
+#endif
+
+//=========================================================================
+
+#define PROPERTIES_MANAGER_SERVICE_NAME "com.sun.star.ucb.PropertiesManager"
+
+//============================================================================
+//
+// class UcbPropertiesManager.
+//
+//============================================================================
+
+class UcbPropertiesManager :
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XTypeProvider,
+ public com::sun::star::lang::XServiceInfo,
+ public com::sun::star::beans::XPropertySetInfo
+{
+// com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
+// m_xSMgr;
+ com::sun::star::uno::Sequence< com::sun::star::beans::Property >*
+ m_pProps;
+ osl::Mutex m_aMutex;
+
+private:
+ sal_Bool queryProperty( const rtl::OUString& rName,
+ com::sun::star::beans::Property& rProp );
+
+public:
+ UcbPropertiesManager( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >&
+ rxSMgr );
+ virtual ~UcbPropertiesManager();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XServiceInfo
+ XSERVICEINFO_DECL()
+
+ // XPropertySetInfo
+ virtual com::sun::star::uno::Sequence<
+ com::sun::star::beans::Property > SAL_CALL
+ getProperties()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual com::sun::star::beans::Property SAL_CALL
+ getPropertyByName( const rtl::OUString& aName )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ hasPropertyByName( const rtl::OUString& Name )
+ throw( com::sun::star::uno::RuntimeException );
+};
+
+#endif /* !_UCBPROPS_HXX */
+
diff --git a/ucb/source/core/ucbserv.cxx b/ucb/source/core/ucbserv.cxx
new file mode 100644
index 000000000000..af6e33786a8d
--- /dev/null
+++ b/ucb/source/core/ucbserv.cxx
@@ -0,0 +1,279 @@
+/*************************************************************************
+ *
+ * $RCSfile: ucbserv.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+
+#ifndef _UCB_HXX
+#include "ucb.hxx"
+#endif
+#ifndef _UCBCFG_HXX
+#include "ucbcfg.hxx"
+#endif
+#ifndef _UCBSTORE_HXX
+#include "ucbstore.hxx"
+#endif
+#ifndef _UCBPROPS_HXX
+#include "ucbprops.hxx"
+#endif
+#ifndef _PROVPROX_HXX
+#include "provprox.hxx"
+#endif
+#ifndef _UCB_UCBDISTRIBUTOR_HXX_
+#include "ucbdistributor.hxx"
+#endif
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+//=========================================================================
+static sal_Bool writeInfo( void * pRegistryKey,
+ const OUString & rImplementationName,
+ Sequence< OUString > const & rServiceNames )
+{
+ OUString aKeyName( OUString::createFromAscii( "/" ) );
+ aKeyName += rImplementationName;
+ aKeyName += OUString::createFromAscii( "/UNO/SERVICES" );
+
+ Reference< XRegistryKey > xKey;
+ try
+ {
+ xKey = static_cast< XRegistryKey * >(
+ pRegistryKey )->createKey( aKeyName );
+ }
+ catch ( InvalidRegistryException const & )
+ {
+ }
+
+ if ( !xKey.is() )
+ return sal_False;
+
+ sal_Bool bSuccess = sal_True;
+
+ for ( sal_Int32 n = 0; n < rServiceNames.getLength(); ++n )
+ {
+ try
+ {
+ xKey->createKey( rServiceNames[ n ] );
+ }
+ catch ( InvalidRegistryException const & )
+ {
+ bSuccess = sal_False;
+ break;
+ }
+ }
+ return bSuccess;
+}
+
+//=========================================================================
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//=========================================================================
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ return pRegistryKey &&
+
+ //////////////////////////////////////////////////////////////////////
+ // Universal Content Broker.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ UniversalContentBroker::getImplementationName_Static(),
+ UniversalContentBroker::getSupportedServiceNames_Static() ) &&
+
+ //////////////////////////////////////////////////////////////////////
+ // UCB Configuration.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ UcbConfigurationManager::getImplementationName_Static(),
+ UcbConfigurationManager::getSupportedServiceNames_Static() ) &&
+
+ //////////////////////////////////////////////////////////////////////
+ // UCB Store.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ UcbStore::getImplementationName_Static(),
+ UcbStore::getSupportedServiceNames_Static() ) &&
+
+ //////////////////////////////////////////////////////////////////////
+ // UCB PropertiesManager.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ UcbPropertiesManager::getImplementationName_Static(),
+ UcbPropertiesManager::getSupportedServiceNames_Static() ) &&
+
+ //////////////////////////////////////////////////////////////////////
+ // UCP Proxy Factory.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ UcbContentProviderProxyFactory::getImplementationName_Static(),
+ UcbContentProviderProxyFactory::getSupportedServiceNames_Static() ) &&
+
+ //////////////////////////////////////////////////////////////////////
+ // UCB Distributor.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ chaos_ucb::UcbDistributor::getImplementationName_Static(),
+ chaos_ucb::UcbDistributor::getSupportedServiceNames_Static() );
+}
+
+//=========================================================================
+extern "C" void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ Reference< XMultiServiceFactory > xSMgr(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
+ Reference< XSingleServiceFactory > xFactory;
+
+ //////////////////////////////////////////////////////////////////////
+ // Universal Content Broker.
+ //////////////////////////////////////////////////////////////////////
+
+ if ( UniversalContentBroker::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory = UniversalContentBroker::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // UCB Configuration.
+ //////////////////////////////////////////////////////////////////////
+
+ else if ( UcbConfigurationManager::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory = UcbConfigurationManager::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // UCB Store.
+ //////////////////////////////////////////////////////////////////////
+
+ else if ( UcbStore::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory = UcbStore::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // UCB PropertiesManager.
+ //////////////////////////////////////////////////////////////////////
+
+ else if ( UcbPropertiesManager::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory = UcbPropertiesManager::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // UCP Proxy Factory.
+ //////////////////////////////////////////////////////////////////////
+
+ else if ( UcbContentProviderProxyFactory::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory
+ = UcbContentProviderProxyFactory::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // UCB Distributor.
+ //////////////////////////////////////////////////////////////////////
+
+ else if ( chaos_ucb::UcbDistributor::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory
+ = chaos_ucb::UcbDistributor::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+
+ return pRet;
+}
+
diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
new file mode 100644
index 000000000000..573e3c639447
--- /dev/null
+++ b/ucb/source/core/ucbstore.cxx
@@ -0,0 +1,2346 @@
+/*************************************************************************
+ *
+ * $RCSfile: ucbstore.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/**************************************************************************
+ TODO
+ **************************************************************************
+
+ UcbStore
+
+ - Vergleiche der URL's case-insensitive -> UNIX ?
+
+ PropertySetRegistry
+
+ *************************************************************************/
+
+#ifndef _RTL_CHAR_H_
+#include <rtl/char.h>
+#endif
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+#ifndef _RTL_MEMORY_H_
+#include <rtl/memory.h>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef __LIST__
+#include <stl/list>
+#endif
+#ifndef __HASH_MAP__
+#include <stl/hash_map>
+#endif
+#ifndef __VECTOR__
+#include <stl/vector>
+#endif
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+#ifndef _VOS_MACROS_HXX_
+#include <vos/macros.hxx>
+#endif
+#ifndef _VOS_DIAGNOSE_HXX_
+#include <vos/diagnose.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _STORE_STORE_HXX_
+#include <store/store.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYSETINFOCHANGE_HPP_
+#include <com/sun/star/beans/PropertySetInfoChange.hpp>
+#endif
+
+#include "ucbstore.hxx"
+
+#ifndef _FLATANY_HXX
+#include "flatany.hxx"
+#endif
+#if 0
+#ifndef _CNTPPSET_HXX
+#include "cntppset.hxx"
+#endif
+#endif
+
+using namespace com::sun::star::beans;
+using namespace com::sun::star::container;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace cppu;
+using namespace rtl;
+
+//=========================================================================
+//
+// stl hash map support.
+//
+//=========================================================================
+
+struct equalStringIgnoreCase_Impl
+{
+ bool operator ()( const OUString& rKey1, const OUString& rKey2 ) const
+ {
+ return !!( rKey1.equalsIgnoreCase( rKey2 ) );
+ }
+};
+
+struct hashStringIgnoreCase_Impl
+{
+ size_t operator()( const OUString& rKey ) const
+ {
+ const sal_Unicode* p = rKey.getStr();
+ sal_uInt32 h = 0;
+ for ( ; *p; ++p )
+ h = 5 * h + rtl_char_toLowerCase( *p );
+
+ return h;
+ }
+};
+
+struct equalString_Impl
+{
+ bool operator()( const OUString& s1, const OUString& s2 ) const
+ {
+ return !!( s1 == s2 );
+ }
+};
+
+struct hashString_Impl
+{
+ size_t operator()( const OUString & rName ) const
+ {
+ return rName.hashCode();
+ }
+};
+
+//=========================================================================
+
+#define PROPERTYSET_STREAM_PREFIX "propset."
+#define PROPERTYSET_STREAM_MAGIC 19690713
+#define PROPERTYSET_STREAM_VERSION 1
+
+struct PropertySetStreamHeader_Impl
+{
+ sal_uInt32 m_nMagic;
+ sal_uInt32 m_nVersion;
+ sal_uInt32 m_nDataLen; // size of data, without header
+ sal_uInt32 m_nCount; // number of elements
+
+ PropertySetStreamHeader_Impl()
+ : m_nMagic( 0 ), m_nVersion( 0 ), m_nDataLen( 0 ), m_nCount( 0 ) {}
+
+ PropertySetStreamHeader_Impl(
+ sal_uInt32 M, sal_uInt32 V, sal_uInt32 D, sal_uInt32 C )
+ : m_nMagic( M ), m_nVersion( V ), m_nDataLen( D ), m_nCount( C ) {}
+};
+
+#define PROPERTYSET_STREAM_HEADER_SIZE sizeof( PropertySetStreamHeader_Impl )
+#define PROPERTYSET_STREAM_ALIGNMENT 4 /* Bytes */
+
+//=========================================================================
+//
+// class PropertySetStreamBuffer_Impl
+//
+//=========================================================================
+
+#define ALIGN_POS( a ) \
+ (( a*( PROPERTYSET_STREAM_ALIGNMENT-1))%PROPERTYSET_STREAM_ALIGNMENT)
+
+class PropertySetStreamBuffer_Impl
+{
+ sal_uInt32 m_nSize;
+ sal_uInt32 m_nGrow;
+ sal_uInt8* m_pBuffer;
+ sal_uInt8* m_pPos;
+
+private:
+ void ensureCapacity( sal_uInt8 nBytesNeeded );
+
+public:
+ PropertySetStreamBuffer_Impl( sal_uInt32 nInitSize,
+ sal_uInt32 nGrowSize = 4096 );
+ ~PropertySetStreamBuffer_Impl();
+
+ operator sal_uInt8* () const { return m_pBuffer; }
+
+ sal_uInt32 getDataLength() const { return ( m_pPos - m_pBuffer ); }
+
+ sal_Bool readString( OUString& rValue );
+ sal_Bool readInt32 ( sal_Int32& rValue );
+ sal_Bool readAny ( Any& rValue );
+
+ sal_Bool writeString( const OUString& rValue );
+ sal_Bool writeInt32 ( sal_Int32 nValue );
+ sal_Bool writeAny ( const Any& rValue );
+};
+
+//=========================================================================
+//
+// RegistryMap_Impl.
+//
+//=========================================================================
+
+typedef std::hash_map
+<
+ OUString,
+ PropertySetRegistry*,
+ hashStringIgnoreCase_Impl,
+ equalStringIgnoreCase_Impl
+>
+RegistryMap_Impl;
+
+//=========================================================================
+//
+// PropertySetMap_Impl.
+//
+//=========================================================================
+
+typedef std::hash_map
+<
+ OUString,
+ PersistentPropertySet*,
+ hashString_Impl,
+ equalString_Impl
+>
+PropertySetMap_Impl;
+
+//=========================================================================
+//
+// class PropertySetInfo_Impl
+//
+//=========================================================================
+
+class PropertySetInfo_Impl :
+ public OWeakObject, public XTypeProvider, public XPropertySetInfo
+{
+ Reference< XMultiServiceFactory > m_xSMgr;
+ Sequence< Property >* m_pProps;
+ PersistentPropertySet* m_pOwner;
+
+private:
+ sal_Bool queryProperty( const OUString& aName, Property& rProp );
+
+public:
+ PropertySetInfo_Impl( const Reference< XMultiServiceFactory >& rxSMgr,
+ PersistentPropertySet* pOwner );
+ virtual ~PropertySetInfo_Impl();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XPropertySetInfo
+ virtual Sequence< Property > SAL_CALL getProperties()
+ throw( RuntimeException );
+ virtual Property SAL_CALL getPropertyByName( const OUString& aName )
+ throw( UnknownPropertyException, RuntimeException );
+ virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name )
+ throw( RuntimeException );
+
+ // Non-interface methods.
+ void reset() { delete m_pProps; m_pProps = 0; }
+};
+
+//=========================================================================
+//
+// UcbStore_Impl.
+//
+//=========================================================================
+
+struct UcbStore_Impl
+{
+ RegistryMap_Impl m_aRegistries;
+ osl::Mutex m_aMutex;
+};
+
+//=========================================================================
+//=========================================================================
+//=========================================================================
+//
+// UcbStore Implementation.
+//
+//=========================================================================
+//=========================================================================
+//=========================================================================
+
+UcbStore::UcbStore( const Reference< XMultiServiceFactory >& rXSMgr )
+: m_xSMgr( rXSMgr ),
+ m_pImpl( new UcbStore_Impl() )
+{
+}
+
+//=========================================================================
+// virtual
+UcbStore::~UcbStore()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_3( UcbStore,
+ XTypeProvider,
+ XServiceInfo,
+ XPropertySetRegistryFactory );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_3( UcbStore,
+ XTypeProvider,
+ XServiceInfo,
+ XPropertySetRegistryFactory );
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+XSERVICEINFO_IMPL_1( UcbStore,
+ OUString::createFromAscii( "UcbStore" ),
+ OUString::createFromAscii( STORE_SERVICE_NAME ) );
+
+//=========================================================================
+//
+// Service factory implementation.
+//
+//=========================================================================
+
+ONE_INSTANCE_SERVICE_FACTORY_IMPL( UcbStore );
+
+//=========================================================================
+//
+// XPropertySetRegistryFactory methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XPropertySetRegistry > SAL_CALL
+UcbStore::createPropertySetRegistry( const OUString& URL )
+ throw( RuntimeException )
+{
+ if ( URL.getLength() )
+ {
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ RegistryMap_Impl& rRegs = m_pImpl->m_aRegistries;
+
+ RegistryMap_Impl::const_iterator it = rRegs.find( URL );
+ if ( it != rRegs.end() )
+ {
+ // Already instanciated.
+ return Reference< XPropertySetRegistry >( (*it).second );
+ }
+ else
+ {
+ // Create new and remember, if valid.
+ PropertySetRegistry* pNew =
+ PropertySetRegistry::create( m_xSMgr, *this, URL );
+ if ( pNew )
+ {
+ rRegs[ URL ] = pNew;
+ return Reference< XPropertySetRegistry >( pNew );
+ }
+ }
+ }
+
+ return Reference< XPropertySetRegistry >();
+}
+
+//=========================================================================
+//
+// New methods.
+//
+//=========================================================================
+
+void UcbStore::removeRegistry( const OUString& URL )
+{
+ if ( URL.getLength() )
+ {
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ RegistryMap_Impl& rRegs = m_pImpl->m_aRegistries;
+
+ RegistryMap_Impl::iterator it = rRegs.find( URL );
+ if ( it != rRegs.end() )
+ {
+ // Found.
+ rRegs.erase( it );
+ }
+ }
+}
+
+//=========================================================================
+//
+// PropertySetRegistry_Impl.
+//
+//=========================================================================
+
+struct PropertySetRegistry_Impl
+{
+ UcbStore* m_pCreator;
+ OUString m_aURL;
+ store::OStoreFile m_aStoreFile;
+ PropertySetMap_Impl m_aPropSets;
+ osl::Mutex m_aMutex;
+
+ PropertySetRegistry_Impl( UcbStore& rCreator,
+ const OUString& rURL,
+ const store::OStoreFile& rStoreFile )
+ : m_pCreator( &rCreator ), m_aURL( rURL ), m_aStoreFile( rStoreFile )
+ {
+ m_pCreator->acquire();
+ }
+
+ ~PropertySetRegistry_Impl()
+ {
+ m_pCreator->removeRegistry( m_aURL );
+ m_pCreator->release();
+ }
+};
+
+//=========================================================================
+//=========================================================================
+//=========================================================================
+//
+// PropertySetRegistry Implementation.
+//
+//=========================================================================
+//=========================================================================
+//=========================================================================
+
+PropertySetRegistry::PropertySetRegistry(
+ const Reference< XMultiServiceFactory >& rXSMgr,
+ UcbStore& rCreator,
+ const OUString& rURL,
+ const store::OStoreFile& rStoreFile )
+: m_xSMgr( rXSMgr ),
+ m_pImpl( new PropertySetRegistry_Impl( rCreator, rURL, rStoreFile ) )
+{
+}
+
+//=========================================================================
+// virtual
+PropertySetRegistry::~PropertySetRegistry()
+{
+ delete m_pImpl;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_5( PropertySetRegistry,
+ XTypeProvider,
+ XServiceInfo,
+ XPropertySetRegistry,
+ XElementAccess, /* base of XNameAccess */
+ XNameAccess );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_4( PropertySetRegistry,
+ XTypeProvider,
+ XServiceInfo,
+ XPropertySetRegistry,
+ XNameAccess );
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+XSERVICEINFO_NOFACTORY_IMPL_1( PropertySetRegistry,
+ OUString::createFromAscii(
+ "PropertySetRegistry" ),
+ OUString::createFromAscii(
+ PROPSET_REG_SERVICE_NAME ) );
+
+//=========================================================================
+//
+// XPropertySetRegistry methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XPersistentPropertySet > SAL_CALL
+PropertySetRegistry::openPropertySet( const OUString& key, sal_Bool create )
+ throw( RuntimeException )
+{
+ if ( key.getLength() )
+ {
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ PropertySetMap_Impl& rSets = m_pImpl->m_aPropSets;
+
+ PropertySetMap_Impl::const_iterator it = rSets.find( key );
+ if ( it != rSets.end() )
+ {
+ // Already instanciated.
+ return Reference< XPersistentPropertySet >( (*it).second );
+ }
+ else
+ {
+ // Create new and remember, if valid.
+ PersistentPropertySet* pNew =
+ PersistentPropertySet::create( m_xSMgr, *this, key, create );
+ if ( pNew )
+ return Reference< XPersistentPropertySet >( pNew );
+ }
+ }
+
+ return Reference< XPersistentPropertySet >();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PropertySetRegistry::removePropertySet( const OUString& key )
+ throw( RuntimeException )
+{
+ OUString aKey( OUString::createFromAscii( PROPERTYSET_STREAM_PREFIX ) );
+ aKey += key;
+
+ storeError nError = m_pImpl->m_aStoreFile.remove(
+ OUString::createFromAscii( "/" ), aKey );
+
+ VOS_ENSURE( ( nError == store_E_None ) || ( nError == store_E_NotExists ),
+ "PropertySetRegistry::removePropertySet - error" );
+}
+
+//=========================================================================
+//
+// XElementAccess methods.
+//
+//=========================================================================
+
+// virtual
+com::sun::star::uno::Type SAL_CALL PropertySetRegistry::getElementType()
+ throw( RuntimeException )
+{
+ return getCppuType( ( Reference< XPersistentPropertySet >* ) 0 );
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL PropertySetRegistry::hasElements()
+ throw( RuntimeException )
+{
+ Sequence< OUString > aSeq( getElementNames() );
+ return ( aSeq.getLength() > 0 );
+}
+
+//=========================================================================
+//
+// XNameAccess methods.
+//
+//=========================================================================
+
+// virtual
+Any SAL_CALL PropertySetRegistry::getByName( const OUString& aName )
+ throw( NoSuchElementException, WrappedTargetException, RuntimeException )
+{
+ Reference< XPersistentPropertySet > xSet(
+ PersistentPropertySet::create( m_xSMgr, *this, aName, sal_False ) );
+ if ( xSet.is() )
+ return Any( &xSet, getCppuType( &xSet ) );
+ else
+ throw NoSuchElementException();
+
+ return Any();
+}
+
+//=========================================================================
+// virtual
+Sequence< OUString > SAL_CALL PropertySetRegistry::getElementNames()
+ throw( RuntimeException )
+{
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ store::OStoreDirectory aDir;
+ storeError nError = aDir.create(
+ m_pImpl->m_aStoreFile, OUString(), OUString(), store_AccessReadOnly );
+
+ if ( nError == store_E_None )
+ {
+ /////////////////////////////////////////////////////////////
+ // Collect names.
+ /////////////////////////////////////////////////////////////
+
+ std::list< OUString > aElements;
+
+ store::OStoreDirectory::iterator iter;
+ OUString aKeyName;
+ const OUString aPrefix( OUString::createFromAscii(
+ PROPERTYSET_STREAM_PREFIX ) );
+ sal_Int32 nPrefixLen = aPrefix.getLength();
+
+ nError = aDir.first( iter );
+
+ while ( nError == store_E_None )
+ {
+ aKeyName = OUString( iter.m_pszName );
+
+ if ( aKeyName.compareTo( aPrefix, nPrefixLen ) == 0 )
+ aElements.push_back(
+ aKeyName.copy( nPrefixLen,
+ aKeyName.getLength() - nPrefixLen ) );
+
+ nError = aDir.next( iter );
+ }
+
+ /////////////////////////////////////////////////////////////
+ // Fill sequence.
+ /////////////////////////////////////////////////////////////
+
+ sal_uInt32 nCount = aElements.size();
+ if ( nCount )
+ {
+ Sequence< OUString > aSeq( nCount );
+ OUString* pNames = aSeq.getArray();
+ sal_uInt32 nArrPos = 0;
+
+ std::list < OUString >::const_iterator it = aElements.begin();
+ std::list < OUString >::const_iterator end = aElements.end();
+
+ while ( it != end )
+ {
+ pNames[ nArrPos ] = (*it);
+ it++;
+ nArrPos++;
+ }
+
+ aDir.close();
+ return aSeq;
+ }
+ }
+
+ aDir.close();
+ return Sequence< OUString >( 0 );
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL PropertySetRegistry::hasByName( const OUString& aName )
+ throw( RuntimeException )
+{
+ Reference< XPersistentPropertySet > xSet(
+ PersistentPropertySet::create( m_xSMgr, *this, aName, sal_False ) );
+ if ( xSet.is() )
+ return sal_True;
+
+ return sal_False;
+}
+
+//=========================================================================
+//
+// Non-interface methods
+//
+//=========================================================================
+
+// static
+PropertySetRegistry* PropertySetRegistry::create(
+ const Reference< XMultiServiceFactory >& rXSMgr,
+ UcbStore& rCreator,
+ const OUString& rURL )
+{
+ if ( !rURL.getLength() )
+ return NULL;
+
+ // Convert URL to system dependent file path.
+ OUString aUNCPath;
+ osl::FileBase::RC
+ eErr = osl::FileBase::getNormalizedPathFromFileURL( rURL, aUNCPath );
+ if ( eErr != osl::FileBase::E_None )
+ return NULL;
+
+ OUString aPath;
+ eErr = osl::FileBase::getSystemPathFromNormalizedPath( aUNCPath, aPath );
+ if ( eErr != osl::FileBase::E_None )
+ return NULL;
+
+ // Try to open/create storage file.
+ store::OStoreFile aStoreFile;
+ storeError nError = aStoreFile.create( aPath, store_AccessReadCreate );
+ if ( nError != store_E_None )
+ return NULL;
+
+ // Root directory must be created explicitely!
+ store::OStoreDirectory aRootDir;
+ nError = aRootDir.create(
+ aStoreFile, OUString(), OUString(), store_AccessReadCreate );
+
+ return new PropertySetRegistry( rXSMgr, rCreator, rURL, aStoreFile );
+}
+
+//=========================================================================
+osl::Mutex& PropertySetRegistry::getRegistryMutex() const
+{
+ return m_pImpl->m_aMutex;
+}
+
+//=========================================================================
+store::OStoreFile& PropertySetRegistry::getStoreFile() const
+{
+ return m_pImpl->m_aStoreFile;
+}
+
+//=========================================================================
+const OUString& PropertySetRegistry::getURL() const
+{
+ return m_pImpl->m_aURL;
+}
+
+//=========================================================================
+void PropertySetRegistry::add( PersistentPropertySet* pSet )
+{
+ OUString key( pSet->getKey() );
+
+ if ( key.getLength() )
+ {
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ PropertySetMap_Impl& rSets = m_pImpl->m_aPropSets;
+
+ PropertySetMap_Impl::const_iterator it = rSets.find( key );
+ rSets[ key ] = pSet;
+ }
+}
+
+//=========================================================================
+void PropertySetRegistry::remove( PersistentPropertySet* pSet )
+{
+ OUString key( pSet->getKey() );
+
+ if ( key.getLength() )
+ {
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ PropertySetMap_Impl& rSets = m_pImpl->m_aPropSets;
+
+ PropertySetMap_Impl::iterator it = rSets.find( key );
+ if ( it != rSets.end() )
+ {
+ // Found.
+ rSets.erase( it );
+ }
+ }
+}
+
+//=========================================================================
+void PropertySetRegistry::renamePropertySet( const OUString& rOldKey,
+ const OUString& rNewKey )
+{
+ OUString aOldKey( OUString::createFromAscii( PROPERTYSET_STREAM_PREFIX ) );
+ OUString aNewKey( aOldKey );
+ aOldKey += rOldKey;
+ aNewKey += rNewKey;
+
+ storeError nError = m_pImpl->m_aStoreFile.rename(
+ OUString::createFromAscii( "/" ), aOldKey,
+ OUString::createFromAscii( "/" ), aNewKey );
+
+ VOS_ENSURE( ( nError == store_E_None ) || ( nError == store_E_NotExists ),
+ "PropertySetRegistry::renamePropertySet - error" );
+}
+
+//=========================================================================
+//
+// PropertyListeners_Impl.
+//
+//=========================================================================
+
+typedef OMultiTypeInterfaceContainerHelperVar
+<
+ OUString,
+ hashString_Impl,
+ equalString_Impl
+> PropertyListeners_Impl;
+
+//=========================================================================
+//
+// PropertyInfoList.
+//
+//=========================================================================
+
+struct PropertyInfo : public com::sun::star::beans::PropertyValue
+{
+ sal_Int32 Attributes;
+
+ PropertyInfo()
+ : Attributes( 0 ) {}
+
+ PropertyInfo( const rtl::OUString& Name,
+ sal_Int32 Handle,
+ const ::com::sun::star::uno::Any& Value,
+ const ::com::sun::star::beans::PropertyState& State,
+ sal_Int32 Attributes )
+ : PropertyValue( Name, Handle, Value, State ), Attributes( Attributes ) {}
+};
+
+//=========================================================================
+//
+// PropertyInfoList_Impl.
+//
+//=========================================================================
+
+typedef std::vector< PropertyInfo > PropertyInfos_Impl;
+
+class PropertyInfoList_Impl : public PropertyInfos_Impl {};
+
+//=========================================================================
+//
+// PersistentPropertySet_Impl.
+//
+//=========================================================================
+
+struct PersistentPropertySet_Impl
+{
+ PropertySetRegistry* m_pCreator;
+ PropertyInfoList_Impl* m_pValues;
+ PropertySetInfo_Impl* m_pInfo;
+ OUString m_aKey;
+ osl::Mutex m_aMutex;
+ store::OStoreStream m_aStream;
+ OInterfaceContainerHelper* m_pDisposeEventListeners;
+ OInterfaceContainerHelper* m_pPropSetChangeListeners;
+ PropertyListeners_Impl* m_pPropertyChangeListeners;
+
+ PersistentPropertySet_Impl( PropertySetRegistry& rCreator,
+ const OUString& rKey,
+ const store::OStoreStream& rStream,
+ PropertyInfoList_Impl* pValues )
+ : m_pCreator( &rCreator ), m_pValues( pValues ),
+ m_pInfo( NULL ), m_aKey( rKey ), m_aStream( rStream ),
+ m_pDisposeEventListeners( NULL ), m_pPropSetChangeListeners( NULL ),
+ m_pPropertyChangeListeners( NULL )
+ {
+ m_pCreator->acquire();
+ }
+
+ ~PersistentPropertySet_Impl()
+ {
+ m_pCreator->release();
+
+ if ( m_pInfo )
+ m_pInfo->release();
+
+ delete m_pValues;
+ delete m_pDisposeEventListeners;
+ delete m_pPropSetChangeListeners;
+ delete m_pPropertyChangeListeners;
+ }
+};
+
+//=========================================================================
+//=========================================================================
+//=========================================================================
+//
+// PersistentPropertySet Implementation.
+//
+//=========================================================================
+//=========================================================================
+//=========================================================================
+
+PersistentPropertySet::PersistentPropertySet(
+ const Reference< XMultiServiceFactory >& rXSMgr,
+ PropertySetRegistry& rCreator,
+ const OUString& rKey,
+ const store::OStoreStream& rStream )
+: m_xSMgr( rXSMgr ),
+ m_pImpl( new PersistentPropertySet_Impl( rCreator, rKey, rStream, NULL ) )
+{
+ // register at creator.
+ rCreator.add( this );
+}
+
+//=========================================================================
+PersistentPropertySet::PersistentPropertySet(
+ const Reference< XMultiServiceFactory >& rXSMgr,
+ PropertySetRegistry& rCreator,
+ const OUString& rKey,
+ const store::OStoreStream& rStream,
+ const PropertyInfoList_Impl& rValues )
+: m_xSMgr( rXSMgr ),
+ m_pImpl( new PersistentPropertySet_Impl(
+ rCreator,
+ rKey,
+ rStream,
+ new PropertyInfoList_Impl( rValues ) ) )
+{
+ // Store properties.
+ store();
+
+ // register at creator.
+ rCreator.add( this );
+}
+
+//=========================================================================
+// virtual
+PersistentPropertySet::~PersistentPropertySet()
+{
+ // deregister at creator.
+ m_pImpl->m_pCreator->remove( this );
+
+ delete m_pImpl;
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_9( PersistentPropertySet,
+ XTypeProvider,
+ XServiceInfo,
+ XComponent,
+ XPropertySet, /* base of XPersistentPropertySet */
+ XNamed,
+ XPersistentPropertySet,
+ XPropertyContainer,
+ XPropertySetInfoChangeNotifier,
+ XPropertyAccess );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_8( PersistentPropertySet,
+ XTypeProvider,
+ XServiceInfo,
+ XComponent,
+ XPersistentPropertySet,
+ XNamed,
+ XPropertyContainer,
+ XPropertySetInfoChangeNotifier,
+ XPropertyAccess );
+
+//=========================================================================
+//
+// XServiceInfo methods.
+//
+//=========================================================================
+
+XSERVICEINFO_NOFACTORY_IMPL_1( PersistentPropertySet,
+ OUString::createFromAscii(
+ "PersistentPropertySet" ),
+ OUString::createFromAscii(
+ PERS_PROPSET_SERVICE_NAME ) );
+
+//=========================================================================
+//
+// XComponent methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL PersistentPropertySet::dispose()
+ throw( RuntimeException )
+{
+ if ( m_pImpl->m_pDisposeEventListeners &&
+ m_pImpl->m_pDisposeEventListeners->getLength() )
+ {
+ EventObject aEvt;
+ aEvt.Source = static_cast< XComponent * >( this );
+ m_pImpl->m_pDisposeEventListeners->disposeAndClear( aEvt );
+ }
+
+ if ( m_pImpl->m_pPropSetChangeListeners &&
+ m_pImpl->m_pPropSetChangeListeners->getLength() )
+ {
+ EventObject aEvt;
+ aEvt.Source = static_cast< XPropertySetInfoChangeNotifier * >( this );
+ m_pImpl->m_pPropSetChangeListeners->disposeAndClear( aEvt );
+ }
+
+ if ( m_pImpl->m_pPropertyChangeListeners )
+ {
+ EventObject aEvt;
+ aEvt.Source = static_cast< XPropertySet * >( this );
+ m_pImpl->m_pPropertyChangeListeners->disposeAndClear( aEvt );
+ }
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PersistentPropertySet::addEventListener(
+ const Reference< XEventListener >& Listener )
+ throw( RuntimeException )
+{
+ if ( !m_pImpl->m_pDisposeEventListeners )
+ m_pImpl->m_pDisposeEventListeners =
+ new OInterfaceContainerHelper( m_pImpl->m_aMutex );
+
+ m_pImpl->m_pDisposeEventListeners->addInterface( Listener );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PersistentPropertySet::removeEventListener(
+ const Reference< XEventListener >& Listener )
+ throw( RuntimeException )
+{
+ if ( m_pImpl->m_pDisposeEventListeners )
+ m_pImpl->m_pDisposeEventListeners->removeInterface( Listener );
+
+ // Note: Don't want to delete empty container here -> performance.
+}
+
+//=========================================================================
+//
+// XPropertySet methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XPropertySetInfo > SAL_CALL
+ PersistentPropertySet::getPropertySetInfo()
+ throw( RuntimeException )
+{
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ PropertySetInfo_Impl*& rpInfo = m_pImpl->m_pInfo;
+ if ( !rpInfo )
+ {
+ rpInfo = new PropertySetInfo_Impl( m_xSMgr, this );
+ rpInfo->acquire();
+ }
+ return Reference< XPropertySetInfo >( rpInfo );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PersistentPropertySet::setPropertyValue(
+ const OUString& aPropertyName, const Any& aValue )
+ throw( UnknownPropertyException,
+ PropertyVetoException,
+ IllegalArgumentException,
+ WrappedTargetException,
+ RuntimeException )
+{
+ if ( !aPropertyName.getLength() )
+ throw UnknownPropertyException();
+
+ m_pImpl->m_aMutex.acquire();
+
+ load();
+
+ PropertyInfoList_Impl& rSeq = *m_pImpl->m_pValues;
+ sal_uInt32 nCount = rSeq.size();
+
+ if ( nCount )
+ {
+ for ( sal_uInt32 n = 0; n < nCount; ++n )
+ {
+ PropertyInfo& rValue = rSeq[ n ];
+
+ if ( rValue.Name == aPropertyName )
+ {
+ // Check type.
+ if ( rValue.Value.getValueType() != aValue.getValueType() )
+ {
+ m_pImpl->m_aMutex.release();
+ throw IllegalArgumentException();
+ }
+
+ // Success.
+
+ rValue.Value = aValue;
+ rValue.State = PropertyState_DIRECT_VALUE;
+
+ PropertyChangeEvent aEvt;
+ if ( m_pImpl->m_pPropertyChangeListeners )
+ {
+ aEvt.Source = (OWeakObject*)this;
+ aEvt.PropertyName = rValue.Name;
+ aEvt.PropertyHandle = rValue.Handle;
+ aEvt.Further = sal_False;
+ aEvt.OldValue = rValue.Value;
+ aEvt.NewValue = aValue;
+ }
+
+ // Callback follows!
+ m_pImpl->m_aMutex.release();
+
+ if ( m_pImpl->m_pPropertyChangeListeners )
+ notifyPropertyChangeEvent( aEvt );
+
+ store();
+ return;
+ }
+ }
+ }
+
+ m_pImpl->m_aMutex.release();
+ throw UnknownPropertyException();
+}
+
+//=========================================================================
+// virtual
+Any SAL_CALL PersistentPropertySet::getPropertyValue(
+ const OUString& PropertyName )
+ throw( UnknownPropertyException,
+ WrappedTargetException,
+ RuntimeException )
+{
+ if ( !PropertyName.getLength() )
+ throw UnknownPropertyException();
+
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ load();
+
+ const PropertyInfoList_Impl& rSeq = *m_pImpl->m_pValues;
+ sal_uInt32 nCount = rSeq.size();
+
+ if ( nCount )
+ {
+ for ( sal_uInt32 n = 0; n < nCount; ++n )
+ {
+ const PropertyInfo& rValue = rSeq[ n ];
+
+ if ( rValue.Name == PropertyName )
+ {
+ // Found.
+ return rValue.Value;
+ }
+ }
+ }
+
+ throw UnknownPropertyException();
+
+ // Make MSC4 happy ;-)
+ return Any();
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PersistentPropertySet::addPropertyChangeListener(
+ const OUString& aPropertyName,
+ const Reference< XPropertyChangeListener >& xListener )
+ throw( UnknownPropertyException,
+ WrappedTargetException,
+ RuntimeException )
+{
+// load();
+
+ if ( !m_pImpl->m_pPropertyChangeListeners )
+ m_pImpl->m_pPropertyChangeListeners =
+ new PropertyListeners_Impl( m_pImpl->m_aMutex );
+
+ m_pImpl->m_pPropertyChangeListeners->addInterface(
+ aPropertyName, xListener );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PersistentPropertySet::removePropertyChangeListener(
+ const OUString& aPropertyName,
+ const Reference< XPropertyChangeListener >& aListener )
+ throw( UnknownPropertyException,
+ WrappedTargetException,
+ RuntimeException )
+{
+// load();
+
+ if ( m_pImpl->m_pPropertyChangeListeners )
+ m_pImpl->m_pPropertyChangeListeners->removeInterface(
+ aPropertyName, aListener );
+
+ // Note: Don't want to delete empty container here -> performance.
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PersistentPropertySet::addVetoableChangeListener(
+ const OUString& PropertyName,
+ const Reference< XVetoableChangeListener >& aListener )
+ throw( UnknownPropertyException,
+ WrappedTargetException,
+ RuntimeException )
+{
+// load();
+// VOS_ENSURE( sal_False,
+// "PersistentPropertySet::addVetoableChangeListener - N.Y.I." );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PersistentPropertySet::removeVetoableChangeListener(
+ const OUString& PropertyName,
+ const Reference< XVetoableChangeListener >& aListener )
+ throw( UnknownPropertyException,
+ WrappedTargetException,
+ RuntimeException )
+{
+// load();
+// VOS_ENSURE( sal_False,
+// "PersistentPropertySet::removeVetoableChangeListener - N.Y.I." );
+}
+
+//=========================================================================
+//
+// XPersistentPropertySet methods.
+//
+//=========================================================================
+
+// virtual
+Reference< XPropertySetRegistry > SAL_CALL PersistentPropertySet::getRegistry()
+ throw( RuntimeException )
+{
+ return Reference< XPropertySetRegistry >( m_pImpl->m_pCreator );
+}
+
+//=========================================================================
+// virtual
+OUString SAL_CALL PersistentPropertySet::getKey()
+ throw( RuntimeException )
+{
+ return m_pImpl->m_aKey;
+}
+
+//=========================================================================
+//
+// XNamed methods.
+//
+//=========================================================================
+
+// virtual
+rtl::OUString SAL_CALL PersistentPropertySet::getName()
+ throw( RuntimeException )
+{
+ // same as getKey()
+ return m_pImpl->m_aKey;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PersistentPropertySet::setName( const OUString& aName )
+ throw( RuntimeException )
+{
+ if ( aName != m_pImpl->m_aKey )
+ m_pImpl->m_pCreator->renamePropertySet( m_pImpl->m_aKey, aName );
+}
+
+//=========================================================================
+//
+// XPropertyContainer methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL PersistentPropertySet::addProperty(
+ const OUString& Name, sal_Int16 Attributes, const Any& DefaultValue )
+ throw( PropertyExistException,
+ IllegalTypeException,
+ IllegalArgumentException,
+ RuntimeException )
+{
+ if ( !Name.getLength() )
+ throw IllegalArgumentException();
+
+ // Check type class ( Not all types can be written to storage )
+ TypeClass eTypeClass = DefaultValue.getValueTypeClass();
+ if ( eTypeClass == TypeClass_INTERFACE )
+ throw IllegalTypeException();
+
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ load();
+
+ PropertyInfoList_Impl& rSeq = *m_pImpl->m_pValues;
+ sal_uInt32 nCount = rSeq.size();
+
+ if ( nCount )
+ {
+ for ( sal_uInt32 n = 0; n < nCount; ++n )
+ {
+ PropertyInfo& rValue = rSeq[ n ];
+
+ if ( rValue.Name == Name )
+ {
+ // Already in set.
+ throw PropertyExistException();
+ }
+ }
+ }
+
+ // Property is always removeable.
+ Attributes |= PropertyAttribute::REMOVEABLE;
+
+ // Add property.
+ rSeq.push_back( PropertyInfo( Name,
+ -1,
+ DefaultValue,
+ PropertyState_DEFAULT_VALUE,
+ Attributes ) );
+ store();
+
+ // Property set info is invalid.
+ if ( m_pImpl->m_pInfo )
+ m_pImpl->m_pInfo->reset();
+
+ // Notify propertyset info change listeners.
+ if ( m_pImpl->m_pPropSetChangeListeners &&
+ m_pImpl->m_pPropSetChangeListeners->getLength() )
+ {
+ PropertySetInfoChangeEvent evt(
+ static_cast< OWeakObject * >( this ),
+ Name,
+ -1,
+ PropertySetInfoChange::PROPERTY_INSERTED );
+ notifyPropertySetInfoChange( evt );
+ }
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PersistentPropertySet::removeProperty( const OUString& Name )
+ throw( UnknownPropertyException,
+ NotRemoveableException,
+ RuntimeException )
+{
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ load();
+
+ PropertyInfoList_Impl& rSeq = *m_pImpl->m_pValues;
+ sal_uInt32 nCount = rSeq.size();
+
+ if ( !nCount )
+ throw UnknownPropertyException();
+
+ sal_Bool bFound = sal_False;
+
+ for ( sal_uInt32 n = 0; n < nCount; ++n )
+ {
+ PropertyInfo& rValue = rSeq[ n ];
+
+ if ( rValue.Name == Name )
+ {
+ // Found.
+
+ PropertyInfo aValue( rValue );
+
+ if ( !( rValue.Attributes & PropertyAttribute::REMOVEABLE ) )
+ {
+ // Not removeable!
+ throw NotRemoveableException();
+ }
+
+ // Remove property from sequence.
+
+ sal_uInt32 nNewCount = nCount - 1;
+
+ if ( n == nNewCount )
+ {
+ // Remove last element.
+ rSeq.pop_back();
+ }
+ else
+ {
+ PropertyInfoList_Impl* pNew = new PropertyInfoList_Impl;
+ PropertyInfoList_Impl& rNew = *pNew;
+
+ for ( sal_uInt32 k = 0, l = 0; k < nNewCount; ++k, ++l )
+ {
+ if ( k == n )
+ l++;
+
+ rNew.push_back( rSeq[ l ] );
+ }
+
+ delete m_pImpl->m_pValues;
+ m_pImpl->m_pValues = pNew;
+ }
+
+ store();
+
+ // Property set info is invalid.
+ if ( m_pImpl->m_pInfo )
+ m_pImpl->m_pInfo->reset();
+
+ // Notify propertyset info change listeners.
+ if ( m_pImpl->m_pPropSetChangeListeners &&
+ m_pImpl->m_pPropSetChangeListeners->getLength() )
+ {
+ PropertySetInfoChangeEvent evt(
+ static_cast< OWeakObject * >( this ),
+ aValue.Name,
+ aValue.Handle,
+ PropertySetInfoChange::PROPERTY_REMOVED );
+ notifyPropertySetInfoChange( evt );
+ }
+
+ return;
+ }
+ }
+
+ throw UnknownPropertyException();
+}
+
+//=========================================================================
+//
+// XPropertySetInfoChangeNotifier methods.
+//
+//=========================================================================
+
+// virtual
+void SAL_CALL PersistentPropertySet::addPropertySetInfoChangeListener(
+ const Reference< XPropertySetInfoChangeListener >& Listener )
+ throw( RuntimeException )
+{
+ if ( !m_pImpl->m_pPropSetChangeListeners )
+ m_pImpl->m_pPropSetChangeListeners =
+ new OInterfaceContainerHelper( m_pImpl->m_aMutex );
+
+ m_pImpl->m_pPropSetChangeListeners->addInterface( Listener );
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PersistentPropertySet::removePropertySetInfoChangeListener(
+ const Reference< XPropertySetInfoChangeListener >& Listener )
+ throw( RuntimeException )
+{
+ if ( m_pImpl->m_pPropSetChangeListeners )
+ m_pImpl->m_pPropSetChangeListeners->removeInterface( Listener );
+}
+
+//=========================================================================
+//
+// XPropertyAccess methods.
+//
+//=========================================================================
+
+// virtual
+Sequence< PropertyValue > SAL_CALL PersistentPropertySet::getPropertyValues()
+ throw( RuntimeException )
+{
+ const PropertyInfoList_Impl aInfo( getProperties() );
+ sal_uInt32 nCount = aInfo.size();
+ Sequence< PropertyValue > aValues( nCount );
+
+ PropertyValue* pValues = aValues.getArray();
+
+ for ( sal_uInt32 n = 0; n < nCount; ++n )
+ pValues[ n ] = aInfo[ n ];
+
+ return aValues;
+}
+
+//=========================================================================
+// virtual
+void SAL_CALL PersistentPropertySet::setPropertyValues(
+ const Sequence< PropertyValue >& aProps )
+ throw( UnknownPropertyException,
+ PropertyVetoException,
+ IllegalArgumentException,
+ WrappedTargetException,
+ RuntimeException )
+{
+ // Note: Unknown properties are ignored - UnknownPropertyExecption's
+ // will not be thrown! The specification of this method is buggy
+ // in my opinion. Refer to definition of XMultiProertySet, where
+ // exceptions are specified well.
+
+ m_pImpl->m_aMutex.acquire();
+
+ load();
+
+ PropertyInfoList_Impl& rSeq = *m_pImpl->m_pValues;
+ sal_uInt32 nCount = rSeq.size();
+
+ if ( nCount )
+ {
+ const PropertyValue* pNewValues = aProps.getConstArray();
+ sal_uInt32 nNewCount = aProps.getLength();
+
+ typedef std::list< PropertyChangeEvent > Events;
+ Events aEvents;
+
+ // Iterate over new property value sequence.
+ for ( sal_uInt32 n = 0; n < nNewCount; ++n )
+ {
+ const PropertyValue& rNewValue = pNewValues[ n ];
+ const OUString& rName = rNewValue.Name;
+
+#ifdef _DEBUG
+ sal_Bool bFound = sal_False;
+#endif
+ // Iterate over property value sequence.
+ for ( sal_uInt32 k = 0; k < nCount; ++k )
+ {
+ PropertyInfo& rValue = rSeq[ k ];
+ if ( rValue.Name == rName )
+ {
+ // type check ?
+
+ VOS_ENSURE( rNewValue.State == PropertyState_DIRECT_VALUE,
+ "PersistentPropertySet::setPropertyValues - "
+ "Wrong property state!" );
+
+#ifdef _DEBUG
+ bFound = sal_True;
+#endif
+
+ if ( m_pImpl->m_pPropertyChangeListeners )
+ {
+ PropertyChangeEvent aEvt;
+ aEvt.Source = (OWeakObject*)this;
+ aEvt.PropertyName = rNewValue.Name;
+ aEvt.PropertyHandle = rNewValue.Handle;
+ aEvt.Further = sal_False;
+ aEvt.OldValue = rValue.Value;
+ aEvt.NewValue = rNewValue.Value;
+
+ aEvents.push_back( aEvt );
+ }
+
+ rValue.Name = rNewValue.Name;
+ rValue.Handle = rNewValue.Handle;
+ rValue.Value = rNewValue.Value;
+ rValue.State = PropertyState_DIRECT_VALUE;
+// rValue.Attributes = <unchanged>
+
+ // Process next property to set.
+ break;
+ }
+ }
+
+ VOS_ENSURE( bFound,
+ "PersistentPropertySet::setPropertyValues - "
+ "Unknown property!" );
+ }
+
+ // Callback follows!
+ m_pImpl->m_aMutex.release();
+
+ if ( m_pImpl->m_pPropertyChangeListeners )
+ {
+ // Notify property changes.
+ Events::const_iterator it = aEvents.begin();
+ Events::const_iterator end = aEvents.end();
+
+ while ( it != end )
+ {
+ notifyPropertyChangeEvent( (*it) );
+ it++;
+ }
+ }
+
+ store();
+ return;
+ }
+
+ m_pImpl->m_aMutex.release();
+
+ VOS_ENSURE( sal_False,
+ "PersistentPropertySet::setPropertyValues - Nothing set!" );
+}
+
+//=========================================================================
+//
+// Non-interface methods
+//
+//=========================================================================
+
+// static
+PersistentPropertySet* PersistentPropertySet::create(
+ const Reference< XMultiServiceFactory >& rXSMgr,
+ PropertySetRegistry& rCreator,
+ const OUString& rKey,
+ sal_Bool bCreate )
+{
+ if ( !rKey.getLength() )
+ return NULL;
+
+ osl::Guard< osl::Mutex > aGuard( rCreator.getRegistryMutex() );
+
+ storeAccessMode eMode =
+ bCreate ? store_AccessReadCreate : store_AccessReadWrite;
+
+ store::OStoreFile& rStore = rCreator.getStoreFile();
+ OUString aStreamName( OUString::createFromAscii(
+ PROPERTYSET_STREAM_PREFIX ) );
+ aStreamName += rKey;
+
+ store::OStoreStream aStream;
+ storeError nError = aStream.create( rStore,
+ OUString::createFromAscii( "/" ),
+ aStreamName,
+ eMode );
+
+ VOS_ENSURE( ( nError == store_E_None )
+ || ( ( nError == store_E_NotExists )
+ && ( eMode == store_AccessReadWrite ) ),
+ "PersistentPropertySet::create - Error!" );
+
+#if 0
+
+ sal_Bool bLookForCHAOSViewProps = sal_False;
+
+ const OUString& rURL = rCreator.getURL();
+ if ( rURL.getLength() > 3 )
+ {
+ // Note: All View Storages ever written by CHAOS have the
+ // filename extension 'scc'.
+
+ const OUString aExtension( rURL.copy( rURL.getLength() - 4 ) );
+ if ( aExtension.equalsIgnoreCase(
+ OUString::createFromAscii( ".scc" ) ) )
+ {
+ if ( ( nError == store_E_NotExists ) &&
+ ( eMode == store_AccessReadWrite ) )
+ {
+ // Stream does not exist. But look for CHAOS view props.
+ bLookForCHAOSViewProps = sal_True;
+ }
+ else if ( ( nError == store_E_None ) &&
+ ( eMode == store_AccessReadCreate ) )
+ {
+ sal_uInt32 nSize = 0;
+ aStream.getSize( nSize );
+ if ( nSize == 0 )
+ {
+ // Stream was just created. Look for CHAOS view props.
+ bLookForCHAOSViewProps = sal_True;
+ }
+ }
+ }
+ }
+
+ if ( bLookForCHAOSViewProps )
+ {
+ //////////////////////////////////////////////////////////////
+ // Compatibility:
+ // Convert View-Properties from CHAOS-View-Storages.
+ //////////////////////////////////////////////////////////////
+
+ PropertyInfoList_Impl aSeq(
+ CntPersistentPropertySet::query( rURL, rKey ) );
+
+ if ( nError == store_E_NotExists )
+ nError = aStream.create( rStore,
+ OUString::createFromAscii( "/" ),
+ aStreamName,
+ store_AccessReadCreate );
+
+ if ( nError == store_E_None )
+ {
+ // Note: Pass the sequence to propset, even if it is empty!
+ return new PersistentPropertySet( rXSMgr,
+ rCreator,
+ rKey,
+ aStream,
+ aSeq );
+ }
+ }
+#endif
+
+ if ( nError == store_E_None )
+ return new PersistentPropertySet( rXSMgr,
+ rCreator,
+ rKey,
+ aStream );
+ return NULL;
+}
+
+//=========================================================================
+const PropertyInfoList_Impl& PersistentPropertySet::getProperties()
+{
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ load();
+ return *m_pImpl->m_pValues;
+}
+
+//=========================================================================
+sal_Bool PersistentPropertySet::load()
+{
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ if ( m_pImpl->m_pValues )
+ return sal_True;
+
+ osl::Guard< osl::Mutex > aRegistryGuard(
+ m_pImpl->m_pCreator->getRegistryMutex() );
+
+ //////////////////////////////////////////////////////////////////////
+ // Read header.
+ //////////////////////////////////////////////////////////////////////
+
+ PropertySetStreamHeader_Impl aHeader;
+
+ sal_uInt32 nBytesRead = 0;
+ storeError nError = m_pImpl->m_aStream.readAt(
+ 0,
+ &aHeader,
+ PROPERTYSET_STREAM_HEADER_SIZE,
+ nBytesRead );
+
+ if ( ( nError == store_E_None ) && ( nBytesRead == 0 ) )
+ {
+ // Not exists.
+ m_pImpl->m_pValues = new PropertyInfoList_Impl;
+ return sal_True;
+ }
+
+ if ( ( nError == store_E_None ) &&
+ ( nBytesRead == PROPERTYSET_STREAM_HEADER_SIZE ) )
+ {
+ //////////////////////////////////////////////////////////////////
+ // Check header.
+ //////////////////////////////////////////////////////////////////
+
+ if ( ( aHeader.m_nMagic == PROPERTYSET_STREAM_MAGIC ) &&
+ ( aHeader.m_nVersion == PROPERTYSET_STREAM_VERSION ) )
+ {
+ if ( !aHeader.m_nDataLen )
+ {
+ // Empty.
+ m_pImpl->m_pValues = new PropertyInfoList_Impl;
+ return sal_True;
+ }
+
+ //////////////////////////////////////////////////////////////
+ // Read data.
+ //////////////////////////////////////////////////////////////
+
+ PropertySetStreamBuffer_Impl aBuffer( aHeader.m_nDataLen );
+
+ nBytesRead = 0;
+ nError = m_pImpl->m_aStream.readAt(
+ PROPERTYSET_STREAM_HEADER_SIZE,
+ static_cast< sal_uInt8 * >( aBuffer ),
+ aHeader.m_nDataLen,
+ nBytesRead );
+
+ if ( ( nError == store_E_None ) &&
+ ( nBytesRead == aHeader.m_nDataLen ) )
+ {
+ sal_Bool bSuccess = sal_True;
+
+ PropertyInfoList_Impl* pSeq = new PropertyInfoList_Impl;
+
+ for ( sal_uInt32 n = 0; n < aHeader.m_nCount; ++n )
+ {
+ //////////////////////////////////////////////////////
+ // Read element.
+ //////////////////////////////////////////////////////
+
+ //////////////////////////////////////////////////////
+ // data format:
+ //
+ // sal_uInt32 nNameLen;
+ // sal_uInt8* Name;
+ // ----> OUString PropertyValue.Name
+ // sal_Int32 Handle;
+ // ----> sal_Int32 PropertyValue.Handle
+ // sal_Int32 Attributes;
+ // ----> sal_Int16 PropertyValue.Attributes
+ // sal_Int32 State;
+ // ----> PropertyState PropertyValue.State
+ // sal_uInt32 nValueLen;
+ // sal_uInt8* Value;
+ // ----> Any PropertyValue.Value
+ //////////////////////////////////////////////////////
+
+ PropertyInfo aValue;
+
+ bSuccess = aBuffer.readString( aValue.Name );
+ if ( !bSuccess )
+ break;
+
+ bSuccess = aBuffer.readInt32( aValue.Handle );
+ if ( !bSuccess )
+ break;
+
+ sal_Int32 nAttributes;
+ bSuccess = aBuffer.readInt32( nAttributes );
+ if ( !bSuccess )
+ break;
+
+ aValue.Attributes = nAttributes; // sal_Int16 !
+
+ sal_Int32 nState;
+ bSuccess = aBuffer.readInt32( nState );
+ if ( !bSuccess )
+ break;
+
+ // enum !
+ aValue.State = static_cast< PropertyState >( nState );
+
+ bSuccess = aBuffer.readAny( aValue.Value );
+ if ( !bSuccess )
+ break;
+
+ pSeq->push_back( aValue );
+ }
+
+ if ( bSuccess )
+ {
+ // Success!
+ m_pImpl->m_pValues = pSeq;
+ return sal_True;
+ }
+ else
+ delete pSeq;
+ }
+ }
+ }
+
+ VOS_ENSURE( sal_False, "PersistentPropertySet::load - error!" );
+ m_pImpl->m_pValues = new PropertyInfoList_Impl;
+ return sal_False;
+}
+
+//=========================================================================
+sal_Bool PersistentPropertySet::store()
+{
+ osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
+
+ load();
+
+ osl::Guard< osl::Mutex > aRegistryGuard(
+ m_pImpl->m_pCreator->getRegistryMutex() );
+
+ sal_Bool bSuccess = sal_True;
+
+ //////////////////////////////////////////////////////////////////////
+ // Create and fill buffer.
+ //////////////////////////////////////////////////////////////////////
+
+ const PropertyInfoList_Impl& rSeq = *m_pImpl->m_pValues;
+ sal_uInt32 nElements = rSeq.size();
+
+ PropertySetStreamBuffer_Impl aBuffer( 65535 /* Bytes - initial size */ );
+
+ for ( sal_uInt32 n = 0; n < nElements; ++n )
+ {
+ const PropertyInfo& rValue = rSeq[ n ];
+
+ //////////////////////////////////////////////////////////////////
+ // Put element into buffer.
+ //////////////////////////////////////////////////////////////////
+ // data format: refer to PersistentPropertySet::load().
+ //////////////////////////////////////////////////////////////////
+
+ bSuccess = aBuffer.writeString( rValue.Name );
+ if ( !bSuccess )
+ break;
+
+ bSuccess = aBuffer.writeInt32( rValue.Handle );
+ if ( !bSuccess )
+ break;
+
+ bSuccess = aBuffer.writeInt32( rValue.Attributes );
+ if ( !bSuccess )
+ break;
+
+ bSuccess = aBuffer.writeInt32( rValue.State );
+ if ( !bSuccess )
+ break;
+
+ bSuccess = aBuffer.writeAny( rValue.Value );
+ if ( !bSuccess )
+ break;
+ }
+
+ if ( bSuccess )
+ {
+ sal_uInt32 nDataBytes = aBuffer.getDataLength();
+
+ //////////////////////////////////////////////////////////////////
+ // Write header.
+ //////////////////////////////////////////////////////////////////
+
+ PropertySetStreamHeader_Impl aHeader( PROPERTYSET_STREAM_MAGIC,
+ PROPERTYSET_STREAM_VERSION,
+ nDataBytes,
+ nElements );
+ sal_uInt32 nBytesWritten;
+ storeError nError = m_pImpl->m_aStream.writeAt(
+ 0,
+ &aHeader,
+ PROPERTYSET_STREAM_HEADER_SIZE,
+ nBytesWritten );
+
+ if ( ( nError == store_E_None ) &&
+ ( nBytesWritten == PROPERTYSET_STREAM_HEADER_SIZE ) )
+ {
+ if ( !nDataBytes )
+ {
+ // Empty.
+ return sal_True;
+ }
+
+ //////////////////////////////////////////////////////////////
+ // Write data.
+ //////////////////////////////////////////////////////////////
+
+ nError = m_pImpl->m_aStream.writeAt(
+ PROPERTYSET_STREAM_HEADER_SIZE,
+ static_cast< sal_uInt8 * >( aBuffer ),
+ nDataBytes,
+ nBytesWritten );
+
+ if ( ( nError == store_E_None ) && ( nBytesWritten == nDataBytes ) )
+ return sal_True;
+ }
+ }
+
+ VOS_ENSURE( sal_False, "PersistentPropertySet::store - error!" );
+ return sal_False;
+}
+
+//=========================================================================
+void PersistentPropertySet::notifyPropertyChangeEvent(
+ const PropertyChangeEvent& rEvent ) const
+{
+ // Get "normal" listeners for the property.
+ OInterfaceContainerHelper* pContainer =
+ m_pImpl->m_pPropertyChangeListeners->getContainer(
+ rEvent.PropertyName );
+ if ( pContainer && pContainer->getLength() )
+ {
+ OInterfaceIteratorHelper aIter( *pContainer );
+ while ( aIter.hasMoreElements() )
+ {
+ // Propagate event.
+ Reference< XPropertyChangeListener > xListener(
+ aIter.next(), UNO_QUERY );
+ if ( xListener.is() )
+ xListener->propertyChange( rEvent );
+ }
+ }
+
+ // Get "normal" listeners for all properties.
+ OInterfaceContainerHelper* pNoNameContainer =
+ m_pImpl->m_pPropertyChangeListeners->getContainer( OUString() );
+ if ( pNoNameContainer && pNoNameContainer->getLength() )
+ {
+ OInterfaceIteratorHelper aIter( *pNoNameContainer );
+ while ( aIter.hasMoreElements() )
+ {
+ // Propagate event.
+ Reference< XPropertyChangeListener > xListener(
+ aIter.next(), UNO_QUERY );
+ if ( xListener.is() )
+ xListener->propertyChange( rEvent );
+ }
+ }
+}
+
+//=========================================================================
+void PersistentPropertySet::notifyPropertySetInfoChange(
+ const PropertySetInfoChangeEvent& evt ) const
+{
+ if ( !m_pImpl->m_pPropSetChangeListeners )
+ return;
+
+ // Notify event listeners.
+ OInterfaceIteratorHelper aIter( *( m_pImpl->m_pPropSetChangeListeners ) );
+ while ( aIter.hasMoreElements() )
+ {
+ // Propagate event.
+ Reference< XPropertySetInfoChangeListener >
+ xListener( aIter.next(), UNO_QUERY );
+ if ( xListener.is() )
+ xListener->propertySetInfoChange( evt );
+ }
+}
+
+//=========================================================================
+//=========================================================================
+//
+// PropertySetStreamBuffer_Impl Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+PropertySetStreamBuffer_Impl::PropertySetStreamBuffer_Impl(
+ sal_uInt32 nInitSize, sal_uInt32 nGrowSize )
+: m_nSize( nInitSize ),
+ m_nGrow( nGrowSize )
+{
+ m_pBuffer = static_cast< sal_uInt8 * >( rtl_allocateMemory( m_nSize ) );
+ m_pPos = m_pBuffer;
+}
+
+//=========================================================================
+PropertySetStreamBuffer_Impl::~PropertySetStreamBuffer_Impl()
+{
+ rtl_freeMemory( m_pBuffer );
+}
+
+//=========================================================================
+sal_Bool PropertySetStreamBuffer_Impl::readString( OUString& rValue )
+{
+ // Read sal_Int32 -> data length.
+ sal_Int32 nLen = 0;
+ readInt32( nLen );
+
+ // Read data bytes -> UTF8 encoded string as byte array.
+ ensureCapacity( nLen );
+ rValue = OUString( reinterpret_cast< const sal_Char * >( m_pPos ),
+ nLen,
+ RTL_TEXTENCODING_UTF8 );
+ m_pPos += nLen;
+
+ // Align buffer position.
+ sal_uInt32 nAlignment = ALIGN_POS( nLen );
+ ensureCapacity( nAlignment );
+ m_pPos += nAlignment;
+
+ return sal_True;
+}
+
+//=========================================================================
+sal_Bool PropertySetStreamBuffer_Impl::readInt32( sal_Int32& rValue )
+{
+ // Read sal_Int32.
+ ensureCapacity( sizeof( sal_Int32 ) );
+ rtl_copyMemory( &rValue, m_pPos, sizeof( sal_Int32 ) );
+ m_pPos += sizeof( sal_Int32 );
+
+#ifdef OSL_BIGENDIAN
+ rValue = VOS_SWAPDWORD( rValue );
+#endif
+
+ return sal_True;
+}
+
+//=========================================================================
+sal_Bool PropertySetStreamBuffer_Impl::readAny( Any& rValue )
+{
+ // Read sal_Int32 -> data length.
+ sal_Int32 nLen = 0;
+ readInt32( nLen );
+
+ if ( nLen )
+ {
+ // Read data bytes -> Any as byte array.
+ ensureCapacity( nLen );
+
+ Sequence< sal_Int8 > aSeq( nLen );
+ sal_Int8* pData = aSeq.getArray();
+ for ( sal_uInt32 n = 0; n < nLen; ++n )
+ {
+ pData[ n ] = *m_pPos;
+ m_pPos++;
+ }
+
+ // Create Any from byte array.
+ rValue = anyDeserialize( aSeq );
+
+ // Align buffer position.
+ sal_uInt32 nAlignment = ALIGN_POS( nLen );
+ ensureCapacity( nAlignment );
+ m_pPos += nAlignment;
+ }
+
+ return sal_True;
+}
+
+//=========================================================================
+sal_Bool PropertySetStreamBuffer_Impl::writeString( const OUString& rValue )
+{
+ const OString aValue(
+ rValue.getStr(), rValue.getLength(), RTL_TEXTENCODING_UTF8 );
+ sal_uInt32 nLen = aValue.getLength();
+
+ // Write sal_uInt32 -> data length.
+ writeInt32( nLen );
+
+ // Write data bytes -> UTF8 encoded string as byte array.
+ ensureCapacity( nLen );
+ rtl_copyMemory( m_pPos, aValue.getStr(), nLen );
+ m_pPos += aValue.getLength();
+
+ // Align buffer position.
+ sal_uInt32 nAlignment = ALIGN_POS( nLen );
+ ensureCapacity( nAlignment );
+ m_pPos += nAlignment;
+
+ return sal_True;
+}
+
+//=========================================================================
+sal_Bool PropertySetStreamBuffer_Impl::writeInt32( sal_Int32 nValue )
+{
+ // Write sal_Int32.
+
+#ifdef OSL_BIGENDIAN
+ nValue = VOS_SWAPDWORD( nValue );
+#endif
+
+ ensureCapacity( sizeof( sal_Int32 ) );
+ rtl_copyMemory( m_pPos, &nValue, sizeof( sal_Int32 ) );
+ m_pPos += sizeof( sal_Int32 );
+
+ return sal_True;
+}
+
+//=========================================================================
+sal_Bool PropertySetStreamBuffer_Impl::writeAny( const Any& rValue )
+{
+ // Convert Any to byte sequence.
+ Sequence< sal_Int8 > aSeq( anySerialize( rValue ) );
+
+ sal_uInt32 nLen = aSeq.getLength();
+
+ // Write sal_uInt32 -> data length.
+ writeInt32( nLen );
+
+ if ( nLen )
+ {
+ // Write data -> Any as byte array.
+ ensureCapacity( nLen );
+
+ const sal_Int8* pData = aSeq.getConstArray();
+ for ( sal_uInt32 n = 0; n < nLen; ++n )
+ {
+ *m_pPos = pData[ n ];
+ m_pPos++;
+ }
+
+ // Align buffer position.
+ sal_uInt32 nAlignment = ALIGN_POS( nLen );
+ ensureCapacity( nAlignment );
+ m_pPos += nAlignment;
+ }
+
+ return sal_True;
+}
+
+//=========================================================================
+void PropertySetStreamBuffer_Impl::ensureCapacity( sal_uInt8 nBytesNeeded )
+{
+ if ( ( m_pPos + nBytesNeeded ) > ( m_pBuffer + m_nSize ) )
+ {
+ sal_uInt32 nPosDelta = m_pPos - m_pBuffer;
+
+ m_pBuffer = static_cast< sal_uInt8 * >(
+ rtl_reallocateMemory( m_pBuffer,
+ m_nSize + m_nGrow ) );
+ m_pPos = m_pBuffer + nPosDelta;
+ m_nSize += m_nGrow;
+ }
+}
+
+//=========================================================================
+//=========================================================================
+//
+// PropertySetInfo_Impl Implementation.
+//
+//=========================================================================
+//=========================================================================
+
+PropertySetInfo_Impl::PropertySetInfo_Impl(
+ const Reference< XMultiServiceFactory >& rxSMgr,
+ PersistentPropertySet* pOwner )
+: m_xSMgr( rxSMgr ),
+ m_pProps( NULL ),
+ m_pOwner( pOwner )
+{
+}
+
+//=========================================================================
+// virtual
+PropertySetInfo_Impl::~PropertySetInfo_Impl()
+{
+ delete m_pProps;
+
+ // !!! Do not delete m_pOwner !!!
+}
+
+//=========================================================================
+//
+// XInterface methods.
+//
+//=========================================================================
+
+XINTERFACE_IMPL_2( PropertySetInfo_Impl,
+ XTypeProvider,
+ XPropertySetInfo );
+
+//=========================================================================
+//
+// XTypeProvider methods.
+//
+//=========================================================================
+
+XTYPEPROVIDER_IMPL_2( PropertySetInfo_Impl,
+ XTypeProvider,
+ XPropertySetInfo );
+
+//=========================================================================
+//
+// XPropertySetInfo methods.
+//
+//=========================================================================
+
+// virtual
+Sequence< Property > SAL_CALL PropertySetInfo_Impl::getProperties()
+ throw( RuntimeException )
+{
+ if ( !m_pProps )
+ {
+ const PropertyInfoList_Impl& rSeq = m_pOwner->getProperties();
+ sal_uInt32 nCount = rSeq.size();
+
+ Sequence< Property >* pPropSeq = new Sequence< Property >( nCount );
+
+ if ( nCount )
+ {
+ Property* pProps = pPropSeq->getArray();
+ for ( sal_uInt32 n = 0; n < nCount; ++n )
+ {
+ const PropertyInfo& rValue = rSeq[ n ];
+ Property& rProp = pProps[ n ];
+
+ rProp.Name = rValue.Name;
+ rProp.Handle = rValue.Handle;
+ rProp.Type = rValue.Value.getValueType();
+ rProp.Attributes = rValue.Attributes;
+ }
+ }
+
+ m_pProps = pPropSeq;
+ }
+
+ return *m_pProps;
+}
+
+//=========================================================================
+// virtual
+Property SAL_CALL PropertySetInfo_Impl::getPropertyByName(
+ const OUString& aName )
+ throw( UnknownPropertyException, RuntimeException )
+{
+ Property aProp;
+ if ( queryProperty( aName, aProp ) )
+ return aProp;
+
+ throw UnknownPropertyException();
+}
+
+//=========================================================================
+// virtual
+sal_Bool SAL_CALL PropertySetInfo_Impl::hasPropertyByName(
+ const OUString& Name )
+ throw( RuntimeException )
+{
+ Property aProp;
+ return queryProperty( Name, aProp );
+}
+
+//=========================================================================
+sal_Bool PropertySetInfo_Impl::queryProperty(
+ const OUString& aName, Property& rProp )
+{
+ const PropertyInfoList_Impl& rSeq = m_pOwner->getProperties();
+ sal_uInt32 nCount = rSeq.size();
+ for ( sal_uInt32 n = 0; n < nCount; ++n )
+ {
+ const PropertyInfo& rValue = rSeq[ n ];
+ if ( rValue.Name == aName )
+ {
+ rProp.Name = rValue.Name;
+ rProp.Handle = rValue.Handle;
+ rProp.Type = rValue.Value.getValueType();
+ rProp.Attributes = rValue.Attributes;
+
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
diff --git a/ucb/source/core/ucbstore.hxx b/ucb/source/core/ucbstore.hxx
new file mode 100644
index 000000000000..5cf29a2583bd
--- /dev/null
+++ b/ucb/source/core/ucbstore.hxx
@@ -0,0 +1,427 @@
+/*************************************************************************
+ *
+ * $RCSfile: ucbstore.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:52:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _UCBSTORE_HXX
+#define _UCBSTORE_HXX
+
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
+#include <com/sun/star/container/XNamed.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XPROPERTYSETREGISTRYFACTORY_HPP_
+#include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XPROPERTYSETREGISTRY_HPP_
+#include <com/sun/star/ucb/XPropertySetRegistry.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XPERSISTENTPROPERTYSET_HPP_
+#include <com/sun/star/ucb/XPersistentPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HPP_
+#include <com/sun/star/beans/XPropertyContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFOCHANGENOTIFIER_HPP_
+#include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYACCESS_HPP_
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+#ifndef _UCBHELPER_MACROS_HXX
+#include <ucbhelper/macros.hxx>
+#endif
+
+namespace store
+{
+ class OStoreFile;
+ class OStoreStream;
+}
+
+//=========================================================================
+
+#define STORE_SERVICE_NAME "com.sun.star.ucb.Store"
+#define PROPSET_REG_SERVICE_NAME "com.sun.star.ucb.PropertySetRegistry"
+#define PERS_PROPSET_SERVICE_NAME "com.sun.star.ucb.PersistentPropertySet"
+
+//=========================================================================
+
+struct UcbStore_Impl;
+
+class UcbStore :
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XTypeProvider,
+ public com::sun::star::lang::XServiceInfo,
+ public com::sun::star::ucb::XPropertySetRegistryFactory
+{
+ com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+ UcbStore_Impl* m_pImpl;
+
+public:
+ UcbStore(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
+ virtual ~UcbStore();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XServiceInfo
+ XSERVICEINFO_DECL()
+
+ // XPropertySetRegistryFactory
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XPropertySetRegistry > SAL_CALL
+ createPropertySetRegistry( const rtl::OUString& URL )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // New
+ void removeRegistry( const rtl::OUString& URL );
+};
+
+//=========================================================================
+
+struct PropertySetRegistry_Impl;
+
+class PropertySetRegistry :
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XTypeProvider,
+ public com::sun::star::lang::XServiceInfo,
+ public com::sun::star::ucb::XPropertySetRegistry,
+ public com::sun::star::container::XNameAccess
+{
+ friend class PersistentPropertySet;
+
+ com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+ PropertySetRegistry_Impl* m_pImpl;
+
+private:
+ void add ( PersistentPropertySet* pSet );
+ void remove( PersistentPropertySet* pSet );
+
+ void renamePropertySet( const rtl::OUString& rOldKey,
+ const rtl::OUString& rNewKey );
+protected:
+ PropertySetRegistry(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rXSMgr,
+ UcbStore& rCreator,
+ const rtl::OUString& rURL,
+ const store::OStoreFile& rStoreFile );
+
+public:
+ virtual ~PropertySetRegistry();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XServiceInfo
+ XSERVICEINFO_NOFACTORY_DECL()
+
+ // XPropertySetRegistry
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XPersistentPropertySet > SAL_CALL
+ openPropertySet( const rtl::OUString& key, sal_Bool create )
+ throw( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ removePropertySet( const rtl::OUString& key )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XElementAccess ( XNameAccess is derived from it )
+ virtual com::sun::star::uno::Type SAL_CALL
+ getElementType()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ hasElements()
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XNameAccess
+ virtual com::sun::star::uno::Any SAL_CALL
+ getByName( const rtl::OUString& aName )
+ throw( com::sun::star::container::NoSuchElementException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+ virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
+ getElementNames()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL
+ hasByName( const rtl::OUString& aName )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // Non-interface methods
+ static PropertySetRegistry* create(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rXSMgr,
+ UcbStore& rCreator,
+ const rtl::OUString& rURL );
+ osl::Mutex& getRegistryMutex() const;
+ store::OStoreFile& getStoreFile() const;
+ const rtl::OUString& getURL() const;
+};
+
+//=========================================================================
+
+struct PersistentPropertySet_Impl;
+class PropertyInfoList_Impl;
+
+class PersistentPropertySet :
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XTypeProvider,
+ public com::sun::star::lang::XServiceInfo,
+ public com::sun::star::lang::XComponent,
+ public com::sun::star::ucb::XPersistentPropertySet,
+ public com::sun::star::container::XNamed,
+ public com::sun::star::beans::XPropertyContainer,
+ public com::sun::star::beans::XPropertySetInfoChangeNotifier,
+ public com::sun::star::beans::XPropertyAccess
+{
+ com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+ PersistentPropertySet_Impl* m_pImpl;
+
+private:
+ sal_Bool load();
+ sal_Bool store();
+
+ void notifyPropertyChangeEvent(
+ const com::sun::star::beans::PropertyChangeEvent& rEvent ) const;
+ void notifyPropertySetInfoChange(
+ const com::sun::star::beans::PropertySetInfoChangeEvent& evt ) const;
+
+protected:
+ PersistentPropertySet(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rXSMgr,
+ PropertySetRegistry& rCreator,
+ const rtl::OUString& rKey,
+ const store::OStoreStream& rStream );
+ PersistentPropertySet(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rXSMgr,
+ PropertySetRegistry& rCreator,
+ const rtl::OUString& rKey,
+ const store::OStoreStream& rStream,
+ const PropertyInfoList_Impl& rValues );
+
+public:
+ virtual ~PersistentPropertySet();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XServiceInfo
+ XSERVICEINFO_NOFACTORY_DECL()
+
+ // XComponent
+ virtual void SAL_CALL
+ dispose()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ addEventListener( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XEventListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ removeEventListener( const com::sun::star::uno::Reference<
+ com::sun::star::lang::XEventListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XPropertySet
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ setPropertyValue( const rtl::OUString& aPropertyName,
+ const com::sun::star::uno::Any& aValue )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::beans::PropertyVetoException,
+ com::sun::star::lang::IllegalArgumentException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+ virtual com::sun::star::uno::Any SAL_CALL
+ getPropertyValue( const rtl::OUString& PropertyName )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ addPropertyChangeListener( const rtl::OUString& aPropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertyChangeListener >& xListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ removePropertyChangeListener( const rtl::OUString& aPropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertyChangeListener >& aListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ addVetoableChangeListener( const rtl::OUString& PropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ removeVetoableChangeListener( const rtl::OUString& PropertyName,
+ const com::sun::star::uno::Reference<
+ com::sun::star::beans::XVetoableChangeListener >& aListener )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+
+ // XPersistentPropertySet
+ virtual com::sun::star::uno::Reference<
+ com::sun::star::ucb::XPropertySetRegistry > SAL_CALL
+ getRegistry()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual rtl::OUString SAL_CALL
+ getKey()
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XNamed
+ virtual rtl::OUString SAL_CALL
+ getName()
+ throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ setName( const ::rtl::OUString& aName )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XPropertyContainer
+ virtual void SAL_CALL
+ addProperty( const rtl::OUString& Name,
+ sal_Int16 Attributes,
+ const com::sun::star::uno::Any& DefaultValue )
+ throw( com::sun::star::beans::PropertyExistException,
+ com::sun::star::beans::IllegalTypeException,
+ com::sun::star::lang::IllegalArgumentException,
+ com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ removeProperty( const rtl::OUString& Name )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::beans::NotRemoveableException,
+ com::sun::star::uno::RuntimeException );
+
+ // XPropertySetInfoChangeNotifier
+ virtual void SAL_CALL
+ addPropertySetInfoChangeListener( const com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertySetInfoChangeListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ removePropertySetInfoChangeListener( const com::sun::star::uno::Reference<
+ com::sun::star::beans::XPropertySetInfoChangeListener >& Listener )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XPropertyAccess
+ virtual com::sun::star::uno::Sequence<
+ com::sun::star::beans::PropertyValue > SAL_CALL
+ getPropertyValues()
+ throw( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL
+ setPropertyValues( const com::sun::star::uno::Sequence<
+ com::sun::star::beans::PropertyValue >& aProps )
+ throw( com::sun::star::beans::UnknownPropertyException,
+ com::sun::star::beans::PropertyVetoException,
+ com::sun::star::lang::IllegalArgumentException,
+ com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException );
+
+ // Non-interface methods
+ static PersistentPropertySet* create(
+ const com::sun::star::uno::Reference<
+ com::sun::star::lang::XMultiServiceFactory >& rXSMgr,
+ PropertySetRegistry& rCreator,
+ const rtl::OUString& rKey,
+ sal_Bool bCreate );
+ const PropertyInfoList_Impl& getProperties();
+};
+
+#endif /* !_UCBSTORE_HXX */
diff --git a/ucb/source/inc/regexp.hxx b/ucb/source/inc/regexp.hxx
new file mode 100644
index 000000000000..6b1b049bccd5
--- /dev/null
+++ b/ucb/source/inc/regexp.hxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * $RCSfile: regexp.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:53:07 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _UCB_REGEXP_HXX_
+#define _UCB_REGEXP_HXX_
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _VOS_DIAGNOSE_H_
+#include <vos/diagnose.hxx>
+#endif
+
+//============================================================================
+namespace ucb {
+
+class Regexp
+{
+public:
+ enum Kind
+ {
+ KIND_PREFIX,
+ KIND_AUTHORITY,
+ KIND_DOMAIN
+ };
+
+ inline bool operator ==(Regexp const & rOther) const;
+
+ inline bool isDefault() const
+ { return m_eKind == KIND_PREFIX && m_aPrefix.getLength() == 0; }
+
+ inline Kind getKind() const { return m_eKind; }
+
+ bool matches(rtl::OUString const & rString, rtl::OUString * pTranslation,
+ bool * pTranslated) const;
+
+ rtl::OUString getRegexp(bool bReverse) const;
+
+ static Regexp parse(rtl::OUString const & rRegexp);
+
+private:
+ Kind m_eKind;
+ rtl::OUString m_aPrefix;
+ rtl::OUString m_aInfix;
+ rtl::OUString m_aReversePrefix;
+ bool m_bEmptyDomain;
+ bool m_bTranslation;
+
+ inline Regexp(Kind eTheKind, rtl::OUString const & rThePrefix,
+ bool bTheEmptyDomain, rtl::OUString const & rTheInfix,
+ bool bTheTranslation,
+ rtl::OUString const & rTheReversePrefix);
+};
+
+inline bool Regexp::operator ==(Regexp const & rOther) const
+{
+ return m_eKind == rOther.m_eKind
+ && m_aPrefix == rOther.m_aPrefix
+ && m_aInfix == rOther.m_aInfix;
+}
+
+}
+
+#endif // _UCPRMT_RMTREGX_HXX_
+
diff --git a/ucb/source/inc/regexpmap.hxx b/ucb/source/inc/regexpmap.hxx
new file mode 100644
index 000000000000..e9af736f33de
--- /dev/null
+++ b/ucb/source/inc/regexpmap.hxx
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * $RCSfile: regexpmap.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:53:07 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _UCB_REGEXPMAP_HXX_
+#define _UCB_REGEXPMAP_HXX_
+
+#ifndef _RTL_OUSTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+
+namespace ucb {
+
+template< typename Val > class RegexpMap;
+template< typename Val > class RegexpMapIter;
+
+//============================================================================
+template< typename Val >
+class RegexpMapEntry
+{
+public:
+ inline RegexpMapEntry(rtl::OUString const & rTheRegexp,
+ Val * pTheValue):
+ m_aRegexp(rTheRegexp), m_pValue(pTheValue) {}
+
+ rtl::OUString getRegexp() const { return m_aRegexp; }
+
+ Val const & getValue() const { return *m_pValue; }
+
+ Val & getValue() { return *m_pValue; }
+
+private:
+ rtl::OUString m_aRegexp;
+ Val * m_pValue;
+};
+
+//============================================================================
+template< typename Val > class RegexpMapIterImpl;
+ // MSC doesn't like this to be a private RegexpMapConstIter member
+ // class...
+
+template< typename Val >
+class RegexpMapConstIter
+{
+ friend RegexpMap< Val >; // to access m_pImpl, ctor
+ friend RegexpMapIter< Val >; // to access m_pImpl, ctor
+
+public:
+ RegexpMapConstIter();
+
+ RegexpMapConstIter(RegexpMapConstIter const & rOther);
+
+ ~RegexpMapConstIter();
+
+ RegexpMapConstIter & operator =(RegexpMapConstIter const & rOther);
+
+ RegexpMapConstIter & operator ++();
+
+ RegexpMapConstIter operator ++(int);
+
+ RegexpMapEntry< Val > const & operator *() const;
+
+ RegexpMapEntry< Val > const * operator ->() const;
+
+ bool equals(RegexpMapConstIter const & rOther) const;
+ // for free operator ==(), operator !=()
+
+private:
+ RegexpMapIterImpl< Val > * m_pImpl;
+
+ RegexpMapConstIter(RegexpMapIterImpl< Val > * pTheImpl);
+};
+
+//============================================================================
+template< typename Val >
+class RegexpMapIter: public RegexpMapConstIter< Val >
+{
+ friend RegexpMap< Val >; // to access ctor
+
+public:
+ RegexpMapIter() {}
+
+ RegexpMapIter & operator ++();
+
+ RegexpMapIter operator ++(int);
+
+ RegexpMapEntry< Val > & operator *();
+
+ RegexpMapEntry< Val > const & operator *() const;
+
+ RegexpMapEntry< Val > * operator ->();
+
+ RegexpMapEntry< Val > const * operator ->() const;
+
+private:
+ RegexpMapIter(RegexpMapIterImpl< Val > * pTheImpl);
+};
+
+//============================================================================
+template< typename Val > struct RegexpMapImpl;
+ // MSC doesn't like this to be a RegexpMap member class...
+
+template< typename Val >
+class RegexpMap
+{
+public:
+ typedef sal_uInt32 size_type;
+ typedef RegexpMapIter< Val > iterator;
+ typedef RegexpMapConstIter< Val > const_iterator;
+
+ RegexpMap();
+
+ RegexpMap(RegexpMap const & rOther);
+
+ ~RegexpMap();
+
+ RegexpMap & operator =(RegexpMap const & rOther);
+
+ bool add(rtl::OUString const & rKey, Val const & rValue, bool bOverwrite,
+ rtl::OUString * pReverse = 0);
+ // throws com::sun::star::lang::IllegalArgumentException
+
+ iterator find(rtl::OUString const & rKey, rtl::OUString * pReverse = 0);
+ // throws com::sun::star::lang::IllegalArgumentException
+
+ void erase(iterator const & rPos);
+
+ iterator begin();
+
+ const_iterator begin() const;
+
+ iterator end();
+
+ const_iterator end() const;
+
+ bool empty() const;
+
+ size_type size() const;
+
+ Val const * map(rtl::OUString const & rString,
+ rtl::OUString * pTranslation = 0, bool * pTranslated = 0)
+ const;
+
+private:
+ RegexpMapImpl< Val > * m_pImpl;
+};
+
+}
+
+//============================================================================
+template< typename Val >
+inline bool operator ==(ucb::RegexpMapConstIter< Val > const & rIter1,
+ ucb::RegexpMapConstIter< Val > const & rIter2)
+{
+ return rIter1.equals(rIter2);
+}
+
+template< typename Val >
+inline bool operator !=(ucb::RegexpMapConstIter< Val > const & rIter1,
+ ucb::RegexpMapConstIter< Val > const & rIter2)
+{
+ return !rIter1.equals(rIter2);
+}
+
+#endif // _UCB_REGEXPMAP_HXX_
+
diff --git a/ucb/source/inc/regexpmap.tpt b/ucb/source/inc/regexpmap.tpt
new file mode 100644
index 000000000000..1b7b1564e284
--- /dev/null
+++ b/ucb/source/inc/regexpmap.tpt
@@ -0,0 +1,597 @@
+/*************************************************************************
+ *
+ * $RCSfile: regexpmap.tpt,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:53:07 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _UCB_REGEXPMAP_TPT_
+#define _UCB_REGEXPMAP_TPT_
+
+#ifndef _UCB_REGEXPMAP_HXX_
+#include <regexpmap.hxx>
+#endif
+
+#include <list>
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _UCB_REGEXP_HXX_
+#include "regexp.hxx"
+#endif
+
+namespace unnamed_ucb_regexpmap {} using namespace unnamed_ucb_regexpmap;
+ // unnamed namespaces don't work well yet...
+
+using namespace ucb;
+
+//============================================================================
+namespace unnamed_ucb_regexpmap {
+
+template< typename Val >
+struct Entry
+{
+ Regexp m_aRegexp;
+ Val m_aValue;
+
+ inline Entry(Regexp const & rTheRegexp, Val const & rTheValue):
+ m_aRegexp(rTheRegexp), m_aValue(rTheValue) {}
+};
+
+//============================================================================
+template< typename Val > class List: public std::list< Entry< Val > > {};
+
+}
+
+//============================================================================
+//
+// RegexpMapIterImpl
+//
+//============================================================================
+
+namespace ucb {
+
+template< typename Val >
+class RegexpMapIterImpl
+{
+public:
+ typedef RegexpMapImpl< Val > MapImpl;
+ typedef List< Val >::iterator ListIterator;
+ // Solaris needs these for the ctor...
+
+ inline RegexpMapIterImpl();
+
+ inline RegexpMapIterImpl(MapImpl * pTheMap, int nTheList,
+ ListIterator aTheIndex);
+
+ RegexpMapIterImpl(RegexpMapImpl< Val > * pTheMap, bool bBegin);
+
+ bool operator ==(RegexpMapIterImpl const & rOther) const;
+
+ RegexpMapImpl< Val > const * getMap() const { return m_pMap; }
+
+ int getList() const { return m_nList; }
+
+ List< Val >::iterator const & getIndex() const { return m_aIndex; }
+
+ void next();
+
+ RegexpMapEntry< Val > & get();
+
+private:
+ mutable RegexpMapEntry< Val > m_aEntry;
+ List< Val >::iterator m_aIndex;
+ RegexpMapImpl< Val > * m_pMap;
+ int m_nList;
+ mutable bool m_bEntrySet;
+
+ void setEntry() const;
+};
+
+}
+
+template< typename Val >
+inline RegexpMapIterImpl< Val >::RegexpMapIterImpl():
+ m_aEntry(rtl::OUString(), 0),
+ m_pMap(0),
+ m_nList(-1),
+ m_bEntrySet(false)
+{}
+
+template< typename Val >
+inline RegexpMapIterImpl< Val >::RegexpMapIterImpl(MapImpl * pTheMap,
+ int nTheList,
+ ListIterator aTheIndex):
+ m_aEntry(rtl::OUString(), 0),
+ m_aIndex(aTheIndex),
+ m_pMap(pTheMap),
+ m_nList(nTheList),
+ m_bEntrySet(false)
+{}
+
+//============================================================================
+template< typename Val >
+void RegexpMapIterImpl< Val >::setEntry() const
+{
+ if (!m_bEntrySet)
+ {
+ Entry< Val > const & rTheEntry
+ = m_nList == -1 ? *m_pMap->m_pDefault : *m_aIndex;
+ m_aEntry
+ = RegexpMapEntry< Val >(rTheEntry.m_aRegexp.getRegexp(false),
+ const_cast< Val * >(&rTheEntry.m_aValue));
+ m_bEntrySet = true;
+ }
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapIterImpl< Val >::RegexpMapIterImpl(RegexpMapImpl< Val > * pTheMap,
+ bool bBegin):
+ m_aEntry(rtl::OUString(), 0),
+ m_pMap(pTheMap),
+ m_bEntrySet(false)
+{
+ if (bBegin)
+ {
+ m_nList = -1;
+ m_aIndex = List< Val >::iterator();
+ if (!m_pMap->m_pDefault)
+ next();
+ }
+ else
+ {
+ m_nList = Regexp::KIND_DOMAIN;
+ m_aIndex = m_pMap->m_aList[Regexp::KIND_DOMAIN].end();
+ }
+}
+
+//============================================================================
+template< typename Val >
+bool RegexpMapIterImpl< Val >::operator ==(RegexpMapIterImpl const & rOther)
+ const
+{
+ return m_pMap == rOther.m_pMap
+ && m_nList == rOther.m_nList
+ && m_aIndex == rOther.m_aIndex;
+}
+
+//============================================================================
+template< typename Val >
+void RegexpMapIterImpl< Val >::next()
+{
+ switch (m_nList)
+ {
+ case Regexp::KIND_DOMAIN:
+ if (m_aIndex == m_pMap->m_aList[m_nList].end())
+ return;
+ default:
+ ++m_aIndex;
+ if (m_nList == Regexp::KIND_DOMAIN
+ || m_aIndex != m_pMap->m_aList[m_nList].end())
+ break;
+ case -1:
+ do
+ {
+ ++m_nList;
+ m_aIndex = m_pMap->m_aList[m_nList].begin();
+ }
+ while (m_nList < Regexp::KIND_DOMAIN
+ && m_aIndex == m_pMap->m_aList[m_nList].end());
+ break;
+ }
+ m_bEntrySet = false;
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapEntry< Val > & RegexpMapIterImpl< Val >::get()
+{
+ setEntry();
+ return m_aEntry;
+}
+
+//============================================================================
+//
+// RegexpMapConstIter
+//
+//============================================================================
+
+template< typename Val >
+RegexpMapConstIter< Val >::RegexpMapConstIter(RegexpMapIterImpl< Val > *
+ pTheImpl):
+ m_pImpl(pTheImpl)
+{}
+
+//============================================================================
+template< typename Val >
+RegexpMapConstIter< Val >::RegexpMapConstIter():
+ m_pImpl(new RegexpMapIterImpl< Val >)
+{}
+
+//============================================================================
+template< typename Val >
+RegexpMapConstIter< Val >::RegexpMapConstIter(RegexpMapConstIter const &
+ rOther):
+ m_pImpl(new RegexpMapIterImpl< Val >(*rOther.m_pImpl))
+{}
+
+//============================================================================
+template< typename Val >
+RegexpMapConstIter< Val >::~RegexpMapConstIter()
+{
+ delete m_pImpl;
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapConstIter< Val > &
+RegexpMapConstIter< Val >::operator =(RegexpMapConstIter const & rOther)
+{
+ *m_pImpl = *rOther.m_pImpl;
+ return *this;
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapConstIter< Val > & RegexpMapConstIter< Val >::operator ++()
+{
+ m_pImpl->next();
+ return *this;
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapConstIter< Val > RegexpMapConstIter< Val >::operator ++(int)
+{
+ RegexpMapConstIter aTemp(*this);
+ m_pImpl->next();
+ return aTemp;
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapEntry< Val > const & RegexpMapConstIter< Val >::operator *() const
+{
+ return m_pImpl->get();
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapEntry< Val > const * RegexpMapConstIter< Val >::operator ->() const
+{
+ return &m_pImpl->get();
+}
+
+//============================================================================
+template< typename Val >
+bool RegexpMapConstIter< Val >::equals(RegexpMapConstIter const & rOther)
+ const
+{
+ return *m_pImpl == *rOther.m_pImpl;
+}
+
+//============================================================================
+//
+// RegexpMapIter
+//
+//============================================================================
+
+template< typename Val >
+RegexpMapIter< Val >::RegexpMapIter(RegexpMapIterImpl< Val > * pTheImpl):
+ RegexpMapConstIter< Val >(pTheImpl)
+{}
+
+//============================================================================
+template< typename Val >
+RegexpMapIter< Val > & RegexpMapIter< Val >::operator ++()
+{
+ m_pImpl->next();
+ return *this;
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapIter< Val > RegexpMapIter< Val >::operator ++(int)
+{
+ RegexpMapIter aTemp(*this);
+ m_pImpl->next();
+ return aTemp;
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapEntry< Val > & RegexpMapIter< Val >::operator *()
+{
+ return m_pImpl->get();
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapEntry< Val > const & RegexpMapIter< Val >::operator *() const
+{
+ return m_pImpl->get();
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapEntry< Val > * RegexpMapIter< Val >::operator ->()
+{
+ return &m_pImpl->get();
+}
+
+//============================================================================
+template< typename Val >
+RegexpMapEntry< Val > const * RegexpMapIter< Val >::operator ->() const
+{
+ return &m_pImpl->get();
+}
+
+//============================================================================
+//
+// RegexpMap
+//
+//============================================================================
+
+namespace ucb {
+
+template< typename Val >
+struct RegexpMapImpl
+{
+ List< Val > m_aList[Regexp::KIND_DOMAIN + 1];
+ Entry< Val > * m_pDefault;
+
+ RegexpMapImpl(): m_pDefault(0) {}
+
+ ~RegexpMapImpl() { delete m_pDefault; }
+};
+
+}
+
+//============================================================================
+template< typename Val >
+RegexpMap< Val >::RegexpMap():
+ m_pImpl(new RegexpMapImpl< Val >)
+{}
+
+//============================================================================
+template< typename Val >
+RegexpMap< Val >::RegexpMap(RegexpMap const & rOther):
+ m_pImpl(new RegexpMapImpl< Val >(*rOther.m_pImpl))
+{}
+
+//============================================================================
+template< typename Val >
+RegexpMap< Val >::~RegexpMap()
+{
+ delete m_pImpl;
+}
+
+//============================================================================
+template< typename Val >
+RegexpMap< Val > & RegexpMap< Val >::operator =(RegexpMap const & rOther)
+{
+ *m_pImpl = *rOther.m_pImpl;
+ return *this;
+}
+
+//============================================================================
+template< typename Val >
+bool RegexpMap< Val >::add(rtl::OUString const & rKey, Val const & rValue,
+ bool bOverwrite, rtl::OUString * pReverse)
+{
+ Regexp aRegexp(Regexp::parse(rKey));
+
+ if (aRegexp.isDefault())
+ {
+ if (m_pImpl->m_pDefault)
+ {
+ if (!bOverwrite)
+ return false;
+ delete m_pImpl->m_pDefault;
+ }
+ m_pImpl->m_pDefault = new Entry< Val >(aRegexp, rValue);
+ }
+ else
+ {
+ List< Val > & rTheList = m_pImpl->m_aList[aRegexp.getKind()];
+
+ List< Val >::iterator aEnd(rTheList.end());
+ for (List< Val >::iterator aIt(rTheList.begin()); aIt != aEnd; ++aIt)
+ if (aIt->m_aRegexp == aRegexp)
+ if (bOverwrite)
+ {
+ rTheList.erase(aIt);
+ break;
+ }
+ else
+ return false;
+
+ rTheList.push_back(Entry< Val >(aRegexp, rValue));
+ }
+
+ if (pReverse)
+ *pReverse = aRegexp.getRegexp(true);
+
+ return true;
+}
+
+//============================================================================
+template< typename Val >
+RegexpMap< Val >::iterator RegexpMap< Val >::find(rtl::OUString const & rKey,
+ rtl::OUString * pReverse)
+{
+ Regexp aRegexp(Regexp::parse(rKey));
+
+ if (pReverse)
+ *pReverse = aRegexp.getRegexp(true);
+
+ if (aRegexp.isDefault())
+ {
+ if (m_pImpl->m_pDefault)
+ return RegexpMapIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl,
+ true));
+ }
+ else
+ {
+ List< Val > & rTheList = m_pImpl->m_aList[aRegexp.getKind()];
+
+ List< Val > ::iterator aEnd(rTheList.end());
+ for (List< Val >::iterator aIt(rTheList.begin()); aIt != aEnd; ++aIt)
+ if (aIt->m_aRegexp == aRegexp)
+ return RegexpMapIter< Val >(new RegexpMapIterImpl< Val >(
+ m_pImpl,
+ aRegexp.getKind(), aIt));
+ }
+
+ return RegexpMapIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl, false));
+}
+
+//============================================================================
+template< typename Val >
+void RegexpMap< Val >::erase(iterator const & rPos)
+{
+ if (rPos.m_pImpl->getMap() == m_pImpl)
+ if (rPos.m_pImpl->getList() == -1)
+ {
+ if (m_pImpl->m_pDefault)
+ {
+ delete m_pImpl->m_pDefault;
+ m_pImpl->m_pDefault = 0;
+ }
+ }
+ else
+ m_pImpl->m_aList[rPos.m_pImpl->getList()].
+ erase(rPos.m_pImpl->getIndex());
+}
+
+//============================================================================
+template< typename Val >
+RegexpMap< Val >::iterator RegexpMap< Val >::begin()
+{
+ return RegexpMapIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl, true));
+}
+
+//============================================================================
+template< typename Val >
+RegexpMap< Val >::const_iterator RegexpMap< Val >::begin() const
+{
+ return RegexpMapConstIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl,
+ true));
+}
+
+//============================================================================
+template< typename Val >
+RegexpMap< Val >::iterator RegexpMap< Val >::end()
+{
+ return RegexpMapIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl, false));
+}
+
+//============================================================================
+template< typename Val >
+RegexpMap< Val >::const_iterator RegexpMap< Val >::end() const
+{
+ return RegexpMapConstIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl,
+ false));
+}
+
+//============================================================================
+template< typename Val >
+bool RegexpMap< Val >::empty() const
+{
+ return !m_pImpl->m_pDefault
+ && m_pImpl->m_aList[Regexp::KIND_PREFIX].empty()
+ && m_pImpl->m_aList[Regexp::KIND_AUTHORITY].empty()
+ && m_pImpl->m_aList[Regexp::KIND_DOMAIN].empty();
+}
+
+//============================================================================
+template< typename Val >
+RegexpMap< Val >::size_type RegexpMap< Val >::size() const
+{
+ return (m_pImpl->m_pDefault ? 1 : 0)
+ + m_pImpl->m_aList[Regexp::KIND_PREFIX].size()
+ + m_pImpl->m_aList[Regexp::KIND_AUTHORITY].size()
+ + m_pImpl->m_aList[Regexp::KIND_DOMAIN].size();
+}
+
+//============================================================================
+template< typename Val >
+Val const * RegexpMap< Val >::map(rtl::OUString const & rString,
+ rtl::OUString * pTranslation,
+ bool * pTranslated) const
+{
+ for (int n = Regexp::KIND_DOMAIN; n >= Regexp::KIND_PREFIX; --n)
+ {
+ List< Val > const & rTheList = m_pImpl->m_aList[n];
+
+ List< Val >::const_iterator aEnd(rTheList.end());
+ for (List< Val >::const_iterator aIt(rTheList.begin()); aIt != aEnd;
+ ++aIt)
+ if (aIt->m_aRegexp.matches(rString, pTranslation, pTranslated))
+ return &aIt->m_aValue;
+ }
+ if (m_pImpl->m_pDefault
+ && m_pImpl->m_pDefault->m_aRegexp.matches(rString, pTranslation,
+ pTranslated))
+ return &m_pImpl->m_pDefault->m_aValue;
+ return 0;
+}
+
+#endif // _UCB_REGEXPMAP_TPT_
diff --git a/ucb/source/regexp/makefile.mk b/ucb/source/regexp/makefile.mk
new file mode 100644
index 000000000000..b74cf33750cf
--- /dev/null
+++ b/ucb/source/regexp/makefile.mk
@@ -0,0 +1,76 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: kso $ $Date: 2000-10-16 14:53:21 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=ucb
+TARGET=regexp
+AUTOSEG=true
+ENABLE_EXCEPTIONS=true
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+SLOFILES=\
+ $(SLO)$/regexp.obj
+
+.INCLUDE : target.mk
diff --git a/ucb/source/regexp/regexp.cxx b/ucb/source/regexp/regexp.cxx
new file mode 100644
index 000000000000..1164182f0a9b
--- /dev/null
+++ b/ucb/source/regexp/regexp.cxx
@@ -0,0 +1,509 @@
+/*************************************************************************
+ *
+ * $RCSfile: regexp.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:53:21 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _UCB_REGEXP_HXX_
+#include <regexp.hxx>
+#endif
+
+#include <cstddef>
+
+#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _VOS_DIAGNOSE_H_
+#include <vos/diagnose.hxx>
+#endif
+
+namespace unnamed_ucb_regexp {} using namespace unnamed_ucb_regexp;
+ // unnamed namespaces don't work well yet...
+
+using namespace com::sun::star;
+using namespace ucb;
+
+//============================================================================
+//
+// Regexp
+//
+//============================================================================
+
+inline Regexp::Regexp(Kind eTheKind, rtl::OUString const & rThePrefix,
+ bool bTheEmptyDomain, rtl::OUString const & rTheInfix,
+ bool bTheTranslation,
+ rtl::OUString const & rTheReversePrefix):
+ m_eKind(eTheKind),
+ m_aPrefix(rThePrefix),
+ m_aInfix(rTheInfix),
+ m_aReversePrefix(rTheReversePrefix),
+ m_bEmptyDomain(bTheEmptyDomain),
+ m_bTranslation(bTheTranslation)
+{
+ VOS_ASSERT(m_eKind == KIND_DOMAIN
+ || !m_bEmptyDomain && m_aInfix.getLength() == 0);
+ VOS_ASSERT(m_bTranslation || m_aReversePrefix.getLength() == 0);
+}
+
+//============================================================================
+namespace unnamed_ucb_regexp {
+
+bool matchStringIgnoreCase(sal_Unicode const ** pBegin,
+ sal_Unicode const * pEnd,
+ rtl::OUString const & rString)
+{
+ sal_Unicode const * p = *pBegin;
+
+ sal_Unicode const * q = rString.getStr();
+ sal_Unicode const * qEnd = q + rString.getLength();
+
+ if (pEnd - p < qEnd - q)
+ return false;
+
+ while (q != qEnd)
+ {
+ sal_Unicode c1 = *p++;
+ sal_Unicode c2 = *q++;
+ if (c1 >= 'a' && c1 <= 'z')
+ c1 -= 'a' - 'A';
+ if (c2 >= 'a' && c2 <= 'z')
+ c2 -= 'a' - 'A';
+ if (c1 != c2)
+ return false;
+ }
+
+ *pBegin = p;
+ return true;
+}
+
+}
+
+bool Regexp::matches(rtl::OUString const & rString,
+ rtl::OUString * pTranslation, bool * pTranslated) const
+{
+ sal_Unicode const * pBegin = rString.getStr();
+ sal_Unicode const * pEnd = pBegin + rString.getLength();
+
+ bool bMatches = false;
+
+ sal_Unicode const * p = pBegin;
+ if (matchStringIgnoreCase(&p, pEnd, m_aPrefix))
+ {
+ sal_Unicode const * pBlock1Begin = p;
+ sal_Unicode const * pBlock1End = pEnd;
+
+ sal_Unicode const * pBlock2Begin = 0;
+ sal_Unicode const * pBlock2End = 0;
+
+ switch (m_eKind)
+ {
+ case KIND_PREFIX:
+ bMatches = true;
+ break;
+
+ case KIND_AUTHORITY:
+ bMatches = p == pEnd || *p == '/' || *p == '?' || *p == '#';
+ break;
+
+ case KIND_DOMAIN:
+ if (!m_bEmptyDomain)
+ {
+ if (p == pEnd || *p == '/' || *p == '?' || *p == '#')
+ break;
+ ++p;
+ }
+ for (;;)
+ {
+ sal_Unicode const * q = p;
+ if (matchStringIgnoreCase(&q, pEnd, m_aInfix)
+ && (q == pEnd || *q == '/' || *q == '?' || *q == '#'))
+ {
+ bMatches = true;
+ pBlock1End = p;
+ pBlock2Begin = q;
+ pBlock2End = pEnd;
+ break;
+ }
+
+ if (p == pEnd)
+ break;
+
+ sal_Unicode c = *p++;
+ if (c == '/' || c == '?' || c == '#')
+ break;
+ }
+ break;
+ }
+
+ if (bMatches)
+ if (m_bTranslation)
+ {
+ if (pTranslation)
+ {
+ rtl::OUStringBuffer aBuffer(m_aReversePrefix);
+ aBuffer.append(pBlock1Begin, pBlock1End - pBlock1Begin);
+ aBuffer.append(m_aInfix);
+ aBuffer.append(pBlock2Begin, pBlock2End - pBlock2Begin);
+ *pTranslation = aBuffer.makeStringAndClear();
+ }
+ if (pTranslated)
+ *pTranslated = true;
+ }
+ else
+ {
+ if (pTranslation)
+ *pTranslation = rString;
+ if (pTranslated)
+ *pTranslated = false;
+ }
+ }
+
+ return bMatches;
+}
+
+//============================================================================
+namespace unnamed_ucb_regexp {
+
+inline bool isAlpha(sal_Unicode c)
+{
+ return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z';
+}
+
+inline bool isDigit(sal_Unicode c)
+{
+ return c >= '0' && c <= '9';
+}
+
+bool isScheme(rtl::OUString const & rString)
+{
+ // Return true if rString matches <scheme> from RFC 2396:
+ sal_Unicode const * p = rString.getStr();
+ sal_Unicode const * pEnd = p + rString.getLength();
+ if (p != pEnd && isAlpha(*p))
+ for (++p;;)
+ {
+ if (p == pEnd)
+ return true;
+ sal_Unicode c = *p++;
+ if (!(isAlpha(c) || isDigit(c)
+ || c == '+' || c == '-' || c == '.'))
+ break;
+ }
+ return false;
+}
+
+void appendStringLiteral(rtl::OUStringBuffer * pBuffer,
+ rtl::OUString const & rString)
+{
+ VOS_ASSERT(pBuffer);
+
+ pBuffer->append(sal_Unicode('"'));
+ sal_Unicode const * p = rString.getStr();
+ sal_Unicode const * pEnd = p + rString.getLength();
+ while (p != pEnd)
+ {
+ sal_Unicode c = *p++;
+ if (c == '"' || c == '\\')
+ pBuffer->append(sal_Unicode('\\'));
+ pBuffer->append(c);
+ }
+ pBuffer->append(sal_Unicode('"'));
+}
+
+}
+
+rtl::OUString Regexp::getRegexp(bool bReverse) const
+{
+ if (m_bTranslation)
+ {
+ rtl::OUStringBuffer aBuffer;
+ if (bReverse)
+ {
+ if (m_aReversePrefix.getLength() != 0)
+ appendStringLiteral(&aBuffer, m_aReversePrefix);
+ }
+ else
+ {
+ if (m_aPrefix.getLength() != 0)
+ appendStringLiteral(&aBuffer, m_aPrefix);
+ }
+ switch (m_eKind)
+ {
+ case KIND_PREFIX:
+ aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("(.*)"));
+ break;
+
+ case KIND_AUTHORITY:
+ aBuffer.
+ appendAscii(RTL_CONSTASCII_STRINGPARAM("(([/?#].*)?)"));
+ break;
+
+ case KIND_DOMAIN:
+ aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("([^/?#]"));
+ aBuffer.append(sal_Unicode(m_bEmptyDomain ? '*' : '+'));
+ if (m_aInfix.getLength() != 0)
+ appendStringLiteral(&aBuffer, m_aInfix);
+ aBuffer.
+ appendAscii(RTL_CONSTASCII_STRINGPARAM("([/?#].*)?)"));
+ break;
+ }
+ aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("->"));
+ if (bReverse)
+ {
+ if (m_aPrefix.getLength() != 0)
+ appendStringLiteral(&aBuffer, m_aPrefix);
+ }
+ else
+ {
+ if (m_aReversePrefix.getLength() != 0)
+ appendStringLiteral(&aBuffer, m_aReversePrefix);
+ }
+ aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("\\1"));
+ return aBuffer.makeStringAndClear();
+ }
+ else if (m_eKind == KIND_PREFIX && isScheme(m_aPrefix))
+ return m_aPrefix;
+ else
+ {
+ rtl::OUStringBuffer aBuffer;
+ if (m_aPrefix.getLength() != 0)
+ appendStringLiteral(&aBuffer, m_aPrefix);
+ switch (m_eKind)
+ {
+ case KIND_PREFIX:
+ aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM(".*"));
+ break;
+
+ case KIND_AUTHORITY:
+ aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("([/?#].*)?"));
+ break;
+
+ case KIND_DOMAIN:
+ aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("[^/?#]"));
+ aBuffer.append(sal_Unicode(m_bEmptyDomain ? '*' : '+'));
+ if (m_aInfix.getLength() != 0)
+ appendStringLiteral(&aBuffer, m_aInfix);
+ aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("([/?#].*)?"));
+ break;
+ }
+ return aBuffer.makeStringAndClear();
+ }
+}
+
+//============================================================================
+namespace unnamed_ucb_regexp {
+
+bool matchString(sal_Unicode const ** pBegin, sal_Unicode const * pEnd,
+ sal_Char const * pString, size_t nStringLength)
+{
+ sal_Unicode const * p = *pBegin;
+
+ sal_uChar const * q = reinterpret_cast< sal_uChar const * >(pString);
+ sal_uChar const * qEnd = q + nStringLength;
+
+ if (pEnd - p < qEnd - q)
+ return false;
+
+ while (q != qEnd)
+ {
+ sal_Unicode c1 = *p++;
+ sal_Unicode c2 = *q++;
+ if (c1 != c2)
+ return false;
+ }
+
+ *pBegin = p;
+ return true;
+}
+
+bool scanStringLiteral(sal_Unicode const ** pBegin, sal_Unicode const * pEnd,
+ rtl::OUString * pString)
+{
+ sal_Unicode const * p = *pBegin;
+
+ if (p == pEnd || *p++ != '"')
+ return false;
+
+ rtl::OUStringBuffer aBuffer;
+ for (;;)
+ {
+ if (p == pEnd)
+ return false;
+ sal_Unicode c = *p++;
+ if (c == '"')
+ break;
+ if (c == '\\')
+ {
+ if (p == pEnd)
+ return false;
+ c = *p++;
+ if (c != '"' && c != '\\')
+ return false;
+ }
+ aBuffer.append(c);
+ }
+
+ *pBegin = p;
+ *pString = aBuffer.makeStringAndClear();
+ return true;
+}
+
+}
+
+Regexp Regexp::parse(rtl::OUString const & rRegexp)
+{
+ // Detect an input of '<scheme>' as an abbreviation of '"<scheme>".*'
+ // where <scheme> is as defined in RFC 2396:
+ if (isScheme(rRegexp))
+ return Regexp(Regexp::KIND_PREFIX, rRegexp, false, rtl::OUString(),
+ false, rtl::OUString());
+
+ sal_Unicode const * p = rRegexp.getStr();
+ sal_Unicode const * pEnd = p + rRegexp.getLength();
+
+ rtl::OUString aPrefix;
+ scanStringLiteral(&p, pEnd, &aPrefix);
+
+ if (p == pEnd)
+ throw lang::IllegalArgumentException();
+
+ if (matchString(&p, pEnd, RTL_CONSTASCII_STRINGPARAM(".*")))
+ {
+ if (p != pEnd)
+ throw lang::IllegalArgumentException();
+
+ return Regexp(Regexp::KIND_PREFIX, aPrefix, false, rtl::OUString(),
+ false, rtl::OUString());
+ }
+ else if (matchString(&p, pEnd, RTL_CONSTASCII_STRINGPARAM("(.*)->")))
+ {
+ rtl::OUString aReversePrefix;
+ scanStringLiteral(&p, pEnd, &aReversePrefix);
+
+ if (!matchString(&p, pEnd, RTL_CONSTASCII_STRINGPARAM("\\1"))
+ || p != pEnd)
+ throw lang::IllegalArgumentException();
+
+ return Regexp(Regexp::KIND_PREFIX, aPrefix, false, rtl::OUString(),
+ true, aReversePrefix);
+ }
+ else if (matchString(&p, pEnd, RTL_CONSTASCII_STRINGPARAM("([/?#].*)?")))
+ {
+ if (p != pEnd)
+ throw lang::IllegalArgumentException();
+
+ return Regexp(Regexp::KIND_AUTHORITY, aPrefix, false, rtl::OUString(),
+ false, rtl::OUString());
+ }
+ else if (matchString(&p, pEnd,
+ RTL_CONSTASCII_STRINGPARAM("(([/?#].*)?)->")))
+ {
+ rtl::OUString aReversePrefix;
+ if (!(scanStringLiteral(&p, pEnd, &aReversePrefix)
+ && matchString(&p, pEnd, RTL_CONSTASCII_STRINGPARAM("\\1"))
+ && p == pEnd))
+ throw lang::IllegalArgumentException();
+
+ return Regexp(Regexp::KIND_AUTHORITY, aPrefix, false, rtl::OUString(),
+ true, aReversePrefix);
+ }
+ else
+ {
+ bool bOpen = false;
+ if (p != pEnd && *p == '(')
+ {
+ ++p;
+ bOpen = true;
+ }
+
+ if (!matchString(&p, pEnd, RTL_CONSTASCII_STRINGPARAM("[^/?#]")))
+ throw lang::IllegalArgumentException();
+
+ if (p == pEnd || *p != '*' && *p != '+')
+ throw lang::IllegalArgumentException();
+ bool bEmptyDomain = *p++ == '*';
+
+ rtl::OUString aInfix;
+ scanStringLiteral(&p, pEnd, &aInfix);
+
+ if (!matchString(&p, pEnd, RTL_CONSTASCII_STRINGPARAM("([/?#].*)?")))
+ throw lang::IllegalArgumentException();
+
+ rtl::OUString aReversePrefix;
+ if (bOpen
+ && !(matchString(&p, pEnd, RTL_CONSTASCII_STRINGPARAM(")->"))
+ && scanStringLiteral(&p, pEnd, &aReversePrefix)
+ && matchString(&p, pEnd, RTL_CONSTASCII_STRINGPARAM("\\1"))))
+ throw lang::IllegalArgumentException();
+
+ if (p != pEnd)
+ throw lang::IllegalArgumentException();
+
+ return Regexp(Regexp::KIND_DOMAIN, aPrefix, bEmptyDomain, aInfix,
+ bOpen, aReversePrefix);
+ }
+
+ throw lang::IllegalArgumentException();
+}
+
diff --git a/ucb/source/sorter/makefile.mk b/ucb/source/sorter/makefile.mk
new file mode 100644
index 000000000000..93601205bb8f
--- /dev/null
+++ b/ucb/source/sorter/makefile.mk
@@ -0,0 +1,135 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: kso $ $Date: 2000-10-16 14:53:23 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library 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 for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=ucb
+TARGET=srtrs
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+
+# Version
+UCB_MAJOR=1
+
+.INCLUDE: svpre.mk
+.INCLUDE: settings.mk
+.INCLUDE: sv.mk
+
+#INCPRE+=$(PRJ)$/source$/inc
+
+SLOFILES=\
+ $(SLO)$/sortdynres.obj \
+ $(SLO)$/sortresult.obj \
+ $(SLO)$/sortmain.obj
+
+# NETBSD: somewhere we have to instantiate the static data members.
+# NETBSD-1.2.1 doesn't know about weak symbols so the default mechanism for GCC won't work.
+# SCO and MACOSX: the linker does know about weak symbols, but we can't ignore multiple defined symbols
+.IF "$(OS)"=="NETBSD" || "$(OS)"=="SCO" || "$(OS)$(COM)"=="OS2GCC" || "$(OS)"=="MACOSX"
+SLOFILES+=$(SLO)$/staticmbsorter.obj
+.ENDIF
+
+LIB1TARGET=$(SLB)$/_$(TARGET).lib
+LIB1OBJFILES=$(SLOFILES)
+
+SHL1TARGET=$(TARGET)$(UCB_MAJOR)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+SHL1STDLIBS=\
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(TOOLSLIB) \
+ $(VOSLIB)
+
+#SHL1STDLIBS=\
+# $(CPPUHELPERLIB) \
+# $(CPPULIB) \
+# $(SALLIB) \
+# $(STORELIB)
+
+
+
+SHL1LIBS=$(LIB1TARGET)
+SHL1IMPLIB=i$(TARGET)
+
+DEF1DEPN=$(MISC)$/$(SHL1TARGET).flt
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORT1 =component_getImplementationEnvironment
+DEF1EXPORT2 =component_writeInfo
+DEF1EXPORT3 =component_getFactory
+DEF1DES=UCB : Sorted Dynamic ResultSet
+
+.INCLUDE: target.mk
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+# @echo Type >> $@
+ @echo cpp >> $@
+ @echo m_ >> $@
+ @echo rtl >> $@
+ @echo vos >> $@
+ @echo component_getImplementationEnvironment >> $@
+ @echo component_writeInfo >> $@
+ @echo component_getFactory >> $@
+.IF "$(COM)"=="MSC"
+ @echo ??_ >> $@
+.ENDIF # COM MSC
diff --git a/ucb/source/sorter/sortdynres.cxx b/ucb/source/sorter/sortdynres.cxx
new file mode 100644
index 000000000000..2a34473294a8
--- /dev/null
+++ b/ucb/source/sorter/sortdynres.cxx
@@ -0,0 +1,665 @@
+/*************************************************************************
+ *
+ * $RCSfile: sortdynres.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:53:23 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <sortdynres.hxx>
+
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UCB_CONTENTRESULTSETCAPABILITY_HPP_
+#include <com/sun/star/ucb/ContentResultSetCapability.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_LISTACTIONTYPE_HPP_
+#include <com/sun/star/ucb/ListActionType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_WELCOMEDYNAMICRESULTSETSTRUCT_HPP_
+#include <com/sun/star/ucb/WelcomeDynamicResultSetStruct.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XCACHEDDYNAMICRESULTSETSTUBFACTORY_HPP_
+#include <com/sun/star/ucb/XCachedDynamicResultSetStubFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XSOURCEINITIALIZATION_HPP_
+#include <com/sun/star/ucb/XSourceInitialization.hpp>
+#endif
+
+//-----------------------------------------------------------------------------
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace cppu;
+using namespace rtl;
+
+//=========================================================================
+
+// The mutex to synchronize access to containers.
+static osl::Mutex& getContainerMutex()
+{
+ static osl::Mutex* pMutex = NULL;
+ if( !pMutex )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pMutex )
+ {
+ static osl::Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+
+ return *pMutex;
+}
+
+//=========================================================================
+//
+// SortedDynamicResultSet
+//
+//=========================================================================
+
+SortedDynamicResultSet::SortedDynamicResultSet(
+ const Reference < XDynamicResultSet > &xOriginal,
+ const Sequence < NumberedSortingInfo > &aOptions,
+ const Reference < XAnyCompareFactory > &xCompFac,
+ const Reference < XMultiServiceFactory > &xSMgr )
+{
+ mpDisposeEventListeners = NULL;
+ mpOwnListener = new SortedDynamicResultSetListener( this );
+
+ mxOwnListener = Reference< XDynamicResultSetListener >( mpOwnListener );
+
+ mxOriginal = xOriginal;
+ maOptions = aOptions;
+ mxCompFac = xCompFac;
+ mxSMgr = xSMgr;
+
+ mpOne = NULL;
+ mpTwo = NULL;
+
+ mbGotWelcome = FALSE;
+ mbUseOne = TRUE;
+ mbStatic = FALSE;
+}
+
+//--------------------------------------------------------------------------
+SortedDynamicResultSet::~SortedDynamicResultSet()
+{
+ mpOwnListener->impl_OwnerDies();
+ mxOwnListener.clear();
+
+ delete mpDisposeEventListeners;
+
+ mxOne.clear();
+ mxTwo.clear();
+ mxOriginal.clear();
+
+ mpOne = NULL;
+ mpTwo = NULL;
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods.
+//--------------------------------------------------------------------------
+
+XINTERFACE_IMPL_4( SortedDynamicResultSet,
+ XTypeProvider,
+ XServiceInfo,
+ XComponent, /* base class of XDynamicResultSet */
+ XDynamicResultSet );
+
+//--------------------------------------------------------------------------
+// XTypeProvider methods.
+//--------------------------------------------------------------------------
+
+XTYPEPROVIDER_IMPL_3( SortedDynamicResultSet,
+ XTypeProvider,
+ XServiceInfo,
+ XDynamicResultSet );
+
+//--------------------------------------------------------------------------
+// XServiceInfo methods.
+//--------------------------------------------------------------------------
+
+XSERVICEINFO_NOFACTORY_IMPL_1( SortedDynamicResultSet,
+ OUString::createFromAscii( "SortedDynamicResultSet" ),
+ OUString::createFromAscii( DYNAMIC_RESULTSET_SERVICE_NAME ) );
+
+
+//--------------------------------------------------------------------------
+// XComponent methods.
+//--------------------------------------------------------------------------
+void SAL_CALL SortedDynamicResultSet::dispose()
+ throw( RuntimeException )
+{
+ vos::OGuard aGuard( maMutex );
+
+ if ( mpDisposeEventListeners && mpDisposeEventListeners->getLength() )
+ {
+ EventObject aEvt;
+ aEvt.Source = static_cast< XComponent * >( this );
+ mpDisposeEventListeners->disposeAndClear( aEvt );
+ }
+
+ mxOne.clear();
+ mxTwo.clear();
+ mxOriginal.clear();
+
+ mpOne = NULL;
+ mpTwo = NULL;
+ mbUseOne = TRUE;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL SortedDynamicResultSet::addEventListener(
+ const Reference< XEventListener >& Listener )
+ throw( RuntimeException )
+{
+ vos::OGuard aGuard( maMutex );
+
+ if ( !mpDisposeEventListeners )
+ mpDisposeEventListeners =
+ new OInterfaceContainerHelper( getContainerMutex() );
+
+ mpDisposeEventListeners->addInterface( Listener );
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL SortedDynamicResultSet::removeEventListener(
+ const Reference< XEventListener >& Listener )
+ throw( RuntimeException )
+{
+ vos::OGuard aGuard( maMutex );
+
+ if ( mpDisposeEventListeners )
+ mpDisposeEventListeners->removeInterface( Listener );
+}
+
+//--------------------------------------------------------------------------
+// XDynamicResultSet methods.
+// ------------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL
+SortedDynamicResultSet::getStaticResultSet()
+ throw( ListenerAlreadySetException, RuntimeException )
+{
+ vos::OGuard aGuard( maMutex );
+
+ if ( mxListener.is() )
+ throw ListenerAlreadySetException();
+
+ mbStatic = TRUE;
+
+ if ( mxOriginal.is() )
+ {
+ mpOne = new SortedResultSet( mxOriginal->getStaticResultSet() );
+ mxOne = mpOne;
+ mpOne->Initialize( maOptions, mxCompFac );
+ }
+
+ return mxOne;
+}
+
+// ------------------------------------------------------------------------------
+void SAL_CALL
+SortedDynamicResultSet::setListener( const Reference< XDynamicResultSetListener >& Listener )
+ throw( ListenerAlreadySetException, RuntimeException )
+{
+ vos::OGuard aGuard( maMutex );
+
+ if ( mxListener.is() )
+ throw ListenerAlreadySetException();
+
+ addEventListener( Reference< XEventListener >::query( Listener ) );
+
+ mxListener = Listener;
+
+ if ( mxOriginal.is() )
+ mxOriginal->setListener( mxOwnListener );
+}
+
+// ------------------------------------------------------------------------------
+void SAL_CALL
+SortedDynamicResultSet::connectToCache(
+ const Reference< XDynamicResultSet > & xCache )
+ throw( ListenerAlreadySetException,
+ AlreadyInitializedException,
+ ServiceNotFoundException,
+ RuntimeException )
+{
+ if( mxListener.is() )
+ throw ListenerAlreadySetException();
+
+ if( mbStatic )
+ throw ListenerAlreadySetException();
+
+ Reference< XSourceInitialization > xTarget( xCache, UNO_QUERY );
+ if( xTarget.is() && mxSMgr.is() )
+ {
+ Reference< XCachedDynamicResultSetStubFactory > xStubFactory(
+ mxSMgr->createInstance( OUString::createFromAscii(
+ "com.sun.star.ucb.CachedDynamicResultSetStubFactory" ) ), UNO_QUERY );
+ if( xStubFactory.is() )
+ {
+ xStubFactory->connectToCache(
+ this, xCache, Sequence< NumberedSortingInfo > (), NULL );
+ return;
+ }
+ }
+ throw ServiceNotFoundException();
+}
+
+// ------------------------------------------------------------------------------
+sal_Int16 SAL_CALL
+SortedDynamicResultSet::getCapabilities()
+ throw( RuntimeException )
+{
+ vos::OGuard aGuard( maMutex );
+
+ sal_Int16 nCaps = 0;
+
+ if ( mxOriginal.is() )
+ nCaps = mxOriginal->getCapabilities();
+
+ nCaps |= ContentResultSetCapability::SORTED;
+
+ return nCaps;
+}
+
+//--------------------------------------------------------------------------
+// XDynamicResultSetListener methods.
+// ------------------------------------------------------------------------------
+
+/** In the first notify-call the listener gets the two
+ <type>XResultSet</type>s and has to hold them. The <type>XResultSet</type>s
+ are implementations of the service <type>ContentResultSet</type>.
+
+ <p>The notified new <type>XResultSet</type> will stay valid after returning
+ notification. The old one will become invalid after returning notification.
+
+ <p>While in notify-call the listener is allowed to read old and new version,
+ except in the first call, where only the new Resultset is valid.
+
+ <p>The Listener is allowed to blockade this call, until he really want to go
+ to the new version. The only situation, where the listener has to return the
+ update call at once is, while he disposes his broadcaster or while he is
+ removing himsef as listener (otherwise you deadlock)!!!
+*/
+void SAL_CALL
+SortedDynamicResultSet::impl_notify( const ListEvent& Changes )
+ throw( RuntimeException )
+{
+ vos::OGuard aGuard( maMutex );
+
+ BOOL bHasNew = FALSE;
+ BOOL bHasModified = FALSE;
+
+ SortedResultSet *pCurSet = NULL;
+
+ // mxNew und mxOld vertauschen und anschliessend die Tabellen von Old
+ // nach New kopieren
+ if ( mbGotWelcome )
+ {
+ if ( mbUseOne )
+ {
+ mbUseOne = FALSE;
+ mpTwo->CopyData( mpOne );
+ pCurSet = mpTwo;
+ }
+ else
+ {
+ mbUseOne = TRUE;
+ mpOne->CopyData( mpTwo );
+ pCurSet = mpOne;
+ }
+ }
+
+ long nOldCount = pCurSet->GetCount();
+ Any aRet = pCurSet->getPropertyValue( OUString::createFromAscii( "IsRowCountFinal" ) );
+ BOOL bWasFinal;
+
+ aRet >>= bWasFinal;
+
+ // handle the actions in the list
+ for ( long i=0; i<Changes.Changes.getLength(); i++ )
+ {
+ const ListAction aAction = Changes.Changes[i];
+ switch ( aAction.ListActionType )
+ {
+ case ListActionType::WELCOME:
+ {
+ WelcomeDynamicResultSetStruct aWelcome;
+ if ( aAction.ActionInfo >>= aWelcome )
+ {
+ mpTwo = new SortedResultSet( aWelcome.Old );
+ mxTwo = mpTwo;
+ mpOne = new SortedResultSet( aWelcome.New );
+ mxOne = mpOne;
+ mpOne->Initialize( maOptions, mxCompFac );
+ mbGotWelcome = TRUE;
+ mbUseOne = TRUE;
+ pCurSet = mpOne;
+
+ aWelcome.Old = mxTwo;
+ aWelcome.New = mxOne;
+
+ ListAction *pWelcomeAction = new ListAction;
+ pWelcomeAction->ActionInfo <<= aWelcome;
+ pWelcomeAction->Position = 0;
+ pWelcomeAction->Count = 0;
+ pWelcomeAction->ListActionType = ListActionType::WELCOME;
+
+ maActions.Insert( pWelcomeAction );
+ }
+ else
+ {
+ // throw RuntimeException();
+ }
+ break;
+ }
+ case ListActionType::INSERTED:
+ {
+ pCurSet->InsertNew( aAction.Position, aAction.Count );
+ bHasNew = TRUE;
+ break;
+ }
+ case ListActionType::REMOVED:
+ {
+ pCurSet->Remove( aAction.Position,
+ aAction.Count,
+ &maActions );
+ break;
+ }
+ case ListActionType::MOVED:
+ {
+ long nOffset;
+ if ( aAction.ActionInfo >>= nOffset )
+ {
+ pCurSet->Move( aAction.Position,
+ aAction.Count,
+ nOffset );
+ }
+ break;
+ }
+ case ListActionType::PROPERTIES_CHANGED:
+ {
+ pCurSet->SetChanged( aAction.Position, aAction.Count );
+ bHasModified = TRUE;
+ break;
+ }
+ default: break;
+ }
+ }
+
+ if ( bHasModified )
+ pCurSet->ResortModified( &maActions );
+
+ if ( bHasNew )
+ pCurSet->ResortNew( &maActions );
+
+ // send the new actions with a notify to the listeners
+ SendNotify();
+
+ // check for propertyChangeEvents
+ pCurSet->CheckProperties( nOldCount, bWasFinal );
+}
+
+//-----------------------------------------------------------------
+// XEventListener
+//-----------------------------------------------------------------
+void SAL_CALL
+SortedDynamicResultSet::impl_disposing( const EventObject& Source )
+ throw( RuntimeException )
+{
+ mxListener.clear();
+ mxOriginal.clear();
+}
+
+// ------------------------------------------------------------------------------
+// private methods
+// ------------------------------------------------------------------------------
+void SortedDynamicResultSet::SendNotify()
+{
+ long nCount = maActions.Count();
+
+ if ( nCount && mxListener.is() )
+ {
+ Sequence< ListAction > aActionList( maActions.Count() );
+ ListAction *pActionList = aActionList.getArray();
+
+ for ( long i=0; i<nCount; i++ )
+ {
+ pActionList[ i ] = *(maActions.GetAction( i ));
+ }
+
+ ListEvent aNewEvent;
+ aNewEvent.Changes = aActionList;
+
+ mxListener->notify( aNewEvent );
+ }
+
+ // clean up
+ maActions.Clear();
+}
+
+//=========================================================================
+//
+// SortedDynamicResultSetFactory
+//
+//=========================================================================
+SortedDynamicResultSetFactory::SortedDynamicResultSetFactory(
+ const Reference< XMultiServiceFactory > & rSMgr )
+{
+ mxSMgr = rSMgr;
+}
+
+//--------------------------------------------------------------------------
+SortedDynamicResultSetFactory::~SortedDynamicResultSetFactory()
+{
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods.
+//--------------------------------------------------------------------------
+
+XINTERFACE_IMPL_3( SortedDynamicResultSetFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XSortedDynamicResultSetFactory );
+
+//--------------------------------------------------------------------------
+// XTypeProvider methods.
+//--------------------------------------------------------------------------
+
+XTYPEPROVIDER_IMPL_3( SortedDynamicResultSetFactory,
+ XTypeProvider,
+ XServiceInfo,
+ XSortedDynamicResultSetFactory );
+
+//--------------------------------------------------------------------------
+// XServiceInfo methods.
+//--------------------------------------------------------------------------
+
+XSERVICEINFO_IMPL_1( SortedDynamicResultSetFactory,
+ OUString::createFromAscii( "SortedDynamicResultSetFactory" ),
+ OUString::createFromAscii( DYNAMIC_RESULTSET_FACTORY_NAME ) );
+
+
+//--------------------------------------------------------------------------
+// Service factory implementation.
+//--------------------------------------------------------------------------
+
+ONE_INSTANCE_SERVICE_FACTORY_IMPL( SortedDynamicResultSetFactory );
+
+//--------------------------------------------------------------------------
+// SortedDynamicResultSetFactory methods.
+//--------------------------------------------------------------------------
+Reference< XDynamicResultSet > SAL_CALL
+SortedDynamicResultSetFactory::createSortedDynamicResultSet(
+ const Reference< XDynamicResultSet > & Source,
+ const Sequence< NumberedSortingInfo > & Info,
+ const Reference< XAnyCompareFactory > & CompareFactory )
+ throw( RuntimeException )
+{
+ Reference< XDynamicResultSet > xRet;
+ xRet = new SortedDynamicResultSet( Source, Info, CompareFactory, mxSMgr );
+ return xRet;
+}
+
+//=========================================================================
+//
+// EventList
+//
+//=========================================================================
+
+EventList::EventList()
+{}
+
+//--------------------------------------------------------------------------
+EventList::~EventList()
+{
+ Clear();
+}
+
+//--------------------------------------------------------------------------
+void EventList::Clear()
+{
+ ListAction *pData = (ListAction*) List::First();
+
+ while ( pData )
+ {
+ delete pData;
+ pData = (ListAction*) List::Next();
+ }
+
+ List::Clear();
+}
+
+//--------------------------------------------------------------------------
+void EventList::AddEvent( long nType, long nPos, long nCount )
+{
+ ListAction *pAction = new ListAction;
+ pAction->Position = nPos;
+ pAction->Count = nCount;
+ pAction->ListActionType = nType;
+
+ Insert( pAction );
+}
+
+//=================================================================
+//
+// SortedDynamicResultSetListener
+//
+//=================================================================
+
+SortedDynamicResultSetListener::SortedDynamicResultSetListener(
+ SortedDynamicResultSet *mOwner )
+{
+ mpOwner = mOwner;
+}
+
+//-----------------------------------------------------------------
+SortedDynamicResultSetListener::~SortedDynamicResultSetListener()
+{
+}
+
+//-----------------------------------------------------------------
+// XInterface methods.
+//-----------------------------------------------------------------
+
+XINTERFACE_IMPL_2( SortedDynamicResultSetListener,
+ XEventListener, /* base class of XDynamicResultSetListener */
+ XDynamicResultSetListener );
+
+//-----------------------------------------------------------------
+// XEventListener ( base of XDynamicResultSetListener )
+//-----------------------------------------------------------------
+void SAL_CALL
+SortedDynamicResultSetListener::disposing( const EventObject& Source )
+ throw( RuntimeException )
+{
+ vos::OGuard aGuard( maMutex );
+
+ if ( mpOwner )
+ mpOwner->impl_disposing( Source );
+}
+
+//-----------------------------------------------------------------
+// XDynamicResultSetListener
+//-----------------------------------------------------------------
+void SAL_CALL
+SortedDynamicResultSetListener::notify( const ListEvent& Changes )
+ throw( RuntimeException )
+{
+ vos::OGuard aGuard( maMutex );
+
+ if ( mpOwner )
+ mpOwner->impl_notify( Changes );
+}
+
+//-----------------------------------------------------------------
+// own methods:
+//-----------------------------------------------------------------
+void SAL_CALL
+SortedDynamicResultSetListener::impl_OwnerDies()
+{
+ vos::OGuard aGuard( maMutex );
+ mpOwner = NULL;
+}
+
diff --git a/ucb/source/sorter/sortdynres.hxx b/ucb/source/sorter/sortdynres.hxx
new file mode 100644
index 000000000000..abdb85fc5003
--- /dev/null
+++ b/ucb/source/sorter/sortdynres.hxx
@@ -0,0 +1,325 @@
+/*************************************************************************
+ *
+ * $RCSfile: sortdynres.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:53:23 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SORTDYNRES_HXX
+#define _SORTDYNRES_HXX
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_NUMBEREDSORTINGINFO_HPP_
+#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XDYNAMICRESULTSET_HPP_
+#include <com/sun/star/ucb/XDynamicResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XDYNAMICRESULTSETLISTENER_HPP_
+#include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_LISTENERALREADYSETEXCEPTION_HPP_
+#include <com/sun/star/ucb/ListenerAlreadySetException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XSORTEDDYNAMICRESULTSETFACTORY_HPP_
+#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
+#endif
+
+#ifndef _CPPUHELPER_WEAK_HXX_
+#include <cppuhelper/weak.hxx>
+#endif
+
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+
+#include <tools/list.hxx>
+
+#ifndef _UCBHELPER_MACROS_HXX
+#include <ucbhelper/macros.hxx>
+#endif
+
+#ifndef _SORTRESULT_HXX
+#include "sortresult.hxx"
+#endif
+
+namespace cppu {
+ class OInterfaceContainerHelper;
+}
+
+//-----------------------------------------------------------------------------
+
+#define NUMBERED_SORTINGINFO com::sun::star::ucb::NumberedSortingInfo
+#define RUNTIMEEXCEPTION com::sun::star::uno::RuntimeException
+#define REFERENCE com::sun::star::uno::Reference
+#define SEQUENCE com::sun::star::uno::Sequence
+#define EVENTOBJECT com::sun::star::lang::EventObject
+#define XEVENTLISTENER com::sun::star::lang::XEventListener
+#define XMULTISERVICEFACTORY com::sun::star::lang::XMultiServiceFactory
+#define XRESULTSET com::sun::star::sdbc::XResultSet
+#define SQLEXCEPTION com::sun::star::sdbc::SQLException
+#define XANYCOMPAREFACTORY com::sun::star::ucb::XAnyCompareFactory
+#define XDYNAMICRESULTSET com::sun::star::ucb::XDynamicResultSet
+#define XDYNAMICRESULTSETLISTENER com::sun::star::ucb::XDynamicResultSetListener
+#define LISTENERALREADYSETEXCEPTION com::sun::star::ucb::ListenerAlreadySetException
+
+#define DYNAMIC_RESULTSET_SERVICE_NAME "com.sun.star.ucb.SortedDynamicResultSet"
+#define DYNAMIC_RESULTSET_FACTORY_NAME "com.sun.star.ucb.SortedDynamicResultSetFactory"
+
+//-----------------------------------------------------------------------------
+class SortedDynamicResultSetListener;
+
+class SortedDynamicResultSet:
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XTypeProvider,
+ public com::sun::star::lang::XServiceInfo,
+ public com::sun::star::ucb::XDynamicResultSet
+{
+ cppu::OInterfaceContainerHelper *mpDisposeEventListeners;
+
+ REFERENCE < XDYNAMICRESULTSETLISTENER > mxListener;
+ REFERENCE < XDYNAMICRESULTSETLISTENER > mxOwnListener;
+
+ REFERENCE < XRESULTSET > mxOne;
+ REFERENCE < XRESULTSET > mxTwo;
+ REFERENCE < XDYNAMICRESULTSET > mxOriginal;
+ SEQUENCE < NUMBERED_SORTINGINFO > maOptions;
+ REFERENCE < XANYCOMPAREFACTORY > mxCompFac;
+ REFERENCE < XMULTISERVICEFACTORY > mxSMgr;
+
+ SortedResultSet* mpOne;
+ SortedResultSet* mpTwo;
+ SortedDynamicResultSetListener* mpOwnListener;
+
+ EventList maActions;
+ ::vos::OMutex maMutex;
+ BOOL mbGotWelcome :1;
+ BOOL mbUseOne :1;
+ BOOL mbStatic :1;
+
+private:
+
+ void SendNotify();
+
+public:
+ SortedDynamicResultSet( const REFERENCE < XDYNAMICRESULTSET > &xOriginal,
+ const SEQUENCE < NUMBERED_SORTINGINFO > &aOptions,
+ const REFERENCE < XANYCOMPAREFACTORY > &xCompFac,
+ const REFERENCE < XMULTISERVICEFACTORY > &xSMgr );
+
+ ~SortedDynamicResultSet();
+
+ //-----------------------------------------------------------------
+ // XInterface
+ //-----------------------------------------------------------------
+ XINTERFACE_DECL()
+
+ //-----------------------------------------------------------------
+ // XTypeProvider
+ //-----------------------------------------------------------------
+ XTYPEPROVIDER_DECL()
+
+ //-----------------------------------------------------------------
+ // XServiceInfo
+ //-----------------------------------------------------------------
+ XSERVICEINFO_NOFACTORY_DECL()
+
+ //-----------------------------------------------------------------
+ // XComponent
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ dispose() throw( RUNTIME_EXCEPTION );
+
+ virtual void SAL_CALL
+ addEventListener( const REFERENCE< XEVENTLISTENER >& Listener )
+ throw( RUNTIME_EXCEPTION );
+
+ virtual void SAL_CALL
+ removeEventListener( const REFERENCE< XEVENTLISTENER >& Listener )
+ throw( RUNTIME_EXCEPTION );
+
+ //-----------------------------------------------------------------
+ // XDynamicResultSet
+ //-----------------------------------------------------------------
+ virtual REFERENCE< XRESULTSET > SAL_CALL
+ getStaticResultSet( )
+ throw( LISTENERALREADYSETEXCEPTION, RUNTIMEEXCEPTION );
+
+ virtual void SAL_CALL
+ setListener( const REFERENCE< XDYNAMICRESULTSETLISTENER >& Listener )
+ throw( LISTENERALREADYSETEXCEPTION, RUNTIMEEXCEPTION );
+
+ virtual void SAL_CALL
+ connectToCache( const REFERENCE< XDYNAMICRESULTSET > & xCache )
+ throw( LISTENERALREADYSETEXCEPTION,
+ com::sun::star::ucb::AlreadyInitializedException,
+ com::sun::star::ucb::ServiceNotFoundException,
+ RUNTIMEEXCEPTION );
+
+ virtual sal_Int16 SAL_CALL
+ getCapabilities()
+ throw( RUNTIMEEXCEPTION );
+
+ //-----------------------------------------------------------------
+ // own methods:
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ impl_disposing( const EVENTOBJECT& Source )
+ throw( RUNTIMEEXCEPTION );
+
+ virtual void SAL_CALL
+ impl_notify( const ::com::sun::star::ucb::ListEvent& Changes )
+ throw( RUNTIMEEXCEPTION );
+};
+
+//-----------------------------------------------------------------------------
+
+class SortedDynamicResultSetListener:
+ public cppu::OWeakObject,
+ public com::sun::star::ucb::XDynamicResultSetListener
+{
+ SortedDynamicResultSet *mpOwner;
+ ::vos::OMutex maMutex;
+
+public:
+ SortedDynamicResultSetListener( SortedDynamicResultSet *mOwner );
+ ~SortedDynamicResultSetListener();
+
+ //-----------------------------------------------------------------
+ // XInterface
+ //-----------------------------------------------------------------
+ XINTERFACE_DECL()
+
+ //-----------------------------------------------------------------
+ // XEventListener ( base of XDynamicResultSetListener )
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ disposing( const EVENTOBJECT& Source )
+ throw( RUNTIMEEXCEPTION );
+
+ //-----------------------------------------------------------------
+ // XDynamicResultSetListener
+ //-----------------------------------------------------------------
+ virtual void SAL_CALL
+ notify( const ::com::sun::star::ucb::ListEvent& Changes )
+ throw( RUNTIMEEXCEPTION );
+
+ //-----------------------------------------------------------------
+ // own methods:
+ //-----------------------------------------------------------------
+ void SAL_CALL impl_OwnerDies();
+};
+
+//-----------------------------------------------------------------------------
+
+class SortedDynamicResultSetFactory:
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XTypeProvider,
+ public com::sun::star::lang::XServiceInfo,
+ public com::sun::star::ucb::XSortedDynamicResultSetFactory
+{
+
+ REFERENCE< XMULTISERVICEFACTORY > mxSMgr;
+
+public:
+
+ SortedDynamicResultSetFactory(
+ const REFERENCE< XMULTISERVICEFACTORY > & rSMgr);
+
+ ~SortedDynamicResultSetFactory();
+
+ //-----------------------------------------------------------------
+ // XInterface
+ //-----------------------------------------------------------------
+ XINTERFACE_DECL()
+
+ //-----------------------------------------------------------------
+ // XTypeProvider
+ //-----------------------------------------------------------------
+ XTYPEPROVIDER_DECL()
+
+ //-----------------------------------------------------------------
+ // XServiceInfo
+ //-----------------------------------------------------------------
+ XSERVICEINFO_DECL()
+
+ //-----------------------------------------------------------------
+ // XSortedDynamicResultSetFactory
+
+ virtual REFERENCE< XDYNAMICRESULTSET > SAL_CALL
+ createSortedDynamicResultSet(
+ const REFERENCE< XDYNAMICRESULTSET > & Source,
+ const SEQUENCE< NUMBERED_SORTINGINFO > & Info,
+ const REFERENCE< XANYCOMPAREFACTORY > & CompareFactory )
+ throw( RUNTIMEEXCEPTION );
+};
+
+#endif
diff --git a/ucb/source/sorter/sortmain.cxx b/ucb/source/sorter/sortmain.cxx
new file mode 100644
index 000000000000..1165ccbf8dc3
--- /dev/null
+++ b/ucb/source/sorter/sortmain.cxx
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * $RCSfile: sortmain.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:53:23 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SORTDYNRES_HXX
+#include <sortdynres.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#endif
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+//=========================================================================
+static sal_Bool writeInfo( void * pRegistryKey,
+ const OUString & rImplementationName,
+ Sequence< OUString > const & rServiceNames )
+{
+ OUString aKeyName( OUString::createFromAscii( "/" ) );
+ aKeyName += rImplementationName;
+ aKeyName += OUString::createFromAscii( "/UNO/SERVICES" );
+
+ Reference< XRegistryKey > xKey;
+ try
+ {
+ xKey = static_cast< XRegistryKey * >(
+ pRegistryKey )->createKey( aKeyName );
+ }
+ catch ( InvalidRegistryException const & )
+ {
+ }
+
+ if ( !xKey.is() )
+ return sal_False;
+
+ sal_Bool bSuccess = sal_True;
+
+ for ( sal_Int32 n = 0; n < rServiceNames.getLength(); ++n )
+ {
+ try
+ {
+ xKey->createKey( rServiceNames[ n ] );
+ }
+ catch ( InvalidRegistryException const & )
+ {
+ bSuccess = sal_False;
+ break;
+ }
+ }
+ return bSuccess;
+}
+
+//=========================================================================
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//=========================================================================
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ return pRegistryKey &&
+
+ //////////////////////////////////////////////////////////////////////
+ // SortedDynamicResultSetFactory.
+ //////////////////////////////////////////////////////////////////////
+
+ writeInfo( pRegistryKey,
+ SortedDynamicResultSetFactory::getImplementationName_Static(),
+ SortedDynamicResultSetFactory::getSupportedServiceNames_Static() );
+}
+
+//=========================================================================
+extern "C" void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ Reference< XMultiServiceFactory > xSMgr(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
+ Reference< XSingleServiceFactory > xFactory;
+
+ //////////////////////////////////////////////////////////////////////
+ // SortedDynamicResultSetFactory.
+ //////////////////////////////////////////////////////////////////////
+
+ if ( SortedDynamicResultSetFactory::getImplementationName_Static().
+ compareToAscii( pImplName ) == 0 )
+ {
+ xFactory = SortedDynamicResultSetFactory::createServiceFactory( xSMgr );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+
+ return pRet;
+}
+
diff --git a/ucb/source/sorter/sortresult.cxx b/ucb/source/sorter/sortresult.cxx
new file mode 100644
index 000000000000..c65fea5e59ee
--- /dev/null
+++ b/ucb/source/sorter/sortresult.cxx
@@ -0,0 +1,2027 @@
+/*************************************************************************
+ *
+ * $RCSfile: sortresult.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: kso $ $Date: 2000-10-16 14:53:23 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <sortresult.hxx>
+
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_LISTACTIONTYPE_HPP_
+#include <com/sun/star/ucb/ListActionType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XANYCOMPARE_HPP_
+#include <com/sun/star/ucb/XAnyCompare.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UCB_XANYCOMPAREFACTORY_HPP_
+#include <com/sun/star/ucb/XAnyCompareFactory.hpp>
+#endif
+
+#include <tools/debug.hxx>
+
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+
+//-----------------------------------------------------------------------------
+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::sdbc;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::util;
+using namespace cppu;
+using namespace rtl;
+
+//=========================================================================
+
+// The mutex to synchronize access to containers.
+static osl::Mutex& getContainerMutex()
+{
+ static osl::Mutex* pMutex = NULL;
+ if( !pMutex )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pMutex )
+ {
+ static osl::Mutex aMutex;
+ pMutex = &aMutex;
+ }
+ }
+
+ return *pMutex;
+}
+
+//==========================================================================
+
+struct SortInfo
+{
+ BOOL mbUseOwnCompare;
+ BOOL mbAscending;
+ BOOL mbCaseSensitive;
+ sal_Int32 mnColumn;
+ sal_Int32 mnType;
+ SortInfo* mpNext;
+ Reference < XAnyCompare > mxCompareFunction;
+};
+
+//-----------------------------------------------------------------------------
+
+struct SortListData
+{
+ sal_Bool mbModified;
+ long mnCurPos;
+ long mnOldPos;
+
+ SortListData( long nPos, sal_Bool bModified = sal_False );
+};
+
+//============================================================================
+//
+// class SRSPropertySetInfo.
+//
+//============================================================================
+
+class SRSPropertySetInfo :
+ public OWeakObject,
+ public XTypeProvider,
+ public XPropertySetInfo
+{
+ Property maProps[2];
+
+private:
+
+public:
+ SRSPropertySetInfo();
+ virtual ~SRSPropertySetInfo();
+
+ // XInterface
+ XINTERFACE_DECL()
+
+ // XTypeProvider
+ XTYPEPROVIDER_DECL()
+
+ // XPropertySetInfo
+ virtual Sequence< Property > SAL_CALL getProperties()
+ throw( RuntimeException );
+ virtual Property SAL_CALL getPropertyByName( const OUString& aName )
+ throw( UnknownPropertyException, RuntimeException );
+ virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name )
+ throw( RuntimeException );
+};
+
+//=========================================================================
+//
+// PropertyChangeListenerContainer_Impl.
+//
+//=========================================================================
+
+struct equalStr_Impl
+{
+ bool operator()( const OUString& s1, const OUString& s2 ) const
+ {
+ return !!( s1 == s2 );
+ }
+};
+
+struct hashStr_Impl
+{
+ size_t operator()( const OUString& rName ) const
+ {
+ return rName.hashCode();
+ }
+};
+
+typedef OMultiTypeInterfaceContainerHelperVar
+<
+ OUString,
+ hashStr_Impl,
+ equalStr_Impl
+> PropertyChangeListenerContainer_Impl;
+
+//=========================================================================
+//
+// class PropertyChangeListeners_Impl
+//
+//=========================================================================
+
+class PropertyChangeListeners_Impl : public PropertyChangeListenerContainer_Impl
+{
+public:
+ PropertyChangeListeners_Impl()
+ : PropertyChangeListenerContainer_Impl( getContainerMutex() ) {}
+};
+
+//==========================================================================
+SortedResultSet::SortedResultSet( Reference< XResultSet > aResult )
+{
+ mpDisposeEventListeners = NULL;
+ mpPropChangeListeners = NULL;
+ mpVetoChangeListeners = NULL;
+ mpPropSetInfo = NULL;
+
+ mxOriginal = aResult;
+ mpSortInfo = NULL;
+ mnLastSort = 0;
+ mnCurEntry = 0;
+ mnCount = 0;
+ mbIsCopy = FALSE;
+}
+
+//--------------------------------------------------------------------------
+SortedResultSet::~SortedResultSet()
+{
+ mxOriginal.clear();
+ mxOther.clear();
+
+ if ( !mbIsCopy )
+ {
+ SortInfo *pInfo = mpSortInfo;
+ while ( pInfo )
+ {
+ mpSortInfo = pInfo->mpNext;
+ delete pInfo;
+ pInfo = mpSortInfo;
+ }
+ }
+
+ mpSortInfo = NULL;
+
+ if ( mpPropSetInfo )
+ mpPropSetInfo->release();
+
+ delete mpPropChangeListeners;
+ delete mpVetoChangeListeners;
+}
+
+//--------------------------------------------------------------------------
+// XInterface methods.
+//--------------------------------------------------------------------------
+
+XINTERFACE_IMPL_9( SortedResultSet,
+ XTypeProvider,
+ XServiceInfo,
+ XComponent,
+ XContentAccess,
+ XResultSet,
+ XRow,
+ XCloseable,
+ XResultSetMetaDataSupplier,
+ XPropertySet );
+
+//--------------------------------------------------------------------------
+// XTypeProvider methods.
+//--------------------------------------------------------------------------
+
+XTYPEPROVIDER_IMPL_9( SortedResultSet,
+ XTypeProvider,
+ XServiceInfo,
+ XComponent,
+ XContentAccess,
+ XResultSet,
+ XRow,
+ XCloseable,
+ XResultSetMetaDataSupplier,
+ XPropertySet );
+
+//--------------------------------------------------------------------------
+// XServiceInfo methods.
+//--------------------------------------------------------------------------
+
+XSERVICEINFO_NOFACTORY_IMPL_1( SortedResultSet,
+ OUString::createFromAscii( "SortedResultSet" ),
+ OUString::createFromAscii( RESULTSET_SERVICE_NAME ) );
+
+//--------------------------------------------------------------------------
+// XComponent methods.
+//--------------------------------------------------------------------------
+void SAL_CALL SortedResultSet::dispose()
+ throw( RuntimeException )
+{
+ vos::OGuard aGuard( maMutex );
+
+ if ( mpDisposeEventListeners && mpDisposeEventListeners->getLength() )
+ {
+ EventObject aEvt;
+ aEvt.Source = static_cast< XComponent * >( this );
+ mpDisposeEventListeners->disposeAndClear( aEvt );
+ }
+