Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <svtools/svtresid.hxx>
22 : #include <svtools/svtools.hrc>
23 : #include <svtools/indexentryres.hxx>
24 :
25 : // -------------------------------------------------------------------------
26 : //
27 : // wrapper for locale specific translations data of indexentry algorithm
28 : //
29 : // -------------------------------------------------------------------------
30 :
31 : class IndexEntryResourceData
32 : {
33 : friend class IndexEntryResource;
34 : private: /* data */
35 : rtl::OUString ma_Name;
36 : rtl::OUString ma_Translation;
37 : private: /* member functions */
38 0 : IndexEntryResourceData () {}
39 : public:
40 0 : IndexEntryResourceData ( const rtl::OUString &r_Algorithm, const rtl::OUString &r_Translation)
41 0 : : ma_Name (r_Algorithm), ma_Translation (r_Translation) {}
42 :
43 0 : const rtl::OUString& GetAlgorithm () const { return ma_Name; }
44 :
45 0 : const rtl::OUString& GetTranslation () const { return ma_Translation; }
46 :
47 0 : ~IndexEntryResourceData () {}
48 :
49 0 : IndexEntryResourceData& operator= (const IndexEntryResourceData& r_From)
50 : {
51 0 : ma_Name = r_From.GetAlgorithm();
52 0 : ma_Translation = r_From.GetTranslation();
53 0 : return *this;
54 : }
55 : };
56 :
57 : // -------------------------------------------------------------------------
58 : //
59 : // implementation of the indexentry-algorithm-name translation
60 : //
61 : // -------------------------------------------------------------------------
62 :
63 : #define INDEXENTRY_RESOURCE_COUNT (STR_SVT_INDEXENTRY_END - STR_SVT_INDEXENTRY_START + 1)
64 :
65 0 : IndexEntryResource::IndexEntryResource()
66 : {
67 0 : mp_Data = new IndexEntryResourceData[INDEXENTRY_RESOURCE_COUNT];
68 :
69 : #define ASCSTR(str) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(str))
70 : #define RESSTR(rid) SvtResId(rid).toString()
71 :
72 : mp_Data[STR_SVT_INDEXENTRY_ALPHANUMERIC - STR_SVT_INDEXENTRY_START] =
73 0 : IndexEntryResourceData (ASCSTR("alphanumeric"), RESSTR(STR_SVT_INDEXENTRY_ALPHANUMERIC));
74 : mp_Data[STR_SVT_INDEXENTRY_DICTIONARY - STR_SVT_INDEXENTRY_START] =
75 0 : IndexEntryResourceData (ASCSTR("dict"), RESSTR(STR_SVT_INDEXENTRY_DICTIONARY));
76 : mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] =
77 0 : IndexEntryResourceData (ASCSTR("pinyin"), RESSTR(STR_SVT_INDEXENTRY_PINYIN));
78 : mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] =
79 0 : IndexEntryResourceData (ASCSTR("radical"), RESSTR(STR_SVT_INDEXENTRY_RADICAL));
80 : mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] =
81 0 : IndexEntryResourceData (ASCSTR("stroke"), RESSTR(STR_SVT_INDEXENTRY_STROKE));
82 : mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] =
83 0 : IndexEntryResourceData (ASCSTR("zhuyin"), RESSTR(STR_SVT_INDEXENTRY_ZHUYIN));
84 : mp_Data[STR_SVT_INDEXENTRY_ZHUYIN - STR_SVT_INDEXENTRY_START] =
85 : IndexEntryResourceData (ASCSTR("phonetic (alphanumeric first) (grouped by syllable)"),
86 0 : RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FS));
87 : mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FS - STR_SVT_INDEXENTRY_START] =
88 : IndexEntryResourceData (ASCSTR("phonetic (alphanumeric first) (grouped by consonant)"),
89 0 : RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FC));
90 : mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FC - STR_SVT_INDEXENTRY_START] =
91 : IndexEntryResourceData (ASCSTR("phonetic (alphanumeric last) (grouped by syllable)"),
92 0 : RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LS));
93 : mp_Data[STR_SVT_INDEXENTRY_PHONETIC_LS - STR_SVT_INDEXENTRY_START] =
94 : IndexEntryResourceData (ASCSTR("phonetic (alphanumeric last) (grouped by consonant)"),
95 0 : RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LC));
96 0 : }
97 :
98 0 : IndexEntryResource::~IndexEntryResource()
99 : {
100 0 : delete[] mp_Data;
101 0 : }
102 :
103 0 : const rtl::OUString& IndexEntryResource::GetTranslation(const rtl::OUString &r_Algorithm)
104 : {
105 0 : sal_Int32 nIndex = r_Algorithm.indexOf('.');
106 0 : rtl::OUString aLocaleFreeAlgorithm;
107 :
108 0 : if (nIndex == -1)
109 0 : aLocaleFreeAlgorithm = r_Algorithm;
110 : else {
111 0 : nIndex += 1;
112 0 : aLocaleFreeAlgorithm = r_Algorithm.copy(nIndex, r_Algorithm.getLength() - nIndex);
113 : }
114 :
115 0 : for (sal_uInt32 i = 0; i < INDEXENTRY_RESOURCE_COUNT; i++)
116 0 : if (aLocaleFreeAlgorithm == mp_Data[i].GetAlgorithm())
117 0 : return mp_Data[i].GetTranslation();
118 0 : return r_Algorithm;
119 : }
120 :
121 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|