[Libreoffice-commits] core.git: sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu May 26 05:41:55 UTC 2016


 sw/source/uibase/inc/wrtsh.hxx   |    4 ++--
 sw/source/uibase/uno/unotxvw.cxx |   12 ++++--------
 sw/source/uibase/wrtsh/move.cxx  |    8 ++++----
 3 files changed, 10 insertions(+), 14 deletions(-)

New commits:
commit cbe78f817da8db78d226b3ad2b1a10d0c2dcf188
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed May 25 14:23:55 2016 +0200

    tdf#100051 Partially revert "loplugin:constantparam in sw"
    
    This partially reverts commit 9585c8b8c8d8724cc1bad4a2060c828c15599929.
    Instead of removing the nCount parameters, make use of them in
    SwXTextViewCursor::go{Left,Right,Down,Up}.
    
    For the following testcase: a document with 1000 lines, and calling
    goDown(1000, true) the spent time goes from 4 secs to 1.8 secs with this
    for me.
    
    Change-Id: I10351a6dbaa6d3fff883520c85701f60b05b4873
    Reviewed-on: https://gerrit.libreoffice.org/25450
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index 5a36e7e..0f8ccda 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -191,8 +191,8 @@ typedef bool (SwWrtShell:: *FNSimpleMove)();
                             sal_uInt16 nCount, bool bBasicCall, bool bVisual = false );
     bool Right      ( sal_uInt16 nMode, bool bSelect,
                             sal_uInt16 nCount, bool bBasicCall, bool bVisual = false );
-    bool Up         ( bool bSelect, bool bBasicCall = false );
-    bool Down       ( bool bSelect, bool bBasicCall = false );
+    bool Up         ( bool bSelect, sal_uInt16 nCount = 1, bool bBasicCall = false );
+    bool Down       ( bool bSelect, sal_uInt16 nCount = 1, bool bBasicCall = false );
     void NxtWrd     ( bool bSelect = false ) { SimpleMove( &SwWrtShell::NxtWrd_, bSelect ); }
     bool PrvWrd     ( bool bSelect = false ) { return SimpleMove( &SwWrtShell::PrvWrd_, bSelect ); }
 
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx
index 2eb2f50..ecbb9df 100644
--- a/sw/source/uibase/uno/unotxvw.cxx
+++ b/sw/source/uibase/uno/unotxvw.cxx
@@ -1000,8 +1000,7 @@ sal_Bool SwXTextViewCursor::goLeft(sal_Int16 nCount, sal_Bool bExpand)
         if (!IsTextSelection())
             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
 
-        for( sal_uInt16 i = 0; i < nCount; i++ )
-            bRet = m_pView->GetWrtShell().Left( CRSR_SKIP_CHARS, bExpand, 1, true );
+        bRet = m_pView->GetWrtShell().Left( CRSR_SKIP_CHARS, bExpand, nCount, true );
     }
     else
         throw uno::RuntimeException();
@@ -1018,8 +1017,7 @@ sal_Bool SwXTextViewCursor::goRight(sal_Int16 nCount, sal_Bool bExpand)
         if (!IsTextSelection())
             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
 
-        for( sal_uInt16 i = 0; i < nCount; i++ )
-            bRet = m_pView->GetWrtShell().Right( CRSR_SKIP_CHARS, bExpand, 1, true );
+        bRet = m_pView->GetWrtShell().Right( CRSR_SKIP_CHARS, bExpand, nCount, true );
     }
     else
         throw uno::RuntimeException();
@@ -1616,8 +1614,7 @@ sal_Bool SwXTextViewCursor::goDown(sal_Int16 nCount, sal_Bool bExpand)
         if (!IsTextSelection())
             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
 
-        for( sal_uInt16 i = 0; i < nCount; i++ )
-            bRet = m_pView->GetWrtShell().Down( bExpand, true );
+        bRet = m_pView->GetWrtShell().Down( bExpand, nCount, true );
     }
     else
         throw uno::RuntimeException();
@@ -1634,8 +1631,7 @@ sal_Bool SwXTextViewCursor::goUp(sal_Int16 nCount, sal_Bool bExpand)
         if (!IsTextSelection())
             throw  uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) );
 
-        for( sal_uInt16 i = 0; i < nCount; i++ )
-            bRet = m_pView->GetWrtShell().Up( bExpand, true );
+        bRet = m_pView->GetWrtShell().Up( bExpand, nCount, true );
     }
     else
         throw uno::RuntimeException();
diff --git a/sw/source/uibase/wrtsh/move.cxx b/sw/source/uibase/wrtsh/move.cxx
index 81b9c7a..7125044 100644
--- a/sw/source/uibase/wrtsh/move.cxx
+++ b/sw/source/uibase/wrtsh/move.cxx
@@ -127,7 +127,7 @@ bool SwWrtShell::Right( sal_uInt16 nMode, bool bSelect,
     }
 }
 
-bool SwWrtShell::Up( bool bSelect, bool bBasicCall )
+bool SwWrtShell::Up( bool bSelect, sal_uInt16 nCount, bool bBasicCall )
 {
     if ( !bSelect && !bBasicCall && IsCursorReadonly()  && !GetViewOptions()->IsSelectionInReadonly())
     {
@@ -138,10 +138,10 @@ bool SwWrtShell::Up( bool bSelect, bool bBasicCall )
     }
 
     ShellMoveCursor aTmp( this, bSelect );
-    return SwCursorShell::Up();
+    return SwCursorShell::Up(nCount);
 }
 
-bool SwWrtShell::Down( bool bSelect, bool bBasicCall )
+bool SwWrtShell::Down( bool bSelect, sal_uInt16 nCount, bool bBasicCall )
 {
     if ( !bSelect && !bBasicCall && IsCursorReadonly() && !GetViewOptions()->IsSelectionInReadonly())
     {
@@ -153,7 +153,7 @@ bool SwWrtShell::Down( bool bSelect, bool bBasicCall )
     }
 
     ShellMoveCursor aTmp( this, bSelect );
-    return SwCursorShell::Down();
+    return SwCursorShell::Down(nCount);
 }
 
 bool SwWrtShell::LeftMargin( bool bSelect, bool bBasicCall )


More information about the Libreoffice-commits mailing list