update dev300-m58
[ooovba.git] / svx / source / msfilter / msvbasic.hxx
blob93ae0a2a2781e56a9d25c099ec2b28f9c841cb5b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: msvbasic.hxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
33 #ifndef _MSVBASIC_HXX
34 #define _MSVBASIC_HXX
36 #ifdef _SOLAR_H
37 #include <tools/solar.h>
38 #endif
39 #include <tools/debug.hxx>
40 #ifndef _SVSTOR_HXX //autogen
41 #include <sot/storage.hxx>
42 #endif
43 #include <tools/dynary.hxx>
44 #ifndef __SGI_STL_VECTOR
45 #include <vector>
46 #endif
47 #include<map>
48 #include <com/sun/star/script/ModuleType.hpp>
49 using namespace ::com::sun::star::script::ModuleType;
51 /* class VBA:
52 * The VBA class provides a set of methods to handle Visual Basic For
53 * Applications streams, the constructor is given the root ole2 stream
54 * of the document, Open reads the VBA project file and figures out
55 * the number of VBA streams, and the offset of the data within them.
56 * Decompress decompresses a particular numbered stream, NoStreams returns
57 * this number, and StreamName can give you the streams name. Decompress
58 * will return a string with the decompressed data. The optional extra
59 * argument will be set if not NULL to 1 in the case of a string overflow,
60 * if I can figure out how to do that.
62 * Otherwise it is possible to inherit from VBA and implement a Output
63 * member which gets called with each 4096 output sized block.
65 * cmc
66 * */
68 DECLARE_DYNARRAY(StringArray,String *)
70 // #117718# define internal types to distinguish between
71 // module types, form, class & normal
72 // #i37965# DR 2004-12-03: add "Document", used in Excel for macros attached to sheet
74 // #117718# define map to hold types of module
76 typedef sal_Int32 ModType;
77 typedef ::std::map< UniString,
78 ModType > ModuleTypeHash;
80 class VBA_Impl
82 public:
83 VBA_Impl(SvStorage &rIn, bool bCmmntd = true);
84 ~VBA_Impl();
85 //0 for failure, 1 for success
86 bool Open( const String &rToplevel, const String &rSublevel);
87 const StringArray & Decompress(sal_uInt16 nIndex, int *pOverflow=0);
88 sal_uInt16 GetNoStreams() const { return nOffsets; }
89 const String &GetStreamName(sal_uInt16 nIndex) const
91 DBG_ASSERT( nIndex < nOffsets, "Index out of range" );
92 return pOffsets[ nIndex ].sName;
94 //I'm the method that would be made virtual to make this class
95 //useful elsewhere
96 void Output(int len, const sal_uInt8 *data);
98 // #117718# member map of module names to types of module
99 ModType GetModuleType( const UniString& rModuleName );
100 rtl::OUString& ProjectName() { return msProjectName; }
101 void SetProjectName( const rtl::OUString& rPName ) { msProjectName = rPName; }
102 const std::vector<rtl::OUString>& ProjectReferences() { return maPrjReferences; }
103 void AddProjectReference( const rtl::OUString& rProject ) { maPrjReferences.push_back( rProject); }
104 SvStorage* GetStorage() { return xStor; }
105 private:
106 std::vector<rtl::OUString> maReferences;
107 std::vector<rtl::OUString> maPrjReferences;
108 struct VBAOffset_Impl
110 String sName;
111 sal_uInt32 nOffset;
114 // #117718# member map of module names to types of module
115 ModuleTypeHash mhModHash;
116 SvStorageRef xVBA;
117 StringArray aVBAStrings;
118 String sComment;
119 SvStorageRef xStor;
120 VBAOffset_Impl *pOffsets;
121 sal_uInt16 nOffsets;
122 enum Limits {nWINDOWLEN = 4096};
123 sal_uInt8 aHistory[nWINDOWLEN];
124 rtl_TextEncoding meCharSet;
125 bool bCommented;
126 bool mbMac;
127 int nLines;
129 //0 for failure, anything else for success
130 int ReadVBAProject(const SvStorageRef &rxVBAStorage);
131 int DecompressVBA(int index, SvStorageStreamRef &rxVBAStream);
132 sal_uInt8 ReadPString(SvStorageStreamRef &xVBAProject, bool bIsUnicode);
133 rtl::OUString msProjectName;
136 #endif
138 /* vi:set tabstop=4 shiftwidth=4 expandtab: */