[Libreoffice-commits] core.git: 2 commits - i18npool/source
László Németh
nemeth at numbertext.org
Mon Jun 30 15:25:24 PDT 2014
i18npool/source/breakiterator/breakiterator_unicode.cxx | 22 +++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
New commits:
commit 712d60f03d4c7dfa1ec56e49f40036ab7eb25fde
Author: László Németh <nemeth at numbertext.org>
Date: Tue Jul 1 00:18:13 2014 +0200
fdo#79372, fdo#56392 fix hyphenation
Change-Id: Iacf84d023d3b4795892bc444299a29bfc663345e
diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx
index 126ac7a..5270b1d 100644
--- a/i18npool/source/breakiterator/breakiterator_unicode.cxx
+++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx
@@ -398,7 +398,7 @@ LineBreakResults SAL_CALL BreakIterator_Unicode::getLineBreak(
uno::Reference< linguistic2::XHyphenatedWord > aHyphenatedWord;
aHyphenatedWord = hOptions.rHyphenator->hyphenate(Text.copy(wBoundary.startPos,
wBoundary.endPos - wBoundary.startPos), rLocale,
- (sal_Int16) (hOptions.hyphenIndex - wBoundary.startPos - nStartPosWordEnd), hOptions.aHyphenationOptions);
+ (sal_Int16) (hOptions.hyphenIndex - wBoundary.startPos - ((hOptions.hyphenIndex == wBoundary.endPos)? nStartPosWordEnd : 0)), hOptions.aHyphenationOptions);
if (aHyphenatedWord.is()) {
lbr.rHyphenatedWord = aHyphenatedWord;
if(wBoundary.startPos + aHyphenatedWord->getHyphenationPos() + 1 < nMinBreakPos )
commit c78d948b6113e3c3b38d8a0b5206155c4c3a13e4
Author: László Németh <nemeth at numbertext.org>
Date: Tue Jul 1 00:15:11 2014 +0200
Revert "fdo#79372 fix hyphenation (remove fdo#56392 fix, except hard hyphen part)"
This reverts commit 259d3421d4cf7788d9099daa40fc181c661783ee.
diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx
index b491181..126ac7a 100644
--- a/i18npool/source/breakiterator/breakiterator_unicode.cxx
+++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx
@@ -376,13 +376,29 @@ LineBreakResults SAL_CALL BreakIterator_Unicode::getLineBreak(
if (line.aBreakIterator->preceding(nStartPos + 1) == nStartPos) { //Line boundary break
lbr.breakIndex = nStartPos;
lbr.breakType = BreakType::WORDBOUNDARY;
- } else if (hOptions.rHyphenator.is()) { //Hyphenation break, FIXME: fdo#56392
- Boundary wBoundary = getWordBoundary( Text, nStartPos, rLocale,
+ } else if (hOptions.rHyphenator.is()) { //Hyphenation break
+ sal_Int32 boundary_with_punctuation = (line.aBreakIterator->next() != BreakIterator::DONE) ? line.aBreakIterator->current() : 0;
+ line.aBreakIterator->preceding(nStartPos + 1); // reset to check correct hyphenation of "word-word"
+
+ sal_Int32 nStartPosWordEnd = nStartPos;
+ while (line.aBreakIterator->current() < nStartPosWordEnd && u_ispunct((sal_uInt32)Text[nStartPosWordEnd])) // starting punctuation
+ nStartPosWordEnd --;
+
+ Boundary wBoundary = getWordBoundary( Text, nStartPosWordEnd, rLocale,
WordType::DICTIONARY_WORD, false);
+
+ nStartPosWordEnd = wBoundary.endPos;
+ while (nStartPosWordEnd < Text.getLength() && (u_ispunct((sal_uInt32)Text[nStartPosWordEnd]))) // ending punctuation
+ nStartPosWordEnd ++;
+ nStartPosWordEnd = nStartPosWordEnd - wBoundary.endPos;
+ if (hOptions.hyphenIndex - wBoundary.startPos < nStartPosWordEnd) nStartPosWordEnd = hOptions.hyphenIndex - wBoundary.startPos;
+#define SPACE 0x0020
+ while (boundary_with_punctuation > wBoundary.endPos && Text[--boundary_with_punctuation] == SPACE);
+ if (boundary_with_punctuation != 0) boundary_with_punctuation += 1 - wBoundary.endPos;
uno::Reference< linguistic2::XHyphenatedWord > aHyphenatedWord;
aHyphenatedWord = hOptions.rHyphenator->hyphenate(Text.copy(wBoundary.startPos,
wBoundary.endPos - wBoundary.startPos), rLocale,
- (sal_Int16) (hOptions.hyphenIndex - wBoundary.startPos), hOptions.aHyphenationOptions);
+ (sal_Int16) (hOptions.hyphenIndex - wBoundary.startPos - nStartPosWordEnd), hOptions.aHyphenationOptions);
if (aHyphenatedWord.is()) {
lbr.rHyphenatedWord = aHyphenatedWord;
if(wBoundary.startPos + aHyphenatedWord->getHyphenationPos() + 1 < nMinBreakPos )
More information about the Libreoffice-commits
mailing list