[Libreoffice-commits] core.git: editeng/source forms/source include/editeng sc/source sd/source starmath/source svx/source sw/source

Noel Grandin noel.grandin at collabora.co.uk
Fri Sep 29 06:53:30 UTC 2017


 editeng/source/editeng/impedit.cxx                   |    4 ++--
 editeng/source/uno/unoforou.cxx                      |    2 +-
 editeng/source/uno/unotext.cxx                       |    2 +-
 editeng/source/uno/unotext2.cxx                      |    4 ++--
 forms/source/richtext/richtextimplcontrol.cxx        |    2 +-
 include/editeng/editdata.hxx                         |   17 +++++++++--------
 sc/source/ui/drawfunc/drtxtob.cxx                    |    2 +-
 sc/source/ui/view/gridwin.cxx                        |    4 ++--
 sd/source/ui/view/Outliner.cxx                       |    4 ++--
 starmath/source/edit.cxx                             |    2 +-
 svx/source/accessibility/AccessibleTextHelper.cxx    |    2 +-
 svx/source/svdraw/textchaincursor.cxx                |    4 ++--
 svx/source/svdraw/textchainflow.cxx                  |    2 +-
 svx/source/table/tablecontroller.cxx                 |    2 +-
 sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx |    2 +-
 sw/source/uibase/docvw/edtwin.cxx                    |    2 +-
 16 files changed, 29 insertions(+), 28 deletions(-)

New commits:
commit 8a8864aeb710e4d17852dc9c0e02b03804a8bf3c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Sep 28 13:06:51 2017 +0200

    convert IsEqual/etc methods on ESelection to operators
    
    Change-Id: Ia8424e701b6f22d0536ee7f3bdb0ecaaed94a3b9
    Reviewed-on: https://gerrit.libreoffice.org/42904
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index aaf24df25f18..f765ed5cd800 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -1935,7 +1935,7 @@ void ImpEditView::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent
                 ESelection aToBeDelSel = pDragAndDropInfo->aBeginDragSel;
                 ESelection aNewSel( pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos,
                                     pDragAndDropInfo->aDropSel.nEndPara, pDragAndDropInfo->aDropSel.nEndPos );
-                bool bBeforeSelection = aDropPos.IsLess( pDragAndDropInfo->aBeginDragSel );
+                bool bBeforeSelection = aDropPos < pDragAndDropInfo->aBeginDragSel;
                 sal_Int32 nParaDiff = pDragAndDropInfo->aBeginDragSel.nEndPara - pDragAndDropInfo->aBeginDragSel.nStartPara;
                 if ( bBeforeSelection )
                 {
@@ -2192,7 +2192,7 @@ void ImpEditView::dragOver(const css::datatransfer::dnd::DropTargetDragEvent& rD
                 ESelection aDestSel( aP.nPara, aP.nIndex, aP.nPara, aP.nIndex);
                 ESelection aCurSel = pEditEngine->pImpEditEngine->CreateESel( GetEditSelection() );
                 aCurSel.Adjust();
-                if ( !aDestSel.IsLess( aCurSel ) && !aDestSel.IsGreater( aCurSel ) )
+                if ( !(aDestSel < aCurSel) && !(aDestSel > aCurSel) )
                 {
                     bAccept = false;
                 }
diff --git a/editeng/source/uno/unoforou.cxx b/editeng/source/uno/unoforou.cxx
index 64336df2d146..2c0bde9c2849 100644
--- a/editeng/source/uno/unoforou.cxx
+++ b/editeng/source/uno/unoforou.cxx
@@ -101,7 +101,7 @@ SfxItemSet SvxOutlinerForwarder::GetAttribs( const ESelection& rSel, EditEngineA
     if( mpAttribsCache && ( EditEngineAttribs::All == nOnlyHardAttrib ) )
     {
         // have we the correct set in cache?
-        if( const_cast<SvxOutlinerForwarder*>(this)->maAttribCacheSelection.IsEqual(rSel) )
+        if( maAttribCacheSelection == rSel )
         {
             // yes! just return the cache
             return *mpAttribsCache;
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index ebc6ee10fba9..b52836cc7b38 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -1955,7 +1955,7 @@ void SAL_CALL SvxUnoTextBase::setString( const OUString& aString )
 uno::Reference< container::XEnumeration > SAL_CALL SvxUnoTextBase::createEnumeration()
 {
     SolarMutexGuard aGuard;
-    if( maSelection.IsEqual(ESelection(0,0,0,0)) || maSelection.IsEqual(ESelection(EE_PARA_MAX_COUNT,0,0,0)) )
+    if( maSelection == ESelection(0,0,0,0) || maSelection == ESelection(EE_PARA_MAX_COUNT,0,0,0) )
     {
         ESelection aSelection;
         ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
diff --git a/editeng/source/uno/unotext2.cxx b/editeng/source/uno/unotext2.cxx
index e647433ebf9c..cf3564d7cbef 100644
--- a/editeng/source/uno/unotext2.cxx
+++ b/editeng/source/uno/unotext2.cxx
@@ -66,7 +66,7 @@ SvxUnoTextContentEnumeration::SvxUnoTextContentEnumeration( const SvxUnoTextBase
                 if( pIterContent && (pIterContent->mnParagraph == currentPara) )
                 {
                     ESelection aIterSel = pIterContent->GetSelection();
-                    if( aIterSel.IsEqual( aCurrentParaSel ) )
+                    if( aIterSel == aCurrentParaSel )
                     {
                         pContent = pIterContent;
                         maContents.emplace_back(pContent );
@@ -408,7 +408,7 @@ SvxUnoTextRangeEnumeration::SvxUnoTextRangeEnumeration( const SvxUnoTextBase& rT
             for( auto aIter = rRanges.begin(); (aIter != rRanges.end()) && (pRange == nullptr); ++aIter )
             {
                 SvxUnoTextRange* pIterRange = dynamic_cast< SvxUnoTextRange* >( ( *aIter ) );
-                if( pIterRange && pIterRange->mbPortion && ( aSel.IsEqual( pIterRange->maSelection ) ) )
+                if( pIterRange && pIterRange->mbPortion && (aSel == pIterRange->maSelection) )
                     pRange = pIterRange;
             }
             if( pRange == nullptr )
diff --git a/forms/source/richtext/richtextimplcontrol.cxx b/forms/source/richtext/richtextimplcontrol.cxx
index dad5042b2846..9d9cf426070b 100644
--- a/forms/source/richtext/richtextimplcontrol.cxx
+++ b/forms/source/richtext/richtextimplcontrol.cxx
@@ -146,7 +146,7 @@ namespace frm
         if ( m_pSelectionListener && m_pView )
         {
             ESelection aCurrentSelection = m_pView->GetSelection();
-            if ( !aCurrentSelection.IsEqual( m_aLastKnownSelection ) )
+            if ( aCurrentSelection != m_aLastKnownSelection )
             {
                 m_aLastKnownSelection = aCurrentSelection;
                 m_pSelectionListener->onSelectionChanged( m_aLastKnownSelection );
diff --git a/include/editeng/editdata.hxx b/include/editeng/editdata.hxx
index 2d5a5e035d87..9dc75ce0bed3 100644
--- a/include/editeng/editdata.hxx
+++ b/include/editeng/editdata.hxx
@@ -139,9 +139,10 @@ struct ESelection
         { }
 
     void    Adjust();
-    bool    IsEqual( const ESelection& rS ) const;
-    bool    IsLess( const ESelection& rS ) const;
-    bool    IsGreater( const ESelection& rS ) const;
+    bool    operator==( const ESelection& rS ) const;
+    bool    operator!=( const ESelection& rS ) const { return !operator==(rS); }
+    bool    operator<( const ESelection& rS ) const;
+    bool    operator>( const ESelection& rS ) const;
     bool    IsZero() const;
     bool    HasRange() const;
 };
@@ -164,26 +165,26 @@ inline bool ESelection::IsZero() const
              ( nEndPara == 0 ) && ( nEndPos == 0 ) );
 }
 
-inline bool ESelection::IsEqual( const ESelection& rS ) const
+inline bool ESelection::operator==( const ESelection& rS ) const
 {
     return ( ( nStartPara == rS.nStartPara ) && ( nStartPos == rS.nStartPos ) &&
              ( nEndPara == rS.nEndPara ) && ( nEndPos == rS.nEndPos ) );
 }
 
-inline bool ESelection::IsLess( const ESelection& rS ) const
+inline bool ESelection::operator<( const ESelection& rS ) const
 {
     // The selection must be adjusted.
     // => Only check if end of 'this' < Start of rS
     return ( nEndPara < rS.nStartPara ) ||
-        ( ( nEndPara == rS.nStartPara ) && ( nEndPos < rS.nStartPos ) && !IsEqual( rS ) );
+        ( ( nEndPara == rS.nStartPara ) && ( nEndPos < rS.nStartPos ) && !operator==( rS ) );
 }
 
-inline bool ESelection::IsGreater( const ESelection& rS ) const
+inline bool ESelection::operator>( const ESelection& rS ) const
 {
     // The selection must be adjusted.
     // => Only check if end of 'this' < Start of rS
     return ( nStartPara > rS.nEndPara ) ||
-        ( ( nStartPara == rS.nEndPara ) && ( nStartPos > rS.nEndPos ) && !IsEqual( rS ) );
+        ( ( nStartPara == rS.nEndPara ) && ( nStartPos > rS.nEndPos ) && !operator==( rS ) );
 }
 
 inline void ESelection::Adjust()
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index 4949d2bf3248..6a2bad28bd50 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -649,7 +649,7 @@ static void lcl_RemoveFields( OutlinerView& rOutView )
         pOutliner->SetUpdateMode( true );
     }
 
-    if ( aOldSel.IsEqual( aSel ) )          // aSel is adjusted
+    if ( aOldSel == aSel )          // aSel is adjusted
         aOldSel.nEndPos = nNewEnd;
     else
         aOldSel.nStartPos = nNewEnd;        // if aOldSel is backwards
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 3cff01b5ddbf..1726e25a1d46 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2957,7 +2957,7 @@ void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCCOL nCellX, S
             ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
             ESelection aSelection = pEditView->GetSelection();
             aSelection.Adjust();    // needed for IsLess/IsGreater
-            if ( aCompare.IsLess(aSelection) || aCompare.IsGreater(aSelection) )
+            if ( aCompare < aSelection || aCompare > aSelection )
             {
                 // clicked outside the selected text - deselect and move text cursor
                 MouseEvent aEvent( rPosPixel );
@@ -3006,7 +3006,7 @@ void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCCOL nCellX, S
             ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
             ESelection aSelection = pOlView->GetSelection();
             aSelection.Adjust();    // needed for IsLess/IsGreater
-            if ( aCompare.IsLess(aSelection) || aCompare.IsGreater(aSelection) )
+            if ( aCompare < aSelection || aCompare > aSelection )
             {
                 // clicked outside the selected text - deselect and move text cursor
                 // use DrawView to allow extra handling there (none currently)
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index be8c1a9c3faa..74b4daea902a 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -411,7 +411,7 @@ svx::SpellPortions SdOutliner::GetNextSpellSentence()
         {
             ESelection aCurrentSelection (pOutlinerView->GetSelection());
             if ( ! mbMatchMayExist
-                && maStartSelection.IsLess(aCurrentSelection))
+                && maStartSelection < aCurrentSelection)
                 EndOfSearch();
 
             // Advance to the next sentence.
@@ -1472,7 +1472,7 @@ bool SdOutliner::HasNoPreviousMatch()
 
     // Detect whether the cursor stands at the beginning
     // resp. at the end of the text.
-    return pOutlinerView->GetSelection().IsEqual(GetSearchStartPosition ());
+    return pOutlinerView->GetSelection() == GetSearchStartPosition();
 }
 
 bool SdOutliner::HandleFailedSearch()
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index fb715793531b..bf0544aec870 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -249,7 +249,7 @@ IMPL_LINK_NOARG(SmEditWindow, CursorMoveTimerHdl, Timer *, void)
 
     ESelection aNewSelection(GetSelection());
 
-    if (!aNewSelection.IsEqual(aOldSelection))
+    if (aNewSelection != aOldSelection)
     {
         SmViewShell *pView = rCmdBox.GetView();
         if (pView)
diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx b/svx/source/accessibility/AccessibleTextHelper.cxx
index f14d5bbd4c01..0bc3a55b39ee 100644
--- a/svx/source/accessibility/AccessibleTextHelper.cxx
+++ b/svx/source/accessibility/AccessibleTextHelper.cxx
@@ -506,7 +506,7 @@ namespace accessibility
             ESelection aSelection;
             if( GetEditViewForwarder().GetSelection( aSelection ) )
             {
-                if( !maLastSelection.IsEqual( aSelection ) &&
+                if( maLastSelection != aSelection &&
                     aSelection.nEndPara < maParaManager.GetNum() )
                 {
                     // #103998# Not that important, changed from assertion to trace
diff --git a/svx/source/svdraw/textchaincursor.cxx b/svx/source/svdraw/textchaincursor.cxx
index 0560ae087e08..d6d1f4de2894 100644
--- a/svx/source/svdraw/textchaincursor.cxx
+++ b/svx/source/svdraw/textchaincursor.cxx
@@ -84,7 +84,7 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
     sal_Int32 nLastParaLen = aLastParaText.getLength();
 
     ESelection aEndSel = ESelection(nLastPara, nLastParaLen);
-    bool bAtEndOfTextContent = aCurSel.IsEqual(aEndSel);
+    bool bAtEndOfTextContent = aCurSel == aEndSel;
 
     // Possibility: Are we "pushing" at the end of the object?
     if (nCode == KEY_RIGHT && bAtEndOfTextContent && pNextLink)
@@ -106,7 +106,7 @@ void TextChainCursorManager::impDetectEvent(const KeyEvent& rKEvt,
     }
 
     ESelection aStartSel = ESelection(0, 0);
-    bool bAtStartOfTextContent = aCurSel.IsEqual(aStartSel);
+    bool bAtStartOfTextContent = aCurSel == aStartSel;
 
     // Possibility: Are we "pushing" at the start of the object?
     if (nCode == KEY_LEFT && bAtStartOfTextContent && pPrevLink)
diff --git a/svx/source/svdraw/textchainflow.cxx b/svx/source/svdraw/textchainflow.cxx
index 559e6b9bd210..b87d2a7f02ed 100644
--- a/svx/source/svdraw/textchainflow.cxx
+++ b/svx/source/svdraw/textchainflow.cxx
@@ -294,7 +294,7 @@ void EditingTextChainFlow::impBroadcastCursorInfo() const
     ESelection aPreChainingSel = GetTextChain()->GetPreChainingSel(GetLinkTarget()) ;
 
     // Test whether the cursor is out of the box.
-    bool bCursorOut = mbPossiblyCursorOut && maOverflowPosSel.IsLess(aPreChainingSel);
+    bool bCursorOut = mbPossiblyCursorOut && maOverflowPosSel < aPreChainingSel;
 
     // NOTE: I handled already the stuff for the comments below. They will be kept temporarily till stuff settles down.
     // Possibility: 1) why don't we stop passing the actual event to the TextChain and instead we pass
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index 8e6a59ce34ff..7c8e2992f698 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -1589,7 +1589,7 @@ SvxTableController::TblAction SvxTableController::getKeyboardAction(const KeyEve
             // during text edit, check if we navigate out of the cell
             ESelection aOldSelection = pOLV->GetSelection();
             pOLV->PostKeyEvent(rKEvt);
-            bTextMove = pOLV && ( aOldSelection.IsEqual(pOLV->GetSelection()) );
+            bTextMove = pOLV && (aOldSelection == pOLV->GetSelection());
             if( !bTextMove )
             {
                 nAction = TblAction::NONE;
diff --git a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
index c468050c323d..2ebbe2be324d 100644
--- a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
+++ b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
@@ -553,7 +553,7 @@ void SwSpellDialogChildWindow::GetFocus()
                     {
                         OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
                         OSL_ENSURE(pOLV, "no OutlinerView in SwSpellDialogChildWindow::GetFocus()");
-                        if(!pOLV || !m_pSpellState->m_aESelection.IsEqual(pOLV->GetSelection()))
+                        if(!pOLV || m_pSpellState->m_aESelection != pOLV->GetSelection())
                             bInvalidate = true;
                     }
                 }
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 5d87ea7909f1..07c467b126fe 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -5671,7 +5671,7 @@ void SwEditWin::SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos )
                 ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
                 // make it a forward selection - otherwise the IsLess/IsGreater do not work :-(
                 aSelection.Adjust();
-                if(!aCompare.IsLess(aSelection)  && !aCompare.IsGreater(aSelection))
+                if(!(aCompare < aSelection) && !(aCompare > aSelection))
                 {
                     return;
                 }


More information about the Libreoffice-commits mailing list