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

Noel Grandin noel.grandin at collabora.co.uk
Thu Apr 26 08:38:37 UTC 2018


 sw/inc/editsh.hxx                  |    2 
 sw/qa/extras/uiwriter/uiwriter.cxx |    4 -
 sw/source/core/edit/eddel.cxx      |   10 ++--
 sw/source/uibase/inc/wrtsh.hxx     |    6 +-
 sw/source/uibase/wrtsh/delete.cxx  |   80 ++++++++++++++++++-------------------
 sw/source/uibase/wrtsh/wrtsh1.cxx  |    2 
 sw/source/uibase/wrtsh/wrtsh2.cxx  |    2 
 7 files changed, 53 insertions(+), 53 deletions(-)

New commits:
commit 3b90faa9c51791d01bef69ac6924a71e869f25d7
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Apr 25 20:53:17 2018 +0200

    SwEditShell functions that really want to return bool
    
    but just couldn't, because they were too shy, so they went to
    ToastMasters, and now they are all grown up and can bool all the day
    long
    
    Change-Id: Id06e0791ec3c930be8a165cc7b05ce4f0c8f7499
    Reviewed-on: https://gerrit.libreoffice.org/53462
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 91bbf131e0e0..c7f3c078a3b4 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -172,7 +172,7 @@ public:
 
     /** Delete content of all ranges.
      If whole nodes are selected, these nodes get deleted. */
-    long Delete();
+    bool Delete();
 
     /// Remove a complete paragraph.
     bool DelFullPara();
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 05478b782488..e729ccf06816 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -2407,8 +2407,8 @@ void SwUiWriterTest::testTdf60967()
     pCursor->Move(fnMoveBackward);
     SwPosition aPosInTable(*(pCursor->GetPoint()));
     //deleting paragraph following table with Ctrl+Shift+Del
-    sal_Int32 val = pWrtShell->DelToEndOfSentence();
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), val);
+    bool val = pWrtShell->DelToEndOfSentence();
+    CPPUNIT_ASSERT_EQUAL(true, val);
     //getting the cursor's position just after the paragraph deletion
     SwPosition aPosAfterDel(*(pCursor->GetPoint()));
     //moving cursor forward to check whether there is any node following the table, BTW there should not be any such node
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index bcd0f9d7b34e..f60fcbc5be54 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -112,10 +112,10 @@ void SwEditShell::DeleteSel( SwPaM& rPam, bool* pUndo )
     rPam.DeleteMark();
 }
 
-long SwEditShell::Delete()
+bool SwEditShell::Delete()
 {
     SET_CURR_SHELL( this );
-    long nRet = 0;
+    bool bRet = false;
     if ( !HasReadonlySel() || CursorInsideInputField() )
     {
         StartAllAction();
@@ -140,14 +140,14 @@ long SwEditShell::Delete()
             GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::END, nullptr);
         }
         EndAllAction();
-        nRet = 1;
+        bRet = true;
     }
     else
     {
-        nRet = RemoveParagraphMetadataFieldAtCursor() ? 1 : 0;
+        bRet = RemoveParagraphMetadataFieldAtCursor();
     }
 
-    return nRet;
+    return bRet;
 }
 
 bool SwEditShell::Copy( SwEditShell* pDestShell )
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index 3b593928cc9b..4693ac1860f3 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -268,13 +268,13 @@ typedef bool (SwWrtShell:: *FNSimpleMove)();
     void    DelToEndOfLine();
     void    DelToStartOfLine();
     void    DelLine();
-    long    DelLeft();
+    bool    DelLeft();
 
     // also deletes the frame or sets the cursor in the frame when bDelFrame == false
-    long    DelRight();
+    bool    DelRight();
     void    DelToEndOfPara();
     void    DelToStartOfPara();
-    long    DelToEndOfSentence();
+    bool    DelToEndOfSentence();
     void    DelToStartOfSentence();
     void    DelNxtWord();
     void    DelPrvWord();
diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx
index fc23a8237858..59436decddf1 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -113,9 +113,9 @@ void SwWrtShell::DelLine()
     SetMark();
     SwCursorShell::RightMargin();
 
-    long nRet = Delete();
+    bool bRet = Delete();
     Pop(SwCursorShell::PopMode::DeleteCurrent);
-    if( nRet )
+    if( bRet )
         UpdateAttr();
 }
 
@@ -123,19 +123,19 @@ void SwWrtShell::DelToStartOfLine()
 {
     OpenMark();
     SwCursorShell::LeftMargin();
-    long nRet = Delete();
-    CloseMark( 0 != nRet );
+    bool bRet = Delete();
+    CloseMark( bRet );
 }
 
 void SwWrtShell::DelToEndOfLine()
 {
     OpenMark();
     SwCursorShell::RightMargin();
-    long nRet = Delete();
-    CloseMark( 0 != nRet );
+    bool bRet = Delete();
+    CloseMark( bRet );
 }
 
-long SwWrtShell::DelLeft()
+bool SwWrtShell::DelLeft()
 {
     // If it's a Fly, throw it away
     SelectionType nSelType = GetSelectionType();
@@ -160,7 +160,7 @@ long SwWrtShell::DelLeft()
             GotoNextFly();
         }
 
-        return 1;
+        return true;
     }
 
     // If a selection exists, erase this
@@ -184,7 +184,7 @@ long SwWrtShell::DelLeft()
             }
             else
                 EnterStdMode();
-            return 1;
+            return true;
         }
         else
             EnterStdMode();
@@ -232,7 +232,7 @@ long SwWrtShell::DelLeft()
         {
             // tdf#115132 Restore previous position and we are done
             SwCursorShell::Pop(SwCursorShell::PopMode::DeleteCurrent);
-            return 0;
+            return false;
         }
 
         SwCursorShell::Pop(SwCursorShell::PopMode::DeleteStack);
