Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / extensions / source / abpilot / unodialogabp.cxx
blob7dc6ab8de2b59ea3885a33dc85c68caaf40736ec
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/processfactory.hxx>
24 #include <comphelper/sequence.hxx>
25 #include <vcl/msgbox.hxx>
27 #define PROPERTY_ID_DATASOURCENAME 3
29 namespace abp
31 using namespace ::com::sun::star;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::lang;
34 using namespace ::com::sun::star::beans;
35 using namespace ::com::sun::star::ui::dialogs;
37 OABSPilotUno::OABSPilotUno(const Reference< XComponentContext >& _rxORB)
38 :OGenericUnoDialog(_rxORB)
40 registerProperty( "DataSourceName", PROPERTY_ID_DATASOURCENAME, PropertyAttribute::READONLY ,
41 &m_sDataSourceName, cppu::UnoType<decltype(m_sDataSourceName)>::get() );
44 Any SAL_CALL OABSPilotUno::queryInterface( const Type& aType )
46 Any aReturn = svt::OGenericUnoDialog::queryInterface( aType );
47 return aReturn.hasValue() ? aReturn : OABSPilotUno_JBase::queryInterface( aType );
50 void SAL_CALL OABSPilotUno::acquire( ) throw ()
52 svt::OGenericUnoDialog::acquire();
55 void SAL_CALL OABSPilotUno::release( ) throw ()
57 svt::OGenericUnoDialog::release();
60 Sequence< Type > SAL_CALL OABSPilotUno::getTypes( )
62 return ::comphelper::concatSequences(
63 svt::OGenericUnoDialog::getTypes(),
64 OABSPilotUno_JBase::getTypes()
68 Sequence<sal_Int8> SAL_CALL OABSPilotUno::getImplementationId( )
70 return css::uno::Sequence<sal_Int8>();
73 OUString SAL_CALL OABSPilotUno::getImplementationName()
75 return OUString("org.openoffice.comp.abp.OAddressBookSourcePilot");
78 css::uno::Sequence<OUString> SAL_CALL OABSPilotUno::getSupportedServiceNames()
80 return { "com.sun.star.ui.dialogs.AddressBookSourcePilot" };
83 Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo()
85 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
86 return xInfo;
90 ::cppu::IPropertyArrayHelper& OABSPilotUno::getInfoHelper()
92 return *getArrayHelper();
96 ::cppu::IPropertyArrayHelper* OABSPilotUno::createArrayHelper( ) const
98 Sequence< Property > aProps;
99 describeProperties(aProps);
100 return new ::cppu::OPropertyArrayHelper(aProps);
103 void SAL_CALL OABSPilotUno::initialize( const Sequence< Any >& aArguments )
105 Reference<awt::XWindow> xParentWindow;
106 if (aArguments.getLength() == 1 && (aArguments[0] >>= xParentWindow) ) {
107 Sequence< Any > aNewArgs(1);
108 aNewArgs[0] <<= PropertyValue( "ParentWindow", 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE );
109 OGenericUnoDialog::initialize(aNewArgs);
110 } else {
111 OGenericUnoDialog::initialize(aArguments);
115 VclPtr<Dialog> OABSPilotUno::createDialog(vcl::Window* _pParent)
117 return VclPtr<OAddressBookSourcePilot>::Create(_pParent, m_aContext );
121 Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ )
123 // not interested in the context, not interested in the args
124 // -> call the execute method of the XExecutableDialog
125 static_cast< XExecutableDialog* >( this )->execute();
127 // result interest not really ...
128 // We show this dialog one times only!
129 // User has one chance to accept it or not.
130 // (or he can start it again by using wizard-menu!)
131 // So we should deregister it on our general job execution service by using right protocol parameters.
132 css::uno::Sequence< css::beans::NamedValue > lProtocol { { "Deactivate", css::uno::makeAny( true ) } };
133 return makeAny( lProtocol );
136 void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult)
138 if ( _nExecutionResult == RET_OK )
140 const AddressSettings& aSettings = static_cast<OAddressBookSourcePilot*>(m_pDialog.get())->getSettings();
141 m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName;
146 } // namespace abp
148 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
149 org_openoffice_comp_abp_OAddressBookSourcePilot(
150 css::uno::XComponentContext *context,
151 css::uno::Sequence<css::uno::Any> const &)
153 abp::OModule::setResourceFilePrefix("abp");
155 return cppu::acquire(new abp::OABSPilotUno(context));
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */