Bump version to 5.0-14
[LibreOffice.git] / svtools / source / control / collatorres.cxx
blobeb345a30e139c08fbee0c692876645e2633a5a6f
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/collatorres.hxx>
27 // wrapper for locale specific translations data of collator algorithm
31 class CollatorResourceData
33 friend class CollatorResource;
34 private: /* data */
35 OUString ma_Name;
36 OUString ma_Translation;
37 private: /* member functions */
38 CollatorResourceData () {}
39 public:
40 CollatorResourceData ( 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 ~CollatorResourceData () {}
49 CollatorResourceData& operator= (const CollatorResourceData& r_From)
51 ma_Name = r_From.GetAlgorithm();
52 ma_Translation = r_From.GetTranslation();
53 return *this;
59 // implementation of the collator-algorithm-name translation
63 #define COLLATOR_RESOURCE_COUNT (STR_SVT_COLLATE_END - STR_SVT_COLLATE_START + 1)
65 CollatorResource::CollatorResource()
67 mp_Data = new CollatorResourceData[COLLATOR_RESOURCE_COUNT];
69 #define RESSTR(rid) SvtResId(rid).toString()
71 mp_Data[0] = CollatorResourceData ("alphanumeric", RESSTR(STR_SVT_COLLATE_ALPHANUMERIC));
72 mp_Data[1] = CollatorResourceData ("charset", RESSTR(STR_SVT_COLLATE_CHARSET));
73 mp_Data[2] = CollatorResourceData ("dict", RESSTR(STR_SVT_COLLATE_DICTIONARY));
74 mp_Data[3] = CollatorResourceData ("normal", RESSTR(STR_SVT_COLLATE_NORMAL));
75 mp_Data[4] = CollatorResourceData ("pinyin", RESSTR(STR_SVT_COLLATE_PINYIN));
76 mp_Data[5] = CollatorResourceData ("radical", RESSTR(STR_SVT_COLLATE_RADICAL));
77 mp_Data[6] = CollatorResourceData ("stroke", RESSTR(STR_SVT_COLLATE_STROKE));
78 mp_Data[7] = CollatorResourceData ("unicode", RESSTR(STR_SVT_COLLATE_UNICODE));
79 mp_Data[8] = CollatorResourceData ("zhuyin", RESSTR(STR_SVT_COLLATE_ZHUYIN));
80 mp_Data[9] = CollatorResourceData ("phonebook", RESSTR(STR_SVT_COLLATE_PHONEBOOK));
81 mp_Data[10] = CollatorResourceData ("phonetic (alphanumeric first)", RESSTR(STR_SVT_COLLATE_PHONETIC_F));
82 mp_Data[11] = CollatorResourceData ("phonetic (alphanumeric last)", RESSTR(STR_SVT_COLLATE_PHONETIC_L));
85 CollatorResource::~CollatorResource()
87 delete[] mp_Data;
90 const OUString&
91 CollatorResource::GetTranslation(const OUString &r_Algorithm)
93 sal_Int32 nIndex = r_Algorithm.indexOf('.');
94 OUString aLocaleFreeAlgorithm;
96 if (nIndex == -1)
98 aLocaleFreeAlgorithm = r_Algorithm;
100 else
102 nIndex += 1;
103 aLocaleFreeAlgorithm = r_Algorithm.copy(nIndex, r_Algorithm.getLength() - nIndex);
106 for (sal_uInt32 i = 0; i < COLLATOR_RESOURCE_COUNT; i++)
108 if (aLocaleFreeAlgorithm == mp_Data[i].GetAlgorithm())
109 return mp_Data[i].GetTranslation();
112 return r_Algorithm;
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */