summaryrefslogtreecommitdiff
path: root/svx/source/editeng/impedit2.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/editeng/impedit2.cxx')
-rw-r--r--svx/source/editeng/impedit2.cxx59
1 files changed, 56 insertions, 3 deletions
diff --git a/svx/source/editeng/impedit2.cxx b/svx/source/editeng/impedit2.cxx
index 1299cfd1520a..f8cd7e67a4c9 100644
--- a/svx/source/editeng/impedit2.cxx
+++ b/svx/source/editeng/impedit2.cxx
@@ -1777,7 +1777,7 @@ void ImpEditEngine::InitScriptTypes( USHORT nPara )
::rtl::OUString aOUText( aText );
USHORT nTextLen = (USHORT)aOUText.getLength();
- long nPos = 0;
+ sal_Int32 nPos = 0;
short nScriptType = _xBI->getScriptType( aOUText, nPos );
rTypes.Insert( ScriptTypePosInfo( nScriptType, (USHORT)nPos, nTextLen ), rTypes.Count() );
nPos = _xBI->endOfScript( aOUText, nPos, nScriptType );
@@ -1795,6 +1795,17 @@ void ImpEditEngine::InitScriptTypes( USHORT nPara )
}
else
{
+ if ( _xBI->getScriptType( aOUText, nPos - 1 ) == i18n::ScriptType::WEAK )
+ {
+ switch ( u_charType(aOUText.iterateCodePoints(&nPos, 0) ) ) {
+ case U_NON_SPACING_MARK:
+ case U_ENCLOSING_MARK:
+ case U_COMBINING_SPACING_MARK:
+ --nPos;
+ rTypes[rTypes.Count()-1].nEndPos--;
+ break;
+ }
+ }
rTypes.Insert( ScriptTypePosInfo( nScriptType, (USHORT)nPos, nTextLen ), rTypes.Count() );
}
@@ -3289,9 +3300,9 @@ USHORT ImpEditEngine::GetLineCount( USHORT nParagraph ) const
xub_StrLen ImpEditEngine::GetLineLen( USHORT nParagraph, USHORT nLine ) const
{
- DBG_ASSERT( nParagraph < GetParaPortions().Count(), "GetLineCount: Out of range" );
+ DBG_ASSERT( nParagraph < GetParaPortions().Count(), "GetLineLen: Out of range" );
ParaPortion* pPPortion = GetParaPortions().SaveGetObject( nParagraph );
- DBG_ASSERT( pPPortion, "Absatz nicht gefunden: GetLineHeight" );
+ DBG_ASSERT( pPPortion, "Absatz nicht gefunden: GetLineLen" );
if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) )
{
EditLine* pLine = pPPortion->GetLines().GetObject( nLine );
@@ -3302,6 +3313,48 @@ xub_StrLen ImpEditEngine::GetLineLen( USHORT nParagraph, USHORT nLine ) const
return 0xFFFF;
}
+void ImpEditEngine::GetLineBoundaries( /*out*/USHORT &rStart, /*out*/USHORT &rEnd, USHORT nParagraph, USHORT nLine ) const
+{
+ DBG_ASSERT( nParagraph < GetParaPortions().Count(), "GetLineCount: Out of range" );
+ ParaPortion* pPPortion = GetParaPortions().SaveGetObject( nParagraph );
+ DBG_ASSERT( pPPortion, "Absatz nicht gefunden: GetLineBoundaries" );
+ rStart = rEnd = 0xFFFF; // default values in case of error
+ if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) )
+ {
+ EditLine* pLine = pPPortion->GetLines().GetObject( nLine );
+ DBG_ASSERT( pLine, "Zeile nicht gefunden: GetLineBoundaries" );
+ rStart = pLine->GetStart();
+ rEnd = pLine->GetEnd();
+ }
+}
+
+USHORT ImpEditEngine::GetLineNumberAtIndex( USHORT nPara, USHORT nIndex ) const
+{
+ USHORT nLineNo = 0xFFFF;
+ ContentNode* pNode = GetEditDoc().SaveGetObject( nPara );
+ DBG_ASSERT( pNode, "GetLineNumberAtIndex: invalid paragraph index" );
+ if (pNode)
+ {
+ // we explicitly allow for the index to point at the character right behind the text
+ const bool bValidIndex = /*0 <= nIndex &&*/ nIndex <= pNode->Len();
+ DBG_ASSERT( bValidIndex, "GetLineNumberAtIndex: invalid index" );
+ const USHORT nLineCount = GetLineCount( nPara );
+ if (nIndex == pNode->Len())
+ nLineNo = nLineCount > 0 ? nLineCount - 1 : 0;
+ else if (bValidIndex) // nIndex < pNode->Len()
+ {
+ USHORT nStart = USHRT_MAX, nEnd = USHRT_MAX;
+ for (USHORT i = 0; i < nLineCount && nLineNo == 0xFFFF; ++i)
+ {
+ GetLineBoundaries( nStart, nEnd, nPara, i );
+ if (nStart <= nIndex && nIndex < nEnd)
+ nLineNo = i;
+ }
+ }
+ }
+ return nLineNo;
+}
+
USHORT ImpEditEngine::GetLineHeight( USHORT nParagraph, USHORT nLine )
{
DBG_ASSERT( nParagraph < GetParaPortions().Count(), "GetLineCount: Out of range" );