Branch data Line data Source code
1 : : #ifndef INCLUDED_COM_SUN_STAR_CONTAINER_ENUMERABLEMAP_HPP
2 : : #define INCLUDED_COM_SUN_STAR_CONTAINER_ENUMERABLEMAP_HPP
3 : :
4 : : #include "sal/config.h"
5 : :
6 : : #include "com/sun/star/uno/RuntimeException.hpp"
7 : : #include "com/sun/star/uno/Exception.hpp"
8 : : #include "com/sun/star/uno/XComponentContext.hpp"
9 : : #include "com/sun/star/lang/XMultiComponentFactory.hpp"
10 : : #include "com/sun/star/lang/IllegalArgumentException.hpp"
11 : : #include "com/sun/star/container/XEnumerableMap.hpp"
12 : : #include "com/sun/star/beans/IllegalTypeException.hpp"
13 : : #include "com/sun/star/uno/DeploymentException.hpp"
14 : : #include "com/sun/star/beans/Pair.hpp"
15 : : #include "com/sun/star/uno/Any.hxx"
16 : : #include "com/sun/star/uno/Reference.hxx"
17 : : #include "com/sun/star/uno/Sequence.hxx"
18 : : #include "com/sun/star/uno/Type.hxx"
19 : : #include "cppu/unotype.hxx"
20 : : #include "rtl/ustring.h"
21 : : #include "rtl/ustring.hxx"
22 : :
23 : : namespace com { namespace sun { namespace star { namespace container {
24 : :
25 : : class EnumerableMap {
26 : : public:
27 : 0 : static ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerableMap > create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & the_context, const ::com::sun::star::uno::Type& KeyType, const ::com::sun::star::uno::Type& ValueType) {
28 [ # # ][ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > the_factory(the_context->getServiceManager());
29 [ # # ]: 0 : if (!the_factory.is()) {
30 [ # # ][ # # ]: 0 : throw com::sun::star::uno::DeploymentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("component context fails to supply service manager")), the_context);
31 : : }
32 [ # # ]: 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > the_arguments(2);
33 [ # # ][ # # ]: 0 : the_arguments[0] <<= KeyType;
34 [ # # ][ # # ]: 0 : the_arguments[1] <<= ValueType;
35 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerableMap > the_instance;
36 : : try {
37 [ # # ][ # # ]: 0 : the_instance = ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerableMap >(the_factory->createInstanceWithArgumentsAndContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.EnumerableMap")), the_arguments, the_context), ::com::sun::star::uno::UNO_QUERY);
[ # # ][ # # ]
[ # # ]
38 : 0 : } catch (::com::sun::star::uno::RuntimeException &) {
39 : 0 : throw;
40 : 0 : } catch (::com::sun::star::beans::IllegalTypeException &) {
41 : 0 : throw;
42 [ # # # # ]: 0 : } catch (::com::sun::star::uno::Exception & the_exception) {
43 [ # # # # ]: 0 : throw ::com::sun::star::uno::DeploymentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("component context fails to supply service com.sun.star.container.EnumerableMap of type com.sun.star.container.XEnumerableMap: ")) + the_exception.Message, the_context);
44 : : }
45 [ # # ]: 0 : if (!the_instance.is()) {
46 [ # # ][ # # ]: 0 : throw ::com::sun::star::uno::DeploymentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("component context fails to supply service com.sun.star.container.EnumerableMap of type com.sun.star.container.XEnumerableMap")), the_context);
47 : : }
48 [ # # ]: 0 : return the_instance;
49 : : }
50 : :
51 : : static ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerableMap > createImmutable(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & the_context, const ::com::sun::star::uno::Type& KeyType, const ::com::sun::star::uno::Type& ValueType, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Pair< ::com::sun::star::uno::Any, ::com::sun::star::uno::Any > >& Values) {
52 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > the_factory(the_context->getServiceManager());
53 : : if (!the_factory.is()) {
54 : : throw com::sun::star::uno::DeploymentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("component context fails to supply service manager")), the_context);
55 : : }
56 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > the_arguments(3);
57 : : the_arguments[0] <<= KeyType;
58 : : the_arguments[1] <<= ValueType;
59 : : the_arguments[2] <<= Values;
60 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerableMap > the_instance;
61 : : try {
62 : : the_instance = ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerableMap >(the_factory->createInstanceWithArgumentsAndContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.EnumerableMap")), the_arguments, the_context), ::com::sun::star::uno::UNO_QUERY);
63 : : } catch (::com::sun::star::uno::RuntimeException &) {
64 : : throw;
65 : : } catch (::com::sun::star::beans::IllegalTypeException &) {
66 : : throw;
67 : : } catch (::com::sun::star::lang::IllegalArgumentException &) {
68 : : throw;
69 : : } catch (::com::sun::star::uno::Exception & the_exception) {
70 : : throw ::com::sun::star::uno::DeploymentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("component context fails to supply service com.sun.star.container.EnumerableMap of type com.sun.star.container.XEnumerableMap: ")) + the_exception.Message, the_context);
71 : : }
72 : : if (!the_instance.is()) {
73 : : throw ::com::sun::star::uno::DeploymentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("component context fails to supply service com.sun.star.container.EnumerableMap of type com.sun.star.container.XEnumerableMap")), the_context);
74 : : }
75 : : return the_instance;
76 : : }
77 : :
78 : : private:
79 : : EnumerableMap(); // not implemented
80 : : EnumerableMap(EnumerableMap &); // not implemented
81 : : ~EnumerableMap(); // not implemented
82 : : void operator =(EnumerableMap); // not implemented
83 : : };
84 : :
85 : : } } } }
86 : :
87 : : #endif // INCLUDED_COM_SUN_STAR_CONTAINER_ENUMERABLEMAP_HPP
|