Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / extensions / source / dbpilots / unoautopilot.hxx
blob4b69cd615ad946476a8cc696fc7d77cfc7d917f3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_UNOAUTOPILOT_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_UNOAUTOPILOT_HXX
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 #include <vcl/svapp.hxx>
32 namespace dbp
34 typedef ::svt::OGenericUnoDialog OUnoAutoPilot_Base;
35 template <class TYPE, class SERVICEINFO>
36 class OUnoAutoPilot final
37 :public OUnoAutoPilot_Base
38 ,public ::comphelper::OPropertyArrayUsageHelper< OUnoAutoPilot< TYPE, SERVICEINFO > >
40 explicit OUnoAutoPilot(const css::uno::Reference< css::uno::XComponentContext >& _rxORB)
41 : OUnoAutoPilot_Base(_rxORB)
46 css::uno::Reference< css::beans::XPropertySet > m_xObjectModel;
48 public:
49 // XTypeProvider
50 virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) override
52 return css::uno::Sequence<sal_Int8>();
55 // XServiceInfo
56 virtual OUString SAL_CALL getImplementationName() override
58 return getImplementationName_Static();
61 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
63 return getSupportedServiceNames_Static();
66 // XServiceInfo - static methods
67 /// @throws css::uno::RuntimeException
68 static css::uno::Sequence< OUString > getSupportedServiceNames_Static()
70 return SERVICEINFO::getServiceNames();
73 /// @throws css::uno::RuntimeException
74 static OUString getImplementationName_Static()
76 return SERVICEINFO::getImplementationName();
79 static css::uno::Reference< css::uno::XInterface >
80 SAL_CALL Create(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory)
82 return *(new OUnoAutoPilot<TYPE, SERVICEINFO>( comphelper::getComponentContext(_rxFactory) ));
85 // XPropertySet
86 virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override
88 css::uno::Reference< css::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
89 return xInfo;
92 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override
94 return *this->getArrayHelper();
97 // OPropertyArrayUsageHelper
98 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override
100 css::uno::Sequence< css::beans::Property > aProps;
101 describeProperties(aProps);
102 return new ::cppu::OPropertyArrayHelper(aProps);
105 private:
106 // OGenericUnoDialog overridables
107 virtual std::unique_ptr<weld::DialogController> createDialog(const css::uno::Reference<css::awt::XWindow>& rParent) override
109 return std::make_unique<TYPE>(Application::GetFrameWeld(rParent), m_xObjectModel, m_aContext);
112 virtual void implInitialize(const css::uno::Any& _rValue) override
114 css::beans::PropertyValue aArgument;
115 if (_rValue >>= aArgument)
116 if (aArgument.Name == "ObjectModel")
118 aArgument.Value >>= m_xObjectModel;
119 return;
122 OUnoAutoPilot_Base::implInitialize(_rValue);
126 } // namespace dbp
129 #endif // INCLUDED_EXTENSIONS_SOURCE_DBPILOTS_UNOAUTOPILOT_HXX
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */