xref: /trunk/main/uui/source/requeststringresolver.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "requeststringresolver.hxx"
25 #include "iahndl.hxx"
26 
27 using namespace com::sun;
28 
UUIInteractionRequestStringResolver(star::uno::Reference<star::lang::XMultiServiceFactory> const & rServiceFactory)29 UUIInteractionRequestStringResolver::UUIInteractionRequestStringResolver(
30     star::uno::Reference< star::lang::XMultiServiceFactory > const &
31         rServiceFactory)
32     SAL_THROW(())
33         : m_xServiceFactory(rServiceFactory),
34           m_pImpl(new UUIInteractionHelper(rServiceFactory))
35 {
36 }
37 
~UUIInteractionRequestStringResolver()38 UUIInteractionRequestStringResolver::~UUIInteractionRequestStringResolver()
39 {
40     delete m_pImpl;
41 }
42 
43 rtl::OUString SAL_CALL
getImplementationName()44 UUIInteractionRequestStringResolver::getImplementationName()
45 {
46     return rtl::OUString::createFromAscii(m_aImplementationName);
47 }
48 
49 sal_Bool SAL_CALL
supportsService(rtl::OUString const & rServiceName)50 UUIInteractionRequestStringResolver::supportsService(
51         rtl::OUString const & rServiceName)
52 {
53     star::uno::Sequence< rtl::OUString >
54         aNames(getSupportedServiceNames_static());
55     for (sal_Int32 i = 0; i < aNames.getLength(); ++i)
56         if (aNames[i] == rServiceName)
57             return true;
58     return false;
59 }
60 
61 star::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames()62 UUIInteractionRequestStringResolver::getSupportedServiceNames()
63 {
64     return getSupportedServiceNames_static();
65 }
66 
67 star::beans::Optional< rtl::OUString > SAL_CALL
getStringFromInformationalRequest(const star::uno::Reference<star::task::XInteractionRequest> & Request)68 UUIInteractionRequestStringResolver::getStringFromInformationalRequest(
69     const star::uno::Reference<
70         star::task::XInteractionRequest >& Request )
71 {
72     try
73     {
74         return m_pImpl->getStringFromRequest(Request);
75     }
76     catch (star::uno::RuntimeException const & ex)
77     {
78         throw star::uno::RuntimeException(ex.Message, *this);
79     }
80 }
81 
82 char const UUIInteractionRequestStringResolver::m_aImplementationName[]
83     = "com.sun.star.comp.uui.UUIInteractionRequestStringResolver";
84 
85 star::uno::Sequence< rtl::OUString >
getSupportedServiceNames_static()86 UUIInteractionRequestStringResolver::getSupportedServiceNames_static()
87 {
88     star::uno::Sequence< rtl::OUString > aNames(1);
89     aNames[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
90                     "com.sun.star.task.InteractionRequestStringResolver"));
91     return aNames;
92 }
93 
94 star::uno::Reference< star::uno::XInterface > SAL_CALL
createInstance(star::uno::Reference<star::lang::XMultiServiceFactory> const & rServiceFactory)95 UUIInteractionRequestStringResolver::createInstance(
96     star::uno::Reference< star::lang::XMultiServiceFactory > const &
97         rServiceFactory)
98 {
99     try
100     {
101         return *new UUIInteractionRequestStringResolver(rServiceFactory);
102     }
103     catch (std::bad_alloc const &)
104     {
105         throw star::uno::RuntimeException(
106         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
107         0);
108     }
109 }
110