[Libreoffice-commits] core.git: 78 commits - basctl/inc basctl/source include/oox include/svtools officecfg/registry oox/CppunitTest_oox_vba_compression.mk oox/Library_oox.mk oox/Module_oox.mk oox/qa oox/source sc/source sfx2/source uui/source

Markus Mohrhard markus.mohrhard at googlemail.com
Wed Sep 9 19:53:20 PDT 2015


 basctl/inc/basidesh.hrc                                  |    1 
 basctl/source/basicide/basidesh.cxx                      |    6 
 basctl/source/basicide/basidesh.src                      |    4 
 include/oox/ole/vbaexport.hxx                            |  116 ++
 include/svtools/sfxecode.hxx                             |    1 
 officecfg/registry/schema/org/openoffice/Office/Calc.xcs |    8 
 oox/CppunitTest_oox_vba_compression.mk                   |   50 
 oox/Library_oox.mk                                       |    1 
 oox/Module_oox.mk                                        |    1 
 oox/qa/unit/data/vba/complex1.bin                        |binary
 oox/qa/unit/data/vba/reference/complex1.bin              |binary
 oox/qa/unit/data/vba/reference/simple1.bin               |binary
 oox/qa/unit/data/vba/reference/simple2.bin               |binary
 oox/qa/unit/data/vba/reference/simple3.bin               |    1 
 oox/qa/unit/data/vba/reference/spec321.bin               |binary
 oox/qa/unit/data/vba/reference/spec322.bin               |binary
 oox/qa/unit/data/vba/reference/spec323.bin               |binary
 oox/qa/unit/data/vba/simple1.bin                         |binary
 oox/qa/unit/data/vba/simple2.bin                         |binary
 oox/qa/unit/data/vba/simple3.bin                         |    1 
 oox/qa/unit/data/vba/spec321.bin                         |    1 
 oox/qa/unit/data/vba/spec322.bin                         |    1 
 oox/qa/unit/data/vba/spec323.bin                         |    1 
 oox/qa/unit/vba_compression.cxx                          |  250 ++++
 oox/source/ole/vbaexport.cxx                             |  857 +++++++++++++++
 sc/source/filter/excel/expop2.cxx                        |   38 
 sc/source/filter/excel/xestream.cxx                      |   19 
 sfx2/source/doc/guisaveas.cxx                            |   35 
 uui/source/iahndl.cxx                                    |   25 
 uui/source/ids.hrc                                       |    1 
 uui/source/ids.src                                       |    5 
 31 files changed, 1344 insertions(+), 79 deletions(-)

New commits:
commit d0ebf4043a53918e176c75e5afa92d98c3ace32c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Sep 10 01:16:03 2015 +0200

    always write \r\n instead of \n for source code in vba export
    
    Change-Id: Ib036ade472b9da4e12153cd0af796df29e750015

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 28ac61f..9b1e751 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -628,7 +628,8 @@ void exportModuleStream(SvStream& rStrm, const OUString& rSourceCode, const OUSt
     OUString aSourceCode = rSourceCode.replaceFirst("Option VBASupport 1\n", "");
     sal_Int32 nPos = aSourceCode.indexOf("Rem Attribute VBA_ModuleType=");
     sal_Int32 nEndPos = aSourceCode.indexOf("\n", nPos);
-    aSourceCode = aSourceCode.replaceAt(nPos, nEndPos - nPos, "");
+    aSourceCode = aSourceCode.replaceAt(nPos, nEndPos - nPos+1, "");
+    aSourceCode = aSourceCode.replaceAll("\n", "\r\n");
     exportString(aModuleStream, aSourceCode);
     aModuleStream.Seek(0);
 
commit 2182220582fc0fc69bd806c08ad92f6219b05472
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Sep 9 18:46:47 2015 +0200

    remove vba header from source code
    
    We add the header during import but should not export it.
    
    Change-Id: I2bab6b9dda50dab396fb8023212b1c6f0f035401

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 01c344a..28ac61f 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -620,11 +620,15 @@ void exportDirStream(SvStream& rStrm, css::uno::Reference<css::container::XNameC
 }
 
 // section 2.3.4.3 Module Stream
-void exportModuleStream(SvStream& rStrm, const OUString& aSourceCode, const OUString& aElementName)
+void exportModuleStream(SvStream& rStrm, const OUString& rSourceCode, const OUString& aElementName)
 {
     SvMemoryStream aModuleStream(4096, 4096);
 
     exportString(aModuleStream, "Attribute VB_Name = \"" + aElementName + "\"\r\n");
+    OUString aSourceCode = rSourceCode.replaceFirst("Option VBASupport 1\n", "");
+    sal_Int32 nPos = aSourceCode.indexOf("Rem Attribute VBA_ModuleType=");
+    sal_Int32 nEndPos = aSourceCode.indexOf("\n", nPos);
+    aSourceCode = aSourceCode.replaceAt(nPos, nEndPos - nPos, "");
     exportString(aModuleStream, aSourceCode);
     aModuleStream.Seek(0);
 
commit ecfcd036603e39940c2a11a81b3fccf0bbddc152
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Sep 9 18:39:17 2015 +0200

    pass objects by const reference
    
    Change-Id: I67fb51c54edbcb877a2f840f30e93910909748ab

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 028d8ae..01c344a 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -432,7 +432,7 @@ void writePROJECTINFORMATION(SvStream& rStrm)
 }
 
 // section 2.3.4.2.2.2
-void writeREFERENCENAME(SvStream& rStrm, const OUString name)
+void writeREFERENCENAME(SvStream& rStrm, const OUString& name)
 {
     rStrm.WriteUInt16(0x0016); // id
     sal_Int32 size = name.getLength();
@@ -445,7 +445,7 @@ void writeREFERENCENAME(SvStream& rStrm, const OUString name)
 }
 
 // section 2.3.4.2.2.5
-void writeREFERENCEREGISTERED(SvStream& rStrm, const OUString libid)
+void writeREFERENCEREGISTERED(SvStream& rStrm, const OUString& libid)
 {
     rStrm.WriteUInt16(0x000D); // id
     sal_Int32 sizeOfLibid = libid.getLength();
@@ -458,7 +458,7 @@ void writeREFERENCEREGISTERED(SvStream& rStrm, const OUString libid)
 }
 
 // section 2.3.4.2.2.1
-void writeREFERENCE(SvStream& rStrm, const OUString name, const OUString libid)
+void writeREFERENCE(SvStream& rStrm, const OUString& name, const OUString& libid)
 {
     writeREFERENCENAME(rStrm, name);
     writeREFERENCEREGISTERED(rStrm, libid);
@@ -481,7 +481,7 @@ void writePROJECTCOOKIE(SvStream& rStrm)
 }
 
 // section 2.3.4.2.3.2.1
-void writeMODULENAME(SvStream& rStrm, const OUString name)
+void writeMODULENAME(SvStream& rStrm, const OUString& name)
 {
     rStrm.WriteUInt16(0x0019); // id
     sal_Int32 n = name.getLength(); // sizeOfModuleName
@@ -490,7 +490,7 @@ void writeMODULENAME(SvStream& rStrm, const OUString name)
 }
 
 // section 2.3.4.2.3.2.2
-void writeMODULENAMEUNICODE(SvStream& rStrm, const OUString name)
+void writeMODULENAMEUNICODE(SvStream& rStrm, const OUString& name)
 {
     rStrm.WriteUInt16(0x0047); // id
     sal_Int32 n = name.getLength() * 2; // sizeOfModuleNameUnicode // TODO: better calculation for unicode string length
@@ -499,7 +499,7 @@ void writeMODULENAMEUNICODE(SvStream& rStrm, const OUString name)
 }
 
 // section 2.3.4.2.3.2.3
-void writeMODULESTREAMNAME(SvStream& rStrm, const OUString streamName)
+void writeMODULESTREAMNAME(SvStream& rStrm, const OUString& streamName)
 {
     rStrm.WriteUInt16(0x001A); // id
     sal_Int32 n = streamName.getLength(); // sizeOfStreamName
@@ -554,7 +554,7 @@ void writeMODULETYPE(SvStream& rStrm, const sal_uInt16 type)
 }
 
 // section 2.3.4.2.3.2
-void writePROJECTMODULE(SvStream& rStrm, const OUString name, const OUString streamName, sal_uInt32 offset, const sal_uInt16 type)
+void writePROJECTMODULE(SvStream& rStrm, const OUString& name, const OUString& streamName, sal_uInt32 offset, const sal_uInt16 type)
 {
     writeMODULENAME(rStrm, name);
     writeMODULENAMEUNICODE(rStrm, name);
@@ -620,7 +620,7 @@ void exportDirStream(SvStream& rStrm, css::uno::Reference<css::container::XNameC
 }
 
 // section 2.3.4.3 Module Stream
-void exportModuleStream(SvStream& rStrm, OUString aSourceCode, OUString aElementName)
+void exportModuleStream(SvStream& rStrm, const OUString& aSourceCode, const OUString& aElementName)
 {
     SvMemoryStream aModuleStream(4096, 4096);
 
@@ -683,7 +683,7 @@ OString generateGUIDString()
 }
 
 // section 2.3.1 PROJECT Stream
-void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer, OUString projectName)
+void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer, const OUString& projectName)
 {
     css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
     sal_Int32 n = aElementNames.getLength();
@@ -736,7 +736,7 @@ void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XN
 }
 
 // section 2.3.3.1 NAMEMAP
-void writeNAMEMAP(SvStream& rStrm, css::uno::Sequence<OUString> rElementNames)
+void writeNAMEMAP(SvStream& rStrm, const css::uno::Sequence<OUString>& rElementNames)
 {
     int n = rElementNames.getLength();
     for(sal_Int32 i = 0; i < n; ++i)
@@ -749,7 +749,7 @@ void writeNAMEMAP(SvStream& rStrm, css::uno::Sequence<OUString> rElementNames)
 }
 
 // section 2.3.3 PROJECTwm Stream
-void exportPROJECTwmStream(SvStream& rStrm, css::uno::Sequence<OUString> rElementNames)
+void exportPROJECTwmStream(SvStream& rStrm, const css::uno::Sequence<OUString>& rElementNames)
 {
     writeNAMEMAP(rStrm, rElementNames);
     rStrm.WriteUInt16(0x0000); // terminator
commit 9fb1ad5abe72a4df5537d2efe9b3296d24029d11
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Wed Sep 9 21:33:31 2015 +0530

    Export the PROJECT stream
    
    Change-Id: I6cc72602c93ac6da64ca32a3ade526d089ce583a

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index db44d41..028d8ae 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -22,6 +22,10 @@
 
 #include <sot/storage.hxx>
 
+#include <rtl/uuid.h>
+
+#include <comphelper/string.hxx>
+
 #define USE_UTF8_CODEPAGE 0
 #if USE_UTF8_CODEPAGE
 #define CODEPAGE_MS 65001
@@ -648,6 +652,89 @@ void exportVBAProjectStream(SvStream& rStrm)
     rStrm.WriteUInt16(0x0000); // Undefined
 }
 
+OString createHexStringFromDigit(sal_uInt8 nDigit)
+{
+    OString aString = OString::number( nDigit, 16 );
+    if(aString.getLength() == 1)
+        aString = aString + OString::number(0);
+    return aString;
+}
+
+OString createGuidStringFromInt(sal_uInt8 nGuid[16])
+{
+    OStringBuffer aBuffer;
+    aBuffer.append('{');
+    for(size_t i = 0; i < 16; ++i)
+    {
+        aBuffer.append(createHexStringFromDigit(nGuid[i]));
+        if(i == 3|| i == 5 || i == 7 || i == 9 )
+            aBuffer.append('-');
+    }
+    aBuffer.append('}');
+    OString aString = aBuffer.makeStringAndClear();
+    return aString.toAsciiUpperCase();
+}
+
+OString generateGUIDString()
+{
+    sal_uInt8 nGuid[16];
+    rtl_createUuid(nGuid, NULL, true);
+    return createGuidStringFromInt(nGuid);
+}
+
+// section 2.3.1 PROJECT Stream
+void exportPROJECTStream(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer, OUString projectName)
+{
+    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);
+    assert(xModuleInfo.is());
+
+    // section 2.3.1.1ProjectProperties
+
+    // section 2.3.1.2 ProjectId
+    exportString(rStrm, "ID=\"");
+    rStrm.WriteOString(generateGUIDString());
+    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]);
+        if(aModuleInfo.ModuleType == 1)
+        {
+            exportString(rStrm, "Module=" + aElementNames[i] + "\r\n");
+        }
+        else if(aModuleInfo.ModuleType == 4)
+        {
+            exportString(rStrm, "Document=" + aElementNames[i] + "/&H00000000\r\n");
+        }
+    }
+
+    // section 2.3.1.11 ProjectName
+    exportString(rStrm, "Name=\"" + projectName + "\"\r\n");
+
+    // section 2.3.1.12 ProjectHelpId
+    exportString(rStrm, "HelpContextID=\"0\"\r\n");
+
+    // section 2.3.1.14 ProjectVersionCompat32
+    exportString(rStrm, "VersionCompatible32=\"393222000\"\r\n");
+
+    // section 2.3.1.15 ProjectProtectionState
+    exportString(rStrm, "CMG=\"BEBC9256EEAAA8AEA8AEA8AEA8AE\"\r\n");
+
+    // section 2.3.1.16 ProjectPassword
+    exportString(rStrm, "DPB=\"7C7E5014B0D3B1D3B1D3\"\r\n");
+
+    // section 2.3.1.17 ProjectVisibilityState
+    exportString(rStrm, "GC=\"3A3816DAD5DBD5DB2A\"\r\n\r\n");
+
+    // section 2.3.1.18 HostExtenders
+    exportString(rStrm, "[Host Extender Info]\r\n"
+                        "&H00000001={3832D640-CF90-11CF-8E43-00A0C911005A};VBE;&H00000000\r\n"
+    );
+}
+
 // section 2.3.3.1 NAMEMAP
 void writeNAMEMAP(SvStream& rStrm, css::uno::Sequence<OUString> rElementNames)
 {
@@ -685,6 +772,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
         pModuleStream[i] = 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);
 
 
