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

simplify SvSlotElement

Change-Id: I4699dca35c0197944df97005ff032e1d16139e5f
üst 8d6e4896
...@@ -49,8 +49,8 @@ public: ...@@ -49,8 +49,8 @@ public:
using typename base_t::reverse_iterator; using typename base_t::reverse_iterator;
using base_t::empty; using base_t::empty;
inline ~SvRefMemberList() { clear(); } ~SvRefMemberList() { clear(); }
inline void clear() void clear()
{ {
for( typename base_t::const_iterator it = base_t::begin(); it != base_t::end(); ++it ) for( typename base_t::const_iterator it = base_t::begin(); it != base_t::end(); ++it )
{ {
...@@ -61,13 +61,19 @@ public: ...@@ -61,13 +61,19 @@ public:
base_t::clear(); base_t::clear();
} }
inline void push_back( T p ) void push_back( T p )
{ {
base_t::push_back( p ); base_t::push_back( p );
p->AddFirstRef(); p->AddFirstRef();
} }
inline T pop_back() void insert( typename base_t::iterator it, T p )
{
base_t::insert( it, p );
p->AddFirstRef();
}
T pop_back()
{ {
T p = base_t::back(); T p = base_t::back();
base_t::pop_back(); base_t::pop_back();
......
...@@ -24,13 +24,6 @@ ...@@ -24,13 +24,6 @@
#include <slot.hxx> #include <slot.hxx>
#include <vector> #include <vector>
struct SvSlotElement
{
tools::SvRef<SvMetaSlot> xSlot;
SvSlotElement( SvMetaSlot * pS ) : xSlot( pS ) {}
};
typedef std::vector< SvSlotElement* > SvSlotElementList;
class SvMetaClass; class SvMetaClass;
typedef ::std::vector< SvMetaClass* > SvMetaClassList; typedef ::std::vector< SvMetaClass* > SvMetaClassList;
......
...@@ -24,10 +24,9 @@ ...@@ -24,10 +24,9 @@
#include <tools/ref.hxx> #include <tools/ref.hxx>
#include <basobj.hxx> #include <basobj.hxx>
struct SvSlotElement;
typedef std::vector< SvSlotElement* > SvSlotElementList;
class SvMetaType; class SvMetaType;
class SvMetaSlot;
typedef SvRefMemberList< SvMetaSlot* > SvSlotElementList;
class SvMetaAttribute : public SvMetaReference class SvMetaAttribute : public SvMetaReference
{ {
......
...@@ -201,8 +201,7 @@ sal_uInt16 SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase, ...@@ -201,8 +201,7 @@ sal_uInt16 SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase,
sal_uInt16 nCount = 0; sal_uInt16 nCount = 0;
for ( size_t i = 0, n = rSlotList.size(); i < n; ++i ) for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
{ {
SvSlotElement *pEle = rSlotList[ i ]; SvMetaSlot *pAttr = rSlotList[ i ];
SvMetaSlot *pAttr = pEle->xSlot;
nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm ); nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm );
} }
...@@ -217,8 +216,7 @@ sal_uInt16 SvMetaClass::WriteSlots( const OString& rShellName, ...@@ -217,8 +216,7 @@ sal_uInt16 SvMetaClass::WriteSlots( const OString& rShellName,
sal_uInt16 nSCount = 0; sal_uInt16 nSCount = 0;
for ( size_t i = 0, n = rSlotList.size(); i < n; ++i ) for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
{ {
SvSlotElement * pEle = rSlotList[ i ]; SvMetaSlot * pAttr = rSlotList[ i ];
SvMetaSlot * pAttr = pEle->xSlot;
nSCount = nSCount + pAttr->WriteSlotMap( rShellName, nCount + nSCount, nSCount = nSCount + pAttr->WriteSlotMap( rShellName, nCount + nSCount,
rSlotList, i, rBase, rSlotList, i, rBase,
rOutStm ); rOutStm );
...@@ -319,8 +317,7 @@ void SvMetaClass::WriteSlotStubs( const OString& rShellName, ...@@ -319,8 +317,7 @@ void SvMetaClass::WriteSlotStubs( const OString& rShellName,
// write all attributes // write all attributes
for ( size_t i = 0, n = rSlotList.size(); i < n; ++i ) for ( size_t i = 0, n = rSlotList.size(); i < n; ++i )
{ {
SvSlotElement *pEle = rSlotList[ i ]; SvMetaSlot *pAttr = rSlotList[ i ];
SvMetaSlot *pAttr = pEle->xSlot;
pAttr->WriteSlotStubs( rShellName, rList, rOutStm ); pAttr->WriteSlotStubs( rShellName, rList, rOutStm );
} }
} }
...@@ -350,8 +347,7 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) ...@@ -350,8 +347,7 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
InsertSlots(aSlotList, aSuperList, classList, OString(), rBase); InsertSlots(aSlotList, aSuperList, classList, OString(), rBase);
for ( size_t i = 0, n = aSlotList.size(); i < n; ++i ) for ( size_t i = 0, n = aSlotList.size(); i < n; ++i )
{ {
SvSlotElement *pEle = aSlotList[ i ]; SvMetaSlot *pSlot = aSlotList[ i ];
SvMetaSlot *pSlot = pEle->xSlot;
pSlot->SetListPos( i ); pSlot->SetListPos( i );
} }
...@@ -402,13 +398,10 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) ...@@ -402,13 +398,10 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
for( size_t i = 0, n = aSlotList.size(); i < n; ++i ) for( size_t i = 0, n = aSlotList.size(); i < n; ++i )
{ {
SvSlotElement* pEle = aSlotList[ i ]; SvMetaSlot* pAttr = aSlotList[ i ];
SvMetaSlot* pAttr = pEle->xSlot;
pAttr->ResetSlotPointer(); pAttr->ResetSlotPointer();
} }
for( size_t i = 0, n = aSlotList.size(); i < n; ++i )
delete aSlotList[ i ];
aSlotList.clear(); aSlotList.clear();
} }
......
...@@ -423,7 +423,7 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix, ...@@ -423,7 +423,7 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix,
if ( !nListCount ) if ( !nListCount )
nPos = 0; nPos = 0;
else if ( nListCount == 1 ) else if ( nListCount == 1 )
nPos = rList[ 0 ]->xSlot->GetSlotId().GetValue() >= nId ? 0 : 1; nPos = rList[ 0 ]->GetSlotId().GetValue() >= nId ? 0 : 1;
else else
{ {
sal_uInt16 nMid = 0, nLow = 0; sal_uInt16 nMid = 0, nLow = 0;
...@@ -433,7 +433,7 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix, ...@@ -433,7 +433,7 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix,
{ {
nMid = (nLow + nHigh) >> 1; nMid = (nLow + nHigh) >> 1;
DBG_ASSERT( nMid < nListCount, "bsearch ist buggy" ); DBG_ASSERT( nMid < nListCount, "bsearch ist buggy" );
int nDiff = (int) nId - (int) rList[ nMid ]->xSlot->GetSlotId().GetValue(); int nDiff = (int) nId - (int) rList[ nMid ]->GetSlotId().GetValue();
if ( nDiff < 0) if ( nDiff < 0)
{ {
if ( nMid == 0 ) if ( nMid == 0 )
...@@ -457,24 +457,24 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix, ...@@ -457,24 +457,24 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix,
DBG_ASSERT( nPos <= nListCount, DBG_ASSERT( nPos <= nListCount,
"nPos too large" ); "nPos too large" );
DBG_ASSERT( nPos == nListCount || nId <= DBG_ASSERT( nPos == nListCount || nId <=
(sal_uInt16) rList[ nPos ]->xSlot->GetSlotId().GetValue(), (sal_uInt16) rList[ nPos ]->GetSlotId().GetValue(),
"Successor has lower SlotId" ); "Successor has lower SlotId" );
DBG_ASSERT( nPos == 0 || nId > DBG_ASSERT( nPos == 0 || nId >
(sal_uInt16) rList[ nPos-1 ]->xSlot->GetSlotId().GetValue(), (sal_uInt16) rList[ nPos-1 ]->GetSlotId().GetValue(),
"Predecessor has higher SlotId" ); "Predecessor has higher SlotId" );
DBG_ASSERT( nPos+1 >= nListCount || nId < DBG_ASSERT( nPos+1 >= nListCount || nId <
(sal_uInt16) rList[ nPos+1 ]->xSlot->GetSlotId().GetValue(), (sal_uInt16) rList[ nPos+1 ]->GetSlotId().GetValue(),
"Successor has lower SlotId" ); "Successor has lower SlotId" );
if ( nPos < rList.size() ) if ( nPos < rList.size() )
{ {
SvSlotElementList::iterator it = rList.begin(); SvSlotElementList::iterator it = rList.begin();
std::advance( it, nPos ); std::advance( it, nPos );
rList.insert( it, new SvSlotElement( this ) ); rList.insert( it, this );
} }
else else
{ {
rList.push_back( new SvSlotElement( this ) ); rList.push_back( this );
} }
// iron out EnumSlots // iron out EnumSlots
...@@ -547,14 +547,14 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix, ...@@ -547,14 +547,14 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const OString& rPrefix,
// concatenate slaves among themselves // concatenate slaves among themselves
xEnumSlot = pFirstEnumSlot; xEnumSlot = pFirstEnumSlot;
size_t i = 0; size_t i = 0;
SvSlotElement *pEle; SvMetaSlot* pEle;
do do
{ {
pEle = ( ++i < rList.size() ) ? rList[ i ] : nullptr; pEle = ( ++i < rList.size() ) ? rList[ i ] : nullptr;
if ( pEle && pEle->xSlot->pLinkedSlot == this ) if ( pEle && pEle->pLinkedSlot == this )
{ {
xEnumSlot->pNextSlot = pEle->xSlot; xEnumSlot->pNextSlot = pEle;
xEnumSlot = pEle->xSlot; xEnumSlot = pEle;
} }
} }
while ( pEle ); while ( pEle );
...@@ -685,8 +685,8 @@ void SvMetaSlot::WriteSlot( const OString& rShellName, sal_uInt16 nCount, ...@@ -685,8 +685,8 @@ void SvMetaSlot::WriteSlot( const OString& rShellName, sal_uInt16 nCount,
// look for the next slot with the same StateMethod like me // look for the next slot with the same StateMethod like me
// the slotlist is set to the current slot // the slotlist is set to the current slot
size_t i = nStart; size_t i = nStart;
SvSlotElement* pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : nullptr; SvMetaSlot* pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : nullptr;
pNextSlot = pEle ? &pEle->xSlot : nullptr; pNextSlot = pEle;
while ( pNextSlot ) while ( pNextSlot )
{ {
if ( !pNextSlot->pNextSlot && if ( !pNextSlot->pNextSlot &&
...@@ -695,7 +695,7 @@ void SvMetaSlot::WriteSlot( const OString& rShellName, sal_uInt16 nCount, ...@@ -695,7 +695,7 @@ void SvMetaSlot::WriteSlot( const OString& rShellName, sal_uInt16 nCount,
break; break;
} }
pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : nullptr; pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : nullptr;
pNextSlot = pEle ? &pEle->xSlot : nullptr; pNextSlot = pEle;
} }
if ( !pNextSlot ) if ( !pNextSlot )
...@@ -704,14 +704,14 @@ void SvMetaSlot::WriteSlot( const OString& rShellName, sal_uInt16 nCount, ...@@ -704,14 +704,14 @@ void SvMetaSlot::WriteSlot( const OString& rShellName, sal_uInt16 nCount,
// So I search for the first slot with it (could be myself). // So I search for the first slot with it (could be myself).
i = 0; i = 0;
pEle = rSlotList.empty() ? nullptr : rSlotList[ i ]; pEle = rSlotList.empty() ? nullptr : rSlotList[ i ];
pNextSlot = pEle ? &pEle->xSlot : nullptr; pNextSlot = pEle;
while ( pNextSlot != this ) while ( pNextSlot != this )
{ {
if ( !pNextSlot->pEnumValue && if ( !pNextSlot->pEnumValue &&
pNextSlot->GetStateMethod() == GetStateMethod() ) pNextSlot->GetStateMethod() == GetStateMethod() )
break; break;
pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : nullptr; pEle = ( ++i < rSlotList.size() ) ? rSlotList[ i ] : nullptr;
pNextSlot = pEle ? &pEle->xSlot : nullptr; pNextSlot = pEle;
} }
} }
......
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