include/svx/fntctrl.hxx | 1 + svx/source/dialog/fntctrl.cxx | 32 +++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-)
New commits: commit 3f289fef2f2b00dcca4948dd9fb2ba2c493fac6f Author: Julien Nabet <serval2...@yahoo.fr> Date: Wed Nov 8 23:17:56 2017 +0100 tdf#113657: fix crash when trying to format empty paragraph by creating a function to clean line feeds and returns if it's empty or not Change-Id: I3a744c52bdb457c92f38595463099e1cbf17a37e Reviewed-on: https://gerrit.libreoffice.org/44513 Tested-by: Jenkins <c...@libreoffice.org> Tested-by: Xisco Faulà <xiscofa...@libreoffice.org> Reviewed-by: Michael Stahl <mst...@redhat.com> diff --git a/include/svx/fntctrl.hxx b/include/svx/fntctrl.hxx index ed0828e8cc3b..9b54d2ae0a3c 100644 --- a/include/svx/fntctrl.hxx +++ b/include/svx/fntctrl.hxx @@ -63,6 +63,7 @@ public: void ResetColor(); void SetBackColor( const Color& rColor ); void UseResourceText(); + bool CleanAndCheckEmpty(OUString& rText); void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override; bool IsTwoLines() const; diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx index c78c8f481d47..039f69fe2d80 100644 --- a/svx/source/dialog/fntctrl.cxx +++ b/svx/source/dialog/fntctrl.cxx @@ -612,6 +612,24 @@ void SvxFontPrevWindow::UseResourceText() pImpl->mbUseResText = true; } +/* + * removes line feeds and carriage returns from string + * returns if param is empty + */ +bool SvxFontPrevWindow::CleanAndCheckEmpty(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, " "); + else + bEmpty = false; + } + return bEmpty; +} + + void SvxFontPrevWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { ApplySettings(rRenderContext); @@ -645,7 +663,7 @@ void SvxFontPrevWindow::Paint(vcl::RenderContext& rRenderContext, const tools::R { pImpl->maText = pSh->GetSelectionText(); pImpl->mbGetSelection = true; - pImpl->mbSelection = !pImpl->maText.isEmpty(); + pImpl->mbSelection = !CleanAndCheckEmpty(pImpl->maText); } if (!pImpl->mbSelection || pImpl->mbUseFontNameAsText) @@ -681,16 +699,8 @@ void SvxFontPrevWindow::Paint(vcl::RenderContext& rRenderContext, const tools::R pImpl->maText = makeRepresentativeTextForFont(LATIN, rFont); } - // remove line feeds and carriage returns from string - bool bNotEmpty = false; - for (sal_Int32 i = 0; i < pImpl->maText.getLength(); ++i) - { - if (0xa == pImpl->maText[i] || 0xd == pImpl->maText[i]) - pImpl->maText = pImpl->maText.replaceAt(i, 1, " "); - else - bNotEmpty = true; - } - if (!bNotEmpty) + bool bEmpty = CleanAndCheckEmpty(pImpl->maText); + if (bEmpty) pImpl->maText = GetText(); if (pImpl->maText.getLength() > (TEXT_WIDTH - 1))
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits