loplugin:flatten in unotools

Change-Id: I2fad16061bca6dc3e57926863e7a3b71947a8ade
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100139
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2020-08-04 21:29:47 +02:00
parent 48a3d6b85e
commit f3ff488fd4
10 changed files with 366 additions and 366 deletions

View File

@ -537,19 +537,19 @@ bool ConfigItem::EnableNotification(const Sequence< OUString >& rNames,
void ConfigItem::RemoveChangesListener()
{
Reference<XHierarchicalNameAccess> xHierarchyAccess = GetTree();
if(xHierarchyAccess.is())
if(!xHierarchyAccess.is())
return;
Reference<XChangesNotifier> xChgNot(xHierarchyAccess, UNO_QUERY);
if(xChgNot.is() && xChangeLstnr.is())
{
Reference<XChangesNotifier> xChgNot(xHierarchyAccess, UNO_QUERY);
if(xChgNot.is() && xChangeLstnr.is())
try
{
xChgNot->removeChangesListener( xChangeLstnr );
xChangeLstnr = nullptr;
}
catch (const Exception&)
{
try
{
xChgNot->removeChangesListener( xChangeLstnr );
xChangeLstnr = nullptr;
}
catch (const Exception&)
{
}
}
}
}

View File

@ -233,88 +233,88 @@ SvtDefaultOptions_Impl::SvtDefaultOptions_Impl() : ConfigItem( "Office.Common/Pa
EnableNotification( aNames );
const Any* pValues = aValues.getConstArray();
DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
if ( aValues.getLength() == aNames.getLength() )
if ( aValues.getLength() != aNames.getLength() )
return;
SvtPathOptions aPathOpt;
OUString aTempStr;
OUStringBuffer aFullPathBuf;
for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
{
SvtPathOptions aPathOpt;
OUString aTempStr;
OUStringBuffer aFullPathBuf;
for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
if ( pValues[nProp].hasValue() )
{
if ( pValues[nProp].hasValue() )
switch ( pValues[nProp].getValueTypeClass() )
{
switch ( pValues[nProp].getValueTypeClass() )
case css::uno::TypeClass_STRING :
{
case css::uno::TypeClass_STRING :
// multi paths
if ( pValues[nProp] >>= aTempStr )
aFullPathBuf = aPathOpt.SubstituteVariable( aTempStr );
else
{
// multi paths
if ( pValues[nProp] >>= aTempStr )
aFullPathBuf = aPathOpt.SubstituteVariable( aTempStr );
else
{
SAL_WARN( "unotools.config", "any operator >>= failed" );
}
break;
}
case css::uno::TypeClass_SEQUENCE :
{
// single paths
aFullPathBuf.setLength(0);
Sequence < OUString > aList;
if ( pValues[nProp] >>= aList )
{
sal_Int32 nCount = aList.getLength();
for ( sal_Int32 nPosition = 0; nPosition < nCount; ++nPosition )
{
aFullPathBuf.append(aPathOpt.SubstituteVariable( aList[ nPosition ] ));
if ( nPosition < nCount-1 )
aFullPathBuf.append(";");
}
}
else
{
SAL_WARN( "unotools.config", "any operator >>= failed" );
}
break;
}
default:
{
SAL_WARN( "unotools.config", "Wrong any type" );
SAL_WARN( "unotools.config", "any operator >>= failed" );
}
break;
}
auto aFullPath = aFullPathBuf.makeStringAndClear();
switch ( nProp )
case css::uno::TypeClass_SEQUENCE :
{
case DEFAULTPATH_ADDIN: m_aAddinPath = aFullPath; break;
case DEFAULTPATH_AUTOCORRECT: m_aAutoCorrectPath = aFullPath; break;
case DEFAULTPATH_AUTOTEXT: m_aAutoTextPath = aFullPath; break;
case DEFAULTPATH_BACKUP: m_aBackupPath = aFullPath; break;
case DEFAULTPATH_BASIC: m_aBasicPath = aFullPath; break;
case DEFAULTPATH_BITMAP: m_aBitmapPath = aFullPath; break;
case DEFAULTPATH_CONFIG: m_aConfigPath = aFullPath; break;
case DEFAULTPATH_DICTIONARY: m_aDictionaryPath = aFullPath; break;
case DEFAULTPATH_FAVORITES: m_aFavoritesPath = aFullPath; break;
case DEFAULTPATH_FILTER: m_aFilterPath = aFullPath; break;
case DEFAULTPATH_GALLERY: m_aGalleryPath = aFullPath; break;
case DEFAULTPATH_GRAPHIC: m_aGraphicPath = aFullPath; break;
case DEFAULTPATH_HELP: m_aHelpPath = aFullPath; break;
case DEFAULTPATH_LINGUISTIC: m_aLinguisticPath = aFullPath; break;
case DEFAULTPATH_MODULE: m_aModulePath = aFullPath; break;
case DEFAULTPATH_PALETTE: m_aPalettePath = aFullPath; break;
case DEFAULTPATH_PLUGIN: m_aPluginPath = aFullPath; break;
case DEFAULTPATH_TEMP: m_aTempPath = aFullPath; break;
case DEFAULTPATH_TEMPLATE: m_aTemplatePath = aFullPath; break;
case DEFAULTPATH_USERCONFIG: m_aUserConfigPath = aFullPath; break;
case DEFAULTPATH_WORK: m_aWorkPath = aFullPath; break;
case DEFAULTPATH_CLASSIFICATION: m_aClassificationPath = aFullPath;break;
case DEFAULTPATH_USERDICTIONARY: break;
default:
SAL_WARN( "unotools.config", "invalid index to load a default path" );
// single paths
aFullPathBuf.setLength(0);
Sequence < OUString > aList;
if ( pValues[nProp] >>= aList )
{
sal_Int32 nCount = aList.getLength();
for ( sal_Int32 nPosition = 0; nPosition < nCount; ++nPosition )
{
aFullPathBuf.append(aPathOpt.SubstituteVariable( aList[ nPosition ] ));
if ( nPosition < nCount-1 )
aFullPathBuf.append(";");
}
}
else
{
SAL_WARN( "unotools.config", "any operator >>= failed" );
}
break;
}
default:
{
SAL_WARN( "unotools.config", "Wrong any type" );
}
}
auto aFullPath = aFullPathBuf.makeStringAndClear();
switch ( nProp )
{
case DEFAULTPATH_ADDIN: m_aAddinPath = aFullPath; break;
case DEFAULTPATH_AUTOCORRECT: m_aAutoCorrectPath = aFullPath; break;
case DEFAULTPATH_AUTOTEXT: m_aAutoTextPath = aFullPath; break;
case DEFAULTPATH_BACKUP: m_aBackupPath = aFullPath; break;
case DEFAULTPATH_BASIC: m_aBasicPath = aFullPath; break;
case DEFAULTPATH_BITMAP: m_aBitmapPath = aFullPath; break;
case DEFAULTPATH_CONFIG: m_aConfigPath = aFullPath; break;
case DEFAULTPATH_DICTIONARY: m_aDictionaryPath = aFullPath; break;
case DEFAULTPATH_FAVORITES: m_aFavoritesPath = aFullPath; break;
case DEFAULTPATH_FILTER: m_aFilterPath = aFullPath; break;
case DEFAULTPATH_GALLERY: m_aGalleryPath = aFullPath; break;
case DEFAULTPATH_GRAPHIC: m_aGraphicPath = aFullPath; break;
case DEFAULTPATH_HELP: m_aHelpPath = aFullPath; break;
case DEFAULTPATH_LINGUISTIC: m_aLinguisticPath = aFullPath; break;
case DEFAULTPATH_MODULE: m_aModulePath = aFullPath; break;
case DEFAULTPATH_PALETTE: m_aPalettePath = aFullPath; break;
case DEFAULTPATH_PLUGIN: m_aPluginPath = aFullPath; break;
case DEFAULTPATH_TEMP: m_aTempPath = aFullPath; break;
case DEFAULTPATH_TEMPLATE: m_aTemplatePath = aFullPath; break;
case DEFAULTPATH_USERCONFIG: m_aUserConfigPath = aFullPath; break;
case DEFAULTPATH_WORK: m_aWorkPath = aFullPath; break;
case DEFAULTPATH_CLASSIFICATION: m_aClassificationPath = aFullPath;break;
case DEFAULTPATH_USERDICTIONARY: break;
default:
SAL_WARN( "unotools.config", "invalid index to load a default path" );
}
}
}

View File

@ -974,72 +974,72 @@ ImplFontAttrs FontSubstConfiguration::getSubstType( const css::uno::Reference< X
void FontSubstConfiguration::readLocaleSubst( const OUString& rBcp47 ) const
{
std::unordered_map< OUString, LocaleSubst >::const_iterator it = m_aSubst.find( rBcp47 );
if( it != m_aSubst.end() )
if( it == m_aSubst.end() )
return;
if( it->second.bConfigRead )
return;
it->second.bConfigRead = true;
Reference< XNameAccess > xNode;
try
{
if( ! it->second.bConfigRead )
{
it->second.bConfigRead = true;
Reference< XNameAccess > xNode;
try
{
Any aAny = m_xConfigAccess->getByName( it->second.aConfigLocaleString );
aAny >>= xNode;
}
catch (const NoSuchElementException&)
{
}
catch (const WrappedTargetException&)
{
}
if( xNode.is() )
{
const Sequence< OUString > aFonts = xNode->getElementNames();
int nFonts = aFonts.getLength();
// improve performance, heap fragmentation
it->second.aSubstAttributes.reserve( nFonts );
// strings for subst retrieval, construct only once
OUString const aSubstFontsStr ( "SubstFonts" );
OUString const aSubstFontsMSStr ( "SubstFontsMS" );
OUString const aSubstWeightStr ( "FontWeight" );
OUString const aSubstWidthStr ( "FontWidth" );
OUString const aSubstTypeStr ( "FontType" );
for( const OUString& rFontName : aFonts )
{
Reference< XNameAccess > xFont;
try
{
Any aAny = xNode->getByName( rFontName );
aAny >>= xFont;
}
catch (const NoSuchElementException&)
{
}
catch (const WrappedTargetException&)
{
}
if( ! xFont.is() )
{
SAL_WARN("unotools.config", "did not get font attributes for " << rFontName);
continue;
}
FontNameAttr aAttr;
// read subst attributes from config
aAttr.Name = rFontName;
fillSubstVector( xFont, aSubstFontsStr, aAttr.Substitutions );
fillSubstVector( xFont, aSubstFontsMSStr, aAttr.MSSubstitutions );
aAttr.Weight = getSubstWeight( xFont, aSubstWeightStr );
aAttr.Width = getSubstWidth( xFont, aSubstWidthStr );
aAttr.Type = getSubstType( xFont, aSubstTypeStr );
// finally insert this entry
it->second.aSubstAttributes.push_back( aAttr );
}
std::sort( it->second.aSubstAttributes.begin(), it->second.aSubstAttributes.end(), StrictStringSort() );
}
}
Any aAny = m_xConfigAccess->getByName( it->second.aConfigLocaleString );
aAny >>= xNode;
}
catch (const NoSuchElementException&)
{
}
catch (const WrappedTargetException&)
{
}
if( !xNode.is() )
return;
const Sequence< OUString > aFonts = xNode->getElementNames();
int nFonts = aFonts.getLength();
// improve performance, heap fragmentation
it->second.aSubstAttributes.reserve( nFonts );
// strings for subst retrieval, construct only once
OUString const aSubstFontsStr ( "SubstFonts" );
OUString const aSubstFontsMSStr ( "SubstFontsMS" );
OUString const aSubstWeightStr ( "FontWeight" );
OUString const aSubstWidthStr ( "FontWidth" );
OUString const aSubstTypeStr ( "FontType" );
for( const OUString& rFontName : aFonts )
{
Reference< XNameAccess > xFont;
try
{
Any aAny = xNode->getByName( rFontName );
aAny >>= xFont;
}
catch (const NoSuchElementException&)
{
}
catch (const WrappedTargetException&)
{
}
if( ! xFont.is() )
{
SAL_WARN("unotools.config", "did not get font attributes for " << rFontName);
continue;
}
FontNameAttr aAttr;
// read subst attributes from config
aAttr.Name = rFontName;
fillSubstVector( xFont, aSubstFontsStr, aAttr.Substitutions );
fillSubstVector( xFont, aSubstFontsMSStr, aAttr.MSSubstitutions );
aAttr.Weight = getSubstWeight( xFont, aSubstWeightStr );
aAttr.Width = getSubstWidth( xFont, aSubstWidthStr );
aAttr.Type = getSubstType( xFont, aSubstTypeStr );
// finally insert this entry
it->second.aSubstAttributes.push_back( aAttr );
}
std::sort( it->second.aSubstAttributes.begin(), it->second.aSubstAttributes.end(), StrictStringSort() );
}
const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontName ) const

View File

@ -268,41 +268,41 @@ void SvtPathOptions_Impl::SetPath( SvtPathOptions::Paths ePath, const OUString&
{
::osl::MutexGuard aGuard( m_aMutex );
if ( ePath < SvtPathOptions::PATH_COUNT )
if ( ePath >= SvtPathOptions::PATH_COUNT )
return;
OUString aResult;
OUString aNewValue;
Any a;
switch ( ePath )
{
OUString aResult;
OUString aNewValue;
Any a;
switch ( ePath )
case SvtPathOptions::PATH_ADDIN:
case SvtPathOptions::PATH_FILTER:
case SvtPathOptions::PATH_HELP:
case SvtPathOptions::PATH_MODULE:
case SvtPathOptions::PATH_PLUGIN:
case SvtPathOptions::PATH_STORAGE:
{
case SvtPathOptions::PATH_ADDIN:
case SvtPathOptions::PATH_FILTER:
case SvtPathOptions::PATH_HELP:
case SvtPathOptions::PATH_MODULE:
case SvtPathOptions::PATH_PLUGIN:
case SvtPathOptions::PATH_STORAGE:
{
// These office paths have to be convert back to UCB-URL's
osl::FileBase::getFileURLFromSystemPath( rNewPath, aResult );
aNewValue = aResult;
}
break;
// These office paths have to be convert back to UCB-URL's
osl::FileBase::getFileURLFromSystemPath( rNewPath, aResult );
aNewValue = aResult;
}
break;
default:
aNewValue = rNewPath;
}
default:
aNewValue = rNewPath;
}
// Resubstitution is done by the service itself using the substitution service
a <<= aNewValue;
try
{
m_xPathSettings->setFastPropertyValue( m_aMapEnumToPropHandle[ static_cast<sal_Int32>(ePath)], a );
}
catch (const Exception&)
{
TOOLS_WARN_EXCEPTION("unotools.config", "SetPath");
}
// Resubstitution is done by the service itself using the substitution service
a <<= aNewValue;
try
{
m_xPathSettings->setFastPropertyValue( m_aMapEnumToPropHandle[ static_cast<sal_Int32>(ePath)], a );
}
catch (const Exception&)
{
TOOLS_WARN_EXCEPTION("unotools.config", "SetPath");
}
}

View File

@ -412,49 +412,49 @@ void SvtSecurityOptions_Impl::LoadAuthors()
m_seqTrustedAuthors.realloc( 0 ); // first clear
const Sequence< OUString > lAuthors = GetNodeNames( PROPERTYNAME_MACRO_TRUSTEDAUTHORS );
sal_Int32 c1 = lAuthors.getLength();
if( c1 )
if( !c1 )
return;
sal_Int32 c2 = c1 * 3; // 3 Properties inside Struct TrustedAuthor
Sequence< OUString > lAllAuthors( c2 );
sal_Int32 i2 = 0;
OUString aSep( "/" );
for( const auto& rAuthor : lAuthors )
{
sal_Int32 c2 = c1 * 3; // 3 Properties inside Struct TrustedAuthor
Sequence< OUString > lAllAuthors( c2 );
lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
++i2;
lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
++i2;
lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
++i2;
}
sal_Int32 i2 = 0;
OUString aSep( "/" );
for( const auto& rAuthor : lAuthors )
{
lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
++i2;
lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
++i2;
lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
++i2;
}
Sequence< Any > lValues = GetProperties( lAllAuthors );
if( lValues.getLength() != c2 )
return;
Sequence< Any > lValues = GetProperties( lAllAuthors );
if( lValues.getLength() == c2 )
std::vector< SvtSecurityOptions::Certificate > v;
SvtSecurityOptions::Certificate aCert( 3 );
i2 = 0;
for( sal_Int32 i1 = 0; i1 < c1; ++i1 )
{
lValues[ i2 ] >>= aCert[ 0 ];
++i2;
lValues[ i2 ] >>= aCert[ 1 ];
++i2;
lValues[ i2 ] >>= aCert[ 2 ];
++i2;
// Filter out TrustedAuthor entries with empty RawData, which
// would cause an unexpected std::bad_alloc in
// SecurityEnvironment_NssImpl::createCertificateFromAscii and
// have been observed in the wild (fdo#55019):
if( !aCert[ 2 ].isEmpty() )
{
std::vector< SvtSecurityOptions::Certificate > v;
SvtSecurityOptions::Certificate aCert( 3 );
i2 = 0;
for( sal_Int32 i1 = 0; i1 < c1; ++i1 )
{
lValues[ i2 ] >>= aCert[ 0 ];
++i2;
lValues[ i2 ] >>= aCert[ 1 ];
++i2;
lValues[ i2 ] >>= aCert[ 2 ];
++i2;
// Filter out TrustedAuthor entries with empty RawData, which
// would cause an unexpected std::bad_alloc in
// SecurityEnvironment_NssImpl::createCertificateFromAscii and
// have been observed in the wild (fdo#55019):
if( !aCert[ 2 ].isEmpty() )
{
v.push_back( aCert );
}
}
m_seqTrustedAuthors = comphelper::containerToSequence(v);
v.push_back( aCert );
}
}
m_seqTrustedAuthors = comphelper::containerToSequence(v);
}
sal_Int32 SvtSecurityOptions_Impl::GetHandle( const OUString& rName )

View File

@ -520,19 +520,19 @@ bool LocaleDataWrapper::doesSecondaryCalendarUseEC( const OUString& rName ) cons
void LocaleDataWrapper::getDefaultCalendarImpl()
{
if (!xDefaultCalendar)
if (xDefaultCalendar)
return;
Sequence< Calendar2 > xCals = getAllCalendars();
auto pCal = xCals.begin();
if (xCals.getLength() > 1)
{
Sequence< Calendar2 > xCals = getAllCalendars();
auto pCal = xCals.begin();
if (xCals.getLength() > 1)
{
pCal = std::find_if(xCals.begin(), xCals.end(),
[](const Calendar2& rCal) { return rCal.Default; });
if (pCal == xCals.end())
pCal = xCals.begin();
}
xDefaultCalendar = std::make_shared<Calendar2>( *pCal);
pCal = std::find_if(xCals.begin(), xCals.end(),
[](const Calendar2& rCal) { return rCal.Default; });
if (pCal == xCals.end())
pCal = xCals.begin();
}
xDefaultCalendar = std::make_shared<Calendar2>( *pCal);
}
const std::shared_ptr< css::i18n::Calendar2 >& LocaleDataWrapper::getDefaultCalendar() const
@ -1061,21 +1061,21 @@ void LocaleDataWrapper::getDigitGroupingImpl()
aGrouping.realloc(3); // room for {3,2,0}
aGrouping[0] = 0; // invalidate
}
if (!aGrouping[0])
if (aGrouping[0])
return;
i18n::LanguageCountryInfo aLCInfo( getLanguageCountryInfo());
if (aLCInfo.Country.equalsIgnoreAsciiCase("IN") || // India
aLCInfo.Country.equalsIgnoreAsciiCase("BT") ) // Bhutan
{
i18n::LanguageCountryInfo aLCInfo( getLanguageCountryInfo());
if (aLCInfo.Country.equalsIgnoreAsciiCase("IN") || // India
aLCInfo.Country.equalsIgnoreAsciiCase("BT") ) // Bhutan
{
aGrouping[0] = 3;
aGrouping[1] = 2;
aGrouping[2] = 0;
}
else
{
aGrouping[0] = 3;
aGrouping[1] = 0;
}
aGrouping[0] = 3;
aGrouping[1] = 2;
aGrouping[2] = 0;
}
else
{
aGrouping[0] = 3;
aGrouping[1] = 0;
}
}

View File

@ -81,27 +81,27 @@ void ReadWriteGuard::changeReadToWrite()
{
bool bOk = !(nMode & (ReadWriteGuardMode::Write | ReadWriteGuardMode::BlockCritical));
DBG_ASSERT( bOk, "ReadWriteGuard::changeReadToWrite: can't" );
if ( bOk )
{
// MUST release read before acquiring write mutex or dead lock would
// occur if there was a write in another thread waiting for this read
// to complete.
rMutex.maMutex.acquire();
--rMutex.nReadCount;
rMutex.maMutex.release();
if ( !bOk )
return;
rMutex.maWriteMutex.acquire();
nMode |= ReadWriteGuardMode::Write;
// wait for any other read to complete
// MUST release read before acquiring write mutex or dead lock would
// occur if there was a write in another thread waiting for this read
// to complete.
rMutex.maMutex.acquire();
--rMutex.nReadCount;
rMutex.maMutex.release();
rMutex.maWriteMutex.acquire();
nMode |= ReadWriteGuardMode::Write;
// wait for any other read to complete
// TODO: set up a waiting thread instead of a loop
bool bWait = true;
do
{
rMutex.maMutex.acquire();
bWait = (rMutex.nReadCount != 0);
rMutex.maMutex.release();
} while ( bWait );
}
bool bWait = true;
do
{
rMutex.maMutex.acquire();
bWait = (rMutex.nReadCount != 0);
rMutex.maMutex.release();
} while ( bWait );
}
} // namespace utl

View File

@ -305,95 +305,95 @@ bool TextSearch::SearchBackward( const OUString & rStr, sal_Int32* pStart,
void TextSearch::ReplaceBackReferences( OUString& rReplaceStr, const OUString &rStr, const SearchResult& rResult ) const
{
if( rResult.subRegExpressions > 0 )
if( rResult.subRegExpressions <= 0 )
return;
sal_Unicode sFndChar;
sal_Int32 i;
OUStringBuffer sBuff(rReplaceStr.getLength()*4);
for(i = 0; i < rReplaceStr.getLength(); i++)
{
sal_Unicode sFndChar;
sal_Int32 i;
OUStringBuffer sBuff(rReplaceStr.getLength()*4);
for(i = 0; i < rReplaceStr.getLength(); i++)
if( rReplaceStr[i] == '&')
{
if( rReplaceStr[i] == '&')
{
sal_Int32 nStart = rResult.startOffset[0];
sal_Int32 nLength = rResult.endOffset[0] - rResult.startOffset[0];
sBuff.append(std::u16string_view(rStr).substr(nStart, nLength));
}
else if((i < rReplaceStr.getLength() - 1) && rReplaceStr[i] == '$')
{
sFndChar = rReplaceStr[ i + 1 ];
switch(sFndChar)
{ // placeholder for a backward reference?
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
{
int j = sFndChar - '0'; // index
if(j < rResult.subRegExpressions)
{
sal_Int32 nSttReg = rResult.startOffset[j];
sal_Int32 nRegLen = rResult.endOffset[j];
if (nSttReg < 0 || nRegLen < 0) // A "not found" optional capture
{
nSttReg = nRegLen = 0; // Copy empty string
}
else if (nRegLen >= nSttReg)
{
nRegLen = nRegLen - nSttReg;
}
else
{
nRegLen = nSttReg - nRegLen;
nSttReg = rResult.endOffset[j];
}
// Copy reference from found string
sBuff.append(std::u16string_view(rStr).substr(nSttReg, nRegLen));
}
i += 1;
}
break;
default:
sBuff.append(rReplaceStr[i]);
sBuff.append(rReplaceStr[i+1]);
i += 1;
break;
}
}
else if((i < rReplaceStr.getLength() - 1) && rReplaceStr[i] == '\\')
{
sFndChar = rReplaceStr[ i+1 ];
switch(sFndChar)
sal_Int32 nStart = rResult.startOffset[0];
sal_Int32 nLength = rResult.endOffset[0] - rResult.startOffset[0];
sBuff.append(std::u16string_view(rStr).substr(nStart, nLength));
}
else if((i < rReplaceStr.getLength() - 1) && rReplaceStr[i] == '$')
{
sFndChar = rReplaceStr[ i + 1 ];
switch(sFndChar)
{ // placeholder for a backward reference?
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
{
case '\\':
case '&':
case '$':
sBuff.append(sFndChar);
i+=1;
break;
case 't':
sBuff.append('\t');
int j = sFndChar - '0'; // index
if(j < rResult.subRegExpressions)
{
sal_Int32 nSttReg = rResult.startOffset[j];
sal_Int32 nRegLen = rResult.endOffset[j];
if (nSttReg < 0 || nRegLen < 0) // A "not found" optional capture
{
nSttReg = nRegLen = 0; // Copy empty string
}
else if (nRegLen >= nSttReg)
{
nRegLen = nRegLen - nSttReg;
}
else
{
nRegLen = nSttReg - nRegLen;
nSttReg = rResult.endOffset[j];
}
// Copy reference from found string
sBuff.append(std::u16string_view(rStr).substr(nSttReg, nRegLen));
}
i += 1;
break;
default:
sBuff.append(rReplaceStr[i]);
sBuff.append(rReplaceStr[i+1]);
i += 1;
break;
}
}
else
{
break;
default:
sBuff.append(rReplaceStr[i]);
sBuff.append(rReplaceStr[i+1]);
i += 1;
break;
}
}
rReplaceStr = sBuff.makeStringAndClear();
else if((i < rReplaceStr.getLength() - 1) && rReplaceStr[i] == '\\')
{
sFndChar = rReplaceStr[ i+1 ];
switch(sFndChar)
{
case '\\':
case '&':
case '$':
sBuff.append(sFndChar);
i+=1;
break;
case 't':
sBuff.append('\t');
i += 1;
break;
default:
sBuff.append(rReplaceStr[i]);
sBuff.append(rReplaceStr[i+1]);
i += 1;
break;
}
}
else
{
sBuff.append(rReplaceStr[i]);
}
}
rReplaceStr = sBuff.makeStringAndClear();
}
} // namespace utl

View File

@ -432,23 +432,23 @@ void MediaDescriptor::setComponentDataEntry( const OUString& rName, const css::u
void MediaDescriptor::clearComponentDataEntry( const OUString& rName )
{
comphelper::SequenceAsHashMap::iterator aPropertyIter = find( PROP_COMPONENTDATA() );
if( aPropertyIter != end() )
if( aPropertyIter == end() )
return;
css::uno::Any& rCompDataAny = aPropertyIter->second;
bool bHasNamedValues = rCompDataAny.has< css::uno::Sequence< css::beans::NamedValue > >();
bool bHasPropValues = rCompDataAny.has< css::uno::Sequence< css::beans::PropertyValue > >();
OSL_ENSURE( bHasNamedValues || bHasPropValues, "MediaDescriptor::clearComponentDataEntry - incompatible 'ComponentData' property in media descriptor" );
if( bHasNamedValues || bHasPropValues )
{
css::uno::Any& rCompDataAny = aPropertyIter->second;
bool bHasNamedValues = rCompDataAny.has< css::uno::Sequence< css::beans::NamedValue > >();
bool bHasPropValues = rCompDataAny.has< css::uno::Sequence< css::beans::PropertyValue > >();
OSL_ENSURE( bHasNamedValues || bHasPropValues, "MediaDescriptor::clearComponentDataEntry - incompatible 'ComponentData' property in media descriptor" );
if( bHasNamedValues || bHasPropValues )
{
// remove the value with the passed name
comphelper::SequenceAsHashMap aCompDataMap( rCompDataAny );
aCompDataMap.erase( rName );
// write back the sequence, or remove it completely if it is empty
if( aCompDataMap.empty() )
erase( aPropertyIter );
else
rCompDataAny = aCompDataMap.getAsConstAny( bHasPropValues );
}
// remove the value with the passed name
comphelper::SequenceAsHashMap aCompDataMap( rCompDataAny );
aCompDataMap.erase( rName );
// write back the sequence, or remove it completely if it is empty
if( aCompDataMap.empty() )
erase( aPropertyIter );
else
rCompDataAny = aCompDataMap.getAsConstAny( bHasPropValues );
}
}

View File

@ -961,18 +961,18 @@ UcbLockBytes::~UcbLockBytes()
}
}
if ( !m_xInputStream.is() && m_xOutputStream.is() )
if ( m_xInputStream.is() || !m_xOutputStream.is() )
return;
try
{
m_xOutputStream->closeOutput();
}
catch (const RuntimeException&)
{
}
catch (const IOException&)
{
try
{
m_xOutputStream->closeOutput();
}
catch (const RuntimeException&)
{
}
catch (const IOException&)
{
}
}
}