GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / svtools / source / control / indexentryres.cxx
blobc80507f015a73821549801814b1d89dec195dd49
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <svtools/svtresid.hxx>
22 #include <svtools/svtools.hrc>
23 #include <svtools/indexentryres.hxx>
25 // -------------------------------------------------------------------------
27 // wrapper for locale specific translations data of indexentry algorithm
29 // -------------------------------------------------------------------------
31 class IndexEntryResourceData
33 friend class IndexEntryResource;
34 private: /* data */
35 OUString ma_Name;
36 OUString ma_Translation;
37 private: /* member functions */
38 IndexEntryResourceData () {}
39 public:
40 IndexEntryResourceData ( const OUString &r_Algorithm, const OUString &r_Translation)
41 : ma_Name (r_Algorithm), ma_Translation (r_Translation) {}
43 const OUString& GetAlgorithm () const { return ma_Name; }
45 const OUString& GetTranslation () const { return ma_Translation; }
47 ~IndexEntryResourceData () {}
49 IndexEntryResourceData& operator= (const IndexEntryResourceData& r_From)
51 ma_Name = r_From.GetAlgorithm();
52 ma_Translation = r_From.GetTranslation();
53 return *this;
57 // -------------------------------------------------------------------------
59 // implementation of the indexentry-algorithm-name translation
61 // -------------------------------------------------------------------------
63 #define INDEXENTRY_RESOURCE_COUNT (STR_SVT_INDEXENTRY_END - STR_SVT_INDEXENTRY_START + 1)
65 IndexEntryResource::IndexEntryResource()
67 mp_Data = new IndexEntryResourceData[INDEXENTRY_RESOURCE_COUNT];
69 #define RESSTR(rid) SvtResId(rid).toString()
71 mp_Data[STR_SVT_INDEXENTRY_ALPHANUMERIC - STR_SVT_INDEXENTRY_START] =
72 IndexEntryResourceData ("alphanumeric", RESSTR(STR_SVT_INDEXENTRY_ALPHANUMERIC));
73 mp_Data[STR_SVT_INDEXENTRY_DICTIONARY - STR_SVT_INDEXENTRY_START] =
74 IndexEntryResourceData ("dict", RESSTR(STR_SVT_INDEXENTRY_DICTIONARY));
75 mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] =
76 IndexEntryResourceData ("pinyin", RESSTR(STR_SVT_INDEXENTRY_PINYIN));
77 mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] =
78 IndexEntryResourceData ("radical", RESSTR(STR_SVT_INDEXENTRY_RADICAL));
79 mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] =
80 IndexEntryResourceData ("stroke", RESSTR(STR_SVT_INDEXENTRY_STROKE));
81 mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] =
82 IndexEntryResourceData ("zhuyin", RESSTR(STR_SVT_INDEXENTRY_ZHUYIN));
83 mp_Data[STR_SVT_INDEXENTRY_ZHUYIN - STR_SVT_INDEXENTRY_START] =
84 IndexEntryResourceData ("phonetic (alphanumeric first) (grouped by syllable)",
85 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FS));
86 mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FS - STR_SVT_INDEXENTRY_START] =
87 IndexEntryResourceData ("phonetic (alphanumeric first) (grouped by consonant)",
88 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FC));
89 mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FC - STR_SVT_INDEXENTRY_START] =
90 IndexEntryResourceData ("phonetic (alphanumeric last) (grouped by syllable)",
91 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LS));
92 mp_Data[STR_SVT_INDEXENTRY_PHONETIC_LS - STR_SVT_INDEXENTRY_START] =
93 IndexEntryResourceData ("phonetic (alphanumeric last) (grouped by consonant)",
94 RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LC));
97 IndexEntryResource::~IndexEntryResource()
99 delete[] mp_Data;
102 const OUString& IndexEntryResource::GetTranslation(const OUString &r_Algorithm)
104 sal_Int32 nIndex = r_Algorithm.indexOf('.');
105 OUString aLocaleFreeAlgorithm;
107 if (nIndex == -1)
108 aLocaleFreeAlgorithm = r_Algorithm;
109 else {
110 nIndex += 1;
111 aLocaleFreeAlgorithm = r_Algorithm.copy(nIndex, r_Algorithm.getLength() - nIndex);
114 for (sal_uInt32 i = 0; i < INDEXENTRY_RESOURCE_COUNT; i++)
115 if (aLocaleFreeAlgorithm == mp_Data[i].GetAlgorithm())
116 return mp_Data[i].GetTranslation();
117 return r_Algorithm;
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */