summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2017-05-30 19:57:53 +0800
committerMark Hung <marklh9@gmail.com>2017-06-05 17:25:15 +0200
commit89f038765a36a938961863efea2e0e07515f44d6 (patch)
tree2eb05db9c897be09f4f3c378dd7684e0799490b0
parentf2d40b8ba172d90be9a43c30cd5cbd62c0e8e548 (diff)
tdf#58604 keep line break follows hanging punctuation.
Do not treat the line as full if the chacracter following the hanging punctuation is a line break, so that the line break is placed after the hanging punctuation instead of at the beginning of the next line. Change-Id: Ia6e07cf457b3e1ba39700eb6d6dc74e4b57b64de Reviewed-on: https://gerrit.libreoffice.org/38216 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mark Hung <marklh9@gmail.com>
-rwxr-xr-xsw/qa/extras/uiwriter/data/tdf58604.odtbin0 -> 9780 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx12
-rw-r--r--sw/source/core/text/guess.cxx5
3 files changed, 17 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf58604.odt b/sw/qa/extras/uiwriter/data/tdf58604.odt
new file mode 100755
index 000000000000..34c51c518325
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf58604.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 2452ad422c21..3239e1b2184d 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -250,6 +250,7 @@ public:
void testTdf105417();
void testTdf105625();
void testTdf106736();
+ void testTdf58604();
void testMsWordCompTrailingBlanks();
void testCreateDocxAnnotation();
void testTdf107976();
@@ -390,6 +391,7 @@ public:
CPPUNIT_TEST(testTdf105417);
CPPUNIT_TEST(testTdf105625);
CPPUNIT_TEST(testTdf106736);
+ CPPUNIT_TEST(testTdf58604);
CPPUNIT_TEST(testMsWordCompTrailingBlanks);
CPPUNIT_TEST(testCreateDocxAnnotation);
CPPUNIT_TEST(testTdf107976);
@@ -4942,6 +4944,16 @@ void SwUiWriterTest::testTdf107976()
CPPUNIT_ASSERT(!pTransferable2->GetShell());
}
+void SwUiWriterTest::testTdf58604()
+{
+#ifdef WNT
+ // Allow linebreak character follows hanging punctuation immediately instead of
+ // breaking at the start of the next line.
+ load(DATA_DIRECTORY, "tdf58604.odt");
+ CPPUNIT_ASSERT_EQUAL( OUString("POR_BRK"), parseDump( "(/root/page/body/txt/LineBreak[1]/preceding::Text)[last()]", "nType" ) );
+#endif
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index 066d45a5a2fa..ca432b1b5f68 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -533,7 +533,12 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf,
nBreakWidth = 0;
if( pHanging )
+ {
nBreakPos = nCutPos;
+ // Keep following SwBreakPortion in the same line.
+ if ( CH_BREAK == rInf.GetChar( nBreakPos + pHanging->GetLen() ) )
+ return true;
+ }
return false;
}