@@ -698,6 +786,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
         exportModuleStream(*pModuleStream[i], aSourceCode, aElementNames[i]);
     }
     exportVBAProjectStream(*pVBAProjectStream);
+    exportPROJECTStream(*pPROJECTStream, xNameContainer, getProjectName());
     exportPROJECTwmStream(*pPROJECTwmStream, aElementNames);
 
     pVBAProjectStream->Commit();
@@ -707,6 +796,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
     }
     pDirStream->Commit();
     pVBAStream->Commit();
+    pPROJECTStream->Commit();
     pPROJECTwmStream->Commit();
     pRootStorage->Commit();
 }
commit e763446ae53c3ea7907b6ffdc0be74a83af13db5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Sep 9 04:59:46 2015 +0200

    the correct stream name is PROJECTwm
    
    Change-Id: I82d12a9451670ab181996d3ab8ec1a8fa32ce86c

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 8f65f5c..db44d41 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -685,7 +685,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
         pModuleStream[i] = pVBAStream->OpenSotStream(aElementNames[i], STREAM_READWRITE);
     }
     SotStorageStream* pVBAProjectStream = pVBAStream->OpenSotStream("_VBA_PROJECT", STREAM_READWRITE);
-    SotStorageStream* pPROJECTwmStream = pRootStorage->OpenSotStream("PROJECT", STREAM_READWRITE);
+    SotStorageStream* pPROJECTwmStream = pRootStorage->OpenSotStream("PROJECTwm", STREAM_READWRITE);
 
 
     // export
commit 86283974755da47aec47779c18ccddd794d5fc4f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Sep 9 03:54:51 2015 +0200

    copy the vba stream to the xlsx file
    
    Change-Id: I48d4a37a35e047b6f26b7d1da03e2d423cab1241

diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 76da6b5..1184cfe 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -59,6 +59,7 @@
 
 #include <com/sun/star/task/XStatusIndicator.hpp>
 #include <memory>
+#include <comphelper/storagehelper.hxx>
 
 #define DEBUG_XL_ENCRYPTION 0
 
@@ -1094,9 +1095,15 @@ bool XclExpXmlStream::exportDocument()
     if (aExport.containsVBAProject())
     {
         const OUString aVbaStreamLocation("/tmp/vba_out.bin");
-        SvFileStream aVbaStream(aVbaStreamLocation, STREAM_READWRITE);
+        SvMemoryStream aVbaStream(4096, 4096);
         tools::SvRef<SotStorage> pVBAStorage(new SotStorage(aVbaStream));
         aExport.exportVBA(pVBAStorage);
+        aVbaStream.Seek(0);
+        css::uno::Reference<css::io::XInputStream> xVBAStream(
+                new utl::OInputStreamWrapper(aVbaStream));
+        css::uno::Reference<css::io::XOutputStream> xVBAOutput =
+            openFragmentStream("xl/vbaProject.bin", "VBA");
+        comphelper::OStorageHelper::CopyInputToOutput(xVBAStream, xVBAOutput);
     }
 
     // destruct at the end of the block
commit 0c6da7fb3eb951fcd0c8fb31dbff1562f75289e9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Sep 9 03:22:35 2015 +0200

    remove unused using statements
    
    Change-Id: I096a6f61677b451074bf3626f21c694ef7193bc1

diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 972dd31..76da6b5 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -62,13 +62,11 @@
 
 #define DEBUG_XL_ENCRYPTION 0
 
-using ::com::sun::star::embed::XStorage;
 using ::com::sun::star::lang::XSingleServiceFactory;
 using ::com::sun::star::registry::InvalidRegistryException;
 using ::com::sun::star::registry::XRegistryKey;
 using ::com::sun::star::uno::Exception;
 using ::com::sun::star::uno::XInterface;
-using ::utl::OStreamWrapper;
 using ::std::vector;
 
 using namespace com::sun::star;
commit a2d3089b5824d70917aaf7f1be7895db0f1c837e
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Mon Sep 7 18:35:18 2015 +0530

    Export PROJECTwm stream
    
    Change-Id: I06515a31b2587d3b3aa5bda03b47d228c563db54

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 49713a2..8f65f5c 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -648,6 +648,26 @@ void exportVBAProjectStream(SvStream& rStrm)
     rStrm.WriteUInt16(0x0000); // Undefined
 }
 
+// section 2.3.3.1 NAMEMAP
+void writeNAMEMAP(SvStream& rStrm, css::uno::Sequence<OUString> rElementNames)
+{
+    int n = rElementNames.getLength();
+    for(sal_Int32 i = 0; i < n; ++i)
+    {
+        exportString(rStrm, rElementNames[i]);
+        rStrm.WriteUInt8(0x00); // terminator
+        exportUTF16String(rStrm, rElementNames[i]);
+        rStrm.WriteUInt16(0x0000); // terminator
+    }
+}
+
+// section 2.3.3 PROJECTwm Stream
+void exportPROJECTwmStream(SvStream& rStrm, css::uno::Sequence<OUString> rElementNames)
+{
+    writeNAMEMAP(rStrm, rElementNames);
+    rStrm.WriteUInt16(0x0000); // terminator
+}
+
 }
 
 void VbaExport::exportVBA(SotStorage* pRootStorage)
@@ -665,6 +685,8 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
         pModuleStream[i] = pVBAStream->OpenSotStream(aElementNames[i], STREAM_READWRITE);
     }
     SotStorageStream* pVBAProjectStream = pVBAStream->OpenSotStream("_VBA_PROJECT", STREAM_READWRITE);
+    SotStorageStream* pPROJECTwmStream = pRootStorage->OpenSotStream("PROJECT", STREAM_READWRITE);
+
 
     // export
     exportDirStream(*pDirStream, xNameContainer);
@@ -676,6 +698,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
         exportModuleStream(*pModuleStream[i], aSourceCode, aElementNames[i]);
     }
     exportVBAProjectStream(*pVBAProjectStream);
+    exportPROJECTwmStream(*pPROJECTwmStream, aElementNames);
 
     pVBAProjectStream->Commit();
     for(sal_Int32 i = 0; i < n; i++)
@@ -684,6 +707,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
     }
     pDirStream->Commit();
     pVBAStream->Commit();
+    pPROJECTwmStream->Commit();
     pRootStorage->Commit();
 }
 
commit 32b7619ced25de5f215b7f31902dc1cf0537df98
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Sat Sep 5 17:18:49 2015 +0530

    Fix the module export code
    
    Change-Id: I56d239927d8a83b2b71f52da36394710a52b0a06

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 3435e36..49713a2 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -615,15 +615,17 @@ void exportDirStream(SvStream& rStrm, css::uno::Reference<css::container::XNameC
     aCompression.write();
 }
 
-void exportModuleStream(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer, OUString aSourceCode)
+// section 2.3.4.3 Module Stream
+void exportModuleStream(SvStream& rStrm, OUString aSourceCode, OUString aElementName)
 {
     SvMemoryStream aModuleStream(4096, 4096);
 
+    exportString(aModuleStream, "Attribute VB_Name = \"" + aElementName + "\"\r\n");
     exportString(aModuleStream, aSourceCode);
     aModuleStream.Seek(0);
 
 #if VBA_EXPORT_DEBUG
-    const OUString aModuleFileName("/tmp/vba_module_out.bin");
+    OUString aModuleFileName("/tmp/vba_" + aElementName + "_out.bin");
     SvFileStream aModuleStreamDebug(aModuleFileName, STREAM_READWRITE);
     aModuleStreamDebug.WriteStream(aModuleStream);
     aModuleStream.Seek(0);
@@ -637,6 +639,7 @@ void exportModuleStream(SvStream& rStrm, css::uno::Reference<css::container::XNa
     aCompression.write();
 }
 
+// section 2.3.4.1 _VBA_PROJECT Stream
 void exportVBAProjectStream(SvStream& rStrm)
 {
     rStrm.WriteUInt16(0x61CC); // Reserved1
@@ -670,7 +673,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
         css::uno::Any aCode = xNameContainer->getByName(aElementNames[i]);
         OUString aSourceCode;
         aCode >>= aSourceCode;
-        exportModuleStream(*pModuleStream[i], xNameContainer, aSourceCode);
+        exportModuleStream(*pModuleStream[i], aSourceCode, aElementNames[i]);
     }
     exportVBAProjectStream(*pVBAProjectStream);
 
commit 4f4a668e04bdd68655a0f574027f486cea953857
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Sat Sep 5 15:22:11 2015 +0530

    Export the module streams
    
    Change-Id: I132c71e06307dbb0a381d85a6d2ba7a9bd1dd5ec

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 6726f61..3435e36 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -615,6 +615,28 @@ void exportDirStream(SvStream& rStrm, css::uno::Reference<css::container::XNameC
     aCompression.write();
 }
 
+void exportModuleStream(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer, OUString aSourceCode)
+{
+    SvMemoryStream aModuleStream(4096, 4096);
+
+    exportString(aModuleStream, aSourceCode);
+    aModuleStream.Seek(0);
+
+#if VBA_EXPORT_DEBUG
+    const OUString aModuleFileName("/tmp/vba_module_out.bin");
+    SvFileStream aModuleStreamDebug(aModuleFileName, STREAM_READWRITE);
+    aModuleStreamDebug.WriteStream(aModuleStream);
+    aModuleStream.Seek(0);
+#endif
+
+    // the stream for the compression
+    SvMemoryStream aMemoryStream(4096, 4096);
+    aMemoryStream.WriteStream(aModuleStream);
+
+    VBACompression aCompression(rStrm, aModuleStream);
+    aCompression.write();
+}
+
 void exportVBAProjectStream(SvStream& rStrm)
 {
     rStrm.WriteUInt16(0x61CC); // Reserved1
@@ -627,18 +649,36 @@ void exportVBAProjectStream(SvStream& rStrm)
 
 void VbaExport::exportVBA(SotStorage* pRootStorage)
 {
+    css::uno::Reference<css::container::XNameContainer> xNameContainer = getBasicLibrary();
+    css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
+    sal_Int32 n = aElementNames.getLength(); // get the number of modules
+
     // start here with the VBA export
     SotStorage* pVBAStream = pRootStorage->OpenSotStorage("VBA", STREAM_READWRITE);
     SotStorageStream* pDirStream = pVBAStream->OpenSotStream("dir", STREAM_READWRITE);
+    SotStorageStream* pModuleStream[n];
+    for (sal_Int32 i = 0; i < n; ++i)
+    {
+        pModuleStream[i] = pVBAStream->OpenSotStream(aElementNames[i], STREAM_READWRITE);
+    }
     SotStorageStream* pVBAProjectStream = pVBAStream->OpenSotStream("_VBA_PROJECT", STREAM_READWRITE);
 
-    css::uno::Reference<css::container::XNameContainer> xNameContainer = getBasicLibrary();
-
     // export
     exportDirStream(*pDirStream, xNameContainer);
+    for (sal_Int32 i = 0; i < n; ++i)
+    {
+        css::uno::Any aCode = xNameContainer->getByName(aElementNames[i]);
+        OUString aSourceCode;
+        aCode >>= aSourceCode;
+        exportModuleStream(*pModuleStream[i], xNameContainer, aSourceCode);
+    }
     exportVBAProjectStream(*pVBAProjectStream);
 
     pVBAProjectStream->Commit();
+    for(sal_Int32 i = 0; i < n; i++)
+    {
+        pModuleStream[i]->Commit();
+    }
     pDirStream->Commit();
     pVBAStream->Commit();
     pRootStorage->Commit();
commit c9efb849fa99c3b0bf9b67920bde8ccfcbfae768
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Sat Sep 5 08:26:56 2015 +0530

    Make the existing code generic
    
    Modify the calls to the writePROJECTMODULE method within
    the writePROJECTMODULES method which are currently
    specific to the example document
    
    Change-Id: I20db96e6c4eb1009f7bc81bec3490b9084532854

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 10bf03b..6726f61 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -540,9 +540,9 @@ void writeMODULECOOKIE(SvStream& rStrm)
 }
 
 // section 2.3.4.2.3.2.8
-void writeMODULETYPE(SvStream& rStrm, const OUString type)
+void writeMODULETYPE(SvStream& rStrm, const sal_uInt16 type)
 {
-    if(type == "procedure")
+    if(type == 1)
         rStrm.WriteUInt16(0x0021); // id for a procedural module
     else
         rStrm.WriteUInt16(0x0022); // id for document, class or design module
@@ -550,7 +550,7 @@ void writeMODULETYPE(SvStream& rStrm, const OUString type)
 }
 
 // section 2.3.4.2.3.2
-void writePROJECTMODULE(SvStream& rStrm, const OUString name, const OUString streamName, sal_uInt32 offset, const OUString type)
+void writePROJECTMODULE(SvStream& rStrm, const OUString name, const OUString streamName, sal_uInt32 offset, const sal_uInt16 type)
 {
     writeMODULENAME(rStrm, name);
     writeMODULENAMEUNICODE(rStrm, name);
@@ -565,29 +565,35 @@ void writePROJECTMODULE(SvStream& rStrm, const OUString name, const OUString str
 }
 
 // section 2.3.4.2.3
-void writePROJECTMODULES(SvStream& rStrm)
+void writePROJECTMODULES(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer)
 {
+    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);
+    assert(xModuleInfo.is());
+
     // TODO: this whole part is document specific
     rStrm.WriteUInt16(0x000F); // id
     rStrm.WriteUInt32(0x00000002); // size of Count
-    sal_Int16 count = 5; // Number of modules // TODO: this is dependent on the document
+    sal_Int16 count = n; // Number of modules // TODO: this is dependent on the document
     rStrm.WriteUInt16(count); // Count
     writePROJECTCOOKIE(rStrm);
-    writePROJECTMODULE(rStrm, "Module1", "Module1", 0x00000379, "procedure");
-    writePROJECTMODULE(rStrm, "ThisWorkbook", "ThisWorkbook", 0x00000325, "other");
-    writePROJECTMODULE(rStrm, "Sheet1", "Sheet1", 0x00000325, "other");
-    writePROJECTMODULE(rStrm, "Sheet2", "Sheet2", 0x00000325, "other");
-    writePROJECTMODULE(rStrm, "Sheet3", "Sheet3", 0x00000325, "other");
+
+    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);
+    }
 }
 
 // section 2.3.4.2
