summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-08-14 23:47:28 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-09-10 02:12:36 +0200
commit4f1f317a0bf7436b1624d60df96a25f4a8b9a58b (patch)
treeb22308934954a23ba439ed45595074b3eead40d2
parenta1b31c0e36d7788ac1dfc3b623756f72f1cb3d78 (diff)
extract compression methods to make them testable
Change-Id: I2ad28134ef723872b9940c02657ee89758efa06f
-rw-r--r--include/oox/ole/vbaexport.hxx69
-rw-r--r--oox/source/ole/vbaexport.cxx68
2 files changed, 70 insertions, 67 deletions
diff --git a/include/oox/ole/vbaexport.hxx b/include/oox/ole/vbaexport.hxx
index 88a0561a8717..6993fe51284d 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 9d6d52ae7963..904fbf9dd0fa 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)
{