Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
26 :
27 0 : extern "C" void SAL_CALL createRegistryInfo_OABSPilotUno()
28 : {
29 0 : static ::abp::OMultiInstanceAutoRegistration< ::abp::OABSPilotUno > aAutoRegistration;
30 0 : }
31 :
32 : #define PROPERTY_ID_DATASOURCENAME 3
33 : //.........................................................................
34 : namespace abp
35 : {
36 : //.........................................................................
37 :
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;
43 :
44 : //=====================================================================
45 : //= OABSPilotUno
46 : //=====================================================================
47 : //---------------------------------------------------------------------
48 0 : OABSPilotUno::OABSPilotUno(const Reference< XComponentContext >& _rxORB)
49 0 : :OGenericUnoDialog(_rxORB)
50 : {
51 : registerProperty( OUString("DataSourceName"), PROPERTY_ID_DATASOURCENAME, PropertyAttribute::READONLY ,
52 0 : &m_sDataSourceName, ::getCppuType( &m_sDataSourceName ) );
53 0 : }
54 :
55 : //--------------------------------------------------------------------------
56 0 : Any SAL_CALL OABSPilotUno::queryInterface( const Type& aType ) throw (RuntimeException)
57 : {
58 0 : Any aReturn = OABSPilotUno_DBase::queryInterface( aType );
59 0 : return aReturn.hasValue() ? aReturn : OABSPilotUno_JBase::queryInterface( aType );
60 : }
61 :
62 : //--------------------------------------------------------------------------
63 0 : void SAL_CALL OABSPilotUno::acquire( ) throw ()
64 : {
65 0 : OABSPilotUno_DBase::acquire();
66 0 : }
67 :
68 : //--------------------------------------------------------------------------
69 0 : void SAL_CALL OABSPilotUno::release( ) throw ()
70 : {
71 0 : OABSPilotUno_DBase::release();
72 0 : }
73 :
74 : //---------------------------------------------------------------------
75 0 : Sequence< Type > SAL_CALL OABSPilotUno::getTypes( ) throw (RuntimeException)
76 : {
77 : return ::comphelper::concatSequences(
78 : OABSPilotUno_DBase::getTypes(),
79 : OABSPilotUno_JBase::getTypes()
80 0 : );
81 : }
82 :
83 : //---------------------------------------------------------------------
84 0 : Sequence<sal_Int8> SAL_CALL OABSPilotUno::getImplementationId( ) throw(RuntimeException)
85 : {
86 : static ::cppu::OImplementationId* s_pId;
87 0 : if ( !s_pId )
88 : {
89 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
90 0 : if ( !s_pId )
91 : {
92 0 : static ::cppu::OImplementationId s_aId;
93 0 : s_pId = &s_aId;
94 0 : }
95 : }
96 0 : return s_pId->getImplementationId();
97 : }
98 :
99 : //---------------------------------------------------------------------
100 0 : Reference< XInterface > SAL_CALL OABSPilotUno::Create(const Reference< XMultiServiceFactory >& _rxFactory)
101 : {
102 0 : return *(new OABSPilotUno( comphelper::getComponentContext(_rxFactory) ));
103 : }
104 :
105 : //---------------------------------------------------------------------
106 0 : OUString SAL_CALL OABSPilotUno::getImplementationName() throw(RuntimeException)
107 : {
108 0 : return getImplementationName_Static();
109 : }
110 :
111 : //---------------------------------------------------------------------
112 0 : OUString OABSPilotUno::getImplementationName_Static() throw(RuntimeException)
113 : {
114 0 : return OUString("org.openoffice.comp.abp.OAddressBookSourcePilot");
115 : }
116 :
117 : //---------------------------------------------------------------------
118 0 : ::comphelper::StringSequence SAL_CALL OABSPilotUno::getSupportedServiceNames() throw(RuntimeException)
119 : {
120 0 : return getSupportedServiceNames_Static();
121 : }
122 :
123 : //---------------------------------------------------------------------
124 0 : ::comphelper::StringSequence OABSPilotUno::getSupportedServiceNames_Static() throw(RuntimeException)
125 : {
126 0 : ::comphelper::StringSequence aSupported(1);
127 0 : aSupported.getArray()[0] = OUString("com.sun.star.ui.dialogs.AddressBookSourcePilot");
128 0 : return aSupported;
129 : }
130 :
131 : //---------------------------------------------------------------------
132 0 : Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo() throw(RuntimeException)
133 : {
134 0 : Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
135 0 : return xInfo;
136 : }
137 :
138 : //---------------------------------------------------------------------
139 0 : ::cppu::IPropertyArrayHelper& OABSPilotUno::getInfoHelper()
140 : {
141 0 : return *const_cast<OABSPilotUno*>(this)->getArrayHelper();
142 : }
143 :
144 : //--------------------------------------------------------------------------
145 0 : ::cppu::IPropertyArrayHelper* OABSPilotUno::createArrayHelper( ) const
146 : {
147 0 : Sequence< Property > aProps;
148 0 : describeProperties(aProps);
149 0 : return new ::cppu::OPropertyArrayHelper(aProps);
150 : }
151 :
152 0 : void SAL_CALL OABSPilotUno::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException)
153 : {
154 0 : Reference<awt::XWindow> xParentWindow;
155 0 : if (aArguments.getLength() == 1 && (aArguments[0] >>= xParentWindow) ) {
156 0 : Sequence< Any > aNewArgs(1);
157 0 : aNewArgs[0] <<= PropertyValue( OUString("ParentWindow"), 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE );
158 0 : OGenericUnoDialog::initialize(aNewArgs);
159 : } else {
160 0 : OGenericUnoDialog::initialize(aArguments);
161 0 : }
162 0 : }
163 :
164 : //--------------------------------------------------------------------------
165 0 : Dialog* OABSPilotUno::createDialog(Window* _pParent)
166 : {
167 0 : return new OAddessBookSourcePilot(_pParent, m_aContext );
168 : }
169 :
170 : //--------------------------------------------------------------------------
171 0 : Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ ) throw (IllegalArgumentException, Exception, RuntimeException)
172 : {
173 : // not interested in the context, not interested in the args
174 : // -> call the execute method of the XExecutableDialog
175 0 : static_cast< XExecutableDialog* >( this )->execute();
176 :
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 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > lProtocol(1);
183 0 : lProtocol[0].Name = OUString("Deactivate");
184 0 : lProtocol[0].Value <<= sal_True;
185 0 : return makeAny( lProtocol );
186 : }
187 : // -----------------------------------------------------------------------------
188 0 : void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult)
189 : {
190 0 : if ( _nExecutionResult == RET_OK )
191 : {
192 0 : const AddressSettings& aSettings = static_cast<OAddessBookSourcePilot*>(m_pDialog)->getSettings();
193 0 : m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName;
194 : }
195 0 : }
196 :
197 : //.........................................................................
198 0 : } // namespace abp
199 : //.........................................................................
200 :
201 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|