-void exportDirStream(SvStream& rStrm)
+void exportDirStream(SvStream& rStrm, css::uno::Reference<css::container::XNameContainer> xNameContainer)
 {
     SvMemoryStream aDirStream(4096, 4096);
 
     writePROJECTINFORMATION(aDirStream);
     writePROJECTREFERENCES(aDirStream);
-    writePROJECTMODULES(aDirStream);
+    writePROJECTMODULES(aDirStream, xNameContainer);
     aDirStream.WriteUInt16(0x0010); // terminator
     aDirStream.WriteUInt32(0x00000000); // reserved
 
@@ -626,27 +632,12 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
     SotStorageStream* pDirStream = pVBAStream->OpenSotStream("dir", STREAM_READWRITE);
     SotStorageStream* pVBAProjectStream = pVBAStream->OpenSotStream("_VBA_PROJECT", STREAM_READWRITE);
 
+    css::uno::Reference<css::container::XNameContainer> xNameContainer = getBasicLibrary();
+
     // export
-    exportDirStream(*pDirStream);
+    exportDirStream(*pDirStream, xNameContainer);
     exportVBAProjectStream(*pVBAProjectStream);
 
-
-    css::uno::Reference<css::container::XNameContainer> xNameContainer = getBasicLibrary();
-    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);
-    assert(xModuleInfo.is());
-    for (sal_Int32 i = 0; i < n; ++i)
-    {
-        SAL_DEBUG(aElementNames[i]);
-        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
-        SAL_DEBUG(aModuleInfo.ModuleType);
-
-        css::uno::Any aCode = xNameContainer->getByName(aElementNames[i]);
-        OUString aSourceCode;
-        aCode >>= aSourceCode;
-        SAL_DEBUG(aSourceCode);
-    }
     pVBAProjectStream->Commit();
     pDirStream->Commit();
     pVBAStream->Commit();
commit 73e8ca5a61653755dcc35bf4ffeb5cfbba63d1cd
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Aug 28 13:34:43 2015 +0200

    also dump the module source code

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index d1ff3c7..10bf03b 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -641,6 +641,11 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
         SAL_DEBUG(aElementNames[i]);
         css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
         SAL_DEBUG(aModuleInfo.ModuleType);
+
+        css::uno::Any aCode = xNameContainer->getByName(aElementNames[i]);
+        OUString aSourceCode;
+        aCode >>= aSourceCode;
+        SAL_DEBUG(aSourceCode);
     }
     pVBAProjectStream->Commit();
     pDirStream->Commit();
commit c5aeca430288057a721688975173ed764860d8b8
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Thu Aug 27 13:39:37 2015 +0530

    Write _VBA_PROJECT stream to a binary file
    
    The stream is written according to the MS-OVBA specification.
    
    Conflicts:
    	oox/source/ole/vbaexport.cxx
    
    Change-Id: Icc63c988435d9b3bed8fdd499b80a17713f3794f

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index c52c1b6..d1ff3c7 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -609,6 +609,14 @@ void exportDirStream(SvStream& rStrm)
     aCompression.write();
 }
 
+void exportVBAProjectStream(SvStream& rStrm)
+{
+    rStrm.WriteUInt16(0x61CC); // Reserved1
+    rStrm.WriteUInt16(0xFFFF); // Version
+    rStrm.WriteUInt8(0x00); // Reserved2
+    rStrm.WriteUInt16(0x0000); // Undefined
+}
+
 }
 
 void VbaExport::exportVBA(SotStorage* pRootStorage)
@@ -616,9 +624,12 @@ 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);
 
     // export
     exportDirStream(*pDirStream);
+    exportVBAProjectStream(*pVBAProjectStream);
+
 
     css::uno::Reference<css::container::XNameContainer> xNameContainer = getBasicLibrary();
     css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
@@ -631,6 +642,7 @@ void VbaExport::exportVBA(SotStorage* pRootStorage)
         css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
         SAL_DEBUG(aModuleInfo.ModuleType);
     }
+    pVBAProjectStream->Commit();
     pDirStream->Commit();
     pVBAStream->Commit();
     pRootStorage->Commit();
commit 3d492e8f5d5062dd4f52f29e36047ea82f18bce4
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Aug 25 00:14:02 2015 +0200

    handle different callers for vba export code
    
    This now integrates it correctly with the XLS code, the XLSX one
    requires a bit more work to copy the stream to the OOXML file.
    
    Change-Id: Ic853ce795fc2ac2941083a76fd0a8cad7c6add09

diff --git a/include/oox/ole/vbaexport.hxx b/include/oox/ole/vbaexport.hxx
index 8c3094b..69d34b1 100644
--- a/include/oox/ole/vbaexport.hxx
+++ b/include/oox/ole/vbaexport.hxx
@@ -16,6 +16,8 @@
 
 #include <oox/dllapi.h>
 
