Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_XLSTRING_HXX
30 : : #define SC_XLSTRING_HXX
31 : :
32 : : #include "ftools.hxx"
33 : :
34 : : // Constants and enumerations =================================================
35 : :
36 : : /** Flags used to specify import/export mode of strings. */
37 : : typedef sal_uInt16 XclStrFlags;
38 : :
39 : : const XclStrFlags EXC_STR_DEFAULT = 0x0000; /// Default string settings.
40 : : const XclStrFlags EXC_STR_FORCEUNICODE = 0x0001; /// Always use UCS-2 characters (default: try to compress). BIFF8 only.
41 : : const XclStrFlags EXC_STR_8BITLENGTH = 0x0002; /// 8-bit string length field (default: 16-bit).
42 : : const XclStrFlags EXC_STR_SMARTFLAGS = 0x0004; /// Omit flags on empty string (default: read/write always). BIFF8 only.
43 : : const XclStrFlags EXC_STR_SEPARATEFORMATS = 0x0008; /// Import: Keep old formats when reading unformatted string (default: clear formats); Export: Write unformatted string.
44 : : const XclStrFlags EXC_STR_NOHEADER = 0x0010; /// Export: Don't write the length and flag fields.
45 : :
46 : : // ----------------------------------------------------------------------------
47 : :
48 : : const sal_uInt16 EXC_STR_MAXLEN_8BIT = 0x00FF;
49 : : const sal_uInt16 EXC_STR_MAXLEN = 0x7FFF;
50 : :
51 : : const sal_uInt8 EXC_STRF_16BIT = 0x01;
52 : : const sal_uInt8 EXC_STRF_FAREAST = 0x04;
53 : : const sal_uInt8 EXC_STRF_RICH = 0x08;
54 : : const sal_uInt8 EXC_STRF_UNKNOWN = 0xF2;
55 : :
56 : : // Fixed-size characters
57 : : const sal_uInt8 EXC_LF_C = '\x0A'; /// LF character (used for line break).
58 : : const sal_uInt16 EXC_LF = EXC_LF_C; /// LF character (unicode).
59 : : const sal_uInt8 EXC_NUL_C = '\x00'; /// NUL chararcter.
60 : : const sal_uInt16 EXC_NUL = EXC_NUL_C; /// NUL chararcter (unicode).
61 : :
62 : : // Rich-string formatting runs ================================================
63 : :
64 : : /** Represents a formatting run for rich-strings.
65 : :
66 : : An Excel formatting run stores the first formatted character in a
67 : : rich-string and the index of a font used to format this and the following
68 : : characters.
69 : : */
70 : : struct XclFormatRun
71 : : {
72 : : sal_uInt16 mnChar; /// First character this format applies to.
73 : : sal_uInt16 mnFontIdx; /// Excel font index for the next characters.
74 : :
75 : 141 : explicit inline XclFormatRun() : mnChar( 0 ), mnFontIdx( 0 ) {}
76 : 318 : explicit inline XclFormatRun( sal_uInt16 nChar, sal_uInt16 nFontIdx ) :
77 : 318 : mnChar( nChar ), mnFontIdx( nFontIdx ) {}
78 : : };
79 : :
80 : 0 : inline bool operator==( const XclFormatRun& rLeft, const XclFormatRun& rRight )
81 : : {
82 [ # # ][ # # ]: 0 : return (rLeft.mnChar == rRight.mnChar) && (rLeft.mnFontIdx == rRight.mnFontIdx);
83 : : }
84 : :
85 : 0 : inline bool operator<( const XclFormatRun& rLeft, const XclFormatRun& rRight )
86 : : {
87 [ # # ][ # # ]: 0 : return (rLeft.mnChar < rRight.mnChar) || ((rLeft.mnChar == rRight.mnChar) && (rLeft.mnFontIdx < rRight.mnFontIdx));
[ # # ]
88 : : }
89 : :
90 : : // ----------------------------------------------------------------------------
91 : :
92 : : /** A vector with all formatting runs for a rich-string. */
93 : : typedef ::std::vector< XclFormatRun > XclFormatRunVec;
94 : :
95 : : // ============================================================================
96 : :
97 : : #endif
98 : :
99 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|