summaryrefslogtreecommitdiff
path: root/sw/source/core/text/itratr.cxx
diff options
context:
space:
mode:
authorFrank Meies <fme@openoffice.org>2001-12-14 11:13:58 +0000
committerFrank Meies <fme@openoffice.org>2001-12-14 11:13:58 +0000
commit70c60c5fff49c43ad4921e183ab8b3be2b93a962 (patch)
tree35b70c990de0982866d107f0c50be8507bb68065 /sw/source/core/text/itratr.cxx
parent4ddb013b3b3eaf74369be74192fd937108eb3cb8 (diff)
Fix #95904#: Consider font changes during weak character classification
Diffstat (limited to 'sw/source/core/text/itratr.cxx')
-rw-r--r--sw/source/core/text/itratr.cxx75
1 files changed, 73 insertions, 2 deletions
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 0631871108e8..6cdba9a34f27 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: itratr.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: ama $ $Date: 2001-11-30 13:52:05 $
+ * last change: $Author: fme $ $Date: 2001-12-14 12:06:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1121,3 +1121,74 @@ USHORT SwTxtNode::GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd )
( nWidth ? ((100 * aIter.GetFnt()->_GetTxtSize( aDrawInf ).Height()) / nWidth ) : 0 );
}
+SwFontIter::SwFontIter( const SwTxtNode& rNode, SwAttrHandler& rAH,
+ xub_StrLen nStt, xub_StrLen nEnd )
+ : aFnt( *rAH.GetFont() ), rAttrHandler( rAH ), pHints( rNode.GetpSwpHints() ),
+ nStartIndex( 0 ), nEndIndex( 0 ), nCurrPos( nStt ), nEndPos( nEnd )
+{
+ ASSERT( pHints,
+ "I think SwFontIter is too expensive if we do not have hints" )
+}
+
+SwFontIter::~SwFontIter()
+{
+ rAttrHandler.Reset();
+}
+
+xub_StrLen SwFontIter::NextFontChg() const
+{
+ xub_StrLen nNextPos = STRING_LEN;
+
+ if (pHints->GetStartCount() > nStartIndex) // Gibt es noch Starts?
+ nNextPos = (*pHints->GetStart(nStartIndex)->GetStart());
+ if (pHints->GetEndCount() > nEndIndex) // Gibt es noch Enden?
+ {
+ xub_StrLen nNextEnd = (*pHints->GetEnd(nEndIndex)->GetAnyEnd());
+ if ( nNextEnd < nNextPos ) nNextPos = nNextEnd; // Wer ist naeher?
+ }
+
+ return Min( nEndPos, nNextPos );
+}
+
+const SwFont& SwFontIter::GetCurrFont( xub_StrLen nNewPos )
+{
+ ASSERT( nNewPos >= nCurrPos, "Do not use me (SwFontIter) like this" )
+
+ // change font for position nPos:
+ const SwTxtAttr *pTxtAttr;
+
+ if ( nStartIndex )
+ {
+ while ( ( nEndIndex < pHints->GetEndCount() ) &&
+ (*(pTxtAttr = pHints->GetEnd(nEndIndex))->GetAnyEnd() <= nNewPos))
+ {
+ // close attributes in front of old position
+ if ( *pTxtAttr->GetStart() <= nCurrPos )
+ rAttrHandler.PopAndChg( *pTxtAttr, aFnt );
+
+ nEndIndex++;
+ }
+ }
+ else // skip non open attributes
+ {
+ while ( ( nEndIndex < pHints->GetEndCount() ) &&
+ (*(pTxtAttr = pHints->GetEnd(nEndIndex))->GetAnyEnd() <= nNewPos))
+ {
+ nEndIndex++;
+ }
+ }
+
+ while ( ( nStartIndex < pHints->GetStartCount() ) &&
+ (*(pTxtAttr = pHints->GetStart(nStartIndex))->GetStart() <= nNewPos))
+ {
+ // open attributes behind new position
+ if ( *pTxtAttr->GetAnyEnd() > nNewPos )
+ rAttrHandler.PushAndChg( *pTxtAttr, aFnt );
+
+ nStartIndex++;
+ }
+
+ nCurrPos = nNewPos;
+
+ return aFnt;
+}