@@ -252,7 +252,7 @@ long SwWrtShell::DelLeft()
         if (pFm && pFm->GetMarkEnd() == *pCurPos)
         {
             getIDocumentMarkAccess()->deleteMark(pFm);
-            return 1;
+            return true;
         }
 
         OpenMark();
@@ -281,18 +281,18 @@ long SwWrtShell::DelLeft()
             }
         }
     }
-    long nRet = Delete();
-    if( !nRet && bSwap )
+    bool bRet = Delete();
+    if( !bRet && bSwap )
         SwCursorShell::SwapPam();
-    CloseMark( 0 != nRet );
-    return nRet;
+    CloseMark( bRet );
+    return bRet;
 }
 
-long SwWrtShell::DelRight()
+bool SwWrtShell::DelRight()
 {
         // Will be or'ed, if a tableselection exists;
         // will here be implemented on SelectionType::Table
-    long nRet = 0;
+    bool bRet = false;
     SelectionType nSelection = GetSelectionType();
     if(nSelection & SelectionType::TableCell)
         nSelection = SelectionType::Table;
@@ -326,7 +326,7 @@ long SwWrtShell::DelRight()
                 }
                 else
                     EnterStdMode();
-                nRet = 1;
+                bRet = true;
                 break;
             }
             else
@@ -388,15 +388,15 @@ long SwWrtShell::DelRight()
             if (pFm && pFm->GetMarkStart() == *GetCursor()->GetPoint())
             {
                 getIDocumentMarkAccess()->deleteMark(pFm);
-                nRet = 1;
+                bRet = true;
                 break;
             }
         }
 
         OpenMark();
         SwCursorShell::Right(1, CRSR_SKIP_CELLS);
-        nRet = Delete();
-        CloseMark( 0 != nRet );
+        bRet = Delete();
+        CloseMark( bRet );
         break;
 
     case SelectionType::Frame:
@@ -444,11 +444,11 @@ long SwWrtShell::DelRight()
                 GotoNextFly();
             }
         }
-        nRet = 1;
+        bRet = true;
         break;
     default: break;
     }
-    return nRet;
+    return bRet;
 }
 
 void SwWrtShell::DelToEndOfPara()
@@ -462,9 +462,9 @@ void SwWrtShell::DelToEndOfPara()
         Pop(SwCursorShell::PopMode::DeleteCurrent);
         return;
     }
-    long nRet = Delete();
+    bool bRet = Delete();
     Pop(SwCursorShell::PopMode::DeleteCurrent);
-    if( nRet )
+    if( bRet )
         UpdateAttr();
 }
 
@@ -479,9 +479,9 @@ void SwWrtShell::DelToStartOfPara()
         Pop(SwCursorShell::PopMode::DeleteCurrent);
         return;
     }
-    long nRet = Delete();
+    bool bRet = Delete();
     Pop(SwCursorShell::PopMode::DeleteCurrent);
-    if( nRet )
+    if( bRet )
         UpdateAttr();
 }
 
@@ -494,16 +494,16 @@ void SwWrtShell::DelToStartOfSentence()
     if(IsStartOfDoc())
         return;
     OpenMark();
-    long nRet = BwdSentence_() ? Delete() : 0;
-    CloseMark( 0 != nRet );
+    bool bRet = BwdSentence_() && Delete();
+    CloseMark( bRet );
 }
 
-long SwWrtShell::DelToEndOfSentence()
+bool SwWrtShell::DelToEndOfSentence()
 {
     if(IsEndOfDoc())
-        return 0;
+        return false;
     OpenMark();
-    long nRet(0);
+    bool bRet(false);
     // fdo#60967: special case that is documented in help: delete
     // paragraph following table if cursor is at end of last cell in table
     if (IsEndOfTable())
@@ -519,17 +519,17 @@ long SwWrtShell::DelToEndOfSentence()
             }
             if (!IsEndOfDoc()) // do not delete last paragraph in body text
             {
-                nRet = DelFullPara() ? 1 : 0;
+                bRet = DelFullPara();
             }
         }
         Pop(SwCursorShell::PopMode::DeleteCurrent);
     }
     else
     {
-        nRet = FwdSentence_() ? Delete() : 0;
+        bRet = FwdSentence_() && Delete();
     }
-    CloseMark( 0 != nRet );
-    return nRet;
+    CloseMark( bRet );
+    return bRet;
 }
 
 void SwWrtShell::DelNxtWord()
@@ -547,8 +547,8 @@ void SwWrtShell::DelNxtWord()
     else
         EndWrd();
 
-    long nRet = Delete();
-    if( nRet )
+    bool bRet = Delete();
+    if( bRet )
         UpdateAttr();
     else
         SwapPam();
@@ -571,8 +571,8 @@ void SwWrtShell::DelPrvWord()
         else
             SttWrd();
     }
-    long nRet = Delete();
-    if( nRet )
+    bool bRet = Delete();
+    if( bRet )
         UpdateAttr();
     else
         SwapPam();
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 1137d5cdae17..2ed8db43218f 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -218,7 +218,7 @@ void SwWrtShell::Insert( const OUString &rStr )
 
         StartUndo(SwUndoId::REPLACE, &aRewriter);
         bStarted = true;
-        bDeleted = DelRight() != 0;
+        bDeleted = DelRight();
     }
 
     bCallIns ?
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index fd1b177a7322..cce9e8b9227b 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -108,7 +108,7 @@ void SwWrtShell::Insert(SwField const &rField)
         }
         else
         {
-            bDeleted = DelRight() != 0;
+            bDeleted = DelRight();
         }
     }
 


More information about the Libreoffice-commits mailing list