Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_UNOAUTOPILOT_HXX
21 : #define INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_UNOAUTOPILOT_HXX
22 :
23 : #include <svtools/genericunodialog.hxx>
24 : #include <comphelper/processfactory.hxx>
25 : #include <comphelper/proparrhlp.hxx>
26 : #include "componentmodule.hxx"
27 : #include <cppuhelper/typeprovider.hxx>
28 : #include <com/sun/star/beans/XPropertySet.hpp>
29 : #include <com/sun/star/beans/PropertyValue.hpp>
30 :
31 :
32 : namespace dbp
33 : {
34 : typedef ::svt::OGenericUnoDialog OUnoAutoPilot_Base;
35 : template <class TYPE, class SERVICEINFO>
36 0 : class OUnoAutoPilot
37 : :public OUnoAutoPilot_Base
38 : ,public ::comphelper::OPropertyArrayUsageHelper< OUnoAutoPilot< TYPE, SERVICEINFO > >
39 : ,public OModuleResourceClient
40 : {
41 0 : OUnoAutoPilot(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB)
42 0 : : OUnoAutoPilot_Base(_rxORB)
43 : {
44 0 : }
45 :
46 :
47 : protected:
48 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
49 : m_xObjectModel;
50 :
51 : public:
52 : // XTypeProvider
53 0 : virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
54 : {
55 0 : return css::uno::Sequence<sal_Int8>();
56 : }
57 :
58 : // XServiceInfo
59 0 : virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
60 : {
61 0 : return getImplementationName_Static();
62 : }
63 :
64 0 : virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
65 : {
66 0 : return getSupportedServiceNames_Static();
67 : }
68 :
69 : // XServiceInfo - static methods
70 0 : static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static() throw( ::com::sun::star::uno::RuntimeException )
71 : {
72 0 : return SERVICEINFO::getServiceNames();
73 : }
74 :
75 0 : static OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException )
76 : {
77 0 : return SERVICEINFO::getImplementationName();
78 : }
79 :
80 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
81 0 : SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
82 : {
83 0 : return *(new OUnoAutoPilot<TYPE, SERVICEINFO>( comphelper::getComponentContext(_rxFactory) ));
84 : }
85 :
86 : // XPropertySet
87 0 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
88 : {
89 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
90 0 : return xInfo;
91 : }
92 :
93 0 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE
94 : {
95 0 : return *this->getArrayHelper();
96 : }
97 :
98 : // OPropertyArrayUsageHelper
99 0 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE
100 : {
101 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aProps;
102 0 : describeProperties(aProps);
103 0 : return new ::cppu::OPropertyArrayHelper(aProps);
104 : }
105 :
106 : protected:
107 : // OGenericUnoDialog overridables
108 0 : virtual VclPtr<Dialog> createDialog(vcl::Window* _pParent) SAL_OVERRIDE
109 : {
110 0 : return VclPtr<TYPE>::Create(_pParent, m_xObjectModel, m_aContext);
111 : }
112 :
113 0 : virtual void implInitialize(const com::sun::star::uno::Any& _rValue) SAL_OVERRIDE
114 : {
115 0 : ::com::sun::star::beans::PropertyValue aArgument;
116 0 : if (_rValue >>= aArgument)
117 0 : if (aArgument.Name == "ObjectModel")
118 : {
119 0 : aArgument.Value >>= m_xObjectModel;
120 0 : return;
121 : }
122 :
123 0 : OUnoAutoPilot_Base::implInitialize(_rValue);
124 : }
125 : };
126 :
127 : } // namespace dbp
128 :
129 :
130 : #endif // INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_UNOAUTOPILOT_HXX
131 :
132 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|