diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-23 15:42:47 +0200 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-12-18 01:08:05 -0500 |
commit | 42fdf23f4d9be733f68196890ec7444ef1c3cf85 (patch) | |
tree | 076e4bcab2411a3e33f485333288728a698ce53c /sfx2 | |
parent | d2f7063d7e8c7631d804ea18ce5cc5d0aa310cb9 (diff) |
convert SFX_VISIBILITY constants to scoped enum
* split the position and the flags information
* remove unused DESKTOP constant
Change-Id: Ibfccb44c7567e89d4527bfd36b3915a73682e6e2
(cherry picked from commit 5af0071d42e5962ed849261134ef0630c7ec3b45)
(cherry picked from commit 82577130d5a1e40396053e86fd0d7beb14170fbd)
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/workwin.cxx | 61 | ||||
-rw-r--r-- | sfx2/source/control/dispatch.cxx | 35 | ||||
-rw-r--r-- | sfx2/source/control/objface.cxx | 51 | ||||
-rw-r--r-- | sfx2/source/inc/workwin.hxx | 26 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 4 |
5 files changed, 98 insertions, 79 deletions
diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx index 38e99da09612..9116675ed5ba 100644 --- a/sfx2/source/appl/workwin.cxx +++ b/sfx2/source/appl/workwin.cxx @@ -468,9 +468,9 @@ SfxWorkWindow::SfxWorkWindow( vcl::Window *pWin, SfxFrame *pFrm, SfxFrame* pMast pWorkWin (pWin), pConfigShell( nullptr ), pActiveChild( nullptr ), - nUpdateMode(SFX_VISIBILITY_STANDARD), + nUpdateMode(SfxVisibilityFlags::Standard), nChildren( 0 ), - nOrigMode( 0 ), + nOrigMode( SfxVisibilityFlags::Invisible ), bSorted( true ), bDockingAllowed(true), bInternalDockingAllowed(true), @@ -528,8 +528,8 @@ SfxWorkWindow::SfxWorkWindow( vcl::Window *pWin, SfxFrame *pFrm, SfxFrame* pMast pSplit[n] = pSplitWin; } - nOrigMode = SFX_VISIBILITY_STANDARD; - nUpdateMode = SFX_VISIBILITY_STANDARD; + nOrigMode = SfxVisibilityFlags::Standard; + nUpdateMode = SfxVisibilityFlags::Standard; } @@ -994,24 +994,22 @@ void SfxWorkWindow::ResetObjectBars_Impl() aChildWins[n]->nId = 0; } -void SfxWorkWindow::SetObjectBar_Impl(sal_uInt16 nPos, sal_uInt32 nResId, +void SfxWorkWindow::SetObjectBar_Impl(sal_uInt16 nPos, SfxVisibilityFlags nFlags, sal_uInt32 nResId, SfxInterface* pIFace) { - DBG_ASSERT( (nPos & SFX_POSITION_MASK) < SFX_OBJECTBAR_MAX, - "object bar position overflow" ); + DBG_ASSERT( nPos < SFX_OBJECTBAR_MAX, "object bar position overflow" ); - sal_uInt16 nRealPos = nPos & SFX_POSITION_MASK; - if ( pParent && IsAppWorkWinToolbox_Impl( nRealPos ) ) + if ( pParent && IsAppWorkWinToolbox_Impl( nPos ) ) { - pParent->SetObjectBar_Impl(nPos, nResId, pIFace); + pParent->SetObjectBar_Impl(nPos, nFlags, nResId, pIFace); return; } SfxObjectBar_Impl aObjBar; aObjBar.pIFace = pIFace; aObjBar.nId = sal::static_int_cast<sal_uInt16>(nResId); - aObjBar.nPos = nRealPos; - aObjBar.nMode = (nPos & SFX_VISIBILITY_MASK); + aObjBar.nPos = nPos; + aObjBar.nMode = nFlags; for (SfxObjectBar_Impl & rBar : aObjBarList) { @@ -1034,13 +1032,12 @@ bool SfxWorkWindow::KnowsObjectBar_Impl( sal_uInt16 nPos ) const */ { - sal_uInt16 nRealPos = nPos & SFX_POSITION_MASK; - if ( pParent && IsAppWorkWinToolbox_Impl( nRealPos ) ) + if ( pParent && IsAppWorkWinToolbox_Impl( nPos ) ) return pParent->KnowsObjectBar_Impl( nPos ); for (const SfxObjectBar_Impl& rBar : aObjBarList) { - if ( rBar.nPos == nRealPos ) + if ( rBar.nPos == nPos ) return true; } @@ -1048,20 +1045,20 @@ bool SfxWorkWindow::KnowsObjectBar_Impl( sal_uInt16 nPos ) const } -bool SfxWorkWindow::IsVisible_Impl( sal_uInt16 nMode ) const +bool SfxWorkWindow::IsVisible_Impl( SfxVisibilityFlags nMode ) const { switch( nUpdateMode ) { - case SFX_VISIBILITY_STANDARD: + case SfxVisibilityFlags::Standard: return true; - case SFX_VISIBILITY_UNVISIBLE: + case SfxVisibilityFlags::Invisible: return false; - case SFX_VISIBILITY_CLIENT: - case SFX_VISIBILITY_SERVER: + case SfxVisibilityFlags::Client: + case SfxVisibilityFlags::Server: return !!(nMode & nUpdateMode); default: return !!(nMode & nOrigMode ) || - nOrigMode == SFX_VISIBILITY_STANDARD; + nOrigMode == SfxVisibilityFlags::Standard; } } @@ -1204,14 +1201,13 @@ void SfxWorkWindow::UpdateObjectBars_Impl2() bool bDestroy = aObjBarList[n].bDestroy; // Determine the valid mode for the ToolBox - sal_uInt16 nTbxMode = aObjBarList[n].nMode; - bool bFullScreenTbx = SFX_VISIBILITY_FULLSCREEN == - ( nTbxMode & SFX_VISIBILITY_FULLSCREEN ); - nTbxMode &= ~SFX_VISIBILITY_FULLSCREEN; - nTbxMode &= ~SFX_VISIBILITY_VIEWER; + SfxVisibilityFlags nTbxMode = aObjBarList[n].nMode; + bool bFullScreenTbx( nTbxMode & SfxVisibilityFlags::FullScreen ); + nTbxMode &= ~SfxVisibilityFlags::FullScreen; + nTbxMode &= ~SfxVisibilityFlags::Viewer; // Is a ToolBox required in this context ? - bool bModesMatching = ( nUpdateMode && ( nTbxMode & nUpdateMode) == nUpdateMode ); + bool bModesMatching = (nUpdateMode != SfxVisibilityFlags::Invisible) && ((nTbxMode & nUpdateMode) == nUpdateMode); if ( bDestroy ) { OUString aTbxId( m_aTbxTypeName ); @@ -1484,9 +1480,9 @@ void SfxWorkWindow::UpdateStatusBar_Impl() void SfxWorkWindow::MakeVisible_Impl( bool bVis ) { if ( bVis ) - nOrigMode = SFX_VISIBILITY_STANDARD; + nOrigMode = SfxVisibilityFlags::Standard; else - nOrigMode = SFX_VISIBILITY_UNVISIBLE; + nOrigMode = SfxVisibilityFlags::Invisible; if ( nOrigMode != nUpdateMode) nUpdateMode = nOrigMode; @@ -1494,7 +1490,7 @@ void SfxWorkWindow::MakeVisible_Impl( bool bVis ) bool SfxWorkWindow::IsVisible_Impl() { - return nOrigMode != SFX_VISIBILITY_UNVISIBLE; + return nOrigMode != SfxVisibilityFlags::Invisible; } @@ -1760,7 +1756,7 @@ void SfxWorkWindow::ConfigChild_Impl(SfxChildIdentifier eChild, } -void SfxWorkWindow::SetChildWindowVisible_Impl( sal_uInt32 lId, bool bEnabled, sal_uInt16 nMode ) +void SfxWorkWindow::SetChildWindowVisible_Impl( sal_uInt32 lId, bool bEnabled, SfxVisibilityFlags nMode ) { sal_uInt16 nInter = (sal_uInt16) ( lId >> 16 ); sal_uInt16 nId = (sal_uInt16) ( lId & 0xFFFF ); @@ -1815,7 +1811,6 @@ void SfxWorkWindow::SetChildWindowVisible_Impl( sal_uInt32 lId, bool bEnabled, s pCW->nInterfaceId = nInter; pCW->nVisibility = nMode; pCW->bEnable = bEnabled; - pCW->nVisibility = nMode; } @@ -1983,7 +1978,7 @@ bool SfxWorkWindow::IsFloating( sal_uInt16 nId ) pCW = new SfxChildWin_Impl( nId ); pCW->bEnable = false; pCW->nId = 0; - pCW->nVisibility = 0; + pCW->nVisibility = SfxVisibilityFlags::Invisible; InitializeChild_Impl( pCW ); if ( pWork && !( pCW->aInfo.nFlags & SfxChildWindowFlags::TASK ) ) pWork->aChildWins.push_back( pCW ); diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 2aeccf26c471..93394c368512 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -95,11 +95,12 @@ struct SfxToDo_Impl struct SfxObjectBars_Impl { - sal_uInt32 nResId; // Resource - and ConfigId of the Toolbox - sal_uInt16 nMode; // special visibility flags - SfxInterface* pIFace; + sal_uInt32 nResId; // Resource - and ConfigId of the Toolbox + sal_uInt16 nPos; + SfxVisibilityFlags nFlags; // special visibility flags + SfxInterface* pIFace; - SfxObjectBars_Impl() : nResId(0), nMode(0), pIFace(nullptr) {} + SfxObjectBars_Impl() : nResId(0), nPos(0), nFlags(SfxVisibilityFlags::Invisible), pIFace(nullptr) {} }; struct SfxDispatcher_Impl @@ -1379,7 +1380,8 @@ void SfxDispatcher::Update_Impl_( bool bUIActive, bool bIsMDIApp, bool bIsIPOwne for ( nNo = 0; pIFace && nNo<pIFace->GetObjectBarCount(); ++nNo ) { sal_uInt16 nPos = pIFace->GetObjectBarPos(nNo); - if ( bReadOnlyShell && !( nPos & SFX_VISIBILITY_READONLYDOC ) ) + SfxVisibilityFlags nFlags = pIFace->GetObjectBarFlags(nNo); + if ( bReadOnlyShell && !( nFlags & SfxVisibilityFlags::ReadonlyDoc ) ) continue; // check whether toolbar needs activation of a special feature @@ -1390,7 +1392,7 @@ void SfxDispatcher::Update_Impl_( bool bUIActive, bool bIsMDIApp, bool bIsIPOwne // check for toolboxes that are exclusively for a viewer if ( xImp->pFrame) { - bool bViewerTbx = SFX_VISIBILITY_VIEWER == ( nPos & SFX_VISIBILITY_VIEWER ); + bool bViewerTbx( nFlags & SfxVisibilityFlags::Viewer ); SfxObjectShell* pSh = xImp->pFrame->GetObjectShell(); const SfxBoolItem* pItem = SfxItemSet::GetItem<SfxBoolItem>(pSh->GetMedium()->GetItemSet(), SID_VIEWONLY, false); bool bIsViewer = pItem && pItem->GetValue(); @@ -1401,16 +1403,17 @@ void SfxDispatcher::Update_Impl_( bool bUIActive, bool bIsMDIApp, bool bIsIPOwne // always register toolbars, allows to switch them on bool bVisible = pIFace->IsObjectBarVisible(nNo); if ( !bVisible ) - nPos &= SFX_POSITION_MASK; + nFlags = SfxVisibilityFlags::Invisible; - SfxObjectBars_Impl& rBar = xImp->aObjBars[nPos & SFX_POSITION_MASK]; - rBar.nMode = nPos; + SfxObjectBars_Impl& rBar = xImp->aObjBars[nPos]; + rBar.nPos = nPos; + rBar.nFlags = nFlags; rBar.nResId = pIFace->GetObjectBarId(nNo); rBar.pIFace = pIFace; if ( bUIActive || bIsActive ) { - pWorkWin->SetObjectBar_Impl(nPos, rBar.nResId, rBar.pIFace); + pWorkWin->SetObjectBar_Impl(nPos, nFlags, rBar.nResId, rBar.pIFace); } if ( !bVisible ) @@ -1434,18 +1437,18 @@ void SfxDispatcher::Update_Impl_( bool bUIActive, bool bIsMDIApp, bool bIsIPOwne continue; // slot decides whether a ChildWindow is shown when document is OLE server or OLE client - sal_uInt16 nMode = SFX_VISIBILITY_STANDARD; + SfxVisibilityFlags nMode = SfxVisibilityFlags::Standard; if( pSlot ) { if ( pSlot->IsMode(SfxSlotMode::CONTAINER) ) { - if ( pWorkWin->IsVisible_Impl( SFX_VISIBILITY_CLIENT ) ) - nMode |= SFX_VISIBILITY_CLIENT; + if ( pWorkWin->IsVisible_Impl( SfxVisibilityFlags::Client ) ) + nMode |= SfxVisibilityFlags::Client; } else { - if ( pWorkWin->IsVisible_Impl( SFX_VISIBILITY_SERVER ) ) - nMode |= SFX_VISIBILITY_SERVER; + if ( pWorkWin->IsVisible_Impl( SfxVisibilityFlags::Server ) ) + nMode |= SfxVisibilityFlags::Server; } } @@ -1473,7 +1476,7 @@ void SfxDispatcher::Update_Impl_( bool bUIActive, bool bIsMDIApp, bool bIsIPOwne { SfxObjectBars_Impl& rBar = xImp->aObjBars[nPos]; rBar = rFixed; - pWorkWin->SetObjectBar_Impl(rFixed.nMode, + pWorkWin->SetObjectBar_Impl(rFixed.nPos, rFixed.nFlags, rFixed.nResId, rFixed.pIFace); } } diff --git a/sfx2/source/control/objface.cxx b/sfx2/source/control/objface.cxx index 495374b16065..68d229dbd470 100644 --- a/sfx2/source/control/objface.cxx +++ b/sfx2/source/control/objface.cxx @@ -53,13 +53,15 @@ SfxCompareSlots_bsearch( const void* pSmaller, const void* pBigger ) struct SfxObjectUI_Impl { - sal_uInt16 nPos; - sal_uInt32 nResId; - bool bContext; - SfxShellFeature nFeature; + sal_uInt16 nPos; + SfxVisibilityFlags nFlags; + sal_uInt32 nResId; + bool bContext; + SfxShellFeature nFeature; - SfxObjectUI_Impl(sal_uInt16 n, sal_uInt32 nId, SfxShellFeature nFeat) : + SfxObjectUI_Impl(sal_uInt16 n, SfxVisibilityFlags f, sal_uInt32 nId, SfxShellFeature nFeat) : nPos(n), + nFlags(f), nResId(nId), bContext(false), nFeature(nFeat) @@ -95,7 +97,7 @@ struct SfxInterface_Impl } }; -static SfxObjectUI_Impl* CreateObjectBarUI_Impl(sal_uInt16 nPos, sal_uInt32 nResId, SfxShellFeature nFeature); +static SfxObjectUI_Impl* CreateObjectBarUI_Impl(sal_uInt16 nPos, SfxVisibilityFlags nFlags, sal_uInt32 nResId, SfxShellFeature nFeature); // constuctor, registeres a new unit SfxInterface::SfxInterface( const char *pClassName, @@ -360,24 +362,24 @@ void SfxInterface::RegisterPopupMenu( const OUString& rResourceName ) pImplData->aPopupName = rResourceName; } -void SfxInterface::RegisterObjectBar(sal_uInt16 nPos, sal_uInt32 nResId) +void SfxInterface::RegisterObjectBar(sal_uInt16 nPos, SfxVisibilityFlags nFlags, sal_uInt32 nResId) { - RegisterObjectBar(nPos, nResId, SfxShellFeature::NONE); + RegisterObjectBar(nPos, nFlags, nResId, SfxShellFeature::NONE); } -void SfxInterface::RegisterObjectBar(sal_uInt16 nPos, sal_uInt32 nResId, SfxShellFeature nFeature) +void SfxInterface::RegisterObjectBar(sal_uInt16 nPos, SfxVisibilityFlags nFlags, sal_uInt32 nResId, SfxShellFeature nFeature) { - SfxObjectUI_Impl* pUI = CreateObjectBarUI_Impl(nPos, nResId, nFeature); + SfxObjectUI_Impl* pUI = CreateObjectBarUI_Impl(nPos, nFlags, nResId, nFeature); if ( pUI ) pImplData->aObjectBars.push_back(pUI); } -SfxObjectUI_Impl* CreateObjectBarUI_Impl(sal_uInt16 nPos, sal_uInt32 nResId, SfxShellFeature nFeature) +SfxObjectUI_Impl* CreateObjectBarUI_Impl(sal_uInt16 nPos, SfxVisibilityFlags nFlags, sal_uInt32 nResId, SfxShellFeature nFeature) { - if ((nPos & SFX_VISIBILITY_MASK) == 0) - nPos |= SFX_VISIBILITY_STANDARD; + if (nFlags == SfxVisibilityFlags::Invisible) + nFlags |= SfxVisibilityFlags::Standard; - return new SfxObjectUI_Impl(nPos, nResId, nFeature); + return new SfxObjectUI_Impl(nPos, nFlags, nResId, nFeature); } sal_uInt32 SfxInterface::GetObjectBarId(sal_uInt16 nNo) const @@ -418,6 +420,25 @@ sal_uInt16 SfxInterface::GetObjectBarPos( sal_uInt16 nNo ) const return pImplData->aObjectBars[nNo]->nPos; } +SfxVisibilityFlags SfxInterface::GetObjectBarFlags( sal_uInt16 nNo ) const +{ + bool bGenoType = (pGenoType != nullptr && pGenoType->UseAsSuperClass()); + if ( bGenoType ) + { + // Are there toolbars in the super class? + sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount(); + if ( nNo < nBaseCount ) + // The Super class comes first + return pGenoType->GetObjectBarFlags( nNo ); + else + nNo = nNo - nBaseCount; + } + + assert( nNo<pImplData->aObjectBars.size() ); + + return pImplData->aObjectBars[nNo]->nFlags; +} + sal_uInt16 SfxInterface::GetObjectBarCount() const { if (pGenoType && pGenoType->UseAsSuperClass()) @@ -433,7 +454,7 @@ void SfxInterface::RegisterChildWindow(sal_uInt16 nId, bool bContext) void SfxInterface::RegisterChildWindow(sal_uInt16 nId, bool bContext, SfxShellFeature nFeature) { - SfxObjectUI_Impl* pUI = new SfxObjectUI_Impl(0, nId, nFeature); + SfxObjectUI_Impl* pUI = new SfxObjectUI_Impl(0, SfxVisibilityFlags::Invisible, nId, nFeature); pUI->bContext = bContext; pImplData->aChildWindows.push_back(pUI); } diff --git a/sfx2/source/inc/workwin.hxx b/sfx2/source/inc/workwin.hxx index bf2cabb62ed1..a612b82baef3 100644 --- a/sfx2/source/inc/workwin.hxx +++ b/sfx2/source/inc/workwin.hxx @@ -46,15 +46,15 @@ class SfxWorkWindow; // This struct makes all relevant Information available of Toolboxes struct SfxObjectBar_Impl { - sal_uInt16 nId; // Resource - and ConfigId of Toolbox - sal_uInt16 nMode; // special visibility flags - sal_uInt16 nPos; - bool bDestroy; - SfxInterface* pIFace; + sal_uInt16 nId; // Resource - and ConfigId of Toolbox + SfxVisibilityFlags nMode; // special visibility flags + sal_uInt16 nPos; + bool bDestroy; + SfxInterface* pIFace; SfxObjectBar_Impl() : nId(0), - nMode(0), + nMode(SfxVisibilityFlags::Invisible), nPos(0), bDestroy(false), pIFace(nullptr) @@ -116,7 +116,7 @@ struct SfxChildWin_Impl bool bCreate; SfxChildWinInfo aInfo; SfxChild_Impl* pCli; // != 0 at direct Children - sal_uInt16 nVisibility; + SfxVisibilityFlags nVisibility; bool bEnable; SfxChildWin_Impl( sal_uInt32 nID ) : @@ -126,7 +126,7 @@ struct SfxChildWin_Impl pWin(nullptr), bCreate(false), pCli(nullptr), - nVisibility( SFX_VISIBILITY_UNVISIBLE ), + nVisibility( SfxVisibilityFlags::Invisible ), bEnable( true ) {} }; @@ -206,9 +206,9 @@ class SfxWorkWindow final VclPtr<vcl::Window> pWorkWin; SfxShell* pConfigShell; VclPtr<vcl::Window> pActiveChild; - sal_uInt16 nUpdateMode; + SfxVisibilityFlags nUpdateMode; sal_uInt16 nChildren; - sal_uInt16 nOrigMode; + SfxVisibilityFlags nOrigMode; bool bSorted : 1; bool bDockingAllowed : 1; bool bInternalDockingAllowed : 1; @@ -275,7 +275,7 @@ public: void UpdateObjectBars_Impl(); void UpdateObjectBars_Impl2(); void ResetObjectBars_Impl(); - void SetObjectBar_Impl(sal_uInt16 nPos, sal_uInt32 nResId, + void SetObjectBar_Impl(sal_uInt16 nPos, SfxVisibilityFlags nFlags, sal_uInt32 nResId, SfxInterface *pIFace); bool KnowsObjectBar_Impl( sal_uInt16 nPos ) const; bool IsVisible_Impl(); @@ -285,7 +285,7 @@ public: // Methods for ChildWindows void UpdateChildWindows_Impl(); void ResetChildWindows_Impl(); - void SetChildWindowVisible_Impl( sal_uInt32, bool, sal_uInt16 ); + void SetChildWindowVisible_Impl( sal_uInt32, bool, SfxVisibilityFlags ); void ToggleChildWindow_Impl(sal_uInt16,bool); bool HasChildWindow_Impl(sal_uInt16); bool KnowsChildWindow_Impl(sal_uInt16); @@ -295,7 +295,7 @@ public: void InitializeChild_Impl(SfxChildWin_Impl*); SfxSplitWindow* GetSplitWindow_Impl(SfxChildAlignment); - bool IsVisible_Impl( sal_uInt16 nMode ) const; + bool IsVisible_Impl( SfxVisibilityFlags nMode ) const; bool IsFloating( sal_uInt16 nId ); void SetActiveChild_Impl( vcl::Window *pChild ); const VclPtr<vcl::Window>& GetActiveChild_Impl() const { return pActiveChild; } diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index c791be4dff0c..cbe1947b37f8 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -149,8 +149,8 @@ void SfxViewFrame::InitInterface_Impl() GetStaticInterface()->RegisterChildWindow(SID_BROWSER); GetStaticInterface()->RegisterChildWindow(SID_RECORDING_FLOATWINDOW); #if HAVE_FEATURE_DESKTOP - GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_FULLSCREEN | SFX_VISIBILITY_FULLSCREEN, RID_FULLSCREENTOOLBOX); - GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION | SFX_VISIBILITY_STANDARD, RID_ENVTOOLBOX ); + GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_FULLSCREEN, SfxVisibilityFlags::FullScreen, RID_FULLSCREENTOOLBOX); + GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION, SfxVisibilityFlags::Standard, RID_ENVTOOLBOX ); #endif } |