sw/qa/extras/layout/data/crashHyphen.fodt |   31 ++++++++++++++++++++++++++++++
 sw/qa/extras/layout/layout3.cxx           |    6 +++++
 sw/source/core/text/guess.cxx             |    1 
 3 files changed, 38 insertions(+)

New commits:
commit c2b2731e7a3fa034f7d0f1b5348d589cabf0f376
Author:     Caolán McNamara <[email protected]>
AuthorDate: Fri Jun 7 20:14:15 2024 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Thu Jun 20 11:17:14 2024 +0200

    stale hyphenation data after skipping blanks
    
    what I see is that after skipping the blanks that the m_xHyphWord
    remains describing the word at the original m_nBreakStart, but we have
    changed that m_nBreakStart and in the example I have the m_nBreakStart
    is at the next word, so the contents of m_xHyphWord bear no relationship
    to the current break position.
    
    Change-Id: I07c91495f0cd7ef6d78c0f0d5cef70070ebb6ff2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168561
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168643
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/sw/qa/extras/layout/data/crashHyphen.fodt 
b/sw/qa/extras/layout/data/crashHyphen.fodt
new file mode 100644
index 000000000000..6cdd2ccc45e6
--- /dev/null
+++ b/sw/qa/extras/layout/data/crashHyphen.fodt
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:settings>
+  <config:config-item-set config:name="ooo:configuration-settings">
+   <config:config-item config:name="JustifyLinesWithShrinking" 
config:type="boolean">true</config:config-item>
+  </config:config-item-set>
+ </office:settings>
+ <office:font-face-decls>
+  <style:font-face style:name="Liberation Sans" 
svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" 
style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:text-align="justify" 
style:justify-single-word="false" fo:hyphenation-ladder-count="no-limit" 
style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" 
style:line-break="strict"/>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Liberation Sans" fo:font-size="14pt" fo:language="en" 
fo:country="US" style:letter-kerning="false" fo:hyphenate="true" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" 
loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" 
loext:hyphenation-word-char-count="5" loext:hyphenation-zone="no-limit"/>
+  </style:default-style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="82mm" fo:page-height="83mm" 
style:print-orientation="portrait" fo:margin-top="1cm" fo:margin-bottom="1cm" 
fo:margin-left="1cm" fo:margin-right="1cm"/>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text>
+   <text:p>He heard quiet steps behind; </text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 8c55a4ad772e..2d7bceb42818 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -2612,6 +2612,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, TestTdf161508)
     assertXPath(pExportDump, "//page[2]/body/tab"_ostr, 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, TestCrashHyphenation)
+{
+    //just care it doesn't crash/assert
+    createSwDoc("crashHyphen.fodt");
+}
+
 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 c3a94187a7ea..c199bbfcfa97 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -443,6 +443,7 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, 
SwTextFormatInfo &rInf,
     {
         m_nCutPos = m_nBreakStart = AdjustCutPos(m_nCutPos, m_nBreakPos, rInf);
         nPorLen = m_nBreakPos - rInf.GetIdx();
+        m_xHyphWord = nullptr;
     }
     else
     {

Reply via email to