bump product version to 5.0.4.1
[LibreOffice.git] / extensions / source / abpilot / unodialogabp.cxx
blob990b313b7003cb26dadb726b1f9f7dc707bd2bec
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 void SAL_CALL createRegistryInfo_OABSPilotUno()
29 static ::abp::OMultiInstanceAutoRegistration< ::abp::OABSPilotUno > aAutoRegistration;
32 #define PROPERTY_ID_DATASOURCENAME 3
34 namespace abp
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::lang;
41 using namespace ::com::sun::star::beans;
42 using namespace ::com::sun::star::ui::dialogs;
44 OABSPilotUno::OABSPilotUno(const Reference< XComponentContext >& _rxORB)
45 :OGenericUnoDialog(_rxORB)
47 registerProperty( OUString("DataSourceName"), PROPERTY_ID_DATASOURCENAME, PropertyAttribute::READONLY ,
48 &m_sDataSourceName, cppu::UnoType<decltype(m_sDataSourceName)>::get() );
52 Any SAL_CALL OABSPilotUno::queryInterface( const Type& aType ) throw (RuntimeException, std::exception)
54 Any aReturn = OABSPilotUno_DBase::queryInterface( aType );
55 return aReturn.hasValue() ? aReturn : OABSPilotUno_JBase::queryInterface( aType );
59 void SAL_CALL OABSPilotUno::acquire( ) throw ()
61 OABSPilotUno_DBase::acquire();
65 void SAL_CALL OABSPilotUno::release( ) throw ()
67 OABSPilotUno_DBase::release();
71 Sequence< Type > SAL_CALL OABSPilotUno::getTypes( ) throw (RuntimeException, std::exception)
73 return ::comphelper::concatSequences(
74 OABSPilotUno_DBase::getTypes(),
75 OABSPilotUno_JBase::getTypes()
80 Sequence<sal_Int8> SAL_CALL OABSPilotUno::getImplementationId( ) throw(RuntimeException, std::exception)
82 return css::uno::Sequence<sal_Int8>();
86 Reference< XInterface > SAL_CALL OABSPilotUno::Create(const Reference< XMultiServiceFactory >& _rxFactory)
88 return *(new OABSPilotUno( comphelper::getComponentContext(_rxFactory) ));
92 OUString SAL_CALL OABSPilotUno::getImplementationName() throw(RuntimeException, std::exception)
94 return getImplementationName_Static();
98 OUString OABSPilotUno::getImplementationName_Static() throw(RuntimeException)
100 return OUString("org.openoffice.comp.abp.OAddressBookSourcePilot");
104 ::comphelper::StringSequence SAL_CALL OABSPilotUno::getSupportedServiceNames() throw(RuntimeException, std::exception)
106 return getSupportedServiceNames_Static();
110 ::comphelper::StringSequence OABSPilotUno::getSupportedServiceNames_Static() throw(RuntimeException)
112 ::comphelper::StringSequence aSupported(1);
113 aSupported[0] = "com.sun.star.ui.dialogs.AddressBookSourcePilot";
114 return aSupported;
118 Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo() throw(RuntimeException, std::exception)
120 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
121 return xInfo;
125 ::cppu::IPropertyArrayHelper& OABSPilotUno::getInfoHelper()
127 return *getArrayHelper();
131 ::cppu::IPropertyArrayHelper* OABSPilotUno::createArrayHelper( ) const
133 Sequence< Property > aProps;
134 describeProperties(aProps);
135 return new ::cppu::OPropertyArrayHelper(aProps);
138 void SAL_CALL OABSPilotUno::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException, std::exception)
140 Reference<awt::XWindow> xParentWindow;
141 if (aArguments.getLength() == 1 && (aArguments[0] >>= xParentWindow) ) {
142 Sequence< Any > aNewArgs(1);
143 aNewArgs[0] <<= PropertyValue( OUString("ParentWindow"), 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE );
144 OGenericUnoDialog::initialize(aNewArgs);
145 } else {
146 OGenericUnoDialog::initialize(aArguments);
151 VclPtr<Dialog> OABSPilotUno::createDialog(vcl::Window* _pParent)
153 return VclPtr<OAddessBookSourcePilot>::Create(_pParent, m_aContext );
157 Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ ) throw (IllegalArgumentException, Exception, RuntimeException, std::exception)
159 // not interested in the context, not interested in the args
160 // -> call the execute method of the XExecutableDialog
161 static_cast< XExecutableDialog* >( this )->execute();
163 // result interest not really ...
164 // We show this dialog one times only!
165 // User has one chance to accept it or not.
166 // (or he can start it again by using wizard-menu!)
167 // So we should deregister it on our general job execution service by using right protocol parameters.
168 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > lProtocol(1);
169 lProtocol[0].Name = "Deactivate";
170 lProtocol[0].Value <<= sal_True;
171 return makeAny( lProtocol );
174 void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult)
176 if ( _nExecutionResult == RET_OK )
178 const AddressSettings& aSettings = static_cast<OAddessBookSourcePilot*>(m_pDialog.get())->getSettings();
179 m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName;
184 } // namespace abp
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */