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::lang
;
35 using namespace ::com::sun::star::beans
;
36 using namespace ::com::sun::star::ui::dialogs
;
38 OABSPilotUno::OABSPilotUno(const Reference
< XComponentContext
>& _rxORB
)
39 :OGenericUnoDialog(_rxORB
)
41 registerProperty( "DataSourceName", PROPERTY_ID_DATASOURCENAME
, PropertyAttribute::READONLY
,
42 &m_sDataSourceName
, cppu::UnoType
<decltype(m_sDataSourceName
)>::get() );
45 Any SAL_CALL
OABSPilotUno::queryInterface( const Type
& aType
)
47 Any aReturn
= svt::OGenericUnoDialog::queryInterface( aType
);
48 return aReturn
.hasValue() ? aReturn
: OABSPilotUno_JBase::queryInterface( aType
);
51 void SAL_CALL
OABSPilotUno::acquire( ) noexcept
53 svt::OGenericUnoDialog::acquire();
56 void SAL_CALL
OABSPilotUno::release( ) noexcept
58 svt::OGenericUnoDialog::release();
61 Sequence
< Type
> SAL_CALL
OABSPilotUno::getTypes( )
63 return ::comphelper::concatSequences(
64 svt::OGenericUnoDialog::getTypes(),
65 OABSPilotUno_JBase::getTypes()
69 Sequence
<sal_Int8
> SAL_CALL
OABSPilotUno::getImplementationId( )
71 return css::uno::Sequence
<sal_Int8
>();
74 OUString SAL_CALL
OABSPilotUno::getImplementationName()
76 return "org.openoffice.comp.abp.OAddressBookSourcePilot";
79 css::uno::Sequence
<OUString
> SAL_CALL
OABSPilotUno::getSupportedServiceNames()
81 return { "com.sun.star.ui.dialogs.AddressBookSourcePilot" };
84 Reference
<XPropertySetInfo
> SAL_CALL
OABSPilotUno::getPropertySetInfo()
86 Reference
<XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
91 ::cppu::IPropertyArrayHelper
& OABSPilotUno::getInfoHelper()
93 return *getArrayHelper();
97 ::cppu::IPropertyArrayHelper
* OABSPilotUno::createArrayHelper( ) const
99 Sequence
< Property
> aProps
;
100 describeProperties(aProps
);
101 return new ::cppu::OPropertyArrayHelper(aProps
);
104 void SAL_CALL
OABSPilotUno::initialize( const Sequence
< Any
>& aArguments
)
106 Reference
<awt::XWindow
> xParentWindow
;
107 if (aArguments
.getLength() == 1 && (aArguments
[0] >>= xParentWindow
) ) {
108 Sequence
< Any
> aNewArgs
{ Any(PropertyValue(
109 "ParentWindow", 0, Any(xParentWindow
), PropertyState_DIRECT_VALUE
)) };
110 OGenericUnoDialog::initialize(aNewArgs
);
112 OGenericUnoDialog::initialize(aArguments
);
116 std::unique_ptr
<weld::DialogController
> OABSPilotUno::createDialog(const css::uno::Reference
<css::awt::XWindow
>& rParent
)
118 return std::make_unique
<OAddressBookSourcePilot
>(Application::GetFrameWeld(rParent
), m_aContext
);
121 Any SAL_CALL
OABSPilotUno::execute( const Sequence
< NamedValue
>& /*lArgs*/ )
123 // not interested in the context, not interested in the args
124 // -> call the execute method of the XExecutableDialog
125 static_cast< XExecutableDialog
* >( this )->execute();
127 // result interest not really ...
128 // We show this dialog one times only!
129 // User has one chance to accept it or not.
130 // (or he can start it again by using wizard-menu!)
131 // So we should deregister it on our general job execution service by using right protocol parameters.
132 css::uno::Sequence
< css::beans::NamedValue
> lProtocol
{ { "Deactivate", css::uno::Any( true ) } };
133 return Any( lProtocol
);
136 void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult
)
138 if ( _nExecutionResult
== RET_OK
)
140 const AddressSettings
& aSettings
= static_cast<OAddressBookSourcePilot
*>(m_xDialog
.get())->getSettings();
141 m_sDataSourceName
= aSettings
.bRegisterDataSource
? aSettings
.sRegisteredDataSourceName
: aSettings
.sDataSourceName
;
148 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
149 org_openoffice_comp_abp_OAddressBookSourcePilot(
150 css::uno::XComponentContext
*context
,
151 css::uno::Sequence
<css::uno::Any
> const &)
153 return cppu::acquire(new abp::OABSPilotUno(context
));
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */