LibreOffice Module extensions (master)
1
extensions
source
abpilot
admininvokationimpl.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 "
admininvokationimpl.hxx
"
21
#include <
comphelper/diagnose_ex.hxx
>
22
#include <
tools/debug.hxx
>
23
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
24
#include <com/sun/star/awt/XWindow.hpp>
25
#include <com/sun/star/sdbc/DriverManager.hpp>
26
#include <
comphelper/propertysequence.hxx
>
27
#include <strings.hrc>
28
#include <
componentmodule.hxx
>
29
#include <utility>
30
#include <
vcl/stdtext.hxx
>
31
#include <
vcl/weld.hxx
>
32
33
namespace
abp
34
{
35
36
37
using namespace
::
com::sun::star::uno
;
38
using namespace
::
com::sun::star::lang
;
39
using namespace
::
com::sun::star::beans
;
40
using namespace
::
com::sun::star::awt
;
41
using namespace
::
com::sun::star::ui::dialogs
;
42
using namespace
::
com::sun::star::sdbc
;
43
44
OAdminDialogInvokation::OAdminDialogInvokation
(
const
Reference< XComponentContext >& _rxContext,
45
css::uno::Reference< css::beans::XPropertySet > _xDataSource,
46
weld::Window
* _pMessageParent)
47
:
m_xContext
(_rxContext)
48
,
m_xDataSource
(
std
::move(_xDataSource))
49
,m_pMessageParent(_pMessageParent)
50
{
51
DBG_ASSERT
(
m_xContext
.is(),
"OAdminDialogInvokation::OAdminDialogInvokation: invalid service factory!"
);
52
DBG_ASSERT
(
m_xDataSource
.is(),
"OAdminDialogInvokation::OAdminDialogInvokation: invalid preferred name!"
);
53
assert(
m_pMessageParent
&&
"OAdminDialogInvokation::OAdminDialogInvokation: invalid message parent!"
);
54
}
55
56
57
bool
OAdminDialogInvokation::invokeAdministration
()
58
{
59
if
(!
m_xContext
.is())
60
return
false
;
61
62
try
63
{
64
// the service name of the administration dialog
65
static
const
char16_t
s_sAdministrationServiceName[] =
u
"com.sun.star.sdb.DatasourceAdministrationDialog"
;
66
static
constexpr
OUStringLiteral s_sDataSourceTypeChangeDialog =
u
"com.sun.star.sdb.DataSourceTypeChangeDialog"
;
67
68
// the parameters for the call
69
Sequence<Any>
aArguments
(
comphelper::InitAnyPropertySequence
(
70
{
71
{
"ParentWindow"
,
Any
(
m_pMessageParent
->
GetXWindow
())},
72
{
"Title"
,
Any
(
compmodule::ModuleRes
(RID_STR_ADMINDIALOGTITLE))},
73
{
"InitialSelection"
,
Any
(
m_xDataSource
)},
// the name of the new data source
74
}));
75
76
77
// create the dialog
78
Reference< XExecutableDialog > xDialog;
79
{
80
// creating the dialog service is potentially expensive (if all the libraries invoked need to be loaded)
81
// so we display a wait cursor
82
weld::WaitObject
aWaitCursor(
m_pMessageParent
);
83
Reference<XInterface>
x
=
m_xContext
->getServiceManager()->createInstanceWithArgumentsAndContext(s_sDataSourceTypeChangeDialog,
aArguments
,
m_xContext
);
84
xDialog.set(
x
, UNO_QUERY );
85
86
// just for a smoother UI: What the dialog does upon execution, is (amongst other things) creating
87
// the DriverManager service
88
// If this context has never been accessed before, this may be expensive (it includes loading of
89
// at least one library).
90
// As this wizard is intended to run on the first office start, it is very likely that the
91
// context needs to be freshly created
92
// Thus, we access the context here (within the WaitCursor), which means the user sees a waitcursor
93
// while his/her office blocks a few seconds...
94
DriverManager::create(
m_xContext
);
95
}
96
97
if
(xDialog.is())
98
{
// execute it
99
if
(xDialog->execute())
100
return
true
;
101
}
102
else
103
ShowServiceNotAvailableError
(
m_pMessageParent
, s_sAdministrationServiceName,
true
);
104
}
105
catch
(
const
Exception
&)
106
{
107
TOOLS_WARN_EXCEPTION
(
"extensions.abpilot"
,
108
"caught an exception while executing the dialog!"
);
109
}
110
return
false
;
111
}
112
113
114
}
// namespace abp
115
116
117
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
admininvokationimpl.hxx
abp::OAdminDialogInvokation::invokeAdministration
bool invokeAdministration()
Definition:
admininvokationimpl.cxx:57
abp::OAdminDialogInvokation::m_pMessageParent
weld::Window * m_pMessageParent
Definition:
admininvokationimpl.hxx:38
abp::OAdminDialogInvokation::OAdminDialogInvokation
OAdminDialogInvokation(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, css::uno::Reference< css::beans::XPropertySet > _xDataSource, weld::Window *_pMessageParent)
Definition:
admininvokationimpl.cxx:44
abp::OAdminDialogInvokation::m_xDataSource
css::uno::Reference< css::beans::XPropertySet > m_xDataSource
Definition:
admininvokationimpl.hxx:37
abp::OAdminDialogInvokation::m_xContext
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition:
admininvokationimpl.hxx:36
weld::WaitObject
weld::Window
weld::Window::GetXWindow
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
componentmodule.hxx
m_xDataSource
Reference< XDataSource > m_xDataSource
debug.hxx
DBG_ASSERT
#define DBG_ASSERT(sCon, aError)
diagnose_ex.hxx
TOOLS_WARN_EXCEPTION
#define TOOLS_WARN_EXCEPTION(area, stream)
u
float u
x
float x
GotoObjFlags::Any
@ Any
m_xContext
Reference< XComponentContext > m_xContext
Definition:
filehandler.cxx:78
aArguments
Sequence< PropertyValue > aArguments
abp
Definition:
abpfinalpage.cxx:33
Sort::Exception
@ Exception
com::sun::star::awt
com::sun::star::beans
com::sun::star::lang
com::sun::star::sdbc
com::sun::star::ui::dialogs
com::sun::star::uno
comphelper::InitAnyPropertySequence
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
compmodule::ModuleRes
OUString ModuleRes(TranslateId pId)
Definition:
componentmodule.cxx:26
std
propertysequence.hxx
stdtext.hxx
ShowServiceNotAvailableError
void VCL_DLLPUBLIC ShowServiceNotAvailableError(weld::Widget *pParent, std::u16string_view rServiceName, bool bError)
weld.hxx
Generated on Sun Jul 30 2023 04:39:36 for LibreOffice Module extensions (master) by
1.9.3