Walt Ogburn wrote:
Changelog: Implement IFontDisp::GetIDsOfNames
You're not being lazy enough. All of this stuff can be easily implemented in one go using CreateStdDispatch, as long as you know how to use it. Try the attached patch.
Changelog: Return the standard font IDispatch interface created using CreateStdDispatch on top of a typelib instead of manually implementing the necessary methods.
On Wed, 14 Sep 2005, Robert Shearman wrote:
You're not being lazy enough. All of this stuff can be easily implemented in one go using CreateStdDispatch, as long as you know how to use it. Try the attached patch.
Changelog: Return the standard font IDispatch interface created using CreateStdDispatch on top of a typelib instead of manually implementing the necessary methods.
That doesn't look very lazy to me, but it simplifies olefont very nicely (300 fewer lines!). Please use this patch for GetIDsOfNames instead of mine.
My patch for DispGetIDsOfNames and the test for IFontDisp_GetIDsOfNames are still OK. With Robert Shearman's big patch to olefont.c and my small one to typelib.c, the tests in my patch to tests/olefont.c all pass.
Thanks, Walter
Wait a minute, hold that - after this patch, you can't use Invoke any more to get and set the members of IFontDisp! With the current code, it works. Alexandre, please don't commit that yet.
Thanks, Walter
On Wed, 14 Sep 2005, Robert Shearman wrote:
Walt Ogburn wrote:
Changelog: Implement IFontDisp::GetIDsOfNames
You're not being lazy enough. All of this stuff can be easily implemented in one go using CreateStdDispatch, as long as you know how to use it. Try the attached patch.
Changelog: Return the standard font IDispatch interface created using CreateStdDispatch on top of a typelib instead of manually implementing the necessary methods.
-- Rob Shearman
On Wed, 14 Sep 2005, Robert Shearman wrote:
You're not being lazy enough. All of this stuff can be easily implemented in one go using CreateStdDispatch, as long as you know how to use it. Try the attached patch.
Changelog: Return the standard font IDispatch interface created using CreateStdDispatch on top of a typelib instead of manually implementing the necessary methods.
Hi Robert,
I'm not sure how to proceed here. My small patch makes the GetIDsOfNames in olefont work, so that programs that want to use GetIDsOfNames to get a DISPID code and then use Invoke to set font size, bold, etc. will work. With your bigger patch, IFontDisp uses the GetIDsOfNames from typelib.c, which also works, but it also uses the Invoke from typelib.c, which doesn't know how to set the font size, etc. Therefore, programs that try to get the DISPID code with GetIDsOfNames and then set some property with Invoke are broken at a different point after your patch.
The thing is, I don't see how the Invoke in typelib.c can be made to get and set the font size, font weight, etc. correctly. It shouldn't know about the internal structure of OLEFontImpl, right? So how can it know that DISPID_FONT_WEIGHT and DISPID_FONT_BOLD mean doing doing different things to the same field in the OLEFontImpl, or where to find it?
If you know how to make Invoke work again after your patch, that would be great. Otherwise, I could just re-submit my patch with the error handling corrected as Alexandre said.
- Walter
Walt Ogburn wrote:
I'm not sure how to proceed here. My small patch makes the GetIDsOfNames in olefont work, so that programs that want to use GetIDsOfNames to get a DISPID code and then use Invoke to set font size, bold, etc. will work. With your bigger patch, IFontDisp uses the GetIDsOfNames from typelib.c, which also works, but it also uses the Invoke from typelib.c, which doesn't know how to set the font size, etc.
It does know how to do that - it uses the typelib to calculate an offset in the vtable of the this pointer passed into CreateStdDispatch and calls the matching method.
Therefore, programs that try to get the DISPID code with GetIDsOfNames and then set some property with Invoke are broken at a different point after your patch.
Have you tested this? How exactly do they break? Do they crash or does Invoke return an error?
The thing is, I don't see how the Invoke in typelib.c can be made to get and set the font size, font weight, etc. correctly. It shouldn't know about the internal structure of OLEFontImpl, right? So how can it know that DISPID_FONT_WEIGHT and DISPID_FONT_BOLD mean doing doing different things to the same field in the OLEFontImpl, or where to find it?
Again, it should look up the offset in the vtable to call the appropriate put_... or get_... function depending on whether propget or propput is specified.
If you know how to make Invoke work again after your patch, that would be great.
It is possible that I overlooked something that we need to do for the invoking through a typelib to work. I'll need more info to find this out.