1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unodialogabp.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include "unodialogabp.hxx"
34 #include <cppuhelper/typeprovider.hxx>
35 #include "abspilot.hxx"
36 #include <comphelper/sequence.hxx>
37 #include <vcl/msgbox.hxx>
39 extern "C" void SAL_CALL
createRegistryInfo_OABSPilotUno()
41 static ::abp::OMultiInstanceAutoRegistration
< ::abp::OABSPilotUno
> aAutoRegistration
;
44 #define PROPERTY_ID_DATASOURCENAME 3
45 //.........................................................................
48 //.........................................................................
50 using namespace ::com::sun::star::uno
;
51 using namespace ::com::sun::star::lang
;
52 using namespace ::com::sun::star::beans
;
53 using namespace ::com::sun::star::ui::dialogs
;
55 //=====================================================================
57 //=====================================================================
58 //---------------------------------------------------------------------
59 OABSPilotUno::OABSPilotUno(const Reference
< XMultiServiceFactory
>& _rxORB
)
60 :OGenericUnoDialog(_rxORB
)
62 registerProperty( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataSourceName")), PROPERTY_ID_DATASOURCENAME
, PropertyAttribute::READONLY
,
63 &m_sDataSourceName
, ::getCppuType( &m_sDataSourceName
) );
66 //--------------------------------------------------------------------------
67 Any SAL_CALL
OABSPilotUno::queryInterface( const Type
& aType
) throw (RuntimeException
)
69 Any aReturn
= OABSPilotUno_DBase::queryInterface( aType
);
70 return aReturn
.hasValue() ? aReturn
: OABSPilotUno_JBase::queryInterface( aType
);
73 //--------------------------------------------------------------------------
74 void SAL_CALL
OABSPilotUno::acquire( ) throw ()
76 OABSPilotUno_DBase::acquire();
79 //--------------------------------------------------------------------------
80 void SAL_CALL
OABSPilotUno::release( ) throw ()
82 OABSPilotUno_DBase::release();
85 //---------------------------------------------------------------------
86 Sequence
< Type
> SAL_CALL
OABSPilotUno::getTypes( ) throw (RuntimeException
)
88 return ::comphelper::concatSequences(
89 OABSPilotUno_DBase::getTypes(),
90 OABSPilotUno_JBase::getTypes()
94 //---------------------------------------------------------------------
95 Sequence
<sal_Int8
> SAL_CALL
OABSPilotUno::getImplementationId( ) throw(RuntimeException
)
97 static ::cppu::OImplementationId
* s_pId
;
100 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
103 static ::cppu::OImplementationId s_aId
;
107 return s_pId
->getImplementationId();
110 //---------------------------------------------------------------------
111 Reference
< XInterface
> SAL_CALL
OABSPilotUno::Create(const Reference
< XMultiServiceFactory
>& _rxFactory
)
113 return *(new OABSPilotUno(_rxFactory
));
116 //---------------------------------------------------------------------
117 ::rtl::OUString SAL_CALL
OABSPilotUno::getImplementationName() throw(RuntimeException
)
119 return getImplementationName_Static();
122 //---------------------------------------------------------------------
123 ::rtl::OUString
OABSPilotUno::getImplementationName_Static() throw(RuntimeException
)
125 return ::rtl::OUString::createFromAscii("org.openoffice.comp.abp.OAddressBookSourcePilot");
128 //---------------------------------------------------------------------
129 ::comphelper::StringSequence SAL_CALL
OABSPilotUno::getSupportedServiceNames() throw(RuntimeException
)
131 return getSupportedServiceNames_Static();
134 //---------------------------------------------------------------------
135 ::comphelper::StringSequence
OABSPilotUno::getSupportedServiceNames_Static() throw(RuntimeException
)
137 ::comphelper::StringSequence
aSupported(1);
138 aSupported
.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.AddressBookSourcePilot");
142 //---------------------------------------------------------------------
143 Reference
<XPropertySetInfo
> SAL_CALL
OABSPilotUno::getPropertySetInfo() throw(RuntimeException
)
145 Reference
<XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
149 //---------------------------------------------------------------------
150 ::cppu::IPropertyArrayHelper
& OABSPilotUno::getInfoHelper()
152 return *const_cast<OABSPilotUno
*>(this)->getArrayHelper();
155 //--------------------------------------------------------------------------
156 ::cppu::IPropertyArrayHelper
* OABSPilotUno::createArrayHelper( ) const
158 Sequence
< Property
> aProps
;
159 describeProperties(aProps
);
160 return new ::cppu::OPropertyArrayHelper(aProps
);
163 //--------------------------------------------------------------------------
164 Dialog
* OABSPilotUno::createDialog(Window
* _pParent
)
166 return new OAddessBookSourcePilot(_pParent
, m_aContext
.getLegacyServiceFactory());
169 //--------------------------------------------------------------------------
170 Any SAL_CALL
OABSPilotUno::execute( const Sequence
< NamedValue
>& /*lArgs*/ ) throw (IllegalArgumentException
, Exception
, RuntimeException
)
172 // not interested in the context, not interested in the args
173 // -> call the execute method of the XExecutableDialog
174 static_cast< XExecutableDialog
* >( this )->execute();
176 // result interest not really ...
177 // We show this dialog one times only!
178 // User has one chance to accept it or not.
179 // (or he can start it again by using wizard-menu!)
180 // So we should deregister it on our general job execution service by using right protocol parameters.
181 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
> lProtocol(1);
182 lProtocol
[0].Name
= ::rtl::OUString::createFromAscii("Deactivate");
183 lProtocol
[0].Value
<<= sal_True
;
184 return makeAny( lProtocol
);
186 // -----------------------------------------------------------------------------
187 void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult
)
189 if ( _nExecutionResult
== RET_OK
)
191 const AddressSettings
& aSettings
= static_cast<OAddessBookSourcePilot
*>(m_pDialog
)->getSettings();
192 m_sDataSourceName
= aSettings
.bRegisterDataSource
? aSettings
.sRegisteredDataSourceName
: aSettings
.sDataSourceName
;
196 //.........................................................................
198 //.........................................................................