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