clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name textconversion_zh.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/i18npool/inc -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/i18npool/source/textconversion/textconversion_zh.cxx
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | #include <textconversion.hxx> |
22 | #include <com/sun/star/i18n/TextConversionType.hpp> |
23 | #include <com/sun/star/i18n/TextConversionOption.hpp> |
24 | #include <com/sun/star/lang/NoSupportException.hpp> |
25 | #include <com/sun/star/linguistic2/ConversionDirection.hpp> |
26 | #include <com/sun/star/linguistic2/ConversionDictionaryType.hpp> |
27 | #include <com/sun/star/linguistic2/ConversionDictionaryList.hpp> |
28 | #include <memory> |
29 | |
30 | using namespace com::sun::star::lang; |
31 | using namespace com::sun::star::i18n; |
32 | using namespace com::sun::star::linguistic2; |
33 | using namespace com::sun::star::uno; |
34 | |
35 | |
36 | namespace i18npool { |
37 | |
38 | TextConversion_zh::TextConversion_zh( const Reference < XComponentContext >& xContext ) |
39 | : TextConversionService("com.sun.star.i18n.TextConversion_zh") |
40 | { |
41 | xCDL = ConversionDictionaryList::create(xContext); |
42 | } |
43 | |
44 | static sal_Unicode getOneCharConversion(sal_Unicode ch, const sal_Unicode* Data, const sal_uInt16* Index) |
45 | { |
46 | if (Data && Index) { |
47 | sal_Unicode address = Index[ch>>8]; |
48 | if (address != 0xFFFF) |
49 | address = Data[address + (ch & 0xFF)]; |
50 | return (address != 0xFFFF) ? address : ch; |
51 | } else { |
52 | return ch; |
53 | } |
54 | } |
55 | |
56 | #ifdef DISABLE_DYNLOADING |
57 | |
58 | extern "C" { |
59 | |
60 | const sal_Unicode* getSTC_CharData_T2S(); |
61 | const sal_uInt16* getSTC_CharIndex_T2S(); |
62 | const sal_Unicode* getSTC_CharData_S2V(); |
63 | const sal_uInt16* getSTC_CharIndex_S2V(); |
64 | const sal_Unicode* getSTC_CharData_S2T(); |
65 | const sal_uInt16* getSTC_CharIndex_S2T(); |
66 | |
67 | const sal_Unicode *getSTC_WordData(sal_Int32&); |
68 | |
69 | const sal_uInt16 *getSTC_WordIndex_T2S(sal_Int32&); |
70 | const sal_uInt16 *getSTC_WordEntry_T2S(); |
71 | const sal_uInt16 *getSTC_WordIndex_S2T(sal_Int32&); |
72 | const sal_uInt16 *getSTC_WordEntry_S2T(); |
73 | |
74 | } |
75 | |
76 | #endif |
77 | |
78 | OUString |
79 | TextConversion_zh::getCharConversion(const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions) |
80 | { |
81 | const sal_Unicode *Data; |
82 | const sal_uInt16 *Index; |
83 | |
84 | #ifndef DISABLE_DYNLOADING |
85 | if (toSChinese) { |
86 | Data = reinterpret_cast<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_T2S"))(); |
87 | Index = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_CharIndex_T2S"))(); |
88 | } else if (nConversionOptions & TextConversionOption::USE_CHARACTER_VARIANTS) { |
89 | Data = reinterpret_cast<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_S2V"))(); |
90 | Index = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_CharIndex_S2V"))(); |
91 | } else { |
92 | Data = reinterpret_cast<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_S2T"))(); |
93 | Index = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_CharIndex_S2T"))(); |
94 | } |
95 | #else |
96 | if (toSChinese) { |
97 | Data = getSTC_CharData_T2S(); |
98 | Index = getSTC_CharIndex_T2S(); |
99 | } else if (nConversionOptions & TextConversionOption::USE_CHARACTER_VARIANTS) { |
100 | Data = getSTC_CharData_S2V(); |
101 | Index = getSTC_CharIndex_S2V(); |
102 | } else { |
103 | Data = getSTC_CharData_S2T(); |
104 | Index = getSTC_CharIndex_S2T(); |
105 | } |
106 | #endif |
107 | |
108 | rtl_uString * newStr = rtl_uString_alloc(nLength); |
109 | for (sal_Int32 i = 0; i < nLength; i++) |
110 | newStr->buffer[i] = |
111 | getOneCharConversion(aText[nStartPos+i], Data, Index); |
112 | return OUString(newStr, SAL_NO_ACQUIRE); |
113 | } |
114 | |
115 | OUString |
116 | TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions, Sequence<sal_Int32>& offset) |
117 | { |
118 | sal_Int32 dictLen = 0; |
119 | sal_Int32 maxLen = 0; |
120 | const sal_uInt16 *index; |
121 | const sal_uInt16 *entry; |
122 | const sal_Unicode *charData; |
123 | const sal_uInt16 *charIndex; |
124 | bool one2one=true; |
125 | |
126 | #ifndef DISABLE_DYNLOADING |
127 | const sal_Unicode *wordData = reinterpret_cast<const sal_Unicode* (*)(sal_Int32&)>(getFunctionBySymbol("getSTC_WordData"))(dictLen); |
128 | if (toSChinese) { |
| |
129 | index = reinterpret_cast<const sal_uInt16* (*)(sal_Int32&)>(getFunctionBySymbol("getSTC_WordIndex_T2S"))(maxLen); |
| 8 | | Value assigned to 'index' | |
|
130 | entry = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_WordEntry_T2S"))(); |
131 | charData = reinterpret_cast<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_T2S"))(); |
132 | charIndex = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_CharIndex_T2S"))(); |
133 | } else { |
134 | index = reinterpret_cast<const sal_uInt16* (*)(sal_Int32&)>(getFunctionBySymbol("getSTC_WordIndex_S2T"))(maxLen); |
135 | entry = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_WordEntry_S2T"))(); |
136 | if (nConversionOptions & TextConversionOption::USE_CHARACTER_VARIANTS) { |
137 | charData = reinterpret_cast<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_S2V"))(); |
138 | charIndex = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_CharIndex_S2V"))(); |
139 | } else { |
140 | charData = reinterpret_cast<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_S2T"))(); |
141 | charIndex = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_CharIndex_S2T"))(); |
142 | } |
143 | } |
144 | #else |
145 | const sal_Unicode *wordData = getSTC_WordData(dictLen); |
146 | if (toSChinese) { |
147 | index = getSTC_WordIndex_T2S(maxLen); |
148 | entry = getSTC_WordEntry_T2S(); |
149 | charData = getSTC_CharData_T2S(); |
150 | charIndex = getSTC_CharIndex_T2S(); |
151 | } else { |
152 | index = getSTC_WordIndex_S2T(maxLen); |
153 | entry = getSTC_WordEntry_S2T(); |
154 | if (nConversionOptions & TextConversionOption::USE_CHARACTER_VARIANTS) { |
155 | charData = getSTC_CharData_S2V(); |
156 | charIndex = getSTC_CharIndex_S2V(); |
157 | } else { |
158 | charData = getSTC_CharData_S2T(); |
159 | charIndex = getSTC_CharIndex_S2T(); |
160 | } |
161 | } |
162 | #endif |
163 | |
164 | if ((!wordData || !index || !entry) && !xCDL.is()) |
| 9 | | Assuming 'wordData' is non-null | |
|
| 10 | | Assuming 'index' is null | |
|
| 11 | | Calling 'BaseReference::is' | |
|
| 14 | | Returning from 'BaseReference::is' | |
|
| |
165 | return getCharConversion(aText, nStartPos, nLength, toSChinese, nConversionOptions); |
166 | |
167 | std::unique_ptr<sal_Unicode[]> newStr(new sal_Unicode[nLength * 2 + 1]); |
168 | sal_Int32 currPos = 0, count = 0; |
169 | while (currPos < nLength) { |
| 16 | | Assuming 'currPos' is < 'nLength' | |
|
| 17 | | Loop condition is true. Entering loop body | |
|
170 | sal_Int32 len = nLength - currPos; |
171 | bool found = false; |
172 | if (len > maxLen) |
| 18 | | Assuming 'len' is <= 'maxLen' | |
|
| |
173 | len = maxLen; |
174 | for (; len > 0 && ! found; len--) { |
| 20 | | Loop condition is true. Entering loop body | |
|
175 | OUString word = aText.copy(nStartPos + currPos, len); |
176 | sal_Int32 current = 0; |
177 | |
178 | if (xCDL.is()) { |
| |
179 | Sequence < OUString > conversions; |
180 | try { |
181 | conversions = xCDL->queryConversions(word, 0, len, |
182 | aLocale, ConversionDictionaryType::SCHINESE_TCHINESE, |
183 | ConversionDirection_FROM_LEFT , |
184 | nConversionOptions); |
185 | } |
186 | catch ( NoSupportException & ) { |
187 | |
188 | |
189 | |
190 | xCDL = nullptr; |
191 | } |
192 | catch (...) { |
193 | |
194 | |
195 | } |
196 | if (conversions.hasElements()) { |
| 22 | | Assuming the condition is false | |
|
| |
197 | if (offset.hasElements()) { |
198 | if (word.getLength() != conversions[0].getLength()) |
199 | one2one=false; |
200 | while (current < conversions[0].getLength()) { |
201 | offset[count] = nStartPos + currPos + (current * |
202 | word.getLength() / conversions[0].getLength()); |
203 | newStr[count++] = conversions[0][current++]; |
204 | } |
205 | |
206 | } else { |
207 | while (current < conversions[0].getLength()) |
208 | newStr[count++] = conversions[0][current++]; |
209 | } |
210 | currPos += word.getLength(); |
211 | found = true; |
212 | } |
213 | } |
214 | |
215 | if (wordData && !found && index[len+1] - index[len] > 0) { |
| 24 | | Array access (from variable 'index') results in a null pointer dereference |
|
216 | sal_Int32 bottom = static_cast<sal_Int32>(index[len]); |
217 | sal_Int32 top = static_cast<sal_Int32>(index[len+1]) - 1; |
218 | |
219 | while (bottom <= top && !found) { |
220 | current = (top + bottom) / 2; |
221 | const sal_Int32 result = rtl_ustr_compare( |
222 | word.getStr(), wordData + entry[current]); |
223 | if (result < 0) |
224 | top = current - 1; |
225 | else if (result > 0) |
226 | bottom = current + 1; |
227 | else { |
228 | if (toSChinese) |
229 | for (current = entry[current]-1; current > 0 && wordData[current-1]; current--) ; |
230 | else |
231 | current = entry[current] + word.getLength() + 1; |
232 | sal_Int32 start=current; |
233 | if (offset.hasElements()) { |
234 | if (word.getLength() != OUString(&wordData[current]).getLength()) |
235 | one2one=false; |
236 | sal_Int32 convertedLength=OUString(&wordData[current]).getLength(); |
237 | while (wordData[current]) { |
238 | offset[count]=nStartPos + currPos + ((current-start) * |
239 | word.getLength() / convertedLength); |
240 | newStr[count++] = wordData[current++]; |
241 | } |
242 | |
243 | } else { |
244 | while (wordData[current]) |
245 | newStr[count++] = wordData[current++]; |
246 | } |
247 | currPos += word.getLength(); |
248 | found = true; |
249 | } |
250 | } |
251 | } |
252 | } |
253 | if (!found) { |
254 | if (offset.hasElements()) |
255 | offset[count]=nStartPos+currPos; |
256 | newStr[count++] = |
257 | getOneCharConversion(aText[nStartPos+currPos], charData, charIndex); |
258 | currPos++; |
259 | } |
260 | } |
261 | if (offset.hasElements()) |
262 | offset.realloc(one2one ? 0 : count); |
263 | OUString aRet(newStr.get(), count); |
264 | return aRet; |
265 | } |
266 | |
267 | TextConversionResult SAL_CALL |
268 | TextConversion_zh::getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, |
269 | const Locale& rLocale, sal_Int16 nConversionType, sal_Int32 nConversionOptions) |
270 | { |
271 | TextConversionResult result; |
272 | |
273 | result.Candidates.realloc(1); |
274 | result.Candidates[0] = getConversion( aText, nStartPos, nLength, rLocale, nConversionType, nConversionOptions); |
275 | result.Boundary.startPos = nStartPos; |
276 | result.Boundary.endPos = nStartPos + nLength; |
277 | |
278 | return result; |
279 | } |
280 | |
281 | OUString SAL_CALL |
282 | TextConversion_zh::getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, |
283 | const Locale& rLocale, sal_Int16 nConversionType, sal_Int32 nConversionOptions) |
284 | { |
285 | if (rLocale.Language != "zh" || ( nConversionType != TextConversionType::TO_SCHINESE && nConversionType != TextConversionType::TO_TCHINESE) ) |
286 | throw NoSupportException(); |
287 | |
288 | aLocale=rLocale; |
289 | bool toSChinese = nConversionType == TextConversionType::TO_SCHINESE; |
290 | |
291 | if (nConversionOptions & TextConversionOption::CHARACTER_BY_CHARACTER) |
292 | |
293 | return getCharConversion(aText, nStartPos, nLength, toSChinese, nConversionOptions); |
294 | else { |
295 | Sequence <sal_Int32> offset; |
296 | |
297 | return getWordConversion(aText, nStartPos, nLength, toSChinese, nConversionOptions, offset); |
298 | } |
299 | } |
300 | |
301 | OUString SAL_CALL |
302 | TextConversion_zh::getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, |
303 | const Locale& rLocale, sal_Int16 nConversionType, sal_Int32 nConversionOptions, Sequence<sal_Int32>& offset) |
304 | { |
305 | if (rLocale.Language != "zh" || ( nConversionType != TextConversionType::TO_SCHINESE && nConversionType != TextConversionType::TO_TCHINESE) ) |
| 1 | Assuming 'nConversionType' is equal to 'TO_SCHINESE' | |
|
306 | throw NoSupportException(); |
307 | |
308 | aLocale=rLocale; |
309 | bool toSChinese = nConversionType == TextConversionType::TO_SCHINESE; |
310 | |
311 | if (nConversionOptions & TextConversionOption::CHARACTER_BY_CHARACTER) { |
| 2 | | Assuming the condition is false | |
|
| |
312 | offset.realloc(0); |
313 | |
314 | return getCharConversion(aText, nStartPos, nLength, toSChinese, nConversionOptions); |
315 | } else { |
316 | if (offset.getLength() < 2*nLength) |
| 4 | | Assuming the condition is false | |
|
| |
317 | offset.realloc(2*nLength); |
318 | |
319 | return getWordConversion(aText, nStartPos, nLength, toSChinese, nConversionOptions, offset); |
| 6 | | Calling 'TextConversion_zh::getWordConversion' | |
|
320 | } |
321 | } |
322 | |
323 | sal_Bool SAL_CALL |
324 | TextConversion_zh::interactiveConversion( const Locale& , sal_Int16 , sal_Int32 ) |
325 | { |
326 | return false; |
327 | } |
328 | |
329 | } |
330 | |
331 | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | #ifndef INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H |
20 | #define INCLUDED_COM_SUN_STAR_UNO_REFERENCE_H |
21 | |
22 | #include "sal/config.h" |
23 | |
24 | #include <cassert> |
25 | #include <cstddef> |
26 | |
27 | #if defined LIBO_INTERNAL_ONLY |
28 | #include <type_traits> |
29 | #endif |
30 | |
31 | #include "rtl/alloc.h" |
32 | |
33 | namespace com |
34 | { |
35 | namespace sun |
36 | { |
37 | namespace star |
38 | { |
39 | namespace uno |
40 | { |
41 | |
42 | class RuntimeException; |
43 | class XInterface; |
44 | class Type; |
45 | class Any; |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | enum UnoReference_NoAcquire |
52 | { |
53 | |
54 | |
55 | |
56 | UNO_REF_NO_ACQUIRE |
57 | }; |
58 | |
59 | |
60 | |
61 | |
62 | class BaseReference |
63 | { |
64 | protected: |
65 | |
66 | |
67 | XInterface * _pInterface; |
68 | |
69 | |
70 | |
71 | |
72 | |
73 | |
74 | |
75 | inline static XInterface * SAL_CALL iquery( XInterface * pInterface, const Type & rType ); |
76 | |
77 | |
78 | |
79 | |
80 | |
81 | |
82 | |
83 | inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface, const Type & rType ); |
84 | |
85 | public: |
86 | |
87 | |
88 | |
89 | |
90 | XInterface * SAL_CALL get() const |
91 | { return _pInterface; } |
92 | |
93 | |
94 | |
95 | |
96 | |
97 | bool SAL_CALL is() const |
98 | { return (NULL != _pInterface); } |
| 12 | | Assuming NULL is not equal to field '_pInterface' | |
|
| 13 | | Returning the value 1, which participates in a condition later | |
|
99 | |
100 | #if defined LIBO_INTERNAL_ONLY |
101 | |
102 | |
103 | |
104 | |
105 | explicit operator bool() const |
106 | { return is(); } |
107 | #endif |
108 | |
109 | |
110 | |
111 | |
112 | |
113 | |
114 | |
115 | inline bool SAL_CALL operator == ( XInterface * pInterface ) const; |
116 | |
117 | |
118 | |
119 | |
120 | |
121 | |
122 | inline bool SAL_CALL operator != ( XInterface * pInterface ) const; |
123 | |
124 | |
125 | |
126 | |
127 | |
128 | |
129 | |
130 | inline bool SAL_CALL operator == ( const BaseReference & rRef ) const; |
131 | |
132 | |
133 | |
134 | |
135 | |
136 | |
137 | inline bool SAL_CALL operator != ( const BaseReference & rRef ) const; |
138 | |
139 | |
140 | |
141 | |
142 | |
143 | |
144 | inline bool SAL_CALL operator < ( const BaseReference & rRef ) const; |
145 | }; |
146 | |
147 | |
148 | |
149 | enum UnoReference_Query |
150 | { |
151 | |
152 | |
153 | UNO_QUERY |
154 | }; |
155 | |
156 | |
157 | |
158 | enum UnoReference_QueryThrow |
159 | { |
160 | |
161 | |
162 | UNO_QUERY_THROW |
163 | }; |
164 | |
165 | |
166 | |
167 | |
168 | |
169 | enum UnoReference_SetThrow |
170 | { |
171 | UNO_SET_THROW |
172 | }; |
173 | |
174 | |
175 | |
176 | |
177 | |
178 | template< class interface_type > |
179 | class SAL_DLLPUBLIC_RTTI Reference : public BaseReference |
180 | { |
181 | |
182 | |
183 | |
184 | |
185 | |
186 | inline static XInterface * SAL_CALL iquery( XInterface * pInterface ); |
187 | |
188 | |
189 | |
190 | |
191 | |
192 | |
193 | inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface ); |
194 | |
195 | |
196 | |
197 | |
198 | |
199 | inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface ); |
200 | |
201 | |
202 | |
203 | |
204 | |
205 | |
206 | |
207 | |
208 | |
209 | |
210 | |
211 | |
212 | static interface_type * castFromXInterface(XInterface * p) { |
213 | return static_cast< interface_type * >(static_cast< void * >(p)); |
214 | } |
215 | |
216 | |
217 | |
218 | |
219 | |
220 | |
221 | |
222 | |
223 | |
224 | |
225 | |
226 | |
227 | static XInterface * castToXInterface(interface_type * p) { |
228 | return static_cast< XInterface * >(static_cast< void * >(p)); |
229 | } |
230 | |
231 | public: |
232 | |
233 | |
234 | static void * SAL_CALL operator new ( ::size_t nSize ) |
235 | { return ::rtl_allocateMemory( nSize ); } |
236 | static void SAL_CALL operator delete ( void * pMem ) |
237 | { ::rtl_freeMemory( pMem ); } |
238 | static void * SAL_CALL operator new ( ::size_t, void * pMem ) |
239 | { return pMem; } |
240 | static void SAL_CALL operator delete ( void *, void * ) |
241 | {} |
242 | |
243 | |
244 | |
245 | |
246 | inline ~Reference() COVERITY_NOEXCEPT_FALSE; |
247 | |
248 | |
249 | |
250 | inline Reference(); |
251 | |
252 | |
253 | |
254 | |
255 | |
256 | inline Reference( const Reference< interface_type > & rRef ); |
257 | |
258 | #if defined LIBO_INTERNAL_ONLY |
259 | |
260 | |
261 | |
262 | |
263 | inline Reference( Reference< interface_type > && rRef ) noexcept; |
264 | |
265 | |
266 | |
267 | |
268 | |
269 | |
270 | |
271 | |
272 | |
273 | template< class derived_type > |
274 | inline Reference( |
275 | const Reference< derived_type > & rRef, |
276 | std::enable_if_t< |
277 | std::is_base_of_v<interface_type, derived_type> |
278 | && !std::is_same_v<interface_type, XInterface>, void *> = nullptr); |
279 | #endif |
280 | |
281 | |
282 | |
283 | |
284 | |
285 | inline Reference( interface_type * pInterface ); |
286 | |
287 | |
288 | |
289 | |
290 | |
291 | |
292 | inline Reference( interface_type * pInterface, __sal_NoAcquire dummy); |
293 | |
294 | |
295 | |
296 | |
297 | |
298 | |
299 | |
300 | inline SAL_DEPRECATED("use SAL_NO_ACQUIRE version") Reference( interface_type * pInterface, UnoReference_NoAcquire dummy ); |
301 | |
302 | |
303 | |
304 | |
305 | |
306 | |
307 | inline Reference( const BaseReference & rRef, UnoReference_Query dummy ); |
308 | |
309 | |
310 | |
311 | |
312 | |
313 | inline Reference( XInterface * pInterface, UnoReference_Query dummy); |
314 | |
315 | |
316 | |
317 | |
318 | |
319 | inline Reference( const Any & rAny, UnoReference_Query dummy); |
320 | |
321 | |
322 | |
323 | |
324 | |
325 | |
326 | |
327 | inline Reference( const BaseReference & rRef, UnoReference_QueryThrow dummy ); |
328 | #ifdef LIBO_INTERNAL_ONLY |
329 | |
330 | |
331 | |
332 | Reference( const Reference< interface_type > & rRef, UnoReference_QueryThrow dummy ) = delete; |
333 | #endif |
334 | |
335 | |
336 | |
337 | |
338 | |
339 | |
340 | |
341 | inline Reference( XInterface * pInterface, UnoReference_QueryThrow dummy ); |
342 | |
343 | |
344 | |
345 | |
346 | |
347 | |
348 | |
349 | inline Reference( const Any & rAny, UnoReference_QueryThrow dummy ); |
350 | |
351 | |
352 | |
353 | |
354 | |
355 | |
356 | |
357 | |
358 | inline Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy ); |
359 | |
360 | |
361 | |
362 | |
363 | |
364 | |
365 | |
366 | |
367 | inline Reference( interface_type * pInterface, UnoReference_SetThrow dummy ); |
368 | |
369 | |
370 | |
371 | |
372 | |
373 | SAL_CALL operator const Reference< XInterface > & () const |
374 | { return * reinterpret_cast< const Reference< XInterface > * >( this ); } |
375 | |
376 | |
377 | |
378 | |
379 | |
380 | interface_type * SAL_CALL operator -> () const { |
381 | assert(_pInterface != NULL); |
382 | return castFromXInterface(_pInterface); |
383 | } |
384 | |
385 | |
386 | |
387 | |
388 | |
389 | |
390 | interface_type & SAL_CALL operator * () const { |
391 | assert(_pInterface != NULL); |
392 | return *castFromXInterface(_pInterface); |
393 | } |
394 | |
395 | |
396 | |
397 | |
398 | |
399 | interface_type * SAL_CALL get() const |
400 | { return castFromXInterface(_pInterface); } |
401 | |
402 | |
403 | |
404 | inline void SAL_CALL clear(); |
405 | |
406 | |
407 | |
408 | |
409 | |
410 | |
411 | inline bool SAL_CALL set( const Reference< interface_type > & rRef ); |
412 | |
413 | |
414 | |
415 | |
416 | |
417 | inline bool SAL_CALL set( interface_type * pInterface ); |
418 | |
419 | |
420 | |
421 | |
422 | |
423 | |
424 | |
425 | inline bool SAL_CALL set( interface_type * pInterface, __sal_NoAcquire dummy); |
426 | |
427 | |
428 | |
429 | |
430 | |
431 | |
432 | |
433 | |
434 | inline SAL_DEPRECATED("use SAL_NO_ACQUIRE version") bool SAL_CALL set( interface_type * pInterface, UnoReference_NoAcquire dummy); |
435 | |
436 | |
437 | |
438 | |
439 | |
440 | |
441 | |
442 | |
443 | inline bool SAL_CALL set( XInterface * pInterface, UnoReference_Query dummy ); |
444 | |
445 | |
446 | |
447 | |
448 | |
449 | |
450 | |
451 | inline bool SAL_CALL set( const BaseReference & rRef, UnoReference_Query dummy); |
452 | |
453 | |
454 | |
455 | |
456 | |
457 | |
458 | |
459 | |
460 | |
461 | |
462 | |
463 | |
464 | inline bool set( Any const & rAny, UnoReference_Query dummy ); |
465 | |
466 | |
467 | |
468 | |
469 | |
470 | |
471 | |
472 | |
473 | |
474 | inline void SAL_CALL set( XInterface * pInterface, UnoReference_QueryThrow dummy ); |
475 | |
476 | |
477 | |
478 | |
479 | |
480 | |
481 | |
482 | |
483 | inline void SAL_CALL set( const BaseReference & rRef, UnoReference_QueryThrow dummy ); |
484 | #ifdef LIBO_INTERNAL_ONLY |
485 | |
486 | |
487 | |
488 | void set( const Reference< interface_type > & rRef, UnoReference_QueryThrow dummy ) = delete; |
489 | #endif |
490 | |
491 | |
492 | |
493 | |
494 | |
495 | |
496 | |
497 | |
498 | |
499 | |
500 | inline void set( Any const & rAny, UnoReference_QueryThrow dummy); |
501 | |
502 | |
503 | |
504 | |
505 | |
506 | |
507 | |
508 | |
509 | |
510 | inline void SAL_CALL set( interface_type * pInterface, UnoReference_SetThrow dummy); |
511 | |
512 | |
513 | |
514 | |
515 | |
516 | |
517 | |
518 | |
519 | |
520 | inline void SAL_CALL set( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy); |
521 | |
522 | |
523 | |
524 | |
525 | |
526 | |
527 | |
528 | |
529 | inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface ); |
530 | |
531 | |
532 | |
533 | |
534 | |
535 | |
536 | inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef ); |
537 | #if defined LIBO_INTERNAL_ONLY |
538 | |
539 | |
540 | |
541 | |
542 | |
543 | |
544 | inline Reference< interface_type > & SAL_CALL operator = ( Reference< interface_type > && rRef ) noexcept; |
545 | #endif |
546 | |
547 | |
548 | |
549 | |
550 | |
551 | SAL_WARN_UNUSED_RESULT inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef ); |
552 | |
553 | |
554 | |
555 | |
556 | |
557 | SAL_WARN_UNUSED_RESULT inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface ); |
558 | }; |
559 | |
560 | } |
561 | } |
562 | } |
563 | } |
564 | |
565 | #endif |
566 | |
567 | |