xref: /aoo4110/main/oox/inc/oox/ole/vbahelper.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef OOX_OLE_VBAHELPER_HXX
25 #define OOX_OLE_VBAHELPER_HXX
26 
27 #include "oox/helper/binarystreambase.hxx"
28 
29 namespace oox { class BinaryInputStream; }
30 
31 namespace oox {
32 namespace ole {
33 
34 // Directory stream record identifiers ========================================
35 
36 const sal_uInt16 VBA_ID_MODULECOOKIE            = 0x002C;
37 const sal_uInt16 VBA_ID_MODULEDOCSTRING         = 0x001C;
38 const sal_uInt16 VBA_ID_MODULEDOCSTRINGUNICODE  = 0x0048;
39 const sal_uInt16 VBA_ID_MODULEEND               = 0x002B;
40 const sal_uInt16 VBA_ID_MODULEHELPCONTEXT       = 0x001E;
41 const sal_uInt16 VBA_ID_MODULENAME              = 0x0019;
42 const sal_uInt16 VBA_ID_MODULENAMEUNICODE       = 0x0047;
43 const sal_uInt16 VBA_ID_MODULEOFFSET            = 0x0031;
44 const sal_uInt16 VBA_ID_MODULEPRIVATE           = 0x0028;
45 const sal_uInt16 VBA_ID_MODULEREADONLY          = 0x0025;
46 const sal_uInt16 VBA_ID_MODULESTREAMNAME        = 0x001A;
47 const sal_uInt16 VBA_ID_MODULESTREAMNAMEUNICODE = 0x0032;
48 const sal_uInt16 VBA_ID_MODULETYPEDOCUMENT      = 0x0022;
49 const sal_uInt16 VBA_ID_MODULETYPEPROCEDURAL    = 0x0021;
50 const sal_uInt16 VBA_ID_PROJECTCODEPAGE         = 0x0003;
51 const sal_uInt16 VBA_ID_PROJECTEND              = 0x0010;
52 const sal_uInt16 VBA_ID_PROJECTMODULES          = 0x000F;
53 const sal_uInt16 VBA_ID_PROJECTNAME             = 0x0004;
54 const sal_uInt16 VBA_ID_PROJECTVERSION          = 0x0009;
55 
56 // ============================================================================
57 
58 /** Static helper functions for the VBA filters. */
59 class VbaHelper
60 {
61 public:
62     /** Returns the full Basic script URL from a VBA module and macro name.
63         The script is assumed to be in a document library. */
64     static ::rtl::OUString getBasicScriptUrl(
65                             const ::rtl::OUString& rLibraryName,
66                             const ::rtl::OUString& rModuleName,
67                             const ::rtl::OUString& rMacroName );
68 
69     /** Reads the next record from the VBA directory stream 'dir'.
70 
71         @param rnRecId  (out parameter) The record identifier of the new record.
72         @param rRecData  (out parameter) The contents of the new record.
73         @param rInStrm  The 'dir' stream.
74 
75         @return  True = next record successfully read. False on any error, or
76             if the stream is EOF.
77      */
78     static bool         readDirRecord(
79                             sal_uInt16& rnRecId,
80                             StreamDataSequence& rRecData,
81                             BinaryInputStream& rInStrm );
82 
83     /** Extracts a key/value pair from a string separated by an equality sign.
84 
85         @param rKey  (out parameter) The key before the separator.
86         @param rValue  (out parameter) The value following the separator.
87         @param rCodeLine  The source key/value pair.
88 
89         @return  True = Equality sign separator found, and the returned key and
90             value are not empty. False otherwise.
91      */
92     static bool         extractKeyValue(
93                             ::rtl::OUString& rKey,
94                             ::rtl::OUString& rValue,
95                             const ::rtl::OUString& rKeyValue );
96 
97 private:
98                         VbaHelper();
99                         ~VbaHelper();
100 };
101 
102 // ============================================================================
103 
104 } // namespace ole
105 } // namespace oox
106 
107 #endif
108