1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 * OpenOffice.org - a multi-platform office productivity suite
8 * This file is part of OpenOffice.org.
10 * OpenOffice.org is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License version 3
12 * only, as published by the Free Software Foundation.
14 * OpenOffice.org is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License version 3 for more details
18 * (a copy is included in the LICENSE file that accompanied this code).
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with OpenOffice.org. If not, see
22 * <http://www.openoffice.org/license.html>
23 * for a copy of the LGPLv3 License.
25 ************************************************************************/
27 #include "precompiled_comphelper.hxx"
29 #include "comphelper/anycompare.hxx"
31 /** === begin UNO includes === **/
32 /** === end UNO includes === **/
34 //......................................................................................................................
37 //......................................................................................................................
39 /** === begin UNO using === **/
40 using ::com::sun::star::uno::Reference
;
41 using ::com::sun::star::uno::XInterface
;
42 using ::com::sun::star::uno::UNO_QUERY
;
43 using ::com::sun::star::uno::UNO_QUERY_THROW
;
44 using ::com::sun::star::uno::UNO_SET_THROW
;
45 using ::com::sun::star::uno::Exception
;
46 using ::com::sun::star::uno::RuntimeException
;
47 using ::com::sun::star::uno::Any
;
48 using ::com::sun::star::uno::makeAny
;
49 using ::com::sun::star::uno::Sequence
;
50 using ::com::sun::star::uno::Type
;
51 using ::com::sun::star::uno::TypeClass_CHAR
;
52 using ::com::sun::star::uno::TypeClass_BOOLEAN
;
53 using ::com::sun::star::uno::TypeClass_BYTE
;
54 using ::com::sun::star::uno::TypeClass_SHORT
;
55 using ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT
;
56 using ::com::sun::star::uno::TypeClass_LONG
;
57 using ::com::sun::star::uno::TypeClass_UNSIGNED_LONG
;
58 using ::com::sun::star::uno::TypeClass_HYPER
;
59 using ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER
;
60 using ::com::sun::star::uno::TypeClass_FLOAT
;
61 using ::com::sun::star::uno::TypeClass_DOUBLE
;
62 using ::com::sun::star::uno::TypeClass_STRING
;
63 using ::com::sun::star::uno::TypeClass_TYPE
;
64 using ::com::sun::star::uno::TypeClass_ENUM
;
65 using ::com::sun::star::uno::TypeClass_INTERFACE
;
66 using ::com::sun::star::i18n::XCollator
;
67 /** === end UNO using === **/
69 //------------------------------------------------------------------------------------------------------------------
70 ::std::auto_ptr
< IKeyPredicateLess
> getStandardLessPredicate( Type
const & i_type
, Reference
< XCollator
> const & i_collator
)
72 ::std::auto_ptr
< IKeyPredicateLess
> pComparator
;
73 switch ( i_type
.getTypeClass() )
76 pComparator
.reset( new ScalarPredicateLess
< sal_Unicode
>() );
78 case TypeClass_BOOLEAN
:
79 pComparator
.reset( new ScalarPredicateLess
< sal_Bool
>() );
82 pComparator
.reset( new ScalarPredicateLess
< sal_Int8
>() );
85 pComparator
.reset( new ScalarPredicateLess
< sal_Int16
>() );
87 case TypeClass_UNSIGNED_SHORT
:
88 pComparator
.reset( new ScalarPredicateLess
< sal_uInt16
>() );
91 pComparator
.reset( new ScalarPredicateLess
< sal_Int32
>() );
93 case TypeClass_UNSIGNED_LONG
:
94 pComparator
.reset( new ScalarPredicateLess
< sal_uInt32
>() );
97 pComparator
.reset( new ScalarPredicateLess
< sal_Int64
>() );
99 case TypeClass_UNSIGNED_HYPER
:
100 pComparator
.reset( new ScalarPredicateLess
< sal_uInt64
>() );
102 case TypeClass_FLOAT
:
103 pComparator
.reset( new ScalarPredicateLess
< float >() );
105 case TypeClass_DOUBLE
:
106 pComparator
.reset( new ScalarPredicateLess
< double >() );
108 case TypeClass_STRING
:
109 if ( i_collator
.is() )
110 pComparator
.reset( new StringCollationPredicateLess( i_collator
) );
112 pComparator
.reset( new StringPredicateLess() );
115 pComparator
.reset( new TypePredicateLess() );
118 pComparator
.reset( new EnumPredicateLess( i_type
) );
120 case TypeClass_INTERFACE
:
121 pComparator
.reset( new InterfacePredicateLess() );
129 //......................................................................................................................
130 } // namespace comphelper
131 //......................................................................................................................