summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorFrank Meies <fme@openoffice.org>2001-08-17 10:08:09 +0000
committerFrank Meies <fme@openoffice.org>2001-08-17 10:08:09 +0000
commitbefedb83d9510fc818c79927c290140949830401 (patch)
treef55fece04cb781a1426ca7e4e512379a89c5a719 /sw/source
parent7aa19942c7b09878eb2709dc392d369b01201792 (diff)
Fix #90905#: Hyphenation and softhyphens at alternative spelling positions
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/text/guess.cxx33
-rw-r--r--sw/source/core/text/txthyph.cxx34
2 files changed, 39 insertions, 28 deletions
diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index fe652364b8..e9eaba9d45 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: guess.cxx,v $
*
- * $Revision: 1.26 $
+ * $Revision: 1.27 $
*
- * last change: $Author: fme $ $Date: 2001-08-14 09:15:03 $
+ * last change: $Author: fme $ $Date: 2001-08-17 11:08:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -254,7 +254,9 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
// if the current character does not fit to the current line,
// we check for possible hanging punctuation:
- if ( nCutPos && nCutPos == rInf.GetIdx() )
+ const sal_Bool bAllowHanging = rInf.IsHanging() && ! rInf.IsMulti() &&
+ ! rPor.InFldGrp();
+ if ( nCutPos && nCutPos == rInf.GetIdx() && bAllowHanging )
{
ASSERT( rSI.ScriptType( nCutPos - 1 ), "Script is not between 1 and 4" );
@@ -304,8 +306,7 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
GetForbiddenCharacters( aLang, TRUE ));
LineBreakUserOptions aUserOpt(
aForbidden.beginLine, aForbidden.endLine,
- rInf.HasForbiddenChars(), rInf.IsHanging() && !rInf.IsMulti(),
- sal_False );
+ rInf.HasForbiddenChars(), bAllowHanging, sal_False );
// determines first possible line break from nRightPos to
// start index of current line
LineBreakResults aResult = pBreakIt->xBreak->getLineBreak(
@@ -331,6 +332,7 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
// found hyphenation position within line
// nBreakPos is set to the hyphenation position
xHyphWord = aResult.rHyphenatedWord;
+ nBreakPos += xHyphWord->getHyphenationPos() + 1;
#ifdef DEBUG
// e.g., Schif-fahrt, referes to our string
@@ -343,14 +345,17 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
const USHORT nHyphenPos = xHyphWord->getHyphenPos();
#endif
- nBreakPos += xHyphWord->getHyphenationPos() + 1;
+ // if not in interactive mode, we have to break behind a soft hyphen
+ if ( ! rInf.IsInterHyph() && rInf.GetIdx() )
+ {
+ const long nSoftHyphPos =
+ xHyphWord->getWord().indexOf( CHAR_SOFTHYPHEN );
- // Check, if break position is soft hyphen or if current position
- // is behind a softhyphen. In both cases an underflow
- // has to be triggered
- if( nBreakPos > rInf.GetLineStart() &&
- ( CHAR_SOFTHYPHEN == rInf.GetTxt().GetChar( nBreakPos ) ) )
- nBreakPos = rInf.GetIdx() - 1;
+ if ( nSoftHyphPos >= 0 &&
+ nBreakStart + nSoftHyphPos <= nBreakPos &&
+ nBreakPos > rInf.GetLineStart() )
+ nBreakPos = rInf.GetIdx() - 1;
+ }
if( nBreakPos >= rInf.GetIdx() )
{
@@ -361,12 +366,14 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
}
else if ( !bHyph && nBreakPos >= rInf.GetLineStart() )
{
+ ASSERT( nBreakPos != STRING_LEN, "we should have found a break pos" );
+
// found break position within line
xHyphWord = NULL;
// check, if break position is soft hyphen and an underflow
// has to be triggered
- if( nBreakPos > rInf.GetLineStart() &&
+ if( nBreakPos > rInf.GetLineStart() && rInf.GetIdx() &&
CHAR_SOFTHYPHEN == rInf.GetTxt().GetChar( nBreakPos - 1 ) )
nBreakPos = rInf.GetIdx() - 1;
diff --git a/sw/source/core/text/txthyph.cxx b/sw/source/core/text/txthyph.cxx
index 613ef38906..21185e1e24 100644
--- a/sw/source/core/text/txthyph.cxx
+++ b/sw/source/core/text/txthyph.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: txthyph.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: tl $ $Date: 2001-03-29 08:07:29 $
+ * last change: $Author: fme $ $Date: 2001-08-17 11:05:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -272,6 +272,7 @@ sal_Bool SwTxtFormatter::Hyphenate( SwInterHyphInfo &rHyphInf )
&& ( !pPos->IsSoftHyphPortion()
|| ((SwSoftHyphPortion*)pPos)->IsExpand() ) )
{
+ nWrdStart += pPos->GetLen();
break;
}
@@ -316,19 +317,22 @@ sal_Bool SwTxtFormatter::Hyphenate( SwInterHyphInfo &rHyphInf )
{
XubString aSelTxt( rInf.GetTxt().Copy(nWrdStart, nLen) );
xub_StrLen nCnt = 0;
- for( xub_StrLen i = 0; i < nLen; ++i )
- {
- sal_Unicode cCh = aSelTxt.GetChar(i);
- if( (CH_TXTATR_BREAKWORD == cCh || CH_TXTATR_INWORD == cCh )
- && rInf.HasHint( nWrdStart + i ) )
- {
- aSelTxt.Erase( i , 1 );
- nCnt++;
- --nLen;
- if( i )
- --i;
- }
- }
+
+// these things should be handled by the dialog
+// for( xub_StrLen i = 0; i < nLen; ++i )
+// {
+// sal_Unicode cCh = aSelTxt.GetChar(i);
+// if( (CH_TXTATR_BREAKWORD == cCh || CH_TXTATR_INWORD == cCh )
+// && rInf.HasHint( nWrdStart + i ) )
+// {
+// aSelTxt.Erase( i , 1 );
+// nCnt++;
+// --nLen;
+// if( i )
+// --i;
+// }
+// }
+
{
MSHORT nMinTrail = 0;
if( nWrdStart + nLen > nEnd )