Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _PROPREAD_HXX_
30 : : #define _PROPREAD_HXX_
31 : :
32 : : #include <map>
33 : : #include <boost/ptr_container/ptr_vector.hpp>
34 : :
35 : : #include <tools/solar.h>
36 : : #include <sot/storage.hxx>
37 : : #include <tools/gen.hxx>
38 : : #include <tools/stream.hxx>
39 : :
40 : : #include <tools/string.hxx>
41 : :
42 : : // SummaryInformation
43 : : #define PID_TITLE 0x02
44 : : #define PID_SUBJECT 0x03
45 : : #define PID_AUTHOR 0x04
46 : : #define PID_KEYWORDS 0x05
47 : : #define PID_COMMENTS 0x06
48 : : #define PID_TEMPLATE 0x07
49 : : #define PID_LASTAUTHOR 0x08
50 : : #define PID_REVNUMBER 0x09
51 : : #define PID_EDITTIME 0x0a
52 : : #define PID_LASTPRINTED_DTM 0x0b
53 : : #define PID_CREATE_DTM 0x0c
54 : : #define PID_LASTSAVED_DTM 0x0d
55 : :
56 : : // DocumentSummaryInformation
57 : : #define PID_CATEGORY 0x02
58 : : #define PID_PRESFORMAT 0x03
59 : : #define PID_BYTECOUNT 0x04
60 : : #define PID_LINECOUNT 0x05
61 : : #define PID_PARACOUNT 0x06
62 : : #define PID_SLIDECOUNT 0x07
63 : : #define PID_NOTECOUNT 0x08
64 : : #define PID_HIDDENCOUNT 0x09
65 : : #define PID_MMCLIPCOUNT 0x0a
66 : : #define PID_SCALE 0x0b
67 : : #define PID_HEADINGPAIR 0x0c
68 : : #define PID_DOCPARTS 0x0d
69 : : #define PID_MANAGER 0x0e
70 : : #define PID_COMPANY 0x0f
71 : : #define PID_LINKSDIRTY 0x10
72 : :
73 : : #define VT_EMPTY 0
74 : : #define VT_NULL 1
75 : : #define VT_I2 2
76 : : #define VT_I4 3
77 : : #define VT_R4 4
78 : : #define VT_R8 5
79 : : #define VT_CY 6
80 : : #define VT_DATE 7
81 : : #define VT_BSTR 8
82 : : #define VT_UI4 9
83 : : #define VT_ERROR 10
84 : : #define VT_BOOL 11
85 : : #define VT_VARIANT 12
86 : : #define VT_DECIMAL 14
87 : : #define VT_I1 16
88 : : #define VT_UI1 17
89 : : #define VT_UI2 18
90 : : #define VT_I8 20
91 : : #define VT_UI8 21
92 : : #define VT_INT 22
93 : : #define VT_UINT 23
94 : : #define VT_LPSTR 30
95 : : #define VT_LPWSTR 31
96 : : #define VT_FILETIME 64
97 : : #define VT_BLOB 65
98 : : #define VT_STREAM 66
99 : : #define VT_STORAGE 67
100 : : #define VT_STREAMED_OBJECT 68
101 : : #define VT_STORED_OBJECT 69
102 : : #define VT_BLOB_OBJECT 70
103 : : #define VT_CF 71
104 : : #define VT_CLSID 72
105 : : #define VT_VECTOR 0x1000
106 : : #define VT_ARRAY 0x2000
107 : : #define VT_BYREF 0x4000
108 : : #define VT_TYPEMASK 0xFFF
109 : :
110 : : // ------------------------------------------------------------------------
111 : :
112 : : typedef std::map<String,sal_uInt32> Dictionary;
113 : :
114 : : struct PropEntry
115 : : {
116 : : sal_uInt32 mnId;
117 : : sal_uInt32 mnSize;
118 : : sal_uInt16 mnTextEnc;
119 : : sal_uInt8* mpBuf;
120 : :
121 : : PropEntry( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBufSize, sal_uInt16 nTextEnc );
122 : : PropEntry( const PropEntry& rProp );
123 [ + - ]: 150 : ~PropEntry() { delete[] mpBuf; } ;
124 : :
125 : : const PropEntry& operator=(const PropEntry& rPropEntry);
126 : : };
127 : :
128 [ - + ]: 24 : class PropItem : public SvMemoryStream
129 : : {
130 : : sal_uInt16 mnTextEnc;
131 : :
132 : : public :
133 : 24 : PropItem(){};
134 : : void Clear();
135 : :
136 : 18 : void SetTextEncoding( sal_uInt16 nTextEnc ){ mnTextEnc = nTextEnc; };
137 : : sal_Bool Read( String& rString, sal_uInt32 nType = VT_EMPTY, sal_Bool bDwordAlign = sal_True );
138 : : PropItem& operator=( PropItem& rPropItem );
139 : :
140 : : using SvStream::Read;
141 : : };
142 : :
143 : : // ------------------------------------------------------------------------
144 : :
145 : 42 : class Section
146 : : {
147 : : sal_uInt16 mnTextEnc;
148 : : boost::ptr_vector<PropEntry> maEntries;
149 : :
150 : : protected:
151 : :
152 : : sal_uInt8 aFMTID[ 16 ];
153 : :
154 : : void AddProperty( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBufSize );
155 : :
156 : : public:
157 : : Section( const sal_uInt8* pFMTID );
158 : : Section( const Section& rSection );
159 : :
160 : : Section& operator=( const Section& rSection );
161 : : sal_Bool GetProperty( sal_uInt32 nId, PropItem& rPropItem );
162 : : sal_Bool GetDictionary( Dictionary& rDict );
163 : 33 : const sal_uInt8* GetFMTID() const { return aFMTID; };
164 : : void Read( SvStorageStream* pStrm );
165 : : };
166 : :
167 : : // ------------------------------------------------------------------------
168 : :
169 [ + - ]: 12 : class PropRead
170 : : {
171 : : sal_Bool mbStatus;
172 : : SvStorageStreamRef mpSvStream;
173 : :
174 : : sal_uInt16 mnByteOrder;
175 : : sal_uInt16 mnFormat;
176 : : sal_uInt16 mnVersionLo;
177 : : sal_uInt16 mnVersionHi;
178 : : sal_uInt8 mApplicationCLSID[ 16 ];
179 : : boost::ptr_vector<Section> maSections;
180 : :
181 : : void AddSection( Section& rSection );
182 : :
183 : : public:
184 : : PropRead( SvStorage& rSvStorage, const String& rName );
185 : :
186 : : PropRead& operator=( const PropRead& rPropRead );
187 : : const Section* GetSection( const sal_uInt8* pFMTID );
188 : 12 : sal_Bool IsValid() const { return mbStatus; };
189 : : void Read();
190 : : };
191 : :
192 : :
193 : : #endif
194 : :
195 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|