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
#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
{
......@@ -158,8 +166,7 @@ public:
void Flush();
void Lock( bool bLock );
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( sal_Bool bEnable = sal_False,
void SetSlotFilter( SfxSlotFilterState nEnable = SFX_SLOT_FILTER_DISABLED,
sal_uInt16 nCount = 0, const sal_uInt16 *pSIDs = 0 );
void HideUI( bool bHide = true );
......@@ -180,8 +187,7 @@ public:
bool bOwnShellsOnly, bool bModal, bool bRealSlot=true );
SAL_DLLPRIVATE void SetReadOnly_Impl( bool bOn );
SAL_DLLPRIVATE bool GetReadOnly_Impl() const;
// bEnable can be sal_True,sal_False, or 2(some kind of read-only override hack)
SAL_DLLPRIVATE sal_Bool IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const;
SAL_DLLPRIVATE SfxSlotFilterState IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const;
SAL_DLLPRIVATE void SetQuietMode_Impl( bool bOn );
SAL_DLLPRIVATE bool IsReadOnlyShell_Impl( sal_uInt16 nShell ) const;
SAL_DLLPRIVATE void RemoveShell_Impl( SfxShell& rShell );
......
......@@ -393,7 +393,7 @@ void DrawDocShell::ApplySlotFilter() const
SfxDispatcher* pDispatcher = pTestViewShell->GetViewFrame()->GetDispatcher();
if( mpFilterSIDs )
pDispatcher->SetSlotFilter( mbFilterEnable, mnFilterCount, mpFilterSIDs );
pDispatcher->SetSlotFilter( mbFilterEnable ? SFX_SLOT_FILTER_ENABLED : SFX_SLOT_FILTER_DISABLED, mnFilterCount, mpFilterSIDs );
else
pDispatcher->SetSlotFilter();
......
......@@ -2744,7 +2744,7 @@ void SAL_CALL SlideshowImpl::activate() throw (RuntimeException, std::exception)
if( pDispatcher )
{
// 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() )
......
......@@ -133,8 +133,8 @@ struct SfxDispatcher_Impl
bool bQuiet; // Only use parent dispatcher
bool bModal; // Only slots from parent dispatcher
sal_Bool bFilterEnabling; // sal_True=filter enabled slots,
// 2==ReadOnlyDoc overturned
SfxSlotFilterState nFilterEnabling; // 1==filter enabled slots,
// 2==ReadOnlyDoc overturned
sal_uInt16 nFilterCount; // Number of SIDs in pFilterSIDs
const sal_uInt16* pFilterSIDs; // sorted Array of SIDs
sal_uInt32 nDisableFlags;
......@@ -347,7 +347,7 @@ void SfxDispatcher::Construct_Impl( SfxDispatcher* pParent )
pImp->bQuiet = false;
pImp->bModal = false;
pImp->pInCallAliveFlag = 0;
pImp->bFilterEnabling = sal_False;
pImp->nFilterEnabling = SFX_SLOT_FILTER_DISABLED;
pImp->nFilterCount = 0;
pImp->pFilterSIDs = 0;
pImp->nDisableFlags = 0;
......@@ -1730,11 +1730,11 @@ void SfxDispatcher::FlushImpl()
void SfxDispatcher::SetSlotFilter
(
// HACK(hier muss mal ein enum rein) ???
sal_Bool bEnable, /* sal_True:
SfxSlotFilterState nEnable, /* 1==true:
only enable specified slots,
disable all other
sal_False:
0==false:
disable specified slots,
first enable all other
*/
......@@ -1780,7 +1780,7 @@ void SfxDispatcher::SetSlotFilter
if ( pImp->pFilterSIDs )
pImp->pFilterSIDs = 0;
pImp->bFilterEnabling = bEnable;
pImp->nFilterEnabling = nEnable;
pImp->nFilterCount = nCount;
pImp->pFilterSIDs = pSIDs;
......@@ -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]
......@@ -1810,7 +1810,7 @@ sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const
disabled by the Filter.
[Return value]
sal_Bool 0 => disabled
int 0 => disabled
1 => enabled
2 => enabled even if ReadOnlyDoc
*/
......@@ -1819,17 +1819,20 @@ sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const
// no filter?
if ( 0 == pImp->nFilterCount )
// => all SIDs allowed
return sal_True;
return SFX_SLOT_FILTER_ENABLED;
// search
bool bFound = 0 != bsearch( &nSID, pImp->pFilterSIDs, pImp->nFilterCount,
sizeof(sal_uInt16), SfxCompareSIDs_Impl );
// even if ReadOnlyDoc
if ( 2 == pImp->bFilterEnabling )
return bFound ? 2 : 1;
if ( SFX_SLOT_FILTER_ENABLED_READONLY == pImp->nFilterEnabling )
return bFound ? SFX_SLOT_FILTER_ENABLED_READONLY : SFX_SLOT_FILTER_ENABLED;
// 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
}
// SID check against set filter
sal_uInt16 nSlotEnableMode=0;
SfxSlotFilterState nSlotEnableMode = SFX_SLOT_FILTER_DISABLED;
if ( pImp->pFrame )
{
nSlotEnableMode = IsSlotEnabledByFilter_Impl( nSlot );
if ( 0 == nSlotEnableMode )
if ( SFX_SLOT_FILTER_DISABLED == nSlotEnableMode )
return false;
}
......@@ -1977,7 +1980,7 @@ bool SfxDispatcher::_FindServer
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
// from top to bottom
......
......@@ -597,7 +597,7 @@ void SwView::_CheckReadonlyState()
}
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;
}
}
......@@ -612,7 +612,7 @@ void SwView::_CheckReadonlyState()
qsort( (void*)aAllProtIds, sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
bAllProtFirst = sal_False;
}
rDis.SetSlotFilter( sal_Bool(2),
rDis.SetSlotFilter( SFX_SLOT_FILTER_ENABLED_READONLY,
sizeof(aAllProtIds)/sizeof(sal_uInt16),
aAllProtIds );
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