summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalte Timmermann <mt@openoffice.org>2001-05-11 07:06:32 +0000
committerMalte Timmermann <mt@openoffice.org>2001-05-11 07:06:32 +0000
commite1a5d66eba3bd7454b47b896820e461c47dc254b (patch)
treeda77b7b2fccdbbd86e847726315f177c5fbac8eb
parent5cf24cd18ce676537997f096705aa590fc29d231 (diff)
hanging punctuation and cleanups...
-rw-r--r--svx/source/editeng/editdoc.cxx8
-rw-r--r--svx/source/editeng/editdoc.hxx10
-rw-r--r--svx/source/editeng/editdoc2.cxx8
-rw-r--r--svx/source/editeng/impedit2.cxx6
-rw-r--r--svx/source/editeng/impedit3.cxx77
-rw-r--r--svx/source/editeng/impedit4.cxx7
6 files changed, 75 insertions, 41 deletions
diff --git a/svx/source/editeng/editdoc.cxx b/svx/source/editeng/editdoc.cxx
index c6e35b83c6f5..4377fb9d8640 100644
--- a/svx/source/editeng/editdoc.cxx
+++ b/svx/source/editeng/editdoc.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: editdoc.cxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: mt $ $Date: 2001-04-02 14:07:17 $
+ * last change: $Author: mt $ $Date: 2001-05-11 08:06:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -434,6 +434,7 @@ EditLine::EditLine()
nTxtHeight = 0;
nCrsrHeight = 0;
nMaxAscent = 0;
+ bHangingPunctuation = FALSE;
bInvalid = TRUE;
}
@@ -445,6 +446,7 @@ EditLine::EditLine( const EditLine& r )
nStart = r.nStart;
nStartPortion = r.nStartPortion;
nEndPortion = r.nEndPortion;
+ bHangingPunctuation = r.bHangingPunctuation;
nHeight = 0;
nStartPosX = 0;
@@ -539,7 +541,7 @@ Size EditLine::CalcTextSize( ParaPortion& rParaPortion )
}
break;
case PORTIONKIND_TAB:
- case PORTIONKIND_EXTRASPACE:
+// case PORTIONKIND_EXTRASPACE:
{
aSz.Width() += pPortion->GetSize().Width();
}
diff --git a/svx/source/editeng/editdoc.hxx b/svx/source/editeng/editdoc.hxx
index 0af0987b0a0e..ed7b72253152 100644
--- a/svx/source/editeng/editdoc.hxx
+++ b/svx/source/editeng/editdoc.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: editdoc.hxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: mt $ $Date: 2001-03-21 12:02:04 $
+ * last change: $Author: mt $ $Date: 2001-05-11 08:06:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -359,7 +359,7 @@ public:
#define PORTIONKIND_LINEBREAK 2
#define PORTIONKIND_FIELD 3
#define PORTIONKIND_HYPHENATOR 4
-#define PORTIONKIND_EXTRASPACE 5
+// #define PORTIONKIND_EXTRASPACE 5
#define DELMODE_SIMPLE 0
#define DELMODE_RESTOFWORD 1
@@ -441,6 +441,7 @@ private:
USHORT nTxtHeight; // Reine Texthoehe
USHORT nCrsrHeight; // Bei Konturfluss hohe Zeilen => Cursor zu gro.
USHORT nMaxAscent;
+ BOOL bHangingPunctuation;
BOOL bInvalid; // fuer geschickte Formatierung
public:
@@ -482,6 +483,9 @@ public:
void SetMaxAscent( USHORT n ) { nMaxAscent = n; }
USHORT GetMaxAscent() const { return nMaxAscent; }
+ void SetHangingPunctuation( BOOL b ) { bHangingPunctuation = b; }
+ BOOL IsHangingPunctuation() const { return bHangingPunctuation; }
+
USHORT GetLen() const { return nEnd - nStart; }
USHORT GetStartPosX() const { return nStartPosX; }
diff --git a/svx/source/editeng/editdoc2.cxx b/svx/source/editeng/editdoc2.cxx
index 5ebb26ef0cc3..b5986eb5ec15 100644
--- a/svx/source/editeng/editdoc2.cxx
+++ b/svx/source/editeng/editdoc2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: editdoc2.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: mt $ $Date: 2001-03-02 16:31:50 $
+ * last change: $Author: mt $ $Date: 2001-05-11 08:06:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -365,7 +365,7 @@ long ParaPortion::GetXPos( EditLine* pLine, USHORT nIndex )
case PORTIONKIND_TEXT:
case PORTIONKIND_HYPHENATOR:
case PORTIONKIND_TAB:
- case PORTIONKIND_EXTRASPACE:
+// case PORTIONKIND_EXTRASPACE:
{
nX += pPortion->GetSize().Width();
}
@@ -416,7 +416,7 @@ USHORT ParaPortion::GetChar( EditLine* pLine, long nXPos, BOOL bSmart )
case PORTIONKIND_FIELD:
case PORTIONKIND_HYPHENATOR:
case PORTIONKIND_TAB:
- case PORTIONKIND_EXTRASPACE:
+// case PORTIONKIND_EXTRASPACE:
{
nLastWidth = pPortion->GetSize().Width();
nTmpX += nLastWidth;
diff --git a/svx/source/editeng/impedit2.cxx b/svx/source/editeng/impedit2.cxx
index 67c61376d690..98e3732d2e4c 100644
--- a/svx/source/editeng/impedit2.cxx
+++ b/svx/source/editeng/impedit2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: impedit2.cxx,v $
*
- * $Revision: 1.30 $
+ * $Revision: 1.31 $
*
- * last change: $Author: kz $ $Date: 2001-05-08 13:13:53 $
+ * last change: $Author: mt $ $Date: 2001-05-11 08:06:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -2381,7 +2381,7 @@ ULONG ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine )
case PORTIONKIND_FIELD:
case PORTIONKIND_HYPHENATOR:
case PORTIONKIND_TAB:
- case PORTIONKIND_EXTRASPACE:
+// case PORTIONKIND_EXTRASPACE:
{
nWidth += pTextPortion->GetSize().Width();
}
diff --git a/svx/source/editeng/impedit3.cxx b/svx/source/editeng/impedit3.cxx
index 9c4b9c6f02bb..0c4633ff1107 100644
--- a/svx/source/editeng/impedit3.cxx
+++ b/svx/source/editeng/impedit3.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: impedit3.cxx,v $
*
- * $Revision: 1.31 $
+ * $Revision: 1.32 $
*
- * last change: $Author: mt $ $Date: 2001-04-24 16:41:16 $
+ * last change: $Author: mt $ $Date: 2001-05-11 08:06:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -970,6 +970,8 @@ sal_Bool ImpEditEngine::CreateLines( USHORT nPara, sal_uInt32 nStartPosY )
if( bScriptSpace && ( nTmpWidth < nXWidth ) && IsScriptChange( EditPaM( pNode, nTmpPos+pPortion->GetLen() ) ) )
{
+ // MT 05/2001: Don't create extra portion, add space to prev portion...
+ /*
USHORT nSpacePortion = nTmpPortion+1;
TextPortion* pSpacePortion = NULL;
@@ -987,6 +989,10 @@ sal_Bool ImpEditEngine::CreateLines( USHORT nPara, sal_uInt32 nStartPosY )
nTmpPortion++; // Skip this Portion
pSpacePortion->GetSize().Width() = pPortion->GetSize().Height()/5;
nTmpWidth += pSpacePortion->GetSize().Width();
+ */
+ long nExtraSpace = pPortion->GetSize().Height()/5;
+ pPortion->GetSize().Width() += nExtraSpace;
+ nTmpWidth += nExtraSpace;
}
}
@@ -1089,7 +1095,7 @@ sal_Bool ImpEditEngine::CreateLines( USHORT nPara, sal_uInt32 nStartPosY )
default:
{
// Ein Feature wird nicht umgebrochen:
- DBG_ASSERT( ( pPortion->GetKind() == PORTIONKIND_LINEBREAK ) /*|| ( pPortion->GetKind() == PORTIONKIND_EXTRASPACE )*/, "Was fuer ein Feature ?" );
+ DBG_ASSERT( ( pPortion->GetKind() == PORTIONKIND_LINEBREAK ), "Was fuer ein Feature ?" );
bEOL = sal_True;
bFixedEnd = sal_True;
}
@@ -1219,9 +1225,6 @@ sal_Bool ImpEditEngine::CreateLines( USHORT nPara, sal_uInt32 nStartPosY )
// }
// }
- // Zeilenhoehe auf Window-Pixel alignen?
- // Nein, waere Positionsabhaengig.
-
if ( ( !IsVertical() && aStatus.AutoPageWidth() ) ||
( IsVertical() && aStatus.AutoPageHeight() ) )
{
@@ -1234,6 +1237,20 @@ sal_Bool ImpEditEngine::CreateLines( USHORT nPara, sal_uInt32 nStartPosY )
if ( aTextSize.Width() < nMaxLineWidthFix )
nMaxLineWidth = nMaxLineWidthFix;
}
+
+ if ( pLine->IsHangingPunctuation() )
+ {
+ // Width from HangingPunctuation was set to 0 in ImpBreakLine,
+ // check for rel width now, maybe create compression...
+ long n = nMaxLineWidth - aTextSize.Width();
+ TextPortion* pTP = pParaPortion->GetTextPortions().GetObject( pLine->GetEndPortion() );
+ sal_uInt16 nPosInArray = pLine->GetEnd()-1-pLine->GetStart();
+ long nNewValue = ( nPosInArray ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0 ) + n;
+ pLine->GetCharPosArray()[ nPosInArray ] = nNewValue;
+ pTP->GetSize().Width() += n;
+
+ }
+
switch ( eJustification )
{
case SVX_ADJUST_CENTER:
@@ -1562,9 +1579,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
}
}
- sal_uInt16 nBreakPos = nMaxBreakPos;
-
- lang::Locale aLocale = GetLocale( EditPaM( pNode, nBreakPos ) );
+ lang::Locale aLocale = GetLocale( EditPaM( pNode, nMaxBreakPos ) );
Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
OUString aText( *pNode );
@@ -1578,28 +1593,38 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
aUserOptions.forbiddenBeginCharacters = pForbidden->beginLine;
aUserOptions.forbiddenEndCharacters = pForbidden->endLine;
aUserOptions.applyForbiddenRules = ((const SfxBoolItem&)pNode->GetContentAttribs().GetItem( EE_PARA_FORBIDDENRULES )).GetValue();
- aUserOptions.allowPunctuationOutsideMargin = FALSE; // ((const SfxBoolItem&)pNode->GetContentAttribs().GetItem( EE_PARA_HANGINGPUNCTUATION )).GetValue();
+ aUserOptions.allowPunctuationOutsideMargin = ((const SfxBoolItem&)pNode->GetContentAttribs().GetItem( EE_PARA_HANGINGPUNCTUATION )).GetValue();
aUserOptions.allowHyphenateEnglish = FALSE;
- i18n::LineBreakResults aLBR = xBI->getLineBreak( *pNode, nBreakPos, aLocale, nMinBreakPos, aHyphOptions, aUserOptions );
- nBreakPos = (USHORT)aLBR.breakIndex;
+ i18n::LineBreakResults aLBR = xBI->getLineBreak( *pNode, nMaxBreakPos, aLocale, nMinBreakPos, aHyphOptions, aUserOptions );
+ sal_uInt16 nBreakPos = (USHORT)aLBR.breakIndex;
+
+ // BUG in I18N - the japanese dot is in the next line!
+ // !!! Testen!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ if ( (nBreakPos + ( aUserOptions.allowPunctuationOutsideMargin ? 0 : 1 ) ) <= nMaxBreakPos )
+ {
+ sal_Unicode cFirstInNextLine = ( (nBreakPos+1) < pNode->Len() ) ? pNode->GetChar( nBreakPos ) : 0;
+ if ( cFirstInNextLine == 12290 )
+ nBreakPos++;
+ }
+
+ sal_Bool bHangingPunctuation = ( nBreakPos > nMaxBreakPos ) ? sal_True : sal_False;
+ pLine->SetHangingPunctuation( bHangingPunctuation );
+ sal_Bool bHyphenated = sal_False;
+ sal_Unicode cAlternateReplChar = 0;
+ sal_Unicode cAlternateExtraChar = 0;
sal_Bool bBlankSeparator = ( ( nBreakPos >= pLine->GetStart() ) &&
- ( pNode->GetChar( nBreakPos ) == ' ' ) ) ? sal_True : sal_False;
+ ( pNode->GetChar( nBreakPos ) == ' ' ) ) ? sal_True : sal_False;
+#ifndef SVX_LIGHT
// Egal ob Trenner oder nicht: Das Wort nach dem Trenner durch
// die Silbentrennung jagen...
// nMaxBreakPos ist das letzte Zeichen was in die Zeile passt,
// nBreakPos ist der Wort-Anfang
// Ein Problem gibt es, wenn das Dok so schmal ist, dass ein Wort
// auf mehr als Zwei Zeilen gebrochen wird...
-
- sal_Bool bHyphenated = sal_False;
- sal_Unicode cAlternateReplChar = 0;
- sal_Unicode cAlternateExtraChar = 0;
-
-#ifndef SVX_LIGHT
- if ( bCanHyphenate && GetHyphenator().is() )
+ if ( !bHangingPunctuation && bCanHyphenate && GetHyphenator().is() )
{
// MT: I18N Umstellen auf getWordBoundary !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sal_uInt16 nWordStart = nBreakPos;
@@ -1704,14 +1729,14 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
// die angeknackste Portion ist die End-Portion
pLine->SetEnd( nBreakPos );
sal_uInt16 nEndPortion = SplitTextPortion( pParaPortion, nBreakPos, pLine );
- if ( bBlankSeparator /* && ( eJustification == SVX_ADJUST_RIGHT ) */ )
+ if ( bBlankSeparator || bHangingPunctuation )
{
// Blanks am Zeilenende generell unterdruecken...
TextPortion* pTP = pParaPortion->GetTextPortions().GetObject( nEndPortion );
DBG_ASSERT( pTP->GetKind() == PORTIONKIND_TEXT, "BlankRubber: Keine TextPortion!" );
DBG_ASSERT( nBreakPos > pLine->GetStart(), "SplitTextPortion am Anfang der Zeile?" );
- sal_uInt16 nBlankPosInArray = nBreakPos-1-pLine->GetStart();
- pTP->GetSize().Width() = ( nBlankPosInArray && ( pTP->GetLen() > 1 ) ) ? pLine->GetCharPosArray()[ nBlankPosInArray-1 ] : 0;
+ sal_uInt16 nPosInArray = nBreakPos-1-pLine->GetStart();
+ pTP->GetSize().Width() = ( nPosInArray && ( pTP->GetLen() > 1 ) ) ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0;
}
else if ( bHyphenated )
{
@@ -1770,8 +1795,8 @@ sal_uInt16 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_uInt16 nP
if ( nTmpPos == nPos ) // dann braucht nichts geteilt werden
{
// Skip Portions with ExtraSpace
- while ( ( (nSplitPortion+1) < nPortions ) && (pPortion->GetTextPortions().GetObject(nSplitPortion+1)->GetKind() == PORTIONKIND_EXTRASPACE ) )
- nSplitPortion++;
+// while ( ( (nSplitPortion+1) < nPortions ) && (pPortion->GetTextPortions().GetObject(nSplitPortion+1)->GetKind() == PORTIONKIND_EXTRASPACE ) )
+// nSplitPortion++;
return nSplitPortion;
}
@@ -2525,7 +2550,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aSta
aTmpPos.Y() += nTxtWidth;
}
break;
- case PORTIONKIND_EXTRASPACE:
+// case PORTIONKIND_EXTRASPACE:
case PORTIONKIND_TAB:
{
if ( pTextPortion->GetExtraValue() && ( pTextPortion->GetExtraValue() != ' ' ) )
diff --git a/svx/source/editeng/impedit4.cxx b/svx/source/editeng/impedit4.cxx
index e0af80c21921..8823e3669267 100644
--- a/svx/source/editeng/impedit4.cxx
+++ b/svx/source/editeng/impedit4.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: impedit4.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: mt $ $Date: 2001-04-19 14:38:01 $
+ * last change: $Author: mt $ $Date: 2001-05-11 08:06:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -2227,5 +2227,8 @@ void ImpEditEngine::TransliterateText( const EditSelection& rSelection, sal_Int3
}
if ( bChanges )
+ {
+ SetModifyFlag( sal_True );
FormatAndUpdate();
+ }
}