/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
/// strips the [OOoBase] vendor identifier from the given error message, if applicable
OUString lcl_stripOOoBaseVendor( const OUString& _rErrorMessage )
{
OUString sErrorMessage( _rErrorMessage );
const OUString sVendorIdentifier( ::connectivity::SQLError::getMessagePrefix() ); if ( sErrorMessage.startsWith( sVendorIdentifier ) )
{ // characters to strip
sal_Int32 nStripLen( sVendorIdentifier.getLength() ); // usually, there should be a whitespace between the vendor and the real message while ( ( sErrorMessage.getLength() > nStripLen )
&& ( sErrorMessage[nStripLen] == ' ' )
)
++nStripLen;
sErrorMessage = sErrorMessage.copy( nStripLen );
}
SQLExceptionIteratorHelper iter( _rErrorInfo ); while ( iter.hasMoreElements() )
{ // current chain element
SQLExceptionInfo aCurrentElement;
iter.next( aCurrentElement );
const SQLException* pCurrentError = aCurrentElement;
assert(pCurrentError && "lcl_buildExceptionChain: iterator failure!"); // hasMoreElements should not have returned <TRUE/> in this case
class OExceptionChainDialog : public weld::GenericDialogController
{
std::unique_ptr<weld::TreeView> m_xExceptionList;
std::unique_ptr<weld::TextView> m_xExceptionText;
explicit SQLMessageBox_Impl( const SQLExceptionInfo& _rExceptionInfo )
{ // transform the exception chain to a form more suitable for displaying it here
ProviderFactory aProviderFactory;
lcl_buildExceptionChain( _rExceptionInfo, aProviderFactory, aDisplayInfo );
}
};
void OSQLMessageBox::impl_fillMessages()
{
OSL_PRECOND( !m_pImpl->aDisplayInfo.empty(), "OSQLMessageBox::impl_fillMessages: nothing to display at all?" );
if ( m_pImpl->aDisplayInfo.empty() ) return; const ExceptionDisplayInfo* pSecondInfo = nullptr;
const ExceptionDisplayInfo& rFirstInfo = *m_pImpl->aDisplayInfo.begin(); if ( m_pImpl->aDisplayInfo.size() > 1 )
pSecondInfo = &m_pImpl->aDisplayInfo[1];
OUString sPrimary, sSecondary;
sPrimary = rFirstInfo.sMessage; // one or two texts to display? if ( pSecondInfo )
{ // we show two elements in the main dialog if and only if one of // - the first element in the chain is an SQLContext, and the second // element denotes its sub entry // - the first and the second element are both independent (i.e. the second // is no sub entry), and none of them is a context. bool bFirstElementIsContext = ( rFirstInfo.eType == SQLExceptionInfo::TYPE::SQLContext ); bool bSecondElementIsContext = ( pSecondInfo->eType == SQLExceptionInfo::TYPE::SQLContext );
if ( bFirstElementIsContext && pSecondInfo->bSubEntry )
sSecondary = pSecondInfo->sMessage; if ( !bFirstElementIsContext && !bSecondElementIsContext )
sSecondary = pSecondInfo->sMessage;
}
// primary text
m_xDialog->set_primary_text(lcl_stripOOoBaseVendor(sPrimary));
// secondary text (if applicable)
m_xDialog->set_secondary_text(lcl_stripOOoBaseVendor(sSecondary));
}
bool bMoreDetailsAvailable = m_pImpl->aDisplayInfo.size() > nFirstPageVisible; if ( !bMoreDetailsAvailable )
{ // even if the text fits into what we can display, we might need to details button // if there is more non-trivial information in the errors than the mere messages for (autoconst& error : m_pImpl->aDisplayInfo)
{ if ( lcl_hasDetails(error) )
{
bMoreDetailsAvailable = true; break;
}
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.22Bemerkung:
(vorverarbeitet am 2026-05-05)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.