From 8353793c94416a9a3a5af074d881624e43e5ec2f Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sat, 15 Aug 2015 15:14:47 +0200 Subject: [PATCH] Use constants instead of (possibly wrong) magic numbers Change-Id: I0829d271337b9fe77341c62a1c2ef4d6ae62c727 --- basctl/source/basicide/baside2.cxx | 4 ++-- include/vcl/textdata.hxx | 3 ++- sw/source/uibase/uiview/srcview.cxx | 4 ++-- vcl/source/edit/texteng.cxx | 2 +- vcl/source/edit/vclmedit.cxx | 8 ++++---- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 339f2d65733a..aa68f51908eb 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -901,7 +901,7 @@ void ModulWindow::ExecuteCommand (SfxRequest& rReq) } case SID_SELECTALL: { - TextSelection aSel( TextPaM( 0, 0 ), TextPaM( TEXT_PARA_ALL, 0xFFFF ) ); + TextSelection aSel( TextPaM( 0, 0 ), TextPaM( TEXT_PARA_ALL, TEXT_INDEX_ALL ) ); TextView * pView = GetEditView(); pView->SetSelection( aSel ); pView->GetWindow()->GrabFocus(); @@ -1245,7 +1245,7 @@ sal_uInt16 ModulWindow::StartSearchAndReplace( const SvxSearchItem& rSearchItem, if ( !rSearchItem.GetBackward() ) pView->SetSelection( TextSelection() ); else - pView->SetSelection( TextSelection( TextPaM( 0xFFFFFFFF, 0xFFFF ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) ); + pView->SetSelection( TextSelection( TextPaM( TEXT_PARA_ALL, TEXT_INDEX_ALL ), TextPaM( TEXT_PARA_ALL, TEXT_INDEX_ALL ) ) ); } bool const bForward = !rSearchItem.GetBackward(); diff --git a/include/vcl/textdata.hxx b/include/vcl/textdata.hxx index d206da947c66..b982b1ecf74e 100644 --- a/include/vcl/textdata.hxx +++ b/include/vcl/textdata.hxx @@ -25,7 +25,8 @@ #include // for Notify, if all paragraphs were deleted -#define TEXT_PARA_ALL 0xFFFFFFFF +#define TEXT_PARA_ALL SAL_MAX_UINT32 +#define TEXT_INDEX_ALL SAL_MAX_INT32 class TextPaM { diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx index 72b4de7b4f59..61553bff3291 100644 --- a/sw/source/uibase/uiview/srcview.cxx +++ b/sw/source/uibase/uiview/srcview.cxx @@ -414,7 +414,7 @@ void SwSrcView::Execute(SfxRequest& rReq) pTextView->Paste(); break; case SID_SELECTALL: - pTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) ); + pTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( TEXT_PARA_ALL, TEXT_INDEX_ALL ) ) ); break; } aEditWin->Invalidate(); @@ -580,7 +580,7 @@ sal_uInt16 SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem, bool bAtStart = pTextView->GetSelection() == TextSelection( aPaM, aPaM ); if( !bForward ) - aPaM = TextPaM( TEXT_PARA_ALL, USHRT_MAX ); + aPaM = TextPaM( TEXT_PARA_ALL, TEXT_INDEX_ALL ); if( bFromStart ) { diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index ef5455cd2983..e1df6d898274 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -2707,7 +2707,7 @@ void TextEngine::ValidatePaM( TextPaM& rPaM ) const if ( rPaM.GetPara() >= nParas ) { rPaM.GetPara() = nParas ? nParas-1 : 0; - rPaM.GetIndex() = 0xFFFF; + rPaM.GetIndex() = TEXT_INDEX_ALL; } const sal_Int32 nMaxIndex = GetTextLen( rPaM.GetPara() ); diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx index 6e18ae4883e1..5a73070ad201 100644 --- a/vcl/source/edit/vclmedit.cxx +++ b/vcl/source/edit/vclmedit.cxx @@ -773,7 +773,7 @@ void TextWindow::KeyInput( const KeyEvent& rKEvent ) ( (nCode == KEY_A) && rKEvent.GetKeyCode().IsMod1() && !rKEvent.GetKeyCode().IsMod2() ) ) { - mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFF, 0xFFFF ) ) ); + mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( TEXT_PARA_ALL, TEXT_INDEX_ALL ) ) ); bDone = true; } else if ( (nCode == KEY_S) && rKEvent.GetKeyCode().IsShift() && rKEvent.GetKeyCode().IsMod1() ) @@ -879,7 +879,7 @@ void TextWindow::Command( const CommandEvent& rCEvt ) mpExtTextEngine->SetModified( true ); mpExtTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); break; - case SV_MENU_EDIT_SELECTALL: mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) ); + case SV_MENU_EDIT_SELECTALL: mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( TEXT_PARA_ALL, TEXT_INDEX_ALL ) ) ); break; case SV_MENU_EDIT_INSERTSYMBOL: { @@ -915,7 +915,7 @@ void TextWindow::GetFocus() // select everything, but do not scroll bool bAutoScroll = mpExtTextView->IsAutoScroll(); mpExtTextView->SetAutoScroll( false ); - mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFF, 0xFFFF ) ) ); + mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( TEXT_PARA_ALL, TEXT_INDEX_ALL ) ) ); mpExtTextView->SetAutoScroll( bAutoScroll ); bGotoCursor = false; } @@ -1516,7 +1516,7 @@ bool VclMultiLineEdit::PreNotify( NotifyEvent& rNEvt ) { if ( rKEvent.GetKeyCode().IsMod1() ) pImpVclMEdit->GetTextWindow()->GetTextView()-> - SetSelection( TextSelection( TextPaM( 0xFFFF, 0xFFFF ) ) ); + SetSelection( TextSelection( TextPaM( TEXT_PARA_ALL, TEXT_INDEX_ALL ) ) ); } break; default: