LibreOffice Module extensions (master) 1
unodialogabp.cxx
Go to the documentation of this file.
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 "abspilot.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>
27
28#define PROPERTY_ID_DATASOURCENAME 3
29
30namespace abp
31{
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;
37
38 OABSPilotUno::OABSPilotUno(const Reference< XComponentContext >& _rxORB)
39 :OGenericUnoDialog(_rxORB)
40 {
41 registerProperty( "DataSourceName", PROPERTY_ID_DATASOURCENAME, PropertyAttribute::READONLY ,
43 }
44
45 Any SAL_CALL OABSPilotUno::queryInterface( const Type& aType )
46 {
48 return aReturn.hasValue() ? aReturn : OABSPilotUno_JBase::queryInterface( aType );
49 }
50
51 void SAL_CALL OABSPilotUno::acquire( ) noexcept
52 {
53 svt::OGenericUnoDialog::acquire();
54 }
55
56 void SAL_CALL OABSPilotUno::release( ) noexcept
57 {
58 svt::OGenericUnoDialog::release();
59 }
60
62 {
63 return ::comphelper::concatSequences(
66 );
67 }
68
69 Sequence<sal_Int8> SAL_CALL OABSPilotUno::getImplementationId( )
70 {
71 return css::uno::Sequence<sal_Int8>();
72 }
73
75 {
76 return "org.openoffice.comp.abp.OAddressBookSourcePilot";
77 }
78
79 css::uno::Sequence<OUString> SAL_CALL OABSPilotUno::getSupportedServiceNames()
80 {
81 return { "com.sun.star.ui.dialogs.AddressBookSourcePilot" };
82 }
83
84 Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo()
85 {
86 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
87 return xInfo;
88 }
89
90
92 {
93 return *getArrayHelper();
94 }
95
96
98 {
99 Sequence< Property > aProps;
100 describeProperties(aProps);
101 return new ::cppu::OPropertyArrayHelper(aProps);
102 }
103
104 void SAL_CALL OABSPilotUno::initialize( const Sequence< Any >& aArguments )
105 {
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);
111 } else {
112 OGenericUnoDialog::initialize(aArguments);
113 }
114 }
115
116 std::unique_ptr<weld::DialogController> OABSPilotUno::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
117 {
118 return std::make_unique<OAddressBookSourcePilot>(Application::GetFrameWeld(rParent), m_aContext);
119 }
120
121 Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ )
122 {
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();
126
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 );
134 }
135
136 void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult)
137 {
138 if ( _nExecutionResult == RET_OK )
139 {
140 const AddressSettings& aSettings = static_cast<OAddressBookSourcePilot*>(m_xDialog.get())->getSettings();
142 }
143 }
144
145
146} // namespace abp
147
148extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
150 css::uno::XComponentContext *context,
151 css::uno::Sequence<css::uno::Any> const &)
152{
153 return cppu::acquire(new abp::OABSPilotUno(context));
154}
155
156/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
the UNO wrapper for the address book source pilot
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual std::unique_ptr< weld::DialogController > createDialog(const css::uno::Reference< css::awt::XWindow > &rParent) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
OUString m_sDataSourceName
OABSPilotUno(const css::uno::Reference< css::uno::XComponentContext > &_rxORB)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void SAL_CALL acquire() noexcept override
virtual void executedDialog(sal_Int16 _nExecutionResult) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual void SAL_CALL release() noexcept override
::cppu::IPropertyArrayHelper * getArrayHelper()
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
std::unique_ptr< weld::DialogController > m_xDialog
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
css::uno::Reference< css::uno::XComponentContext > m_aContext
virtual sal_Int16 SAL_CALL execute() override
Sequence< PropertyValue > aArguments
Type
OUString sRegisteredDataSourceName
#define PROPERTY_ID_DATASOURCENAME
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_openoffice_comp_abp_OAddressBookSourcePilot(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
RET_OK