Line data Source code
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 :
20 : #include <assert.h>
21 : #include <cppuhelper/supportsservice.hxx>
22 : #include <textconversion.hxx>
23 :
24 : using namespace com::sun::star::uno;
25 :
26 : namespace com { namespace sun { namespace star { namespace i18n {
27 :
28 : #ifndef DISABLE_DYNLOADING
29 :
30 0 : extern "C" { static void SAL_CALL thisModule() {} }
31 :
32 : #endif
33 :
34 2 : TextConversionService::TextConversionService(const char *pImplName)
35 2 : : implementationName(pImplName)
36 : {
37 : #ifndef DISABLE_DYNLOADING
38 : #ifdef SAL_DLLPREFIX
39 2 : OUString lib(SAL_DLLPREFIX"textconv_dict" SAL_DLLEXTENSION);
40 : #else
41 : OUString lib("textconv_dict" SAL_DLLEXTENSION);
42 : #endif
43 : hModule = osl_loadModuleRelative(
44 2 : &thisModule, lib.pData, SAL_LOADMODULE_DEFAULT );
45 : #endif
46 2 : }
47 :
48 4 : TextConversionService::~TextConversionService()
49 : {
50 : #ifndef DISABLE_DYNLOADING
51 2 : if (hModule) osl_unloadModule(hModule);
52 : #endif
53 2 : }
54 :
55 : #ifndef DISABLE_DYNLOADING
56 :
57 0 : static void* nullFunc()
58 : {
59 0 : return NULL;
60 : }
61 :
62 : oslGenericFunction SAL_CALL
63 8 : TextConversionService::getFunctionBySymbol(const sal_Char* func)
64 : {
65 8 : if (hModule)
66 8 : return osl_getFunctionSymbol(hModule, OUString::createFromAscii(func).pData);
67 : else
68 0 : return reinterpret_cast< oslGenericFunction >(nullFunc);
69 : }
70 :
71 : #endif
72 :
73 : OUString SAL_CALL
74 0 : TextConversionService::getImplementationName() throw( RuntimeException, std::exception )
75 : {
76 0 : return OUString::createFromAscii(implementationName);
77 : }
78 :
79 : sal_Bool SAL_CALL
80 0 : TextConversionService::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
81 : {
82 0 : return cppu::supportsService(this, rServiceName);
83 : }
84 :
85 : Sequence< OUString > SAL_CALL
86 0 : TextConversionService::getSupportedServiceNames() throw( RuntimeException, std::exception )
87 : {
88 0 : Sequence< OUString > aRet(1);
89 0 : aRet[0] = OUString::createFromAscii(implementationName);
90 0 : return aRet;
91 : }
92 :
93 : } } } }
94 :
95 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|