summaryrefslogtreecommitdiff
path: root/linguistic
diff options
context:
space:
mode:
authorThomas Lange <tl@openoffice.org>2001-08-14 08:15:49 +0000
committerThomas Lange <tl@openoffice.org>2001-08-14 08:15:49 +0000
commitfbd1abd2f53d511e5378ce9ff55128f9d2ab2ddb (patch)
tree967aeed5039c66eccee4231355d2f5641682574f /linguistic
parentec655436f00e00f4005955b0d7c89ce2ddbb1722 (diff)
#90905# behaviour for soft-hyphens changed
Diffstat (limited to 'linguistic')
-rw-r--r--linguistic/source/hyphdsp.cxx12
-rw-r--r--linguistic/source/misc.cxx32
2 files changed, 23 insertions, 21 deletions
diff --git a/linguistic/source/hyphdsp.cxx b/linguistic/source/hyphdsp.cxx
index 4e7e2673621d..5079983c67b4 100644
--- a/linguistic/source/hyphdsp.cxx
+++ b/linguistic/source/hyphdsp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hyphdsp.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: tl $ $Date: 2001-08-10 10:30:31 $
+ * last change: $Author: tl $ $Date: 2001-08-14 09:15:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -319,11 +319,11 @@ Reference< XHyphenatedWord > SAL_CALL
{
// allow only hyphenation positions to the left of the
// first soft-hyphen
- INT32 nFirstSoftHyphenPos = rWord.indexOf( SVT_SOFT_HYPHEN );
- if (nFirstSoftHyphenPos >= 0 && nFirstSoftHyphenPos <= nMaxLeading)
+ INT32 nLastSoftHyphenPos = rWord.lastIndexOf( SVT_SOFT_HYPHEN );
+ if (nLastSoftHyphenPos >= 0 && nLastSoftHyphenPos <= nMaxLeading)
{
- INT16 nP = nFirstSoftHyphenPos - 1;
- DBG_ASSERT( nP > 0, "unexpected soft-hyphen pos" );
+ INT16 nP = nLastSoftHyphenPos - 1;
+ DBG_ASSERT( nP >= 0, "unexpected soft-hyphen pos" );
xRes = queryAlternativeSpelling( rWord, rLocale, nP, rProperties );
if (!xRes.is())
xRes = new HyphenatedWord( rWord, nLanguage, nP, rWord, nP );
diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx
index 0115a18bcf55..1aecef5b1684 100644
--- a/linguistic/source/misc.cxx
+++ b/linguistic/source/misc.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: misc.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: tl $ $Date: 2001-07-25 10:09:50 $
+ * last change: $Author: tl $ $Date: 2001-08-14 09:15:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -425,17 +425,15 @@ static BOOL GetAltSpelling( INT16 &rnChgPos, INT16 &rnChgLen, OUString &rRplc,
static INT16 GetOrigWordPos( const OUString &rOrigWord, INT16 nPos )
{
INT32 nLen = rOrigWord.getLength();
- INT32 nNotSkippedChars = 0;
- for (INT32 i = 0; i < nLen; ++i)
+ INT32 i = -1;
+ while (nPos >= 0 && i++ < nLen)
{
sal_Unicode cChar = rOrigWord[i];
BOOL bSkip = IsHyphen( cChar ) || IsControlChar( cChar );
if (!bSkip)
- ++nNotSkippedChars;
- if (nNotSkippedChars > nPos || (bSkip && nNotSkippedChars == nPos))
- break;
+ --nPos;
}
- return i < nLen ? i : -1;
+ return (0 <= i && i < nLen) ? i : -1;
}
@@ -473,40 +471,44 @@ Reference< XHyphenatedWord > RebuildHyphensAndControlChars(
BOOL bAltSpelling = GetAltSpelling( nChgPos, nChgLen, aRplc, rxHyphWord );
OUString aOrigHyphenatedWord;
- INT16 nOrigHyphenPos = -1;
+ INT16 nOrigHyphenPos = -1;
+ INT16 nOrigHyphenationPos = -1;
if (!bAltSpelling)
{
#ifdef DEBUG
OUString aWord( rxHyphWord->getWord() );
#endif
aOrigHyphenatedWord = rOrigWord;
- nOrigHyphenPos = GetOrigWordPos( rOrigWord, rxHyphWord->getHyphenPos() );
+ nOrigHyphenPos = GetOrigWordPos( rOrigWord, rxHyphWord->getHyphenPos() );
+ nOrigHyphenationPos = GetOrigWordPos( rOrigWord, rxHyphWord->getHyphenationPos() );
}
else
{
OUString aLeft, aRight;
INT16 nPos = GetOrigWordPos( rOrigWord, nChgPos );
+ nPos += (-1 + nChgLen);
aLeft = rOrigWord.copy( 0, nPos );
-// nPos = GetOrigWordPos( rOrigWord, nChgPos + nChgLen );
aRight = rOrigWord.copy( nPos + nChgLen );
aOrigHyphenatedWord = aLeft;
aOrigHyphenatedWord += aRplc;
aOrigHyphenatedWord += aRight;
- nOrigHyphenPos = aLeft.getLength() +
+ nOrigHyphenPos = aLeft.getLength() +
rxHyphWord->getHyphenPos() - nChgPos;
+ nOrigHyphenationPos = aLeft.getLength() +
+ rxHyphWord->getHyphenationPos() - nChgPos;
}
- if (nOrigHyphenPos == -1)
+ if (nOrigHyphenPos == -1 || nOrigHyphenationPos == -1)
{
- DBG_ERROR( "failed to get nOrigHyphenPos" );
+ DBG_ERROR( "failed to get nOrigHyphenPos or nOrigHyphenationPos" );
}
else
{
INT16 nLang = LocaleToLanguage( rxHyphWord->getLocale() );
xRes = new HyphenatedWord(
- rOrigWord, nLang, rxHyphWord->getHyphenationPos(),
+ rOrigWord, nLang, nOrigHyphenationPos,
aOrigHyphenatedWord, nOrigHyphenPos );
}