bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / source / abpilot / unodialogabp.cxx
blob636fb2fbe485cea9daa50e6c728d7b261a3fb251
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 #include "unodialogabp.hxx"
21 #include <cppuhelper/typeprovider.hxx>
22 #include "abspilot.hxx"
23 #include <comphelper/sequence.hxx>
24 #include <toolkit/helper/vclunohelper.hxx>
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <com/sun/star/awt/XWindow.hpp>
29 #define PROPERTY_ID_DATASOURCENAME 3
31 namespace abp
33 using namespace ::com::sun::star;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::ui::dialogs;
39 OABSPilotUno::OABSPilotUno(const Reference< XComponentContext >& _rxORB)
40 :OGenericUnoDialog(_rxORB)
42 registerProperty( "DataSourceName", PROPERTY_ID_DATASOURCENAME, PropertyAttribute::READONLY ,
43 &m_sDataSourceName, cppu::UnoType<decltype(m_sDataSourceName)>::get() );
46 Any SAL_CALL OABSPilotUno::queryInterface( const Type& aType )
48 Any aReturn = svt::OGenericUnoDialog::queryInterface( aType );
49 return aReturn.hasValue() ? aReturn : OABSPilotUno_JBase::queryInterface( aType );
52 void SAL_CALL OABSPilotUno::acquire( ) throw ()
54 svt::OGenericUnoDialog::acquire();
57 void SAL_CALL OABSPilotUno::release( ) throw ()
59 svt::OGenericUnoDialog::release();
62 Sequence< Type > SAL_CALL OABSPilotUno::getTypes( )
64 return ::comphelper::concatSequences(
65 svt::OGenericUnoDialog::getTypes(),
66 OABSPilotUno_JBase::getTypes()
70 Sequence<sal_Int8> SAL_CALL OABSPilotUno::getImplementationId( )
72 return css::uno::Sequence<sal_Int8>();
75 OUString SAL_CALL OABSPilotUno::getImplementationName()
77 return OUString("org.openoffice.comp.abp.OAddressBookSourcePilot");
80 css::uno::Sequence<OUString> SAL_CALL OABSPilotUno::getSupportedServiceNames()
82 return { "com.sun.star.ui.dialogs.AddressBookSourcePilot" };
85 Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo()
87 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
88 return xInfo;
92 ::cppu::IPropertyArrayHelper& OABSPilotUno::getInfoHelper()
94 return *getArrayHelper();
98 ::cppu::IPropertyArrayHelper* OABSPilotUno::createArrayHelper( ) const
100 Sequence< Property > aProps;
101 describeProperties(aProps);
102 return new ::cppu::OPropertyArrayHelper(aProps);
105 void SAL_CALL OABSPilotUno::initialize( const Sequence< Any >& aArguments )
107 Reference<awt::XWindow> xParentWindow;
108 if (aArguments.getLength() == 1 && (aArguments[0] >>= xParentWindow) ) {
109 Sequence< Any > aNewArgs(1);
110 aNewArgs[0] <<= PropertyValue( "ParentWindow", 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE );
111 OGenericUnoDialog::initialize(aNewArgs);
112 } else {
113 OGenericUnoDialog::initialize(aArguments);
117 svt::OGenericUnoDialog::Dialog OABSPilotUno::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
119 return svt::OGenericUnoDialog::Dialog(VclPtr<OAddressBookSourcePilot>::Create(VCLUnoHelper::GetWindow(rParent), m_aContext));
123 Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ )
125 // not interested in the context, not interested in the args
126 // -> call the execute method of the XExecutableDialog
127 static_cast< XExecutableDialog* >( this )->execute();
129 // result interest not really ...
130 // We show this dialog one times only!
131 // User has one chance to accept it or not.
132 // (or he can start it again by using wizard-menu!)
133 // So we should deregister it on our general job execution service by using right protocol parameters.
134 css::uno::Sequence< css::beans::NamedValue > lProtocol { { "Deactivate", css::uno::makeAny( true ) } };
135 return makeAny( lProtocol );
138 void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult)
140 if ( _nExecutionResult == RET_OK )
142 const AddressSettings& aSettings = static_cast<OAddressBookSourcePilot*>(m_aDialog.m_xVclDialog.get())->getSettings();
143 m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName;
148 } // namespace abp
150 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
151 org_openoffice_comp_abp_OAddressBookSourcePilot(
152 css::uno::XComponentContext *context,
153 css::uno::Sequence<css::uno::Any> const &)
155 return cppu::acquire(new abp::OABSPilotUno(context));
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */