1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 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> 35 36 extern "C" void SAL_CALL createRegistryInfo_OABSPilotUno() 37 { 38 static ::abp::OMultiInstanceAutoRegistration< ::abp::OABSPilotUno > aAutoRegistration; 39 } 40 41 #define PROPERTY_ID_DATASOURCENAME 3 42 //......................................................................... 43 namespace abp 44 { 45 //......................................................................... 46 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; 51 52 //===================================================================== 53 //= OABSPilotUno 54 //===================================================================== 55 //--------------------------------------------------------------------- 56 OABSPilotUno::OABSPilotUno(const Reference< XMultiServiceFactory >& _rxORB) 57 :OGenericUnoDialog(_rxORB) 58 { 59 registerProperty( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataSourceName")), PROPERTY_ID_DATASOURCENAME, PropertyAttribute::READONLY , 60 &m_sDataSourceName, ::getCppuType( &m_sDataSourceName ) ); 61 } 62 63 //-------------------------------------------------------------------------- 64 Any SAL_CALL OABSPilotUno::queryInterface( const Type& aType ) throw (RuntimeException) 65 { 66 Any aReturn = OABSPilotUno_DBase::queryInterface( aType ); 67 return aReturn.hasValue() ? aReturn : OABSPilotUno_JBase::queryInterface( aType ); 68 } 69 70 //-------------------------------------------------------------------------- 71 void SAL_CALL OABSPilotUno::acquire( ) throw () 72 { 73 OABSPilotUno_DBase::acquire(); 74 } 75 76 //-------------------------------------------------------------------------- 77 void SAL_CALL OABSPilotUno::release( ) throw () 78 { 79 OABSPilotUno_DBase::release(); 80 } 81 82 //--------------------------------------------------------------------- 83 Sequence< Type > SAL_CALL OABSPilotUno::getTypes( ) throw (RuntimeException) 84 { 85 return ::comphelper::concatSequences( 86 OABSPilotUno_DBase::getTypes(), 87 OABSPilotUno_JBase::getTypes() 88 ); 89 } 90 91 //--------------------------------------------------------------------- 92 Sequence<sal_Int8> SAL_CALL OABSPilotUno::getImplementationId( ) throw(RuntimeException) 93 { 94 static ::cppu::OImplementationId* s_pId; 95 if ( !s_pId ) 96 { 97 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 98 if ( !s_pId ) 99 { 100 static ::cppu::OImplementationId s_aId; 101 s_pId = &s_aId; 102 } 103 } 104 return s_pId->getImplementationId(); 105 } 106 107 //--------------------------------------------------------------------- 108 Reference< XInterface > SAL_CALL OABSPilotUno::Create(const Reference< XMultiServiceFactory >& _rxFactory) 109 { 110 return *(new OABSPilotUno(_rxFactory)); 111 } 112 113 //--------------------------------------------------------------------- 114 ::rtl::OUString SAL_CALL OABSPilotUno::getImplementationName() throw(RuntimeException) 115 { 116 return getImplementationName_Static(); 117 } 118 119 //--------------------------------------------------------------------- 120 ::rtl::OUString OABSPilotUno::getImplementationName_Static() throw(RuntimeException) 121 { 122 return ::rtl::OUString::createFromAscii("org.openoffice.comp.abp.OAddressBookSourcePilot"); 123 } 124 125 //--------------------------------------------------------------------- 126 ::comphelper::StringSequence SAL_CALL OABSPilotUno::getSupportedServiceNames() throw(RuntimeException) 127 { 128 return getSupportedServiceNames_Static(); 129 } 130 131 //--------------------------------------------------------------------- 132 ::comphelper::StringSequence OABSPilotUno::getSupportedServiceNames_Static() throw(RuntimeException) 133 { 134 ::comphelper::StringSequence aSupported(1); 135 aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.AddressBookSourcePilot"); 136 return aSupported; 137 } 138 139 //--------------------------------------------------------------------- 140 Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo() throw(RuntimeException) 141 { 142 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); 143 return xInfo; 144 } 145 146 //--------------------------------------------------------------------- 147 ::cppu::IPropertyArrayHelper& OABSPilotUno::getInfoHelper() 148 { 149 return *const_cast<OABSPilotUno*>(this)->getArrayHelper(); 150 } 151 152 //-------------------------------------------------------------------------- 153 ::cppu::IPropertyArrayHelper* OABSPilotUno::createArrayHelper( ) const 154 { 155 Sequence< Property > aProps; 156 describeProperties(aProps); 157 return new ::cppu::OPropertyArrayHelper(aProps); 158 } 159 160 //-------------------------------------------------------------------------- 161 Dialog* OABSPilotUno::createDialog(Window* _pParent) 162 { 163 return new OAddessBookSourcePilot(_pParent, m_aContext.getLegacyServiceFactory()); 164 } 165 166 //-------------------------------------------------------------------------- 167 Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ ) throw (IllegalArgumentException, Exception, RuntimeException) 168 { 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(); 172 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 ); 182 } 183 // ----------------------------------------------------------------------------- 184 void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult) 185 { 186 if ( _nExecutionResult == RET_OK ) 187 { 188 const AddressSettings& aSettings = static_cast<OAddessBookSourcePilot*>(m_pDialog)->getSettings(); 189 m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName; 190 } 191 } 192 193 //......................................................................... 194 } // namespace abp 195 //......................................................................... 196 197