+class SotStorage;
+
 namespace com { namespace sun { namespace star {
     namespace container { class XNameContainer; }
     namespace frame { class XModel; }
@@ -27,7 +29,7 @@ class OOX_DLLPUBLIC VbaExport
 public:
     VbaExport(css::uno::Reference<css::frame::XModel> xModel);
 
-    void exportVBA();
+    void exportVBA(SotStorage* pRootStorage);
 
     bool containsVBAProject();
 
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index d20de95..c52c1b6 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -611,15 +611,10 @@ void exportDirStream(SvStream& rStrm)
 
 }
 
-void VbaExport::exportVBA()
+void VbaExport::exportVBA(SotStorage* pRootStorage)
 {
     // start here with the VBA export
-
-    const OUString aVbaStreamLocation("/tmp/vba_out.bin");
-    SvFileStream aVbaStream(aVbaStreamLocation, STREAM_READWRITE);
-
-    tools::SvRef<SotStorage> aStorage(new SotStorage(aVbaStream));
-    SotStorage* pVBAStream = aStorage->OpenSotStorage("VBA", STREAM_READWRITE);
+    SotStorage* pVBAStream = pRootStorage->OpenSotStorage("VBA", STREAM_READWRITE);
     SotStorageStream* pDirStream = pVBAStream->OpenSotStream("dir", STREAM_READWRITE);
 
     // export
@@ -638,7 +633,7 @@ void VbaExport::exportVBA()
     }
     pDirStream->Commit();
     pVBAStream->Commit();
-    aStorage->Commit();
+    pRootStorage->Commit();
 }
 
 css::uno::Reference<css::script::XLibraryContainer> VbaExport::getLibraryContainer()
diff --git a/sc/source/filter/excel/expop2.cxx b/sc/source/filter/excel/expop2.cxx
index ba08fb2..f169716 100644
--- a/sc/source/filter/excel/expop2.cxx
+++ b/sc/source/filter/excel/expop2.cxx
@@ -97,7 +97,10 @@ FltError ExportBiff5::Write()
     {
         VbaExport aExport(pDocShell->GetModel());
         if (aExport.containsVBAProject())
-            aExport.exportVBA();
+        {
+            SotStorage* pVBARoot = xRootStrg->OpenSotStorage("_VBA_PROJECT_CUR");
+            aExport.exportVBA(pVBARoot);
+        }
     }
     else if( pDocShell && xRootStrg.Is() && eVbaExportMode == VBAExportMode::REEXPORT_STREAM )
     {
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 490f9d4..972dd31 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -1094,7 +1094,12 @@ bool XclExpXmlStream::exportDocument()
 
     VbaExport aExport(getModel());
     if (aExport.containsVBAProject())
-        aExport.exportVBA();
+    {
+        const OUString aVbaStreamLocation("/tmp/vba_out.bin");
+        SvFileStream aVbaStream(aVbaStreamLocation, STREAM_READWRITE);
+        tools::SvRef<SotStorage> pVBAStorage(new SotStorage(aVbaStream));
+        aExport.exportVBA(pVBAStorage);
+    }
 
     // destruct at the end of the block
     {
commit 8e06037b3f9d13a29a6ffd2f030e4360c7e1a30a
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Aug 24 23:56:54 2015 +0200

    introduce mode to save vba stream also to xls files
    
    Change-Id: Ic1066fa9492090e42d37ec487c2e9e8234de4375

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index c3fa523..8e1200e 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1629,6 +1629,14 @@
           <info>
             <desc>Specifies how VBA macros are treated in Excel files.</desc>
           </info>
+          <prop oor:name="UseExport" oor:type="xs:boolean" oor:nillable="false">
+            <!-- UIHints: Tools  Options - Filter Settings  Microsoft Office  [Section] Microsoft Excel 97/2000 -->
+            <info>
+              <desc>Indicates whether VBA macros are exported through the vba export code.</desc>
+              <label>Export VBA</label>
+            </info>
+            <value>true</value>
+          </prop>
           <prop oor:name="Load" oor:type="xs:boolean" oor:nillable="false">
             <!-- OldPath: Filter/MS_Office/Basic/Excel -->
             <!-- OldLocation: soffice.cfg -->
diff --git a/sc/source/filter/excel/expop2.cxx b/sc/source/filter/excel/expop2.cxx
index b81e5d0..ba08fb2 100644
--- a/sc/source/filter/excel/expop2.cxx
+++ b/sc/source/filter/excel/expop2.cxx
@@ -23,6 +23,8 @@
 #include <sfx2/docinf.hxx>
 #include <filter/msfilter/svxmsbas.hxx>
 
+#include <oox/ole/vbaexport.hxx>
+
 #include "scerrors.hxx"
 #include "scextopt.hxx"
 
@@ -38,9 +40,22 @@
 #include "xltools.hxx"
 #include "xelink.hxx"
 
+#include <officecfg/Office/Calc.hxx>
+
 #include <com/sun/star/document/XDocumentProperties.hpp>
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 
+namespace {
+
+enum class VBAExportMode
+{
+    NONE,
+    REEXPORT_STREAM,
+    FULL_EXPORT
+};
+
+}
+
 ExportBiff5::ExportBiff5( XclExpRootData& rExpData, SvStream& rStrm ):
     ExportTyp( rStrm, &rExpData.mrDoc, rExpData.meTextEnc ),
     XclExpRoot( rExpData )
@@ -65,14 +80,26 @@ FltError ExportBiff5::Write()
     tools::SvRef<SotStorage> xRootStrg = GetRootStorage();
     OSL_ENSURE( xRootStrg.Is(), "ExportBiff5::Write - no root storage" );
 
-    bool bWriteBasicStrg = false;
+    VBAExportMode eVbaExportMode = VBAExportMode::NONE;
     if( GetBiff() == EXC_BIFF8 )
     {
-        const SvtFilterOptions& rFilterOpt = SvtFilterOptions::Get();
-        bWriteBasicStrg = rFilterOpt.IsLoadExcelBasicStorage();
+        if (officecfg::Office::Calc::Filter::Import::VBA::UseExport::get())
+            eVbaExportMode = VBAExportMode::FULL_EXPORT;
+        else
+        {
+            const SvtFilterOptions& rFilterOpt = SvtFilterOptions::Get();
+            if (rFilterOpt.IsLoadExcelBasicStorage())
+                eVbaExportMode = VBAExportMode::REEXPORT_STREAM;
+        }
     }
 
-    if( pDocShell && xRootStrg.Is() && bWriteBasicStrg )
+    if ( pDocShell && xRootStrg.Is() && eVbaExportMode == VBAExportMode::FULL_EXPORT)
+    {
+        VbaExport aExport(pDocShell->GetModel());
+        if (aExport.containsVBAProject())
+            aExport.exportVBA();
+    }
+    else if( pDocShell && xRootStrg.Is() && eVbaExportMode == VBAExportMode::REEXPORT_STREAM )
     {
         SvxImportMSVBasic aBasicImport( *pDocShell, *xRootStrg );
         sal_uLong nErr = aBasicImport.SaveOrDelMSVBAStorage( true, EXC_STORAGE_VBA_PROJECT );
commit 1f1ec819edc14ad266d49f16116056fd439b7c46
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Aug 24 23:48:45 2015 +0200

    remove more warnings about vba export
    
    Change-Id: I8d0e6f69dd4d51d195422e6e934fedc406caec16

diff --git a/include/svtools/sfxecode.hxx b/include/svtools/sfxecode.hxx
index 5246f5a..4968f0e 100644
--- a/include/svtools/sfxecode.hxx
+++ b/include/svtools/sfxecode.hxx
@@ -77,7 +77,6 @@
 #define ERRCODE_SFX_INCOMPLETE_ENCRYPTION    (ERRCODE_WARNING_MASK | ERRCODE_AREA_SFX | ERRCODE_CLASS_NONE | 55)
 #define ERRCODE_SFX_DOCUMENT_MACRO_DISABLED_MAC (ERRCODE_WARNING_MASK | ERRCODE_AREA_SFX | ERRCODE_CLASS_NONE | 56)
 #define ERRCODE_SFX_FORMAT_ROWCOL           (ERRCODE_AREA_SFX | ERRCODE_CLASS_NONE | 57)
-#define ERRCODE_SFX_VBASIC_CANTSAVE_STORAGE (ERRCODE_WARNING_MASK | ERRCODE_AREA_SFX | ERRCODE_CLASS_NONE | 58)
 
 
 //Dies und das
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index f614540..63aebd2 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -803,41 +803,6 @@ sal_Int8 ModelData_Impl::CheckFilter( const OUString& aFilterName )
 
         if ( !aPreusedFilterName.equals( aFilterName ) && !aUIName.equals( aDefUIName ) )
         {
-            // is it possible to get these names from somewhere and not just
-            // hardcode them?
-            OUString sXLSXFilter("Calc MS Excel 2007 XML");
-            OUString sOtherXLSXFilter("Calc Office Open XML");
-            bool bHasMacros = hasMacros( GetModel() );
-            if ( bHasMacros && (  aFilterName == sXLSXFilter  ||  aFilterName == sOtherXLSXFilter ) )
-            {
-                uno::Reference< task::XInteractionHandler > xHandler;
-                GetMediaDescr()[ OUString( "InteractionHandler" ) ] >>= xHandler;
-                if ( xHandler.is() )
-                {
-                    bool bResult = false;
-                    try
-                    {
-                        task::ErrorCodeRequest aErrorCode;
-                        aErrorCode.ErrCode = ERRCODE_SFX_VBASIC_CANTSAVE_STORAGE;
-
-                        uno::Any aRequest = uno::makeAny( aErrorCode );
-                        uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( 2 );
-
-                        ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove );
-                        aContinuations[ 0 ] = pApprove.get();
-
-                        ::rtl::Reference< ::comphelper::OInteractionAbort > pAbort( new ::comphelper::OInteractionAbort );
-                        aContinuations[ 1 ] = pAbort.get();
-                        xHandler->handle(::framework::InteractionRequest::CreateRequest (aRequest,aContinuations));
-                        bResult = pApprove->wasSelected();
-                    }
-                    catch( const uno::Exception& )
-                    {
-                    }
-                    if ( !bResult )
-                        return STATUS_SAVEAS;
-                }
-            }
             if ( !SfxStoringHelper::WarnUnacceptableFormat( GetModel(), aUIName, aDefUIName, aDefExtension,
                                                             true, (bool)( nDefFiltFlags & SfxFilterFlags::ALIEN ) ) )
                 return STATUS_SAVEAS_STANDARDNAME;
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index 4fa54a7..8f58d85 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -743,26 +743,11 @@ UUIInteractionHelper::handleRequest_impl(
         task::ErrorCodeRequest aErrorCodeRequest;
         if (aAnyRequest >>= aErrorCodeRequest)
         {
-            // Sucky special handling for xlsx macro filter warning
-            if ( (sal_uInt32)ERRCODE_SFX_VBASIC_CANTSAVE_STORAGE == (sal_uInt32)aErrorCodeRequest.ErrCode)
-            {
-                std::vector< OUString > aArguments;
-                handleErrorHandlerRequest( task::InteractionClassification_WARNING,
-                                       ERRCODE_UUI_IO_WARN_CANTSAVE_MACROS,
-                                       aArguments,
-                                       rRequest->getContinuations(),
-                                       bObtainErrorStringOnly,
-                                       bHasErrorString,
-                                       rErrorString);
-            }
-            else
-            {
-                handleGenericErrorRequest( aErrorCodeRequest.ErrCode,
-                                       rRequest->getContinuations(),
-                                       bObtainErrorStringOnly,
-                                       bHasErrorString,
-                                       rErrorString);
-            }
+            handleGenericErrorRequest( aErrorCodeRequest.ErrCode,
+                    rRequest->getContinuations(),
+                    bObtainErrorStringOnly,
+                    bHasErrorString,
+                    rErrorString);
             return true;
         }
 
diff --git a/uui/source/ids.hrc b/uui/source/ids.hrc
index 9ff94d8..e70c7a8 100644
--- a/uui/source/ids.hrc
+++ b/uui/source/ids.hrc
@@ -133,7 +133,6 @@
 #define ERRCODE_UUI_LOCKING_NOT_LOCKED                          (ERRCODE_AREA_UUI + 61)
 #define ERRCODE_UUI_LOCKING_LOCK_EXPIRED                        (ERRCODE_AREA_UUI + 62)
 #define ERRCODE_UUI_CANNOT_ACTIVATE_FACTORY                     (ERRCODE_AREA_UUI + 63)
-#define ERRCODE_UUI_IO_WARN_CANTSAVE_MACROS                     (ERRCODE_WARNING_MASK | ( ERRCODE_AREA_UUI + 64))
 #define ERRCODE_AREA_UUI_UNKNOWNAUTH    25000
 #define SSLWARN_TYPE_DOMAINMISMATCH     10
 #define SSLWARN_TYPE_EXPIRED            20
diff --git a/uui/source/ids.src b/uui/source/ids.src
index 13e2bab..d7ae643 100644
--- a/uui/source/ids.src
+++ b/uui/source/ids.src
@@ -397,11 +397,6 @@ Resource RID_UUI_ERRHDL
         Text [ en-US ] = "Component cannot be loaded, possibly broken or incomplete installation.\nFull error message:\n\n $(ARG1).";
     };
 
-    String (ERRCODE_UUI_IO_WARN_CANTSAVE_MACROS & ERRCODE_RES_MASK)
-    {
-        Text [ en-US ] = "You are saving to a macro-free document format, the macros contained in this document will not be saved.\nDo you wish to continue?";
-    };
-
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 5958c94274c99058e2596923a83de3ed684e7848
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Aug 24 12:52:55 2015 +0200

    no need to warn anymore as we can save VBA now
    
    Well we will be able when this feature hits master.
    
    Change-Id: I5547863e9002bfe16119a26059fa5281bd9e9070

diff --git a/basctl/inc/basidesh.hrc b/basctl/inc/basidesh.hrc
index 3403c79..df9f997 100644
--- a/basctl/inc/basidesh.hrc
+++ b/basctl/inc/basidesh.hrc
@@ -61,7 +61,6 @@
 #define RID_STR_OPEN                    ( RID_BASICIDE_START + 20 )
 #define RID_STR_SAVE                    ( RID_BASICIDE_START + 21 )
 #define RID_STR_RUNTIMEERROR            ( RID_BASICIDE_START + 22 )
-#define RID_STR_CANNOTSAVEVBA           ( RID_BASICIDE_START + 23 )
 #define RID_STR_STDDIALOGNAME           ( RID_BASICIDE_START + 24 )
 
 #define RID_STR_STDMODULENAME           ( RID_BASICIDE_START + 27 )
diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx
index 979d2dc..ab3c1ac 100644
--- a/basctl/source/basicide/basidesh.cxx
+++ b/basctl/source/basicide/basidesh.cxx
@@ -255,14 +255,8 @@ Shell::~Shell()
 void Shell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
 {
     if (pCurWin)
-    {
         pCurWin->OnNewDocument();
 
-        // for VBA documents, show a warning that we can save them only in ODF
-        if (pCurWin->GetDocument().isInVBAMode())
-            GetViewFrame()->AppendInfoBar("vba_save", IDE_RESSTR(RID_STR_CANNOTSAVEVBA));
-    }
-
     UpdateWindows();
 }
 
diff --git a/basctl/source/basicide/basidesh.src b/basctl/source/basicide/basidesh.src
index 3b2d243..65c7066 100644
--- a/basctl/source/basicide/basidesh.src
+++ b/basctl/source/basicide/basidesh.src
@@ -211,10 +211,6 @@ String RID_STR_CANNOTCLOSE
 {
     Text [ en-US ] = "The window cannot be closed while BASIC is running." ;
 };
-String RID_STR_CANNOTSAVEVBA
-{
-    Text [ en-US ] = "You are editing a VBA macro. Changes can be saved only in OpenDocument Format." ;
-};
 String RID_STR_REPLACESTDLIB
 {
     Text [ en-US ] = "The default library cannot be replaced." ;
commit 7e4ee8112aa4f211de2d7dcd962996166e6384b8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Aug 24 12:50:54 2015 +0200

    we don't need that code anymore
    
    Change-Id: I77b5816a4e7743494444b0ac2366164a3bc5d13d

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index feecd37..d20de95 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -655,12 +655,6 @@ css::uno::Reference<css::container::XNameContainer> VbaExport::getBasicLibrary()
     try
     {
         css::uno::Reference<css::script::XLibraryContainer> xLibContainer = getLibraryContainer();
-        css::uno::Sequence<OUString> aElementNames = xLibContainer->getElementNames();
-        sal_Int32 n = aElementNames.getLength();
-        for (sal_Int32 i = 0; i < n; ++i)
-        {
-            SAL_DEBUG(aElementNames[i]);
-        }
         OUString aProjectName = getProjectName();
         xLibrary.set( xLibContainer->getByName(aProjectName), css::uno::UNO_QUERY_THROW );
     }
commit 85f42858043b07eb52b32cc42fe8c22a8333a21e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Aug 24 12:46:00 2015 +0200

    get correct vba project name
    
    Change-Id: I48efd62ca1df00b8a0cbecb01b394814ca40c2e9

diff --git a/include/oox/ole/vbaexport.hxx b/include/oox/ole/vbaexport.hxx
index 3217e1b..8c3094b 100644
--- a/include/oox/ole/vbaexport.hxx
+++ b/include/oox/ole/vbaexport.hxx
@@ -19,6 +19,7 @@
 namespace com { namespace sun { namespace star {
     namespace container { class XNameContainer; }
     namespace frame { class XModel; }
+    namespace script { class XLibraryContainer; }
 } } }
 
 class OOX_DLLPUBLIC VbaExport
@@ -28,14 +29,19 @@ public:
 
     void exportVBA();
 
+    bool containsVBAProject();
+
 private:
 
     css::uno::Reference<css::container::XNameContainer>
         getBasicLibrary();
 
-    css::uno::Reference<css::frame::XModel> mxModel;
+    css::uno::Reference<css::script::XLibraryContainer>
+        getLibraryContainer();
 
-    OUString maProjectName;
+    OUString getProjectName();
+
+    css::uno::Reference<css::frame::XModel> mxModel;
 };
 
 class VBACompressionChunk
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index dbcc256..feecd37 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -13,6 +13,7 @@
 
 #include <com/sun/star/script/XLibraryContainer.hpp>
 #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
+#include <com/sun/star/script/vba/XVBACompatibility.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 
 #include <oox/helper/binaryoutputstream.hxx>
@@ -313,8 +314,6 @@ void VBACompression::write()
 VbaExport::VbaExport(css::uno::Reference<css::frame::XModel> xModel):
     mxModel(xModel)
 {
-    // TODO: how do we get the correct project name
-    maProjectName = "VBAProject";
 }
 
 namespace {
@@ -642,20 +641,28 @@ void VbaExport::exportVBA()
     aStorage->Commit();
 }
 
+css::uno::Reference<css::script::XLibraryContainer> VbaExport::getLibraryContainer()
+{
+    oox::PropertySet aDocProp(mxModel);
+    css::uno::Reference<css::script::XLibraryContainer> xLibContainer(aDocProp.getAnyProperty(oox::PROP_BasicLibraries), css::uno::UNO_QUERY);
+
+    return xLibContainer;
+}
+
 css::uno::Reference<css::container::XNameContainer> VbaExport::getBasicLibrary()
 {
     css::uno::Reference<css::container::XNameContainer> xLibrary;
     try
     {
-        oox::PropertySet aDocProp(mxModel);
-        css::uno::Reference<css::script::XLibraryContainer> xLibContainer(aDocProp.getAnyProperty(oox::PROP_BasicLibraries), css::uno::UNO_QUERY_THROW);
+        css::uno::Reference<css::script::XLibraryContainer> xLibContainer = getLibraryContainer();
         css::uno::Sequence<OUString> aElementNames = xLibContainer->getElementNames();
         sal_Int32 n = aElementNames.getLength();
         for (sal_Int32 i = 0; i < n; ++i)
         {
             SAL_DEBUG(aElementNames[i]);
         }
-        xLibrary.set( xLibContainer->getByName(maProjectName), css::uno::UNO_QUERY_THROW );
+        OUString aProjectName = getProjectName();
+        xLibrary.set( xLibContainer->getByName(aProjectName), css::uno::UNO_QUERY_THROW );
     }
     catch(...)
     {
@@ -664,4 +671,28 @@ css::uno::Reference<css::container::XNameContainer> VbaExport::getBasicLibrary()
     return xLibrary;
 }
 
+bool VbaExport::containsVBAProject()
+{
+    css::uno::Reference<css::script::XLibraryContainer> xLibContainer = getLibraryContainer();
+    if (!xLibContainer.is())
+        return false;
+
+    css::uno::Reference<css::script::vba::XVBACompatibility> xVbaCompatibility (xLibContainer, css::uno::UNO_QUERY);
+    if (!xVbaCompatibility.is())
+        return false;
+
+    bool bVBACompatibilty = xVbaCompatibility->getVBACompatibilityMode();
+
+    return bVBACompatibilty;
+}
+
+OUString VbaExport::getProjectName()
+{
+    css::uno::Reference<css::script::vba::XVBACompatibility> xVbaCompatibility(getLibraryContainer(), css::uno::UNO_QUERY);
+    if (xVbaCompatibility.is())
+        return xVbaCompatibility->getProjectName();
+
+    return OUString();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index fec4682..490f9d4 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -1093,7 +1093,8 @@ bool XclExpXmlStream::exportDocument()
                                     "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" ) );
 
     VbaExport aExport(getModel());
-    aExport.exportVBA();
+    if (aExport.containsVBAProject())
+        aExport.exportVBA();
 
     // destruct at the end of the block
     {
commit 3187eeab10df77a6c0dd6397be993a68276d7141
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Aug 23 19:37:48 2015 +0200

    small refactoring in the vba export code
    
    Change-Id: I68a7c7700b8405f4fe2b75516deff684f21e256c

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 619c820..dbcc256 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -30,6 +30,8 @@
 #define CODEPAGE RTL_TEXTENCODING_MS_1252
 #endif
 
+#define VBA_EXPORT_DEBUG 1
+
 namespace {
 
 void exportString(SvStream& rStrm, const OUString& rString)
@@ -582,11 +584,30 @@ void writePROJECTMODULES(SvStream& rStrm)
 // section 2.3.4.2
 void exportDirStream(SvStream& rStrm)
 {
-    writePROJECTINFORMATION(rStrm);
-    writePROJECTREFERENCES(rStrm);
-    writePROJECTMODULES(rStrm);
-    rStrm.WriteUInt16(0x0010); // terminator
-    rStrm.WriteUInt32(0x00000000); // reserved
+    SvMemoryStream aDirStream(4096, 4096);
+
+    writePROJECTINFORMATION(aDirStream);
+    writePROJECTREFERENCES(aDirStream);
+    writePROJECTMODULES(aDirStream);
+    aDirStream.WriteUInt16(0x0010); // terminator
+    aDirStream.WriteUInt32(0x00000000); // reserved
+
+    aDirStream.Seek(0);
+
+#if VBA_EXPORT_DEBUG
+    const OUString aDirFileName("/tmp/vba_dir_out.bin");
+    SvFileStream aDirStreamDebug(aDirFileName, STREAM_READWRITE);
+
+    aDirStreamDebug.WriteStream(aDirStream);
+    aDirStream.Seek(0);
+#endif
+
+    // the stream for the compression
+    SvMemoryStream aMemoryStream(4096, 4096);
+    aMemoryStream.WriteStream(aDirStream);
+
+    VBACompression aCompression(rStrm, aDirStream);
+    aCompression.write();
 }
 
 }
@@ -602,19 +623,8 @@ void VbaExport::exportVBA()
     SotStorage* pVBAStream = aStorage->OpenSotStorage("VBA", STREAM_READWRITE);
     SotStorageStream* pDirStream = pVBAStream->OpenSotStream("dir", STREAM_READWRITE);
 
-    const OUString aDirFileName("/tmp/vba_dir_out.bin");
-    SvFileStream aDirStream(aDirFileName, STREAM_READWRITE);
-
     // export
-    exportDirStream(aDirStream);
-
-    aDirStream.Seek(0);
-
-    SvMemoryStream aMemoryStream(4096, 4096);
-    aMemoryStream.WriteStream(aDirStream);
-
-    VBACompression aCompression(*pDirStream, aMemoryStream);
-    aCompression.write();
+    exportDirStream(*pDirStream);
 
     css::uno::Reference<css::container::XNameContainer> xNameContainer = getBasicLibrary();
     css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
commit 4389db13ed20a85fbe2d213ddc833b39e572936d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Aug 18 13:17:02 2015 +0200

    add remaining test from spec for vba compression
    
    That test is testing the case that a sequence can not be compressed at
    all.
    
    Change-Id: I98d1065919acc9688d713ea09bf578c325b1f821

diff --git a/oox/qa/unit/data/vba/reference/spec321.bin b/oox/qa/unit/data/vba/reference/spec321.bin
new file mode 100644
index 0000000..3120c7f
Binary files /dev/null and b/oox/qa/unit/data/vba/reference/spec321.bin differ
diff --git a/oox/qa/unit/data/vba/spec321.bin b/oox/qa/unit/data/vba/spec321.bin
new file mode 100644
index 0000000..c5d48c9
--- /dev/null
+++ b/oox/qa/unit/data/vba/spec321.bin
@@ -0,0 +1 @@
+abcdefghijklmnopqrstuv.
\ No newline at end of file
diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx
index abf2b29..0247fb9 100644
--- a/oox/qa/unit/vba_compression.cxx
+++ b/oox/qa/unit/vba_compression.cxx
@@ -33,6 +33,8 @@ public:
     // tests taken from the VBA specification
     // section 3.2
 
+    // section 3.2.1
+    void testSpec321();
     // section 3.2.2
     void testSpec322();
     // section 3.2.3
@@ -47,6 +49,7 @@ public:
     CPPUNIT_TEST(testSimple2);
     CPPUNIT_TEST(testSimple3);
     CPPUNIT_TEST(testComplex1);
+    CPPUNIT_TEST(testSpec321);
     CPPUNIT_TEST(testSpec322);
     CPPUNIT_TEST(testSpec323);
     CPPUNIT_TEST_SUITE_END();
@@ -166,6 +169,28 @@ void TestVbaCompression::testComplex1()
     }
 }
 
+void TestVbaCompression::testSpec321()
+{
+    OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/spec321.bin");
+    OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/spec321.bin");
+
+    SvMemoryStream aOutputMemoryStream(4096, 4096);
+    SvMemoryStream aReferenceMemoryStream(4096, 4096);
+    ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug_spec321.bin");
+
+    CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
+
+    const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();
+    const sal_uInt8* pData = (const sal_uInt8*)aOutputMemoryStream.GetData();
+
+    size_t nSize = std::min(aReferenceMemoryStream.GetSize(),
+            aOutputMemoryStream.GetSize());
+    for (size_t i = 0; i < nSize; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]);
+    }
+}
+
 void TestVbaCompression::testSpec322()
 {
     OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/spec322.bin");
@@ -195,7 +220,7 @@ void TestVbaCompression::testSpec323()
 
     SvMemoryStream aOutputMemoryStream(4096, 4096);
     SvMemoryStream aReferenceMemoryStream(4096, 4096);
-    ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug_spec321.bin");
+    ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug_spec323.bin");
 
     CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
 
commit 33c3c4256c71462350f05d6cdc816d09f550daaf
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Aug 18 03:27:09 2015 +0200

    add another test from the VBA spec for the compression code
    
    Change-Id: I5368e30bbb383621153c31ae8705cff6df7dad90

diff --git a/oox/qa/unit/data/vba/reference/spec322.bin b/oox/qa/unit/data/vba/reference/spec322.bin
new file mode 100644
index 0000000..7724b62
Binary files /dev/null and b/oox/qa/unit/data/vba/reference/spec322.bin differ
diff --git a/oox/qa/unit/data/vba/spec322.bin b/oox/qa/unit/data/vba/spec322.bin
new file mode 100644
index 0000000..781c426
--- /dev/null
+++ b/oox/qa/unit/data/vba/spec322.bin
@@ -0,0 +1 @@
+#aaabcdefaaaaghijaaaaaklaaamnopqaaaaaaaaaaaarstuvwxyzaaa
\ No newline at end of file
diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx
index 79d394b..abf2b29 100644
--- a/oox/qa/unit/vba_compression.cxx
+++ b/oox/qa/unit/vba_compression.cxx
@@ -33,6 +33,8 @@ public:
     // tests taken from the VBA specification
     // section 3.2
 
+    // section 3.2.2
+    void testSpec322();
     // section 3.2.3
     void testSpec323();
 
@@ -45,6 +47,7 @@ public:
     CPPUNIT_TEST(testSimple2);
     CPPUNIT_TEST(testSimple3);
     CPPUNIT_TEST(testComplex1);
+    CPPUNIT_TEST(testSpec322);
     CPPUNIT_TEST(testSpec323);
     CPPUNIT_TEST_SUITE_END();
 
@@ -163,6 +166,28 @@ void TestVbaCompression::testComplex1()
     }
 }
 
