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: indexentryres.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 <indexentryres.hxx>
40 // -------------------------------------------------------------------------
42 // wrapper for locale specific translations data of indexentry algorithm
44 // -------------------------------------------------------------------------
46 class IndexEntryRessourceData
48 friend class IndexEntryRessource
;
51 String ma_Translation
;
52 private: /* member functions */
53 IndexEntryRessourceData () {}
55 IndexEntryRessourceData ( 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 ~IndexEntryRessourceData () {}
64 IndexEntryRessourceData
& operator= (const IndexEntryRessourceData
& r_From
)
66 ma_Name
= r_From
.GetAlgorithm();
67 ma_Translation
= r_From
.GetTranslation();
72 // -------------------------------------------------------------------------
74 // implementation of the indexentry-algorithm-name translation
76 // -------------------------------------------------------------------------
78 #define INDEXENTRY_RESSOURCE_COUNT (STR_SVT_INDEXENTRY_END - STR_SVT_INDEXENTRY_START + 1)
80 IndexEntryRessource::IndexEntryRessource()
82 mp_Data
= new IndexEntryRessourceData
[INDEXENTRY_RESSOURCE_COUNT
];
84 #define ASCSTR(str) String(RTL_CONSTASCII_USTRINGPARAM(str))
85 #define RESSTR(rid) String(SvtResId(rid))
87 mp_Data
[STR_SVT_INDEXENTRY_ALPHANUMERIC
- STR_SVT_INDEXENTRY_START
] =
88 IndexEntryRessourceData (ASCSTR("alphanumeric"), RESSTR(STR_SVT_INDEXENTRY_ALPHANUMERIC
));
89 mp_Data
[STR_SVT_INDEXENTRY_DICTIONARY
- STR_SVT_INDEXENTRY_START
] =
90 IndexEntryRessourceData (ASCSTR("dict"), RESSTR(STR_SVT_INDEXENTRY_DICTIONARY
));
91 mp_Data
[STR_SVT_INDEXENTRY_PINYIN
- STR_SVT_INDEXENTRY_START
] =
92 IndexEntryRessourceData (ASCSTR("pinyin"), RESSTR(STR_SVT_INDEXENTRY_PINYIN
));
93 mp_Data
[STR_SVT_INDEXENTRY_PINYIN
- STR_SVT_INDEXENTRY_START
] =
94 IndexEntryRessourceData (ASCSTR("radical"), RESSTR(STR_SVT_INDEXENTRY_RADICAL
));
95 mp_Data
[STR_SVT_INDEXENTRY_STROKE
- STR_SVT_INDEXENTRY_START
] =
96 IndexEntryRessourceData (ASCSTR("stroke"), RESSTR(STR_SVT_INDEXENTRY_STROKE
));
97 mp_Data
[STR_SVT_INDEXENTRY_STROKE
- STR_SVT_INDEXENTRY_START
] =
98 IndexEntryRessourceData (ASCSTR("zhuyin"), RESSTR(STR_SVT_INDEXENTRY_ZHUYIN
));
99 mp_Data
[STR_SVT_INDEXENTRY_ZHUYIN
- STR_SVT_INDEXENTRY_START
] =
100 IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric first) (grouped by syllable)"),
101 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FS
));
102 mp_Data
[STR_SVT_INDEXENTRY_PHONETIC_FS
- STR_SVT_INDEXENTRY_START
] =
103 IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric first) (grouped by consonant)"),
104 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FC
));
105 mp_Data
[STR_SVT_INDEXENTRY_PHONETIC_FC
- STR_SVT_INDEXENTRY_START
] =
106 IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric last) (grouped by syllable)"),
107 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LS
));
108 mp_Data
[STR_SVT_INDEXENTRY_PHONETIC_LS
- STR_SVT_INDEXENTRY_START
] =
109 IndexEntryRessourceData (ASCSTR("phonetic (alphanumeric last) (grouped by consonant)"),
110 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LC
));
113 IndexEntryRessource::~IndexEntryRessource()
119 IndexEntryRessource::GetTranslation (const String
&r_Algorithm
)
121 xub_StrLen nIndex
= r_Algorithm
.Search('.');
122 String aLocaleFreeAlgorithm
;
124 if (nIndex
== STRING_NOTFOUND
)
125 aLocaleFreeAlgorithm
= r_Algorithm
;
128 aLocaleFreeAlgorithm
= String(r_Algorithm
, nIndex
, r_Algorithm
.Len() - nIndex
);
131 for (sal_uInt32 i
= 0; i
< INDEXENTRY_RESSOURCE_COUNT
; i
++)
132 if (aLocaleFreeAlgorithm
== mp_Data
[i
].GetAlgorithm())
133 return mp_Data
[i
].GetTranslation();