convert NAV_STATE to scoped enum

Change-Id: I855a320884c42807fadf9ce42adc0ece8c65ce1c
Reviewed-on: https://gerrit.libreoffice.org/25067
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Noel Grandin 2016-05-17 16:37:11 +02:00 committed by Noel Grandin
parent 397f567ebc
commit 45ec74a080
3 changed files with 33 additions and 31 deletions

View File

@ -843,45 +843,45 @@ void SdNavigatorControllerItem::StateChanged( sal_uInt16 nSId,
if( eState >= SfxItemState::DEFAULT && nSId == SID_NAVIGATOR_STATE )
{
const SfxUInt32Item& rStateItem = dynamic_cast<const SfxUInt32Item&>(*pItem);
sal_uInt32 nState = rStateItem.GetValue();
NavState nState = (NavState)rStateItem.GetValue();
// only if doc in LB is the active
NavDocInfo* pInfo = pNavigatorWin->GetDocInfo();
if( pInfo && pInfo->IsActive() )
{
// First
if( nState & NAVBTN_FIRST_ENABLED &&
if( nState & NavState::BtnFirstEnabled &&
!pNavigatorWin->maToolbox->IsItemEnabled( TBI_FIRST ) )
pNavigatorWin->maToolbox->EnableItem( TBI_FIRST );
if( nState & NAVBTN_FIRST_DISABLED &&
if( nState & NavState::BtnFirstDisabled &&
pNavigatorWin->maToolbox->IsItemEnabled( TBI_FIRST ) )
pNavigatorWin->maToolbox->EnableItem( TBI_FIRST, false );
// Prev
if( nState & NAVBTN_PREV_ENABLED &&
if( nState & NavState::BtnPrevEnabled &&
!pNavigatorWin->maToolbox->IsItemEnabled( TBI_PREVIOUS ) )
pNavigatorWin->maToolbox->EnableItem( TBI_PREVIOUS );
if( nState & NAVBTN_PREV_DISABLED &&
if( nState & NavState::BtnPrevDisabled &&
pNavigatorWin->maToolbox->IsItemEnabled( TBI_PREVIOUS ) )
pNavigatorWin->maToolbox->EnableItem( TBI_PREVIOUS, false );
// Last
if( nState & NAVBTN_LAST_ENABLED &&
if( nState & NavState::BtnLastEnabled &&
!pNavigatorWin->maToolbox->IsItemEnabled( TBI_LAST ) )
pNavigatorWin->maToolbox->EnableItem( TBI_LAST );
if( nState & NAVBTN_LAST_DISABLED &&
if( nState & NavState::BtnLastDisabled &&
pNavigatorWin->maToolbox->IsItemEnabled( TBI_LAST ) )
pNavigatorWin->maToolbox->EnableItem( TBI_LAST, false );
// Next
if( nState & NAVBTN_NEXT_ENABLED &&
if( nState & NavState::BtnNextEnabled &&
!pNavigatorWin->maToolbox->IsItemEnabled( TBI_NEXT ) )
pNavigatorWin->maToolbox->EnableItem( TBI_NEXT );
if( nState & NAVBTN_NEXT_DISABLED &&
if( nState & NavState::BtnNextDisabled &&
pNavigatorWin->maToolbox->IsItemEnabled( TBI_NEXT ) )
pNavigatorWin->maToolbox->EnableItem( TBI_NEXT, false );
if( nState & NAVTLB_UPDATE )
if( nState & NavState::TableUpdate )
{
// InitTlb; is initiated by Slot
if (maUpdateRequest)

View File

@ -27,20 +27,6 @@
#include "sdtreelb.hxx"
#include "pres.hxx"
#define NAVSTATE_NONE 0x00000000
#define NAVTLB_UPDATE 0x00000100
#define NAVBTN_FIRST_ENABLED 0x00001000
#define NAVBTN_FIRST_DISABLED 0x00002000
#define NAVBTN_PREV_ENABLED 0x00004000
#define NAVBTN_PREV_DISABLED 0x00008000
#define NAVBTN_LAST_ENABLED 0x00010000
#define NAVBTN_LAST_DISABLED 0x00020000
#define NAVBTN_NEXT_ENABLED 0x00040000
#define NAVBTN_NEXT_DISABLED 0x00080000
// forward
namespace sd {
class DrawDocShell;
@ -50,6 +36,22 @@ class Menu;
class SdNavigatorControllerItem;
class SdPageNameControllerItem;
enum class NavState {
NONE = 0x000000,
TableUpdate = 0x000100,
BtnFirstEnabled = 0x001000,
BtnFirstDisabled = 0x002000,
BtnPrevEnabled = 0x004000,
BtnPrevDisabled = 0x008000,
BtnLastEnabled = 0x010000,
BtnLastDisabled = 0x020000,
BtnNextEnabled = 0x040000,
BtnNextDisabled = 0x080000,
};
namespace o3tl {
template<> struct typed_flags<NavState> : is_typed_flags<NavState, 0x0ff100> {};
}
class NavDocInfo
{
public:

View File

@ -152,13 +152,13 @@ void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
{
sal_uInt32 nState = NAVSTATE_NONE;
NavState nState = NavState::NONE;
sal_uInt16 nCurrentPage = 0;
sal_uInt16 nFirstPage = 0;
sal_uInt16 nLastPage;
OUString aPageName;
nState |= NAVTLB_UPDATE;
nState |= NavState::TableUpdate;
if (mpActualPage != nullptr)
{
@ -171,24 +171,24 @@ void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
// first page / previous page
if( nCurrentPage == nFirstPage )
{
nState |= NAVBTN_FIRST_DISABLED | NAVBTN_PREV_DISABLED;
nState |= NavState::BtnFirstDisabled | NavState::BtnPrevDisabled;
}
else
{
nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
nState |= NavState::BtnFirstEnabled | NavState::BtnPrevEnabled;
}
// last page / next page
if( nCurrentPage == nLastPage )
{
nState |= NAVBTN_LAST_DISABLED | NAVBTN_NEXT_DISABLED;
nState |= NavState::BtnLastDisabled | NavState::BtnNextDisabled;
}
else
{
nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
nState |= NavState::BtnLastEnabled | NavState::BtnNextEnabled;
}
rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, (sal_uInt32)nState ) );
rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
}