Branch data Line data Source code
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 : :
21 : : #include "sqlmessage.hxx"
22 : : #include "unosqlmessage.hxx"
23 : : #include "dbu_reghelper.hxx"
24 : : #include "dbustrings.hrc"
25 : : #include <cppuhelper/typeprovider.hxx>
26 : : #include <connectivity/dbexception.hxx>
27 : :
28 : : using namespace dbaui;
29 : : using namespace dbtools;
30 : :
31 : : using namespace ::com::sun::star::sdbc;
32 : : using namespace ::com::sun::star::sdb;
33 : :
34 : 8 : extern "C" void SAL_CALL createRegistryInfo_OSQLMessageDialog()
35 : : {
36 [ + - ][ + - ]: 8 : static OMultiInstanceAutoRegistration< OSQLMessageDialog > aAutoRegistration;
[ + - ][ # # ]
37 : 8 : }
38 : :
39 : : //.........................................................................
40 : : namespace dbaui
41 : : {
42 : : //.........................................................................
43 : :
44 : : using namespace ::com::sun::star::uno;
45 : : using namespace ::com::sun::star::lang;
46 : : using namespace ::com::sun::star::beans;
47 : :
48 : : //=========================================================================
49 : : //-------------------------------------------------------------------------
50 : 4 : OSQLMessageDialog::OSQLMessageDialog(const Reference< XMultiServiceFactory >& _rxORB)
51 [ + - ][ + - ]: 4 : :OSQLMessageDialogBase(_rxORB)
52 : : {
53 : : registerMayBeVoidProperty(PROPERTY_SQLEXCEPTION, PROPERTY_ID_SQLEXCEPTION, PropertyAttribute::TRANSIENT | PropertyAttribute::MAYBEVOID,
54 [ + - ][ + - ]: 4 : &m_aException, ::getCppuType(static_cast<SQLException*>(NULL)));
[ + - ]
55 : : registerProperty( PROPERTY_HELP_URL, PROPERTY_ID_HELP_URL, PropertyAttribute::TRANSIENT,
56 [ + - ][ + - ]: 4 : &m_sHelpURL, ::getCppuType( &m_sHelpURL ) );
[ + - ]
57 : 4 : }
58 : :
59 : : //-------------------------------------------------------------------------
60 : 0 : Sequence<sal_Int8> SAL_CALL OSQLMessageDialog::getImplementationId( ) throw(RuntimeException)
61 : : {
62 [ # # ][ # # ]: 0 : static ::cppu::OImplementationId aId;
63 : 0 : return aId.getImplementationId();
64 : : }
65 : :
66 : : //-------------------------------------------------------------------------
67 : 4 : Reference< XInterface > SAL_CALL OSQLMessageDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
68 : : {
69 [ + - ]: 4 : return *(new OSQLMessageDialog(_rxFactory));
70 : : }
71 : :
72 : : //-------------------------------------------------------------------------
73 : 0 : ::rtl::OUString SAL_CALL OSQLMessageDialog::getImplementationName() throw(RuntimeException)
74 : : {
75 : 0 : return getImplementationName_Static();
76 : : }
77 : :
78 : : //-------------------------------------------------------------------------
79 : 16 : ::rtl::OUString OSQLMessageDialog::getImplementationName_Static() throw(RuntimeException)
80 : : {
81 : 16 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OSQLMessageDialog"));
82 : : }
83 : :
84 : : //-------------------------------------------------------------------------
85 : 2 : ::comphelper::StringSequence SAL_CALL OSQLMessageDialog::getSupportedServiceNames() throw(RuntimeException)
86 : : {
87 : 2 : return getSupportedServiceNames_Static();
88 : : }
89 : :
90 : : //-------------------------------------------------------------------------
91 : 10 : ::comphelper::StringSequence OSQLMessageDialog::getSupportedServiceNames_Static() throw(RuntimeException)
92 : : {
93 : 10 : ::comphelper::StringSequence aSupported(1);
94 [ + - ][ + - ]: 10 : aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ErrorMessageDialog"));
95 : 10 : return aSupported;
96 : : }
97 : :
98 : : //-------------------------------------------------------------------------
99 : 10 : sal_Bool SAL_CALL OSQLMessageDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException)
100 : : {
101 [ - + ]: 10 : switch (_nHandle)
102 : : {
103 : : case PROPERTY_ID_SQLEXCEPTION:
104 : : {
105 [ # # ]: 0 : SQLExceptionInfo aInfo(_rValue);
106 [ # # ]: 0 : if (!aInfo.isValid())
107 [ # # ]: 0 : throw IllegalArgumentException();
108 : :
109 : 0 : _rOldValue = m_aException;
110 : 0 : _rConvertedValue = aInfo.get();
111 : :
112 [ # # ]: 0 : return sal_True;
113 : : // always assume "modified", don't bother with with comparing the two values
114 : : }
115 : : default:
116 : 10 : return OSQLMessageDialogBase::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
117 : : }
118 : : }
119 : :
120 : : //-------------------------------------------------------------------------
121 : 12 : Reference<XPropertySetInfo> SAL_CALL OSQLMessageDialog::getPropertySetInfo() throw(RuntimeException)
122 : : {
123 : 12 : Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
124 : 12 : return xInfo;
125 : : }
126 : :
127 : : //-------------------------------------------------------------------------
128 : 86 : ::cppu::IPropertyArrayHelper& OSQLMessageDialog::getInfoHelper()
129 : : {
130 : 86 : return *const_cast<OSQLMessageDialog*>(this)->getArrayHelper();
131 : : }
132 : :
133 : : //------------------------------------------------------------------------------
134 : 2 : ::cppu::IPropertyArrayHelper* OSQLMessageDialog::createArrayHelper( ) const
135 : : {
136 [ + - ]: 2 : Sequence< Property > aProps;
137 [ + - ]: 2 : describeProperties(aProps);
138 [ + - ][ + - ]: 2 : return new ::cppu::OPropertyArrayHelper(aProps);
139 : : }
140 : :
141 : : //------------------------------------------------------------------------------
142 : 0 : Dialog* OSQLMessageDialog::createDialog(Window* _pParent)
143 : : {
144 [ # # ]: 0 : if ( m_aException.hasValue() )
145 [ # # ][ # # ]: 0 : return new OSQLMessageBox( _pParent, SQLExceptionInfo( m_aException ), WB_OK | WB_DEF_OK, m_sHelpURL );
146 : :
147 : : OSL_FAIL("OSQLMessageDialog::createDialog : You should use the SQLException property to specify the error to display!");
148 [ # # ][ # # ]: 0 : return new OSQLMessageBox(_pParent, SQLException());
[ # # ][ # # ]
149 : : }
150 : :
151 : : //.........................................................................
152 : : } // namespace dbaui
153 : : //.........................................................................
154 : :
155 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|