+void TestVbaCompression::testSpec322()
+{
+    OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/spec322.bin");
+    OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/spec322.bin");
+
+    SvMemoryStream aOutputMemoryStream(4096, 4096);
+    SvMemoryStream aReferenceMemoryStream(4096, 4096);
+    ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug_spec322.bin");
+
+    CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
+
+    const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();
+    const sal_uInt8* pData = (const sal_uInt8*)aOutputMemoryStream.GetData();
+
+    size_t nSize = std::min(aReferenceMemoryStream.GetSize(),
+            aOutputMemoryStream.GetSize());
+    for (size_t i = 0; i < nSize; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]);
+    }
+}
+
 void TestVbaCompression::testSpec323()
 {
     OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/spec323.bin");
commit 25bd36c63503c9461933032625808e1e197606d2
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Aug 18 00:32:00 2015 +0200

    add test from the VBA spec for the compression algorithm
    
    Change-Id: I41d5aca8940e34b41e2cc70a72b6e076707bfac6

diff --git a/oox/qa/unit/data/vba/reference/spec323.bin b/oox/qa/unit/data/vba/reference/spec323.bin
new file mode 100644
index 0000000..51104ee
Binary files /dev/null and b/oox/qa/unit/data/vba/reference/spec323.bin differ
diff --git a/oox/qa/unit/data/vba/spec323.bin b/oox/qa/unit/data/vba/spec323.bin
new file mode 100644
index 0000000..9ca58b9
--- /dev/null
+++ b/oox/qa/unit/data/vba/spec323.bin
@@ -0,0 +1 @@
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\ No newline at end of file
diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx
index 4519700..79d394b 100644
--- a/oox/qa/unit/vba_compression.cxx
+++ b/oox/qa/unit/vba_compression.cxx
@@ -30,6 +30,12 @@ public:
     // real stream from a document
     void testComplex1();
 
+    // tests taken from the VBA specification
+    // section 3.2
+
+    // section 3.2.3
+    void testSpec323();
+
     // avoid the BootstrapFixtureBase::setUp and tearDown
     virtual void setUp() SAL_OVERRIDE;
     virtual void tearDown() SAL_OVERRIDE;
@@ -39,6 +45,7 @@ public:
     CPPUNIT_TEST(testSimple2);
     CPPUNIT_TEST(testSimple3);
     CPPUNIT_TEST(testComplex1);
+    CPPUNIT_TEST(testSpec323);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -156,6 +163,28 @@ void TestVbaCompression::testComplex1()
     }
 }
 
+void TestVbaCompression::testSpec323()
+{
+    OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/spec323.bin");
+    OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/spec323.bin");
+
+    SvMemoryStream aOutputMemoryStream(4096, 4096);
+    SvMemoryStream aReferenceMemoryStream(4096, 4096);
+    ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug_spec321.bin");
+
+    CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
+
+    const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();
+    const sal_uInt8* pData = (const sal_uInt8*)aOutputMemoryStream.GetData();
+
+    size_t nSize = std::min(aReferenceMemoryStream.GetSize(),
+            aOutputMemoryStream.GetSize());
+    for (size_t i = 0; i < nSize; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]);
+    }
+}
+
 void TestVbaCompression::setUp()
 {
 }
commit cb2fadd35e2834a16c93c677fb3d0b2a39adb738
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Aug 17 19:05:59 2015 +0200

    export the vba OLE container correctly
    
    Change-Id: Ic4b0db9dc69079be4ebe686d0c7a8edc91c41fa5

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 4c27603..619c820 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -19,6 +19,8 @@
 #include "oox/helper/propertyset.hxx"
 #include "oox/token/properties.hxx"
 
+#include <sot/storage.hxx>
+
 #define USE_UTF8_CODEPAGE 0
 #if USE_UTF8_CODEPAGE
 #define CODEPAGE_MS 65001
@@ -592,6 +594,14 @@ void exportDirStream(SvStream& rStrm)
 void VbaExport::exportVBA()
 {
     // start here with the VBA export
+
+    const OUString aVbaStreamLocation("/tmp/vba_out.bin");
+    SvFileStream aVbaStream(aVbaStreamLocation, STREAM_READWRITE);
+
+    tools::SvRef<SotStorage> aStorage(new SotStorage(aVbaStream));
+    SotStorage* pVBAStream = aStorage->OpenSotStorage("VBA", STREAM_READWRITE);
+    SotStorageStream* pDirStream = pVBAStream->OpenSotStream("dir", STREAM_READWRITE);
+
     const OUString aDirFileName("/tmp/vba_dir_out.bin");
     SvFileStream aDirStream(aDirFileName, STREAM_READWRITE);
 
@@ -601,12 +611,9 @@ void VbaExport::exportVBA()
     aDirStream.Seek(0);
 
     SvMemoryStream aMemoryStream(4096, 4096);
-    OUString aCompressedFileName("/tmp/vba_dir_out_compressed.bin");
-    SvFileStream aCompressedStream(aCompressedFileName, STREAM_READWRITE);
-
     aMemoryStream.WriteStream(aDirStream);
 
-    VBACompression aCompression(aCompressedStream, aMemoryStream);
+    VBACompression aCompression(*pDirStream, aMemoryStream);
     aCompression.write();
 
     css::uno::Reference<css::container::XNameContainer> xNameContainer = getBasicLibrary();
@@ -620,7 +627,9 @@ void VbaExport::exportVBA()
         css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
         SAL_DEBUG(aModuleInfo.ModuleType);
     }
-
+    pDirStream->Commit();
+    pVBAStream->Commit();
+    aStorage->Commit();
 }
 
 css::uno::Reference<css::container::XNameContainer> VbaExport::getBasicLibrary()
commit 2846de32e6a38023d584dee843230b1806bf8dba
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Aug 15 04:28:42 2015 +0200

    also log the module type

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 253d43e..4c27603 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -12,6 +12,7 @@
 #include <tools/stream.hxx>
 
 #include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 
 #include <oox/helper/binaryoutputstream.hxx>
@@ -611,10 +612,15 @@ void VbaExport::exportVBA()
     css::uno::Reference<css::container::XNameContainer> xNameContainer = getBasicLibrary();
     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);
+    assert(xModuleInfo.is());
     for (sal_Int32 i = 0; i < n; ++i)
     {
         SAL_DEBUG(aElementNames[i]);
+        css::script::ModuleInfo aModuleInfo = xModuleInfo->getModuleInfo(aElementNames[i]);
+        SAL_DEBUG(aModuleInfo.ModuleType);
     }
+
 }
 
 css::uno::Reference<css::container::XNameContainer> VbaExport::getBasicLibrary()
commit 400c2a1a0ab14eea159cdded5f8e592287590d56
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Aug 15 04:13:41 2015 +0200

    list all libraries used in the document

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index e2ec045..253d43e 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -308,7 +308,8 @@ void VBACompression::write()
 VbaExport::VbaExport(css::uno::Reference<css::frame::XModel> xModel):
     mxModel(xModel)
 {
-    maProjectName = "How to get the correct project name?";
+    // TODO: how do we get the correct project name
+    maProjectName = "VBAProject";
 }
 
 namespace {
@@ -606,6 +607,14 @@ void VbaExport::exportVBA()
 
     VBACompression aCompression(aCompressedStream, aMemoryStream);
     aCompression.write();
+
+    css::uno::Reference<css::container::XNameContainer> xNameContainer = getBasicLibrary();
+    css::uno::Sequence<OUString> aElementNames = xNameContainer->getElementNames();
+    sal_Int32 n = aElementNames.getLength();
+    for (sal_Int32 i = 0; i < n; ++i)
+    {
+        SAL_DEBUG(aElementNames[i]);
+    }
 }
 
 css::uno::Reference<css::container::XNameContainer> VbaExport::getBasicLibrary()
@@ -615,6 +624,12 @@ css::uno::Reference<css::container::XNameContainer> VbaExport::getBasicLibrary()
     {
         oox::PropertySet aDocProp(mxModel);
         css::uno::Reference<css::script::XLibraryContainer> xLibContainer(aDocProp.getAnyProperty(oox::PROP_BasicLibraries), css::uno::UNO_QUERY_THROW);
+        css::uno::Sequence<OUString> aElementNames = xLibContainer->getElementNames();
+        sal_Int32 n = aElementNames.getLength();
+        for (sal_Int32 i = 0; i < n; ++i)
+        {
+            SAL_DEBUG(aElementNames[i]);
+        }
         xLibrary.set( xLibContainer->getByName(maProjectName), css::uno::UNO_QUERY_THROW );
     }
     catch(...)
commit e1c1a5da515ba3ec10b9e68b148433c841f51ff7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Aug 15 02:57:55 2015 +0200

    forgot to add the test makefile
    
    Change-Id: If68972ac8e0f464869660e60e9bd54197ed0e5e6

diff --git a/oox/CppunitTest_oox_vba_compression.mk b/oox/CppunitTest_oox_vba_compression.mk
new file mode 100644
index 0000000..bb87cb4
--- /dev/null
+++ b/oox/CppunitTest_oox_vba_compression.mk
@@ -0,0 +1,50 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,oox_vba_compression))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,oox_vba_compression,\
+    oox/qa/unit/vba_compression \
+))
+
+$(eval $(call gb_CppunitTest_use_api,oox_vba_compression,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,oox_vba_compression,\
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    editeng \
+    expwrap \
+    drawinglayer \
+    msfilter \
+    sal \
+    i18nlangtag \
+    oox \
+    sax \
+    sfx \
+    svl \
+    svt \
+    svx \
+    svxcore \
+    sot \
+    tl \
+    unotest \
+    utl \
+    vcl \
+    xo \
+    xmlscript \
+    $(gb_UWINAPI) \
+))
+
+# vim: set noet sw=4 ts=4:
commit d53ac4d2711c5c1a7639739d34eaeaecc6a53b56
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Aug 15 02:57:23 2015 +0200

    add complext vba compression test
    
    This is based on my real world test document.
    
    Change-Id: I6e6c38aa1ced7fe836a8926c26aa7d488d44e6d9

diff --git a/oox/qa/unit/data/vba/complex1.bin b/oox/qa/unit/data/vba/complex1.bin
new file mode 100644
index 0000000..3902082
Binary files /dev/null and b/oox/qa/unit/data/vba/complex1.bin differ
diff --git a/oox/qa/unit/data/vba/reference/complex1.bin b/oox/qa/unit/data/vba/reference/complex1.bin
new file mode 100644
index 0000000..335b8e8
Binary files /dev/null and b/oox/qa/unit/data/vba/reference/complex1.bin differ
diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx
index 715a0e4..4519700 100644
--- a/oox/qa/unit/vba_compression.cxx
+++ b/oox/qa/unit/vba_compression.cxx
@@ -27,6 +27,9 @@ public:
 
     void testSimple3();
 
+    // real stream from a document
+    void testComplex1();
+
     // avoid the BootstrapFixtureBase::setUp and tearDown
     virtual void setUp() SAL_OVERRIDE;
     virtual void tearDown() SAL_OVERRIDE;
@@ -35,6 +38,7 @@ public:
     CPPUNIT_TEST(testSimple1);
     CPPUNIT_TEST(testSimple2);
     CPPUNIT_TEST(testSimple3);
+    CPPUNIT_TEST(testComplex1);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -130,6 +134,28 @@ void TestVbaCompression::testSimple3()
     }
 }
 
+void TestVbaCompression::testComplex1()
+{
+    OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/complex1.bin");
+    OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/complex1.bin");
+
+    SvMemoryStream aOutputMemoryStream(4096, 4096);
+    SvMemoryStream aReferenceMemoryStream(4096, 4096);
+    ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug_complex1.bin");
+
+    CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
+
+    const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();
+    const sal_uInt8* pData = (const sal_uInt8*)aOutputMemoryStream.GetData();
+
+    size_t nSize = std::min(aReferenceMemoryStream.GetSize(),
+            aOutputMemoryStream.GetSize());
+    for (size_t i = 0; i < nSize; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]);
+    }
+}
+
 void TestVbaCompression::setUp()
 {
 }
commit ef1a6c7786eb16690c7d3a4dff86f0effe5a846b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Aug 15 02:42:28 2015 +0200

    fix some of the vba compression tests
    
    Change-Id: Icfb9b63206fe22641ebdef76619fe70e1f5d5e04

diff --git a/oox/qa/unit/data/vba/reference/simple1.bin b/oox/qa/unit/data/vba/reference/simple1.bin
index bd55e2e..a4644fb 100644
Binary files a/oox/qa/unit/data/vba/reference/simple1.bin and b/oox/qa/unit/data/vba/reference/simple1.bin differ
diff --git a/oox/qa/unit/data/vba/reference/simple2.bin b/oox/qa/unit/data/vba/reference/simple2.bin
index 89f448a..5de3f5a 100644
Binary files a/oox/qa/unit/data/vba/reference/simple2.bin and b/oox/qa/unit/data/vba/reference/simple2.bin differ
diff --git a/oox/qa/unit/data/vba/reference/simple3.bin b/oox/qa/unit/data/vba/reference/simple3.bin
new file mode 100644
index 0000000..a38e8a8
--- /dev/null
+++ b/oox/qa/unit/data/vba/reference/simple3.bin
@@ -0,0 +1 @@
+°
diff --git a/oox/qa/unit/data/vba/simple1.bin b/oox/qa/unit/data/vba/simple1.bin
index 61dbbeb..d59c1d5 100644
Binary files a/oox/qa/unit/data/vba/simple1.bin and b/oox/qa/unit/data/vba/simple1.bin differ
diff --git a/oox/qa/unit/data/vba/simple2.bin b/oox/qa/unit/data/vba/simple2.bin
index 9843ad2..1b9b88b 100644
Binary files a/oox/qa/unit/data/vba/simple2.bin and b/oox/qa/unit/data/vba/simple2.bin differ
diff --git a/oox/qa/unit/data/vba/simple3.bin b/oox/qa/unit/data/vba/simple3.bin
new file mode 100644
index 0000000..72060e8
--- /dev/null
+++ b/oox/qa/unit/data/vba/simple3.bin
@@ -0,0 +1 @@
+
diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx
index 6a71331..715a0e4 100644
--- a/oox/qa/unit/vba_compression.cxx
+++ b/oox/qa/unit/vba_compression.cxx
@@ -25,6 +25,8 @@ public:
     // a sequence containing one subsequence that can be compressed
     void testSimple2();
 
+    void testSimple3();
+
     // avoid the BootstrapFixtureBase::setUp and tearDown
     virtual void setUp() SAL_OVERRIDE;
     virtual void tearDown() SAL_OVERRIDE;
@@ -32,6 +34,7 @@ public:
     CPPUNIT_TEST_SUITE(TestVbaCompression);
     CPPUNIT_TEST(testSimple1);
     CPPUNIT_TEST(testSimple2);
+    CPPUNIT_TEST(testSimple3);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -70,7 +73,7 @@ void TestVbaCompression::testSimple1()
     ReadFiles(aTestFile, aReference, aOutputMemoryStream,
             aReferenceMemoryStream, "/tmp/vba_debug.bin");
 
-    // CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
+    CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
 
     const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();
     const sal_uInt8* pData = (const sal_uInt8*)aOutputMemoryStream.GetData();
@@ -91,8 +94,30 @@ void TestVbaCompression::testSimple2()
     SvMemoryStream aOutputMemoryStream(4096, 4096);
     SvMemoryStream aReferenceMemoryStream(4096, 4096);
     ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug2.bin");
