LibreOffice Module i18npool (master)  1
transliteration_Ignore.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_I18NPOOL_INC_TRANSLITERATION_IGNORE_HXX
20 #define INCLUDED_I18NPOOL_INC_TRANSLITERATION_IGNORE_HXX
21 
23 #include <unicode/translit.h>
24 #include <memory>
25 
26 namespace i18nutil { class oneToOneMapping; }
27 
28 typedef sal_Unicode (*TransFunc)(const sal_Unicode);
29 
30 namespace i18npool {
31 
33 {
34 public:
35  virtual OUString
36  foldingImpl( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 >* pOffset ) override;
37 
38  // This method is shared.
39  sal_Bool SAL_CALL
40  equals( const OUString& str1, sal_Int32 pos1, sal_Int32 nCount1, sal_Int32& nMatch1,
41  const OUString& str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32& nMatch2 ) override;
42 
43  // This method is implemented in sub class if needed. Otherwise, the method implemented in this class will be used.
44  css::uno::Sequence< OUString > SAL_CALL
45  transliterateRange( const OUString& str1, const OUString& str2 ) override;
46 
47 
48  // Methods which are shared.
49  sal_Int16 SAL_CALL getType( ) override;
50 
51  OUString
52  transliterateImpl( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 >* pOffset ) override;
53 
54  virtual sal_Unicode SAL_CALL
55  transliterateChar2Char( sal_Unicode inChar) override;
56 
58  static css::uno::Sequence< OUString >
59  transliterateRange( const OUString& str1, const OUString& str2, XTransliteration& t1, XTransliteration& t2 );
60 
61  struct Mapping {
65  bool two2one;
66  };
67 
68 protected:
70  i18nutil::oneToOneMapping *table;
71  const Mapping *map;
72 };
73 
74 #define TRANSLITERATION_IGNORE( name ) \
75 class ignore##name final : public transliteration_Ignore {\
76 public:\
77  ignore##name ();\
78 };
79 
80 TRANSLITERATION_IGNORE(BaFa_ja_JP)
81 TRANSLITERATION_IGNORE(HyuByu_ja_JP)
82 TRANSLITERATION_IGNORE(SeZe_ja_JP)
83 TRANSLITERATION_IGNORE(TiJi_ja_JP)
84 TRANSLITERATION_IGNORE(MiddleDot_ja_JP)
85 TRANSLITERATION_IGNORE(MinusSign_ja_JP)
86 TRANSLITERATION_IGNORE(Separator_ja_JP)
87 TRANSLITERATION_IGNORE(Space_ja_JP)
88 TRANSLITERATION_IGNORE(TraditionalKana_ja_JP)
89 TRANSLITERATION_IGNORE(TraditionalKanji_ja_JP)
90 TRANSLITERATION_IGNORE(ZiZu_ja_JP)
91 TRANSLITERATION_IGNORE(Kashida_CTL)
92 
94 {
95  std::unique_ptr<icu::Transliterator> m_transliterator;
96 
97 public:
99 
100  OUString
101  foldingImpl(const OUString& rInStr, sal_Int32 nStartPos, sal_Int32 nCount, css::uno::Sequence<sal_Int32>* pOffset) override;
102 
103  sal_Unicode SAL_CALL
104  transliterateChar2Char(sal_Unicode nInChar) override;
105 };
106 
107 #undef TRANSLITERATION_IGNORE
108 
109 #define TRANSLITERATION_IGNORE( name ) \
110 class ignore##name final : public transliteration_Ignore {\
111 public:\
112  ignore##name () {\
113  func = nullptr;\
114  table = nullptr;\
115  map = nullptr;\
116  transliterationName = "ignore"#name;\
117  implementationName = "com.sun.star.i18n.Transliteration.ignore"#name;\
118  };\
119  OUString foldingImpl( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, \
120  css::uno::Sequence< sal_Int32 >* pOffset) override; \
121 };
122 
123 TRANSLITERATION_IGNORE(KiKuFollowedBySa_ja_JP)
124 TRANSLITERATION_IGNORE(IandEfollowedByYa_ja_JP)
125 TRANSLITERATION_IGNORE(IterationMark_ja_JP)
126 TRANSLITERATION_IGNORE(ProlongedSoundMark_ja_JP)
127 
128 #undef TRANSLITERATION_IGNORE
129 
130 #define TRANSLITERATION_IGNORE( name ) \
131 class ignore##name final : public transliteration_Ignore {\
132 public:\
133  ignore##name () {\
134  func = nullptr;\
135  table = nullptr;\
136  map = nullptr;\
137  transliterationName = "ignore"#name;\
138  implementationName = "com.sun.star.i18n.Transliteration.ignore"#name;\
139  };\
140  OUString foldingImpl( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, \
141  css::uno::Sequence< sal_Int32 >* pOffset) override; \
142  using transliteration_Ignore::transliterateRange;\
143  css::uno::Sequence< OUString > SAL_CALL transliterateRange( const OUString& str1, \
144  const OUString& str2 ) override; \
145  sal_Unicode SAL_CALL \
146  transliterateChar2Char( sal_Unicode inChar) \
147  override;\
148 };
149 
152 TRANSLITERATION_IGNORE(Size_ja_JP)
153 
154 #undef TRANSLITERATION_IGNORE
155 
156 }
157 
158 #endif // INCLUDED_I18NPOOL_INC_TRANSLITERATION_IGNORE_HXX
159 
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Unicode(* TransFunc)(const sal_Unicode)
sal_Int16 SAL_CALL getType() override
sal_uInt16 sal_Unicode
#define TRANSLITERATION_IGNORE(name)
int nCount
virtual sal_Unicode SAL_CALL transliterateChar2Char(sal_Unicode inChar) override
sal_Bool SAL_CALL equals(const OUString &str1, sal_Int32 pos1, sal_Int32 nCount1, sal_Int32 &nMatch1, const OUString &str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32 &nMatch2) override
virtual OUString foldingImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override
unsigned char sal_Bool
Constant values shared between i18npool and, for example, the number formatter.
css::uno::Sequence< OUString > SAL_CALL transliterateRange(const OUString &str1, const OUString &str2) override
std::unique_ptr< icu::Transliterator > m_transliterator
sal_Unicode(* TransFunc)(const sal_Unicode)
OUString transliterateImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override