[Libreoffice-commits] core.git: Branch 'aoo/trunk' - editeng/source svtools/source sw/inc sw/source vcl/source vcl/unx

Tsutomu Uchino hanya at apache.org
Tue Jan 16 17:11:53 UTC 2018


 editeng/source/editeng/impedit2.cxx |    7 ++++++-
 svtools/source/edit/textview.cxx    |    4 ++++
 sw/inc/crsrsh.hxx                   |    5 +++++
 sw/source/core/crsr/crsrsh.cxx      |    8 ++++++++
 sw/source/ui/docvw/edtwin.cxx       |   36 ++++++++++++++++++++++++++++++++++--
 vcl/source/control/edit.cxx         |    7 +++++--
 vcl/unx/gtk/window/gtkframe.cxx     |    4 +++-
 7 files changed, 65 insertions(+), 6 deletions(-)

New commits:
commit e387056aa78f50e7be024014e9236aacd1fe7eab
Author: Tsutomu Uchino <hanya at apache.org>
Date:   Tue Jan 16 16:17:17 2018 +0000

    #i127662# send better window position to input method for suggestion window

diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 2adf55cf57fa..e10fa9c67dc9 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -622,7 +622,12 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
                 nInputEnd = pLine->GetEnd();
             Rectangle aR2 = PaMtoEditCursor( EditPaM( aPaM.GetNode(), nInputEnd ), GETCRSR_ENDOFLINE );
             Rectangle aRect = pView->GetImpEditView()->GetWindowPos( aR1 );
-            pView->GetWindow()->SetCursorRect( &aRect, aR2.Left()-aR1.Right() );
+            long nWidth = aR2.Left()-aR1.Right();
+            if ( nWidth == 0 ) {
+                Rectangle aR3 = PaMtoEditCursor( mpIMEInfos->aPos );
+                nWidth = -(aR1.Left() - aR3.Left());
+            }
+            pView->GetWindow()->SetCursorRect( &aRect, nWidth );
         }
         else
         {
diff --git a/svtools/source/edit/textview.cxx b/svtools/source/edit/textview.cxx
index 455866301843..c1adec5300a1 100644
--- a/svtools/source/edit/textview.cxx
+++ b/svtools/source/edit/textview.cxx
@@ -1048,6 +1048,10 @@ void TextView::Command( const CommandEvent& rCEvt )
 
             long nWidth = aR2.Left()-aR1.Right();
             aR1.Move( -GetStartDocPos().X(), -GetStartDocPos().Y() );
+            if ( nWidth == 0 ) {
+                Rectangle aR3 = mpImpl->mpTextEngine->PaMtoEditCursor( mpImpl->mpTextEngine->mpIMEInfos->aPos );
+                nWidth = -(aR1.Left() - aR3.Left());
+            }
             GetWindow()->SetCursorRect( &aR1, nWidth );
         }
         else
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index ac4227ebed20..ba3ef5aa0ddf 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -550,6 +550,11 @@ public:
      * liefert das SRectangle, auf dem der Cursor steht.
      */
     const SwRect &GetCharRect() const { return aCharRect; }
+
+    // Obtains character rectangle at the position.
+    sal_Bool GetCharRectAt( SwRect& rOrig, const SwPosition& rPos,
+                                  SwCrsrMoveState *pCMS = 0 ) const;
+
     /*
      * liefert zurueck, ob der Cursor sich ganz oder teilweise im
      * sichtbaren Bereich befindet.
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 9ef7c499e86d..05c5ab7a8e58 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1233,6 +1233,14 @@ sal_Bool SwCrsrShell::GoPrevCrsr()
 }
 
 
+sal_Bool SwCrsrShell::GetCharRectAt( SwRect& rOrig, const SwPosition& rPos,
+                                     SwCrsrMoveState* pCMS ) const
+{
+    SwCntntFrm * pFrm = GetCurrFrm();
+    return pFrm ? pFrm->GetCharRect( rOrig, rPos, pCMS ) : sal_False;
+}
+
+
 void SwCrsrShell::Paint( const Rectangle &rRect)
 {
     SET_CURR_SHELL( this );
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 6836fb982392..53f435e6909c 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -5059,8 +5059,40 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
     }
     break;
     case COMMAND_CURSORPOS:
-        // will be handled by the base class
-        break;
+    {
+        sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
+                              rSh.IsCrsrReadonly();
+        if ( !bIsDocReadOnly )
+        {
+            if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
+            {
+                bCallBase = sal_False;
+                rSh.GetDrawView()->GetTextEditOutlinerView()->Command( rCEvt );
+            }
+            else
+            {
+                const SwExtTextInput* pExtInp = rSh.GetDoc()->GetExtTextInput();
+                if ( pExtInp )
+                {
+                    // The carret placed at the end of the preedit.
+                    if ( POS_COLLIDE_START == ComparePosition( *pExtInp->End(), *pExtInp->End(),
+                                        *rSh.GetCrsr()->End(), *rSh.GetCrsr()->End() ) )
+                    {
+                        SwRect aInputRect;
+                        if ( rSh.GetCharRectAt( aInputRect, *pExtInp->Start() ) )
+                        {
+                            Rectangle aRect( aInputRect.SVRect() );
+                            SetCursorRect( &aRect, 1 );
+                            bCallBase = sal_False;
+                        }
+                    }
+                    if ( bCallBase )
+                        SetCursorRect();
+                }
+            }
+        }
+    }
+    break;
 
     case COMMAND_PASTESELECTION:
         if( !rView.GetDocShell()->IsReadOnly() )
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 4479a02cb033..d4a42e072a9c 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -2313,8 +2313,11 @@ void Edit::Command( const CommandEvent& rCEvt )
         if ( mpIMEInfos )
         {
             xub_StrLen nCursorPos = (sal_uInt16)GetSelection().Max();
-            SetCursorRect( NULL, GetTextWidth(
-                maText, nCursorPos, mpIMEInfos->nPos+mpIMEInfos->nLen-nCursorPos ) );
+            long nWidth = GetTextWidth( maText, mpIMEInfos->nPos, mpIMEInfos->nLen );
+            if ( nCursorPos == ( mpIMEInfos->nPos + mpIMEInfos->nLen ) ) {
+                nWidth = -nWidth;
+            }
+            SetCursorRect( NULL, nWidth );
         }
         else
         {
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index afa557dc2d79..c7a53b419a81 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -3344,7 +3344,9 @@ void GtkSalFrame::IMHandler::updateIMSpotLocation()
     SalExtTextInputPosEvent aPosEvent;
     m_pFrame->CallCallback( SALEVENT_EXTTEXTINPUTPOS, (void*)&aPosEvent );
     GdkRectangle aArea;
-    aArea.x = aPosEvent.mnX;
+    // Positive aPosEvent.mnExtWidth means ahead of the carret,
+    // negative value means behind of the carret.
+    aArea.x = aPosEvent.mnX + (aPosEvent.mnExtWidth < 0 ? aPosEvent.mnExtWidth : 0);
     aArea.y = aPosEvent.mnY;
     aArea.width = aPosEvent.mnWidth;
     aArea.height = aPosEvent.mnHeight;


More information about the Libreoffice-commits mailing list