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 : 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, std::exception)
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, std::exception)
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, std::exception)
85 : {
86 0 : return css::uno::Sequence<sal_Int8>();
87 : }
88 :
89 :
90 0 : Reference< XInterface > SAL_CALL OABSPilotUno::Create(const Reference< XMultiServiceFactory >& _rxFactory)
91 : {
92 0 : return *(new OABSPilotUno( comphelper::getComponentContext(_rxFactory) ));
93 : }
94 :
95 :
96 0 : OUString SAL_CALL OABSPilotUno::getImplementationName() throw(RuntimeException, std::exception)
97 : {
98 0 : return getImplementationName_Static();
99 : }
100 :
101 :
102 0 : OUString OABSPilotUno::getImplementationName_Static() throw(RuntimeException)
103 : {
104 0 : return OUString("org.openoffice.comp.abp.OAddressBookSourcePilot");
105 : }
106 :
107 :
108 0 : ::comphelper::StringSequence SAL_CALL OABSPilotUno::getSupportedServiceNames() throw(RuntimeException, std::exception)
109 : {
110 0 : return getSupportedServiceNames_Static();
111 : }
112 :
113 :
114 0 : ::comphelper::StringSequence OABSPilotUno::getSupportedServiceNames_Static() throw(RuntimeException)
115 : {
116 0 : ::comphelper::StringSequence aSupported(1);
117 0 : aSupported[0] = "com.sun.star.ui.dialogs.AddressBookSourcePilot";
118 0 : return aSupported;
119 : }
120 :
121 :
122 0 : Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo() throw(RuntimeException, std::exception)
123 : {
124 0 : Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
125 0 : return xInfo;
126 : }
127 :
128 :
129 0 : ::cppu::IPropertyArrayHelper& OABSPilotUno::getInfoHelper()
130 : {
131 0 : return *const_cast<OABSPilotUno*>(this)->getArrayHelper();
132 : }
133 :
134 :
135 0 : ::cppu::IPropertyArrayHelper* OABSPilotUno::createArrayHelper( ) const
136 : {
137 0 : Sequence< Property > aProps;
138 0 : describeProperties(aProps);
139 0 : return new ::cppu::OPropertyArrayHelper(aProps);
140 : }
141 :
142 0 : void SAL_CALL OABSPilotUno::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException, std::exception)
143 : {
144 0 : Reference<awt::XWindow> xParentWindow;
145 0 : if (aArguments.getLength() == 1 && (aArguments[0] >>= xParentWindow) ) {
146 0 : Sequence< Any > aNewArgs(1);
147 0 : aNewArgs[0] <<= PropertyValue( OUString("ParentWindow"), 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE );
148 0 : OGenericUnoDialog::initialize(aNewArgs);
149 : } else {
150 0 : OGenericUnoDialog::initialize(aArguments);
151 0 : }
152 0 : }
153 :
154 :
155 0 : Dialog* OABSPilotUno::createDialog(vcl::Window* _pParent)
156 : {
157 0 : return new OAddessBookSourcePilot(_pParent, m_aContext );
158 : }
159 :
160 :
161 0 : Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ ) throw (IllegalArgumentException, Exception, RuntimeException, std::exception)
162 : {
163 : // not interested in the context, not interested in the args
164 : // -> call the execute method of the XExecutableDialog
165 0 : static_cast< XExecutableDialog* >( this )->execute();
166 :
167 : // result interest not really ...
168 : // We show this dialog one times only!
169 : // User has one chance to accept it or not.
170 : // (or he can start it again by using wizard-menu!)
171 : // So we should deregister it on our general job execution service by using right protocol parameters.
172 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > lProtocol(1);
173 0 : lProtocol[0].Name = "Deactivate";
174 0 : lProtocol[0].Value <<= sal_True;
175 0 : return makeAny( lProtocol );
176 : }
177 :
178 0 : void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult)
179 : {
180 0 : if ( _nExecutionResult == RET_OK )
181 : {
182 0 : const AddressSettings& aSettings = static_cast<OAddessBookSourcePilot*>(m_pDialog)->getSettings();
183 0 : m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName;
184 : }
185 0 : }
186 :
187 :
188 0 : } // namespace abp
189 :
190 :
191 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|