summaryrefslogtreecommitdiff
path: root/ucb/source/core
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/core
parent4ab353132a0d57510151f9844d8c2012feca0dad (diff)
Moved here from module 'chaos'.
Diffstat (limited to 'ucb/source/core')
-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
13 files changed, 5707 insertions, 0 deletions
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 */