convert IsEqual/etc methods on ESelection to operators
Change-Id: Ia8424e701b6f22d0536ee7f3bdb0ecaaed94a3b9 Reviewed-on: https://gerrit.libreoffice.org/42904 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
ce301dadcb
commit
8a8864aeb7
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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() );
|
||||
|
@ -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 )
|
||||
|
@ -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 );
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user