1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_dbaccess.hxx" 26 27 #ifndef _DBAUI_SQLMESSAGE_HXX_ 28 #include "sqlmessage.hxx" 29 #endif 30 #ifndef _DBAUI_UNOSQLMESSAGE_HXX_ 31 #include "unosqlmessage.hxx" 32 #endif 33 #ifndef _DBU_REGHELPER_HXX_ 34 #include "dbu_reghelper.hxx" 35 #endif 36 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 37 #include "dbustrings.hrc" 38 #endif 39 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ 40 #include <cppuhelper/typeprovider.hxx> 41 #endif 42 #ifndef _DBHELPER_DBEXCEPTION_HXX_ 43 #include <connectivity/dbexception.hxx> 44 #endif 45 46 using namespace dbaui; 47 using namespace dbtools; 48 49 using namespace ::com::sun::star::sdbc; 50 using namespace ::com::sun::star::sdb; 51 52 extern "C" void SAL_CALL createRegistryInfo_OSQLMessageDialog() 53 { 54 static OMultiInstanceAutoRegistration< OSQLMessageDialog > aAutoRegistration; 55 } 56 57 //......................................................................... 58 namespace dbaui 59 { 60 //......................................................................... 61 62 using namespace ::com::sun::star::uno; 63 using namespace ::com::sun::star::lang; 64 using namespace ::com::sun::star::beans; 65 66 //========================================================================= 67 //------------------------------------------------------------------------- 68 OSQLMessageDialog::OSQLMessageDialog(const Reference< XMultiServiceFactory >& _rxORB) 69 :OSQLMessageDialogBase(_rxORB) 70 { 71 registerMayBeVoidProperty(PROPERTY_SQLEXCEPTION, PROPERTY_ID_SQLEXCEPTION, PropertyAttribute::TRANSIENT | PropertyAttribute::MAYBEVOID, 72 &m_aException, ::getCppuType(static_cast<SQLException*>(NULL))); 73 registerProperty( PROPERTY_HELP_URL, PROPERTY_ID_HELP_URL, PropertyAttribute::TRANSIENT, 74 &m_sHelpURL, ::getCppuType( &m_sHelpURL ) ); 75 } 76 77 //------------------------------------------------------------------------- 78 Sequence<sal_Int8> SAL_CALL OSQLMessageDialog::getImplementationId( ) throw(RuntimeException) 79 { 80 static ::cppu::OImplementationId aId; 81 return aId.getImplementationId(); 82 } 83 84 //------------------------------------------------------------------------- 85 Reference< XInterface > SAL_CALL OSQLMessageDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory) 86 { 87 return *(new OSQLMessageDialog(_rxFactory)); 88 } 89 90 //------------------------------------------------------------------------- 91 ::rtl::OUString SAL_CALL OSQLMessageDialog::getImplementationName() throw(RuntimeException) 92 { 93 return getImplementationName_Static(); 94 } 95 96 //------------------------------------------------------------------------- 97 ::rtl::OUString OSQLMessageDialog::getImplementationName_Static() throw(RuntimeException) 98 { 99 return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.OSQLMessageDialog"); 100 } 101 102 //------------------------------------------------------------------------- 103 ::comphelper::StringSequence SAL_CALL OSQLMessageDialog::getSupportedServiceNames() throw(RuntimeException) 104 { 105 return getSupportedServiceNames_Static(); 106 } 107 108 //------------------------------------------------------------------------- 109 ::comphelper::StringSequence OSQLMessageDialog::getSupportedServiceNames_Static() throw(RuntimeException) 110 { 111 ::comphelper::StringSequence aSupported(1); 112 aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.ErrorMessageDialog"); 113 return aSupported; 114 } 115 116 //------------------------------------------------------------------------- 117 sal_Bool SAL_CALL OSQLMessageDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException) 118 { 119 switch (_nHandle) 120 { 121 case PROPERTY_ID_SQLEXCEPTION: 122 { 123 SQLExceptionInfo aInfo(_rValue); 124 if (!aInfo.isValid()) 125 throw IllegalArgumentException(); 126 127 _rOldValue = m_aException; 128 _rConvertedValue = aInfo.get(); 129 130 return sal_True; 131 // always assume "modified", don't bother with with comparing the two values 132 } 133 default: 134 return OSQLMessageDialogBase::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue); 135 } 136 } 137 138 //------------------------------------------------------------------------- 139 Reference<XPropertySetInfo> SAL_CALL OSQLMessageDialog::getPropertySetInfo() throw(RuntimeException) 140 { 141 Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); 142 return xInfo; 143 } 144 145 //------------------------------------------------------------------------- 146 ::cppu::IPropertyArrayHelper& OSQLMessageDialog::getInfoHelper() 147 { 148 return *const_cast<OSQLMessageDialog*>(this)->getArrayHelper(); 149 } 150 151 //------------------------------------------------------------------------------ 152 ::cppu::IPropertyArrayHelper* OSQLMessageDialog::createArrayHelper( ) const 153 { 154 Sequence< Property > aProps; 155 describeProperties(aProps); 156 return new ::cppu::OPropertyArrayHelper(aProps); 157 } 158 159 //------------------------------------------------------------------------------ 160 Dialog* OSQLMessageDialog::createDialog(Window* _pParent) 161 { 162 if ( m_aException.hasValue() ) 163 return new OSQLMessageBox( _pParent, SQLExceptionInfo( m_aException ), WB_OK | WB_DEF_OK, m_sHelpURL ); 164 165 OSL_ENSURE(sal_False, "OSQLMessageDialog::createDialog : You should use the SQLException property to specify the error to display!"); 166 return new OSQLMessageBox(_pParent, SQLException()); 167 } 168 169 //......................................................................... 170 } // namespace dbaui 171 //......................................................................... 172 173