diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2022-09-01 18:00:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-02 09:34:51 +0200 |
commit | d8326fc81f7225047178e1b8a7605d32109fa08c (patch) | |
tree | c4ca7ccc751552e5a9183a53e650fc9f165e6845 /svx/source/dialog | |
parent | ee46457ce572649c0b5f238d2556c0cc5a7a8ead (diff) |
tdf#150712: Format->Conditional->Condition 100% CPU (2nd try)
Change-Id: I5f7fe01141ecd057840c01a9080ff7fd2b941049
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139226
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/dialog')
-rw-r--r-- | svx/source/dialog/fntctrl.cxx | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx index 58b412f1e822..a2d466c1e232 100644 --- a/svx/source/dialog/fntctrl.cxx +++ b/svx/source/dialog/fntctrl.cxx @@ -122,18 +122,11 @@ void setFont(const SvxFont& rNewFont, SvxFont& rImplFont) * removes line feeds and carriage returns from string * returns if param is empty */ -bool CleanAndCheckEmpty(OUString& rText) +OUString removeCRLF(const OUString& rText) { - bool bEmpty = true; - for (sal_Int32 i = 0; i < rText.getLength(); ++i) - { - if (0xa == rText[i] || 0xd == rText[i]) - rText = rText.replaceAt(i, 1, u" "); - else - bEmpty = false; - } - return bEmpty; + return rText.replace(0xa, ' ').replace(0xd, ' ').trim(); } + } // end anonymous namespace class FontPrevWin_Impl @@ -635,9 +628,9 @@ void SvxFontPrevWindow::Paint(vcl::RenderContext& rRenderContext, const tools::R if (pSh && !pImpl->mbGetSelection && !pImpl->mbUseFontNameAsText) { - pImpl->maText = pSh->GetSelectionText(); + pImpl->maText = removeCRLF(pSh->GetSelectionText()); pImpl->mbGetSelection = true; - pImpl->mbSelection = !CleanAndCheckEmpty(pImpl->maText); + pImpl->mbSelection = !(pImpl->maText.isEmpty()); } if (!pImpl->mbSelection || pImpl->mbUseFontNameAsText) @@ -670,9 +663,7 @@ void SvxFontPrevWindow::Paint(vcl::RenderContext& rRenderContext, const tools::R pImpl->maText = makeRepresentativeTextForFont(LATIN, rFont); } - bool bEmpty = CleanAndCheckEmpty(pImpl->maText); - if (bEmpty) - pImpl->maText = OUString(); + pImpl->maText = removeCRLF(pImpl->maText); if (pImpl->maText.getLength() > (TEXT_WIDTH - 1)) { |