1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "requeststringresolver.hxx"
29 #include "iahndl.hxx"
30 
31 using namespace com::sun;
32 
33 UUIInteractionRequestStringResolver::UUIInteractionRequestStringResolver(
34     star::uno::Reference< star::lang::XMultiServiceFactory > const &
35         rServiceFactory)
36     SAL_THROW(())
37         : m_xServiceFactory(rServiceFactory),
38           m_pImpl(new UUIInteractionHelper(rServiceFactory))
39 {
40 }
41 
42 UUIInteractionRequestStringResolver::~UUIInteractionRequestStringResolver()
43 {
44     delete m_pImpl;
45 }
46 
47 rtl::OUString SAL_CALL
48 UUIInteractionRequestStringResolver::getImplementationName()
49     throw (star::uno::RuntimeException)
50 {
51     return rtl::OUString::createFromAscii(m_aImplementationName);
52 }
53 
54 sal_Bool SAL_CALL
55 UUIInteractionRequestStringResolver::supportsService(
56         rtl::OUString const & rServiceName)
57     throw (star::uno::RuntimeException)
58 {
59     star::uno::Sequence< rtl::OUString >
60         aNames(getSupportedServiceNames_static());
61     for (sal_Int32 i = 0; i < aNames.getLength(); ++i)
62         if (aNames[i] == rServiceName)
63             return true;
64     return false;
65 }
66 
67 star::uno::Sequence< rtl::OUString > SAL_CALL
68 UUIInteractionRequestStringResolver::getSupportedServiceNames()
69     throw (star::uno::RuntimeException)
70 {
71     return getSupportedServiceNames_static();
72 }
73 
74 star::beans::Optional< rtl::OUString > SAL_CALL
75 UUIInteractionRequestStringResolver::getStringFromInformationalRequest(
76     const star::uno::Reference<
77         star::task::XInteractionRequest >& Request )
78     throw (star::uno::RuntimeException)
79 {
80     try
81     {
82         return m_pImpl->getStringFromRequest(Request);
83     }
84     catch (star::uno::RuntimeException const & ex)
85     {
86         throw star::uno::RuntimeException(ex.Message, *this);
87     }
88 }
89 
90 char const UUIInteractionRequestStringResolver::m_aImplementationName[]
91     = "com.sun.star.comp.uui.UUIInteractionRequestStringResolver";
92 
93 star::uno::Sequence< rtl::OUString >
94 UUIInteractionRequestStringResolver::getSupportedServiceNames_static()
95 {
96     star::uno::Sequence< rtl::OUString > aNames(1);
97     aNames[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
98                     "com.sun.star.task.InteractionRequestStringResolver"));
99     return aNames;
100 }
101 
102 star::uno::Reference< star::uno::XInterface > SAL_CALL
103 UUIInteractionRequestStringResolver::createInstance(
104     star::uno::Reference< star::lang::XMultiServiceFactory > const &
105         rServiceFactory)
106     SAL_THROW((star::uno::Exception))
107 {
108     try
109     {
110         return *new UUIInteractionRequestStringResolver(rServiceFactory);
111     }
112     catch (std::bad_alloc const &)
113     {
114         throw star::uno::RuntimeException(
115 	    rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
116 	    0);
117     }
118 }
119