merged tag ooo/OOO330_m14
[LibreOffice.git] / extensions / source / abpilot / unodialogabp.cxx
blob46534b56d61e021142239c4e8061e318b5c4d715
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "unodialogabp.hxx"
31 #include <cppuhelper/typeprovider.hxx>
32 #include "abspilot.hxx"
33 #include <comphelper/sequence.hxx>
34 #include <vcl/msgbox.hxx>
36 extern "C" void SAL_CALL createRegistryInfo_OABSPilotUno()
38 static ::abp::OMultiInstanceAutoRegistration< ::abp::OABSPilotUno > aAutoRegistration;
41 #define PROPERTY_ID_DATASOURCENAME 3
42 //.........................................................................
43 namespace abp
45 //.........................................................................
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::lang;
49 using namespace ::com::sun::star::beans;
50 using namespace ::com::sun::star::ui::dialogs;
52 //=====================================================================
53 //= OABSPilotUno
54 //=====================================================================
55 //---------------------------------------------------------------------
56 OABSPilotUno::OABSPilotUno(const Reference< XMultiServiceFactory >& _rxORB)
57 :OGenericUnoDialog(_rxORB)
59 registerProperty( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataSourceName")), PROPERTY_ID_DATASOURCENAME, PropertyAttribute::READONLY ,
60 &m_sDataSourceName, ::getCppuType( &m_sDataSourceName ) );
63 //--------------------------------------------------------------------------
64 Any SAL_CALL OABSPilotUno::queryInterface( const Type& aType ) throw (RuntimeException)
66 Any aReturn = OABSPilotUno_DBase::queryInterface( aType );
67 return aReturn.hasValue() ? aReturn : OABSPilotUno_JBase::queryInterface( aType );
70 //--------------------------------------------------------------------------
71 void SAL_CALL OABSPilotUno::acquire( ) throw ()
73 OABSPilotUno_DBase::acquire();
76 //--------------------------------------------------------------------------
77 void SAL_CALL OABSPilotUno::release( ) throw ()
79 OABSPilotUno_DBase::release();
82 //---------------------------------------------------------------------
83 Sequence< Type > SAL_CALL OABSPilotUno::getTypes( ) throw (RuntimeException)
85 return ::comphelper::concatSequences(
86 OABSPilotUno_DBase::getTypes(),
87 OABSPilotUno_JBase::getTypes()
91 //---------------------------------------------------------------------
92 Sequence<sal_Int8> SAL_CALL OABSPilotUno::getImplementationId( ) throw(RuntimeException)
94 static ::cppu::OImplementationId* s_pId;
95 if ( !s_pId )
97 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
98 if ( !s_pId )
100 static ::cppu::OImplementationId s_aId;
101 s_pId = &s_aId;
104 return s_pId->getImplementationId();
107 //---------------------------------------------------------------------
108 Reference< XInterface > SAL_CALL OABSPilotUno::Create(const Reference< XMultiServiceFactory >& _rxFactory)
110 return *(new OABSPilotUno(_rxFactory));
113 //---------------------------------------------------------------------
114 ::rtl::OUString SAL_CALL OABSPilotUno::getImplementationName() throw(RuntimeException)
116 return getImplementationName_Static();
119 //---------------------------------------------------------------------
120 ::rtl::OUString OABSPilotUno::getImplementationName_Static() throw(RuntimeException)
122 return ::rtl::OUString::createFromAscii("org.openoffice.comp.abp.OAddressBookSourcePilot");
125 //---------------------------------------------------------------------
126 ::comphelper::StringSequence SAL_CALL OABSPilotUno::getSupportedServiceNames() throw(RuntimeException)
128 return getSupportedServiceNames_Static();
131 //---------------------------------------------------------------------
132 ::comphelper::StringSequence OABSPilotUno::getSupportedServiceNames_Static() throw(RuntimeException)
134 ::comphelper::StringSequence aSupported(1);
135 aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.AddressBookSourcePilot");
136 return aSupported;
139 //---------------------------------------------------------------------
140 Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo() throw(RuntimeException)
142 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
143 return xInfo;
146 //---------------------------------------------------------------------
147 ::cppu::IPropertyArrayHelper& OABSPilotUno::getInfoHelper()
149 return *const_cast<OABSPilotUno*>(this)->getArrayHelper();
152 //--------------------------------------------------------------------------
153 ::cppu::IPropertyArrayHelper* OABSPilotUno::createArrayHelper( ) const
155 Sequence< Property > aProps;
156 describeProperties(aProps);
157 return new ::cppu::OPropertyArrayHelper(aProps);
160 //--------------------------------------------------------------------------
161 Dialog* OABSPilotUno::createDialog(Window* _pParent)
163 return new OAddessBookSourcePilot(_pParent, m_aContext.getLegacyServiceFactory());
166 //--------------------------------------------------------------------------
167 Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ ) throw (IllegalArgumentException, Exception, RuntimeException)
169 // not interested in the context, not interested in the args
170 // -> call the execute method of the XExecutableDialog
171 static_cast< XExecutableDialog* >( this )->execute();
173 // result interest not really ...
174 // We show this dialog one times only!
175 // User has one chance to accept it or not.
176 // (or he can start it again by using wizard-menu!)
177 // So we should deregister it on our general job execution service by using right protocol parameters.
178 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > lProtocol(1);
179 lProtocol[0].Name = ::rtl::OUString::createFromAscii("Deactivate");
180 lProtocol[0].Value <<= sal_True;
181 return makeAny( lProtocol );
183 // -----------------------------------------------------------------------------
184 void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult)
186 if ( _nExecutionResult == RET_OK )
188 const AddressSettings& aSettings = static_cast<OAddessBookSourcePilot*>(m_pDialog)->getSettings();
189 m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName;
193 //.........................................................................
194 } // namespace abp
195 //.........................................................................