CWS-TOOLING: integrate CWS os146
[LibreOffice.git] / comphelper / source / misc / anycompare.cxx
bloba86174daf08e75041732471c0d704f6868f32b8f
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 //......................................................................................................................
35 namespace comphelper
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() )
75 case TypeClass_CHAR:
76 pComparator.reset( new ScalarPredicateLess< sal_Unicode >() );
77 break;
78 case TypeClass_BOOLEAN:
79 pComparator.reset( new ScalarPredicateLess< sal_Bool >() );
80 break;
81 case TypeClass_BYTE:
82 pComparator.reset( new ScalarPredicateLess< sal_Int8 >() );
83 break;
84 case TypeClass_SHORT:
85 pComparator.reset( new ScalarPredicateLess< sal_Int16 >() );
86 break;
87 case TypeClass_UNSIGNED_SHORT:
88 pComparator.reset( new ScalarPredicateLess< sal_uInt16 >() );
89 break;
90 case TypeClass_LONG:
91 pComparator.reset( new ScalarPredicateLess< sal_Int32 >() );
92 break;
93 case TypeClass_UNSIGNED_LONG:
94 pComparator.reset( new ScalarPredicateLess< sal_uInt32 >() );
95 break;
96 case TypeClass_HYPER:
97 pComparator.reset( new ScalarPredicateLess< sal_Int64 >() );
98 break;
99 case TypeClass_UNSIGNED_HYPER:
100 pComparator.reset( new ScalarPredicateLess< sal_uInt64 >() );
101 break;
102 case TypeClass_FLOAT:
103 pComparator.reset( new ScalarPredicateLess< float >() );
104 break;
105 case TypeClass_DOUBLE:
106 pComparator.reset( new ScalarPredicateLess< double >() );
107 break;
108 case TypeClass_STRING:
109 if ( i_collator.is() )
110 pComparator.reset( new StringCollationPredicateLess( i_collator ) );
111 else
112 pComparator.reset( new StringPredicateLess() );
113 break;
114 case TypeClass_TYPE:
115 pComparator.reset( new TypePredicateLess() );
116 break;
117 case TypeClass_ENUM:
118 pComparator.reset( new EnumPredicateLess( i_type ) );
119 break;
120 case TypeClass_INTERFACE:
121 pComparator.reset( new InterfacePredicateLess() );
122 break;
123 default:
124 break;
126 return pComparator;
129 //......................................................................................................................
130 } // namespace comphelper
131 //......................................................................................................................