On 10/09/14 04:58, Noel Power wrote:
> On 09/09/14 15:55, Justin Luth wrote:
>>
>> I have identified that the vbahelper function getCurrentDoc() is
>> broken, causing bug 71248
>>
>> I'm still going to try to figure out how to properly fix
>> "getCurrentDoc" but so far I don't really understand what it is doing.
> I haven't looked at that code in a long time so feel free to dive in
> there, iirc basically 'THIS' is tracked in the uno context (VBA has a
> custom uno context), CURRENT should be accessible as a UNO global
> variable inserted in to 'application' StarBasic. It sounds like
> somehow somewhere getCurrentDoc either is no longer searching for the
> correct variable, or its no longer getting updated (used to be updated
> somewhere in sfx2/.../objxstor.cxx (try searching for 'ThisComponent',
> it's bound to be handled somewhere close to that)
> There used to be some confusing (but necessary) indirection to
> handling this e.g. because Libreoffice is a single application (and
> VBA support was trying to support both Word & Excel) the code in
> objxstor.cxx needs to find out which variable in StartBasic to update,
> in the case of a Word document it would need to update StarBasic
> variable named 'ThisWordDoc' & for Excel 'ThisExcelDoc' variable (both
> can exist simulateously if multiple documents xls/doc are open).  That
> is my recollection how this used to work, it is possible imports from
> AOO code have trampled/changed this possibly in an incompatible way
>
Noel, Thanks for that information.  I've attached a diff that seems to
fix the problem of the GlobalUNOConstant/Standard library names
'ThisWordDoc' and 'ThisExcelDoc' not being updated when the active
document changes.

Are you willing to review this and enter it into master/4.3 if it is
good?  I spent two weeks just trying to understand what is going on
here, so I don't feel competent to try and submit the patch myself.

Thanks,
Justin
https://bugs.freedesktop.org/show_bug.cgi?id=71248
99a100,101
> #include <com/sun/star/frame/XModel2.hpp>
> #include <com/sun/star/frame/ModuleManager.hpp>
978a981,994
>         uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext(), uno::UNO_QUERY_THROW );
>         uno::Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xContext) );
>         OUString aIdentifier = xModuleManager->identify( _rxComponent );
> 
>         if (aIdentifier == (OUString)"com.sun.star.sheet.SpreadsheetDocument")
>                 {
>                     //set "ThisExcelDoc" to mark the last active Excel document for VBA
>             pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", Any( _rxComponent ) );
>         }
>                 else if (aIdentifier == (OUString)"com.sun.star.text.TextDocument")
>                 {
>                         //set "ThisExcelDoc" to mark the last active Word document for VBA
>                 pAppMgr->SetGlobalUNOConstant( "ThisWordDoc", Any( _rxComponent ) );
>                 }    
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to