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     throw (star::uno::RuntimeException)
46 {
47     return rtl::OUString::createFromAscii(m_aImplementationName);
48 }
49 
50 sal_Bool SAL_CALL
supportsService(rtl::OUString const & rServiceName)51 UUIInteractionRequestStringResolver::supportsService(
52         rtl::OUString const & rServiceName)
53     throw (star::uno::RuntimeException)
54 {
55     star::uno::Sequence< rtl::OUString >
56         aNames(getSupportedServiceNames_static());
57     for (sal_Int32 i = 0; i < aNames.getLength(); ++i)
58         if (aNames[i] == rServiceName)
59             return true;
60     return false;
61 }
62 
63 star::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames()64 UUIInteractionRequestStringResolver::getSupportedServiceNames()
65     throw (star::uno::RuntimeException)
66 {
67     return getSupportedServiceNames_static();
68 }
69 
70 star::beans::Optional< rtl::OUString > SAL_CALL
getStringFromInformationalRequest(const star::uno::Reference<star::task::XInteractionRequest> & Request)71 UUIInteractionRequestStringResolver::getStringFromInformationalRequest(
72     const star::uno::Reference<
73         star::task::XInteractionRequest >& Request )
74     throw (star::uno::RuntimeException)
75 {
76     try
77     {
78         return m_pImpl->getStringFromRequest(Request);
79     }
80     catch (star::uno::RuntimeException const & ex)
81     {
82         throw star::uno::RuntimeException(ex.Message, *this);
83     }
84 }
85 
86 char const UUIInteractionRequestStringResolver::m_aImplementationName[]
87     = "com.sun.star.comp.uui.UUIInteractionRequestStringResolver";
88 
89 star::uno::Sequence< rtl::OUString >
getSupportedServiceNames_static()90 UUIInteractionRequestStringResolver::getSupportedServiceNames_static()
91 {
92     star::uno::Sequence< rtl::OUString > aNames(1);
93     aNames[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
94                     "com.sun.star.task.InteractionRequestStringResolver"));
95     return aNames;
96 }
97 
98 star::uno::Reference< star::uno::XInterface > SAL_CALL
createInstance(star::uno::Reference<star::lang::XMultiServiceFactory> const & rServiceFactory)99 UUIInteractionRequestStringResolver::createInstance(
100     star::uno::Reference< star::lang::XMultiServiceFactory > const &
101         rServiceFactory)
102     SAL_THROW((star::uno::Exception))
103 {
104     try
105     {
106         return *new UUIInteractionRequestStringResolver(rServiceFactory);
107     }
108     catch (std::bad_alloc const &)
109     {
110         throw star::uno::RuntimeException(
111 	    rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
112 	    0);
113     }
114 }
115