Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <svtools/svtresid.hxx>
31 : : #include <svtools/svtools.hrc>
32 : : #include <svtools/collatorres.hxx>
33 : :
34 : : // -------------------------------------------------------------------------
35 : : //
36 : : // wrapper for locale specific translations data of collator algorithm
37 : : //
38 : : // -------------------------------------------------------------------------
39 : :
40 : : class CollatorResourceData
41 : : {
42 : : friend class CollatorResource;
43 : : private: /* data */
44 : : rtl::OUString ma_Name;
45 : : rtl::OUString ma_Translation;
46 : : private: /* member functions */
47 : 0 : CollatorResourceData () {}
48 : : public:
49 : 0 : CollatorResourceData ( const rtl::OUString &r_Algorithm, const rtl::OUString &r_Translation)
50 : 0 : : ma_Name (r_Algorithm), ma_Translation (r_Translation) {}
51 : :
52 : 0 : const rtl::OUString& GetAlgorithm () const { return ma_Name; }
53 : :
54 : 0 : const rtl::OUString& GetTranslation () const { return ma_Translation; }
55 : :
56 : 0 : ~CollatorResourceData () {}
57 : :
58 : 0 : CollatorResourceData& operator= (const CollatorResourceData& r_From)
59 : : {
60 : 0 : ma_Name = r_From.GetAlgorithm();
61 : 0 : ma_Translation = r_From.GetTranslation();
62 : 0 : return *this;
63 : : }
64 : : };
65 : :
66 : : // -------------------------------------------------------------------------
67 : : //
68 : : // implementation of the collator-algorithm-name translation
69 : : //
70 : : // -------------------------------------------------------------------------
71 : :
72 : : #define COLLATOR_RESOURCE_COUNT (STR_SVT_COLLATE_END - STR_SVT_COLLATE_START + 1)
73 : :
74 : 0 : CollatorResource::CollatorResource()
75 : : {
76 [ # # ]: 0 : mp_Data = new CollatorResourceData[COLLATOR_RESOURCE_COUNT];
77 : :
78 : : #define ASCSTR(str) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(str))
79 : : #define RESSTR(rid) SvtResId(rid).toString()
80 : :
81 [ # # ][ # # ]: 0 : mp_Data[0] = CollatorResourceData (ASCSTR("alphanumeric"), RESSTR(STR_SVT_COLLATE_ALPHANUMERIC));
82 [ # # ][ # # ]: 0 : mp_Data[1] = CollatorResourceData (ASCSTR("charset"), RESSTR(STR_SVT_COLLATE_CHARSET));
83 [ # # ][ # # ]: 0 : mp_Data[2] = CollatorResourceData (ASCSTR("dict"), RESSTR(STR_SVT_COLLATE_DICTIONARY));
84 [ # # ][ # # ]: 0 : mp_Data[3] = CollatorResourceData (ASCSTR("normal"), RESSTR(STR_SVT_COLLATE_NORMAL));
85 [ # # ][ # # ]: 0 : mp_Data[4] = CollatorResourceData (ASCSTR("pinyin"), RESSTR(STR_SVT_COLLATE_PINYIN));
86 [ # # ][ # # ]: 0 : mp_Data[5] = CollatorResourceData (ASCSTR("radical"), RESSTR(STR_SVT_COLLATE_RADICAL));
87 [ # # ][ # # ]: 0 : mp_Data[6] = CollatorResourceData (ASCSTR("stroke"), RESSTR(STR_SVT_COLLATE_STROKE));
88 [ # # ][ # # ]: 0 : mp_Data[7] = CollatorResourceData (ASCSTR("unicode"), RESSTR(STR_SVT_COLLATE_UNICODE));
89 [ # # ][ # # ]: 0 : mp_Data[8] = CollatorResourceData (ASCSTR("zhuyin"), RESSTR(STR_SVT_COLLATE_ZHUYIN));
90 [ # # ][ # # ]: 0 : mp_Data[9] = CollatorResourceData (ASCSTR("phonebook"), RESSTR(STR_SVT_COLLATE_PHONEBOOK));
91 [ # # ][ # # ]: 0 : mp_Data[10] = CollatorResourceData (ASCSTR("phonetic (alphanumeric first)"), RESSTR(STR_SVT_COLLATE_PHONETIC_F));
92 [ # # ][ # # ]: 0 : mp_Data[11] = CollatorResourceData (ASCSTR("phonetic (alphanumeric last)"), RESSTR(STR_SVT_COLLATE_PHONETIC_L));
93 : 0 : }
94 : :
95 : 0 : CollatorResource::~CollatorResource()
96 : : {
97 [ # # ][ # # ]: 0 : delete[] mp_Data;
98 : 0 : }
99 : :
100 : : const rtl::OUString&
101 : 0 : CollatorResource::GetTranslation(const rtl::OUString &r_Algorithm)
102 : : {
103 : 0 : sal_Int32 nIndex = r_Algorithm.indexOf('.');
104 : 0 : rtl::OUString aLocaleFreeAlgorithm;
105 : :
106 [ # # ]: 0 : if (nIndex == -1)
107 : : {
108 : 0 : aLocaleFreeAlgorithm = r_Algorithm;
109 : : }
110 : : else
111 : : {
112 : 0 : nIndex += 1;
113 : 0 : aLocaleFreeAlgorithm = r_Algorithm.copy(nIndex, r_Algorithm.getLength() - nIndex);
114 : : }
115 : :
116 [ # # ]: 0 : for (sal_uInt32 i = 0; i < COLLATOR_RESOURCE_COUNT; i++)
117 : : {
118 [ # # ]: 0 : if (aLocaleFreeAlgorithm == mp_Data[i].GetAlgorithm())
119 : 0 : return mp_Data[i].GetTranslation();
120 : : }
121 : :
122 : 0 : return r_Algorithm;
123 : : }
124 : :
125 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|