LibreOffice Module oox (master) 1
vbaexport.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef INCLUDED_OOX_OLE_VBAEXPORT_HXX
11#define INCLUDED_OOX_OLE_VBAEXPORT_HXX
12
13#include <cstddef>
14
15#include <com/sun/star/uno/Reference.hxx>
16#include <oox/dllapi.h>
17#include <rtl/ustring.hxx>
18#include <sal/types.h>
19
20class SotStorage;
21class SvStream;
22class SvMemoryStream;
23
24namespace com::sun::star {
25 namespace container { class XNameContainer; }
26 namespace frame { class XModel; }
27 namespace script { class XLibraryContainer; }
28}
29
31{
32public:
33 VbaExport(css::uno::Reference<css::frame::XModel> xModel);
34
35 void exportVBA(SotStorage* pRootStorage);
36
37 bool containsVBAProject();
38
39private:
40
41 css::uno::Reference<css::container::XNameContainer>
42 getBasicLibrary() const;
43
44 css::uno::Reference<css::script::XLibraryContainer>
45 getLibraryContainer() const;
46
47 OUString getProjectName() const;
48 rtl_TextEncoding getVBATextEncoding() const;
49
50 css::uno::Reference<css::frame::XModel> mxModel;
51};
52
54{
55public:
56
57 VBACompressionChunk(SvStream& rCompressedStream, const sal_uInt8* pData, std::size_t nChunkSize);
58
59 void write();
60
61private:
65
66 // same as DecompressedChunkEnd in the spec
67 std::size_t mnChunkSize;
68
69 // CompressedCurrent according to the spec
71
72 // CompressedEnd according to the spec
73 sal_uInt64 mnCompressedEnd;
74
75 // DecompressedCurrent according to the spec
77
78 // DecompressedEnd according to the spec
80
81 static void PackCompressedChunkSize(size_t nSize, sal_uInt16& rHeader);
82
83 static void PackCompressedChunkFlag(bool bCompressed, sal_uInt16& rHeader);
84
85 static void PackCompressedChunkSignature(sal_uInt16& rHeader);
86
88
89 void compressToken(size_t index, sal_uInt8& nFlagByte);
90
91 static void SetFlagBit(size_t index, bool bVal, sal_uInt8& rFlag);
92
93 sal_uInt16 CopyToken(size_t nLength, size_t nOffset);
94
95 void match(size_t& rLength, size_t& rOffset);
96
97 void CopyTokenHelp(sal_uInt16& rLengthMask, sal_uInt16& rOffsetMask,
98 sal_uInt16& rBitCount, sal_uInt16& rMaximumLength);
99
100 void writeRawChunk();
101
102 sal_uInt16 handleHeader(bool bCompressed);
103};
104
106{
107public:
108 VBACompression(SvStream& rCompressedStream,
109 SvMemoryStream& rUncompressedStream);
110
111 void write();
112
113private:
116};
117
119{
120public:
122 const sal_uInt16 nLength,
123 SvStream& rEncryptedData,
124 sal_uInt8 nProjKey,
125 rtl_TextEncoding eTextEncoding);
126
127 void write();
128
129 static sal_uInt8 calculateProjKey(const OUString& rString);
130
131private:
132 const sal_uInt8* mpData; // an array of bytes to be obfuscated
133 const sal_uInt16 mnLength; // the length of Data
134 SvStream& mrEncryptedData; // Encrypted Data Structure
135 sal_uInt8 mnUnencryptedByte1; // the last unencrypted byte read or written
136 sal_uInt8 mnEncryptedByte1; // the last encrypted byte read or written
137 sal_uInt8 mnEncryptedByte2; // the next-to-last encrypted byte read or written
138 sal_Unicode mnProjKey; // a project-specific encryption key
139 sal_uInt8 mnIgnoredLength; // the length in bytes of IgnoredEnc
140
141 sal_uInt8 mnSeed; // the seed value
142 sal_uInt8 mnVersionEnc; // the version encoding
143 rtl_TextEncoding meTextEncoding; // the VBA text encoding on export
144
145 void writeSeed();
146 void writeVersionEnc();
147 void writeProjKeyEnc();
148 void writeIgnoredEnc();
149 void writeDataLengthEnc();
150 void writeDataEnc();
151};
152
153#endif
154
155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 script
void compressToken(size_t index, sal_uInt8 &nFlagByte)
Definition: vbaexport.cxx:195
sal_uInt64 mnDecompressedEnd
Definition: vbaexport.hxx:79
VBACompressionChunk(SvStream &rCompressedStream, const sal_uInt8 *pData, std::size_t nChunkSize)
Definition: vbaexport.cxx:85
void CopyTokenHelp(sal_uInt16 &rLengthMask, sal_uInt16 &rOffsetMask, sal_uInt16 &rBitCount, sal_uInt16 &rMaximumLength)
Definition: vbaexport.cxx:295
static void PackCompressedChunkSignature(sal_uInt16 &rHeader)
Definition: vbaexport.cxx:171
sal_uInt16 CopyToken(size_t nLength, size_t nOffset)
Definition: vbaexport.cxx:239
const sal_uInt8 * mpUncompressedData
Definition: vbaexport.hxx:63
void match(size_t &rLength, size_t &rOffset)
Definition: vbaexport.cxx:254
SvStream & mrCompressedStream
Definition: vbaexport.hxx:62
std::size_t mnChunkSize
Definition: vbaexport.hxx:67
static void SetFlagBit(size_t index, bool bVal, sal_uInt8 &rFlag)
Definition: vbaexport.cxx:231
sal_uInt64 mnCompressedEnd
Definition: vbaexport.hxx:73
sal_uInt16 handleHeader(bool bCompressed)
Definition: vbaexport.cxx:103
sal_uInt64 mnCompressedCurrent
Definition: vbaexport.hxx:70
sal_uInt8 * mpCompressedChunkStream
Definition: vbaexport.hxx:64
static void PackCompressedChunkFlag(bool bCompressed, sal_uInt16 &rHeader)
Definition: vbaexport.cxx:163
static void PackCompressedChunkSize(size_t nSize, sal_uInt16 &rHeader)
Definition: vbaexport.cxx:155
void compressTokenSequence()
Definition: vbaexport.cxx:178
sal_uInt64 mnDecompressedCurrent
Definition: vbaexport.hxx:76
SvStream & mrCompressedStream
Definition: vbaexport.hxx:114
SvMemoryStream & mrUncompressedStream
Definition: vbaexport.hxx:115
SvStream & mrEncryptedData
Definition: vbaexport.hxx:134
sal_uInt8 mnEncryptedByte2
Definition: vbaexport.hxx:137
sal_uInt8 mnEncryptedByte1
Definition: vbaexport.hxx:136
sal_uInt8 mnIgnoredLength
Definition: vbaexport.hxx:139
const sal_uInt16 mnLength
Definition: vbaexport.hxx:133
sal_Unicode mnProjKey
Definition: vbaexport.hxx:138
const sal_uInt8 * mpData
Definition: vbaexport.hxx:132
sal_uInt8 mnSeed
Definition: vbaexport.hxx:141
rtl_TextEncoding meTextEncoding
Definition: vbaexport.hxx:143
sal_uInt8 mnVersionEnc
Definition: vbaexport.hxx:142
sal_uInt8 mnUnencryptedByte1
Definition: vbaexport.hxx:135
css::uno::Reference< css::frame::XModel > mxModel
Definition: vbaexport.hxx:50
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
std::unique_ptr< sal_Int32[]> pData
Reference< XModel > xModel
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
sal_Int32 nLength