1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #ifndef _DBAUI_SQLMESSAGE_HXX_ 32*cdf0e10cSrcweir #include "sqlmessage.hxx" 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir #ifndef _DBU_DLG_HRC_ 35*cdf0e10cSrcweir #include "dbu_dlg.hrc" 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir #ifndef _DBAUI_SQLMESSAGE_HRC_ 38*cdf0e10cSrcweir #include "sqlmessage.hrc" 39*cdf0e10cSrcweir #endif 40*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_ 41*cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLException.hpp> 42*cdf0e10cSrcweir #endif 43*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ 44*cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp> 45*cdf0e10cSrcweir #endif 46*cdf0e10cSrcweir #ifndef _SV_GROUP_HXX //autogen 47*cdf0e10cSrcweir #include <vcl/fixed.hxx> 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir #ifndef _SVTREEBOX_HXX 50*cdf0e10cSrcweir #include <svtools/svtreebx.hxx> 51*cdf0e10cSrcweir #endif 52*cdf0e10cSrcweir #ifndef _SVEDIT_HXX //autogen 53*cdf0e10cSrcweir #include <svtools/svmedit.hxx> 54*cdf0e10cSrcweir #endif 55*cdf0e10cSrcweir #ifndef _DBHELPER_DBEXCEPTION_HXX_ 56*cdf0e10cSrcweir #include <connectivity/dbexception.hxx> 57*cdf0e10cSrcweir #endif 58*cdf0e10cSrcweir #ifndef CONNECTIVITY_SQLERROR_HXX 59*cdf0e10cSrcweir #include <connectivity/sqlerror.hxx> 60*cdf0e10cSrcweir #endif 61*cdf0e10cSrcweir #ifndef _SV_MSGBOX_HXX //autogen 62*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 63*cdf0e10cSrcweir #endif 64*cdf0e10cSrcweir #ifndef _UTL_CONFIGMGR_HXX_ 65*cdf0e10cSrcweir #include <unotools/configmgr.hxx> 66*cdf0e10cSrcweir #endif 67*cdf0e10cSrcweir #ifndef _SFX_SFXUNO_HXX 68*cdf0e10cSrcweir #include <sfx2/sfxuno.hxx> 69*cdf0e10cSrcweir #endif 70*cdf0e10cSrcweir #ifndef _DBA_DBACCESS_HELPID_HRC_ 71*cdf0e10cSrcweir #include "dbaccess_helpid.hrc" 72*cdf0e10cSrcweir #endif 73*cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX 74*cdf0e10cSrcweir #include "UITools.hxx" 75*cdf0e10cSrcweir #endif 76*cdf0e10cSrcweir #ifndef _DBAUI_MODULE_DBU_HXX_ 77*cdf0e10cSrcweir #include "moduledbu.hxx" 78*cdf0e10cSrcweir #endif 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir #include <tools/urlobj.hxx> 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir #define BUTTONID_MORE BUTTONID_RETRY + 1 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir #define DIALOG_WIDTH 220 85*cdf0e10cSrcweir #define OUTER_MARGIN 6 86*cdf0e10cSrcweir #define IMAGE_SIZE 20 87*cdf0e10cSrcweir #define INNER_PADDING 3 88*cdf0e10cSrcweir #define TEXT_POS_X ( OUTER_MARGIN + IMAGE_SIZE + INNER_PADDING ) 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir using namespace dbtools; 91*cdf0e10cSrcweir using namespace com::sun::star::uno; 92*cdf0e10cSrcweir using namespace com::sun::star::sdb; 93*cdf0e10cSrcweir using namespace com::sun::star::sdbc; 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir //......................................................................... 96*cdf0e10cSrcweir namespace dbaui 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir //......................................................................... 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir namespace 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir //------------------------------------------------------------------------------ 103*cdf0e10cSrcweir class IImageProvider 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir public: 106*cdf0e10cSrcweir virtual Image getImage( bool _highContrast ) const = 0; 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir virtual ~IImageProvider() { } 109*cdf0e10cSrcweir }; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir //------------------------------------------------------------------------------ 112*cdf0e10cSrcweir class ILabelProvider 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir public: 115*cdf0e10cSrcweir virtual String getLabel() const = 0; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir virtual ~ILabelProvider() { }; 118*cdf0e10cSrcweir }; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir //------------------------------------------------------------------------------ 121*cdf0e10cSrcweir class ImageProvider : public IImageProvider 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir private: 124*cdf0e10cSrcweir sal_uInt16 m_defaultImageID; 125*cdf0e10cSrcweir sal_uInt16 m_highContrastImageID; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir mutable Image m_defaultImage; 128*cdf0e10cSrcweir mutable Image m_highContrastImage; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir public: 131*cdf0e10cSrcweir ImageProvider( sal_uInt16 _defaultImageID, sal_uInt16 _highContrastImageID ) 132*cdf0e10cSrcweir :m_defaultImageID( _defaultImageID ) 133*cdf0e10cSrcweir ,m_highContrastImageID( _highContrastImageID ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir virtual Image getImage( bool _highContrast ) const 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir if ( _highContrast ) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir if ( !m_highContrastImage ) 142*cdf0e10cSrcweir m_highContrastImage = Image( ModuleRes( m_highContrastImageID ) ); 143*cdf0e10cSrcweir return m_highContrastImage; 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir if ( !m_defaultImage ) 147*cdf0e10cSrcweir m_defaultImage = Image( ModuleRes( m_defaultImageID ) ); 148*cdf0e10cSrcweir return m_defaultImage; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir }; 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir //------------------------------------------------------------------------------ 153*cdf0e10cSrcweir class LabelProvider : public ILabelProvider 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir private: 156*cdf0e10cSrcweir String m_label; 157*cdf0e10cSrcweir public: 158*cdf0e10cSrcweir LabelProvider( sal_uInt16 _labelResourceID ) 159*cdf0e10cSrcweir :m_label( ModuleRes( _labelResourceID ) ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir virtual String getLabel() const 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir return m_label; 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir }; 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir //------------------------------------------------------------------------------ 170*cdf0e10cSrcweir class ProviderFactory 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir private: 173*cdf0e10cSrcweir mutable ::boost::shared_ptr< IImageProvider > m_pErrorImage; 174*cdf0e10cSrcweir mutable ::boost::shared_ptr< IImageProvider > m_pWarningsImage; 175*cdf0e10cSrcweir mutable ::boost::shared_ptr< IImageProvider > m_pInfoImage; 176*cdf0e10cSrcweir mutable ::boost::shared_ptr< ILabelProvider > m_pErrorLabel; 177*cdf0e10cSrcweir mutable ::boost::shared_ptr< ILabelProvider > m_pWarningsLabel; 178*cdf0e10cSrcweir mutable ::boost::shared_ptr< ILabelProvider > m_pInfoLabel; 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir public: 181*cdf0e10cSrcweir ProviderFactory() 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir ::boost::shared_ptr< IImageProvider > getImageProvider( SQLExceptionInfo::TYPE _eType ) const 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir ::boost::shared_ptr< IImageProvider >* ppProvider( &m_pErrorImage ); 188*cdf0e10cSrcweir sal_uInt16 nNormalImageID( BMP_EXCEPTION_ERROR ); 189*cdf0e10cSrcweir sal_uInt16 nHCImageID( BMP_EXCEPTION_ERROR_SCH ); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir switch ( _eType ) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir case SQLExceptionInfo::SQL_WARNING: 194*cdf0e10cSrcweir ppProvider = &m_pWarningsImage; 195*cdf0e10cSrcweir nNormalImageID = BMP_EXCEPTION_WARNING; 196*cdf0e10cSrcweir nHCImageID = BMP_EXCEPTION_WARNING_SCH; 197*cdf0e10cSrcweir break; 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir case SQLExceptionInfo::SQL_CONTEXT: 200*cdf0e10cSrcweir ppProvider = &m_pInfoImage; 201*cdf0e10cSrcweir nNormalImageID = BMP_EXCEPTION_INFO; 202*cdf0e10cSrcweir nHCImageID = BMP_EXCEPTION_INFO_SCH; 203*cdf0e10cSrcweir break; 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir default: 206*cdf0e10cSrcweir break; 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir if ( !ppProvider->get() ) 210*cdf0e10cSrcweir ppProvider->reset( new ImageProvider( nNormalImageID, nHCImageID ) ); 211*cdf0e10cSrcweir return *ppProvider; 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir ::boost::shared_ptr< ILabelProvider > getLabelProvider( SQLExceptionInfo::TYPE _eType, bool _bSubLabel ) const 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir ::boost::shared_ptr< ILabelProvider >* ppProvider( &m_pErrorLabel ); 217*cdf0e10cSrcweir sal_uInt16 nLabelID( STR_EXCEPTION_ERROR ); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir switch ( _eType ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir case SQLExceptionInfo::SQL_WARNING: 222*cdf0e10cSrcweir ppProvider = &m_pWarningsLabel; 223*cdf0e10cSrcweir nLabelID = STR_EXCEPTION_WARNING; 224*cdf0e10cSrcweir break; 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir case SQLExceptionInfo::SQL_CONTEXT: 227*cdf0e10cSrcweir ppProvider = &m_pInfoLabel; 228*cdf0e10cSrcweir nLabelID = _bSubLabel ? STR_EXCEPTION_DETAILS : STR_EXCEPTION_INFO; 229*cdf0e10cSrcweir break; 230*cdf0e10cSrcweir default: 231*cdf0e10cSrcweir break; 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir if ( !ppProvider->get() ) 235*cdf0e10cSrcweir ppProvider->reset( new LabelProvider( nLabelID ) ); 236*cdf0e10cSrcweir return *ppProvider; 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir }; 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir //------------------------------------------------------------------------------ 242*cdf0e10cSrcweir /// a stripped version of the SQLException, packed for displaying 243*cdf0e10cSrcweir struct ExceptionDisplayInfo 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir SQLExceptionInfo::TYPE eType; 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir ::boost::shared_ptr< IImageProvider > pImageProvider; 248*cdf0e10cSrcweir ::boost::shared_ptr< ILabelProvider > pLabelProvider; 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir bool bSubEntry; 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir String sMessage; 253*cdf0e10cSrcweir String sSQLState; 254*cdf0e10cSrcweir String sErrorCode; 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir ExceptionDisplayInfo() : eType( SQLExceptionInfo::UNDEFINED ), bSubEntry( false ) { } 257*cdf0e10cSrcweir ExceptionDisplayInfo( SQLExceptionInfo::TYPE _eType ) : eType( _eType ), bSubEntry( false ) { } 258*cdf0e10cSrcweir }; 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir static bool lcl_hasDetails( const ExceptionDisplayInfo& _displayInfo ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir return ( _displayInfo.sErrorCode.Len() ) 263*cdf0e10cSrcweir || ( _displayInfo.sSQLState.Len() 264*cdf0e10cSrcweir && !_displayInfo.sSQLState.EqualsAscii( "S1000" ) 265*cdf0e10cSrcweir ); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir typedef ::std::vector< ExceptionDisplayInfo > ExceptionDisplayChain; 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir //------------------------------------------------------------------------------ 271*cdf0e10cSrcweir /// strips the [OOoBase] vendor identifier from the given error message, if applicable 272*cdf0e10cSrcweir ::rtl::OUString lcl_stripOOoBaseVendor( const ::rtl::OUString& _rErrorMessage ) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir ::rtl::OUString sErrorMessage( _rErrorMessage ); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir const ::rtl::OUString sVendorIdentifier( ::connectivity::SQLError::getMessagePrefix() ); 277*cdf0e10cSrcweir if ( sErrorMessage.indexOf( sVendorIdentifier ) == 0 ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir // characters to strip 280*cdf0e10cSrcweir sal_Int32 nStripLen( sVendorIdentifier.getLength() ); 281*cdf0e10cSrcweir // usually, there should be a whitespace between the vendor and the real message 282*cdf0e10cSrcweir while ( ( sErrorMessage.getLength() > nStripLen ) 283*cdf0e10cSrcweir && ( sErrorMessage[nStripLen] == ' ' ) 284*cdf0e10cSrcweir ) 285*cdf0e10cSrcweir ++nStripLen; 286*cdf0e10cSrcweir sErrorMessage = sErrorMessage.copy( nStripLen ); 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir return sErrorMessage; 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir //------------------------------------------------------------------------------ 293*cdf0e10cSrcweir void lcl_buildExceptionChain( const SQLExceptionInfo& _rErrorInfo, const ProviderFactory& _rFactory, ExceptionDisplayChain& _out_rChain ) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir ExceptionDisplayChain empty; 297*cdf0e10cSrcweir _out_rChain.swap( empty ); 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir SQLExceptionIteratorHelper iter( _rErrorInfo ); 301*cdf0e10cSrcweir while ( iter.hasMoreElements() ) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir // current chain element 304*cdf0e10cSrcweir SQLExceptionInfo aCurrentElement; 305*cdf0e10cSrcweir iter.next( aCurrentElement ); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir const SQLException* pCurrentError = (const SQLException*)aCurrentElement; 308*cdf0e10cSrcweir DBG_ASSERT( pCurrentError, "lcl_buildExceptionChain: iterator failure!" ); 309*cdf0e10cSrcweir // hasMoreElements should not have returned <TRUE/> in this case 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir ExceptionDisplayInfo aDisplayInfo( aCurrentElement.getType() ); 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir aDisplayInfo.sMessage = pCurrentError->Message.trim(); 314*cdf0e10cSrcweir aDisplayInfo.sSQLState = pCurrentError->SQLState; 315*cdf0e10cSrcweir if ( pCurrentError->ErrorCode ) 316*cdf0e10cSrcweir aDisplayInfo.sErrorCode = String::CreateFromInt32( pCurrentError->ErrorCode ); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir if ( !aDisplayInfo.sMessage.Len() 319*cdf0e10cSrcweir && !lcl_hasDetails( aDisplayInfo ) 320*cdf0e10cSrcweir ) 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir OSL_ENSURE( false, "lcl_buildExceptionChain: useles exception: no state, no error code, no message!" ); 323*cdf0e10cSrcweir continue; 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir aDisplayInfo.pImageProvider = _rFactory.getImageProvider( aCurrentElement.getType() ); 327*cdf0e10cSrcweir aDisplayInfo.pLabelProvider = _rFactory.getLabelProvider( aCurrentElement.getType(), false ); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir _out_rChain.push_back( aDisplayInfo ); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir if ( aCurrentElement.getType() == SQLExceptionInfo::SQL_CONTEXT ) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir const SQLContext* pContext = (const SQLContext*)aCurrentElement; 334*cdf0e10cSrcweir if ( pContext->Details.getLength() ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir ExceptionDisplayInfo aSubInfo( aCurrentElement.getType() ); 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir aSubInfo.sMessage = pContext->Details; 339*cdf0e10cSrcweir aSubInfo.pImageProvider = _rFactory.getImageProvider( aCurrentElement.getType() ); 340*cdf0e10cSrcweir aSubInfo.pLabelProvider = _rFactory.getLabelProvider( aCurrentElement.getType(), true ); 341*cdf0e10cSrcweir aSubInfo.bSubEntry = true; 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir _out_rChain.push_back( aSubInfo ); 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir //------------------------------------------------------------------------------ 350*cdf0e10cSrcweir void lcl_insertExceptionEntry( SvTreeListBox& _rList, bool _bHiContrast, size_t _nElementPos, const ExceptionDisplayInfo& _rEntry ) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir Image aEntryImage( _rEntry.pImageProvider->getImage( _bHiContrast ) ); 353*cdf0e10cSrcweir SvLBoxEntry* pListEntry = 354*cdf0e10cSrcweir _rList.InsertEntry( _rEntry.pLabelProvider->getLabel(), aEntryImage, aEntryImage ); 355*cdf0e10cSrcweir pListEntry->SetUserData( reinterpret_cast< void* >( _nElementPos ) ); 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir //============================================================================== 360*cdf0e10cSrcweir class OExceptionChainDialog : public ModalDialog 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir FixedLine m_aFrame; 363*cdf0e10cSrcweir FixedText m_aListLabel; 364*cdf0e10cSrcweir SvTreeListBox m_aExceptionList; 365*cdf0e10cSrcweir FixedText m_aDescLabel; 366*cdf0e10cSrcweir MultiLineEdit m_aExceptionText; 367*cdf0e10cSrcweir OKButton m_aOK; 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir String m_sStatusLabel; 370*cdf0e10cSrcweir String m_sErrorCodeLabel; 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir ExceptionDisplayChain m_aExceptions; 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir public: 375*cdf0e10cSrcweir OExceptionChainDialog( Window* pParent, const ExceptionDisplayChain& _rExceptions ); 376*cdf0e10cSrcweir ~OExceptionChainDialog(); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir protected: 379*cdf0e10cSrcweir DECL_LINK(OnExceptionSelected, void*); 380*cdf0e10cSrcweir }; 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir DBG_NAME(OExceptionChainDialog) 383*cdf0e10cSrcweir //------------------------------------------------------------------------------ 384*cdf0e10cSrcweir OExceptionChainDialog::OExceptionChainDialog( Window* pParent, const ExceptionDisplayChain& _rExceptions ) 385*cdf0e10cSrcweir :ModalDialog(pParent, ModuleRes(DLG_SQLEXCEPTIONCHAIN)) 386*cdf0e10cSrcweir ,m_aFrame (this, ModuleRes(FL_DETAILS)) 387*cdf0e10cSrcweir ,m_aListLabel (this, ModuleRes(FT_ERRORLIST)) 388*cdf0e10cSrcweir ,m_aExceptionList (this, ModuleRes(CTL_ERRORLIST)) 389*cdf0e10cSrcweir ,m_aDescLabel (this, ModuleRes(FT_DESCRIPTION)) 390*cdf0e10cSrcweir ,m_aExceptionText (this, ModuleRes(ME_DESCRIPTION)) 391*cdf0e10cSrcweir ,m_aOK (this, ModuleRes(PB_OK)) 392*cdf0e10cSrcweir ,m_aExceptions( _rExceptions ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir DBG_CTOR(OExceptionChainDialog,NULL); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir m_sStatusLabel = String( ModuleRes( STR_EXCEPTION_STATUS ) ); 397*cdf0e10cSrcweir m_sErrorCodeLabel = String( ModuleRes( STR_EXCEPTION_ERRORCODE ) ); 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir FreeResource(); 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir m_aExceptionList.SetSelectionMode(SINGLE_SELECTION); 402*cdf0e10cSrcweir m_aExceptionList.SetDragDropMode(0); 403*cdf0e10cSrcweir m_aExceptionList.EnableInplaceEditing(sal_False); 404*cdf0e10cSrcweir m_aExceptionList.SetStyle(m_aExceptionList.GetStyle() | WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL); 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir m_aExceptionList.SetSelectHdl(LINK(this, OExceptionChainDialog, OnExceptionSelected)); 407*cdf0e10cSrcweir m_aExceptionList.SetNodeDefaultImages( ); 408*cdf0e10cSrcweir m_aExceptionText.SetReadOnly(sal_True); 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir bool bHave22018 = false; 411*cdf0e10cSrcweir bool bHiContrast = isHiContrast( this ); 412*cdf0e10cSrcweir size_t elementPos = 0; 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir for ( ExceptionDisplayChain::const_iterator loop = m_aExceptions.begin(); 415*cdf0e10cSrcweir loop != m_aExceptions.end(); 416*cdf0e10cSrcweir ++loop, ++elementPos 417*cdf0e10cSrcweir ) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir lcl_insertExceptionEntry( m_aExceptionList, bHiContrast, elementPos, *loop ); 420*cdf0e10cSrcweir bHave22018 = loop->sSQLState.EqualsAscii( "22018" ); 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir // if the error has the code 22018, then add an additional explanation 424*cdf0e10cSrcweir // #i24021# / 2004-10-14 / frank.schoenheit@sun.com 425*cdf0e10cSrcweir if ( bHave22018 ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir ProviderFactory aProviderFactory; 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir ExceptionDisplayInfo aInfo22018; 430*cdf0e10cSrcweir aInfo22018.sMessage = String( ModuleRes( STR_EXPLAN_STRINGCONVERSION_ERROR ) ); 431*cdf0e10cSrcweir aInfo22018.pLabelProvider = aProviderFactory.getLabelProvider( SQLExceptionInfo::SQL_CONTEXT, false ); 432*cdf0e10cSrcweir aInfo22018.pImageProvider = aProviderFactory.getImageProvider( SQLExceptionInfo::SQL_CONTEXT ); 433*cdf0e10cSrcweir m_aExceptions.push_back( aInfo22018 ); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir lcl_insertExceptionEntry( m_aExceptionList, bHiContrast, m_aExceptions.size() - 1, aInfo22018 ); 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir //------------------------------------------------------------------------------ 440*cdf0e10cSrcweir OExceptionChainDialog::~OExceptionChainDialog() 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir DBG_DTOR(OExceptionChainDialog,NULL); 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir //------------------------------------------------------------------------------ 446*cdf0e10cSrcweir IMPL_LINK(OExceptionChainDialog, OnExceptionSelected, void*, EMPTYARG) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir SvLBoxEntry* pSelected = m_aExceptionList.FirstSelected(); 449*cdf0e10cSrcweir DBG_ASSERT(!pSelected || !m_aExceptionList.NextSelected(pSelected), "OExceptionChainDialog::OnExceptionSelected : multi selection ?"); 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir String sText; 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir if ( pSelected ) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir size_t pos = reinterpret_cast< size_t >( pSelected->GetUserData() ); 456*cdf0e10cSrcweir const ExceptionDisplayInfo& aExceptionInfo( m_aExceptions[ pos ] ); 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir if ( aExceptionInfo.sSQLState.Len() ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir sText += m_sStatusLabel; 461*cdf0e10cSrcweir sText.AppendAscii(": "); 462*cdf0e10cSrcweir sText += aExceptionInfo.sSQLState; 463*cdf0e10cSrcweir sText.AppendAscii("\n"); 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir if ( aExceptionInfo.sErrorCode.Len() ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir sText += m_sErrorCodeLabel; 469*cdf0e10cSrcweir sText.AppendAscii(": "); 470*cdf0e10cSrcweir sText += aExceptionInfo.sErrorCode; 471*cdf0e10cSrcweir sText.AppendAscii("\n"); 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir if ( sText.Len() ) 475*cdf0e10cSrcweir sText.AppendAscii( "\n" ); 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir sText += aExceptionInfo.sMessage; 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir m_aExceptionText.SetText(sText); 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir return 0L; 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir //============================================================================== 486*cdf0e10cSrcweir //= SQLMessageBox_Impl 487*cdf0e10cSrcweir //============================================================================== 488*cdf0e10cSrcweir struct SQLMessageBox_Impl 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir ExceptionDisplayChain aDisplayInfo; 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir SQLMessageBox_Impl( const SQLExceptionInfo& _rExceptionInfo ) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir // transform the exception chain to a form more suitable for displaying it here 495*cdf0e10cSrcweir ProviderFactory aProviderFactory; 496*cdf0e10cSrcweir lcl_buildExceptionChain( _rExceptionInfo, aProviderFactory, aDisplayInfo ); 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir }; 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir //------------------------------------------------------------------------------ 501*cdf0e10cSrcweir namespace 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir ::rtl::OUString lcl_getProductName() 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir ::rtl::OUString sProductName; 506*cdf0e10cSrcweir OSL_VERIFY( ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME ) >>= sProductName ); 507*cdf0e10cSrcweir return sProductName; 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir void lcl_positionInAppFont( const Window& _rParent, Window& _rChild, long _nX, long _nY, long _Width, long _Height ) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir Point aPos = _rParent.LogicToPixel( Point( _nX, _nY ), MAP_APPFONT ); 513*cdf0e10cSrcweir Size aSize = _rParent.LogicToPixel( Size( _Width, _Height ), MAP_APPFONT ); 514*cdf0e10cSrcweir _rChild.SetPosSizePixel( aPos, aSize ); 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir void lcl_addButton( ButtonDialog& _rDialog, StandardButtonType _eType, bool _bDefault ) 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir sal_uInt16 nButtonID = 0; 520*cdf0e10cSrcweir switch ( _eType ) 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir case BUTTON_YES: nButtonID = BUTTONID_YES; break; 523*cdf0e10cSrcweir case BUTTON_NO: nButtonID = BUTTONID_NO; break; 524*cdf0e10cSrcweir case BUTTON_OK: nButtonID = BUTTONID_OK; break; 525*cdf0e10cSrcweir case BUTTON_CANCEL: nButtonID = BUTTONID_CANCEL; break; 526*cdf0e10cSrcweir case BUTTON_RETRY: nButtonID = BUTTONID_RETRY; break; 527*cdf0e10cSrcweir case BUTTON_HELP: nButtonID = BUTTONID_HELP; break; 528*cdf0e10cSrcweir default: 529*cdf0e10cSrcweir OSL_ENSURE( false, "lcl_addButton: invalid button id!" ); 530*cdf0e10cSrcweir break; 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir _rDialog.AddButton( _eType, nButtonID, _bDefault ? BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON : 0 ); 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir //------------------------------------------------------------------------------ 537*cdf0e10cSrcweir void OSQLMessageBox::impl_positionControls() 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir OSL_PRECOND( !m_pImpl->aDisplayInfo.empty(), "OSQLMessageBox::impl_positionControls: nothing to display at all?" ); 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir if ( m_pImpl->aDisplayInfo.empty() ) 543*cdf0e10cSrcweir return; 544*cdf0e10cSrcweir const ExceptionDisplayInfo* pSecondInfo = NULL; 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir const ExceptionDisplayInfo& rFirstInfo = *m_pImpl->aDisplayInfo.begin(); 547*cdf0e10cSrcweir if ( m_pImpl->aDisplayInfo.size() > 1 ) 548*cdf0e10cSrcweir pSecondInfo = &m_pImpl->aDisplayInfo[1]; 549*cdf0e10cSrcweir String sPrimary, sSecondary; 550*cdf0e10cSrcweir sPrimary = rFirstInfo.sMessage; 551*cdf0e10cSrcweir // one or two texts to display? 552*cdf0e10cSrcweir if ( pSecondInfo ) 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir // we show two elements in the main dialog if and only if one of 555*cdf0e10cSrcweir // - the first element in the chain is an SQLContext, and the second 556*cdf0e10cSrcweir // element denotes its sub entry 557*cdf0e10cSrcweir // - the first and the second element are both independent (i.e. the second 558*cdf0e10cSrcweir // is no sub entry), and none of them is a context. 559*cdf0e10cSrcweir bool bFirstElementIsContext = ( rFirstInfo.eType == SQLExceptionInfo::SQL_CONTEXT ); 560*cdf0e10cSrcweir bool bSecondElementIsContext = ( pSecondInfo->eType == SQLExceptionInfo::SQL_CONTEXT ); 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir if ( bFirstElementIsContext && pSecondInfo->bSubEntry ) 563*cdf0e10cSrcweir sSecondary = pSecondInfo->sMessage; 564*cdf0e10cSrcweir if ( !bFirstElementIsContext && !bSecondElementIsContext ) 565*cdf0e10cSrcweir sSecondary = pSecondInfo->sMessage; 566*cdf0e10cSrcweir } 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir // image 569*cdf0e10cSrcweir lcl_positionInAppFont( *this, m_aInfoImage, OUTER_MARGIN, OUTER_MARGIN, IMAGE_SIZE, IMAGE_SIZE ); 570*cdf0e10cSrcweir m_aInfoImage.Show(); 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir // primary text 573*cdf0e10cSrcweir lcl_positionInAppFont( *this, m_aTitle, TEXT_POS_X, OUTER_MARGIN, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 16 ); 574*cdf0e10cSrcweir sPrimary = lcl_stripOOoBaseVendor( sPrimary ); 575*cdf0e10cSrcweir m_aTitle.SetText( sPrimary ); 576*cdf0e10cSrcweir m_aTitle.Show(); 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir Rectangle aPrimaryRect( m_aTitle.GetPosPixel(), m_aTitle.GetSizePixel() ); 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir // secondary text (if applicable) 581*cdf0e10cSrcweir m_aMessage.SetStyle( m_aMessage.GetStyle() | WB_NOLABEL ); 582*cdf0e10cSrcweir sSecondary = lcl_stripOOoBaseVendor( sSecondary ); 583*cdf0e10cSrcweir m_aMessage.SetText( sSecondary ); 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir lcl_positionInAppFont( *this, m_aMessage, TEXT_POS_X, OUTER_MARGIN + 16 + 3, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 8 ); 586*cdf0e10cSrcweir Rectangle aSecondaryRect( m_aMessage.GetPosPixel(), m_aMessage.GetSizePixel() ); 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir bool bHaveSecondaryText = sSecondary.Len() != 0; 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir // determine which space the secondary text would occupy 591*cdf0e10cSrcweir if ( bHaveSecondaryText ) 592*cdf0e10cSrcweir aSecondaryRect = GetTextRect( aSecondaryRect, sSecondary, TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE | TEXT_DRAW_LEFT ); 593*cdf0e10cSrcweir else 594*cdf0e10cSrcweir aSecondaryRect.Bottom() = aSecondaryRect.Top() - 1; 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir // adjust secondary control height accordingly 597*cdf0e10cSrcweir m_aMessage.SetSizePixel( aSecondaryRect.GetSize() ); 598*cdf0e10cSrcweir m_aMessage.Show( aSecondaryRect.GetHeight() > 0 ); 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir // if there's no secondary text ... 601*cdf0e10cSrcweir if ( !bHaveSecondaryText ) 602*cdf0e10cSrcweir { // then give the primary text as much horizontal space as it needs 603*cdf0e10cSrcweir Rectangle aSuggestedRect( GetTextRect( aPrimaryRect, sPrimary, TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE | TEXT_DRAW_CENTER ) ); 604*cdf0e10cSrcweir aPrimaryRect.Right() = aPrimaryRect.Left() + aSuggestedRect.GetWidth(); 605*cdf0e10cSrcweir aPrimaryRect.Bottom() = aPrimaryRect.Top() + aSuggestedRect.GetHeight(); 606*cdf0e10cSrcweir // and center it horizontally 607*cdf0e10cSrcweir m_aTitle.SetStyle( ( m_aTitle.GetStyle() & ~WB_LEFT ) | WB_CENTER ); 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir Rectangle aInfoRect( m_aInfoImage.GetPosPixel(), m_aInfoImage.GetSizePixel() ); 610*cdf0e10cSrcweir // also, if it's not as high as the image ... 611*cdf0e10cSrcweir if ( aPrimaryRect.GetHeight() < m_aInfoImage.GetSizePixel().Height() ) 612*cdf0e10cSrcweir { // ... make it fit the image height 613*cdf0e10cSrcweir aPrimaryRect.Bottom() += aInfoRect.GetHeight() - aPrimaryRect.GetHeight(); 614*cdf0e10cSrcweir // and center it vertically 615*cdf0e10cSrcweir m_aTitle.SetStyle( m_aTitle.GetStyle() | WB_VCENTER ); 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir else 618*cdf0e10cSrcweir { // ... otherwise, center the image vertically, relative to the primary text 619*cdf0e10cSrcweir aInfoRect.Move( 0, ( aPrimaryRect.GetHeight() - aInfoRect.GetHeight() ) / 2 ); 620*cdf0e10cSrcweir m_aInfoImage.SetPosSizePixel( aInfoRect.TopLeft(), aInfoRect.GetSize() ); 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir m_aTitle.SetPosSizePixel( aPrimaryRect.TopLeft(), aPrimaryRect.GetSize() ); 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir // adjust dialog size accordingly 627*cdf0e10cSrcweir const Rectangle& rBottomTextRect( bHaveSecondaryText ? aSecondaryRect : aPrimaryRect ); 628*cdf0e10cSrcweir Size aBorderSize = LogicToPixel( Size( OUTER_MARGIN, OUTER_MARGIN ), MAP_APPFONT ); 629*cdf0e10cSrcweir Size aDialogSize( LogicToPixel( Size( DIALOG_WIDTH, 30 ), MAP_APPFONT ) ); 630*cdf0e10cSrcweir aDialogSize.Height() = rBottomTextRect.Bottom() + aBorderSize.Height(); 631*cdf0e10cSrcweir aDialogSize.Width() = aPrimaryRect.Right() + aBorderSize.Width(); 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir SetSizePixel( aDialogSize ); 634*cdf0e10cSrcweir SetPageSizePixel( aDialogSize ); 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir //------------------------------------------------------------------------------ 638*cdf0e10cSrcweir void OSQLMessageBox::impl_initImage( MessageType _eImage ) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir switch (_eImage) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir default: 643*cdf0e10cSrcweir DBG_ERROR( "OSQLMessageBox::impl_initImage: unsupported image type!" ); 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir case Info: 646*cdf0e10cSrcweir m_aInfoImage.SetImage(InfoBox::GetStandardImage()); 647*cdf0e10cSrcweir break; 648*cdf0e10cSrcweir case Warning: 649*cdf0e10cSrcweir m_aInfoImage.SetImage(WarningBox::GetStandardImage()); 650*cdf0e10cSrcweir break; 651*cdf0e10cSrcweir case Error: 652*cdf0e10cSrcweir m_aInfoImage.SetImage(ErrorBox::GetStandardImage()); 653*cdf0e10cSrcweir break; 654*cdf0e10cSrcweir case Query: 655*cdf0e10cSrcweir m_aInfoImage.SetImage(QueryBox::GetStandardImage()); 656*cdf0e10cSrcweir break; 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir } 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir //------------------------------------------------------------------------------ 661*cdf0e10cSrcweir void OSQLMessageBox::impl_createStandardButtons( WinBits _nStyle ) 662*cdf0e10cSrcweir { 663*cdf0e10cSrcweir if ( _nStyle & WB_YES_NO_CANCEL ) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir lcl_addButton( *this, BUTTON_YES, ( _nStyle & WB_DEF_YES ) != 0 ); 666*cdf0e10cSrcweir lcl_addButton( *this, BUTTON_NO, ( _nStyle & WB_DEF_NO ) != 0 ); 667*cdf0e10cSrcweir lcl_addButton( *this, BUTTON_CANCEL, ( _nStyle & WB_DEF_CANCEL ) != 0 ); 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir else if ( _nStyle & WB_OK_CANCEL ) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir lcl_addButton( *this, BUTTON_OK, ( _nStyle & WB_DEF_OK ) != 0 ); 672*cdf0e10cSrcweir lcl_addButton( *this, BUTTON_CANCEL, ( _nStyle & WB_DEF_CANCEL ) != 0 ); 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir else if ( _nStyle & WB_YES_NO ) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir lcl_addButton( *this, BUTTON_YES, ( _nStyle & WB_DEF_YES ) != 0 ); 677*cdf0e10cSrcweir lcl_addButton( *this, BUTTON_NO, ( _nStyle & WB_DEF_NO ) != 0 ); 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir else if ( _nStyle & WB_RETRY_CANCEL ) 680*cdf0e10cSrcweir { 681*cdf0e10cSrcweir lcl_addButton( *this, BUTTON_RETRY, ( _nStyle & WB_DEF_RETRY ) != 0 ); 682*cdf0e10cSrcweir lcl_addButton( *this, BUTTON_CANCEL, ( _nStyle & WB_DEF_CANCEL ) != 0 ); 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir else 685*cdf0e10cSrcweir { 686*cdf0e10cSrcweir OSL_ENSURE( WB_OK & _nStyle, "OSQLMessageBox::impl_createStandardButtons: unsupported dialog style requested!" ); 687*cdf0e10cSrcweir AddButton( BUTTON_OK, BUTTONID_OK, BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON ); 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir if ( m_sHelpURL.getLength() ) 691*cdf0e10cSrcweir { 692*cdf0e10cSrcweir lcl_addButton( *this, BUTTON_HELP, false ); 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir rtl::OUString aTmp; 695*cdf0e10cSrcweir INetURLObject aHID( m_sHelpURL ); 696*cdf0e10cSrcweir if ( aHID.GetProtocol() == INET_PROT_HID ) 697*cdf0e10cSrcweir aTmp = aHID.GetURLPath(); 698*cdf0e10cSrcweir else 699*cdf0e10cSrcweir aTmp = m_sHelpURL; 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir SetHelpId( rtl::OUStringToOString( aTmp, RTL_TEXTENCODING_UTF8 ) ); 702*cdf0e10cSrcweir } 703*cdf0e10cSrcweir } 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir //------------------------------------------------------------------------------ 706*cdf0e10cSrcweir void OSQLMessageBox::impl_addDetailsButton() 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir size_t nFirstPageVisible = m_aMessage.IsVisible() ? 2 : 1; 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir bool bMoreDetailsAvailable = m_pImpl->aDisplayInfo.size() > nFirstPageVisible; 711*cdf0e10cSrcweir if ( !bMoreDetailsAvailable ) 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir // even if the text fits into what we can display, we might need to details button 714*cdf0e10cSrcweir // if there is more non-trivial information in the errors than the mere messages 715*cdf0e10cSrcweir for ( ExceptionDisplayChain::const_iterator error = m_pImpl->aDisplayInfo.begin(); 716*cdf0e10cSrcweir error != m_pImpl->aDisplayInfo.end(); 717*cdf0e10cSrcweir ++error 718*cdf0e10cSrcweir ) 719*cdf0e10cSrcweir { 720*cdf0e10cSrcweir if ( lcl_hasDetails( *error ) ) 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir bMoreDetailsAvailable = true; 723*cdf0e10cSrcweir break; 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir if ( bMoreDetailsAvailable ) 729*cdf0e10cSrcweir { 730*cdf0e10cSrcweir AddButton( BUTTON_MORE, BUTTONID_MORE, 0 ); 731*cdf0e10cSrcweir PushButton* pButton = GetPushButton( BUTTONID_MORE ); 732*cdf0e10cSrcweir OSL_ENSURE( pButton, "OSQLMessageBox::impl_addDetailsButton: just added this button, why isn't it there?" ); 733*cdf0e10cSrcweir pButton->SetClickHdl( LINK( this, OSQLMessageBox, ButtonClickHdl ) ); 734*cdf0e10cSrcweir pButton->SetUniqueId( UID_SQLERROR_BUTTONMORE ); 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir //------------------------------------------------------------------------------ 739*cdf0e10cSrcweir void OSQLMessageBox::Construct( WinBits _nStyle, MessageType _eImage ) 740*cdf0e10cSrcweir { 741*cdf0e10cSrcweir // Changed as per BugID 79541 Branding/Configuration 742*cdf0e10cSrcweir String sDialogTitle( lcl_getProductName() ); 743*cdf0e10cSrcweir SetText( sDialogTitle.AppendAscii( " Base" ) ); 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir // position and size the controls and the dialog, depending on whether we have one or two texts to display 746*cdf0e10cSrcweir impl_positionControls(); 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir // init the image 749*cdf0e10cSrcweir MessageType eType( _eImage ); 750*cdf0e10cSrcweir if ( eType == AUTO ) 751*cdf0e10cSrcweir { 752*cdf0e10cSrcweir switch ( m_pImpl->aDisplayInfo[0].eType ) 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir case SQLExceptionInfo::SQL_EXCEPTION: eType = Error; break; 755*cdf0e10cSrcweir case SQLExceptionInfo::SQL_WARNING: eType = Warning; break; 756*cdf0e10cSrcweir case SQLExceptionInfo::SQL_CONTEXT: eType = Info; break; 757*cdf0e10cSrcweir default: OSL_ENSURE( false, "OSQLMessageBox::Construct: invalid type!" ); 758*cdf0e10cSrcweir } 759*cdf0e10cSrcweir } 760*cdf0e10cSrcweir impl_initImage( eType ); 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir // create buttons 763*cdf0e10cSrcweir impl_createStandardButtons( _nStyle ); 764*cdf0e10cSrcweir impl_addDetailsButton(); 765*cdf0e10cSrcweir } 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir //------------------------------------------------------------------------------ 768*cdf0e10cSrcweir OSQLMessageBox::OSQLMessageBox(Window* _pParent, const SQLExceptionInfo& _rException, WinBits _nStyle, const ::rtl::OUString& _rHelpURL ) 769*cdf0e10cSrcweir :ButtonDialog( _pParent, WB_HORZ | WB_STDDIALOG ) 770*cdf0e10cSrcweir ,m_aInfoImage( this ) 771*cdf0e10cSrcweir ,m_aTitle( this, WB_WORDBREAK | WB_LEFT ) 772*cdf0e10cSrcweir ,m_aMessage( this, WB_WORDBREAK | WB_LEFT ) 773*cdf0e10cSrcweir ,m_sHelpURL( _rHelpURL ) 774*cdf0e10cSrcweir ,m_pImpl( new SQLMessageBox_Impl( _rException ) ) 775*cdf0e10cSrcweir { 776*cdf0e10cSrcweir Construct( _nStyle, AUTO ); 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir //------------------------------------------------------------------------------ 780*cdf0e10cSrcweir OSQLMessageBox::OSQLMessageBox( Window* _pParent, const UniString& _rTitle, const UniString& _rMessage, WinBits _nStyle, MessageType _eType, const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo ) 781*cdf0e10cSrcweir :ButtonDialog( _pParent, WB_HORZ | WB_STDDIALOG ) 782*cdf0e10cSrcweir ,m_aInfoImage( this ) 783*cdf0e10cSrcweir ,m_aTitle( this, WB_WORDBREAK | WB_LEFT ) 784*cdf0e10cSrcweir ,m_aMessage( this, WB_WORDBREAK | WB_LEFT ) 785*cdf0e10cSrcweir { 786*cdf0e10cSrcweir SQLContext aError; 787*cdf0e10cSrcweir aError.Message = _rTitle; 788*cdf0e10cSrcweir aError.Details = _rMessage; 789*cdf0e10cSrcweir if ( _pAdditionalErrorInfo ) 790*cdf0e10cSrcweir aError.NextException = _pAdditionalErrorInfo->get(); 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir m_pImpl.reset( new SQLMessageBox_Impl( SQLExceptionInfo( aError ) ) ); 793*cdf0e10cSrcweir 794*cdf0e10cSrcweir Construct( _nStyle, _eType ); 795*cdf0e10cSrcweir } 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir //-------------------------------------------------------------------------- 798*cdf0e10cSrcweir OSQLMessageBox::~OSQLMessageBox() 799*cdf0e10cSrcweir { 800*cdf0e10cSrcweir } 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir //-------------------------------------------------------------------------- 803*cdf0e10cSrcweir IMPL_LINK( OSQLMessageBox, ButtonClickHdl, Button *, /*pButton*/ ) 804*cdf0e10cSrcweir { 805*cdf0e10cSrcweir OExceptionChainDialog aDlg( this, m_pImpl->aDisplayInfo ); 806*cdf0e10cSrcweir aDlg.Execute(); 807*cdf0e10cSrcweir return 0; 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir //================================================================== 811*cdf0e10cSrcweir // OSQLWarningBox 812*cdf0e10cSrcweir //================================================================== 813*cdf0e10cSrcweir OSQLWarningBox::OSQLWarningBox( Window* _pParent, const UniString& _rMessage, WinBits _nStyle, 814*cdf0e10cSrcweir const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo ) 815*cdf0e10cSrcweir :OSQLMessageBox( _pParent, String( ModuleRes( STR_STAT_WARNING ) ), _rMessage, _nStyle, OSQLMessageBox::Warning, _pAdditionalErrorInfo ) 816*cdf0e10cSrcweir { 817*cdf0e10cSrcweir } 818*cdf0e10cSrcweir 819*cdf0e10cSrcweir //......................................................................... 820*cdf0e10cSrcweir } // namespace dbaui 821*cdf0e10cSrcweir //......................................................................... 822*cdf0e10cSrcweir 823