bump product version to 4.1.6.2
[LibreOffice.git] / extensions / source / abpilot / unodialogabp.cxx
blobfaa79d095305ba1c743004d79ef933d22f0c71f6
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 extern "C" void SAL_CALL createRegistryInfo_OABSPilotUno()
29 static ::abp::OMultiInstanceAutoRegistration< ::abp::OABSPilotUno > aAutoRegistration;
32 #define PROPERTY_ID_DATASOURCENAME 3
33 //.........................................................................
34 namespace abp
36 //.........................................................................
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 //=====================================================================
45 //= OABSPilotUno
46 //=====================================================================
47 //---------------------------------------------------------------------
48 OABSPilotUno::OABSPilotUno(const Reference< XComponentContext >& _rxORB)
49 :OGenericUnoDialog(_rxORB)
51 registerProperty( OUString("DataSourceName"), PROPERTY_ID_DATASOURCENAME, PropertyAttribute::READONLY ,
52 &m_sDataSourceName, ::getCppuType( &m_sDataSourceName ) );
55 //--------------------------------------------------------------------------
56 Any SAL_CALL OABSPilotUno::queryInterface( const Type& aType ) throw (RuntimeException)
58 Any aReturn = OABSPilotUno_DBase::queryInterface( aType );
59 return aReturn.hasValue() ? aReturn : OABSPilotUno_JBase::queryInterface( aType );
62 //--------------------------------------------------------------------------
63 void SAL_CALL OABSPilotUno::acquire( ) throw ()
65 OABSPilotUno_DBase::acquire();
68 //--------------------------------------------------------------------------
69 void SAL_CALL OABSPilotUno::release( ) throw ()
71 OABSPilotUno_DBase::release();
74 //---------------------------------------------------------------------
75 Sequence< Type > SAL_CALL OABSPilotUno::getTypes( ) throw (RuntimeException)
77 return ::comphelper::concatSequences(
78 OABSPilotUno_DBase::getTypes(),
79 OABSPilotUno_JBase::getTypes()
83 //---------------------------------------------------------------------
84 Sequence<sal_Int8> SAL_CALL OABSPilotUno::getImplementationId( ) throw(RuntimeException)
86 static ::cppu::OImplementationId* s_pId;
87 if ( !s_pId )
89 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
90 if ( !s_pId )
92 static ::cppu::OImplementationId s_aId;
93 s_pId = &s_aId;
96 return s_pId->getImplementationId();
99 //---------------------------------------------------------------------
100 Reference< XInterface > SAL_CALL OABSPilotUno::Create(const Reference< XMultiServiceFactory >& _rxFactory)
102 return *(new OABSPilotUno( comphelper::getComponentContext(_rxFactory) ));
105 //---------------------------------------------------------------------
106 OUString SAL_CALL OABSPilotUno::getImplementationName() throw(RuntimeException)
108 return getImplementationName_Static();
111 //---------------------------------------------------------------------
112 OUString OABSPilotUno::getImplementationName_Static() throw(RuntimeException)
114 return OUString("org.openoffice.comp.abp.OAddressBookSourcePilot");
117 //---------------------------------------------------------------------
118 ::comphelper::StringSequence SAL_CALL OABSPilotUno::getSupportedServiceNames() throw(RuntimeException)
120 return getSupportedServiceNames_Static();
123 //---------------------------------------------------------------------
124 ::comphelper::StringSequence OABSPilotUno::getSupportedServiceNames_Static() throw(RuntimeException)
126 ::comphelper::StringSequence aSupported(1);
127 aSupported.getArray()[0] = OUString("com.sun.star.ui.dialogs.AddressBookSourcePilot");
128 return aSupported;
131 //---------------------------------------------------------------------
132 Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo() throw(RuntimeException)
134 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
135 return xInfo;
138 //---------------------------------------------------------------------
139 ::cppu::IPropertyArrayHelper& OABSPilotUno::getInfoHelper()
141 return *const_cast<OABSPilotUno*>(this)->getArrayHelper();
144 //--------------------------------------------------------------------------
145 ::cppu::IPropertyArrayHelper* OABSPilotUno::createArrayHelper( ) const
147 Sequence< Property > aProps;
148 describeProperties(aProps);
149 return new ::cppu::OPropertyArrayHelper(aProps);
152 void SAL_CALL OABSPilotUno::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException)
154 Reference<awt::XWindow> xParentWindow;
155 if (aArguments.getLength() == 1 && (aArguments[0] >>= xParentWindow) ) {
156 Sequence< Any > aNewArgs(1);
157 aNewArgs[0] <<= PropertyValue( OUString("ParentWindow"), 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE );
158 OGenericUnoDialog::initialize(aNewArgs);
159 } else {
160 OGenericUnoDialog::initialize(aArguments);
164 //--------------------------------------------------------------------------
165 Dialog* OABSPilotUno::createDialog(Window* _pParent)
167 return new OAddessBookSourcePilot(_pParent, m_aContext );
170 //--------------------------------------------------------------------------
171 Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ ) throw (IllegalArgumentException, Exception, RuntimeException)
173 // not interested in the context, not interested in the args
174 // -> call the execute method of the XExecutableDialog
175 static_cast< XExecutableDialog* >( this )->execute();
177 // result interest not really ...
178 // We show this dialog one times only!
179 // User has one chance to accept it or not.
180 // (or he can start it again by using wizard-menu!)
181 // So we should deregister it on our general job execution service by using right protocol parameters.
182 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > lProtocol(1);
183 lProtocol[0].Name = OUString("Deactivate");
184 lProtocol[0].Value <<= sal_True;
185 return makeAny( lProtocol );
187 // -----------------------------------------------------------------------------
188 void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult)
190 if ( _nExecutionResult == RET_OK )
192 const AddressSettings& aSettings = static_cast<OAddessBookSourcePilot*>(m_pDialog)->getSettings();
193 m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName;
197 //.........................................................................
198 } // namespace abp
199 //.........................................................................
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */