// registers the availability of the Interface of functions
void SfxSlotPool::RegisterInterface( SfxInterface& rInterface )
{ // add to the list of SfxObjectInterface instances
_vInterfaces.push_back(&rInterface);
// Stop at a (single) Null-slot (for syntactic reasons the interfaces // always contain at least one slot) if ( rInterface.Count() != 0 && !rInterface.pSlots[0].nSlotId ) return;
// possibly add Interface-id and group-ids of funcs to the list of groups if ( _pParentPool )
{ // The Groups in parent Slotpool are also known here
_vGroups.insert( _vGroups.end(), _pParentPool->_vGroups.begin(), _pParentPool->_vGroups.end() );
}
// get the first SfxMessage for a special Id (e.g. for getting check-mode)
const SfxSlot* SfxSlotPool::GetSlot( sal_uInt16 nId ) const
{ // First, search their own interfaces for (SfxInterface* _pInterface : _vInterfaces)
{ const SfxSlot *pDef = _pInterface->GetSlot(nId); if ( pDef ) return pDef;
}
// Then try any of the possible existing parent return _pParentPool ? _pParentPool->GetSlot( nId ) : nullptr;
}
// skips to the next group
OUString SfxSlotPool::SeekGroup( sal_uInt16 nNo )
{ // if the group exists, use it if ( nNo < _vGroups.size() )
{
_nCurGroup = nNo; if ( _pParentPool )
{ // In most cases, the order of the IDs agree
sal_uInt16 nParentCount = _pParentPool->_vGroups.size(); if ( nNo < nParentCount && _vGroups[nNo] == _pParentPool->_vGroups[nNo] )
_pParentPool->_nCurGroup = nNo; else
{ // Otherwise search. If the group is not found in the parent // pool, _nCurGroup is set outside the valid range
sal_uInt16 i; for ( i=1; i<nParentCount; i++ ) if ( _vGroups[nNo] == _pParentPool->_vGroups[i] ) break;
_pParentPool->_nCurGroup = i;
}
}
TranslateId pResId = getGidResId(_vGroups[_nCurGroup]); if (!pResId)
{
OSL_FAIL( "GroupId-Name not defined in SFX!" ); return OUString();
}
const SfxSlot* SfxSlotPool::SeekSlot( sal_uInt16 nStartInterface )
{ // The numbering starts at the interfaces of the parent pool
sal_uInt16 nFirstInterface = _pParentPool ? _pParentPool->_vInterfaces.size() : 0;
// have reached the end of the Parent-Pools? if ( nStartInterface < nFirstInterface &&
_pParentPool->_nCurGroup >= _pParentPool->_vGroups.size() )
nStartInterface = nFirstInterface;
// Is the Interface still in the Parent-Pool? if ( nStartInterface < nFirstInterface )
{
SAL_WARN_IF(!_pParentPool, "sfx.control", "No parent pool!");
_nCurInterface = nStartInterface; return _pParentPool->SeekSlot( nStartInterface );
}
// find the first func-def with the current group id
sal_uInt16 nCount = _vInterfaces.size() + nFirstInterface; for ( _nCurInterface = nStartInterface;
_nCurInterface < nCount;
++_nCurInterface )
{
SfxInterface* pInterface = _vInterfaces[_nCurInterface-nFirstInterface]; for ( _nCurMsg = 0;
_nCurMsg < pInterface->Count();
++_nCurMsg )
{ const SfxSlot& rMsg = pInterface->pSlots[_nCurMsg]; if (rMsg.GetGroupId() == _vGroups.at(_nCurGroup)) return &rMsg;
}
}
return nullptr;
}
// skips to the next func in the current group
const SfxSlot* SfxSlotPool::NextSlot()
{ // The numbering starts at the interfaces of the parent pool
sal_uInt16 nFirstInterface = _pParentPool ? _pParentPool->_vInterfaces.size() : 0;
if ( _nCurInterface < nFirstInterface )
{
SAL_WARN_IF(!_pParentPool, "sfx.control", "No parent pool!"); const SfxSlot *pSlot = _pParentPool->NextSlot();
_nCurInterface = _pParentPool->_nCurInterface; if ( pSlot ) return pSlot; if ( _nCurInterface == nFirstInterface ) // parent pool is ready return SeekSlot( nFirstInterface );
}
sal_uInt16 nInterface = _nCurInterface - nFirstInterface; // possibly we are already at the end if ( nInterface >= _vInterfaces.size() ) return nullptr;
// look for further matching func-defs within the same Interface
SfxInterface* pInterface = _vInterfaces[nInterface]; while ( ++_nCurMsg < pInterface->Count() )
{
SfxSlot& rMsg = pInterface->pSlots[_nCurMsg]; if (rMsg.GetGroupId() == _vGroups.at(_nCurGroup)) return &rMsg;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.