1*e3508121SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*e3508121SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*e3508121SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*e3508121SAndrew Rist * distributed with this work for additional information
6*e3508121SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*e3508121SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*e3508121SAndrew Rist * "License"); you may not use this file except in compliance
9*e3508121SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*e3508121SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*e3508121SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*e3508121SAndrew Rist * software distributed under the License is distributed on an
15*e3508121SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e3508121SAndrew Rist * KIND, either express or implied. See the License for the
17*e3508121SAndrew Rist * specific language governing permissions and limitations
18*e3508121SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*e3508121SAndrew Rist *************************************************************/
21*e3508121SAndrew Rist
22*e3508121SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef OOX_DUMP_DUMPERBASE_HXX
25cdf0e10cSrcweir #define OOX_DUMP_DUMPERBASE_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <math.h>
28cdf0e10cSrcweir #include <vector>
29cdf0e10cSrcweir #include <stack>
30cdf0e10cSrcweir #include <set>
31cdf0e10cSrcweir #include <map>
32cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
33cdf0e10cSrcweir #include <rtl/strbuf.hxx>
34cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
35cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
36cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp>
37cdf0e10cSrcweir #include <comphelper/mediadescriptor.hxx>
38cdf0e10cSrcweir #include "oox/helper/binaryinputstream.hxx"
39cdf0e10cSrcweir #include "oox/helper/helper.hxx"
40cdf0e10cSrcweir #include "oox/helper/storagebase.hxx"
41cdf0e10cSrcweir
42cdf0e10cSrcweir #define OOX_INCLUDE_DUMPER (OSL_DEBUG_LEVEL > 0)
43cdf0e10cSrcweir
44cdf0e10cSrcweir #if OOX_INCLUDE_DUMPER
45cdf0e10cSrcweir
46cdf0e10cSrcweir namespace com { namespace sun { namespace star {
47cdf0e10cSrcweir namespace io { class XInputStream; }
48cdf0e10cSrcweir namespace io { class XOutputStream; }
49cdf0e10cSrcweir namespace io { class XTextOutputStream; }
50cdf0e10cSrcweir namespace uno { class XComponentContext; }
51cdf0e10cSrcweir } } }
52cdf0e10cSrcweir
53cdf0e10cSrcweir namespace comphelper {
54cdf0e10cSrcweir class IDocPasswordVerifier;
55cdf0e10cSrcweir }
56cdf0e10cSrcweir
57cdf0e10cSrcweir namespace oox {
58cdf0e10cSrcweir class BinaryOutputStream;
59cdf0e10cSrcweir class TextInputStream;
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
62cdf0e10cSrcweir namespace oox { namespace core {
63cdf0e10cSrcweir class FilterBase;
64cdf0e10cSrcweir } }
65cdf0e10cSrcweir
66cdf0e10cSrcweir namespace oox {
67cdf0e10cSrcweir namespace dump {
68cdf0e10cSrcweir
69cdf0e10cSrcweir // ============================================================================
70cdf0e10cSrcweir
71cdf0e10cSrcweir #define OOX_DUMP_UNUSED "unused"
72cdf0e10cSrcweir #define OOX_DUMP_UNKNOWN "?unknown"
73cdf0e10cSrcweir
74cdf0e10cSrcweir #define OOX_DUMP_ERRASCII( ascii ) "?err:" ascii
75cdf0e10cSrcweir #define OOX_DUMP_ERRSTRING( ascii ) CREATE_OUSTRING( OOX_DUMP_ERRASCII( ascii ) )
76cdf0e10cSrcweir
77cdf0e10cSrcweir #define OOX_DUMP_ERR_NOMAP OOX_DUMP_ERRSTRING( "no-map" )
78cdf0e10cSrcweir #define OOX_DUMP_ERR_NONAME OOX_DUMP_ERRSTRING( "no-name" )
79cdf0e10cSrcweir #define OOX_DUMP_ERR_STREAM OOX_DUMP_ERRSTRING( "stream-error" )
80cdf0e10cSrcweir
81cdf0e10cSrcweir #define OOX_DUMP_DUMPEXT CREATE_OUSTRING( ".dump" )
82cdf0e10cSrcweir
83cdf0e10cSrcweir const sal_Unicode OOX_DUMP_STRQUOTE = '\'';
84cdf0e10cSrcweir const sal_Unicode OOX_DUMP_FMLASTRQUOTE = '"';
85cdf0e10cSrcweir const sal_Unicode OOX_DUMP_ADDRABS = '$';
86cdf0e10cSrcweir const sal_Unicode OOX_DUMP_R1C1ROW = 'R';
87cdf0e10cSrcweir const sal_Unicode OOX_DUMP_R1C1COL = 'C';
88cdf0e10cSrcweir const sal_Unicode OOX_DUMP_R1C1OPEN = '[';
89cdf0e10cSrcweir const sal_Unicode OOX_DUMP_R1C1CLOSE = ']';
90cdf0e10cSrcweir const sal_Unicode OOX_DUMP_RANGESEP = ':';
91cdf0e10cSrcweir const sal_Unicode OOX_DUMP_BASECLASS = 'B';
92cdf0e10cSrcweir const sal_Unicode OOX_DUMP_FUNCSEP = ',';
93cdf0e10cSrcweir const sal_Unicode OOX_DUMP_LISTSEP = ',';
94cdf0e10cSrcweir const sal_Unicode OOX_DUMP_TABSEP = '!';
95cdf0e10cSrcweir const sal_Unicode OOX_DUMP_ARRAYSEP = ';';
96cdf0e10cSrcweir const sal_Unicode OOX_DUMP_EMPTYVALUE = '~';
97cdf0e10cSrcweir const sal_Unicode OOX_DUMP_CMDPROMPT = '?';
98cdf0e10cSrcweir const sal_Unicode OOX_DUMP_PLACEHOLDER = '\x01';
99cdf0e10cSrcweir
100cdf0e10cSrcweir typedef ::std::pair< ::rtl::OUString, ::rtl::OUString > OUStringPair;
101cdf0e10cSrcweir typedef ::std::pair< sal_Int64, sal_Int64 > Int64Pair;
102cdf0e10cSrcweir
103cdf0e10cSrcweir typedef ::std::vector< ::rtl::OUString > OUStringVector;
104cdf0e10cSrcweir typedef ::std::vector< sal_Int64 > Int64Vector;
105cdf0e10cSrcweir
106cdf0e10cSrcweir // ============================================================================
107cdf0e10cSrcweir // ============================================================================
108cdf0e10cSrcweir
109cdf0e10cSrcweir /** Static helper functions for system file and stream access. */
110cdf0e10cSrcweir class InputOutputHelper
111cdf0e10cSrcweir {
112cdf0e10cSrcweir public:
113cdf0e10cSrcweir // file names -------------------------------------------------------------
114cdf0e10cSrcweir
115cdf0e10cSrcweir static ::rtl::OUString convertFileNameToUrl( const ::rtl::OUString& rFileName );
116cdf0e10cSrcweir static sal_Int32 getFileNamePos( const ::rtl::OUString& rFileUrl );
117cdf0e10cSrcweir static ::rtl::OUString getFileNameExtension( const ::rtl::OUString& rFileUrl );
118cdf0e10cSrcweir
119cdf0e10cSrcweir // input streams ----------------------------------------------------------
120cdf0e10cSrcweir
121cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
122cdf0e10cSrcweir openInputStream(
123cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
124cdf0e10cSrcweir const ::rtl::OUString& rFileName );
125cdf0e10cSrcweir
126cdf0e10cSrcweir // output streams ---------------------------------------------------------
127cdf0e10cSrcweir
128cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
129cdf0e10cSrcweir openOutputStream(
130cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
131cdf0e10cSrcweir const ::rtl::OUString& rFileName );
132cdf0e10cSrcweir
133cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextOutputStream >
134cdf0e10cSrcweir openTextOutputStream(
135cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
136cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rxOutStrm,
137cdf0e10cSrcweir rtl_TextEncoding eTextEnc );
138cdf0e10cSrcweir
139cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextOutputStream >
140cdf0e10cSrcweir openTextOutputStream(
141cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
142cdf0e10cSrcweir const ::rtl::OUString& rFileName,
143cdf0e10cSrcweir rtl_TextEncoding eTextEnc );
144cdf0e10cSrcweir };
145cdf0e10cSrcweir
146cdf0e10cSrcweir // ============================================================================
147cdf0e10cSrcweir
148cdf0e10cSrcweir class BinaryInputStreamRef : public ::oox::BinaryInputStreamRef
149cdf0e10cSrcweir {
150cdf0e10cSrcweir public:
BinaryInputStreamRef()151cdf0e10cSrcweir inline BinaryInputStreamRef() {}
152cdf0e10cSrcweir
BinaryInputStreamRef(BinaryInputStream * pInStrm)153cdf0e10cSrcweir inline /*implicit*/ BinaryInputStreamRef( BinaryInputStream* pInStrm ) :
154cdf0e10cSrcweir ::oox::BinaryInputStreamRef( pInStrm ) {}
155cdf0e10cSrcweir
BinaryInputStreamRef(const::com::sun::star::uno::Reference<::com::sun::star::io::XInputStream> & rxInStrm)156cdf0e10cSrcweir inline /*implicit*/ BinaryInputStreamRef( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ) :
157cdf0e10cSrcweir ::oox::BinaryInputStreamRef( new BinaryXInputStream( rxInStrm, true ) ) {}
158cdf0e10cSrcweir
159cdf0e10cSrcweir template< typename StreamType >
BinaryInputStreamRef(const::boost::shared_ptr<StreamType> & rxInStrm)160cdf0e10cSrcweir inline /*implicit*/ BinaryInputStreamRef( const ::boost::shared_ptr< StreamType >& rxInStrm ) :
161cdf0e10cSrcweir ::oox::BinaryInputStreamRef( rxInStrm ) {}
162cdf0e10cSrcweir };
163cdf0e10cSrcweir
164cdf0e10cSrcweir // ============================================================================
165cdf0e10cSrcweir // ============================================================================
166cdf0e10cSrcweir
167cdf0e10cSrcweir /** Specifiers for atomic data types. */
168cdf0e10cSrcweir enum DataType
169cdf0e10cSrcweir {
170cdf0e10cSrcweir DATATYPE_VOID, /// No data type.
171cdf0e10cSrcweir DATATYPE_INT8, /// Signed 8-bit integer.
172cdf0e10cSrcweir DATATYPE_UINT8, /// Unsigned 8-bit integer.
173cdf0e10cSrcweir DATATYPE_INT16, /// Signed 16-bit integer.
174cdf0e10cSrcweir DATATYPE_UINT16, /// Unsigned 16-bit integer.
175cdf0e10cSrcweir DATATYPE_INT32, /// Signed 32-bit integer.
176cdf0e10cSrcweir DATATYPE_UINT32, /// Unsigned 32-bit integer.
177cdf0e10cSrcweir DATATYPE_INT64, /// Signed 64-bit integer.
178cdf0e10cSrcweir DATATYPE_UINT64, /// Unsigned 64-bit integer.
179cdf0e10cSrcweir DATATYPE_FLOAT, /// Floating-point, single precision.
180cdf0e10cSrcweir DATATYPE_DOUBLE /// Floating-point, double precision.
181cdf0e10cSrcweir };
182cdf0e10cSrcweir
183cdf0e10cSrcweir // ----------------------------------------------------------------------------
184cdf0e10cSrcweir
185cdf0e10cSrcweir /** Specifiers for the output format of values. */
186cdf0e10cSrcweir enum FormatType
187cdf0e10cSrcweir {
188cdf0e10cSrcweir FORMATTYPE_NONE, /// No numeric format (e.g. show name only).
189cdf0e10cSrcweir FORMATTYPE_DEC, /// Decimal.
190cdf0e10cSrcweir FORMATTYPE_HEX, /// Hexadecimal.
191cdf0e10cSrcweir FORMATTYPE_SHORTHEX, /// Hexadecimal, as short as possible (no leading zeros).
192cdf0e10cSrcweir FORMATTYPE_BIN, /// Binary.
193cdf0e10cSrcweir FORMATTYPE_FIX, /// Fixed-point.
194cdf0e10cSrcweir FORMATTYPE_BOOL /// Boolean ('true' or 'false').
195cdf0e10cSrcweir };
196cdf0e10cSrcweir
197cdf0e10cSrcweir // ----------------------------------------------------------------------------
198cdf0e10cSrcweir
199cdf0e10cSrcweir /** Describes the output format of a data item.
200cdf0e10cSrcweir
201cdf0e10cSrcweir Data items are written in the following format:
202cdf0e10cSrcweir
203cdf0e10cSrcweir <NAME>=<VALUE>=<NAME-FROM-LIST>
204cdf0e10cSrcweir
205cdf0e10cSrcweir NAME is the name of the data item. The name is contained in the member
206cdf0e10cSrcweir maItemName. If the name is empty, only the value is written (without a
207cdf0e10cSrcweir leading equality sign).
208cdf0e10cSrcweir
209cdf0e10cSrcweir VALUE is the numeric value of the data item. Its format is dependent on the
210cdf0e10cSrcweir output format given in the member meFmtType. If the format type is
211cdf0e10cSrcweir FORMATTYPE_NONE, no value is written.
212cdf0e10cSrcweir
213cdf0e10cSrcweir NAME-FROM-LIST is a symbolic name for the current value of the data item.
214cdf0e10cSrcweir Various types of name lists produce different names for values, which can
215cdf0e10cSrcweir be used for enumerations or names for single bits in bitfields (see class
216cdf0e10cSrcweir NameListBase and derived classes). The name of the list is given in the
217cdf0e10cSrcweir member maListName. If it is empty, no name is written for the value.
218cdf0e10cSrcweir */
219cdf0e10cSrcweir struct ItemFormat
220cdf0e10cSrcweir {
221cdf0e10cSrcweir DataType meDataType; /// Data type of the item.
222cdf0e10cSrcweir FormatType meFmtType; /// Output format for the value.
223cdf0e10cSrcweir ::rtl::OUString maItemName; /// Name of the item.
224cdf0e10cSrcweir ::rtl::OUString maListName; /// Name of a name list to be used for this item.
225cdf0e10cSrcweir
226cdf0e10cSrcweir explicit ItemFormat();
227cdf0e10cSrcweir
228cdf0e10cSrcweir void set( DataType eDataType, FormatType eFmtType, const ::rtl::OUString& rItemName );
229cdf0e10cSrcweir void set( DataType eDataType, FormatType eFmtType, const ::rtl::OUString& rItemName, const ::rtl::OUString& rListName );
230cdf0e10cSrcweir
231cdf0e10cSrcweir /** Initializes the struct from a vector of strings containing the item format.
232cdf0e10cSrcweir
233cdf0e10cSrcweir The vector must contain at least 2 strings. The struct is filled from
234cdf0e10cSrcweir the strings in the vector in the following order:
235cdf0e10cSrcweir 1) Data type (one of: [u]int8, [u]int16, [u]int32, [u]int64, float, double).
236cdf0e10cSrcweir 2) Format type (one of: dec, hex, shorthex, bin, fix, bool, unused, unknown).
237cdf0e10cSrcweir 3) Item name (optional).
238cdf0e10cSrcweir 4) Name list name (optional).
239cdf0e10cSrcweir
240cdf0e10cSrcweir @return Iterator pointing to the first unhandled string.
241cdf0e10cSrcweir */
242cdf0e10cSrcweir OUStringVector::const_iterator parse( const OUStringVector& rFormatVec );
243cdf0e10cSrcweir
244cdf0e10cSrcweir /** Initializes the struct from a string containing the item format.
245cdf0e10cSrcweir
246cdf0e10cSrcweir The string must have the following format:
247cdf0e10cSrcweir DATATYPE,FORMATTYPE[,ITEMNAME[,LISTNAME]]
248cdf0e10cSrcweir
249cdf0e10cSrcweir DATATYPE is the data type of the item (see above for possible values).
250cdf0e10cSrcweir FORMATTYPE is the format type of the item (see above for possible values).
251cdf0e10cSrcweir ITEMNAME is the name of the item (optional).
252cdf0e10cSrcweir LISTNAME is the name of a name list (optional).
253cdf0e10cSrcweir
254cdf0e10cSrcweir @return List containing remaining unhandled format strings.
255cdf0e10cSrcweir */
256cdf0e10cSrcweir OUStringVector parse( const ::rtl::OUString& rFormatStr );
257cdf0e10cSrcweir };
258cdf0e10cSrcweir
259cdf0e10cSrcweir // ============================================================================
260cdf0e10cSrcweir // ============================================================================
261cdf0e10cSrcweir
262cdf0e10cSrcweir struct Address
263cdf0e10cSrcweir {
264cdf0e10cSrcweir sal_Int32 mnCol;
265cdf0e10cSrcweir sal_Int32 mnRow;
Addressoox::dump::Address266cdf0e10cSrcweir inline explicit Address() : mnCol( 0 ), mnRow( 0 ) {}
Addressoox::dump::Address267cdf0e10cSrcweir inline explicit Address( sal_Int32 nCol, sal_Int32 nRow ) : mnCol( nCol ), mnRow( nRow ) {}
268cdf0e10cSrcweir };
269cdf0e10cSrcweir
270cdf0e10cSrcweir // ----------------------------------------------------------------------------
271cdf0e10cSrcweir
272cdf0e10cSrcweir struct Range
273cdf0e10cSrcweir {
274cdf0e10cSrcweir Address maFirst;
275cdf0e10cSrcweir Address maLast;
Rangeoox::dump::Range276cdf0e10cSrcweir inline explicit Range() {}
277cdf0e10cSrcweir };
278cdf0e10cSrcweir
279cdf0e10cSrcweir // ----------------------------------------------------------------------------
280cdf0e10cSrcweir
281cdf0e10cSrcweir typedef ::std::vector< Range > RangeList;
282cdf0e10cSrcweir
283cdf0e10cSrcweir // ============================================================================
284cdf0e10cSrcweir
285cdf0e10cSrcweir struct TokenAddress : public Address
286cdf0e10cSrcweir {
287cdf0e10cSrcweir bool mbRelCol;
288cdf0e10cSrcweir bool mbRelRow;
TokenAddressoox::dump::TokenAddress289cdf0e10cSrcweir inline explicit TokenAddress() : mbRelCol( false ), mbRelRow( false ) {}
290cdf0e10cSrcweir };
291cdf0e10cSrcweir
292cdf0e10cSrcweir // ----------------------------------------------------------------------------
293cdf0e10cSrcweir
294cdf0e10cSrcweir struct TokenRange
295cdf0e10cSrcweir {
296cdf0e10cSrcweir TokenAddress maFirst;
297cdf0e10cSrcweir TokenAddress maLast;
TokenRangeoox::dump::TokenRange298cdf0e10cSrcweir inline explicit TokenRange() {}
299cdf0e10cSrcweir };
300cdf0e10cSrcweir
301cdf0e10cSrcweir // ============================================================================
302cdf0e10cSrcweir // ============================================================================
303cdf0e10cSrcweir
304cdf0e10cSrcweir /** Static helper functions for formatted output to strings. */
305cdf0e10cSrcweir class StringHelper
306cdf0e10cSrcweir {
307cdf0e10cSrcweir public:
308cdf0e10cSrcweir // append string to string ------------------------------------------------
309cdf0e10cSrcweir
310cdf0e10cSrcweir static void appendChar( ::rtl::OUStringBuffer& rStr, sal_Unicode cChar, sal_Int32 nCount = 1 );
311cdf0e10cSrcweir static void appendString( ::rtl::OUStringBuffer& rStr, const ::rtl::OUString& rData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
312cdf0e10cSrcweir
313cdf0e10cSrcweir // append decimal ---------------------------------------------------------
314cdf0e10cSrcweir
315cdf0e10cSrcweir static void appendDec( ::rtl::OUStringBuffer& rStr, sal_uInt8 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
316cdf0e10cSrcweir static void appendDec( ::rtl::OUStringBuffer& rStr, sal_Int8 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
317cdf0e10cSrcweir static void appendDec( ::rtl::OUStringBuffer& rStr, sal_uInt16 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
318cdf0e10cSrcweir static void appendDec( ::rtl::OUStringBuffer& rStr, sal_Int16 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
319cdf0e10cSrcweir static void appendDec( ::rtl::OUStringBuffer& rStr, sal_uInt32 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
320cdf0e10cSrcweir static void appendDec( ::rtl::OUStringBuffer& rStr, sal_Int32 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
321cdf0e10cSrcweir static void appendDec( ::rtl::OUStringBuffer& rStr, sal_uInt64 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
322cdf0e10cSrcweir static void appendDec( ::rtl::OUStringBuffer& rStr, sal_Int64 nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
323cdf0e10cSrcweir static void appendDec( ::rtl::OUStringBuffer& rStr, double fData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' );
324cdf0e10cSrcweir
325cdf0e10cSrcweir // append hexadecimal -----------------------------------------------------
326cdf0e10cSrcweir
327cdf0e10cSrcweir static void appendHex( ::rtl::OUStringBuffer& rStr, sal_uInt8 nData, bool bPrefix = true );
328cdf0e10cSrcweir static void appendHex( ::rtl::OUStringBuffer& rStr, sal_Int8 nData, bool bPrefix = true );
329cdf0e10cSrcweir static void appendHex( ::rtl::OUStringBuffer& rStr, sal_uInt16 nData, bool bPrefix = true );
330cdf0e10cSrcweir static void appendHex( ::rtl::OUStringBuffer& rStr, sal_Int16 nData, bool bPrefix = true );
331cdf0e10cSrcweir static void appendHex( ::rtl::OUStringBuffer& rStr, sal_uInt32 nData, bool bPrefix = true );
332cdf0e10cSrcweir static void appendHex( ::rtl::OUStringBuffer& rStr, sal_Int32 nData, bool bPrefix = true );
333cdf0e10cSrcweir static void appendHex( ::rtl::OUStringBuffer& rStr, sal_uInt64 nData, bool bPrefix = true );
334cdf0e10cSrcweir static void appendHex( ::rtl::OUStringBuffer& rStr, sal_Int64 nData, bool bPrefix = true );
335cdf0e10cSrcweir static void appendHex( ::rtl::OUStringBuffer& rStr, double fData, bool bPrefix = true );
336cdf0e10cSrcweir
337cdf0e10cSrcweir // append shortened hexadecimal -------------------------------------------
338cdf0e10cSrcweir
339cdf0e10cSrcweir static void appendShortHex( ::rtl::OUStringBuffer& rStr, sal_uInt8 nData, bool bPrefix = true );
340cdf0e10cSrcweir static void appendShortHex( ::rtl::OUStringBuffer& rStr, sal_Int8 nData, bool bPrefix = true );
341cdf0e10cSrcweir static void appendShortHex( ::rtl::OUStringBuffer& rStr, sal_uInt16 nData, bool bPrefix = true );
342cdf0e10cSrcweir static void appendShortHex( ::rtl::OUStringBuffer& rStr, sal_Int16 nData, bool bPrefix = true );
343cdf0e10cSrcweir static void appendShortHex( ::rtl::OUStringBuffer& rStr, sal_uInt32 nData, bool bPrefix = true );
344cdf0e10cSrcweir static void appendShortHex( ::rtl::OUStringBuffer& rStr, sal_Int32 nData, bool bPrefix = true );
345cdf0e10cSrcweir static void appendShortHex( ::rtl::OUStringBuffer& rStr, sal_uInt64 nData, bool bPrefix = true );
346cdf0e10cSrcweir static void appendShortHex( ::rtl::OUStringBuffer& rStr, sal_Int64 nData, bool bPrefix = true );
347cdf0e10cSrcweir static void appendShortHex( ::rtl::OUStringBuffer& rStr, double fData, bool bPrefix = true );
348cdf0e10cSrcweir
349cdf0e10cSrcweir // append binary ----------------------------------------------------------
350cdf0e10cSrcweir
351cdf0e10cSrcweir static void appendBin( ::rtl::OUStringBuffer& rStr, sal_uInt8 nData, bool bDots = true );
352cdf0e10cSrcweir static void appendBin( ::rtl::OUStringBuffer& rStr, sal_Int8 nData, bool bDots = true );
353cdf0e10cSrcweir static void appendBin( ::rtl::OUStringBuffer& rStr, sal_uInt16 nData, bool bDots = true );
354cdf0e10cSrcweir static void appendBin( ::rtl::OUStringBuffer& rStr, sal_Int16 nData, bool bDots = true );
355cdf0e10cSrcweir static void appendBin( ::rtl::OUStringBuffer& rStr, sal_uInt32 nData, bool bDots = true );
356cdf0e10cSrcweir static void appendBin( ::rtl::OUStringBuffer& rStr, sal_Int32 nData, bool bDots = true );
357cdf0e10cSrcweir static void appendBin( ::rtl::OUStringBuffer& rStr, sal_uInt64 nData, bool bDots = true );
358cdf0e10cSrcweir static void appendBin( ::rtl::OUStringBuffer& rStr, sal_Int64 nData, bool bDots = true );
359cdf0e10cSrcweir static void appendBin( ::rtl::OUStringBuffer& rStr, double fData, bool bDots = true );
360cdf0e10cSrcweir
361cdf0e10cSrcweir // append fixed-point decimal ---------------------------------------------
362cdf0e10cSrcweir
363cdf0e10cSrcweir template< typename Type >
364cdf0e10cSrcweir static void appendFix( ::rtl::OUStringBuffer& rStr, Type nData, sal_Int32 nWidth = 0 );
365cdf0e10cSrcweir
366cdf0e10cSrcweir // append formatted value -------------------------------------------------
367cdf0e10cSrcweir
368cdf0e10cSrcweir static void appendBool( ::rtl::OUStringBuffer& rStr, bool bData );
369cdf0e10cSrcweir template< typename Type >
370cdf0e10cSrcweir static void appendValue( ::rtl::OUStringBuffer& rStr, Type nData, FormatType eFmtType );
371cdf0e10cSrcweir
372cdf0e10cSrcweir // append columns, rows, addresses ----------------------------------------
373cdf0e10cSrcweir
374cdf0e10cSrcweir static void appendAddrCol( ::rtl::OUStringBuffer& rStr, sal_Int32 nCol, bool bRel );
375cdf0e10cSrcweir static void appendAddrRow( ::rtl::OUStringBuffer& rStr, sal_Int32 nRow, bool bRel );
376cdf0e10cSrcweir static void appendAddrName( ::rtl::OUStringBuffer& rStr, sal_Unicode cPrefix, sal_Int32 nColRow, bool bRel );
377cdf0e10cSrcweir
378cdf0e10cSrcweir static void appendAddress( ::rtl::OUStringBuffer& rStr, const Address& rPos );
379cdf0e10cSrcweir static void appendRange( ::rtl::OUStringBuffer& rStr, const Range& rRange );
380cdf0e10cSrcweir static void appendRangeList( ::rtl::OUStringBuffer& rStr, const RangeList& rRanges );
381cdf0e10cSrcweir
382cdf0e10cSrcweir static void appendAddress( ::rtl::OUStringBuffer& rStr, const TokenAddress& rPos, bool bR1C1 );
383cdf0e10cSrcweir static void appendRange( ::rtl::OUStringBuffer& rStr, const TokenRange& rRange, bool bR1C1 );
384cdf0e10cSrcweir
385cdf0e10cSrcweir // encoded text output ----------------------------------------------------
386cdf0e10cSrcweir
387cdf0e10cSrcweir static void appendCChar( ::rtl::OUStringBuffer& rStr, sal_Unicode cChar, bool bPrefix = true );
388cdf0e10cSrcweir static void appendEncChar( ::rtl::OUStringBuffer& rStr, sal_Unicode cChar, sal_Int32 nCount = 1, bool bPrefix = true );
389cdf0e10cSrcweir static void appendEncString( ::rtl::OUStringBuffer& rStr, const ::rtl::OUString& rData, bool bPrefix = true );
390cdf0e10cSrcweir
391cdf0e10cSrcweir // token list -------------------------------------------------------------
392cdf0e10cSrcweir
393cdf0e10cSrcweir static void appendToken( ::rtl::OUStringBuffer& rStr, const ::rtl::OUString& rToken, sal_Unicode cSep = OOX_DUMP_LISTSEP );
394cdf0e10cSrcweir static void appendToken( ::rtl::OUStringBuffer& rStr, sal_Int64 nToken, sal_Unicode cSep = OOX_DUMP_LISTSEP );
395cdf0e10cSrcweir static void prependToken( ::rtl::OUStringBuffer& rStr, const ::rtl::OUString& rToken, sal_Unicode cSep = OOX_DUMP_LISTSEP );
396cdf0e10cSrcweir static void prependToken( ::rtl::OUStringBuffer& rStr, sal_Int64 nToken, sal_Unicode cSep = OOX_DUMP_LISTSEP );
397cdf0e10cSrcweir
398cdf0e10cSrcweir static void appendIndex( ::rtl::OUStringBuffer& rStr, const ::rtl::OUString& rIdx );
399cdf0e10cSrcweir static void appendIndex( ::rtl::OUStringBuffer& rStr, sal_Int64 nIdx );
400cdf0e10cSrcweir static void appendIndexedText( ::rtl::OUStringBuffer& rStr, const ::rtl::OUString& rData, const ::rtl::OUString& rIdx );
401cdf0e10cSrcweir static void appendIndexedText( ::rtl::OUStringBuffer& rStr, const ::rtl::OUString& rData, sal_Int64 nIdx );
402cdf0e10cSrcweir
403cdf0e10cSrcweir static ::rtl::OUString getToken( const ::rtl::OUString& rData, sal_Int32& rnPos, sal_Unicode cSep = OOX_DUMP_LISTSEP );
404cdf0e10cSrcweir
405cdf0e10cSrcweir /** Encloses the passed string with the passed characters. Uses cOpen, if cClose is NUL. */
406cdf0e10cSrcweir static void enclose( ::rtl::OUStringBuffer& rStr, sal_Unicode cOpen, sal_Unicode cClose = '\0' );
407cdf0e10cSrcweir
408cdf0e10cSrcweir // string conversion ------------------------------------------------------
409cdf0e10cSrcweir
410cdf0e10cSrcweir static ::rtl::OUString trimSpaces( const ::rtl::OUString& rStr );
411cdf0e10cSrcweir static ::rtl::OUString trimTrailingNul( const ::rtl::OUString& rStr );
412cdf0e10cSrcweir
413cdf0e10cSrcweir static ::rtl::OString convertToUtf8( const ::rtl::OUString& rStr );
414cdf0e10cSrcweir static DataType convertToDataType( const ::rtl::OUString& rStr );
415cdf0e10cSrcweir static FormatType convertToFormatType( const ::rtl::OUString& rStr );
416cdf0e10cSrcweir
417cdf0e10cSrcweir static bool convertFromDec( sal_Int64& ornData, const ::rtl::OUString& rData );
418cdf0e10cSrcweir static bool convertFromHex( sal_Int64& ornData, const ::rtl::OUString& rData );
419cdf0e10cSrcweir
420cdf0e10cSrcweir static bool convertStringToInt( sal_Int64& ornData, const ::rtl::OUString& rData );
421cdf0e10cSrcweir static bool convertStringToDouble( double& orfData, const ::rtl::OUString& rData );
422cdf0e10cSrcweir static bool convertStringToBool( const ::rtl::OUString& rData );
423cdf0e10cSrcweir
424cdf0e10cSrcweir static OUStringPair convertStringToPair( const ::rtl::OUString& rString, sal_Unicode cSep = '=' );
425cdf0e10cSrcweir
426cdf0e10cSrcweir // string to list conversion ----------------------------------------------
427cdf0e10cSrcweir
428cdf0e10cSrcweir static void convertStringToStringList( OUStringVector& orVec, const ::rtl::OUString& rData, bool bIgnoreEmpty );
429cdf0e10cSrcweir static void convertStringToIntList( Int64Vector& orVec, const ::rtl::OUString& rData, bool bIgnoreEmpty );
430cdf0e10cSrcweir };
431cdf0e10cSrcweir
432cdf0e10cSrcweir // ----------------------------------------------------------------------------
433cdf0e10cSrcweir
434cdf0e10cSrcweir template< typename Type >
appendFix(::rtl::OUStringBuffer & rStr,Type nData,sal_Int32 nWidth)435cdf0e10cSrcweir void StringHelper::appendFix( ::rtl::OUStringBuffer& rStr, Type nData, sal_Int32 nWidth )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir appendDec( rStr, static_cast< double >( nData ) / pow( 2.0, 4.0 * sizeof( Type ) ), nWidth );
438cdf0e10cSrcweir }
439cdf0e10cSrcweir
440cdf0e10cSrcweir template< typename Type >
appendValue(::rtl::OUStringBuffer & rStr,Type nData,FormatType eFmtType)441cdf0e10cSrcweir void StringHelper::appendValue( ::rtl::OUStringBuffer& rStr, Type nData, FormatType eFmtType )
442cdf0e10cSrcweir {
443cdf0e10cSrcweir switch( eFmtType )
444cdf0e10cSrcweir {
445cdf0e10cSrcweir case FORMATTYPE_DEC: appendDec( rStr, nData ); break;
446cdf0e10cSrcweir case FORMATTYPE_HEX: appendHex( rStr, nData ); break;
447cdf0e10cSrcweir case FORMATTYPE_SHORTHEX: appendShortHex( rStr, nData ); break;
448cdf0e10cSrcweir case FORMATTYPE_BIN: appendBin( rStr, nData ); break;
449cdf0e10cSrcweir case FORMATTYPE_FIX: appendFix( rStr, nData ); break;
450cdf0e10cSrcweir case FORMATTYPE_BOOL: appendBool( rStr, nData ); break;
451cdf0e10cSrcweir default:;
452cdf0e10cSrcweir }
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
455cdf0e10cSrcweir // ============================================================================
456cdf0e10cSrcweir
457cdf0e10cSrcweir class String : public ::rtl::OUString
458cdf0e10cSrcweir {
459cdf0e10cSrcweir public:
String()460cdf0e10cSrcweir inline String() {}
String(const::rtl::OUString & rStr)461cdf0e10cSrcweir inline /*implicit*/ String( const ::rtl::OUString& rStr ) : ::rtl::OUString( rStr ) {}
String(const sal_Char * pcStr)462cdf0e10cSrcweir inline /*implicit*/ String( const sal_Char* pcStr ) : ::rtl::OUString( ::rtl::OUString::createFromAscii( pcStr ? pcStr : "" ) ) {}
String(sal_Unicode cChar)463cdf0e10cSrcweir inline /*implicit*/ String( sal_Unicode cChar ) : ::rtl::OUString( cChar ) {}
464cdf0e10cSrcweir
has() const465cdf0e10cSrcweir inline bool has() const { return getLength() > 0; }
operator ()(const sal_Char * pcDefault) const466cdf0e10cSrcweir inline ::rtl::OUString operator()( const sal_Char* pcDefault ) const { if( has() ) return *this; return String( pcDefault ); }
467cdf0e10cSrcweir };
468cdf0e10cSrcweir
469cdf0e10cSrcweir static const String EMPTY_STRING;
470cdf0e10cSrcweir
471cdf0e10cSrcweir // ============================================================================
472cdf0e10cSrcweir // ============================================================================
473cdf0e10cSrcweir
474cdf0e10cSrcweir /** Stack to create a human readable formula string from a UPN token array. */
475cdf0e10cSrcweir class FormulaStack
476cdf0e10cSrcweir {
477cdf0e10cSrcweir public:
478cdf0e10cSrcweir explicit FormulaStack();
479cdf0e10cSrcweir
getFormulaString() const480cdf0e10cSrcweir inline const ::rtl::OUString& getFormulaString() const { return getString( maFmlaStack ); }
getClassesString() const481cdf0e10cSrcweir inline const ::rtl::OUString& getClassesString() const { return getString( maClassStack ); }
482cdf0e10cSrcweir
483cdf0e10cSrcweir void pushOperand( const String& rOp, const ::rtl::OUString& rTokClass );
484cdf0e10cSrcweir void pushOperand( const String& rOp );
485cdf0e10cSrcweir void pushUnaryOp( const String& rLOp, const String& rROp );
486cdf0e10cSrcweir void pushBinaryOp( const String& rOp );
487cdf0e10cSrcweir void pushFuncOp( const String& rFunc, const ::rtl::OUString& rTokClass, sal_uInt8 nParamCount );
488cdf0e10cSrcweir
setError()489cdf0e10cSrcweir inline void setError() { mbError = true; }
490cdf0e10cSrcweir void replaceOnTop( const ::rtl::OUString& rOld, const ::rtl::OUString& rNew );
491cdf0e10cSrcweir
492cdf0e10cSrcweir private:
493cdf0e10cSrcweir typedef ::std::stack< ::rtl::OUString > StringStack;
494cdf0e10cSrcweir
check(bool bCond)495cdf0e10cSrcweir inline bool check( bool bCond ) { return (mbError |= !bCond) == false; }
496cdf0e10cSrcweir
497cdf0e10cSrcweir const ::rtl::OUString& getString( const StringStack& rStack ) const;
498cdf0e10cSrcweir void pushUnaryOp( StringStack& rStack, const ::rtl::OUString& rLOp, const ::rtl::OUString& rROp );
499cdf0e10cSrcweir void pushBinaryOp( StringStack& rStack, const ::rtl::OUString& rOp );
500cdf0e10cSrcweir void pushFuncOp( StringStack& rStack, const ::rtl::OUString& rOp, sal_uInt8 nParamCount );
501cdf0e10cSrcweir
502cdf0e10cSrcweir private:
503cdf0e10cSrcweir StringStack maFmlaStack;
504cdf0e10cSrcweir StringStack maClassStack;
505cdf0e10cSrcweir bool mbError;
506cdf0e10cSrcweir };
507cdf0e10cSrcweir
508cdf0e10cSrcweir // ============================================================================
509cdf0e10cSrcweir // ============================================================================
510cdf0e10cSrcweir
511cdf0e10cSrcweir class Base;
512cdf0e10cSrcweir typedef ::boost::shared_ptr< Base > BaseRef;
513cdf0e10cSrcweir
514cdf0e10cSrcweir /** Base class for all dumper classes.
515cdf0e10cSrcweir
516cdf0e10cSrcweir Derived classes implement the virtual function implIsValid(). It should
517cdf0e10cSrcweir check all members the other functions rely on. If the function
518cdf0e10cSrcweir implIsValid() returns true, all references and pointers can be used without
519cdf0e10cSrcweir further checking.
520cdf0e10cSrcweir
521cdf0e10cSrcweir Overview of all classes in this header file based on this Base class:
522cdf0e10cSrcweir
523cdf0e10cSrcweir Base
524cdf0e10cSrcweir |
525cdf0e10cSrcweir +----> NameListBase
526cdf0e10cSrcweir | |
527cdf0e10cSrcweir | +----> ConstList ------> MultiList
528cdf0e10cSrcweir | |
529cdf0e10cSrcweir | +----> FlagsList ------> CombiList
530cdf0e10cSrcweir | |
531cdf0e10cSrcweir | +----> UnitConverter
532cdf0e10cSrcweir |
533cdf0e10cSrcweir +----> SharedConfigData
534cdf0e10cSrcweir |
535cdf0e10cSrcweir +----> Config
536cdf0e10cSrcweir |
537cdf0e10cSrcweir +----> Output
538cdf0e10cSrcweir |
539cdf0e10cSrcweir +----> StorageIterator
540cdf0e10cSrcweir |
541cdf0e10cSrcweir +----> ObjectBase
542cdf0e10cSrcweir |
543cdf0e10cSrcweir +----> StorageObjectBase
544cdf0e10cSrcweir |
545cdf0e10cSrcweir +----> OutputObjectBase
546cdf0e10cSrcweir | |
547cdf0e10cSrcweir | +----> InputObjectBase
548cdf0e10cSrcweir | |
549cdf0e10cSrcweir | +----> BinaryStreamObject
550cdf0e10cSrcweir | |
551cdf0e10cSrcweir | +----> TextStreamObjectBase
552cdf0e10cSrcweir | | |
553cdf0e10cSrcweir | | +----> TextStreamObject
554cdf0e10cSrcweir | | |
555cdf0e10cSrcweir | | +----> XmlStreamObject
556cdf0e10cSrcweir | |
557cdf0e10cSrcweir | +----> RecordObjectBase
558cdf0e10cSrcweir | |
559cdf0e10cSrcweir | +----> SequenceRecordObjectBase
560cdf0e10cSrcweir |
561cdf0e10cSrcweir +----> DumperBase
562cdf0e10cSrcweir */
563cdf0e10cSrcweir class Base
564cdf0e10cSrcweir {
565cdf0e10cSrcweir public:
566cdf0e10cSrcweir virtual ~Base();
567cdf0e10cSrcweir
isValid() const568cdf0e10cSrcweir inline bool isValid() const { return implIsValid(); }
isValid(const BaseRef & rxBase)569cdf0e10cSrcweir inline static bool isValid( const BaseRef& rxBase ) { return rxBase.get() && rxBase->isValid(); }
570cdf0e10cSrcweir
571cdf0e10cSrcweir protected:
Base()572cdf0e10cSrcweir inline explicit Base() {}
573cdf0e10cSrcweir
574cdf0e10cSrcweir virtual bool implIsValid() const = 0;
575cdf0e10cSrcweir };
576cdf0e10cSrcweir
577cdf0e10cSrcweir // ============================================================================
578cdf0e10cSrcweir // ============================================================================
579cdf0e10cSrcweir
580cdf0e10cSrcweir class ConfigItemBase
581cdf0e10cSrcweir {
582cdf0e10cSrcweir public:
583cdf0e10cSrcweir virtual ~ConfigItemBase();
584cdf0e10cSrcweir void readConfigBlock( TextInputStream& rStrm );
585cdf0e10cSrcweir
586cdf0e10cSrcweir protected:
ConfigItemBase()587cdf0e10cSrcweir inline explicit ConfigItemBase() {}
588cdf0e10cSrcweir
589cdf0e10cSrcweir virtual void implProcessConfigItemStr(
590cdf0e10cSrcweir TextInputStream& rStrm,
591cdf0e10cSrcweir const ::rtl::OUString& rKey,
592cdf0e10cSrcweir const ::rtl::OUString& rData );
593cdf0e10cSrcweir
594cdf0e10cSrcweir virtual void implProcessConfigItemInt(
595cdf0e10cSrcweir TextInputStream& rStrm,
596cdf0e10cSrcweir sal_Int64 nKey,
597cdf0e10cSrcweir const ::rtl::OUString& rData );
598cdf0e10cSrcweir
599cdf0e10cSrcweir void readConfigBlockContents(
600cdf0e10cSrcweir TextInputStream& rStrm );
601cdf0e10cSrcweir
602cdf0e10cSrcweir private:
603cdf0e10cSrcweir enum LineType { LINETYPE_DATA, LINETYPE_END };
604cdf0e10cSrcweir
605cdf0e10cSrcweir LineType readConfigLine(
606cdf0e10cSrcweir TextInputStream& rStrm,
607cdf0e10cSrcweir ::rtl::OUString& orKey,
608cdf0e10cSrcweir ::rtl::OUString& orData ) const;
609cdf0e10cSrcweir
610cdf0e10cSrcweir LineType readConfigLine(
611cdf0e10cSrcweir TextInputStream& rStrm ) const;
612cdf0e10cSrcweir
613cdf0e10cSrcweir void processConfigItem(
614cdf0e10cSrcweir TextInputStream& rStrm,
615cdf0e10cSrcweir const ::rtl::OUString& rKey,
616cdf0e10cSrcweir const ::rtl::OUString& rData );
617cdf0e10cSrcweir };
618cdf0e10cSrcweir
619cdf0e10cSrcweir // ============================================================================
620cdf0e10cSrcweir
621cdf0e10cSrcweir class SharedConfigData;
622cdf0e10cSrcweir class Config;
623cdf0e10cSrcweir
624cdf0e10cSrcweir class NameListBase;
625cdf0e10cSrcweir typedef ::boost::shared_ptr< NameListBase > NameListRef;
626cdf0e10cSrcweir
627cdf0e10cSrcweir /** Base class of all classes providing names for specific values (name lists).
628cdf0e10cSrcweir
629cdf0e10cSrcweir The idea is to provide a unique interfase for all different methods to
630cdf0e10cSrcweir write specific names for any values. This can be enumerations (dedicated
631cdf0e10cSrcweir names for a subset of values), or names for bits in bit fields. Classes
632cdf0e10cSrcweir derived from this base class implement the specific behaviour for the
633cdf0e10cSrcweir desired purpose.
634cdf0e10cSrcweir */
635cdf0e10cSrcweir class NameListBase : public Base, public ConfigItemBase
636cdf0e10cSrcweir {
637cdf0e10cSrcweir public:
638cdf0e10cSrcweir typedef ::std::map< sal_Int64, ::rtl::OUString > OUStringMap;
639cdf0e10cSrcweir typedef OUStringMap::const_iterator const_iterator;
640cdf0e10cSrcweir
641cdf0e10cSrcweir public:
642cdf0e10cSrcweir virtual ~NameListBase();
643cdf0e10cSrcweir
644cdf0e10cSrcweir /** Sets a name for the specified key. */
645cdf0e10cSrcweir void setName( sal_Int64 nKey, const String& rName );
646cdf0e10cSrcweir
647cdf0e10cSrcweir /** Include all names of the passed list. */
648cdf0e10cSrcweir void includeList( const NameListRef& rxList );
649cdf0e10cSrcweir
650cdf0e10cSrcweir /** Returns true, if the map contains an entry for the passed key. */
651cdf0e10cSrcweir template< typename Type >
hasName(Type nKey) const652cdf0e10cSrcweir inline bool hasName( Type nKey ) const
653cdf0e10cSrcweir { return maMap.count( static_cast< sal_Int64 >( nKey ) ) != 0; }
654cdf0e10cSrcweir
655cdf0e10cSrcweir /** Returns the name for the passed key. */
656cdf0e10cSrcweir template< typename Type >
getName(const Config & rCfg,Type nKey) const657cdf0e10cSrcweir inline ::rtl::OUString getName( const Config& rCfg, Type nKey ) const
658cdf0e10cSrcweir { return implGetName( rCfg, static_cast< sal_Int64 >( nKey ) ); }
659cdf0e10cSrcweir
660cdf0e10cSrcweir /** Returns a display name for the passed double value. */
getName(const Config & rCfg,double fValue) const661cdf0e10cSrcweir inline ::rtl::OUString getName( const Config& rCfg, double fValue ) const
662cdf0e10cSrcweir { return implGetNameDbl( rCfg, fValue ); }
663cdf0e10cSrcweir
664cdf0e10cSrcweir /** Returns a map iterator pointing to the first contained name. */
begin() const665cdf0e10cSrcweir inline const_iterator begin() const { return maMap.begin(); }
666cdf0e10cSrcweir /** Returns a map iterator pointing one past the last contained name. */
end() const667cdf0e10cSrcweir inline const_iterator end() const { return maMap.end(); }
668cdf0e10cSrcweir
669cdf0e10cSrcweir protected:
NameListBase(const SharedConfigData & rCfgData)670cdf0e10cSrcweir inline explicit NameListBase( const SharedConfigData& rCfgData ) : mrCfgData( rCfgData ) {}
671cdf0e10cSrcweir
672cdf0e10cSrcweir virtual bool implIsValid() const;
673cdf0e10cSrcweir
674cdf0e10cSrcweir virtual void implProcessConfigItemStr(
675cdf0e10cSrcweir TextInputStream& rStrm,
676cdf0e10cSrcweir const ::rtl::OUString& rKey,
677cdf0e10cSrcweir const ::rtl::OUString& rData );
678cdf0e10cSrcweir
679cdf0e10cSrcweir virtual void implProcessConfigItemInt(
680cdf0e10cSrcweir TextInputStream& rStrm,
681cdf0e10cSrcweir sal_Int64 nKey,
682cdf0e10cSrcweir const ::rtl::OUString& rData );
683cdf0e10cSrcweir
684cdf0e10cSrcweir /** Derived classes set the name for the passed key. */
685cdf0e10cSrcweir virtual void implSetName( sal_Int64 nKey, const ::rtl::OUString& rName ) = 0;
686cdf0e10cSrcweir /** Derived classes generate and return the name for the passed key. */
687cdf0e10cSrcweir virtual ::rtl::OUString implGetName( const Config& rCfg, sal_Int64 nKey ) const = 0;
688cdf0e10cSrcweir /** Derived classes generate and return the name for the passed double value. */
689cdf0e10cSrcweir virtual ::rtl::OUString implGetNameDbl( const Config& rCfg, double fValue ) const = 0;
690cdf0e10cSrcweir /** Derived classes insert all names and other settings from the passed list. */
691cdf0e10cSrcweir virtual void implIncludeList( const NameListBase& rList ) = 0;
692cdf0e10cSrcweir
693cdf0e10cSrcweir /** Inserts the passed name into the internal map. */
694cdf0e10cSrcweir void insertRawName( sal_Int64 nKey, const ::rtl::OUString& rName );
695cdf0e10cSrcweir /** Returns the name for the passed key, or 0, if nothing found. */
696cdf0e10cSrcweir const ::rtl::OUString* findRawName( sal_Int64 nKey ) const;
697cdf0e10cSrcweir
698cdf0e10cSrcweir private:
699cdf0e10cSrcweir /** Includes name lists, given in a comma separated list of names of the lists. */
700cdf0e10cSrcweir void include( const ::rtl::OUString& rListKeys );
701cdf0e10cSrcweir /** Excludes names from the list, given in a comma separated list of their keys. */
702cdf0e10cSrcweir void exclude( const ::rtl::OUString& rKeys );
703cdf0e10cSrcweir
704cdf0e10cSrcweir private:
705cdf0e10cSrcweir OUStringMap maMap;
706cdf0e10cSrcweir const SharedConfigData& mrCfgData;
707cdf0e10cSrcweir };
708cdf0e10cSrcweir
709cdf0e10cSrcweir // ============================================================================
710cdf0e10cSrcweir
711cdf0e10cSrcweir class ConstList : public NameListBase
712cdf0e10cSrcweir {
713cdf0e10cSrcweir public:
714cdf0e10cSrcweir explicit ConstList( const SharedConfigData& rCfgData );
715cdf0e10cSrcweir
716cdf0e10cSrcweir /** Sets a default name for unknown keys. */
setDefaultName(const String & rDefName)717cdf0e10cSrcweir inline void setDefaultName( const String& rDefName ) { maDefName = rDefName; }
718cdf0e10cSrcweir /** Enables or disables automatic quotation of returned names. */
setQuoteNames(bool bQuoteNames)719cdf0e10cSrcweir inline void setQuoteNames( bool bQuoteNames ) { mbQuoteNames = bQuoteNames; }
720cdf0e10cSrcweir
721cdf0e10cSrcweir protected:
722cdf0e10cSrcweir virtual void implProcessConfigItemStr(
723cdf0e10cSrcweir TextInputStream& rStrm,
724cdf0e10cSrcweir const ::rtl::OUString& rKey,
725cdf0e10cSrcweir const ::rtl::OUString& rData );
726cdf0e10cSrcweir
727cdf0e10cSrcweir /** Sets the name for the passed key. */
728cdf0e10cSrcweir virtual void implSetName( sal_Int64 nKey, const ::rtl::OUString& rName );
729cdf0e10cSrcweir /** Returns the name for the passed key, or the default name, if key is not contained. */
730cdf0e10cSrcweir virtual ::rtl::OUString implGetName( const Config& rCfg, sal_Int64 nKey ) const;
731cdf0e10cSrcweir /** Returns the name for the passed double value. */
732cdf0e10cSrcweir virtual ::rtl::OUString implGetNameDbl( const Config& rCfg, double fValue ) const;
733cdf0e10cSrcweir /** Inserts all names from the passed list. */
734cdf0e10cSrcweir virtual void implIncludeList( const NameListBase& rList );
735cdf0e10cSrcweir
736cdf0e10cSrcweir private:
737cdf0e10cSrcweir ::rtl::OUString maDefName;
738cdf0e10cSrcweir bool mbQuoteNames;
739cdf0e10cSrcweir };
740cdf0e10cSrcweir
741cdf0e10cSrcweir // ============================================================================
742cdf0e10cSrcweir
743cdf0e10cSrcweir class MultiList : public ConstList
744cdf0e10cSrcweir {
745cdf0e10cSrcweir public:
746cdf0e10cSrcweir explicit MultiList( const SharedConfigData& rCfgData );
747cdf0e10cSrcweir
748cdf0e10cSrcweir void setNamesFromVec( sal_Int64 nStartKey, const OUStringVector& rNames );
749cdf0e10cSrcweir
750cdf0e10cSrcweir protected:
751cdf0e10cSrcweir virtual void implProcessConfigItemStr(
752cdf0e10cSrcweir TextInputStream& rStrm,
753cdf0e10cSrcweir const ::rtl::OUString& rKey,
754cdf0e10cSrcweir const ::rtl::OUString& rData );
755cdf0e10cSrcweir
756cdf0e10cSrcweir virtual void implSetName( sal_Int64 nKey, const ::rtl::OUString& rName );
757cdf0e10cSrcweir
758cdf0e10cSrcweir private:
759cdf0e10cSrcweir void insertNames( sal_Int64 nStartKey, const ::rtl::OUString& rData );
760cdf0e10cSrcweir
761cdf0e10cSrcweir private:
762cdf0e10cSrcweir bool mbIgnoreEmpty;
763cdf0e10cSrcweir };
764cdf0e10cSrcweir
765cdf0e10cSrcweir // ============================================================================
766cdf0e10cSrcweir
767cdf0e10cSrcweir class FlagsList : public NameListBase
768cdf0e10cSrcweir {
769cdf0e10cSrcweir public:
770cdf0e10cSrcweir explicit FlagsList( const SharedConfigData& rCfgData );
771cdf0e10cSrcweir
772cdf0e10cSrcweir /** Returns the flags to be ignored on output. */
getIgnoreFlags() const773cdf0e10cSrcweir inline sal_Int64 getIgnoreFlags() const { return mnIgnore; }
774cdf0e10cSrcweir /** Sets flags to be ignored on output. */
setIgnoreFlags(sal_Int64 nIgnore)775cdf0e10cSrcweir inline void setIgnoreFlags( sal_Int64 nIgnore ) { mnIgnore = nIgnore; }
776cdf0e10cSrcweir
777cdf0e10cSrcweir protected:
778cdf0e10cSrcweir virtual void implProcessConfigItemStr(
779cdf0e10cSrcweir TextInputStream& rStrm,
780cdf0e10cSrcweir const ::rtl::OUString& rKey,
781cdf0e10cSrcweir const ::rtl::OUString& rData );
782cdf0e10cSrcweir
783cdf0e10cSrcweir /** Sets the name for the passed key. */
784cdf0e10cSrcweir virtual void implSetName( sal_Int64 nKey, const ::rtl::OUString& rName );
785cdf0e10cSrcweir /** Returns the name for the passed key. */
786cdf0e10cSrcweir virtual ::rtl::OUString implGetName( const Config& rCfg, sal_Int64 nKey ) const;
787cdf0e10cSrcweir /** Returns the name for the passed double value. */
788cdf0e10cSrcweir virtual ::rtl::OUString implGetNameDbl( const Config& rCfg, double fValue ) const;
789cdf0e10cSrcweir /** Inserts all flags from the passed list. */
790cdf0e10cSrcweir virtual void implIncludeList( const NameListBase& rList );
791cdf0e10cSrcweir
792cdf0e10cSrcweir private:
793cdf0e10cSrcweir sal_Int64 mnIgnore;
794cdf0e10cSrcweir };
795cdf0e10cSrcweir
796cdf0e10cSrcweir // ============================================================================
797cdf0e10cSrcweir
798cdf0e10cSrcweir class CombiList : public FlagsList
799cdf0e10cSrcweir {
800cdf0e10cSrcweir public:
801cdf0e10cSrcweir explicit CombiList( const SharedConfigData& rCfgData );
802cdf0e10cSrcweir
803cdf0e10cSrcweir protected:
804cdf0e10cSrcweir /** Sets the name for the passed key. */
805cdf0e10cSrcweir virtual void implSetName( sal_Int64 nKey, const ::rtl::OUString& rName );
806cdf0e10cSrcweir /** Returns the name for the passed key. */
807cdf0e10cSrcweir virtual ::rtl::OUString implGetName( const Config& rCfg, sal_Int64 nKey ) const;
808cdf0e10cSrcweir /** Inserts all flags from the passed list. */
809cdf0e10cSrcweir virtual void implIncludeList( const NameListBase& rList );
810cdf0e10cSrcweir
811cdf0e10cSrcweir private:
812cdf0e10cSrcweir struct ExtItemFormatKey
813cdf0e10cSrcweir {
814cdf0e10cSrcweir sal_Int64 mnKey;
815cdf0e10cSrcweir Int64Pair maFilter;
ExtItemFormatKeyoox::dump::CombiList::ExtItemFormatKey816cdf0e10cSrcweir inline explicit ExtItemFormatKey( sal_Int64 nKey ) : mnKey( nKey ), maFilter( 0, 0 ) {}
817cdf0e10cSrcweir bool operator<( const ExtItemFormatKey& rRight ) const;
818cdf0e10cSrcweir
819cdf0e10cSrcweir };
820cdf0e10cSrcweir struct ExtItemFormat : public ItemFormat
821cdf0e10cSrcweir {
822cdf0e10cSrcweir bool mbShiftValue;
ExtItemFormatoox::dump::CombiList::ExtItemFormat823cdf0e10cSrcweir inline explicit ExtItemFormat() : mbShiftValue( true ) {}
824cdf0e10cSrcweir };
825cdf0e10cSrcweir typedef ::std::map< ExtItemFormatKey, ExtItemFormat > ExtItemFormatMap;
826cdf0e10cSrcweir ExtItemFormatMap maFmtMap;
827cdf0e10cSrcweir };
828cdf0e10cSrcweir
829cdf0e10cSrcweir // ============================================================================
830cdf0e10cSrcweir
831cdf0e10cSrcweir class UnitConverter : public NameListBase
832cdf0e10cSrcweir {
833cdf0e10cSrcweir public:
834cdf0e10cSrcweir explicit UnitConverter( const SharedConfigData& rCfgData );
835cdf0e10cSrcweir
setUnitName(const String & rUnitName)836cdf0e10cSrcweir inline void setUnitName( const String& rUnitName ) { maUnitName = rUnitName; }
setFactor(double fFactor)837cdf0e10cSrcweir inline void setFactor( double fFactor ) { mfFactor = fFactor; }
838cdf0e10cSrcweir
839cdf0e10cSrcweir protected:
840cdf0e10cSrcweir /** Sets the name for the passed key. */
841cdf0e10cSrcweir virtual void implSetName( sal_Int64 nKey, const ::rtl::OUString& rName );
842cdf0e10cSrcweir /** Returns the converted value with appended unit name. */
843cdf0e10cSrcweir virtual ::rtl::OUString implGetName( const Config& rCfg, sal_Int64 nKey ) const;
844cdf0e10cSrcweir /** Returns the converted value with appended unit name. */
845cdf0e10cSrcweir virtual ::rtl::OUString implGetNameDbl( const Config& rCfg, double fValue ) const;
846cdf0e10cSrcweir /** Empty implementation. */
847cdf0e10cSrcweir virtual void implIncludeList( const NameListBase& rList );
848cdf0e10cSrcweir
849cdf0e10cSrcweir private:
850cdf0e10cSrcweir ::rtl::OUString maUnitName;
851cdf0e10cSrcweir double mfFactor;
852cdf0e10cSrcweir };
853cdf0e10cSrcweir
854cdf0e10cSrcweir // ============================================================================
855cdf0e10cSrcweir
856cdf0e10cSrcweir class NameListWrapper
857cdf0e10cSrcweir {
858cdf0e10cSrcweir public:
NameListWrapper()859cdf0e10cSrcweir inline NameListWrapper() {}
NameListWrapper(const::rtl::OUString & rListName)860cdf0e10cSrcweir inline /*implicit*/ NameListWrapper( const ::rtl::OUString& rListName ) : maName( rListName ) {}
NameListWrapper(const sal_Char * pcListName)861cdf0e10cSrcweir inline /*implicit*/ NameListWrapper( const sal_Char* pcListName ) : maName( pcListName ) {}
NameListWrapper(const NameListRef & rxList)862cdf0e10cSrcweir inline /*implicit*/ NameListWrapper( const NameListRef& rxList ) : mxList( rxList ) {}
863cdf0e10cSrcweir
isEmpty() const864cdf0e10cSrcweir inline bool isEmpty() const { return !mxList && !maName.has(); }
865cdf0e10cSrcweir NameListRef getNameList( const Config& rCfg ) const;
866cdf0e10cSrcweir
867cdf0e10cSrcweir private:
868cdf0e10cSrcweir String maName;
869cdf0e10cSrcweir mutable NameListRef mxList;
870cdf0e10cSrcweir };
871cdf0e10cSrcweir
872cdf0e10cSrcweir static const NameListWrapper NO_LIST;
873cdf0e10cSrcweir
874cdf0e10cSrcweir // ============================================================================
875cdf0e10cSrcweir
876cdf0e10cSrcweir class ItemFormatMap : public ::std::map< sal_Int64, ItemFormat >
877cdf0e10cSrcweir {
878cdf0e10cSrcweir public:
ItemFormatMap()879cdf0e10cSrcweir inline explicit ItemFormatMap() {}
ItemFormatMap(const NameListRef & rxNameList)880cdf0e10cSrcweir inline explicit ItemFormatMap( const NameListRef& rxNameList ) { insertFormats( rxNameList ); }
881cdf0e10cSrcweir
882cdf0e10cSrcweir void insertFormats( const NameListRef& rxNameList );
883cdf0e10cSrcweir };
884cdf0e10cSrcweir
885cdf0e10cSrcweir // ============================================================================
886cdf0e10cSrcweir // ============================================================================
887cdf0e10cSrcweir
888cdf0e10cSrcweir class SharedConfigData : public Base, public ConfigItemBase
889cdf0e10cSrcweir {
890cdf0e10cSrcweir public:
891cdf0e10cSrcweir explicit SharedConfigData(
892cdf0e10cSrcweir const ::rtl::OUString& rFileName,
893cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
894cdf0e10cSrcweir const StorageRef& rxRootStrg,
895cdf0e10cSrcweir const ::rtl::OUString& rSysFileName,
896cdf0e10cSrcweir ::comphelper::MediaDescriptor& rMediaDesc );
897cdf0e10cSrcweir
898cdf0e10cSrcweir virtual ~SharedConfigData();
899cdf0e10cSrcweir
getContext() const900cdf0e10cSrcweir inline const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& getContext() const { return mxContext; }
getRootStorage() const901cdf0e10cSrcweir inline const StorageRef& getRootStorage() const { return mxRootStrg; }
getSysFileName() const902cdf0e10cSrcweir inline const ::rtl::OUString& getSysFileName() const { return maSysFileName; }
903cdf0e10cSrcweir
904cdf0e10cSrcweir void setOption( const ::rtl::OUString& rKey, const ::rtl::OUString& rData );
905cdf0e10cSrcweir const ::rtl::OUString* getOption( const ::rtl::OUString& rKey ) const;
906cdf0e10cSrcweir
907cdf0e10cSrcweir template< typename ListType >
908cdf0e10cSrcweir ::boost::shared_ptr< ListType > createNameList( const ::rtl::OUString& rListName );
909cdf0e10cSrcweir void setNameList( const ::rtl::OUString& rListName, const NameListRef& rxList );
910cdf0e10cSrcweir void eraseNameList( const ::rtl::OUString& rListName );
911cdf0e10cSrcweir NameListRef getNameList( const ::rtl::OUString& rListName ) const;
912cdf0e10cSrcweir
913cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > requestEncryptionData( ::comphelper::IDocPasswordVerifier& rVerifier );
isPasswordCancelled() const914cdf0e10cSrcweir inline bool isPasswordCancelled() const { return mbPwCancelled; }
915cdf0e10cSrcweir
916cdf0e10cSrcweir protected:
917cdf0e10cSrcweir virtual bool implIsValid() const;
918cdf0e10cSrcweir virtual void implProcessConfigItemStr(
919cdf0e10cSrcweir TextInputStream& rStrm,
920cdf0e10cSrcweir const ::rtl::OUString& rKey,
921cdf0e10cSrcweir const ::rtl::OUString& rData );
922cdf0e10cSrcweir
923cdf0e10cSrcweir private:
924cdf0e10cSrcweir bool readConfigFile( const ::rtl::OUString& rFileUrl );
925cdf0e10cSrcweir template< typename ListType >
926cdf0e10cSrcweir void readNameList( TextInputStream& rStrm, const ::rtl::OUString& rListName );
927cdf0e10cSrcweir void createShortList( const ::rtl::OUString& rData );
928cdf0e10cSrcweir void createUnitConverter( const ::rtl::OUString& rData );
929cdf0e10cSrcweir
930cdf0e10cSrcweir private:
931cdf0e10cSrcweir typedef ::std::set< ::rtl::OUString > ConfigFileSet;
932cdf0e10cSrcweir typedef ::std::map< ::rtl::OUString, ::rtl::OUString > ConfigDataMap;
933cdf0e10cSrcweir typedef ::std::map< ::rtl::OUString, NameListRef > NameListMap;
934cdf0e10cSrcweir
935cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
936cdf0e10cSrcweir StorageRef mxRootStrg;
937cdf0e10cSrcweir ::rtl::OUString maSysFileName;
938cdf0e10cSrcweir ::comphelper::MediaDescriptor& mrMediaDesc;
939cdf0e10cSrcweir ConfigFileSet maConfigFiles;
940cdf0e10cSrcweir ConfigDataMap maConfigData;
941cdf0e10cSrcweir NameListMap maNameLists;
942cdf0e10cSrcweir ::rtl::OUString maConfigPath;
943cdf0e10cSrcweir bool mbLoaded;
944cdf0e10cSrcweir bool mbPwCancelled;
945cdf0e10cSrcweir };
946cdf0e10cSrcweir
947cdf0e10cSrcweir // ----------------------------------------------------------------------------
948cdf0e10cSrcweir
949cdf0e10cSrcweir template< typename ListType >
createNameList(const::rtl::OUString & rListName)950cdf0e10cSrcweir ::boost::shared_ptr< ListType > SharedConfigData::createNameList( const ::rtl::OUString& rListName )
951cdf0e10cSrcweir {
952cdf0e10cSrcweir ::boost::shared_ptr< ListType > xList;
953cdf0e10cSrcweir if( rListName.getLength() > 0 )
954cdf0e10cSrcweir {
955cdf0e10cSrcweir xList.reset( new ListType( *this ) );
956cdf0e10cSrcweir setNameList( rListName, xList );
957cdf0e10cSrcweir }
958cdf0e10cSrcweir return xList;
959cdf0e10cSrcweir }
960cdf0e10cSrcweir
961cdf0e10cSrcweir template< typename ListType >
readNameList(TextInputStream & rStrm,const::rtl::OUString & rListName)962cdf0e10cSrcweir void SharedConfigData::readNameList( TextInputStream& rStrm, const ::rtl::OUString& rListName )
963cdf0e10cSrcweir {
964cdf0e10cSrcweir NameListRef xList = createNameList< ListType >( rListName );
965cdf0e10cSrcweir if( xList.get() )
966cdf0e10cSrcweir xList->readConfigBlock( rStrm );
967cdf0e10cSrcweir }
968cdf0e10cSrcweir
969cdf0e10cSrcweir // ============================================================================
970cdf0e10cSrcweir
971cdf0e10cSrcweir class Config : public Base
972cdf0e10cSrcweir {
973cdf0e10cSrcweir public:
974cdf0e10cSrcweir explicit Config( const Config& rParent );
975cdf0e10cSrcweir explicit Config(
976cdf0e10cSrcweir const sal_Char* pcEnvVar,
977cdf0e10cSrcweir const ::oox::core::FilterBase& rFilter );
978cdf0e10cSrcweir explicit Config(
979cdf0e10cSrcweir const sal_Char* pcEnvVar,
980cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
981cdf0e10cSrcweir const StorageRef& rxRootStrg,
982cdf0e10cSrcweir const ::rtl::OUString& rSysFileName,
983cdf0e10cSrcweir ::comphelper::MediaDescriptor& rMediaDesc );
984cdf0e10cSrcweir
985cdf0e10cSrcweir virtual ~Config();
986cdf0e10cSrcweir
getContext() const987cdf0e10cSrcweir inline const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& getContext() const { return mxCfgData->getContext(); }
getRootStorage() const988cdf0e10cSrcweir inline const StorageRef& getRootStorage() const { return mxCfgData->getRootStorage(); }
getSysFileName() const989cdf0e10cSrcweir inline const ::rtl::OUString& getSysFileName() const { return mxCfgData->getSysFileName(); }
990cdf0e10cSrcweir
991cdf0e10cSrcweir void setStringOption( const String& rKey, const String& rData );
992cdf0e10cSrcweir
993cdf0e10cSrcweir const ::rtl::OUString& getStringOption( const String& rKey, const ::rtl::OUString& rDefault ) const;
994cdf0e10cSrcweir bool getBoolOption( const String& rKey, bool bDefault ) const;
995cdf0e10cSrcweir template< typename Type >
996cdf0e10cSrcweir Type getIntOption( const String& rKey, Type nDefault ) const;
997cdf0e10cSrcweir
998cdf0e10cSrcweir bool isDumperEnabled() const;
999cdf0e10cSrcweir bool isImportEnabled() const;
1000cdf0e10cSrcweir
1001cdf0e10cSrcweir template< typename ListType >
1002cdf0e10cSrcweir ::boost::shared_ptr< ListType > createNameList( const String& rListName );
1003cdf0e10cSrcweir void setNameList( const String& rListName, const NameListRef& rxList );
1004cdf0e10cSrcweir void eraseNameList( const String& rListName );
1005cdf0e10cSrcweir NameListRef getNameList( const String& rListName ) const;
1006cdf0e10cSrcweir
1007cdf0e10cSrcweir /** Returns the name for the passed key from the passed name list. */
1008cdf0e10cSrcweir template< typename Type >
1009cdf0e10cSrcweir ::rtl::OUString getName( const NameListWrapper& rListWrp, Type nKey ) const;
1010cdf0e10cSrcweir /** Returns true, if the passed name list contains an entry for the passed key. */
1011cdf0e10cSrcweir template< typename Type >
1012cdf0e10cSrcweir bool hasName( const NameListWrapper& rListWrp, Type nKey ) const;
1013cdf0e10cSrcweir
1014cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > requestEncryptionData( ::comphelper::IDocPasswordVerifier& rVerifier );
1015cdf0e10cSrcweir bool isPasswordCancelled() const;
1016cdf0e10cSrcweir
1017cdf0e10cSrcweir protected:
Config()1018cdf0e10cSrcweir inline explicit Config() {}
1019cdf0e10cSrcweir void construct( const Config& rParent );
1020cdf0e10cSrcweir void construct(
1021cdf0e10cSrcweir const sal_Char* pcEnvVar,
1022cdf0e10cSrcweir const ::oox::core::FilterBase& rFilter );
1023cdf0e10cSrcweir void construct(
1024cdf0e10cSrcweir const sal_Char* pcEnvVar,
1025cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
1026cdf0e10cSrcweir const StorageRef& rxRootStrg,
1027cdf0e10cSrcweir const ::rtl::OUString& rSysFileName,
1028cdf0e10cSrcweir ::comphelper::MediaDescriptor& rMediaDesc );
1029cdf0e10cSrcweir
1030cdf0e10cSrcweir virtual bool implIsValid() const;
1031cdf0e10cSrcweir virtual const ::rtl::OUString* implGetOption( const ::rtl::OUString& rKey ) const;
1032cdf0e10cSrcweir virtual NameListRef implGetNameList( const ::rtl::OUString& rListName ) const;
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir private:
1035cdf0e10cSrcweir typedef ::boost::shared_ptr< SharedConfigData > SharedConfigDataRef;
1036cdf0e10cSrcweir SharedConfigDataRef mxCfgData;
1037cdf0e10cSrcweir };
1038cdf0e10cSrcweir
1039cdf0e10cSrcweir typedef ::boost::shared_ptr< Config > ConfigRef;
1040cdf0e10cSrcweir
1041cdf0e10cSrcweir // ----------------------------------------------------------------------------
1042cdf0e10cSrcweir
1043cdf0e10cSrcweir template< typename Type >
getIntOption(const String & rKey,Type nDefault) const1044cdf0e10cSrcweir Type Config::getIntOption( const String& rKey, Type nDefault ) const
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir sal_Int64 nRawData;
1047cdf0e10cSrcweir const ::rtl::OUString* pData = implGetOption( rKey );
1048cdf0e10cSrcweir return (pData && StringHelper::convertStringToInt( nRawData, *pData )) ?
1049cdf0e10cSrcweir static_cast< Type >( nRawData ) : nDefault;
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir template< typename ListType >
createNameList(const String & rListName)1053cdf0e10cSrcweir ::boost::shared_ptr< ListType > Config::createNameList( const String& rListName )
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir return mxCfgData->createNameList< ListType >( rListName );
1056cdf0e10cSrcweir }
1057cdf0e10cSrcweir
1058cdf0e10cSrcweir template< typename Type >
getName(const NameListWrapper & rListWrp,Type nKey) const1059cdf0e10cSrcweir ::rtl::OUString Config::getName( const NameListWrapper& rListWrp, Type nKey ) const
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir NameListRef xList = rListWrp.getNameList( *this );
1062cdf0e10cSrcweir return xList.get() ? xList->getName( *this, nKey ) : OOX_DUMP_ERR_NOMAP;
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir template< typename Type >
hasName(const NameListWrapper & rListWrp,Type nKey) const1066cdf0e10cSrcweir bool Config::hasName( const NameListWrapper& rListWrp, Type nKey ) const
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir NameListRef xList = rListWrp.getNameList( *this );
1069cdf0e10cSrcweir return xList.get() && xList->hasName( nKey );
1070cdf0e10cSrcweir }
1071cdf0e10cSrcweir
1072cdf0e10cSrcweir // ============================================================================
1073cdf0e10cSrcweir // ============================================================================
1074cdf0e10cSrcweir
1075cdf0e10cSrcweir class Output : public Base
1076cdf0e10cSrcweir {
1077cdf0e10cSrcweir public:
1078cdf0e10cSrcweir explicit Output(
1079cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
1080cdf0e10cSrcweir const ::rtl::OUString& rFileName );
1081cdf0e10cSrcweir
1082cdf0e10cSrcweir // ------------------------------------------------------------------------
1083cdf0e10cSrcweir
1084cdf0e10cSrcweir void newLine();
1085cdf0e10cSrcweir void emptyLine( size_t nCount = 1 );
getLine()1086cdf0e10cSrcweir inline ::rtl::OUStringBuffer& getLine() { return maLine; }
1087cdf0e10cSrcweir
1088cdf0e10cSrcweir void incIndent();
1089cdf0e10cSrcweir void decIndent();
1090cdf0e10cSrcweir void resetIndent();
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir void startTable( sal_Int32 nW1 );
1093cdf0e10cSrcweir void startTable( sal_Int32 nW1, sal_Int32 nW2 );
1094cdf0e10cSrcweir void startTable( sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3 );
1095cdf0e10cSrcweir void startTable( sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3, sal_Int32 nW4 );
1096cdf0e10cSrcweir void startTable( size_t nColCount, const sal_Int32* pnColWidths );
1097cdf0e10cSrcweir void tab();
1098cdf0e10cSrcweir void tab( size_t nCol );
1099cdf0e10cSrcweir void endTable();
1100cdf0e10cSrcweir
1101cdf0e10cSrcweir void resetItemIndex( sal_Int64 nIdx = 0 );
1102cdf0e10cSrcweir void startItem( const String& rItemName );
1103cdf0e10cSrcweir void contItem();
1104cdf0e10cSrcweir void endItem();
getLastItemValue() const1105cdf0e10cSrcweir inline const ::rtl::OUString& getLastItemValue() const { return maLastItem; }
1106cdf0e10cSrcweir
1107cdf0e10cSrcweir void startMultiItems();
1108cdf0e10cSrcweir void endMultiItems();
1109cdf0e10cSrcweir
1110cdf0e10cSrcweir // ------------------------------------------------------------------------
1111cdf0e10cSrcweir
1112cdf0e10cSrcweir void writeChar( sal_Unicode cChar, sal_Int32 nCount = 1 );
1113cdf0e10cSrcweir void writeAscii( const sal_Char* pcStr );
1114cdf0e10cSrcweir void writeString( const ::rtl::OUString& rStr );
1115cdf0e10cSrcweir void writeArray( const sal_uInt8* pnData, sal_Size nSize, sal_Unicode cSep = OOX_DUMP_LISTSEP );
1116cdf0e10cSrcweir void writeBool( bool bData );
1117cdf0e10cSrcweir void writeColorABGR( sal_Int32 nColor );
1118cdf0e10cSrcweir void writeDateTime( const ::com::sun::star::util::DateTime& rDateTime );
1119cdf0e10cSrcweir void writeColIndex( sal_Int32 nCol );
1120cdf0e10cSrcweir void writeRowIndex( sal_Int32 nRow );
1121cdf0e10cSrcweir void writeColRowRange( sal_Int32 nColRow1, sal_Int32 nColRow2 );
1122cdf0e10cSrcweir void writeColRange( sal_Int32 nCol1, sal_Int32 nCol2 );
1123cdf0e10cSrcweir void writeRowRange( sal_Int32 nRow1, sal_Int32 nRow2 );
1124cdf0e10cSrcweir void writeAddress( const Address& rPos );
1125cdf0e10cSrcweir void writeRange( const Range& rRange );
1126cdf0e10cSrcweir void writeRangeList( const RangeList& rRanges );
1127cdf0e10cSrcweir
1128cdf0e10cSrcweir template< typename Type >
writeDec(Type nData,sal_Int32 nWidth=0,sal_Unicode cFill=' ')1129cdf0e10cSrcweir inline void writeDec( Type nData, sal_Int32 nWidth = 0, sal_Unicode cFill = ' ' )
1130cdf0e10cSrcweir { StringHelper::appendDec( maLine, nData, nWidth, cFill ); }
1131cdf0e10cSrcweir template< typename Type >
writeHex(Type nData,bool bPrefix=true)1132cdf0e10cSrcweir inline void writeHex( Type nData, bool bPrefix = true )
1133cdf0e10cSrcweir { StringHelper::appendHex( maLine, nData, bPrefix ); }
1134cdf0e10cSrcweir template< typename Type >
writeShortHex(Type nData,bool bPrefix=true)1135cdf0e10cSrcweir inline void writeShortHex( Type nData, bool bPrefix = true )
1136cdf0e10cSrcweir { StringHelper::appendShortHex( maLine, nData, bPrefix ); }
1137cdf0e10cSrcweir template< typename Type >
writeBin(Type nData,bool bDots=true)1138cdf0e10cSrcweir inline void writeBin( Type nData, bool bDots = true )
1139cdf0e10cSrcweir { StringHelper::appendBin( maLine, nData, bDots ); }
1140cdf0e10cSrcweir template< typename Type >
writeFix(Type nData,sal_Int32 nWidth=0)1141cdf0e10cSrcweir inline void writeFix( Type nData, sal_Int32 nWidth = 0 )
1142cdf0e10cSrcweir { StringHelper::appendFix( maLine, nData, nWidth ); }
1143cdf0e10cSrcweir template< typename Type >
writeValue(Type nData,FormatType eFmtType)1144cdf0e10cSrcweir inline void writeValue( Type nData, FormatType eFmtType )
1145cdf0e10cSrcweir { StringHelper::appendValue( maLine, nData, eFmtType ); }
1146cdf0e10cSrcweir template< typename Type >
writeName(const Config & rCfg,Type nData,const NameListWrapper & rListWrp)1147cdf0e10cSrcweir inline void writeName( const Config& rCfg, Type nData, const NameListWrapper& rListWrp )
1148cdf0e10cSrcweir { writeString( rCfg.getName( rListWrp, nData ) ); }
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir // ------------------------------------------------------------------------
1151cdf0e10cSrcweir protected:
1152cdf0e10cSrcweir virtual bool implIsValid() const;
1153cdf0e10cSrcweir
1154cdf0e10cSrcweir private:
1155cdf0e10cSrcweir void writeItemName( const String& rItemName );
1156cdf0e10cSrcweir
1157cdf0e10cSrcweir private:
1158cdf0e10cSrcweir typedef ::std::vector< sal_Int32 > StringLenVec;
1159cdf0e10cSrcweir
1160cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextOutputStream > mxStrm;
1161cdf0e10cSrcweir ::rtl::OUString maIndent;
1162cdf0e10cSrcweir ::rtl::OUStringBuffer maLine;
1163cdf0e10cSrcweir ::rtl::OUString maLastItem;
1164cdf0e10cSrcweir StringLenVec maColPos;
1165cdf0e10cSrcweir size_t mnCol;
1166cdf0e10cSrcweir size_t mnItemLevel;
1167cdf0e10cSrcweir size_t mnMultiLevel;
1168cdf0e10cSrcweir sal_Int64 mnItemIdx;
1169cdf0e10cSrcweir sal_Int32 mnLastItem;
1170cdf0e10cSrcweir };
1171cdf0e10cSrcweir
1172cdf0e10cSrcweir typedef ::boost::shared_ptr< Output > OutputRef;
1173cdf0e10cSrcweir
1174cdf0e10cSrcweir // ============================================================================
1175cdf0e10cSrcweir
1176cdf0e10cSrcweir class IndentGuard
1177cdf0e10cSrcweir {
1178cdf0e10cSrcweir public:
IndentGuard(const OutputRef & rxOut)1179cdf0e10cSrcweir inline explicit IndentGuard( const OutputRef& rxOut ) : mrOut( *rxOut ) { mrOut.incIndent(); }
~IndentGuard()1180cdf0e10cSrcweir inline ~IndentGuard() { mrOut.decIndent(); }
1181cdf0e10cSrcweir private:
1182cdf0e10cSrcweir IndentGuard( const IndentGuard& );
1183cdf0e10cSrcweir IndentGuard& operator=( const IndentGuard& );
1184cdf0e10cSrcweir private:
1185cdf0e10cSrcweir Output& mrOut;
1186cdf0e10cSrcweir };
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir // ----------------------------------------------------------------------------
1189cdf0e10cSrcweir
1190cdf0e10cSrcweir class TableGuard
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir public:
TableGuard(const OutputRef & rxOut,sal_Int32 nW1)1193cdf0e10cSrcweir inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1 ) :
1194cdf0e10cSrcweir mrOut( *rxOut ) { mrOut.startTable( nW1 ); }
TableGuard(const OutputRef & rxOut,sal_Int32 nW1,sal_Int32 nW2)1195cdf0e10cSrcweir inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2 ) :
1196cdf0e10cSrcweir mrOut( *rxOut ) { mrOut.startTable( nW1, nW2 ); }
TableGuard(const OutputRef & rxOut,sal_Int32 nW1,sal_Int32 nW2,sal_Int32 nW3)1197cdf0e10cSrcweir inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3 ) :
1198cdf0e10cSrcweir mrOut( *rxOut ) { mrOut.startTable( nW1, nW2, nW3 ); }
TableGuard(const OutputRef & rxOut,sal_Int32 nW1,sal_Int32 nW2,sal_Int32 nW3,sal_Int32 nW4)1199cdf0e10cSrcweir inline explicit TableGuard( const OutputRef& rxOut, sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3, sal_Int32 nW4 ) :
1200cdf0e10cSrcweir mrOut( *rxOut ) { mrOut.startTable( nW1, nW2, nW3, nW4 ); }
TableGuard(const OutputRef & rxOut,size_t nColCount,const sal_Int32 * pnColWidths)1201cdf0e10cSrcweir inline explicit TableGuard( const OutputRef& rxOut, size_t nColCount,
1202cdf0e10cSrcweir const sal_Int32* pnColWidths ) :
1203cdf0e10cSrcweir mrOut( *rxOut ) { mrOut.startTable( nColCount, pnColWidths ); }
~TableGuard()1204cdf0e10cSrcweir inline ~TableGuard() { mrOut.endTable(); }
tab()1205cdf0e10cSrcweir inline void tab() { mrOut.tab(); }
tab(size_t nCol)1206cdf0e10cSrcweir inline void tab( size_t nCol ) { mrOut.tab( nCol ); }
1207cdf0e10cSrcweir private:
1208cdf0e10cSrcweir TableGuard( const TableGuard& );
1209cdf0e10cSrcweir TableGuard& operator=( const TableGuard& );
1210cdf0e10cSrcweir private:
1211cdf0e10cSrcweir Output& mrOut;
1212cdf0e10cSrcweir };
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir // ----------------------------------------------------------------------------
1215cdf0e10cSrcweir
1216cdf0e10cSrcweir class ItemGuard
1217cdf0e10cSrcweir {
1218cdf0e10cSrcweir public:
ItemGuard(const OutputRef & rxOut,const String & rName=EMPTY_STRING)1219cdf0e10cSrcweir inline explicit ItemGuard( const OutputRef& rxOut, const String& rName = EMPTY_STRING ) :
1220cdf0e10cSrcweir mrOut( *rxOut ) { mrOut.startItem( rName ); }
~ItemGuard()1221cdf0e10cSrcweir inline ~ItemGuard() { mrOut.endItem(); }
cont()1222cdf0e10cSrcweir inline void cont() { mrOut.contItem(); }
1223cdf0e10cSrcweir private:
1224cdf0e10cSrcweir ItemGuard( const ItemGuard& );
1225cdf0e10cSrcweir ItemGuard& operator=( const ItemGuard& );
1226cdf0e10cSrcweir private:
1227cdf0e10cSrcweir Output& mrOut;
1228cdf0e10cSrcweir };
1229cdf0e10cSrcweir
1230cdf0e10cSrcweir // ----------------------------------------------------------------------------
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir class MultiItemsGuard
1233cdf0e10cSrcweir {
1234cdf0e10cSrcweir public:
MultiItemsGuard(const OutputRef & rxOut)1235cdf0e10cSrcweir inline explicit MultiItemsGuard( const OutputRef& rxOut ) : mrOut( *rxOut ) { mrOut.startMultiItems(); }
~MultiItemsGuard()1236cdf0e10cSrcweir inline ~MultiItemsGuard() { mrOut.endMultiItems(); }
1237cdf0e10cSrcweir private:
1238cdf0e10cSrcweir MultiItemsGuard( const MultiItemsGuard& );
1239cdf0e10cSrcweir MultiItemsGuard& operator=( const MultiItemsGuard& );
1240cdf0e10cSrcweir private:
1241cdf0e10cSrcweir Output& mrOut;
1242cdf0e10cSrcweir };
1243cdf0e10cSrcweir
1244cdf0e10cSrcweir // ============================================================================
1245cdf0e10cSrcweir
1246cdf0e10cSrcweir class StorageIterator : public Base
1247cdf0e10cSrcweir {
1248cdf0e10cSrcweir public:
1249cdf0e10cSrcweir explicit StorageIterator( const StorageRef& rxStrg );
1250cdf0e10cSrcweir virtual ~StorageIterator();
1251cdf0e10cSrcweir
1252cdf0e10cSrcweir size_t getElementCount() const;
1253cdf0e10cSrcweir
1254cdf0e10cSrcweir StorageIterator& operator++();
1255cdf0e10cSrcweir
1256cdf0e10cSrcweir ::rtl::OUString getName() const;
1257cdf0e10cSrcweir bool isStream() const;
1258cdf0e10cSrcweir bool isStorage() const;
1259cdf0e10cSrcweir
1260cdf0e10cSrcweir private:
1261cdf0e10cSrcweir virtual bool implIsValid() const;
1262cdf0e10cSrcweir
1263cdf0e10cSrcweir private:
1264cdf0e10cSrcweir StorageRef mxStrg;
1265cdf0e10cSrcweir OUStringVector maNames;
1266cdf0e10cSrcweir OUStringVector::const_iterator maIt;
1267cdf0e10cSrcweir };
1268cdf0e10cSrcweir
1269cdf0e10cSrcweir // ============================================================================
1270cdf0e10cSrcweir // ============================================================================
1271cdf0e10cSrcweir
1272cdf0e10cSrcweir class ObjectBase : public Base
1273cdf0e10cSrcweir {
1274cdf0e10cSrcweir public:
1275cdf0e10cSrcweir virtual ~ObjectBase();
1276cdf0e10cSrcweir
1277cdf0e10cSrcweir inline const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&
getContext() const1278cdf0e10cSrcweir getContext() const { return mxConfig->getContext(); }
1279cdf0e10cSrcweir
1280cdf0e10cSrcweir void dump();
1281cdf0e10cSrcweir
1282cdf0e10cSrcweir // ------------------------------------------------------------------------
1283cdf0e10cSrcweir protected:
ObjectBase()1284cdf0e10cSrcweir inline explicit ObjectBase() {}
1285cdf0e10cSrcweir
1286cdf0e10cSrcweir void construct( const ConfigRef& rxConfig );
1287cdf0e10cSrcweir void construct( const ObjectBase& rParent );
1288cdf0e10cSrcweir
1289cdf0e10cSrcweir virtual bool implIsValid() const;
1290cdf0e10cSrcweir virtual void implDump();
1291cdf0e10cSrcweir
1292cdf0e10cSrcweir // ------------------------------------------------------------------------
1293cdf0e10cSrcweir
1294cdf0e10cSrcweir void reconstructConfig( const ConfigRef& rxConfig );
1295cdf0e10cSrcweir
cfg() const1296cdf0e10cSrcweir inline Config& cfg() const { return *mxConfig; }
1297cdf0e10cSrcweir
1298cdf0e10cSrcweir private:
1299cdf0e10cSrcweir ConfigRef mxConfig;
1300cdf0e10cSrcweir };
1301cdf0e10cSrcweir
1302cdf0e10cSrcweir typedef ::boost::shared_ptr< ObjectBase > ObjectRef;
1303cdf0e10cSrcweir
1304cdf0e10cSrcweir // ============================================================================
1305cdf0e10cSrcweir // ============================================================================
1306cdf0e10cSrcweir
1307cdf0e10cSrcweir class StorageObjectBase : public ObjectBase
1308cdf0e10cSrcweir {
1309cdf0e10cSrcweir protected:
StorageObjectBase()1310cdf0e10cSrcweir inline explicit StorageObjectBase() {}
1311cdf0e10cSrcweir
1312cdf0e10cSrcweir protected:
1313cdf0e10cSrcweir using ObjectBase::construct;
1314cdf0e10cSrcweir void construct( const ObjectBase& rParent, const StorageRef& rxStrg, const ::rtl::OUString& rSysPath );
1315cdf0e10cSrcweir void construct( const ObjectBase& rParent );
1316cdf0e10cSrcweir
1317cdf0e10cSrcweir virtual bool implIsValid() const;
1318cdf0e10cSrcweir virtual void implDump();
1319cdf0e10cSrcweir
1320cdf0e10cSrcweir virtual void implDumpStream(
1321cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxStrm,
1322cdf0e10cSrcweir const ::rtl::OUString& rStrgPath,
1323cdf0e10cSrcweir const ::rtl::OUString& rStrmName,
1324cdf0e10cSrcweir const ::rtl::OUString& rSysFileName );
1325cdf0e10cSrcweir
1326cdf0e10cSrcweir virtual void implDumpStorage(
1327cdf0e10cSrcweir const StorageRef& rxStrg,
1328cdf0e10cSrcweir const ::rtl::OUString& rStrgPath,
1329cdf0e10cSrcweir const ::rtl::OUString& rSysPath );
1330cdf0e10cSrcweir
1331cdf0e10cSrcweir virtual void implDumpBaseStream(
1332cdf0e10cSrcweir const BinaryInputStreamRef& rxStrm,
1333cdf0e10cSrcweir const ::rtl::OUString& rSysFileName );
1334cdf0e10cSrcweir
1335cdf0e10cSrcweir void addPreferredStream( const String& rStrmName );
1336cdf0e10cSrcweir void addPreferredStorage( const String& rStrgPath );
1337cdf0e10cSrcweir
1338cdf0e10cSrcweir private:
1339cdf0e10cSrcweir ::rtl::OUString getSysFileName(
1340cdf0e10cSrcweir const ::rtl::OUString& rStrmName,
1341cdf0e10cSrcweir const ::rtl::OUString& rSysOutPath );
1342cdf0e10cSrcweir
1343cdf0e10cSrcweir void extractStream(
1344cdf0e10cSrcweir StorageBase& rStrg,
1345cdf0e10cSrcweir const ::rtl::OUString& rStrgPath,
1346cdf0e10cSrcweir const ::rtl::OUString& rStrmName,
1347cdf0e10cSrcweir const ::rtl::OUString& rSysFileName );
1348cdf0e10cSrcweir void extractStorage(
1349cdf0e10cSrcweir const StorageRef& rxStrg,
1350cdf0e10cSrcweir const ::rtl::OUString& rStrgPath,
1351cdf0e10cSrcweir const ::rtl::OUString& rSysPath );
1352cdf0e10cSrcweir
1353cdf0e10cSrcweir void extractItem(
1354cdf0e10cSrcweir const StorageRef& rxStrg,
1355cdf0e10cSrcweir const ::rtl::OUString& rStrgPath,
1356cdf0e10cSrcweir const ::rtl::OUString& rItemName,
1357cdf0e10cSrcweir const ::rtl::OUString& rSysPath,
1358cdf0e10cSrcweir bool bIsStrg, bool bIsStrm );
1359cdf0e10cSrcweir
1360cdf0e10cSrcweir private:
1361cdf0e10cSrcweir struct PreferredItem
1362cdf0e10cSrcweir {
1363cdf0e10cSrcweir ::rtl::OUString maName;
1364cdf0e10cSrcweir bool mbStorage;
1365cdf0e10cSrcweir
PreferredItemoox::dump::StorageObjectBase::PreferredItem1366cdf0e10cSrcweir inline explicit PreferredItem( const ::rtl::OUString rName, bool bStorage ) :
1367cdf0e10cSrcweir maName( rName ), mbStorage( bStorage ) {}
1368cdf0e10cSrcweir };
1369cdf0e10cSrcweir typedef ::std::vector< PreferredItem > PreferredItemVector;
1370cdf0e10cSrcweir
1371cdf0e10cSrcweir StorageRef mxStrg;
1372cdf0e10cSrcweir ::rtl::OUString maSysPath;
1373cdf0e10cSrcweir PreferredItemVector maPreferred;
1374cdf0e10cSrcweir };
1375cdf0e10cSrcweir
1376cdf0e10cSrcweir typedef ::boost::shared_ptr< StorageObjectBase > StorageObjectRef;
1377cdf0e10cSrcweir
1378cdf0e10cSrcweir // ============================================================================
1379cdf0e10cSrcweir // ============================================================================
1380cdf0e10cSrcweir
1381cdf0e10cSrcweir class OutputObjectBase : public ObjectBase
1382cdf0e10cSrcweir {
1383cdf0e10cSrcweir public:
1384cdf0e10cSrcweir virtual ~OutputObjectBase();
1385cdf0e10cSrcweir
1386cdf0e10cSrcweir // ------------------------------------------------------------------------
1387cdf0e10cSrcweir protected:
OutputObjectBase()1388cdf0e10cSrcweir inline explicit OutputObjectBase() {}
1389cdf0e10cSrcweir
1390cdf0e10cSrcweir using ObjectBase::construct;
1391cdf0e10cSrcweir void construct( const ObjectBase& rParent, const ::rtl::OUString& rSysFileName );
1392cdf0e10cSrcweir void construct( const OutputObjectBase& rParent );
1393cdf0e10cSrcweir
1394cdf0e10cSrcweir virtual bool implIsValid() const;
1395cdf0e10cSrcweir
1396cdf0e10cSrcweir // ------------------------------------------------------------------------
1397cdf0e10cSrcweir
1398cdf0e10cSrcweir void writeEmptyItem( const String& rName );
1399cdf0e10cSrcweir void writeInfoItem( const String& rName, const String& rData );
1400cdf0e10cSrcweir void writeCharItem( const String& rName, sal_Unicode cData );
1401cdf0e10cSrcweir void writeStringItem( const String& rName, const ::rtl::OUString& rData );
1402cdf0e10cSrcweir void writeArrayItem( const String& rName, const sal_uInt8* pnData, sal_Size nSize, sal_Unicode cSep = OOX_DUMP_LISTSEP );
1403cdf0e10cSrcweir void writeBoolItem( const String& rName, bool bData );
1404cdf0e10cSrcweir double writeRkItem( const String& rName, sal_Int32 nRk );
1405cdf0e10cSrcweir void writeColorABGRItem( const String& rName, sal_Int32 nColor );
1406cdf0e10cSrcweir void writeDateTimeItem( const String& rName, const ::com::sun::star::util::DateTime& rDateTime );
1407cdf0e10cSrcweir void writeGuidItem( const String& rName, const ::rtl::OUString& rGuid );
1408cdf0e10cSrcweir void writeColIndexItem( const String& rName, sal_Int32 nCol );
1409cdf0e10cSrcweir void writeRowIndexItem( const String& rName, sal_Int32 nRow );
1410cdf0e10cSrcweir void writeColRangeItem( const String& rName, sal_Int32 nCol1, sal_Int32 nCol2 );
1411cdf0e10cSrcweir void writeRowRangeItem( const String& rName, sal_Int32 nRow1, sal_Int32 nRow2 );
1412cdf0e10cSrcweir void writeAddressItem( const String& rName, const Address& rPos );
1413cdf0e10cSrcweir void writeRangeItem( const String& rName, const Range& rRange );
1414cdf0e10cSrcweir void writeRangeListItem( const String& rName, const RangeList& rRanges );
1415cdf0e10cSrcweir void writeTokenAddressItem( const String& rName, const TokenAddress& rPos, bool bNameMode );
1416cdf0e10cSrcweir void writeTokenAddress3dItem( const String& rName, const ::rtl::OUString& rRef, const TokenAddress& rPos, bool bNameMode );
1417cdf0e10cSrcweir void writeTokenRangeItem( const String& rName, const TokenRange& rRange, bool bNameMode );
1418cdf0e10cSrcweir void writeTokenRange3dItem( const String& rName, const ::rtl::OUString& rRef, const TokenRange& rRange, bool bNameMode );
1419cdf0e10cSrcweir
1420cdf0e10cSrcweir template< typename Type >
1421cdf0e10cSrcweir void addNameToItem( Type nData, const NameListWrapper& rListWrp );
1422cdf0e10cSrcweir
1423cdf0e10cSrcweir template< typename Type >
1424cdf0e10cSrcweir void writeNameItem( const String& rName, Type nData, const NameListWrapper& rListWrp );
1425cdf0e10cSrcweir template< typename Type >
1426cdf0e10cSrcweir void writeDecItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
1427cdf0e10cSrcweir template< typename Type >
1428cdf0e10cSrcweir void writeHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
1429cdf0e10cSrcweir template< typename Type >
1430cdf0e10cSrcweir void writeShortHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
1431cdf0e10cSrcweir template< typename Type >
1432cdf0e10cSrcweir void writeBinItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
1433cdf0e10cSrcweir template< typename Type >
1434cdf0e10cSrcweir void writeFixItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
1435cdf0e10cSrcweir template< typename Type >
1436cdf0e10cSrcweir void writeDecBoolItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST );
1437cdf0e10cSrcweir template< typename Type >
1438cdf0e10cSrcweir void writeValueItem( const String& rName, Type nData, FormatType eFmtType, const NameListWrapper& rListWrp = NO_LIST );
1439cdf0e10cSrcweir
1440cdf0e10cSrcweir template< typename Type >
1441cdf0e10cSrcweir void writeValueItem( const ItemFormat& rItemFmt, Type nData );
1442cdf0e10cSrcweir
1443cdf0e10cSrcweir template< typename Type >
1444cdf0e10cSrcweir void writeDecPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep = ',' );
1445cdf0e10cSrcweir template< typename Type >
1446cdf0e10cSrcweir void writeHexPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep = ',' );
1447cdf0e10cSrcweir
1448cdf0e10cSrcweir protected:
1449cdf0e10cSrcweir OutputRef mxOut;
1450cdf0e10cSrcweir ::rtl::OUString maSysFileName;
1451cdf0e10cSrcweir };
1452cdf0e10cSrcweir
1453cdf0e10cSrcweir typedef ::boost::shared_ptr< OutputObjectBase > OutputObjectRef;
1454cdf0e10cSrcweir
1455cdf0e10cSrcweir // ----------------------------------------------------------------------------
1456cdf0e10cSrcweir
1457cdf0e10cSrcweir template< typename Type >
addNameToItem(Type nData,const NameListWrapper & rListWrp)1458cdf0e10cSrcweir void OutputObjectBase::addNameToItem( Type nData, const NameListWrapper& rListWrp )
1459cdf0e10cSrcweir {
1460cdf0e10cSrcweir if( !rListWrp.isEmpty() )
1461cdf0e10cSrcweir {
1462cdf0e10cSrcweir mxOut->contItem();
1463cdf0e10cSrcweir mxOut->writeName( cfg(), nData, rListWrp );
1464cdf0e10cSrcweir }
1465cdf0e10cSrcweir }
1466cdf0e10cSrcweir
1467cdf0e10cSrcweir template< typename Type >
writeNameItem(const String & rName,Type nData,const NameListWrapper & rListWrp)1468cdf0e10cSrcweir void OutputObjectBase::writeNameItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
1469cdf0e10cSrcweir {
1470cdf0e10cSrcweir ItemGuard aItem( mxOut, rName );
1471cdf0e10cSrcweir mxOut->writeName( cfg(), nData, rListWrp );
1472cdf0e10cSrcweir }
1473cdf0e10cSrcweir
1474cdf0e10cSrcweir template< typename Type >
writeDecItem(const String & rName,Type nData,const NameListWrapper & rListWrp)1475cdf0e10cSrcweir void OutputObjectBase::writeDecItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
1476cdf0e10cSrcweir {
1477cdf0e10cSrcweir ItemGuard aItem( mxOut, rName );
1478cdf0e10cSrcweir mxOut->writeDec( nData );
1479cdf0e10cSrcweir addNameToItem( nData, rListWrp );
1480cdf0e10cSrcweir }
1481cdf0e10cSrcweir
1482cdf0e10cSrcweir template< typename Type >
writeHexItem(const String & rName,Type nData,const NameListWrapper & rListWrp)1483cdf0e10cSrcweir void OutputObjectBase::writeHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
1484cdf0e10cSrcweir {
1485cdf0e10cSrcweir ItemGuard aItem( mxOut, rName );
1486cdf0e10cSrcweir mxOut->writeHex( nData );
1487cdf0e10cSrcweir addNameToItem( nData, rListWrp );
1488cdf0e10cSrcweir }
1489cdf0e10cSrcweir
1490cdf0e10cSrcweir template< typename Type >
writeShortHexItem(const String & rName,Type nData,const NameListWrapper & rListWrp)1491cdf0e10cSrcweir void OutputObjectBase::writeShortHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
1492cdf0e10cSrcweir {
1493cdf0e10cSrcweir ItemGuard aItem( mxOut, rName );
1494cdf0e10cSrcweir mxOut->writeShortHex( nData );
1495cdf0e10cSrcweir addNameToItem( nData, rListWrp );
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir
1498cdf0e10cSrcweir template< typename Type >
writeBinItem(const String & rName,Type nData,const NameListWrapper & rListWrp)1499cdf0e10cSrcweir void OutputObjectBase::writeBinItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
1500cdf0e10cSrcweir {
1501cdf0e10cSrcweir ItemGuard aItem( mxOut, rName );
1502cdf0e10cSrcweir mxOut->writeBin( nData );
1503cdf0e10cSrcweir addNameToItem( nData, rListWrp );
1504cdf0e10cSrcweir }
1505cdf0e10cSrcweir
1506cdf0e10cSrcweir template< typename Type >
writeFixItem(const String & rName,Type nData,const NameListWrapper & rListWrp)1507cdf0e10cSrcweir void OutputObjectBase::writeFixItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
1508cdf0e10cSrcweir {
1509cdf0e10cSrcweir ItemGuard aItem( mxOut, rName );
1510cdf0e10cSrcweir mxOut->writeFix( nData );
1511cdf0e10cSrcweir addNameToItem( nData, rListWrp );
1512cdf0e10cSrcweir }
1513cdf0e10cSrcweir
1514cdf0e10cSrcweir template< typename Type >
writeDecBoolItem(const String & rName,Type nData,const NameListWrapper & rListWrp)1515cdf0e10cSrcweir void OutputObjectBase::writeDecBoolItem( const String& rName, Type nData, const NameListWrapper& rListWrp )
1516cdf0e10cSrcweir {
1517cdf0e10cSrcweir ItemGuard aItem( mxOut, rName );
1518cdf0e10cSrcweir mxOut->writeDec( nData );
1519cdf0e10cSrcweir aItem.cont();
1520cdf0e10cSrcweir mxOut->writeBool( nData != 0 );
1521cdf0e10cSrcweir addNameToItem( nData, rListWrp );
1522cdf0e10cSrcweir }
1523cdf0e10cSrcweir
1524cdf0e10cSrcweir template< typename Type >
writeValueItem(const String & rName,Type nData,FormatType eFmtType,const NameListWrapper & rListWrp)1525cdf0e10cSrcweir void OutputObjectBase::writeValueItem( const String& rName, Type nData, FormatType eFmtType, const NameListWrapper& rListWrp )
1526cdf0e10cSrcweir {
1527cdf0e10cSrcweir if( eFmtType == FORMATTYPE_BOOL )
1528cdf0e10cSrcweir writeDecBoolItem( rName, nData, rListWrp );
1529cdf0e10cSrcweir else
1530cdf0e10cSrcweir {
1531cdf0e10cSrcweir ItemGuard aItem( mxOut, rName );
1532cdf0e10cSrcweir mxOut->writeValue( nData, eFmtType );
1533cdf0e10cSrcweir addNameToItem( nData, rListWrp );
1534cdf0e10cSrcweir }
1535cdf0e10cSrcweir }
1536cdf0e10cSrcweir
1537cdf0e10cSrcweir template< typename Type >
writeValueItem(const ItemFormat & rItemFmt,Type nData)1538cdf0e10cSrcweir void OutputObjectBase::writeValueItem( const ItemFormat& rItemFmt, Type nData )
1539cdf0e10cSrcweir {
1540cdf0e10cSrcweir ::rtl::OString aNameUtf8 = StringHelper::convertToUtf8( rItemFmt.maItemName );
1541cdf0e10cSrcweir writeValueItem( aNameUtf8.getStr(), nData, rItemFmt.meFmtType, rItemFmt.maListName );
1542cdf0e10cSrcweir }
1543cdf0e10cSrcweir
1544cdf0e10cSrcweir template< typename Type >
writeDecPairItem(const String & rName,Type nData1,Type nData2,sal_Unicode cSep)1545cdf0e10cSrcweir void OutputObjectBase::writeDecPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep )
1546cdf0e10cSrcweir {
1547cdf0e10cSrcweir ItemGuard aItem( mxOut, rName );
1548cdf0e10cSrcweir mxOut->writeDec( nData1 );
1549cdf0e10cSrcweir mxOut->writeChar( cSep );
1550cdf0e10cSrcweir mxOut->writeDec( nData2 );
1551cdf0e10cSrcweir }
1552cdf0e10cSrcweir
1553cdf0e10cSrcweir template< typename Type >
writeHexPairItem(const String & rName,Type nData1,Type nData2,sal_Unicode cSep)1554cdf0e10cSrcweir void OutputObjectBase::writeHexPairItem( const String& rName, Type nData1, Type nData2, sal_Unicode cSep )
1555cdf0e10cSrcweir {
1556cdf0e10cSrcweir ItemGuard aItem( mxOut, rName );
1557cdf0e10cSrcweir mxOut->writeHex( nData1 );
1558cdf0e10cSrcweir mxOut->writeChar( cSep );
1559cdf0e10cSrcweir mxOut->writeHex( nData2 );
1560cdf0e10cSrcweir }
1561cdf0e10cSrcweir
1562cdf0e10cSrcweir // ============================================================================
1563cdf0e10cSrcweir // ============================================================================
1564cdf0e10cSrcweir
1565cdf0e10cSrcweir class InputObjectBase : public OutputObjectBase
1566cdf0e10cSrcweir {
1567cdf0e10cSrcweir public:
1568cdf0e10cSrcweir virtual ~InputObjectBase();
1569cdf0e10cSrcweir
1570cdf0e10cSrcweir // ------------------------------------------------------------------------
1571cdf0e10cSrcweir protected:
InputObjectBase()1572cdf0e10cSrcweir inline explicit InputObjectBase() {}
1573cdf0e10cSrcweir
1574cdf0e10cSrcweir using OutputObjectBase::construct;
1575cdf0e10cSrcweir void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName );
1576cdf0e10cSrcweir void construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm );
1577cdf0e10cSrcweir void construct( const InputObjectBase& rParent );
1578cdf0e10cSrcweir
1579cdf0e10cSrcweir virtual bool implIsValid() const;
1580cdf0e10cSrcweir
1581cdf0e10cSrcweir // ------------------------------------------------------------------------
1582cdf0e10cSrcweir
1583cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
1584cdf0e10cSrcweir getXInputStream() const;
1585cdf0e10cSrcweir
1586cdf0e10cSrcweir // ------------------------------------------------------------------------
1587cdf0e10cSrcweir
1588cdf0e10cSrcweir void skipBlock( sal_Int64 nBytes, bool bShowSize = true );
1589cdf0e10cSrcweir void dumpRawBinary( sal_Int64 nBytes, bool bShowOffset = true, bool bStream = false );
1590cdf0e10cSrcweir
1591cdf0e10cSrcweir void dumpBinary( const String& rName, sal_Int64 nBytes, bool bShowOffset = true );
1592cdf0e10cSrcweir void dumpRemaining( sal_Int64 nBytes );
1593cdf0e10cSrcweir void dumpRemainingTo( sal_Int64 nPos );
1594cdf0e10cSrcweir void dumpRemainingStream();
1595cdf0e10cSrcweir
1596cdf0e10cSrcweir void dumpArray( const String& rName, sal_Int32 nBytes, sal_Unicode cSep = OOX_DUMP_LISTSEP );
dumpUnused(sal_Int32 nBytes)1597cdf0e10cSrcweir inline void dumpUnused( sal_Int32 nBytes ) { dumpArray( OOX_DUMP_UNUSED, nBytes ); }
dumpUnknown(sal_Int32 nBytes)1598cdf0e10cSrcweir inline void dumpUnknown( sal_Int32 nBytes ) { dumpArray( OOX_DUMP_UNKNOWN, nBytes ); }
1599cdf0e10cSrcweir
1600cdf0e10cSrcweir sal_Unicode dumpChar( const String& rName, rtl_TextEncoding eTextEnc );
1601cdf0e10cSrcweir sal_Unicode dumpUnicode( const String& rName );
1602cdf0e10cSrcweir
1603cdf0e10cSrcweir ::rtl::OUString dumpCharArray( const String& rName, sal_Int32 nLen, rtl_TextEncoding eTextEnc, bool bHideTrailingNul = false );
1604cdf0e10cSrcweir ::rtl::OUString dumpUnicodeArray( const String& rName, sal_Int32 nLen, bool bHideTrailingNul = false );
1605cdf0e10cSrcweir
1606cdf0e10cSrcweir ::rtl::OUString dumpNullCharArray( const String& rName, rtl_TextEncoding eTextEnc );
1607cdf0e10cSrcweir ::rtl::OUString dumpNullUnicodeArray( const String& rName );
1608cdf0e10cSrcweir
1609cdf0e10cSrcweir double dumpRk( const String& rName = EMPTY_STRING );
1610cdf0e10cSrcweir sal_Int32 dumpColorABGR( const String& rName = EMPTY_STRING );
1611cdf0e10cSrcweir ::com::sun::star::util::DateTime dumpFileTime( const String& rName = EMPTY_STRING );
1612cdf0e10cSrcweir ::rtl::OUString dumpGuid( const String& rName = EMPTY_STRING );
1613cdf0e10cSrcweir
1614cdf0e10cSrcweir void dumpItem( const ItemFormat& rItemFmt );
1615cdf0e10cSrcweir
1616cdf0e10cSrcweir template< typename Type >
1617cdf0e10cSrcweir Type dumpName( const String& rName, const NameListWrapper& rListWrp );
1618cdf0e10cSrcweir template< typename Type >
1619cdf0e10cSrcweir Type dumpDec( const String& rName, const NameListWrapper& rListWrp = NO_LIST );
1620cdf0e10cSrcweir template< typename Type >
1621cdf0e10cSrcweir Type dumpHex( const String& rName, const NameListWrapper& rListWrp = NO_LIST );
1622cdf0e10cSrcweir template< typename Type >
1623cdf0e10cSrcweir Type dumpBin( const String& rName, const NameListWrapper& rListWrp = NO_LIST );
1624cdf0e10cSrcweir template< typename Type >
1625cdf0e10cSrcweir Type dumpFix( const String& rName, const NameListWrapper& rListWrp = NO_LIST );
1626cdf0e10cSrcweir template< typename Type >
1627cdf0e10cSrcweir Type dumpBool( const String& rName, const NameListWrapper& rListWrp = NO_LIST );
1628cdf0e10cSrcweir template< typename Type >
1629cdf0e10cSrcweir Type dumpValue( const ItemFormat& rItemFmt );
1630cdf0e10cSrcweir
1631cdf0e10cSrcweir template< typename Type1, typename Type2 >
1632cdf0e10cSrcweir Type1 dumpName( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
1633cdf0e10cSrcweir template< typename Type1, typename Type2 >
1634cdf0e10cSrcweir Type1 dumpDec( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
1635cdf0e10cSrcweir template< typename Type1, typename Type2 >
1636cdf0e10cSrcweir Type1 dumpHex( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
1637cdf0e10cSrcweir template< typename Type1, typename Type2 >
1638cdf0e10cSrcweir Type1 dumpBin( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
1639cdf0e10cSrcweir template< typename Type1, typename Type2 >
1640cdf0e10cSrcweir Type1 dumpFix( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
1641cdf0e10cSrcweir template< typename Type1, typename Type2 >
1642cdf0e10cSrcweir Type1 dumpBool( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST );
1643cdf0e10cSrcweir template< typename Type1, typename Type2 >
1644cdf0e10cSrcweir Type1 dumpValue( bool bType1, const ItemFormat& rItemFmt );
1645cdf0e10cSrcweir
1646cdf0e10cSrcweir template< typename Type >
1647cdf0e10cSrcweir void dumpDecPair( const String& rName, sal_Unicode cSep = ',' );
1648cdf0e10cSrcweir template< typename Type >
1649cdf0e10cSrcweir void dumpHexPair( const String& rName, sal_Unicode cSep = ',' );
1650cdf0e10cSrcweir
1651cdf0e10cSrcweir protected:
1652cdf0e10cSrcweir BinaryInputStreamRef mxStrm;
1653cdf0e10cSrcweir };
1654cdf0e10cSrcweir
1655cdf0e10cSrcweir typedef ::boost::shared_ptr< InputObjectBase > InputObjectRef;
1656cdf0e10cSrcweir
1657cdf0e10cSrcweir // ----------------------------------------------------------------------------
1658cdf0e10cSrcweir
1659cdf0e10cSrcweir template< typename Type >
dumpName(const String & rName,const NameListWrapper & rListWrp)1660cdf0e10cSrcweir Type InputObjectBase::dumpName( const String& rName, const NameListWrapper& rListWrp )
1661cdf0e10cSrcweir {
1662cdf0e10cSrcweir Type nData;
1663cdf0e10cSrcweir *mxStrm >> nData;
1664cdf0e10cSrcweir writeNameItem( rName, nData, rListWrp );
1665cdf0e10cSrcweir return nData;
1666cdf0e10cSrcweir }
1667cdf0e10cSrcweir
1668cdf0e10cSrcweir template< typename Type >
dumpDec(const String & rName,const NameListWrapper & rListWrp)1669cdf0e10cSrcweir Type InputObjectBase::dumpDec( const String& rName, const NameListWrapper& rListWrp )
1670cdf0e10cSrcweir {
1671cdf0e10cSrcweir Type nData;
1672cdf0e10cSrcweir *mxStrm >> nData;
1673cdf0e10cSrcweir writeDecItem( rName, nData, rListWrp );
1674cdf0e10cSrcweir return nData;
1675cdf0e10cSrcweir }
1676cdf0e10cSrcweir
1677cdf0e10cSrcweir template< typename Type >
dumpHex(const String & rName,const NameListWrapper & rListWrp)1678cdf0e10cSrcweir Type InputObjectBase::dumpHex( const String& rName, const NameListWrapper& rListWrp )
1679cdf0e10cSrcweir {
1680cdf0e10cSrcweir Type nData;
1681cdf0e10cSrcweir *mxStrm >> nData;
1682cdf0e10cSrcweir writeHexItem( rName, nData, rListWrp );
1683cdf0e10cSrcweir return nData;
1684cdf0e10cSrcweir }
1685cdf0e10cSrcweir
1686cdf0e10cSrcweir template< typename Type >
dumpBin(const String & rName,const NameListWrapper & rListWrp)1687cdf0e10cSrcweir Type InputObjectBase::dumpBin( const String& rName, const NameListWrapper& rListWrp )
1688cdf0e10cSrcweir {
1689cdf0e10cSrcweir Type nData;
1690cdf0e10cSrcweir *mxStrm >> nData;
1691cdf0e10cSrcweir writeBinItem( rName, nData, rListWrp );
1692cdf0e10cSrcweir return nData;
1693cdf0e10cSrcweir }
1694cdf0e10cSrcweir
1695cdf0e10cSrcweir template< typename Type >
dumpFix(const String & rName,const NameListWrapper & rListWrp)1696cdf0e10cSrcweir Type InputObjectBase::dumpFix( const String& rName, const NameListWrapper& rListWrp )
1697cdf0e10cSrcweir {
1698cdf0e10cSrcweir Type nData;
1699cdf0e10cSrcweir *mxStrm >> nData;
1700cdf0e10cSrcweir writeFixItem( rName, nData, rListWrp );
1701cdf0e10cSrcweir return nData;
1702cdf0e10cSrcweir }
1703cdf0e10cSrcweir
1704cdf0e10cSrcweir template< typename Type >
dumpBool(const String & rName,const NameListWrapper & rListWrp)1705cdf0e10cSrcweir Type InputObjectBase::dumpBool( const String& rName, const NameListWrapper& rListWrp )
1706cdf0e10cSrcweir {
1707cdf0e10cSrcweir Type nData;
1708cdf0e10cSrcweir *mxStrm >> nData;
1709cdf0e10cSrcweir writeDecBoolItem( rName, nData, rListWrp );
1710cdf0e10cSrcweir return nData;
1711cdf0e10cSrcweir }
1712cdf0e10cSrcweir
1713cdf0e10cSrcweir template< typename Type >
dumpValue(const ItemFormat & rItemFmt)1714cdf0e10cSrcweir Type InputObjectBase::dumpValue( const ItemFormat& rItemFmt )
1715cdf0e10cSrcweir {
1716cdf0e10cSrcweir Type nData;
1717cdf0e10cSrcweir *mxStrm >> nData;
1718cdf0e10cSrcweir writeValueItem( rItemFmt, nData );
1719cdf0e10cSrcweir return nData;
1720cdf0e10cSrcweir }
1721cdf0e10cSrcweir
1722cdf0e10cSrcweir template< typename Type1, typename Type2 >
dumpName(bool bType1,const String & rName,const NameListWrapper & rListWrp)1723cdf0e10cSrcweir Type1 InputObjectBase::dumpName( bool bType1, const String& rName, const NameListWrapper& rListWrp )
1724cdf0e10cSrcweir {
1725cdf0e10cSrcweir return bType1 ? dumpName< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpName< Type2 >( rName, rListWrp ) );
1726cdf0e10cSrcweir }
1727cdf0e10cSrcweir
1728cdf0e10cSrcweir template< typename Type1, typename Type2 >
dumpDec(bool bType1,const String & rName,const NameListWrapper & rListWrp)1729cdf0e10cSrcweir Type1 InputObjectBase::dumpDec( bool bType1, const String& rName, const NameListWrapper& rListWrp )
1730cdf0e10cSrcweir {
1731cdf0e10cSrcweir return bType1 ? dumpDec< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpDec< Type2 >( rName, rListWrp ) );
1732cdf0e10cSrcweir }
1733cdf0e10cSrcweir
1734cdf0e10cSrcweir template< typename Type1, typename Type2 >
dumpHex(bool bType1,const String & rName,const NameListWrapper & rListWrp)1735cdf0e10cSrcweir Type1 InputObjectBase::dumpHex( bool bType1, const String& rName, const NameListWrapper& rListWrp )
1736cdf0e10cSrcweir {
1737cdf0e10cSrcweir return bType1 ? dumpHex< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpHex< Type2 >( rName, rListWrp ) );
1738cdf0e10cSrcweir }
1739cdf0e10cSrcweir
1740cdf0e10cSrcweir template< typename Type1, typename Type2 >
dumpBin(bool bType1,const String & rName,const NameListWrapper & rListWrp)1741cdf0e10cSrcweir Type1 InputObjectBase::dumpBin( bool bType1, const String& rName, const NameListWrapper& rListWrp )
1742cdf0e10cSrcweir {
1743cdf0e10cSrcweir return bType1 ? dumpBin< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpBin< Type2 >( rName, rListWrp ) );
1744cdf0e10cSrcweir }
1745cdf0e10cSrcweir
1746cdf0e10cSrcweir template< typename Type1, typename Type2 >
dumpFix(bool bType1,const String & rName,const NameListWrapper & rListWrp)1747cdf0e10cSrcweir Type1 InputObjectBase::dumpFix( bool bType1, const String& rName, const NameListWrapper& rListWrp )
1748cdf0e10cSrcweir {
1749cdf0e10cSrcweir return bType1 ? dumpFix< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpFix< Type2 >( rName, rListWrp ) );
1750cdf0e10cSrcweir }
1751cdf0e10cSrcweir
1752cdf0e10cSrcweir template< typename Type1, typename Type2 >
dumpBool(bool bType1,const String & rName,const NameListWrapper & rListWrp)1753cdf0e10cSrcweir Type1 InputObjectBase::dumpBool( bool bType1, const String& rName, const NameListWrapper& rListWrp )
1754cdf0e10cSrcweir {
1755cdf0e10cSrcweir return bType1 ? dumpBool< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpBool< Type2 >( rName, rListWrp ) );
1756cdf0e10cSrcweir }
1757cdf0e10cSrcweir
1758cdf0e10cSrcweir template< typename Type1, typename Type2 >
dumpValue(bool bType1,const ItemFormat & rItemFmt)1759cdf0e10cSrcweir Type1 InputObjectBase::dumpValue( bool bType1, const ItemFormat& rItemFmt )
1760cdf0e10cSrcweir {
1761cdf0e10cSrcweir return bType1 ? dumpValue< Type1 >( rItemFmt ) : static_cast< Type1 >( dumpValue< Type2 >( rItemFmt ) );
1762cdf0e10cSrcweir }
1763cdf0e10cSrcweir
1764cdf0e10cSrcweir template< typename Type >
dumpDecPair(const String & rName,sal_Unicode cSep)1765cdf0e10cSrcweir void InputObjectBase::dumpDecPair( const String& rName, sal_Unicode cSep )
1766cdf0e10cSrcweir {
1767cdf0e10cSrcweir Type nData1, nData2;
1768cdf0e10cSrcweir *mxStrm >> nData1 >> nData2;
1769cdf0e10cSrcweir writeDecPairItem( rName, nData1, nData2, cSep );
1770cdf0e10cSrcweir }
1771cdf0e10cSrcweir
1772cdf0e10cSrcweir template< typename Type >
dumpHexPair(const String & rName,sal_Unicode cSep)1773cdf0e10cSrcweir void InputObjectBase::dumpHexPair( const String& rName, sal_Unicode cSep )
1774cdf0e10cSrcweir {
1775cdf0e10cSrcweir Type nData1, nData2;
1776cdf0e10cSrcweir *mxStrm >> nData1 >> nData2;
1777cdf0e10cSrcweir writeHexPairItem( rName, nData1, nData2, cSep );
1778cdf0e10cSrcweir }
1779cdf0e10cSrcweir
1780cdf0e10cSrcweir // ============================================================================
1781cdf0e10cSrcweir // ============================================================================
1782cdf0e10cSrcweir
1783cdf0e10cSrcweir class BinaryStreamObject : public InputObjectBase
1784cdf0e10cSrcweir {
1785cdf0e10cSrcweir public:
1786cdf0e10cSrcweir explicit BinaryStreamObject(
1787cdf0e10cSrcweir const ObjectBase& rParent,
1788cdf0e10cSrcweir const BinaryInputStreamRef& rxStrm,
1789cdf0e10cSrcweir const ::rtl::OUString& rSysFileName );
1790cdf0e10cSrcweir
1791cdf0e10cSrcweir explicit BinaryStreamObject(
1792cdf0e10cSrcweir const OutputObjectBase& rParent,
1793cdf0e10cSrcweir const BinaryInputStreamRef& rxStrm );
1794cdf0e10cSrcweir
1795cdf0e10cSrcweir protected:
1796cdf0e10cSrcweir void dumpBinaryStream( bool bShowOffset = true );
1797cdf0e10cSrcweir
1798cdf0e10cSrcweir virtual void implDump();
1799cdf0e10cSrcweir };
1800cdf0e10cSrcweir
1801cdf0e10cSrcweir // ============================================================================
1802cdf0e10cSrcweir // ============================================================================
1803cdf0e10cSrcweir
1804cdf0e10cSrcweir class TextStreamObjectBase : public InputObjectBase
1805cdf0e10cSrcweir {
1806cdf0e10cSrcweir protected:
TextStreamObjectBase()1807cdf0e10cSrcweir inline TextStreamObjectBase() {}
1808cdf0e10cSrcweir
1809cdf0e10cSrcweir using InputObjectBase::construct;
1810cdf0e10cSrcweir void construct(
1811cdf0e10cSrcweir const ObjectBase& rParent,
1812cdf0e10cSrcweir const BinaryInputStreamRef& rxStrm,
1813cdf0e10cSrcweir rtl_TextEncoding eTextEnc,
1814cdf0e10cSrcweir const ::rtl::OUString& rSysFileName );
1815cdf0e10cSrcweir void construct(
1816cdf0e10cSrcweir const OutputObjectBase& rParent,
1817cdf0e10cSrcweir const BinaryInputStreamRef& rxStrm,
1818cdf0e10cSrcweir rtl_TextEncoding eTextEnc );
1819cdf0e10cSrcweir void construct(
1820cdf0e10cSrcweir const InputObjectBase& rParent,
1821cdf0e10cSrcweir rtl_TextEncoding eTextEnc );
1822cdf0e10cSrcweir
1823cdf0e10cSrcweir virtual bool implIsValid() const;
1824cdf0e10cSrcweir virtual void implDump();
1825cdf0e10cSrcweir
1826cdf0e10cSrcweir virtual void implDumpText( TextInputStream& rTextStrm ) = 0;
1827cdf0e10cSrcweir
1828cdf0e10cSrcweir private:
1829cdf0e10cSrcweir void constructTextStrmObj( rtl_TextEncoding eTextEnc );
1830cdf0e10cSrcweir
1831cdf0e10cSrcweir protected:
1832cdf0e10cSrcweir ::boost::shared_ptr< TextInputStream > mxTextStrm;
1833cdf0e10cSrcweir };
1834cdf0e10cSrcweir
1835cdf0e10cSrcweir // ============================================================================
1836cdf0e10cSrcweir
1837cdf0e10cSrcweir class TextLineStreamObject : public TextStreamObjectBase
1838cdf0e10cSrcweir {
1839cdf0e10cSrcweir public:
1840cdf0e10cSrcweir explicit TextLineStreamObject(
1841cdf0e10cSrcweir const ObjectBase& rParent,
1842cdf0e10cSrcweir const BinaryInputStreamRef& rxStrm,
1843cdf0e10cSrcweir rtl_TextEncoding eTextEnc,
1844cdf0e10cSrcweir const ::rtl::OUString& rSysFileName );
1845cdf0e10cSrcweir
1846cdf0e10cSrcweir explicit TextLineStreamObject(
1847cdf0e10cSrcweir const OutputObjectBase& rParent,
1848cdf0e10cSrcweir const BinaryInputStreamRef& rxStrm,
1849cdf0e10cSrcweir rtl_TextEncoding eTextEnc );
1850cdf0e10cSrcweir
1851cdf0e10cSrcweir protected:
1852cdf0e10cSrcweir virtual void implDumpText( TextInputStream& rTextStrm );
1853cdf0e10cSrcweir virtual void implDumpLine( const ::rtl::OUString& rLine, sal_uInt32 nLine );
1854cdf0e10cSrcweir };
1855cdf0e10cSrcweir
1856cdf0e10cSrcweir // ============================================================================
1857cdf0e10cSrcweir
1858cdf0e10cSrcweir class XmlStreamObject : public TextStreamObjectBase
1859cdf0e10cSrcweir {
1860cdf0e10cSrcweir public:
1861cdf0e10cSrcweir explicit XmlStreamObject(
1862cdf0e10cSrcweir const ObjectBase& rParent,
1863cdf0e10cSrcweir const BinaryInputStreamRef& rxStrm,
1864cdf0e10cSrcweir const ::rtl::OUString& rSysFileName );
1865cdf0e10cSrcweir
1866cdf0e10cSrcweir explicit XmlStreamObject(
1867cdf0e10cSrcweir const OutputObjectBase& rParent,
1868cdf0e10cSrcweir const BinaryInputStreamRef& rxStrm );
1869cdf0e10cSrcweir
1870cdf0e10cSrcweir protected:
1871cdf0e10cSrcweir virtual void implDumpText( TextInputStream& rTextStrm );
1872cdf0e10cSrcweir };
1873cdf0e10cSrcweir
1874cdf0e10cSrcweir // ============================================================================
1875cdf0e10cSrcweir // ============================================================================
1876cdf0e10cSrcweir
1877cdf0e10cSrcweir class RecordObjectBase : public InputObjectBase
1878cdf0e10cSrcweir {
1879cdf0e10cSrcweir protected:
RecordObjectBase()1880cdf0e10cSrcweir inline explicit RecordObjectBase() {}
1881cdf0e10cSrcweir
1882cdf0e10cSrcweir using InputObjectBase::construct;
1883cdf0e10cSrcweir void construct(
1884cdf0e10cSrcweir const ObjectBase& rParent,
1885cdf0e10cSrcweir const BinaryInputStreamRef& rxBaseStrm,
1886cdf0e10cSrcweir const ::rtl::OUString& rSysFileName,
1887cdf0e10cSrcweir const BinaryInputStreamRef& rxRecStrm,
1888cdf0e10cSrcweir const String& rRecNames,
1889cdf0e10cSrcweir const String& rSimpleRecs = EMPTY_STRING );
1890cdf0e10cSrcweir void construct(
1891cdf0e10cSrcweir const OutputObjectBase& rParent,
1892cdf0e10cSrcweir const BinaryInputStreamRef& rxBaseStrm,
1893cdf0e10cSrcweir const BinaryInputStreamRef& rxRecStrm,
1894cdf0e10cSrcweir const String& rRecNames,
1895cdf0e10cSrcweir const String& rSimpleRecs = EMPTY_STRING );
1896cdf0e10cSrcweir
getRecPos() const1897cdf0e10cSrcweir inline sal_Int64 getRecPos() const { return mnRecPos; }
getRecId() const1898cdf0e10cSrcweir inline sal_Int64 getRecId() const { return mnRecId; }
getRecSize() const1899cdf0e10cSrcweir inline sal_Int64 getRecSize() const { return mnRecSize; }
getRecNames() const1900cdf0e10cSrcweir inline NameListRef getRecNames() const { return maRecNames.getNameList( cfg() ); }
1901cdf0e10cSrcweir
setBinaryOnlyMode(bool bBinaryOnly)1902cdf0e10cSrcweir inline void setBinaryOnlyMode( bool bBinaryOnly ) { mbBinaryOnly = bBinaryOnly; }
isBinaryOnlyMode() const1903cdf0e10cSrcweir inline bool isBinaryOnlyMode() const { return mbBinaryOnly; }
1904cdf0e10cSrcweir
1905cdf0e10cSrcweir virtual bool implIsValid() const;
1906cdf0e10cSrcweir virtual void implDump();
1907cdf0e10cSrcweir
1908cdf0e10cSrcweir virtual bool implStartRecord( BinaryInputStream& rBaseStrm, sal_Int64& ornRecPos, sal_Int64& ornRecId, sal_Int64& ornRecSize ) = 0;
1909cdf0e10cSrcweir virtual void implWriteExtHeader();
1910cdf0e10cSrcweir virtual void implDumpRecordBody();
1911cdf0e10cSrcweir
1912cdf0e10cSrcweir private:
1913cdf0e10cSrcweir void constructRecObjBase(
1914cdf0e10cSrcweir const BinaryInputStreamRef& rxBaseStrm,
1915cdf0e10cSrcweir const String& rRecNames,
1916cdf0e10cSrcweir const String& rSimpleRecs );
1917cdf0e10cSrcweir
1918cdf0e10cSrcweir void writeHeader();
1919cdf0e10cSrcweir
1920cdf0e10cSrcweir private:
1921cdf0e10cSrcweir BinaryInputStreamRef mxBaseStrm;
1922cdf0e10cSrcweir NameListWrapper maRecNames;
1923cdf0e10cSrcweir NameListWrapper maSimpleRecs;
1924cdf0e10cSrcweir sal_Int64 mnRecPos;
1925cdf0e10cSrcweir sal_Int64 mnRecId;
1926cdf0e10cSrcweir sal_Int64 mnRecSize;
1927cdf0e10cSrcweir bool mbShowRecPos;
1928cdf0e10cSrcweir bool mbBinaryOnly;
1929cdf0e10cSrcweir };
1930cdf0e10cSrcweir
1931cdf0e10cSrcweir // ============================================================================
1932cdf0e10cSrcweir
1933cdf0e10cSrcweir class SequenceRecordObjectBase : public RecordObjectBase
1934cdf0e10cSrcweir {
1935cdf0e10cSrcweir protected:
SequenceRecordObjectBase()1936cdf0e10cSrcweir inline explicit SequenceRecordObjectBase() : mxRecData( new StreamDataSequence ) {}
1937cdf0e10cSrcweir
getRecordDataSequence()1938cdf0e10cSrcweir inline StreamDataSequence& getRecordDataSequence() { return *mxRecData; }
1939cdf0e10cSrcweir
1940cdf0e10cSrcweir using RecordObjectBase::construct;
1941cdf0e10cSrcweir void construct(
1942cdf0e10cSrcweir const ObjectBase& rParent,
1943cdf0e10cSrcweir const BinaryInputStreamRef& rxBaseStrm,
1944cdf0e10cSrcweir const ::rtl::OUString& rSysFileName,
1945cdf0e10cSrcweir const String& rRecNames,
1946cdf0e10cSrcweir const String& rSimpleRecs = EMPTY_STRING );
1947cdf0e10cSrcweir void construct(
1948cdf0e10cSrcweir const OutputObjectBase& rParent,
1949cdf0e10cSrcweir const BinaryInputStreamRef& rxBaseStrm,
1950cdf0e10cSrcweir const String& rRecNames,
1951cdf0e10cSrcweir const String& rSimpleRecs = EMPTY_STRING );
1952cdf0e10cSrcweir
1953cdf0e10cSrcweir virtual bool implStartRecord( BinaryInputStream& rBaseStrm, sal_Int64& ornRecPos, sal_Int64& ornRecId, sal_Int64& ornRecSize );
1954cdf0e10cSrcweir virtual bool implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) = 0;
1955cdf0e10cSrcweir
1956cdf0e10cSrcweir private:
1957cdf0e10cSrcweir typedef ::boost::shared_ptr< StreamDataSequence > StreamDataSeqRef;
1958cdf0e10cSrcweir StreamDataSeqRef mxRecData;
1959cdf0e10cSrcweir };
1960cdf0e10cSrcweir
1961cdf0e10cSrcweir // ============================================================================
1962cdf0e10cSrcweir // ============================================================================
1963cdf0e10cSrcweir
1964cdf0e10cSrcweir /** Base class for a file dumper. Derived classes implement the implDump()
1965cdf0e10cSrcweir function to add functionality.
1966cdf0e10cSrcweir */
1967cdf0e10cSrcweir class DumperBase : public ObjectBase
1968cdf0e10cSrcweir {
1969cdf0e10cSrcweir public:
1970cdf0e10cSrcweir virtual ~DumperBase();
1971cdf0e10cSrcweir
1972cdf0e10cSrcweir bool isImportEnabled() const;
1973cdf0e10cSrcweir bool isImportCancelled() const;
1974cdf0e10cSrcweir
1975cdf0e10cSrcweir protected:
DumperBase()1976cdf0e10cSrcweir inline explicit DumperBase() {}
1977cdf0e10cSrcweir
1978cdf0e10cSrcweir using ObjectBase::construct;
1979cdf0e10cSrcweir void construct( const ConfigRef& rxConfig );
1980cdf0e10cSrcweir };
1981cdf0e10cSrcweir
1982cdf0e10cSrcweir // ============================================================================
1983cdf0e10cSrcweir // ============================================================================
1984cdf0e10cSrcweir
1985cdf0e10cSrcweir } // namespace dump
1986cdf0e10cSrcweir } // namespace oox
1987cdf0e10cSrcweir
1988cdf0e10cSrcweir #define OOX_DUMP_FILE( DumperClassName ) \
1989cdf0e10cSrcweir do { \
1990cdf0e10cSrcweir DumperClassName aDumper( *this ); \
1991cdf0e10cSrcweir aDumper.dump(); \
1992cdf0e10cSrcweir bool bCancelled = aDumper.isImportCancelled(); \
1993cdf0e10cSrcweir if( !aDumper.isImportEnabled() || bCancelled ) \
1994cdf0e10cSrcweir return aDumper.isValid() && !bCancelled; \
1995cdf0e10cSrcweir } while( false )
1996cdf0e10cSrcweir
1997cdf0e10cSrcweir #else // OOX_INCLUDE_DUMPER
1998cdf0e10cSrcweir
1999cdf0e10cSrcweir #define OOX_DUMP_FILE( DumperClassName ) (void)0
2000cdf0e10cSrcweir
2001cdf0e10cSrcweir #endif // OOX_INCLUDE_DUMPER
2002cdf0e10cSrcweir #endif
2003