Avoid potential negative array index access to cached text.
[LibreOffice.git] / i18npool / source / textconversion / textconversion.cxx
bloba64f4072cc062c4e1f511b8873a2f46ebbe194f0
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 .
20 #include <cppuhelper/supportsservice.hxx>
21 #include <textconversion.hxx>
23 using namespace com::sun::star::uno;
25 namespace i18npool {
27 #ifndef DISABLE_DYNLOADING
29 extern "C" { static void thisModule() {} }
31 #endif
33 TextConversionService::TextConversionService(const char *pImplName)
34 : implementationName(pImplName)
36 #ifndef DISABLE_DYNLOADING
37 #ifdef SAL_DLLPREFIX
38 OUString lib(SAL_DLLPREFIX"textconv_dict" SAL_DLLEXTENSION);
39 #else
40 OUString lib("textconv_dict" SAL_DLLEXTENSION);
41 #endif
42 hModule = osl_loadModuleRelative(
43 &thisModule, lib.pData, SAL_LOADMODULE_DEFAULT );
44 #endif
47 TextConversionService::~TextConversionService()
49 #ifndef DISABLE_DYNLOADING
50 if (hModule) osl_unloadModule(hModule);
51 #endif
54 #ifndef DISABLE_DYNLOADING
56 static void* nullFunc()
58 return nullptr;
61 oslGenericFunction
62 TextConversionService::getFunctionBySymbol(const char* func)
64 if (hModule)
65 return osl_getFunctionSymbol(hModule, OUString::createFromAscii(func).pData);
66 else
67 return reinterpret_cast< oslGenericFunction >(nullFunc);
70 #endif
72 OUString SAL_CALL
73 TextConversionService::getImplementationName()
75 return OUString::createFromAscii(implementationName);
78 sal_Bool SAL_CALL
79 TextConversionService::supportsService(const OUString& rServiceName)
81 return cppu::supportsService(this, rServiceName);
84 Sequence< OUString > SAL_CALL
85 TextConversionService::getSupportedServiceNames()
87 Sequence< OUString > aRet { OUString::createFromAscii(implementationName) };
88 return aRet;
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */