Get the style color and number just once
[LibreOffice.git] / include / oox / ole / vbaexport.hxx
bloba8c763c555c0dc71f3e3e185abb7882e5a31b596
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #ifndef INCLUDED_OOX_OLE_VBAEXPORT_HXX
11 #define INCLUDED_OOX_OLE_VBAEXPORT_HXX
13 #include <cstddef>
15 #include <com/sun/star/uno/Reference.hxx>
16 #include <oox/dllapi.h>
17 #include <rtl/ustring.hxx>
18 #include <sal/types.h>
20 class SotStorage;
21 class SvStream;
22 class SvMemoryStream;
24 namespace com::sun::star {
25 namespace container { class XNameContainer; }
26 namespace frame { class XModel; }
27 namespace script { class XLibraryContainer; }
30 class OOX_DLLPUBLIC VbaExport
32 public:
33 VbaExport(css::uno::Reference<css::frame::XModel> xModel);
35 void exportVBA(SotStorage* pRootStorage);
37 bool containsVBAProject();
39 private:
41 css::uno::Reference<css::container::XNameContainer>
42 getBasicLibrary() const;
44 css::uno::Reference<css::script::XLibraryContainer>
45 getLibraryContainer() const;
47 OUString getProjectName() const;
48 rtl_TextEncoding getVBATextEncoding() const;
50 css::uno::Reference<css::frame::XModel> mxModel;
53 class VBACompressionChunk
55 public:
57 VBACompressionChunk(SvStream& rCompressedStream, const sal_uInt8* pData, std::size_t nChunkSize);
59 void write();
61 private:
62 SvStream& mrCompressedStream;
63 const sal_uInt8* mpUncompressedData;
64 sal_uInt8* mpCompressedChunkStream;
66 // same as DecompressedChunkEnd in the spec
67 std::size_t mnChunkSize;
69 // CompressedCurrent according to the spec
70 sal_uInt64 mnCompressedCurrent;
72 // CompressedEnd according to the spec
73 sal_uInt64 mnCompressedEnd;
75 // DecompressedCurrent according to the spec
76 sal_uInt64 mnDecompressedCurrent;
78 // DecompressedEnd according to the spec
79 sal_uInt64 mnDecompressedEnd;
81 static void PackCompressedChunkSize(size_t nSize, sal_uInt16& rHeader);
83 static void PackCompressedChunkFlag(bool bCompressed, sal_uInt16& rHeader);
85 static void PackCompressedChunkSignature(sal_uInt16& rHeader);
87 void compressTokenSequence();
89 void compressToken(size_t index, sal_uInt8& nFlagByte);
91 static void SetFlagBit(size_t index, bool bVal, sal_uInt8& rFlag);
93 sal_uInt16 CopyToken(size_t nLength, size_t nOffset);
95 void match(size_t& rLength, size_t& rOffset);
97 void CopyTokenHelp(sal_uInt16& rLengthMask, sal_uInt16& rOffsetMask,
98 sal_uInt16& rBitCount, sal_uInt16& rMaximumLength);
100 void writeRawChunk();
102 sal_uInt16 handleHeader(bool bCompressed);
105 class OOX_DLLPUBLIC VBACompression
107 public:
108 VBACompression(SvStream& rCompressedStream,
109 SvMemoryStream& rUncompressedStream);
111 void write();
113 private:
114 SvStream& mrCompressedStream;
115 SvMemoryStream& mrUncompressedStream;
118 class OOX_DLLPUBLIC VBAEncryption
120 public:
121 VBAEncryption(const sal_uInt8* pData,
122 const sal_uInt16 nLength,
123 SvStream& rEncryptedData,
124 sal_uInt8 nProjKey,
125 rtl_TextEncoding eTextEncoding);
127 void write();
129 static sal_uInt8 calculateProjKey(const OUString& rString);
131 private:
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
141 sal_uInt8 mnSeed; // the seed value
142 sal_uInt8 mnVersionEnc; // the version encoding
143 rtl_TextEncoding meTextEncoding; // the VBA text encoding on export
145 void writeSeed();
146 void writeVersionEnc();
147 void writeProjKeyEnc();
148 void writeIgnoredEnc();
149 void writeDataLengthEnc();
150 void writeDataEnc();
153 #endif
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */