LibreOffice Module dbaccess (master) 1
unosqlmessage.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 <sqlmessage.hxx>
21#include <unosqlmessage.hxx>
22#include <stringconstants.hxx>
23#include <strings.hxx>
26#include <vcl/svapp.hxx>
27#include <com/sun/star/awt/XWindow.hpp>
28#include <com/sun/star/beans/PropertyAttribute.hpp>
29#include <com/sun/star/sdbc/SQLException.hpp>
30
31using namespace dbaui;
32using namespace dbtools;
33
34using namespace ::com::sun::star::sdbc;
35using namespace ::com::sun::star::sdb;
36
37extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
39 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
40{
41 return cppu::acquire(new OSQLMessageDialog(context));
42}
43
44namespace dbaui
45{
46
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::lang;
49 using namespace ::com::sun::star::beans;
50
53{
54 registerMayBeVoidProperty(PROPERTY_SQLEXCEPTION, PROPERTY_ID_SQLEXCEPTION, PropertyAttribute::TRANSIENT | PropertyAttribute::MAYBEVOID,
56 registerProperty( PROPERTY_HELP_URL, PROPERTY_ID_HELP_URL, PropertyAttribute::TRANSIENT,
57 &m_sHelpURL, cppu::UnoType<decltype(m_sHelpURL)>::get() );
58}
59
61{
62 return css::uno::Sequence<sal_Int8>();
63}
64
66{
67 return "org.openoffice.comp.dbu.OSQLMessageDialog";
68}
69
70css::uno::Sequence<OUString> SAL_CALL OSQLMessageDialog::getSupportedServiceNames()
71{
72 return { "com.sun.star.sdb.ErrorMessageDialog" };
73}
74
76{
77 OUString title;
79
80 if ((args.getLength() == 3) && (args[0] >>= title) && (args[1] >>= parentWindow)) {
82 {
83 {"Title", Any(title)},
84 {"ParentWindow", Any(parentWindow)},
85 {"SQLException", args[2]}
86 }));
88 } else {
90 }
91}
92
93sal_Bool SAL_CALL OSQLMessageDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue)
94{
95 switch (_nHandle)
96 {
98 {
99 SQLExceptionInfo aInfo(_rValue);
100 if (!aInfo.isValid())
101 throw IllegalArgumentException();
102
103 _rOldValue = m_aException;
104 _rConvertedValue = aInfo.get();
105
106 return true;
107 // always assume "modified", don't bother with comparing the two values
108 }
109 default:
110 return OSQLMessageDialogBase::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
111 }
112}
113
115{
116 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
117 return xInfo;
118}
119
121{
122 return *getArrayHelper();
123}
124
126{
128 describeProperties(aProps);
129 return new ::cppu::OPropertyArrayHelper(aProps);
130}
131
132std::unique_ptr<weld::DialogController> OSQLMessageDialog::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent)
133{
134 weld::Window* pParent = Application::GetFrameWeld(rParent);
135 if ( m_aException.hasValue() )
136 return std::make_unique<OSQLMessageBox>(pParent, SQLExceptionInfo(m_aException), MessBoxStyle::Ok | MessBoxStyle::DefaultOk, m_sHelpURL);
137
138 OSL_FAIL("OSQLMessageDialog::createDialog : You should use the SQLException property to specify the error to display!");
139 return std::make_unique<OSQLMessageBox>(pParent, SQLException());
140}
141
142} // namespace dbaui
143
144/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &_rConvertedValue, css::uno::Any &_rOldValue, sal_Int32 _nHandle, const css::uno::Any &_rValue) override
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual std::unique_ptr< weld::DialogController > createDialog(const css::uno::Reference< css::awt::XWindow > &rParent) override
virtual void SAL_CALL initialize(css::uno::Sequence< css::uno::Any > const &args) override
OSQLMessageDialog(const css::uno::Reference< css::uno::XComponentContext > &_rxORB)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
const css::uno::Any & get() const
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
args
#define PROPERTY_ID_SQLEXCEPTION
#define PROPERTY_ID_HELP_URL
constexpr OUStringLiteral PROPERTY_SQLEXCEPTION(u"SQLException")
constexpr OUStringLiteral PROPERTY_HELP_URL(u"HelpURL")
unsigned char sal_Bool
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_openoffice_comp_dbu_OSQLMessageDialog_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)