diff options
-rw-r--r-- | svx/source/editeng/impedit.hxx | 7 | ||||
-rw-r--r-- | svx/source/editeng/impedit2.cxx | 40 | ||||
-rw-r--r-- | svx/source/editeng/impedit5.cxx | 7 |
3 files changed, 45 insertions, 9 deletions
diff --git a/svx/source/editeng/impedit.hxx b/svx/source/editeng/impedit.hxx index 027facf0673f..19cdfb37875e 100644 --- a/svx/source/editeng/impedit.hxx +++ b/svx/source/editeng/impedit.hxx @@ -2,9 +2,9 @@ * * $RCSfile: impedit.hxx,v $ * - * $Revision: 1.29 $ + * $Revision: 1.30 $ * - * last change: $Author: mt $ $Date: 2001-05-31 11:32:00 $ + * last change: $Author: mt $ $Date: 2001-06-13 10:55:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -170,13 +170,14 @@ struct DragAndDropInfo struct ImplIMEInfos { + String aOldTextAfterStartPos; sal_uInt16* pAttribs; EditPaM aPos; sal_uInt16 nLen; sal_Bool bCursor; sal_Bool bWasCursorOverwrite; - ImplIMEInfos( const EditPaM& rPos ); + ImplIMEInfos( const EditPaM& rPos, const String& rOldTextAfterStartPos ); ~ImplIMEInfos(); void CopyAttribs( const sal_uInt16* pA, sal_uInt16 nL ); diff --git a/svx/source/editeng/impedit2.cxx b/svx/source/editeng/impedit2.cxx index 0ac6c9340685..ab858a71af4e 100644 --- a/svx/source/editeng/impedit2.cxx +++ b/svx/source/editeng/impedit2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: impedit2.cxx,v $ * - * $Revision: 1.33 $ + * $Revision: 1.34 $ * - * last change: $Author: mt $ $Date: 2001-05-14 15:19:42 $ + * last change: $Author: mt $ $Date: 2001-06-13 10:55:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -520,7 +520,12 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView ) { pView->DeleteSelected(); delete mpIMEInfos; - mpIMEInfos = new ImplIMEInfos( pView->GetImpEditView()->GetEditSelection().Max() ); + EditPaM aPaM = pView->GetImpEditView()->GetEditSelection().Max(); + String aOldTextAfterStartPos = aPaM.GetNode()->Copy( aPaM.GetIndex() ); + USHORT nMax = aOldTextAfterStartPos.Search( CH_FEATURE ); + if ( nMax != STRING_NOTFOUND ) // don't overwrite features! + aOldTextAfterStartPos.Erase( nMax ); + mpIMEInfos = new ImplIMEInfos( aPaM, aOldTextAfterStartPos ); mpIMEInfos->bWasCursorOverwrite = !pView->IsInsertMode(); } else if ( rCEvt.GetCommand() == COMMAND_ENDEXTTEXTINPUT ) @@ -555,6 +560,35 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView ) aSel = DeleteSelected( aSel ); aSel = ImpInsertText( aSel, pData->GetText() ); + if ( mpIMEInfos->bWasCursorOverwrite ) + { + USHORT nOldIMETextLen = mpIMEInfos->nLen; + USHORT nNewIMETextLen = pData->GetText().Len(); + + if ( ( nOldIMETextLen > nNewIMETextLen ) && + ( nNewIMETextLen < mpIMEInfos->aOldTextAfterStartPos.Len() ) ) + { + // restore old characters + USHORT nRestore = nOldIMETextLen - nNewIMETextLen; + EditPaM aPaM( mpIMEInfos->aPos ); + aPaM.GetIndex() += nNewIMETextLen; + ImpInsertText( aPaM, mpIMEInfos->aOldTextAfterStartPos.Copy( nNewIMETextLen, nRestore ) ); + } + else if ( ( nOldIMETextLen < nNewIMETextLen ) && + ( nOldIMETextLen < mpIMEInfos->aOldTextAfterStartPos.Len() ) ) + { + // overwrite + USHORT nOverwrite = nNewIMETextLen - nOldIMETextLen; + if ( ( nOldIMETextLen + nOverwrite ) > mpIMEInfos->aOldTextAfterStartPos.Len() ) + nOverwrite = mpIMEInfos->aOldTextAfterStartPos.Len() - nOldIMETextLen; + DBG_ASSERT( nOverwrite && (nOverwrite < 0xFF00), "IME Overwrite?!" ); + EditPaM aPaM( mpIMEInfos->aPos ); + aPaM.GetIndex() += nNewIMETextLen; + EditSelection aSel( aPaM ); + aSel.Max().GetIndex() += nOverwrite; + DeleteSelected( aSel ); + } + } if ( pData->GetTextAttr() ) { mpIMEInfos->CopyAttribs( pData->GetTextAttr(), pData->GetText().Len() ); diff --git a/svx/source/editeng/impedit5.cxx b/svx/source/editeng/impedit5.cxx index 53e06c9d4c95..42606608fc3f 100644 --- a/svx/source/editeng/impedit5.cxx +++ b/svx/source/editeng/impedit5.cxx @@ -2,9 +2,9 @@ * * $RCSfile: impedit5.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: mt $ $Date: 2001-05-03 08:19:53 $ + * last change: $Author: mt $ $Date: 2001-06-13 10:56:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -829,7 +829,8 @@ void IdleFormattter::ForceTimeout() } } -ImplIMEInfos::ImplIMEInfos( const EditPaM& rPos ) +ImplIMEInfos::ImplIMEInfos( const EditPaM& rPos, const String& rOldTextAfterStartPos ) + : aOldTextAfterStartPos( rOldTextAfterStartPos ) { aPos = rPos; nLen = 0; |