sw/source/filter/basflt/fltini.cxx | 49 +++++++++++++------------------------ 1 file changed, 18 insertions(+), 31 deletions(-)
New commits: commit 2b8676b01ca742792596e3516ad9990392ae100c Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Nov 15 09:32:45 2018 +0100 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Nov 15 11:35:54 2018 +0100 Make parameter parsing linear, not loop Just cleaner IMO. Change-Id: I89c0c13b8b0be55dcbc2e5536abf982d75e4034d Reviewed-on: https://gerrit.libreoffice.org/63401 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx index 39a4e856ef7d..da64fa262012 100644 --- a/sw/source/filter/basflt/fltini.cxx +++ b/sw/source/filter/basflt/fltini.cxx @@ -576,37 +576,24 @@ OUString NameFromCharSet(rtl_TextEncoding nChrSet) void SwAsciiOptions::ReadUserData( const OUString& rStr ) { sal_Int32 nToken = 0; - int nCnt = 0; - do { - const OUString sToken = rStr.getToken( 0, ',', nToken ); - if (!sToken.isEmpty()) - { - switch( nCnt ) - { - case 0: // CharSet - eCharSet = CharSetFromName(sToken); - break; - case 1: // LineEnd - if (sToken.equalsIgnoreAsciiCase("CRLF")) - eCRLF_Flag = LINEEND_CRLF; - else if (sToken.equalsIgnoreAsciiCase("LF")) - eCRLF_Flag = LINEEND_LF; - else - eCRLF_Flag = LINEEND_CR; - break; - case 2: // fontname - sFont = sToken; - break; - case 3: // Language - nLanguage = LanguageTag::convertToLanguageTypeWithFallback( sToken ); - break; - case 4: - bIncludeBOM = !(sToken.equalsIgnoreAsciiCase("FALSE")); - break; - } - } - ++nCnt; - } while( -1 != nToken ); + OUString sToken = rStr.getToken(0, ',', nToken); // 1. Charset name + if (!sToken.isEmpty()) + eCharSet = CharSetFromName(sToken); + if (nToken >= 0 && !(sToken = rStr.getToken(0, ',', nToken)).isEmpty()) // 2. Line ending type + { + if (sToken.equalsIgnoreAsciiCase("CRLF")) + eCRLF_Flag = LINEEND_CRLF; + else if (sToken.equalsIgnoreAsciiCase("LF")) + eCRLF_Flag = LINEEND_LF; + else + eCRLF_Flag = LINEEND_CR; + } + if (nToken >= 0 && !(sToken = rStr.getToken(0, ',', nToken)).isEmpty()) // 3. Font name + sFont = sToken; + if (nToken >= 0 && !(sToken = rStr.getToken(0, ',', nToken)).isEmpty()) // 4. Language tag + nLanguage = LanguageTag::convertToLanguageTypeWithFallback(sToken); + if (nToken >= 0 && !(sToken = rStr.getToken(0, ',', nToken)).isEmpty()) // 5. Include BOM? + bIncludeBOM = !(sToken.equalsIgnoreAsciiCase("FALSE")); } void SwAsciiOptions::WriteUserData(OUString& rStr) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits