Kaydet (Commit) 5788bb02 authored tarafından Matteo Casalin's avatar Matteo Casalin

Clarify flow, reduce scope

Change-Id: I99dbde5d2b25a8cbffc027e136d29cf911d5337b
Reviewed-on: https://gerrit.libreoffice.org/69243
Tested-by: Jenkins
Reviewed-by: 's avatarMatteo Casalin <matteo.casalin@yahoo.com>
üst 1d86bad1
...@@ -168,17 +168,18 @@ namespace ...@@ -168,17 +168,18 @@ namespace
void SetFsysExtension_Impl( OUString& rFile, const OUString& rExtension ) void SetFsysExtension_Impl( OUString& rFile, const OUString& rExtension )
{ {
const sal_Unicode* p0 = rFile.getStr(); const sal_Int32 nDotPos{ rFile.lastIndexOf('.') };
const sal_Unicode* p1 = p0 + rFile.getLength() - 1; if (nDotPos>=0)
while ( p1 >= p0 && *p1 != '.' ) {
p1--; if (!rExtension.isEmpty())
if ( p1 >= p0 ) rFile = rFile.copy(0, nDotPos) + rExtension; // replace old extension with new (not empty) one
// remove old extension else if (nDotPos)
rFile = rFile.copy( 0, p1 - p0 + 1 - ( rExtension.getLength() > 0 ? 0 : 1 ) ); rFile = rFile.copy(0, nDotPos-1); // truncate extension (new one is empty)
else if ( !rExtension.isEmpty() ) else
// no old extension rFile.clear(); // Filename was just an extension
rFile += "."; }
rFile += rExtension; else if (!rExtension.isEmpty())
rFile += "." + rExtension; // no extension was present, append new one if not empty
} }
void lcl_autoUpdateFileExtension( SvtFileDialog* _pDialog, const OUString& _rLastFilterExt ) void lcl_autoUpdateFileExtension( SvtFileDialog* _pDialog, const OUString& _rLastFilterExt )
...@@ -1309,14 +1310,13 @@ SvtFileDialogFilter_Impl* SvtFileDialog::FindFilter_Impl ...@@ -1309,14 +1310,13 @@ SvtFileDialogFilter_Impl* SvtFileDialog::FindFilter_Impl
{ {
SvtFileDialogFilter_Impl* pFilter = rList[ nFilter ].get(); SvtFileDialogFilter_Impl* pFilter = rList[ nFilter ].get();
const OUString& rType = pFilter->GetType(); const OUString& rType = pFilter->GetType();
OUString aSingleType = rType;
if ( _bMultiExt ) if ( _bMultiExt )
{ {
sal_Int32 nIdx = 0; sal_Int32 nIdx = 0;
while ( !pFoundFilter && nIdx != -1 ) while ( !pFoundFilter && nIdx != -1 )
{ {
aSingleType = rType.getToken( 0, FILEDIALOG_DEF_EXTSEP, nIdx ); const OUString aSingleType = rType.getToken( 0, FILEDIALOG_DEF_EXTSEP, nIdx );
#ifdef UNX #ifdef UNX
if ( aSingleType == _rFilter ) if ( aSingleType == _rFilter )
#else #else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment