Bug Hunting Session
Bug 38804 - Implement Simple export of (some) VBA streams
Summary: Implement Simple export of (some) VBA streams
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyInteresting, skillCpp, topicDebug
Depends on:
Blocks:
 
Reported: 2011-06-30 06:26 UTC by Björn Michaelsen
Modified: 2016-01-26 19:44 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Michaelsen 2011-06-30 06:26:20 UTC
Background: We allow import and running of vba macros in LibreOffice. However, it is not possible to make some changes to the vba code and resave ( e.g. roundrip ) the document. In this scenario all changes to the basic streams are discarded and the original basic streams are restored as part of the save/save as operation. It would be nice to improve this situation by at least allowing the modification of the vba code in imported modules. This would be very useful for those situations where you need to maybe tweak the vba code a little so it runs both in LibreOffice and in MicroSoft Office. This task could be a bit tricky but surely is interesting, there are plenty of open questions like how to determine what to export, just changed modules ? do we handle deleted modules ? or added Modules. Another thing is there is some metadata buried in the Module streams that we strip out ( see VbaModule::readSourceCode in vbamodule.cxx ) Additionally we add some those funny 'Option VBASupport 1' ( and some other comments ) that probably would need to be stripped out on export. Then there is the need to surgically insert the newly modified module streams into the existing project streams ( whilst preserving the existing information ) Note: In addition the module code is compressed there is an experimental compression routine we tried in the past ( I need to find it ;-) ) but it was written prior to release of the Microsoft office file protocols, perhaps it would be better anyway to start from scratch with the algorithm that will be already documented ( see useful links below ) Useful info ( I will add to this )
[edit] export hooks

1) in the oox filter

( note: probably not invoked even in calc export which no doubt still uses the legacy stuff for copying the streams ;-) ) is in source/ole/vbaproject.cxx (VbaProject::importVbaProject method handles both import and export... go figure!

2) in the legacy filter

is in filter/source/msfilter/svxmsbas2.cxx SvxImportMSVBasic::SaveOrDelMSVBAStorage
[edit] VBA Stream specifications

http://download.microsoft.com/download/2/4/8/24862317-78f0-4c4b-b355-c7b2c1d997db/%5BMS-OVBA%5D.pdf
[edit] Useful uno apis

http://api.openoffice.org/docs/common/ref/com/sun/star/script/XLibraryContainer.html http://api.openoffice.org/docs/common/ref/com/sun/star/script/vba/XVBAModuleInfo.html

which can be accessed via the 'BasicLibraries' property of the document

Skills: building, debugging, C++
Comment 1 Florian Reisinger 2012-05-18 09:47:27 UTC
Deleted "Easyhack" from summary.
Comment 2 Björn Michaelsen 2013-10-04 18:47:19 UTC
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility.

see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
Comment 3 Björn Michaelsen 2015-01-15 16:32:18 UTC
Removing EasyHack due to limited response since 2011-06.
Comment 4 Robinson Tryon (qubit) 2015-12-14 07:20:48 UTC
Migrating Whiteboard tags to Keywords: (DifficultyInteresting SkillCpp SkillDebug)
[NinjaEdit]
Comment 5 Björn Michaelsen 2016-01-26 18:02:36 UTC
topicDebug is a Topic.
Comment 6 Björn Michaelsen 2016-01-26 18:04:54 UTC
Remove skillDebug, superceded by topicDebug.
Comment 7 Markus Mohrhard 2016-01-26 19:06:01 UTC
Fixed by Rosemary in 5.2 and following.
Comment 8 Markus Mohrhard 2016-01-26 19:06:27 UTC
Actually 5.1 has it already in calc.
Comment 9 Cor Nouws 2016-01-26 19:44:30 UTC
(In reply to Markus Mohrhard (retired) from comment #8)
> Actually 5.1 has it already in calc.

see http://cgit.freedesktop.org/libreoffice/core/commit/?id=c5aeca430288057a721688975173ed764860d8b8 (and others)

and https://wiki.documentfoundation.org/ReleaseNotes/5.1#Improvements_in_OpenXML_filter