fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / stoc / source / registry_tdprovider / tdsingleton.cxx
blobd91a8c4bb16a84cf73f81fcc31aad2a7f685ebb5
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 <osl/diagnose.h>
21 #include "base.hxx"
23 #include "com/sun/star/uno/RuntimeException.hpp"
25 using namespace com::sun::star;
27 namespace stoc_rdbtdp
30 void SingletonTypeDescriptionImpl::init() {
32 MutexGuard guard(getMutex());
33 if (_xInterfaceTD.is() || _xServiceTD.is()) {
34 return;
37 Reference< XTypeDescription > base;
38 try {
39 base = Reference< XTypeDescription >(
40 _xTDMgr->getByHierarchicalName(_aBaseName), UNO_QUERY_THROW);
41 } catch (NoSuchElementException const & e) {
42 throw RuntimeException(
43 (OUString(
44 "com.sun.star.container.NoSuchElementException: ")
45 + e.Message),
46 static_cast< OWeakObject * >(this));
48 MutexGuard guard(getMutex());
49 if (!_xInterfaceTD.is() && !_xServiceTD.is()) {
50 if (resolveTypedefs(base)->getTypeClass() == TypeClass_INTERFACE) {
51 _xInterfaceTD = base;
52 } else if (base->getTypeClass() == TypeClass_SERVICE) {
53 _xServiceTD = Reference< XServiceTypeDescription >(
54 base, UNO_QUERY_THROW);
55 } else {
56 throw RuntimeException(
57 OUString(
58 "Singleton is based on neither interface nor service"),
59 static_cast< OWeakObject * >(this));
62 OSL_ASSERT(_xInterfaceTD.is() ^ _xServiceTD.is());
65 //__________________________________________________________________________________________________
66 // virtual
67 SingletonTypeDescriptionImpl::~SingletonTypeDescriptionImpl() {}
69 // XTypeDescription
70 //__________________________________________________________________________________________________
71 // virtual
72 TypeClass SingletonTypeDescriptionImpl::getTypeClass()
73 throw(::com::sun::star::uno::RuntimeException)
75 return TypeClass_SINGLETON;
77 //__________________________________________________________________________________________________
78 // virtual
79 OUString SingletonTypeDescriptionImpl::getName()
80 throw(::com::sun::star::uno::RuntimeException)
82 return _aName;
85 // XSingletonTypeDescription
86 //__________________________________________________________________________________________________
87 // virtual
88 Reference< XServiceTypeDescription > SAL_CALL
89 SingletonTypeDescriptionImpl::getService()
90 throw(::com::sun::star::uno::RuntimeException)
92 init();
93 return _xServiceTD;
96 // XSingletonTypeDescription2
97 //______________________________________________________________________________
98 // virtual
99 sal_Bool SAL_CALL
100 SingletonTypeDescriptionImpl::isInterfaceBased()
101 throw(::com::sun::star::uno::RuntimeException)
103 init();
104 return _xInterfaceTD.is();
107 //______________________________________________________________________________
108 // virtual
109 Reference< XTypeDescription > SAL_CALL
110 SingletonTypeDescriptionImpl::getInterface()
111 throw(::com::sun::star::uno::RuntimeException)
113 init();
114 return _xInterfaceTD;
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */