1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_i18npool.hxx"
30 #include <comphelper/processfactory.hxx>
32 #include "ordinalsuffix.hxx"
35 using namespace ::com::sun::star::i18n
;
36 using namespace ::com::sun::star::uno
;
37 using namespace ::com::sun::star::lang
;
38 using namespace ::rtl
;
40 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{
43 OrdinalSuffix::OrdinalSuffix(
44 const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& rxMSF
) :
45 _xServiceManager( rxMSF
)
49 OrdinalSuffix::~OrdinalSuffix()
54 static OUString
getOrdinalSuffixEn( sal_Int32 nNumber
)
58 switch( labs( nNumber
) % 100 )
60 case 11: case 12: case 13:
61 retValue
= OUString::createFromAscii( "th" );
64 switch( nNumber
% 10 )
67 retValue
= OUString::createFromAscii( "st" );
70 retValue
= OUString::createFromAscii( "nd" );
73 retValue
= OUString::createFromAscii( "rd" );
76 retValue
= OUString::createFromAscii( "th" );
86 OUString SAL_CALL
OrdinalSuffix::getOrdinalSuffix( sal_Int32 nNumber
,
87 const Locale
&aLocale
) throw( RuntimeException
)
91 if (aLocale
.Language
.equalsAsciiL("en",2))
92 retValue
= getOrdinalSuffixEn( nNumber
);
98 const sal_Char cOrdinalSuffix
[] = "com.sun.star.i18n.OrdinalSuffix";
100 OUString SAL_CALL
OrdinalSuffix::getImplementationName(void) throw( RuntimeException
)
102 return OUString::createFromAscii(cOrdinalSuffix
);
105 sal_Bool SAL_CALL
OrdinalSuffix::supportsService( const OUString
& rServiceName
) throw( RuntimeException
)
107 return !rServiceName
.compareToAscii(cOrdinalSuffix
);
110 Sequence
< OUString
> SAL_CALL
OrdinalSuffix::getSupportedServiceNames(void) throw( RuntimeException
)
112 Sequence
< OUString
> aRet(1);
113 aRet
[0] = OUString::createFromAscii(cOrdinalSuffix
);