Kaydet (Commit) 8fbbd1bd authored tarafından Noel Grandin's avatar Noel Grandin

fix hacked bool in SfxDispatcher::SetSlotFilter

The bEnable flag was being passed an extra value.
Make this explicit now using an enum.

Change-Id: I292aca44e8592c9f3c1497c24c41140c8c3b5452
üst 3edb4611
...@@ -61,6 +61,14 @@ namespace com ...@@ -61,6 +61,14 @@ namespace com
#define SFX_SHELL_PUSH 1 #define SFX_SHELL_PUSH 1
enum SfxSlotFilterState
{
SFX_SLOT_FILTER_DISABLED,
SFX_SLOT_FILTER_ENABLED,
// enabled even if ReadOnlyDoc
SFX_SLOT_FILTER_ENABLED_READONLY,
};
class SFX2_DLLPUBLIC SfxDispatcher class SFX2_DLLPUBLIC SfxDispatcher
{ {
...@@ -158,8 +166,7 @@ public: ...@@ -158,8 +166,7 @@ public:
void Flush(); void Flush();
void Lock( bool bLock ); void Lock( bool bLock );
bool IsLocked( sal_uInt16 nSID = 0 ) const; bool IsLocked( sal_uInt16 nSID = 0 ) const;
// bEnable can be sal_True,sal_False, or 2(some kind of read-only override hack) void SetSlotFilter( SfxSlotFilterState nEnable = SFX_SLOT_FILTER_DISABLED,
void SetSlotFilter( sal_Bool bEnable = sal_False,
sal_uInt16 nCount = 0, const sal_uInt16 *pSIDs = 0 ); sal_uInt16 nCount = 0, const sal_uInt16 *pSIDs = 0 );
void HideUI( bool bHide = true ); void HideUI( bool bHide = true );
...@@ -180,8 +187,7 @@ public: ...@@ -180,8 +187,7 @@ public:
bool bOwnShellsOnly, bool bModal, bool bRealSlot=true ); bool bOwnShellsOnly, bool bModal, bool bRealSlot=true );
SAL_DLLPRIVATE void SetReadOnly_Impl( bool bOn ); SAL_DLLPRIVATE void SetReadOnly_Impl( bool bOn );
SAL_DLLPRIVATE bool GetReadOnly_Impl() const; SAL_DLLPRIVATE bool GetReadOnly_Impl() const;
// bEnable can be sal_True,sal_False, or 2(some kind of read-only override hack) SAL_DLLPRIVATE SfxSlotFilterState IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const;
SAL_DLLPRIVATE sal_Bool IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const;
SAL_DLLPRIVATE void SetQuietMode_Impl( bool bOn ); SAL_DLLPRIVATE void SetQuietMode_Impl( bool bOn );
SAL_DLLPRIVATE bool IsReadOnlyShell_Impl( sal_uInt16 nShell ) const; SAL_DLLPRIVATE bool IsReadOnlyShell_Impl( sal_uInt16 nShell ) const;
SAL_DLLPRIVATE void RemoveShell_Impl( SfxShell& rShell ); SAL_DLLPRIVATE void RemoveShell_Impl( SfxShell& rShell );
......
...@@ -393,7 +393,7 @@ void DrawDocShell::ApplySlotFilter() const ...@@ -393,7 +393,7 @@ void DrawDocShell::ApplySlotFilter() const
SfxDispatcher* pDispatcher = pTestViewShell->GetViewFrame()->GetDispatcher(); SfxDispatcher* pDispatcher = pTestViewShell->GetViewFrame()->GetDispatcher();
if( mpFilterSIDs ) if( mpFilterSIDs )
pDispatcher->SetSlotFilter( mbFilterEnable, mnFilterCount, mpFilterSIDs ); pDispatcher->SetSlotFilter( mbFilterEnable ? SFX_SLOT_FILTER_ENABLED : SFX_SLOT_FILTER_DISABLED, mnFilterCount, mpFilterSIDs );
else else
pDispatcher->SetSlotFilter(); pDispatcher->SetSlotFilter();
......
...@@ -2744,7 +2744,7 @@ void SAL_CALL SlideshowImpl::activate() throw (RuntimeException, std::exception) ...@@ -2744,7 +2744,7 @@ void SAL_CALL SlideshowImpl::activate() throw (RuntimeException, std::exception)
if( pDispatcher ) if( pDispatcher )
{ {
// filter all forbiden slots // filter all forbiden slots
pDispatcher->SetSlotFilter( true, sizeof(pAllowed) / sizeof(sal_uInt16), pAllowed ); pDispatcher->SetSlotFilter( SFX_SLOT_FILTER_ENABLED, sizeof(pAllowed) / sizeof(sal_uInt16), pAllowed );
} }
if( getBindings() ) if( getBindings() )
......
...@@ -133,8 +133,8 @@ struct SfxDispatcher_Impl ...@@ -133,8 +133,8 @@ struct SfxDispatcher_Impl
bool bQuiet; // Only use parent dispatcher bool bQuiet; // Only use parent dispatcher
bool bModal; // Only slots from parent dispatcher bool bModal; // Only slots from parent dispatcher
sal_Bool bFilterEnabling; // sal_True=filter enabled slots, SfxSlotFilterState nFilterEnabling; // 1==filter enabled slots,
// 2==ReadOnlyDoc overturned // 2==ReadOnlyDoc overturned
sal_uInt16 nFilterCount; // Number of SIDs in pFilterSIDs sal_uInt16 nFilterCount; // Number of SIDs in pFilterSIDs
const sal_uInt16* pFilterSIDs; // sorted Array of SIDs const sal_uInt16* pFilterSIDs; // sorted Array of SIDs
sal_uInt32 nDisableFlags; sal_uInt32 nDisableFlags;
...@@ -347,7 +347,7 @@ void SfxDispatcher::Construct_Impl( SfxDispatcher* pParent ) ...@@ -347,7 +347,7 @@ void SfxDispatcher::Construct_Impl( SfxDispatcher* pParent )
pImp->bQuiet = false; pImp->bQuiet = false;
pImp->bModal = false; pImp->bModal = false;
pImp->pInCallAliveFlag = 0; pImp->pInCallAliveFlag = 0;
pImp->bFilterEnabling = sal_False; pImp->nFilterEnabling = SFX_SLOT_FILTER_DISABLED;
pImp->nFilterCount = 0; pImp->nFilterCount = 0;
pImp->pFilterSIDs = 0; pImp->pFilterSIDs = 0;
pImp->nDisableFlags = 0; pImp->nDisableFlags = 0;
...@@ -1730,11 +1730,11 @@ void SfxDispatcher::FlushImpl() ...@@ -1730,11 +1730,11 @@ void SfxDispatcher::FlushImpl()
void SfxDispatcher::SetSlotFilter void SfxDispatcher::SetSlotFilter
( (
// HACK(hier muss mal ein enum rein) ??? // HACK(hier muss mal ein enum rein) ???
sal_Bool bEnable, /* sal_True: SfxSlotFilterState nEnable, /* 1==true:
only enable specified slots, only enable specified slots,
disable all other disable all other
sal_False: 0==false:
disable specified slots, disable specified slots,
first enable all other first enable all other
*/ */
...@@ -1780,7 +1780,7 @@ void SfxDispatcher::SetSlotFilter ...@@ -1780,7 +1780,7 @@ void SfxDispatcher::SetSlotFilter
if ( pImp->pFilterSIDs ) if ( pImp->pFilterSIDs )
pImp->pFilterSIDs = 0; pImp->pFilterSIDs = 0;
pImp->bFilterEnabling = bEnable; pImp->nFilterEnabling = nEnable;
pImp->nFilterCount = nCount; pImp->nFilterCount = nCount;
pImp->pFilterSIDs = pSIDs; pImp->pFilterSIDs = pSIDs;
...@@ -1801,7 +1801,7 @@ SfxCompareSIDs_Impl( const void* pSmaller, const void* pBigger ) ...@@ -1801,7 +1801,7 @@ SfxCompareSIDs_Impl( const void* pSmaller, const void* pBigger )
} }
sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const SfxSlotFilterState SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const
/* [Description] /* [Description]
...@@ -1810,7 +1810,7 @@ sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const ...@@ -1810,7 +1810,7 @@ sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const
disabled by the Filter. disabled by the Filter.
[Return value] [Return value]
sal_Bool 0 => disabled int 0 => disabled
1 => enabled 1 => enabled
2 => enabled even if ReadOnlyDoc 2 => enabled even if ReadOnlyDoc
*/ */
...@@ -1819,17 +1819,20 @@ sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const ...@@ -1819,17 +1819,20 @@ sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const
// no filter? // no filter?
if ( 0 == pImp->nFilterCount ) if ( 0 == pImp->nFilterCount )
// => all SIDs allowed // => all SIDs allowed
return sal_True; return SFX_SLOT_FILTER_ENABLED;
// search // search
bool bFound = 0 != bsearch( &nSID, pImp->pFilterSIDs, pImp->nFilterCount, bool bFound = 0 != bsearch( &nSID, pImp->pFilterSIDs, pImp->nFilterCount,
sizeof(sal_uInt16), SfxCompareSIDs_Impl ); sizeof(sal_uInt16), SfxCompareSIDs_Impl );
// even if ReadOnlyDoc // even if ReadOnlyDoc
if ( 2 == pImp->bFilterEnabling ) if ( SFX_SLOT_FILTER_ENABLED_READONLY == pImp->nFilterEnabling )
return bFound ? 2 : 1; return bFound ? SFX_SLOT_FILTER_ENABLED_READONLY : SFX_SLOT_FILTER_ENABLED;
// Otherwise after Negative/Positive Filter // Otherwise after Negative/Positive Filter
return pImp->bFilterEnabling ? bFound : !bFound; else if ( SFX_SLOT_FILTER_ENABLED == pImp->nFilterEnabling )
return bFound ? SFX_SLOT_FILTER_ENABLED : SFX_SLOT_FILTER_DISABLED;
else
return bFound ? SFX_SLOT_FILTER_DISABLED : SFX_SLOT_FILTER_ENABLED;
} }
...@@ -1955,11 +1958,11 @@ bool SfxDispatcher::_FindServer ...@@ -1955,11 +1958,11 @@ bool SfxDispatcher::_FindServer
} }
// SID check against set filter // SID check against set filter
sal_uInt16 nSlotEnableMode=0; SfxSlotFilterState nSlotEnableMode = SFX_SLOT_FILTER_DISABLED;
if ( pImp->pFrame ) if ( pImp->pFrame )
{ {
nSlotEnableMode = IsSlotEnabledByFilter_Impl( nSlot ); nSlotEnableMode = IsSlotEnabledByFilter_Impl( nSlot );
if ( 0 == nSlotEnableMode ) if ( SFX_SLOT_FILTER_DISABLED == nSlotEnableMode )
return false; return false;
} }
...@@ -1977,7 +1980,7 @@ bool SfxDispatcher::_FindServer ...@@ -1977,7 +1980,7 @@ bool SfxDispatcher::_FindServer
return false; return false;
} }
bool bReadOnly = ( 2 != nSlotEnableMode && pImp->bReadOnly ); bool bReadOnly = ( SFX_SLOT_FILTER_ENABLED_READONLY != nSlotEnableMode && pImp->bReadOnly );
// search through all the shells of the chained dispatchers // search through all the shells of the chained dispatchers
// from top to bottom // from top to bottom
......
...@@ -597,7 +597,7 @@ void SwView::_CheckReadonlyState() ...@@ -597,7 +597,7 @@ void SwView::_CheckReadonlyState()
} }
if ( SFX_ITEM_DISABLED == eStateRO ) if ( SFX_ITEM_DISABLED == eStateRO )
{ {
rDis.SetSlotFilter( sal_Bool(2), sizeof(aROIds)/sizeof(sal_uInt16), aROIds ); rDis.SetSlotFilter( SFX_SLOT_FILTER_ENABLED_READONLY, sizeof(aROIds)/sizeof(sal_uInt16), aROIds );
bChgd = sal_True; bChgd = sal_True;
} }
} }
...@@ -612,7 +612,7 @@ void SwView::_CheckReadonlyState() ...@@ -612,7 +612,7 @@ void SwView::_CheckReadonlyState()
qsort( (void*)aAllProtIds, sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds ); qsort( (void*)aAllProtIds, sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
bAllProtFirst = sal_False; bAllProtFirst = sal_False;
} }
rDis.SetSlotFilter( sal_Bool(2), rDis.SetSlotFilter( SFX_SLOT_FILTER_ENABLED_READONLY,
sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(aAllProtIds)/sizeof(sal_uInt16),
aAllProtIds ); aAllProtIds );
bChgd = sal_True; bChgd = sal_True;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment