[Libreoffice-commits] core.git: 5 commits - oox/Library_oox.mk oox/source

Markus Mohrhard markus.mohrhard at googlemail.com
Sun Sep 13 21:18:09 PDT 2015


 oox/Library_oox.mk           |    4 
 oox/source/ole/vbaexport.cxx |  213 +++++++++++++++++++++++++++++++++++--------
 2 files changed, 182 insertions(+), 35 deletions(-)

New commits:
commit 912c9dd087bb7b3b4340c4cd9ba49ac0d923ae0a
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Sep 14 06:13:30 2015 +0200

    now we can also open the vba project in the MS vba editor
    
    If I use another GUID I can't open the project.
    
    Change-Id: Idfd642daaa0e6fb9f3b9bcfc6e1ba467c035bf05

diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index e997d28..fcd7215 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -33,6 +33,10 @@ $(eval $(call gb_Library_add_defs,oox,\
 
 $(eval $(call gb_Library_use_sdk_api,oox))
 
+$(eval $(call gb_Library_use_api,oox,\
+    oovbaapi \
+))
+
 $(eval $(call gb_Library_use_libraries,oox,\
     basegfx \
     comphelper \
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 703ddfd..9d756d1 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -20,6 +20,8 @@
 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 
+#include <ooo/vba/excel/XWorkbook.hpp>
+
 #include <oox/helper/binaryoutputstream.hxx>
 #include "oox/helper/propertyset.hxx"
 #include "oox/token/properties.hxx"
@@ -582,7 +584,7 @@ void writePROJECTMODULE(SvStream& rStrm, const OUString& name, const OUString& s
 }
 
 // section 2.3.4.2.3
-void writePROJECTMODULES(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer)
+void writePROJECTMODULES(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer, const std::vector<sal_Int32>& rLibrayMap)
 {
     css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
     sal_Int32 n = aElementNames.getLength();
@@ -598,19 +600,20 @@ void writePROJECTMODULES(SvStream& rStrm, css::uno::Reference<css::container::XN
 
     for (sal_Int32 i = 0; i < n; ++i)
     {
-        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
-        writePROJECTMODULE(rStrm, aElementNames[i], aElementNames[i], 0x00000000, aModuleInfo.ModuleType);
+        const OUString& rModuleName = aElementNames[rLibrayMap[i]];
+        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(rModuleName);
+        writePROJECTMODULE(rStrm, rModuleName, rModuleName, 0x00000000, aModuleInfo.ModuleType);
     }
 }
 
 // section 2.3.4.2
-void exportDirStream(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer)
+void exportDirStream(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer, const std::vector<sal_Int32>& rLibraryMap)
 {
     SvMemoryStream aDirStream(4096, 4096);
 
     writePROJECTINFORMATION(aDirStream);
     writePROJECTREFERENCES(aDirStream);
-    writePROJECTMODULES(aDirStream, xNameContainer);
+    writePROJECTMODULES(aDirStream, xNameContainer, rLibraryMap);
     aDirStream.WriteUInt16(0x0010); // terminator
     aDirStream.WriteUInt32(0x00000000); // reserved
 
@@ -681,6 +684,7 @@ void exportVBAProjectStream(SvStream& rStrm)
     rStrm.WriteUInt16(0x0000); // Undefined
 }
 
+/*
 OString createHexStringFromDigit(sal_uInt8 nDigit)
 {
     OString aString = OString::number( nDigit, 16 );
@@ -711,8 +715,11 @@ OString generateGUIDString()
     return createGuidStringFromInt(nGuid);
 }
 
+*/
+
 // section 2.3.1 PROJECT Stream
-void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer, const OUString& projectName)
+void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer,
+        const OUString& projectName, const std::vector<sal_Int32>& rLibraryMap)
 {
     css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
     sal_Int32 n = aElementNames.getLength();
@@ -723,20 +730,21 @@ void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XN
 
     // section 2.3.1.2 ProjectId
     exportString(rStrm, "ID=\"");
-    rStrm.WriteOString(generateGUIDString());
+    exportString(rStrm, "{9F10AB9C-89AC-4C0F-8AFB-8E9B96D5F170}");
     exportString(rStrm, "\"\r\n");
 
     // section 2.3.1.3 ProjectModule
     for (sal_Int32 i = 0; i < n; ++i)
     {
-        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
+        const OUString& rModuleName = aElementNames[rLibraryMap[i]];
+        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(rModuleName);
         if(aModuleInfo.ModuleType == 1)
         {
-            exportString(rStrm, "Module=" + aElementNames[i] + "\r\n");
+            exportString(rStrm, "Module=" + rModuleName + "\r\n");
         }
         else if(aModuleInfo.ModuleType == 4)
         {
-            exportString(rStrm, "Document=" + aElementNames[i] + "/&H00000000\r\n");
+            exportString(rStrm, "Document=" + rModuleName + "/&H00000000\r\n");
         }
     }
 
@@ -767,30 +775,89 @@ void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XN
     exportString(rStrm, "[Workspace]\r\n");
     for (sal_Int32 i = 0; i < n; ++i)
     {
-        exportString(rStrm, aElementNames[i] + "=0, 0, 0, 0, C\r\n");
+        const OUString& rModuleName = aElementNames[rLibraryMap[i]];
+        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(rModuleName);
+        if(aModuleInfo.ModuleType == 1)
+        {
+            exportString(rStrm,  rModuleName + "=25, 25, 1439, 639, \r\n");
+        }
+        else
+        {
+            exportString(rStrm, rModuleName + "=0, 0, 0, 0, C\r\n");
+        }
     }
 }
 
 // section 2.3.3.1 NAMEMAP
-void writeNAMEMAP(SvStream& rStrm, const css::uno::Sequence<OUString>& rElementNames)
+void writeNAMEMAP(SvStream& rStrm, const css::uno::Sequence<OUString>& rElementNames,
+        const std::vector<sal_Int32>& rLibraryMap)
 {
     int n = rElementNames.getLength();
     for(sal_Int32 i = 0; i < n; ++i)
     {
-        exportString(rStrm, rElementNames[i]);
+        const OUString& rModuleName = rElementNames[rLibraryMap[i]];
+        exportString(rStrm, rModuleName);
         rStrm.WriteUInt8(0x00); // terminator
-        exportUTF16String(rStrm, rElementNames[i]);
+        exportUTF16String(rStrm, rModuleName);
         rStrm.WriteUInt16(0x0000); // terminator
     }
 }
 
 // section 2.3.3 PROJECTwm Stream
-void exportPROJECTwmStream(SvStream& rStrm, const css::uno::Sequence<OUString>& rElementNames)
+void exportPROJECTwmStream(SvStream& rStrm, const css::uno::Sequence<OUString>& rElementNames,
+        const std::vector<sal_Int32>& rLibraryMap)
 {
-    writeNAMEMAP(rStrm, rElementNames);
+    writeNAMEMAP(rStrm, rElementNames, rLibraryMap);
     rStrm.WriteUInt16(0x0000); // terminator
 }
 
+void getCorrectExportOrder(css::uno::Reference<css::container::XNameContainer> xNameContainer, std::vector<sal_Int32>& rLibraryMap)
+{
+    css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
+    sal_Int32 n = aElementNames.getLength();
+    css::uno::Reference<css::script::vba::XVBAModuleInfo> xModuleInfo(xNameContainer, css::uno::UNO_QUERY);
+
+    sal_Int32 nCurrentId = 0;
+    // first all the non-document modules
+    for (sal_Int32 i = 0; i < n; ++i)
+    {
+        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
+        if (aModuleInfo.ModuleType != 4)
+        {
+            rLibraryMap[nCurrentId] = i;
+            ++nCurrentId;
+        }
+    }
+
+    sal_Int32 nWorkbookIndex = -1;
+    // then possibly the workbook module
+    for (sal_Int32 i = 0; i < n; ++i)
+    {
+        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
+        css::uno::Reference<ooo::vba::excel::XWorkbook> xWorkbook(aModuleInfo.ModuleObject, css::uno::UNO_QUERY);
+        if (xWorkbook.is())
+        {
+            nWorkbookIndex = i;
+            rLibraryMap[nCurrentId] = i;
+            ++nCurrentId;
+        }
+    }
+
+    // then the remaining modules
+    for (sal_Int32 i = 0; i < n; ++i)
+    {
+        if (i == nWorkbookIndex)
+            continue;
+
+        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
+        if (aModuleInfo.ModuleType == 4)
+        {
+            rLibraryMap[nCurrentId] = i;
+            ++nCurrentId;
+        }
+    }
+}
+
 }
 
 void addFileStreamToSotStream(const OUString& rPath, SotStorageStream* pStream)
@@ -807,6 +874,10 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
     }
     css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
     sal_Int32 n = aElementNames.getLength(); // get the number of modules
+    // export the elements in the order MSO expects them
+    // we store the index of the
+    std::vector<sal_Int32> aLibraryMap(n, 0);
+    getCorrectExportOrder(xNameContainer, aLibraryMap);
 
     // start here with the VBA export
     SotStorage* pVBAStream = pRootStorage->OpenSotStorage("VBA", STREAM_READWRITE);
@@ -820,27 +891,21 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
     OUString aProjectwmPath = "/home/moggi/Documents/testfiles/vba/PROJECTwm";
     addFileStreamToSotStream(aProjectwmPath, pPROJECTwmStream);
 #else
-    exportPROJECTwmStream(*pPROJECTwmStream, aElementNames);
+    exportPROJECTwmStream(*pPROJECTwmStream, aElementNames, aLibraryMap);
 #endif
 
 #if VBA_USE_ORIGINAL_DIR_STREAM
     OUString aDirPath = "/home/moggi/Documents/testfiles/vba/VBA/dir";
     addFileStreamToSotStream(aDirPath, pDirStream);
 #else
-    std::vector<SotStorageStream*> aModuleStreams;
-    exportDirStream(*pDirStream, xNameContainer);
-    aModuleStreams.reserve(n);
-    for (sal_Int32 i = 0; i < n; ++i)
-    {
-        aModuleStreams.push_back(pVBAStream->OpenSotStream(aElementNames[i], STREAM_READWRITE));
-    }
+    exportDirStream(*pDirStream, xNameContainer, aLibraryMap);
 #endif
 
 #if VBA_USE_ORIGINAL_PROJECT_STREAM
     OUString aProjectPath = "/home/moggi/Documents/testfiles/vba/PROJECT";
     addFileStreamToSotStream(aProjectPath, pPROJECTStream);
 #else
-    exportPROJECTStream(*pPROJECTStream, xNameContainer, getProjectName());
+    exportPROJECTStream(*pPROJECTStream, xNameContainer, getProjectName(), aLibraryMap);
 #endif
 
 #if VBA_USE_ORIGINAL_VBA_PROJECT
@@ -877,12 +942,14 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
     css::uno::Reference<css::script::vba::XVBAModuleInfo> xModuleInfo(xNameContainer, css::uno::UNO_QUERY);
     for (sal_Int32 i = 0; i < n; ++i)
     {
-        css::uno::Any aCode = xNameContainer->getByName(aElementNames[i]);
-        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
+        const OUString& rModuleName = aElementNames[aLibraryMap[i]];
+        SotStorageStream* pModuleStream = pVBAStream->OpenSotStream(rModuleName, STREAM_READWRITE);
+        css::uno::Any aCode = xNameContainer->getByName(rModuleName);
+        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(rModuleName);
         OUString aSourceCode;
         aCode >>= aSourceCode;
-        exportModuleStream(*aModuleStreams[i], aSourceCode, aElementNames[i], aModuleInfo.ModuleType);
-        aModuleStreams[i]->Commit();
+        exportModuleStream(*pModuleStream, aSourceCode, rModuleName, aModuleInfo.ModuleType);
+        pModuleStream->Commit();
     }
 
 #endif
commit a5d761723f6aca26c6c05182bc5ba184576e29a1
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Sep 14 02:47:58 2015 +0200

    move a little bit closer to the export from MSO
    
    Change-Id: I378d96f65fbeb2c529eae6a9c90ef7c0ecccc97d

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 064a1e4..703ddfd 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -760,8 +760,15 @@ void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XN
 
     // section 2.3.1.18 HostExtenders
     exportString(rStrm, "[Host Extender Info]\r\n"
-                        "&H00000001={3832D640-CF90-11CF-8E43-00A0C911005A};VBE;&H00000000\r\n"
+                        "&H00000001={3832D640-CF90-11CF-8E43-00A0C911005A};VBE;&H00000000\r\n\r\n"
     );
+
+    // section 2.3.1.19 ProjectWorkspace
+    exportString(rStrm, "[Workspace]\r\n");
+    for (sal_Int32 i = 0; i < n; ++i)
+    {
+        exportString(rStrm, aElementNames[i] + "=0, 0, 0, 0, C\r\n");
+    }
 }
 
 // section 2.3.3.1 NAMEMAP
commit f435b78866f8ae7959c0cbf1484e6bfca8084eba
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Sep 14 02:46:29 2015 +0200

    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

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index d31c1e9..064a1e4 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();
     }
 
commit 57f6d49d8e83e39b7d83b9c2e48900538bf88f05
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Sep 14 02:44:36 2015 +0200

    introduce a special vba export debug mode
    
    In that mode we can write back existing files as part of the vba stream.
    That allows us to create files that contain to some part out of existing
    VBA streams. So we have streams that we know are correct and streams
    that are new from us.
    
    Change-Id: I1be04207f887146d9824f97d17866fda440f93a7

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index a0fb91a..d31c1e9 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -40,6 +40,10 @@
 #endif
 
 #define VBA_EXPORT_DEBUG 0
+#define VBA_USE_ORIGINAL_WM_STREAM 0
+#define VBA_USE_ORIGINAL_DIR_STREAM 0
+#define VBA_USE_ORIGINAL_PROJECT_STREAM 0
+#define VBA_USE_ORIGINAL_VBA_PROJECT 0
 
 namespace {
 
@@ -772,6 +776,12 @@ void exportPROJECTwmStream(SvStream& rStrm, const css::uno::Sequence<OUString>&
 
 }
 
+void addFileStreamToSotStream(const OUString& rPath, SotStorageStream* pStream)
+{
+    SvFileStream aFileStream(rPath, STREAM_READWRITE);
+    pStream->WriteStream(aFileStream);
+}
+
 void VbaExport::exportVBA(SotStorage* pRootStorage)
 {
     css::uno::Reference<css::container::XNameContainer> xNameContainer = getBasicLibrary();
@@ -784,35 +794,84 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
     // start here with the VBA export
     SotStorage* pVBAStream = pRootStorage->OpenSotStorage("VBA", STREAM_READWRITE);
     SotStorageStream* pDirStream = pVBAStream->OpenSotStream("dir", STREAM_READWRITE);
+
+    SotStorageStream* pVBAProjectStream = pVBAStream->OpenSotStream("_VBA_PROJECT", STREAM_READWRITE);
+    SotStorageStream* pPROJECTStream = pRootStorage->OpenSotStream("PROJECT", STREAM_READWRITE);
+    SotStorageStream* pPROJECTwmStream = pRootStorage->OpenSotStream("PROJECTwm", STREAM_READWRITE);
+
+#if VBA_USE_ORIGINAL_WM_STREAM
+    OUString aProjectwmPath = "/home/moggi/Documents/testfiles/vba/PROJECTwm";
+    addFileStreamToSotStream(aProjectwmPath, pPROJECTwmStream);
+#else
+    exportPROJECTwmStream(*pPROJECTwmStream, aElementNames);
+#endif
+
+#if VBA_USE_ORIGINAL_DIR_STREAM
+    OUString aDirPath = "/home/moggi/Documents/testfiles/vba/VBA/dir";
+    addFileStreamToSotStream(aDirPath, pDirStream);
+#else
     std::vector<SotStorageStream*> aModuleStreams;
+    exportDirStream(*pDirStream, xNameContainer);
     aModuleStreams.reserve(n);
     for (sal_Int32 i = 0; i < n; ++i)
     {
         aModuleStreams.push_back(pVBAStream->OpenSotStream(aElementNames[i], STREAM_READWRITE));
     }
-    SotStorageStream* pVBAProjectStream = pVBAStream->OpenSotStream("_VBA_PROJECT", STREAM_READWRITE);
-    SotStorageStream* pPROJECTStream = pRootStorage->OpenSotStream("PROJECT", STREAM_READWRITE);
-    SotStorageStream* pPROJECTwmStream = pRootStorage->OpenSotStream("PROJECTwm", STREAM_READWRITE);
+#endif
+
+#if VBA_USE_ORIGINAL_PROJECT_STREAM
+    OUString aProjectPath = "/home/moggi/Documents/testfiles/vba/PROJECT";
+    addFileStreamToSotStream(aProjectPath, pPROJECTStream);
+#else
+    exportPROJECTStream(*pPROJECTStream, xNameContainer, getProjectName());
+#endif
+
+#if VBA_USE_ORIGINAL_VBA_PROJECT
+    OUString a_VBA_ProjectPath = "/home/moggi/Documents/testfiles/vba/VBA/_VBA_PROJECT";
+    addFileStreamToSotStream(a_VBA_ProjectPath, pVBAProjectStream);
+#else
+    exportVBAProjectStream(*pVBAProjectStream);
+#endif
 
+#if VBA_USE_ORIGINAL_DIR_STREAM
+    OUString aModule1Path = "/home/moggi/Documents/testfiles/vba/VBA/Module1";
+    OUString aSheet1Path = "/home/moggi/Documents/testfiles/vba/VBA/Sheet1";
+    OUString aSheet2Path = "/home/moggi/Documents/testfiles/vba/VBA/Sheet2";
+    OUString aSheet3Path = "/home/moggi/Documents/testfiles/vba/VBA/Sheet3";
+    OUString aWorkbookPath = "/home/moggi/Documents/testfiles/vba/VBA/ThisWorkbook";
+    SotStorageStream* pModule1Stream = pVBAStream->OpenSotStream("Module1", STREAM_READWRITE);
+    SotStorageStream* pSheet1Stream = pVBAStream->OpenSotStream("Sheet1", STREAM_READWRITE);
+    SotStorageStream* pSheet2Stream = pVBAStream->OpenSotStream("Sheet2", STREAM_READWRITE);
+    SotStorageStream* pSheet3Stream = pVBAStream->OpenSotStream("Sheet3", STREAM_READWRITE);
+    SotStorageStream* pWorkbookStream = pVBAStream->OpenSotStream("ThisWorkbook", STREAM_READWRITE);
+    addFileStreamToSotStream(aModule1Path, pModule1Stream);
+    addFileStreamToSotStream(aSheet1Path, pSheet1Stream);
+    addFileStreamToSotStream(aSheet2Path, pSheet2Stream);
+    addFileStreamToSotStream(aSheet3Path, pSheet3Stream);
+    addFileStreamToSotStream(aWorkbookPath, pWorkbookStream);
+
+    pModule1Stream->Commit();
+    pSheet1Stream->Commit();
+    pSheet2Stream->Commit();
+    pSheet3Stream->Commit();
+    pWorkbookStream->Commit();
+#else
 
-    // export
-    exportDirStream(*pDirStream, xNameContainer);
+    css::uno::Reference<css::script::vba::XVBAModuleInfo> xModuleInfo(xNameContainer, css::uno::UNO_QUERY);
     for (sal_Int32 i = 0; i < n; ++i)
     {
         css::uno::Any aCode = xNameContainer->getByName(aElementNames[i]);
+        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
         OUString aSourceCode;
         aCode >>= aSourceCode;
         exportModuleStream(*aModuleStreams[i], aSourceCode, aElementNames[i]);
+        aModuleStreams[i]->Commit();
     }
-    exportVBAProjectStream(*pVBAProjectStream);
-    exportPROJECTStream(*pPROJECTStream, xNameContainer, getProjectName());
-    exportPROJECTwmStream(*pPROJECTwmStream, aElementNames);
+
+#endif
 
     pVBAProjectStream->Commit();
-    for(sal_Int32 i = 0; i < n; i++)
-    {
-        aModuleStreams[i]->Commit();
-    }
+
     pDirStream->Commit();
     pVBAStream->Commit();
     pPROJECTStream->Commit();
commit 0e916b4143b2c46fec6df25cce6f14b595d5b023
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Sep 12 02:29:43 2015 +0200

    don't use VBA_EXPORT_DEBUG in master
    
    Change-Id: I89ae01c34f6a7faf62b97cf28220f7700a7241b7

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 88f74b4c..a0fb91a 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -39,7 +39,7 @@
 #define CODEPAGE RTL_TEXTENCODING_MS_1252
 #endif
 
-#define VBA_EXPORT_DEBUG 1
+#define VBA_EXPORT_DEBUG 0
 
 namespace {
 


More information about the Libreoffice-commits mailing list