Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "unodialogabp.hxx"
30 : : #include <cppuhelper/typeprovider.hxx>
31 : : #include "abspilot.hxx"
32 : : #include <comphelper/sequence.hxx>
33 : : #include <vcl/msgbox.hxx>
34 : :
35 : 0 : extern "C" void SAL_CALL createRegistryInfo_OABSPilotUno()
36 : : {
37 : 0 : static ::abp::OMultiInstanceAutoRegistration< ::abp::OABSPilotUno > aAutoRegistration;
38 : 0 : }
39 : :
40 : : #define PROPERTY_ID_DATASOURCENAME 3
41 : : //.........................................................................
42 : : namespace abp
43 : : {
44 : : //.........................................................................
45 : :
46 : : using namespace ::com::sun::star::uno;
47 : : using namespace ::com::sun::star::lang;
48 : : using namespace ::com::sun::star::beans;
49 : : using namespace ::com::sun::star::ui::dialogs;
50 : :
51 : : //=====================================================================
52 : : //= OABSPilotUno
53 : : //=====================================================================
54 : : //---------------------------------------------------------------------
55 : 0 : OABSPilotUno::OABSPilotUno(const Reference< XMultiServiceFactory >& _rxORB)
56 : 0 : :OGenericUnoDialog(_rxORB)
57 : : {
58 : : registerProperty( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataSourceName")), PROPERTY_ID_DATASOURCENAME, PropertyAttribute::READONLY ,
59 : 0 : &m_sDataSourceName, ::getCppuType( &m_sDataSourceName ) );
60 : 0 : }
61 : :
62 : : //--------------------------------------------------------------------------
63 : 0 : Any SAL_CALL OABSPilotUno::queryInterface( const Type& aType ) throw (RuntimeException)
64 : : {
65 : 0 : Any aReturn = OABSPilotUno_DBase::queryInterface( aType );
66 : 0 : return aReturn.hasValue() ? aReturn : OABSPilotUno_JBase::queryInterface( aType );
67 : : }
68 : :
69 : : //--------------------------------------------------------------------------
70 : 0 : void SAL_CALL OABSPilotUno::acquire( ) throw ()
71 : : {
72 : 0 : OABSPilotUno_DBase::acquire();
73 : 0 : }
74 : :
75 : : //--------------------------------------------------------------------------
76 : 0 : void SAL_CALL OABSPilotUno::release( ) throw ()
77 : : {
78 : 0 : OABSPilotUno_DBase::release();
79 : 0 : }
80 : :
81 : : //---------------------------------------------------------------------
82 : 0 : Sequence< Type > SAL_CALL OABSPilotUno::getTypes( ) throw (RuntimeException)
83 : : {
84 : : return ::comphelper::concatSequences(
85 : : OABSPilotUno_DBase::getTypes(),
86 : : OABSPilotUno_JBase::getTypes()
87 : 0 : );
88 : : }
89 : :
90 : : //---------------------------------------------------------------------
91 : 0 : Sequence<sal_Int8> SAL_CALL OABSPilotUno::getImplementationId( ) throw(RuntimeException)
92 : : {
93 : : static ::cppu::OImplementationId* s_pId;
94 : 0 : if ( !s_pId )
95 : : {
96 : 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
97 : 0 : if ( !s_pId )
98 : : {
99 : 0 : static ::cppu::OImplementationId s_aId;
100 : 0 : s_pId = &s_aId;
101 : 0 : }
102 : : }
103 : 0 : return s_pId->getImplementationId();
104 : : }
105 : :
106 : : //---------------------------------------------------------------------
107 : 0 : Reference< XInterface > SAL_CALL OABSPilotUno::Create(const Reference< XMultiServiceFactory >& _rxFactory)
108 : : {
109 : 0 : return *(new OABSPilotUno(_rxFactory));
110 : : }
111 : :
112 : : //---------------------------------------------------------------------
113 : 0 : ::rtl::OUString SAL_CALL OABSPilotUno::getImplementationName() throw(RuntimeException)
114 : : {
115 : 0 : return getImplementationName_Static();
116 : : }
117 : :
118 : : //---------------------------------------------------------------------
119 : 0 : ::rtl::OUString OABSPilotUno::getImplementationName_Static() throw(RuntimeException)
120 : : {
121 : 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.abp.OAddressBookSourcePilot"));
122 : : }
123 : :
124 : : //---------------------------------------------------------------------
125 : 0 : ::comphelper::StringSequence SAL_CALL OABSPilotUno::getSupportedServiceNames() throw(RuntimeException)
126 : : {
127 : 0 : return getSupportedServiceNames_Static();
128 : : }
129 : :
130 : : //---------------------------------------------------------------------
131 : 0 : ::comphelper::StringSequence OABSPilotUno::getSupportedServiceNames_Static() throw(RuntimeException)
132 : : {
133 : 0 : ::comphelper::StringSequence aSupported(1);
134 : 0 : aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.dialogs.AddressBookSourcePilot"));
135 : 0 : return aSupported;
136 : : }
137 : :
138 : : //---------------------------------------------------------------------
139 : 0 : Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo() throw(RuntimeException)
140 : : {
141 : 0 : Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
142 : 0 : return xInfo;
143 : : }
144 : :
145 : : //---------------------------------------------------------------------
146 : 0 : ::cppu::IPropertyArrayHelper& OABSPilotUno::getInfoHelper()
147 : : {
148 : 0 : return *const_cast<OABSPilotUno*>(this)->getArrayHelper();
149 : : }
150 : :
151 : : //--------------------------------------------------------------------------
152 : 0 : ::cppu::IPropertyArrayHelper* OABSPilotUno::createArrayHelper( ) const
153 : : {
154 : 0 : Sequence< Property > aProps;
155 : 0 : describeProperties(aProps);
156 : 0 : return new ::cppu::OPropertyArrayHelper(aProps);
157 : : }
158 : :
159 : : //--------------------------------------------------------------------------
160 : 0 : Dialog* OABSPilotUno::createDialog(Window* _pParent)
161 : : {
162 : 0 : return new OAddessBookSourcePilot(_pParent, m_aContext.getLegacyServiceFactory());
163 : : }
164 : :
165 : : //--------------------------------------------------------------------------
166 : 0 : Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ ) throw (IllegalArgumentException, Exception, RuntimeException)
167 : : {
168 : : // not interested in the context, not interested in the args
169 : : // -> call the execute method of the XExecutableDialog
170 : 0 : static_cast< XExecutableDialog* >( this )->execute();
171 : :
172 : : // result interest not really ...
173 : : // We show this dialog one times only!
174 : : // User has one chance to accept it or not.
175 : : // (or he can start it again by using wizard-menu!)
176 : : // So we should deregister it on our general job execution service by using right protocol parameters.
177 : 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > lProtocol(1);
178 : 0 : lProtocol[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Deactivate"));
179 : 0 : lProtocol[0].Value <<= sal_True;
180 : 0 : return makeAny( lProtocol );
181 : : }
182 : : // -----------------------------------------------------------------------------
183 : 0 : void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult)
184 : : {
185 : 0 : if ( _nExecutionResult == RET_OK )
186 : : {
187 : 0 : const AddressSettings& aSettings = static_cast<OAddessBookSourcePilot*>(m_pDialog)->getSettings();
188 : 0 : m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName;
189 : : }
190 : 0 : }
191 : :
192 : : //.........................................................................
193 : : } // namespace abp
194 : : //.........................................................................
195 : :
196 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|