summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-09-14 02:46:29 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-09-14 06:14:38 +0200
commitf435b78866f8ae7959c0cbf1484e6bfca8084eba (patch)
tree5c159cead52cae2b1c94fb9ae240b3cb3599239e
parent57f6d49d8e83e39b7d83b9c2e48900538bf88f05 (diff)
fix the vba document module code export
After some debugging it seems that MSO gets totally confused if these entries are missing. I need to look into MS-VBAL to make them more generic but at least that allows me to execute the macro in the exported files. Change-Id: I9648647323f87b2765c96950f470193f1a60bb9e
-rw-r--r--oox/source/ole/vbaexport.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index d31c1e9d61fb..064a1e40ee4a 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -633,11 +633,21 @@ void exportDirStream(SvStream& rStrm, css::uno::Reference<css::container::XNameC
}
// section 2.3.4.3 Module Stream
-void exportModuleStream(SvStream& rStrm, const OUString& rSourceCode, const OUString& aElementName)
+void exportModuleStream(SvStream& rStrm, const OUString& rSourceCode, const OUString& aElementName, sal_Int32 nModuleType)
{
SvMemoryStream aModuleStream(4096, 4096);
exportString(aModuleStream, "Attribute VB_Name = \"" + aElementName + "\"\r\n");
+ if (nModuleType == 4)
+ {
+ exportString(aModuleStream, "Attribute VB_Base = \"0{00020820-0000-0000-C000-000000000046}\"\r\n");
+ exportString(aModuleStream, "Attribute VB_GlobalNameSpace = False\r\n");
+ exportString(aModuleStream, "Attribute VB_Creatable = False\r\n");
+ exportString(aModuleStream, "Attribute VB_PredeclaredId = True\r\n");
+ exportString(aModuleStream, "Attribute VB_Exposed = True\r\n");
+ exportString(aModuleStream, "Attribute VB_TemplateDerived = False\r\n");
+ exportString(aModuleStream, "Attribute VB_Customizable = True\r\n");
+ }
OUString aSourceCode = rSourceCode.replaceFirst("Option VBASupport 1\n", "");
const sal_Int32 nPos = aSourceCode.indexOf("Rem Attribute VBA_ModuleType=");
const sal_Int32 nEndPos = nPos != -1 ? aSourceCode.indexOf("\n", nPos) : -1;
@@ -864,7 +874,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
OUString aSourceCode;
aCode >>= aSourceCode;
- exportModuleStream(*aModuleStreams[i], aSourceCode, aElementNames[i]);
+ exportModuleStream(*aModuleStreams[i], aSourceCode, aElementNames[i], aModuleInfo.ModuleType);
aModuleStreams[i]->Commit();
}