-    //
-    // CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
+
+    CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
+
+    const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();
+    const sal_uInt8* pData = (const sal_uInt8*)aOutputMemoryStream.GetData();
+
+    size_t nSize = std::min(aReferenceMemoryStream.GetSize(),
+            aOutputMemoryStream.GetSize());
+    for (size_t i = 0; i < nSize; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]);
+    }
+}
+
+void TestVbaCompression::testSimple3()
+{
+    OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/simple3.bin");
+    OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/simple3.bin");
+
+    SvMemoryStream aOutputMemoryStream(4096, 4096);
+    SvMemoryStream aReferenceMemoryStream(4096, 4096);
+    ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug3.bin");
+
+    CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
 
     const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();
     const sal_uInt8* pData = (const sal_uInt8*)aOutputMemoryStream.GetData();
commit 6917cd98ca6b6fd2d495d0257c7fe50611982d34
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Aug 15 02:24:34 2015 +0200

    add one more test for vba compression
    
    Change-Id: Iba6b4e7b5d26ac7943f72e2a5b3d5d2dc4fc95fd

diff --git a/oox/qa/unit/data/vba/reference/simple2.bin b/oox/qa/unit/data/vba/reference/simple2.bin
new file mode 100644
index 0000000..89f448a
Binary files /dev/null and b/oox/qa/unit/data/vba/reference/simple2.bin differ
diff --git a/oox/qa/unit/data/vba/simple2.bin b/oox/qa/unit/data/vba/simple2.bin
new file mode 100644
index 0000000..9843ad2
--- /dev/null
+++ b/oox/qa/unit/data/vba/simple2.bin
@@ -0,0 +1 @@
+0000000: 0001 0203 0000 0000 0405             .
diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx
index b526a3c..6a71331 100644
--- a/oox/qa/unit/vba_compression.cxx
+++ b/oox/qa/unit/vba_compression.cxx
@@ -19,40 +19,79 @@ class TestVbaCompression : public test::BootstrapFixtureBase
 {
 public:
 
+    // just a sequence of bytes that should not be compressed at all
     void testSimple1();
 
+    // a sequence containing one subsequence that can be compressed
+    void testSimple2();
+
     // avoid the BootstrapFixtureBase::setUp and tearDown
     virtual void setUp() SAL_OVERRIDE;
     virtual void tearDown() SAL_OVERRIDE;
 
     CPPUNIT_TEST_SUITE(TestVbaCompression);
     CPPUNIT_TEST(testSimple1);
+    CPPUNIT_TEST(testSimple2);
     CPPUNIT_TEST_SUITE_END();
 
 private:
 };
 
-void TestVbaCompression::testSimple1()
-{
-    OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/simple1.bin");
-    OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/simple1.bin");
+namespace {
 
-    SvFileStream aInputStream(aTestFile, StreamMode::READ);
+void ReadFiles(const OUString& rTestFile, const OUString& rReference,
+        SvMemoryStream& rOutputMemoryStream, SvMemoryStream& rReferenceMemoryStream,
+        const OUString& rDebugPath)
+{
+    SvFileStream aInputStream(rTestFile, StreamMode::READ);
     SvMemoryStream aInputMemoryStream(4096, 4096);
     aInputMemoryStream.WriteStream(aInputStream);
 
-    SvMemoryStream aOutputMemoryStream(4096, 4096);
-    VBACompression aCompression(aOutputMemoryStream, aInputMemoryStream);
+    VBACompression aCompression(rOutputMemoryStream, aInputMemoryStream);
     aCompression.write();
 
-    SvFileStream aReferenceStream(aReference, StreamMode::READ);
+    SvFileStream aReferenceStream(rReference, StreamMode::READ);
+    rReferenceMemoryStream.WriteStream(aReferenceStream);
+
+    rOutputMemoryStream.Seek(0);
+    SvFileStream aDebugStream(rDebugPath, StreamMode::WRITE);
+    aDebugStream.WriteStream(rOutputMemoryStream);
+}
+
+}
+
+void TestVbaCompression::testSimple1()
+{
+    OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/simple1.bin");
+    OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/simple1.bin");
+
+    SvMemoryStream aOutputMemoryStream(4096, 4096);
     SvMemoryStream aReferenceMemoryStream(4096, 4096);
-    aReferenceMemoryStream.WriteStream(aReferenceStream);
+    ReadFiles(aTestFile, aReference, aOutputMemoryStream,
+            aReferenceMemoryStream, "/tmp/vba_debug.bin");
+
+    // CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
 
-    aOutputMemoryStream.Seek(0);
-    SvFileStream aDebugStream("/tmp/vba_debug.bin", StreamMode::WRITE);
-    aDebugStream.WriteStream(aOutputMemoryStream);
+    const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();
+    const sal_uInt8* pData = (const sal_uInt8*)aOutputMemoryStream.GetData();
 
+    size_t nSize = std::min(aReferenceMemoryStream.GetSize(),
+            aOutputMemoryStream.GetSize());
+    for (size_t i = 0; i < nSize; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]);
+    }
+}
+
+void TestVbaCompression::testSimple2()
+{
+    OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/simple2.bin");
+    OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/simple2.bin");
+
+    SvMemoryStream aOutputMemoryStream(4096, 4096);
+    SvMemoryStream aReferenceMemoryStream(4096, 4096);
+    ReadFiles(aTestFile, aReference, aOutputMemoryStream, aReferenceMemoryStream, "/tmp/vba_debug2.bin");
+    //
     // CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
 
     const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();
commit c465695b7e18b38ab99f202fab169fa1bdf930f8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Aug 15 01:25:37 2015 +0200

    write compressed stream to a temporary file
    
    Change-Id: I4791ec65961129475bb81491dcf681295fcfdea6

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 723824b..e2ec045 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -591,10 +591,21 @@ void VbaExport::exportVBA()
 {
     // start here with the VBA export
     const OUString aDirFileName("/tmp/vba_dir_out.bin");
-    SvFileStream aDirStream(aDirFileName, StreamMode::WRITE);
+    SvFileStream aDirStream(aDirFileName, STREAM_READWRITE);
 
     // export
     exportDirStream(aDirStream);
+
+    aDirStream.Seek(0);
+
+    SvMemoryStream aMemoryStream(4096, 4096);
+    OUString aCompressedFileName("/tmp/vba_dir_out_compressed.bin");
+    SvFileStream aCompressedStream(aCompressedFileName, STREAM_READWRITE);
+
+    aMemoryStream.WriteStream(aDirStream);
+
+    VBACompression aCompression(aCompressedStream, aMemoryStream);
+    aCompression.write();
 }
 
 css::uno::Reference<css::container::XNameContainer> VbaExport::getBasicLibrary()
commit 5e4c27820176976771429ad21d7420902597ccb2
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Aug 15 01:22:34 2015 +0200

    add first vba compression test
    
    Change-Id: I9e3abebb0ac932b46f7fc96cd37d39023b783af2

diff --git a/include/oox/ole/vbaexport.hxx b/include/oox/ole/vbaexport.hxx
index 146bb88..3217e1b 100644
--- a/include/oox/ole/vbaexport.hxx
+++ b/include/oox/ole/vbaexport.hxx
@@ -90,7 +90,7 @@ private:
     sal_uInt16 handleHeader(bool bCompressed);
 };
 
-class VBACompression
+class OOX_DLLPUBLIC VBACompression
 {
 public:
     VBACompression(SvStream& rCompressedStream,
diff --git a/oox/Module_oox.mk b/oox/Module_oox.mk
index 361054d..1c8edf0 100644
--- a/oox/Module_oox.mk
+++ b/oox/Module_oox.mk
@@ -18,6 +18,7 @@ $(eval $(call gb_Module_add_targets,oox,\
 
 $(eval $(call gb_Module_add_check_targets,oox,\
 	CppunitTest_oox_tokenmap \
+	CppunitTest_oox_vba_compression \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/oox/qa/unit/data/vba/reference/simple1.bin b/oox/qa/unit/data/vba/reference/simple1.bin
new file mode 100644
index 0000000..bd55e2e
Binary files /dev/null and b/oox/qa/unit/data/vba/reference/simple1.bin differ
diff --git a/oox/qa/unit/data/vba/simple1.bin b/oox/qa/unit/data/vba/simple1.bin
new file mode 100644
index 0000000..61dbbeb
--- /dev/null
+++ b/oox/qa/unit/data/vba/simple1.bin
@@ -0,0 +1 @@
+00000000:0001 0203 0405 0607 0809 1011 1213       .
diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx
new file mode 100644
index 0000000..b526a3c
--- /dev/null
+++ b/oox/qa/unit/vba_compression.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <unotest/bootstrapfixturebase.hxx>
+
+#include <cppunit/plugin/TestPlugIn.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestFixture.h>
+
+#include <oox/ole/vbaexport.hxx>
+
+class TestVbaCompression : public test::BootstrapFixtureBase
+{
+public:
+
+    void testSimple1();
+
+    // avoid the BootstrapFixtureBase::setUp and tearDown
+    virtual void setUp() SAL_OVERRIDE;
+    virtual void tearDown() SAL_OVERRIDE;
+
+    CPPUNIT_TEST_SUITE(TestVbaCompression);
+    CPPUNIT_TEST(testSimple1);
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+};
+
+void TestVbaCompression::testSimple1()
+{
+    OUString aTestFile = getPathFromSrc("/oox/qa/unit/data/vba/simple1.bin");
+    OUString aReference = getPathFromSrc("/oox/qa/unit/data/vba/reference/simple1.bin");
+
+    SvFileStream aInputStream(aTestFile, StreamMode::READ);
+    SvMemoryStream aInputMemoryStream(4096, 4096);
+    aInputMemoryStream.WriteStream(aInputStream);
+
+    SvMemoryStream aOutputMemoryStream(4096, 4096);
+    VBACompression aCompression(aOutputMemoryStream, aInputMemoryStream);
+    aCompression.write();
+
+    SvFileStream aReferenceStream(aReference, StreamMode::READ);
+    SvMemoryStream aReferenceMemoryStream(4096, 4096);
+    aReferenceMemoryStream.WriteStream(aReferenceStream);
+
+    aOutputMemoryStream.Seek(0);
+    SvFileStream aDebugStream("/tmp/vba_debug.bin", StreamMode::WRITE);
+    aDebugStream.WriteStream(aOutputMemoryStream);
+
+    // CPPUNIT_ASSERT_EQUAL(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize());
+
+    const sal_uInt8* pReferenceData = (const sal_uInt8*) aReferenceMemoryStream.GetData();
+    const sal_uInt8* pData = (const sal_uInt8*)aOutputMemoryStream.GetData();
+
+    size_t nSize = std::min(aReferenceMemoryStream.GetSize(),
+            aOutputMemoryStream.GetSize());
+    for (size_t i = 0; i < nSize; ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]);
+    }
+}
+
+void TestVbaCompression::setUp()
+{
+}
+
+void TestVbaCompression::tearDown()
+{
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(TestVbaCompression);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit eaab276fbb2939d6f315a9e491ff7925edfc6fd8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Aug 15 01:20:43 2015 +0200

    fix my horrible chunk header code
    
    Change-Id: Ic91c06dbe05180d97b0db5de497f26f14b2d4ec4

diff --git a/include/oox/ole/vbaexport.hxx b/include/oox/ole/vbaexport.hxx
index 6993fe5..146bb88 100644
--- a/include/oox/ole/vbaexport.hxx
+++ b/include/oox/ole/vbaexport.hxx
@@ -66,9 +66,6 @@ private:
     // DecompressedEnd according to the spec
     sal_uInt64 mnDecompressedEnd;
 
-    // Start of the current decompressed chunk
-    sal_uInt64 mnChunkStart;
-
     void PackCompressedChunkSize(size_t nSize, sal_uInt16& rHeader);
 
     void PackCompressedChunkFlag(bool bCompressed, sal_uInt16& rHeader);
@@ -89,6 +86,8 @@ private:
             sal_uInt16& rBitCount, sal_uInt16& rMaximumLength);
 
     void writeRawChunk();
+
+    sal_uInt16 handleHeader(bool bCompressed);
 };
 
 class VBACompression
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index ea364bc..723824b 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -55,13 +55,27 @@ VBACompressionChunk::VBACompressionChunk(SvStream& rCompressedStream, const sal_
 {
 }
 
+void setUInt16(sal_uInt8* pBuffer, size_t nPos, sal_uInt16 nVal)
+{
+    pBuffer[nPos] = nVal & 0xFF;
+    pBuffer[nPos+1] = (nVal & 0xFF00) >> 8;
+}
+
+sal_uInt16 VBACompressionChunk::handleHeader(bool bCompressed)
+{
+    // handle header bytes
+    size_t nSize = mnCompressedCurrent;
+    sal_uInt16 nHeader = 0;
+    PackCompressedChunkSize(nSize, nHeader);
+    PackCompressedChunkFlag(bCompressed, nHeader);
+    PackCompressedChunkSignature(nHeader);
+
+    return nHeader;
+}
+
 // section 2.4.1.3.7
 void VBACompressionChunk::write()
 {
-    mnChunkStart = mrCompressedStream.Tell();
-
-    // we need to fill these two bytes later
-    mrCompressedStream.WriteUInt16(0x0);
 
     mnDecompressedCurrent = 0;
     mnCompressedCurrent = 2;
@@ -80,30 +94,22 @@ void VBACompressionChunk::write()
         compressTokenSequence();
     }
 
-    bool bCompressedFlag = true;
     if (mnDecompressedCurrent < mnDecompressedEnd)
     {
+        sal_uInt64 nChunkStart = mrCompressedStream.Tell();
+        mrCompressedStream.WriteUInt16(0);
         writeRawChunk();
-        bCompressedFlag = false;
+        mrCompressedStream.Seek(nChunkStart);
+        sal_uInt16 nHeader = handleHeader(false);
+        mrCompressedStream.WriteUInt16(nHeader);
     }
     else
     {
+        sal_uInt16 nHeader = handleHeader(true);
+        setUInt16(pCompressedChunkStream, 0, nHeader);
         // copy the compressed stream to our output stream
         mrCompressedStream.Write(pCompressedChunkStream, mnCompressedCurrent);
     }
-
-    // handle header bytes
-    size_t nSize = mnCompressedCurrent;
-    sal_uInt16 nHeader = 0;
-    PackCompressedChunkSize(nSize, nHeader);
-    PackCompressedChunkFlag(bCompressedFlag, nHeader);
-    PackCompressedChunkSignature(nHeader);
-
-    // overwrite the two bytes
-    sal_uInt64 nEnd = mrCompressedStream.Tell();
-    mrCompressedStream.Seek(mnChunkStart);
-    mrCompressedStream.WriteUInt16(nHeader);
-    mrCompressedStream.Seek(nEnd);
 }
 
 // section 2.4.1.3.13
@@ -146,12 +152,6 @@ void VBACompressionChunk::compressTokenSequence()
     mpCompressedChunkStream[nFlagByteIndex] = nFlagByte;
 }
 
-void setUInt16(sal_uInt8* pBuffer, size_t nPos, sal_uInt16 nVal)
-{
-    pBuffer[nPos] = nVal & 0xFFFF;
-    pBuffer[nPos+1] = (nVal & 0xFFFF0000) >> 8;
-}
-
 // section 2.4.1.3.9
 void VBACompressionChunk::compressToken(size_t index, sal_uInt8& nFlagByte)
 {
commit f9386c07b1431aaa7cc091effe3b0e0847790731
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Aug 14 23:48:49 2015 +0200

    also write the chunks to the compressed stream
    
    Change-Id: I4b079f0f5b83379e1c8c7c7d99a16b794ab36c11

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 904fbf9..ea364bc 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -297,6 +297,7 @@ void VBACompression::write()
     {
         sal_Size nChunkSize = nRemainingSize > 4096 ? 4096 : nRemainingSize;
         VBACompressionChunk aChunk(mrCompressedStream, &pData[nSize - nRemainingSize], nChunkSize);
+        aChunk.write();
 
         // update the uncompressed chunk start marker
         nRemainingSize -= nChunkSize;
commit 4f1f317a0bf7436b1624d60df96a25f4a8b9a58b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Aug 14 23:47:28 2015 +0200

    extract compression methods to make them testable
    
    Change-Id: I2ad28134ef723872b9940c02657ee89758efa06f

diff --git a/include/oox/ole/vbaexport.hxx b/include/oox/ole/vbaexport.hxx
index 88a0561..6993fe5 100644
--- a/include/oox/ole/vbaexport.hxx
+++ b/include/oox/ole/vbaexport.hxx
@@ -11,6 +11,9 @@
 #define __INCLUDED_INCLUDE_OOX_OLE_VBAEXPORT_HXX__
 
 #include <com/sun/star/uno/XInterface.hpp>
+
+#include <tools/stream.hxx>
+
 #include <oox/dllapi.h>
 
 namespace com { namespace sun { namespace star {
@@ -35,6 +38,72 @@ private:
     OUString maProjectName;
 };
 
+class VBACompressionChunk
+{
+public:
+
+    VBACompressionChunk(SvStream& rCompressedStream, const sal_uInt8* pData, sal_Size nChunkSize);
+
+    void write();
+
+private:
+    SvStream& mrCompressedStream;
+    const sal_uInt8* mpUncompressedData;
+    sal_uInt8* mpCompressedChunkStream;
+
+    // same as DecompressedChunkEnd in the spec
+    sal_Size mnChunkSize;
+
+    // CompressedCurrent according to the spec
+    sal_uInt64 mnCompressedCurrent;
+
+    // CompressedEnd according to the spec
+    sal_uInt64 mnCompressedEnd;
+
+    // DecompressedCurrent according to the spec
+    sal_uInt64 mnDecompressedCurrent;
+
+    // DecompressedEnd according to the spec
+    sal_uInt64 mnDecompressedEnd;
+
+    // Start of the current decompressed chunk
+    sal_uInt64 mnChunkStart;
+
+    void PackCompressedChunkSize(size_t nSize, sal_uInt16& rHeader);
+
+    void PackCompressedChunkFlag(bool bCompressed, sal_uInt16& rHeader);
+
+    void PackCompressedChunkSignature(sal_uInt16& rHeader);
+
+    void compressTokenSequence();
+
+    void compressToken(size_t index, sal_uInt8& nFlagByte);
+
+    void SetFlagBit(size_t index, bool bVal, sal_uInt8& rFlag);
+
+    sal_uInt16 CopyToken(size_t nLength, size_t nOffset);
+
+    void match(size_t& rLength, size_t& rOffset);
+
+    void CopyTokenHelp(sal_uInt16& rLengthMask, sal_uInt16& rOffsetMask,
+            sal_uInt16& rBitCount, sal_uInt16& rMaximumLength);
+
+    void writeRawChunk();
+};
+
+class VBACompression
+{
+public:
+    VBACompression(SvStream& rCompressedStream,
+            SvMemoryStream& rUncompressedStream);
+
+    void write();
+
+private:
+    SvStream& mrCompressedStream;
+    SvMemoryStream& mrUncompressedStream;
+};
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 9d6d52a..904fbf9 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -46,58 +46,7 @@ void exportUTF16String(SvStream& rStrm, const OUString& rString)
     }
 }
 
-class VBACompressionChunk
-{
-public:
-
-    VBACompressionChunk(SvStream& rCompressedStream, const sal_uInt8* pData, sal_Size nChunkSize);
-
-    void write();
-
-private:
-    SvStream& mrCompressedStream;
-    const sal_uInt8* mpUncompressedData;
-    sal_uInt8* mpCompressedChunkStream;
-
-    // same as DecompressedChunkEnd in the spec
-    sal_Size mnChunkSize;
-
-    // CompressedCurrent according to the spec
-    sal_uInt64 mnCompressedCurrent;
-
-    // CompressedEnd according to the spec
-    sal_uInt64 mnCompressedEnd;
-
-    // DecompressedCurrent according to the spec
-    sal_uInt64 mnDecompressedCurrent;
-
-    // DecompressedEnd according to the spec
-    sal_uInt64 mnDecompressedEnd;
-
-    // Start of the current decompressed chunk
-    sal_uInt64 mnChunkStart;
-
-    void PackCompressedChunkSize(size_t nSize, sal_uInt16& rHeader);
-
-    void PackCompressedChunkFlag(bool bCompressed, sal_uInt16& rHeader);
-
-    void PackCompressedChunkSignature(sal_uInt16& rHeader);
-
-    void compressTokenSequence();
-
-    void compressToken(size_t index, sal_uInt8& nFlagByte);
-
-    void SetFlagBit(size_t index, bool bVal, sal_uInt8& rFlag);
-
-    sal_uInt16 CopyToken(size_t nLength, size_t nOffset);
-
-    void match(size_t& rLength, size_t& rOffset);
-
-    void CopyTokenHelp(sal_uInt16& rLengthMask, sal_uInt16& rOffsetMask,
-            sal_uInt16& rBitCount, sal_uInt16& rMaximumLength);
-
-    void writeRawChunk();
-};
+}
 
 VBACompressionChunk::VBACompressionChunk(SvStream& rCompressedStream, const sal_uInt8* pData, sal_Size nChunkSize):
     mrCompressedStream(rCompressedStream),
@@ -328,19 +277,6 @@ void VBACompressionChunk::writeRawChunk()
     }
 }
 
-class VBACompression
-{
-public:
-    VBACompression(SvStream& rCompressedStream,
-            SvMemoryStream& rUncompressedStream);
-
-    void write();
-
-private:
-    SvStream& mrCompressedStream;
-    SvMemoryStream& mrUncompressedStream;
-};
-
 VBACompression::VBACompression(SvStream& rCompressedStream,
         SvMemoryStream& rUncompressedStream):
     mrCompressedStream(rCompressedStream),
@@ -368,8 +304,6 @@ void VBACompression::write()
     }
 }
 
-}
-
 VbaExport::VbaExport(css::uno::Reference<css::frame::XModel> xModel):
     mxModel(xModel)
 {
commit a1b31c0e36d7788ac1dfc3b623756f72f1cb3d78
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Aug 14 21:30:36 2015 +0200

    fix small glitch
    
    Change-Id: I8c219db7aa3eb53c82232469e8334b6a47489cb2

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 93c228f..9d6d52a 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -634,7 +634,7 @@ void writePROJECTMODULES(SvStream& rStrm)
     rStrm.WriteUInt16(count); // Count
     writePROJECTCOOKIE(rStrm);
     writePROJECTMODULE(rStrm, "Module1", "Module1", 0x00000379, "procedure");
-    writePROJECTMODULE(rStrm, "ThisWorkbook", "ThisWorkbook", 0x000004BD, "other");
+    writePROJECTMODULE(rStrm, "ThisWorkbook", "ThisWorkbook", 0x00000325, "other");
     writePROJECTMODULE(rStrm, "Sheet1", "Sheet1", 0x00000325, "other");
     writePROJECTMODULE(rStrm, "Sheet2", "Sheet2", 0x00000325, "other");
     writePROJECTMODULE(rStrm, "Sheet3", "Sheet3", 0x00000325, "other");
commit b0e1a08cc438dff932d555a123bdc2110a0bd1c3
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Fri Aug 14 11:36:05 2015 +0530

    termination of dir stream
    
    Change-Id: Iac2284fe0876afe244fad8f33fe88402dc48a704

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 9f54e03..93c228f 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -646,6 +646,8 @@ void exportDirStream(SvStream& rStrm)
     writePROJECTINFORMATION(rStrm);
     writePROJECTREFERENCES(rStrm);
     writePROJECTMODULES(rStrm);
+    rStrm.WriteUInt16(0x0010); // terminator
+    rStrm.WriteUInt32(0x00000000); // reserved
 }
 
 }
commit c41f53b52552ff2632e61384c36087534a737f8f
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Fri Aug 14 11:29:41 2015 +0530

    implementing the fifth module - sheet3
    
    Change-Id: I50abe3687e37fad43ffb93b360f82acf07d74331

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 4494093..9f54e03 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -637,6 +637,7 @@ void writePROJECTMODULES(SvStream& rStrm)
     writePROJECTMODULE(rStrm, "ThisWorkbook", "ThisWorkbook", 0x000004BD, "other");
     writePROJECTMODULE(rStrm, "Sheet1", "Sheet1", 0x00000325, "other");
     writePROJECTMODULE(rStrm, "Sheet2", "Sheet2", 0x00000325, "other");
+    writePROJECTMODULE(rStrm, "Sheet3", "Sheet3", 0x00000325, "other");
 }
 
 // section 2.3.4.2
commit bc6135bdb2f8cc89d9c40a6c47bed579a53ab678
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Fri Aug 14 11:17:30 2015 +0530

    implementing the fourth module - sheet2
    
    Change-Id: Ib3ff765e3646ba381e6d01654147ba1fdda65377

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 65fc6d6..4494093 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -636,6 +636,7 @@ void writePROJECTMODULES(SvStream& rStrm)
     writePROJECTMODULE(rStrm, "Module1", "Module1", 0x00000379, "procedure");
     writePROJECTMODULE(rStrm, "ThisWorkbook", "ThisWorkbook", 0x000004BD, "other");
     writePROJECTMODULE(rStrm, "Sheet1", "Sheet1", 0x00000325, "other");
+    writePROJECTMODULE(rStrm, "Sheet2", "Sheet2", 0x00000325, "other");
 }
 
 // section 2.3.4.2
commit 026493da55f31d0e8c57395cd1168e397edf63f2
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Fri Aug 14 11:11:55 2015 +0530

    implementing the third module - sheet1
    
    Change-Id: I57633ce039163fa9145a3aa71b594c4b30999475

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 58c1207..65fc6d6 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -635,6 +635,7 @@ void writePROJECTMODULES(SvStream& rStrm)
     writePROJECTCOOKIE(rStrm);
     writePROJECTMODULE(rStrm, "Module1", "Module1", 0x00000379, "procedure");
     writePROJECTMODULE(rStrm, "ThisWorkbook", "ThisWorkbook", 0x000004BD, "other");
+    writePROJECTMODULE(rStrm, "Sheet1", "Sheet1", 0x00000325, "other");
 }
 
 // section 2.3.4.2
commit 08bfc7be1f43215ddecd86e1c005df2539567494
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Fri Aug 14 11:05:35 2015 +0530

    implementing the second module
    
    Change-Id: I6a9e1fb07c990bcf65fa15e84e72cc410996cd73

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 1b82b8e..58c1207 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -634,6 +634,7 @@ void writePROJECTMODULES(SvStream& rStrm)
     rStrm.WriteUInt16(count); // Count
     writePROJECTCOOKIE(rStrm);
     writePROJECTMODULE(rStrm, "Module1", "Module1", 0x00000379, "procedure");
+    writePROJECTMODULE(rStrm, "ThisWorkbook", "ThisWorkbook", 0x000004BD, "other");
 }
 
 // section 2.3.4.2
commit 28ab982e1363d1006e12b24b406e919d80736afe
Author: Rosemary <rosemaryseb8 at gmail.com>
Date:   Fri Aug 14 10:53:59 2015 +0530

    modified to implement more module records
    
    Conflicts:
    	oox/source/ole/vbaexport.cxx
    
    Change-Id: I292869ffd8b2e5aa5d2ba865c237ed1536db3fdb

diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 578da98..1b82b8e 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -537,30 +537,33 @@ void writePROJECTCOOKIE(SvStream& rStrm)
 }
 
 // section 2.3.4.2.3.2.1

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list