1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: collatorres.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_svtools.hxx"
34 #include <svtools/svtdata.hxx>
35 #include <svtools/svtools.hrc>
38 #include <collatorres.hxx>
40 // -------------------------------------------------------------------------
42 // wrapper for locale specific translations data of collator algorithm
44 // -------------------------------------------------------------------------
46 class CollatorRessourceData
48 friend class CollatorRessource
;
51 String ma_Translation
;
52 private: /* member functions */
53 CollatorRessourceData () {}
55 CollatorRessourceData ( const String
&r_Algorithm
, const String
&r_Translation
)
56 : ma_Name (r_Algorithm
), ma_Translation (r_Translation
) {}
58 const String
& GetAlgorithm () const { return ma_Name
; }
60 const String
& GetTranslation () const { return ma_Translation
; }
62 ~CollatorRessourceData () {}
64 CollatorRessourceData
& operator= (const CollatorRessourceData
& r_From
)
66 ma_Name
= r_From
.GetAlgorithm();
67 ma_Translation
= r_From
.GetTranslation();
72 // -------------------------------------------------------------------------
74 // implementation of the collator-algorithm-name translation
76 // -------------------------------------------------------------------------
78 #define COLLATOR_RESSOURCE_COUNT (STR_SVT_COLLATE_END - STR_SVT_COLLATE_START + 1)
80 CollatorRessource::CollatorRessource()
82 mp_Data
= new CollatorRessourceData
[COLLATOR_RESSOURCE_COUNT
];
84 #define ASCSTR(str) String(RTL_CONSTASCII_USTRINGPARAM(str))
85 #define RESSTR(rid) String(SvtResId(rid))
88 mp_Data
[0] = CollatorRessourceData (ASCSTR("alphanumeric"), RESSTR(STR_SVT_COLLATE_ALPHANUMERIC
));
89 mp_Data
[1] = CollatorRessourceData (ASCSTR("charset"), RESSTR(STR_SVT_COLLATE_CHARSET
));
90 mp_Data
[2] = CollatorRessourceData (ASCSTR("dict"), RESSTR(STR_SVT_COLLATE_DICTIONARY
));
91 mp_Data
[3] = CollatorRessourceData (ASCSTR("normal"), RESSTR(STR_SVT_COLLATE_NORMAL
));
92 mp_Data
[4] = CollatorRessourceData (ASCSTR("pinyin"), RESSTR(STR_SVT_COLLATE_PINYIN
));
93 mp_Data
[5] = CollatorRessourceData (ASCSTR("radical"), RESSTR(STR_SVT_COLLATE_RADICAL
));
94 mp_Data
[6] = CollatorRessourceData (ASCSTR("stroke"), RESSTR(STR_SVT_COLLATE_STROKE
));
95 mp_Data
[7] = CollatorRessourceData (ASCSTR("unicode"), RESSTR(STR_SVT_COLLATE_UNICODE
));
96 mp_Data
[8] = CollatorRessourceData (ASCSTR("zhuyin"), RESSTR(STR_SVT_COLLATE_ZHUYIN
));
97 mp_Data
[9] = CollatorRessourceData (ASCSTR("phonebook"), RESSTR(STR_SVT_COLLATE_PHONEBOOK
));
98 mp_Data
[10] = CollatorRessourceData (ASCSTR("phonetic (alphanumeric first)"), RESSTR(STR_SVT_COLLATE_PHONETIC_F
));
99 mp_Data
[11] = CollatorRessourceData (ASCSTR("phonetic (alphanumeric last)"), RESSTR(STR_SVT_COLLATE_PHONETIC_L
));
102 CollatorRessource::~CollatorRessource()
108 CollatorRessource::GetTranslation (const String
&r_Algorithm
)
110 xub_StrLen nIndex
= r_Algorithm
.Search('.');
111 String aLocaleFreeAlgorithm
;
113 if (nIndex
== STRING_NOTFOUND
)
115 aLocaleFreeAlgorithm
= r_Algorithm
;
120 aLocaleFreeAlgorithm
= String(r_Algorithm
, nIndex
, r_Algorithm
.Len() - nIndex
);
123 for (sal_uInt32 i
= 0; i
< COLLATOR_RESSOURCE_COUNT
; i
++)
125 if (aLocaleFreeAlgorithm
== mp_Data
[i
].GetAlgorithm())
126 return mp_Data
[i
].GetTranslation();