diff options
-rw-r--r-- | sw/qa/extras/odfimport/data/tdf120677.fodt | 13 | ||||
-rw-r--r-- | sw/qa/extras/odfimport/odfimport.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/text/guess.cxx | 20 |
3 files changed, 30 insertions, 8 deletions
diff --git a/sw/qa/extras/odfimport/data/tdf120677.fodt b/sw/qa/extras/odfimport/data/tdf120677.fodt new file mode 100644 index 000000000000..b2006828fb10 --- /dev/null +++ b/sw/qa/extras/odfimport/data/tdf120677.fodt @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:body> + <office:text> + <text:p><draw:frame draw:name="Frame1" text:anchor-type="char" svg:width="0cm" svg:height="2cm"> + <draw:text-box> + <text:p>. </text:p><!-- The "space" here is non-breaking space --> + </draw:text-box> + </draw:frame></text:p> + </office:text> + </office:body> +</office:document>
\ No newline at end of file diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index bd31b56d3e76..160f72028f51 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -910,5 +910,10 @@ DECLARE_ODFIMPORT_TEST(testTdf116195, "tdf116195.odt") ); } +DECLARE_ODFIMPORT_TEST(testTdf120677, "tdf120677.fodt") +{ + // The document used to hang the layout, consuming memory until OOM +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx index 96f82ae8dd5e..f24fdef51094 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -40,7 +40,14 @@ using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::linguistic2; -#define CH_FULL_BLANK 0x3000 +namespace{ + +const sal_Unicode CH_FULL_BLANK = 0x3000; +const sal_Unicode CH_NB_SPACE = 0xA0; + +bool IsBlank(sal_Unicode ch) { return ch == CH_BLANK || ch == CH_FULL_BLANK || ch == CH_NB_SPACE; } + +} // provides information for line break calculation // returns true if no line break has to be performed @@ -243,7 +250,7 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, sal_Unicode cCutChar = nCutPos < TextFrameIndex(rInf.GetText().getLength()) ? rInf.GetText()[sal_Int32(nCutPos)] : 0; - if( CH_BLANK == cCutChar || CH_FULL_BLANK == cCutChar ) + if (IsBlank(cCutChar)) { nBreakPos = nCutPos; TextFrameIndex nX = nBreakPos; @@ -253,23 +260,20 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, // we step back until a non blank character has been found // or there is only one more character left while (nX && TextFrameIndex(rInf.GetText().getLength()) < nBreakPos && - ( CH_BLANK == ( cCutChar = rInf.GetChar( --nX ) ) || - CH_FULL_BLANK == cCutChar ) ) + IsBlank(rInf.GetChar(--nX))) --nBreakPos; } else // #i20878# { while (nX && nBreakPos > rInf.GetLineStart() + TextFrameIndex(1) && - ( CH_BLANK == ( cCutChar = rInf.GetChar( --nX ) ) || - CH_FULL_BLANK == cCutChar ) ) + IsBlank(rInf.GetChar(--nX))) --nBreakPos; } if( nBreakPos > rInf.GetIdx() ) nPorLen = nBreakPos - rInf.GetIdx(); while (++nCutPos < TextFrameIndex(rInf.GetText().getLength()) && - ( CH_BLANK == ( cCutChar = rInf.GetChar( nCutPos ) ) || - CH_FULL_BLANK == cCutChar ) ) + IsBlank(rInf.GetChar(nCutPos))) ; // nothing nBreakStart = nCutPos; |