用法:
头文件中声明:
DECL_LINK( PaintingFirstLineHdl, PaintFirstLineInfo* );
宏:#define DECL_LINK( Method, ArgType ) \
long Method( ArgType ); \
static long LinkStub##Method( void* pThis, void* )
展开:
long PaintingFirstLineHdl(PaintFirstLineInfo*);
static long LinkStubPaintingFirstLineHdl(void*pThis,void*);
等于声明了两个方法。
CXX文件: IMPL_LINK(OutlineView, PaintingFirstLineHdl, PaintFirstLineInfo*, pInfo)
宏:
#define IMPL_LINK( Class, Method, ArgType, ArgName ) \
IMPL_STUB( Class, Method, ArgType ) \
long Class::Method( ArgType ArgName )
#define IMPL_STUB(Class, Method, ArgType) \
long __EXPORT Class::LinkStub##Method( void* pThis, void* pCaller) \
{ \
return ((Class*)pThis )->Method( (ArgType)pCaller ); \
}
展开:
long_EXPORT OutlineView::LinkStubPaintingFirstLineHdl(void *pThis,void *pCaller)
{
return ((Outlineview*)pThis)->PaintingFirstLineHdl((PaintFirstLineInfo*)pCaller)
}
long OutlineView::PaintingFirstLineHdl(PaintFirstLineInfo* plnfo)
传递函数指针:
Link alink (LINK(this,OutlineView,PaintingFirstLineHdl))
宏:
typedef long (*PSTUB)( void*, void* );
#define LINK( Inst, Class, Member ) Link( (Class*)Inst, (PSTUB)&Class::LinkStub##Member )
展开:
Link((OutlineView*)this,(PSTUB)&OutlineView::LinkStubPaintingFirstLineHdl)
Link类的构造函数: Link( void* pLinkHdl, PSTUB pMemFunc );
pLinkHdl: 对象的地址。
pMemFunc: 指向所要调用的函数指针。
这样把alink传递到任何地方,只要对象还存在就能调用PaintingFirstLineHdl这个方法。
调用:
inline long Link::Call(void *pCaller) const
{
return pFunc ? (*pFunc)(pInst, pCaller) : 0;
}
================
补充:
IMPL_LINK(OutlineView, PaintingFirstLineHdl, PaintFirstLineInfo*, pInfo)
void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aStartPos, sal_Bool bStripOnly, short nOrientation )
mpOutliner->SetPaintFirstLineHdl(LINK(this,OutlineView,PaintingFirstLineHdl));
Link aLink( LINK(this,OutlineView,EventMultiplexerListener) );
mpOutlineViewShell->GetViewShellBase().GetEventMultiplexer()->AddEventListener(
aLink,
tools::EventMultiplexerEvent::EID_CURRENT_PAGE
| tools::EventMultiplexerEvent::EID_PAGE_ORDER);
/
赋值:
mpOutliner->SetPaintFirstLineHdl(LINK(this,OutlineView,PaintingFirstLineHdl));
/
调用:
inline long Link::Call(void *pCaller) const
{
return pFunc ? (*pFunc)(pInst, pCaller) : 0;
}
构造函数: Link( void* pLinkHdl, PSTUB pMemFunc );
pLinkHdl: 对象的地址。
pMemFunc: 指向所要调用的函数指针。
宏:
typedef long (*PSTUB)( void*, void* );
#define LINK( Inst, Class, Member ) Link( (Class*)Inst, (PSTUB)&Class::LinkStub##Member )
mpOutliner->SetPaintFirstLineHdl(LINK(this,OutlineView,PaintingFirstLineHdl));
Using ## concatenates what's before the ## with what's after it.
展开:Link((OutlineView*)this,(PSTUB)&OutlineView::LinkStub##PaintingFirstLineHdl)
LinkStubPaintingFirstLineHdl
IMPL_LINK(OutlineView, PaintingFirstLineHdl, PaintFirstLineInfo*, pInfo)
按照下面的宏展开:
IMPL_STUB(OutlineView,PaintingFirstLineHdl,PaintFirstLINEInfo*) \
long OutlineView::PaintingFirstLineHdl(PaintFirstLineInfo* plnfo)
long_EXPORT OutlineView::LinkStubPaintingFirstLineHdl(void *pThis,void *pCaller){
return ((Outlineview*)pThis)->Method((argType)pCaller) }\
long OutlineView::PaintingFirstLineHdl(PaintFirstLineInfo* plnfo)
#define IMPL_LINK( Class, Method, ArgType, ArgName ) \
IMPL_STUB( Class, Method, ArgType ) \
long Class::Method( ArgType ArgName )
#define IMPL_STUB(Class, Method, ArgType) \
long __EXPORT Class::LinkStub##Method( void* pThis, void* pCaller) \
{ \
return ((Class*)pThis )->Method( (ArgType)pCaller ); \
}
头文件中声明:
DECL_LINK( PaintingFirstLineHdl, PaintFirstLineInfo* );
宏:#define DECL_LINK( Method, ArgType ) \
long Method( ArgType ); \
static long LinkStub##Method( void* pThis, void* )
展开:
long PaintingFirstLineHdl(PaintFirstLineInfo*);
static long LinkStubPaintingFirstLineHdl(void*pThis,void*);
等于声明了两个方法。
CXX文件: IMPL_LINK(OutlineView, PaintingFirstLineHdl, PaintFirstLineInfo*, pInfo)
宏:
#define IMPL_LINK( Class, Method, ArgType, ArgName ) \
IMPL_STUB( Class, Method, ArgType ) \
long Class::Method( ArgType ArgName )
#define IMPL_STUB(Class, Method, ArgType) \
long __EXPORT Class::LinkStub##Method( void* pThis, void* pCaller) \
{ \
return ((Class*)pThis )->Method( (ArgType)pCaller ); \
}
展开:
long_EXPORT OutlineView::LinkStubPaintingFirstLineHdl(void *pThis,void *pCaller)
{
return ((Outlineview*)pThis)->PaintingFirstLineHdl((PaintFirstLineInfo*)pCaller)
}
long OutlineView::PaintingFirstLineHdl(PaintFirstLineInfo* plnfo)
传递函数指针:
Link alink (LINK(this,OutlineView,PaintingFirstLineHdl))
宏:
typedef long (*PSTUB)( void*, void* );
#define LINK( Inst, Class, Member ) Link( (Class*)Inst, (PSTUB)&Class::LinkStub##Member )
展开:
Link((OutlineView*)this,(PSTUB)&OutlineView::LinkStubPaintingFirstLineHdl)
Link类的构造函数: Link( void* pLinkHdl, PSTUB pMemFunc );
pLinkHdl: 对象的地址。
pMemFunc: 指向所要调用的函数指针。
这样把alink传递到任何地方,只要对象还存在就能调用PaintingFirstLineHdl这个方法。
调用:
inline long Link::Call(void *pCaller) const
{
return pFunc ? (*pFunc)(pInst, pCaller) : 0;
}
================
补充:
IMPL_LINK(OutlineView, PaintingFirstLineHdl, PaintFirstLineInfo*, pInfo)
void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aStartPos, sal_Bool bStripOnly, short nOrientation )
mpOutliner->SetPaintFirstLineHdl(LINK(this,OutlineView,PaintingFirstLineHdl));
Link aLink( LINK(this,OutlineView,EventMultiplexerListener) );
mpOutlineViewShell->GetViewShellBase().GetEventMultiplexer()->AddEventListener(
aLink,
tools::EventMultiplexerEvent::EID_CURRENT_PAGE
| tools::EventMultiplexerEvent::EID_PAGE_ORDER);
/
赋值:
mpOutliner->SetPaintFirstLineHdl(LINK(this,OutlineView,PaintingFirstLineHdl));
/
调用:
inline long Link::Call(void *pCaller) const
{
return pFunc ? (*pFunc)(pInst, pCaller) : 0;
}
构造函数: Link( void* pLinkHdl, PSTUB pMemFunc );
pLinkHdl: 对象的地址。
pMemFunc: 指向所要调用的函数指针。
宏:
typedef long (*PSTUB)( void*, void* );
#define LINK( Inst, Class, Member ) Link( (Class*)Inst, (PSTUB)&Class::LinkStub##Member )
mpOutliner->SetPaintFirstLineHdl(LINK(this,OutlineView,PaintingFirstLineHdl));
Using ## concatenates what's before the ## with what's after it.
展开:Link((OutlineView*)this,(PSTUB)&OutlineView::LinkStub##PaintingFirstLineHdl)
LinkStubPaintingFirstLineHdl
IMPL_LINK(OutlineView, PaintingFirstLineHdl, PaintFirstLineInfo*, pInfo)
按照下面的宏展开:
IMPL_STUB(OutlineView,PaintingFirstLineHdl,PaintFirstLINEInfo*) \
long OutlineView::PaintingFirstLineHdl(PaintFirstLineInfo* plnfo)
long_EXPORT OutlineView::LinkStubPaintingFirstLineHdl(void *pThis,void *pCaller){
return ((Outlineview*)pThis)->Method((argType)pCaller) }\
long OutlineView::PaintingFirstLineHdl(PaintFirstLineInfo* plnfo)
#define IMPL_LINK( Class, Method, ArgType, ArgName ) \
IMPL_STUB( Class, Method, ArgType ) \
long Class::Method( ArgType ArgName )
#define IMPL_STUB(Class, Method, ArgType) \
long __EXPORT Class::LinkStub##Method( void* pThis, void* pCaller) \
{ \
return ((Class*)pThis )->Method( (ArgType)pCaller ); \
}