summaryrefslogtreecommitdiffstats
path: root/extensions/source/abpilot/unodialogabp.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /extensions/source/abpilot/unodialogabp.cxx
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extensions/source/abpilot/unodialogabp.cxx')
-rw-r--r--extensions/source/abpilot/unodialogabp.cxx156
1 files changed, 156 insertions, 0 deletions
diff --git a/extensions/source/abpilot/unodialogabp.cxx b/extensions/source/abpilot/unodialogabp.cxx
new file mode 100644
index 000000000..812773213
--- /dev/null
+++ b/extensions/source/abpilot/unodialogabp.cxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "unodialogabp.hxx"
+#include "abspilot.hxx"
+#include <comphelper/sequence.hxx>
+#include <vcl/svapp.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+
+#define PROPERTY_ID_DATASOURCENAME 3
+
+namespace abp
+{
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::ui::dialogs;
+
+ OABSPilotUno::OABSPilotUno(const Reference< XComponentContext >& _rxORB)
+ :OGenericUnoDialog(_rxORB)
+ {
+ registerProperty( "DataSourceName", PROPERTY_ID_DATASOURCENAME, PropertyAttribute::READONLY ,
+ &m_sDataSourceName, cppu::UnoType<decltype(m_sDataSourceName)>::get() );
+ }
+
+ Any SAL_CALL OABSPilotUno::queryInterface( const Type& aType )
+ {
+ Any aReturn = svt::OGenericUnoDialog::queryInterface( aType );
+ return aReturn.hasValue() ? aReturn : OABSPilotUno_JBase::queryInterface( aType );
+ }
+
+ void SAL_CALL OABSPilotUno::acquire( ) throw ()
+ {
+ svt::OGenericUnoDialog::acquire();
+ }
+
+ void SAL_CALL OABSPilotUno::release( ) throw ()
+ {
+ svt::OGenericUnoDialog::release();
+ }
+
+ Sequence< Type > SAL_CALL OABSPilotUno::getTypes( )
+ {
+ return ::comphelper::concatSequences(
+ svt::OGenericUnoDialog::getTypes(),
+ OABSPilotUno_JBase::getTypes()
+ );
+ }
+
+ Sequence<sal_Int8> SAL_CALL OABSPilotUno::getImplementationId( )
+ {
+ return css::uno::Sequence<sal_Int8>();
+ }
+
+ OUString SAL_CALL OABSPilotUno::getImplementationName()
+ {
+ return "org.openoffice.comp.abp.OAddressBookSourcePilot";
+ }
+
+ css::uno::Sequence<OUString> SAL_CALL OABSPilotUno::getSupportedServiceNames()
+ {
+ return { "com.sun.star.ui.dialogs.AddressBookSourcePilot" };
+ }
+
+ Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo()
+ {
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+
+ ::cppu::IPropertyArrayHelper& OABSPilotUno::getInfoHelper()
+ {
+ return *getArrayHelper();
+ }
+
+
+ ::cppu::IPropertyArrayHelper* OABSPilotUno::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+ }
+
+ void SAL_CALL OABSPilotUno::initialize( const Sequence< Any >& aArguments )
+ {
+ Reference<awt::XWindow> xParentWindow;
+ if (aArguments.getLength() == 1 && (aArguments[0] >>= xParentWindow) ) {
+ Sequence< Any > aNewArgs(1);
+ aNewArgs[0] <<= PropertyValue( "ParentWindow", 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE );
+ OGenericUnoDialog::initialize(aNewArgs);
+ } else {
+ OGenericUnoDialog::initialize(aArguments);
+ }
+ }
+
+ std::unique_ptr<weld::DialogController> OABSPilotUno::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
+ {
+ return std::make_unique<OAddressBookSourcePilot>(Application::GetFrameWeld(rParent), m_aContext);
+ }
+
+ Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ )
+ {
+ // not interested in the context, not interested in the args
+ // -> call the execute method of the XExecutableDialog
+ static_cast< XExecutableDialog* >( this )->execute();
+
+ // result interest not really ...
+ // We show this dialog one times only!
+ // User has one chance to accept it or not.
+ // (or he can start it again by using wizard-menu!)
+ // So we should deregister it on our general job execution service by using right protocol parameters.
+ css::uno::Sequence< css::beans::NamedValue > lProtocol { { "Deactivate", css::uno::makeAny( true ) } };
+ return makeAny( lProtocol );
+ }
+
+ void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult)
+ {
+ if ( _nExecutionResult == RET_OK )
+ {
+ const AddressSettings& aSettings = static_cast<OAddressBookSourcePilot*>(m_xDialog.get())->getSettings();
+ m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName;
+ }
+ }
+
+
+} // namespace abp
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+org_openoffice_comp_abp_OAddressBookSourcePilot(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new abp::OABSPilotUno(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */