summaryrefslogtreecommitdiffstats
path: root/comphelper
diff options
context:
space:
mode:
authorMikhail Voitenko <mav@openoffice.org>2002-01-11 16:48:39 +0000
committerMikhail Voitenko <mav@openoffice.org>2002-01-11 16:48:39 +0000
commit1ff989c14074572ee33d30b4bf162f7012c775b7 (patch)
treed108c4d53eceeb92e0c3a2558d2f33955510bd2f /comphelper
parentspeed up writing of stream by 25-60 (diff)
downloadcore-1ff989c14074572ee33d30b4bf162f7012c775b7.tar.gz
core-1ff989c14074572ee33d30b4bf162f7012c775b7.zip
#95512# new AnyCompareFactory service implementation
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/prj/build.lst3
-rw-r--r--comphelper/source/compare/AnyCompareFactory.cxx229
-rw-r--r--comphelper/source/compare/makefile.mk81
-rw-r--r--comphelper/source/misc/facreg.cxx19
-rw-r--r--comphelper/util/makefile.mk7
5 files changed, 333 insertions, 6 deletions
diff --git a/comphelper/prj/build.lst b/comphelper/prj/build.lst
index 7f36e0bd4c4f..5dc80ad3079c 100644
--- a/comphelper/prj/build.lst
+++ b/comphelper/prj/build.lst
@@ -6,4 +6,5 @@ ph comphelper\source\misc nmake - all ph_misc NULL
ph comphelper\source\processfactory nmake - all ph_procfact NULL
ph comphelper\source\property nmake - all ph_property NULL
ph comphelper\source\streaming nmake - all ph_streaming NULL
-ph comphelper\util nmake - all ph_util ph_container ph_evtatmgr ph_misc ph_procfact ph_property ph_streaming NULL
+ph comphelper\source\compare nmake - all ph_compare NULL
+ph comphelper\util nmake - all ph_util ph_container ph_evtatmgr ph_misc ph_procfact ph_property ph_streaming ph_compare NULL
diff --git a/comphelper/source/compare/AnyCompareFactory.cxx b/comphelper/source/compare/AnyCompareFactory.cxx
new file mode 100644
index 000000000000..8e1ca1a6a6c4
--- /dev/null
+++ b/comphelper/source/compare/AnyCompareFactory.cxx
@@ -0,0 +1,229 @@
+/*************************************************************************
+ *
+ * $RCSfile: AnyCompareFactory.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: mav $ $Date: 2002-01-11 17:48:39 $
+ *
+ * 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_UCB_XANYCOMPAREFACTORY_HPP_
+#include <com/sun/star/ucb/XAnyCompareFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_I18N_XCOLLATOR_HPP_
+#include <com/sun/star/i18n/XCollator.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
+#include <com/sun/star/lang/Locale.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
+#include <com/sun/star/uno/Sequence.h>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COMPHELPER_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#ifndef __SGI_STL_MAP
+#include <map>
+#endif
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::i18n;
+using namespace rtl;
+
+//=============================================================================
+
+class AnyCompare : public ::cppu::WeakImplHelper1< XAnyCompare >
+{
+ Reference< XCollator > m_rCollator;
+
+public:
+ AnyCompare( Reference< XMultiServiceFactory > xFactory, const Locale& rLocale ) throw()
+ {
+ m_rCollator = Reference< XCollator >(
+ xFactory->createInstance( OUString::createFromAscii( "com.sun.star.i18n.Collator" ) ),
+ UNO_QUERY );
+
+ m_rCollator->loadDefaultCollator( rLocale,
+ 0 ); //???
+
+ }
+
+ virtual sal_Int16 SAL_CALL compare( const Any& any1, const Any& any2 ) throw();
+};
+
+//=============================================================================
+
+Sequence< rtl::OUString > SAL_CALL AnyCompareFactory_getSupportedServiceNames() throw();
+rtl::OUString SAL_CALL AnyCompareFactory_getImplementationName() throw();
+Reference< XInterface > SAL_CALL AnyCompareFactory_createInstance(
+ const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception );
+
+class AnyCompareFactory : public cppu::WeakImplHelper3< XAnyCompareFactory, XInitialization, XServiceInfo >
+{
+ Reference< XAnyCompare > m_rAnyCompare;
+ Reference< XMultiServiceFactory > m_rFactory;
+ Locale m_Locale;
+
+public:
+ AnyCompareFactory( Reference< XMultiServiceFactory > xFactory ) : m_rFactory( xFactory )
+ {
+ }
+
+ // XAnyCompareFactory
+ virtual Reference< XAnyCompare > SAL_CALL createAnyCompareByName ( const OUString& aPropertyName ) throw();
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments )
+ throw ( Exception, RuntimeException );
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
+};
+
+//===========================================================================================
+
+sal_Int16 SAL_CALL AnyCompare::compare( const Any& any1, const Any& any2 ) throw()
+{
+ sal_Int16 aResult = 0;
+
+ if( m_rCollator.is() )
+ {
+ OUString aStr1;
+ OUString aStr2;
+
+ any1 >>= aStr1;
+ any2 >>= aStr2;
+
+ aResult = ( sal_Int16 )m_rCollator->compareString( aStr1, aStr2 );
+ }
+
+ return aResult;
+}
+
+//===========================================================================================
+
+Reference< XAnyCompare > SAL_CALL AnyCompareFactory::createAnyCompareByName( const OUString& aPropertyName ) throw()
+{
+ // for now only OUString properties compare is implemented
+ // so no check for the property name is done
+
+ return m_rAnyCompare;
+}
+
+void SAL_CALL AnyCompareFactory::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
+{
+ if( aArguments.getLength() )
+ {
+ aArguments[0] >>= m_Locale;
+ m_rAnyCompare = new AnyCompare( m_rFactory, m_Locale );
+ }
+}
+
+OUString SAL_CALL AnyCompareFactory::getImplementationName( ) throw( RuntimeException )
+{
+ return AnyCompareFactory_getImplementationName();
+}
+
+sal_Bool SAL_CALL AnyCompareFactory::supportsService( const OUString& ServiceName ) throw(RuntimeException)
+{
+ rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.NamedPropertyValues" ) );
+ return aServiceName == ServiceName;
+}
+
+Sequence< OUString > SAL_CALL AnyCompareFactory::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return AnyCompareFactory_getSupportedServiceNames();
+}
+
+
+Sequence< rtl::OUString > SAL_CALL AnyCompareFactory_getSupportedServiceNames() throw()
+{
+ const rtl::OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.AnyCompareFactory" ) );
+ const Sequence< rtl::OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+rtl::OUString SAL_CALL AnyCompareFactory_getImplementationName() throw()
+{
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AnyCompareFactory" ) );
+}
+
+Reference< XInterface > SAL_CALL AnyCompareFactory_createInstance(
+ const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception )
+{
+ return (cppu::OWeakObject*)new AnyCompareFactory( rSMgr );
+}
+
diff --git a/comphelper/source/compare/makefile.mk b/comphelper/source/compare/makefile.mk
new file mode 100644
index 000000000000..a469a87d9c0e
--- /dev/null
+++ b/comphelper/source/compare/makefile.mk
@@ -0,0 +1,81 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: mav $ $Date: 2002-01-11 17:48:39 $
+#
+# 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=..$/..
+PRJINC=..$/..$/inc
+PRJNAME=comphelper
+TARGET=compare
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+
+SLOFILES=$(SLO)$/AnyCompareFactory.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/comphelper/source/misc/facreg.cxx b/comphelper/source/misc/facreg.cxx
index 0ba1570b96c3..cc60ccb40a8c 100644
--- a/comphelper/source/misc/facreg.cxx
+++ b/comphelper/source/misc/facreg.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: facreg.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jl $ $Date: 2001-03-22 13:30:49 $
+ * last change: $Author: mav $ $Date: 2002-01-11 17:47:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,6 +85,12 @@ extern uno::Sequence< OUString > SAL_CALL NamedPropertyValuesContainer_getSuppor
extern OUString SAL_CALL NamedPropertyValuesContainer_getImplementationName() throw();
extern uno::Reference< uno::XInterface > SAL_CALL NamedPropertyValuesContainer_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+// NamedPropertyValuesContainer
+extern uno::Sequence< OUString > SAL_CALL AnyCompareFactory_getSupportedServiceNames() throw();
+extern OUString SAL_CALL AnyCompareFactory_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL AnyCompareFactory_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+
//
#ifdef __cplusplus
extern "C"
@@ -118,6 +124,7 @@ sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryK
writeInfo( pKey, IndexedPropertyValuesContainer_getImplementationName(), IndexedPropertyValuesContainer_getSupportedServiceNames() );
// NamedPropertyValuesContainer
writeInfo( pKey, NamedPropertyValuesContainer_getImplementationName(), NamedPropertyValuesContainer_getSupportedServiceNames() );
+ writeInfo( pKey, AnyCompareFactory_getImplementationName(), AnyCompareFactory_getSupportedServiceNames() );
}
catch (registry::InvalidRegistryException &)
{
@@ -151,6 +158,14 @@ void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServic
NamedPropertyValuesContainer_createInstance,
NamedPropertyValuesContainer_getSupportedServiceNames() );
}
+ else if( AnyCompareFactory_getImplementationName().equalsAsciiL( pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ AnyCompareFactory_getImplementationName(),
+ AnyCompareFactory_createInstance,
+ AnyCompareFactory_getSupportedServiceNames() );
+ }
+
if( xFactory.is())
{
xFactory->acquire();
diff --git a/comphelper/util/makefile.mk b/comphelper/util/makefile.mk
index aa01d6e91239..f3d60545ebe3 100644
--- a/comphelper/util/makefile.mk
+++ b/comphelper/util/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: mtg $ $Date: 2001-03-14 12:16:24 $
+# last change: $Author: mav $ $Date: 2002-01-11 17:46:39 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -79,7 +79,8 @@ LIB1FILES= $(SLB)$/container.lib \
$(SLB)$/misc.lib \
$(SLB)$/processfactory.lib \
$(SLB)$/property.lib \
- $(SLB)$/streaming.lib
+ $(SLB)$/streaming.lib \
+ $(SLB)$/compare.lib
LIB1TARGET=$(SLB)$/$(TARGET).lib