build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / dbaccess / source / ui / uno / unosqlmessage.cxx
blob6638c82feaaccd7cfc85c642bfe32146a219fef8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "sqlmessage.hxx"
21 #include "uiservices.hxx"
22 #include "unosqlmessage.hxx"
23 #include "dbu_reghelper.hxx"
24 #include "dbustrings.hrc"
25 #include <comphelper/processfactory.hxx>
26 #include <cppuhelper/typeprovider.hxx>
27 #include <connectivity/dbexception.hxx>
29 using namespace dbaui;
30 using namespace dbtools;
32 using namespace ::com::sun::star::sdbc;
33 using namespace ::com::sun::star::sdb;
35 extern "C" void SAL_CALL createRegistryInfo_OSQLMessageDialog()
37 static OMultiInstanceAutoRegistration< OSQLMessageDialog > aAutoRegistration;
40 namespace dbaui
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::lang;
45 using namespace ::com::sun::star::beans;
47 OSQLMessageDialog::OSQLMessageDialog(const Reference< XComponentContext >& _rxORB)
48 :OSQLMessageDialogBase(_rxORB)
50 registerMayBeVoidProperty(PROPERTY_SQLEXCEPTION, PROPERTY_ID_SQLEXCEPTION, PropertyAttribute::TRANSIENT | PropertyAttribute::MAYBEVOID,
51 &m_aException, ::cppu::UnoType<SQLException>::get());
52 registerProperty( PROPERTY_HELP_URL, PROPERTY_ID_HELP_URL, PropertyAttribute::TRANSIENT,
53 &m_sHelpURL, cppu::UnoType<decltype(m_sHelpURL)>::get() );
56 Sequence<sal_Int8> SAL_CALL OSQLMessageDialog::getImplementationId( ) throw(RuntimeException, std::exception)
58 return css::uno::Sequence<sal_Int8>();
61 Reference< XInterface > SAL_CALL OSQLMessageDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
63 return *(new OSQLMessageDialog( comphelper::getComponentContext(_rxFactory) ));
66 OUString SAL_CALL OSQLMessageDialog::getImplementationName() throw(RuntimeException, std::exception)
68 return getImplementationName_Static();
71 OUString OSQLMessageDialog::getImplementationName_Static() throw(RuntimeException)
73 return OUString("org.openoffice.comp.dbu.OSQLMessageDialog");
76 css::uno::Sequence<OUString> SAL_CALL OSQLMessageDialog::getSupportedServiceNames() throw(RuntimeException, std::exception)
78 return getSupportedServiceNames_Static();
81 css::uno::Sequence<OUString> OSQLMessageDialog::getSupportedServiceNames_Static() throw(RuntimeException)
83 css::uno::Sequence<OUString> aSupported { "com.sun.star.sdb.ErrorMessageDialog" };
84 return aSupported;
87 void OSQLMessageDialog::initialize(Sequence<Any> const & args) throw (css::uno::Exception, css::uno::RuntimeException, std::exception)
89 OUString title;
90 Reference< css::awt::XWindow > parentWindow;
92 if ((args.getLength() == 3) && (args[0] >>= title) && (args[1] >>= parentWindow)) {
93 Sequence<Any> s(3);
94 s[0] <<= PropertyValue( "Title", -1, makeAny(title), PropertyState_DIRECT_VALUE);
95 s[1] <<= PropertyValue( "ParentWindow", -1, makeAny(parentWindow), PropertyState_DIRECT_VALUE);
96 s[2] <<= PropertyValue( "SQLException", -1, args[2], PropertyState_DIRECT_VALUE);
97 OGenericUnoDialog::initialize(s);
98 } else {
99 OGenericUnoDialog::initialize(args);
103 sal_Bool SAL_CALL OSQLMessageDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException)
105 switch (_nHandle)
107 case PROPERTY_ID_SQLEXCEPTION:
109 SQLExceptionInfo aInfo(_rValue);
110 if (!aInfo.isValid())
111 throw IllegalArgumentException();
113 _rOldValue = m_aException;
114 _rConvertedValue = aInfo.get();
116 return true;
117 // always assume "modified", don't bother with comparing the two values
119 default:
120 return OSQLMessageDialogBase::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
124 Reference<XPropertySetInfo> SAL_CALL OSQLMessageDialog::getPropertySetInfo() throw(RuntimeException, std::exception)
126 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
127 return xInfo;
130 ::cppu::IPropertyArrayHelper& OSQLMessageDialog::getInfoHelper()
132 return *getArrayHelper();
135 ::cppu::IPropertyArrayHelper* OSQLMessageDialog::createArrayHelper( ) const
137 Sequence< Property > aProps;
138 describeProperties(aProps);
139 return new ::cppu::OPropertyArrayHelper(aProps);
142 VclPtr<Dialog> OSQLMessageDialog::createDialog(vcl::Window* _pParent)
144 if ( m_aException.hasValue() )
145 return VclPtr<OSQLMessageBox>::Create( _pParent, SQLExceptionInfo( m_aException ), WB_OK | WB_DEF_OK, m_sHelpURL );
147 OSL_FAIL("OSQLMessageDialog::createDialog : You should use the SQLException property to specify the error to display!");
148 return VclPtr<OSQLMessageBox>::Create(_pParent, SQLException());
151 } // namespace dbaui
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */