1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "unodialogabp.hxx"
21 #include "abspilot.hxx"
22 #include <comphelper/sequence.hxx>
23 #include <vcl/svapp.hxx>
24 #include <com/sun/star/beans/PropertyAttribute.hpp>
25 #include <com/sun/star/beans/PropertyValue.hpp>
26 #include <com/sun/star/awt/XWindow.hpp>
28 #define PROPERTY_ID_DATASOURCENAME 3
32 using namespace ::com::sun::star
;
33 using namespace ::com::sun::star::uno
;
34 using namespace ::com::sun::star::beans
;
35 using namespace ::com::sun::star::ui::dialogs
;
37 OABSPilotUno::OABSPilotUno(const Reference
< XComponentContext
>& _rxORB
)
38 : OABSPilotUno_JBase(_rxORB
)
40 registerProperty( u
"DataSourceName"_ustr
, PROPERTY_ID_DATASOURCENAME
, PropertyAttribute::READONLY
,
41 &m_sDataSourceName
, cppu::UnoType
<decltype(m_sDataSourceName
)>::get() );
44 OUString SAL_CALL
OABSPilotUno::getImplementationName()
46 return u
"org.openoffice.comp.abp.OAddressBookSourcePilot"_ustr
;
49 css::uno::Sequence
<OUString
> SAL_CALL
OABSPilotUno::getSupportedServiceNames()
51 return { u
"com.sun.star.ui.dialogs.AddressBookSourcePilot"_ustr
};
54 Reference
<XPropertySetInfo
> SAL_CALL
OABSPilotUno::getPropertySetInfo()
56 Reference
<XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
61 ::cppu::IPropertyArrayHelper
& OABSPilotUno::getInfoHelper()
63 return *getArrayHelper();
67 ::cppu::IPropertyArrayHelper
* OABSPilotUno::createArrayHelper( ) const
69 Sequence
< Property
> aProps
;
70 describeProperties(aProps
);
71 return new ::cppu::OPropertyArrayHelper(aProps
);
74 void SAL_CALL
OABSPilotUno::initialize( const Sequence
< Any
>& aArguments
)
76 Reference
<awt::XWindow
> xParentWindow
;
77 if (aArguments
.getLength() == 1 && (aArguments
[0] >>= xParentWindow
) ) {
78 Sequence
< Any
> aNewArgs
{ Any(PropertyValue(
79 u
"ParentWindow"_ustr
, 0, Any(xParentWindow
), PropertyState_DIRECT_VALUE
)) };
80 OGenericUnoDialog::initialize(aNewArgs
);
82 OGenericUnoDialog::initialize(aArguments
);
86 std::unique_ptr
<weld::DialogController
> OABSPilotUno::createDialog(const css::uno::Reference
<css::awt::XWindow
>& rParent
)
88 return std::make_unique
<OAddressBookSourcePilot
>(Application::GetFrameWeld(rParent
), m_aContext
);
91 Any SAL_CALL
OABSPilotUno::execute( const Sequence
< NamedValue
>& /*lArgs*/ )
93 // not interested in the context, not interested in the args
94 // -> call the execute method of the XExecutableDialog
95 static_cast< XExecutableDialog
* >( this )->execute();
97 // result interest not really ...
98 // We show this dialog one times only!
99 // User has one chance to accept it or not.
100 // (or he can start it again by using wizard-menu!)
101 // So we should deregister it on our general job execution service by using right protocol parameters.
102 css::uno::Sequence
< css::beans::NamedValue
> lProtocol
{ { u
"Deactivate"_ustr
, css::uno::Any( true ) } };
103 return Any( lProtocol
);
106 void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult
)
108 if ( _nExecutionResult
== RET_OK
)
110 const AddressSettings
& aSettings
= static_cast<OAddressBookSourcePilot
*>(m_xDialog
.get())->getSettings();
111 m_sDataSourceName
= aSettings
.bRegisterDataSource
? aSettings
.sRegisteredDataSourceName
: aSettings
.sDataSourceName
;
118 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
119 org_openoffice_comp_abp_OAddressBookSourcePilot(
120 css::uno::XComponentContext
*context
,
121 css::uno::Sequence
<css::uno::Any
> const &)
123 return cppu::acquire(new abp::OABSPilotUno(context
));
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */