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