update dev300-m58
[ooovba.git] / dbaccess / source / ui / uno / unosqlmessage.cxx
blobddd11802ef48583250a6d96bbbac6f73eda86102
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unosqlmessage.cxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #ifndef _DBAUI_SQLMESSAGE_HXX_
35 #include "sqlmessage.hxx"
36 #endif
37 #ifndef _DBAUI_UNOSQLMESSAGE_HXX_
38 #include "unosqlmessage.hxx"
39 #endif
40 #ifndef _DBU_REGHELPER_HXX_
41 #include "dbu_reghelper.hxx"
42 #endif
43 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
44 #include "dbustrings.hrc"
45 #endif
46 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
47 #include <cppuhelper/typeprovider.hxx>
48 #endif
49 #ifndef _DBHELPER_DBEXCEPTION_HXX_
50 #include <connectivity/dbexception.hxx>
51 #endif
53 using namespace dbaui;
54 using namespace dbtools;
56 using namespace ::com::sun::star::sdbc;
57 using namespace ::com::sun::star::sdb;
59 extern "C" void SAL_CALL createRegistryInfo_OSQLMessageDialog()
61 static OMultiInstanceAutoRegistration< OSQLMessageDialog > aAutoRegistration;
64 //.........................................................................
65 namespace dbaui
67 //.........................................................................
69 using namespace ::com::sun::star::uno;
70 using namespace ::com::sun::star::lang;
71 using namespace ::com::sun::star::beans;
73 //=========================================================================
74 //-------------------------------------------------------------------------
75 OSQLMessageDialog::OSQLMessageDialog(const Reference< XMultiServiceFactory >& _rxORB)
76 :OSQLMessageDialogBase(_rxORB)
78 registerMayBeVoidProperty(PROPERTY_SQLEXCEPTION, PROPERTY_ID_SQLEXCEPTION, PropertyAttribute::TRANSIENT | PropertyAttribute::MAYBEVOID,
79 &m_aException, ::getCppuType(static_cast<SQLException*>(NULL)));
80 registerProperty( PROPERTY_HELP_URL, PROPERTY_ID_HELP_URL, PropertyAttribute::TRANSIENT,
81 &m_sHelpURL, ::getCppuType( &m_sHelpURL ) );
84 //-------------------------------------------------------------------------
85 Sequence<sal_Int8> SAL_CALL OSQLMessageDialog::getImplementationId( ) throw(RuntimeException)
87 static ::cppu::OImplementationId aId;
88 return aId.getImplementationId();
91 //-------------------------------------------------------------------------
92 Reference< XInterface > SAL_CALL OSQLMessageDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
94 return *(new OSQLMessageDialog(_rxFactory));
97 //-------------------------------------------------------------------------
98 ::rtl::OUString SAL_CALL OSQLMessageDialog::getImplementationName() throw(RuntimeException)
100 return getImplementationName_Static();
103 //-------------------------------------------------------------------------
104 ::rtl::OUString OSQLMessageDialog::getImplementationName_Static() throw(RuntimeException)
106 return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.OSQLMessageDialog");
109 //-------------------------------------------------------------------------
110 ::comphelper::StringSequence SAL_CALL OSQLMessageDialog::getSupportedServiceNames() throw(RuntimeException)
112 return getSupportedServiceNames_Static();
115 //-------------------------------------------------------------------------
116 ::comphelper::StringSequence OSQLMessageDialog::getSupportedServiceNames_Static() throw(RuntimeException)
118 ::comphelper::StringSequence aSupported(1);
119 aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.ErrorMessageDialog");
120 return aSupported;
123 //-------------------------------------------------------------------------
124 sal_Bool SAL_CALL OSQLMessageDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException)
126 switch (_nHandle)
128 case PROPERTY_ID_SQLEXCEPTION:
130 SQLExceptionInfo aInfo(_rValue);
131 if (!aInfo.isValid())
132 throw IllegalArgumentException();
134 _rOldValue = m_aException;
135 _rConvertedValue = aInfo.get();
137 return sal_True;
138 // always assume "modified", don't bother with with comparing the two values
140 default:
141 return OSQLMessageDialogBase::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
145 //-------------------------------------------------------------------------
146 Reference<XPropertySetInfo> SAL_CALL OSQLMessageDialog::getPropertySetInfo() throw(RuntimeException)
148 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
149 return xInfo;
152 //-------------------------------------------------------------------------
153 ::cppu::IPropertyArrayHelper& OSQLMessageDialog::getInfoHelper()
155 return *const_cast<OSQLMessageDialog*>(this)->getArrayHelper();
158 //------------------------------------------------------------------------------
159 ::cppu::IPropertyArrayHelper* OSQLMessageDialog::createArrayHelper( ) const
161 Sequence< Property > aProps;
162 describeProperties(aProps);
163 return new ::cppu::OPropertyArrayHelper(aProps);
166 //------------------------------------------------------------------------------
167 Dialog* OSQLMessageDialog::createDialog(Window* _pParent)
169 if ( m_aException.hasValue() )
170 return new OSQLMessageBox( _pParent, SQLExceptionInfo( m_aException ), WB_OK | WB_DEF_OK, m_sHelpURL );
172 OSL_ENSURE(sal_False, "OSQLMessageDialog::createDialog : You should use the SQLException property to specify the error to display!");
173 return new OSQLMessageBox(_pParent, SQLException());
176 //.........................................................................
177 } // namespace dbaui
178 //.........................................................................