Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef SC_XLSTRING_HXX
21 : #define SC_XLSTRING_HXX
22 :
23 : #include "ftools.hxx"
24 :
25 : // Constants and enumerations =================================================
26 :
27 : /** Flags used to specify import/export mode of strings. */
28 : typedef sal_uInt16 XclStrFlags;
29 :
30 : const XclStrFlags EXC_STR_DEFAULT = 0x0000; /// Default string settings.
31 : const XclStrFlags EXC_STR_FORCEUNICODE = 0x0001; /// Always use UCS-2 characters (default: try to compress). BIFF8 only.
32 : const XclStrFlags EXC_STR_8BITLENGTH = 0x0002; /// 8-bit string length field (default: 16-bit).
33 : const XclStrFlags EXC_STR_SMARTFLAGS = 0x0004; /// Omit flags on empty string (default: read/write always). BIFF8 only.
34 : const XclStrFlags EXC_STR_SEPARATEFORMATS = 0x0008; /// Import: Keep old formats when reading unformatted string (default: clear formats); Export: Write unformatted string.
35 : const XclStrFlags EXC_STR_NOHEADER = 0x0010; /// Export: Don't write the length and flag fields.
36 :
37 : // ----------------------------------------------------------------------------
38 :
39 : const sal_uInt16 EXC_STR_MAXLEN_8BIT = 0x00FF;
40 : const sal_uInt16 EXC_STR_MAXLEN = 0x7FFF;
41 :
42 : const sal_uInt8 EXC_STRF_16BIT = 0x01;
43 : const sal_uInt8 EXC_STRF_FAREAST = 0x04;
44 : const sal_uInt8 EXC_STRF_RICH = 0x08;
45 : const sal_uInt8 EXC_STRF_UNKNOWN = 0xF2;
46 :
47 : // Fixed-size characters
48 : const sal_uInt8 EXC_LF_C = '\x0A'; /// LF character (used for line break).
49 : const sal_uInt16 EXC_LF = EXC_LF_C; /// LF character (unicode).
50 : const sal_uInt8 EXC_NUL_C = '\x00'; /// NUL chararcter.
51 : const sal_uInt16 EXC_NUL = EXC_NUL_C; /// NUL chararcter (unicode).
52 :
53 : // Rich-string formatting runs ================================================
54 :
55 : /** Represents a formatting run for rich-strings.
56 :
57 : An Excel formatting run stores the first formatted character in a
58 : rich-string and the index of a font used to format this and the following
59 : characters.
60 : */
61 : struct XclFormatRun
62 : {
63 : sal_uInt16 mnChar; /// First character this format applies to.
64 : sal_uInt16 mnFontIdx; /// Excel font index for the next characters.
65 :
66 48 : explicit inline XclFormatRun() : mnChar( 0 ), mnFontIdx( 0 ) {}
67 115 : explicit inline XclFormatRun( sal_uInt16 nChar, sal_uInt16 nFontIdx ) :
68 115 : mnChar( nChar ), mnFontIdx( nFontIdx ) {}
69 : };
70 :
71 0 : inline bool operator==( const XclFormatRun& rLeft, const XclFormatRun& rRight )
72 : {
73 0 : return (rLeft.mnChar == rRight.mnChar) && (rLeft.mnFontIdx == rRight.mnFontIdx);
74 : }
75 :
76 0 : inline bool operator<( const XclFormatRun& rLeft, const XclFormatRun& rRight )
77 : {
78 0 : return (rLeft.mnChar < rRight.mnChar) || ((rLeft.mnChar == rRight.mnChar) && (rLeft.mnFontIdx < rRight.mnFontIdx));
79 : }
80 :
81 : // ----------------------------------------------------------------------------
82 :
83 : /** A vector with all formatting runs for a rich-string. */
84 : typedef ::std::vector< XclFormatRun > XclFormatRunVec;
85 :
86 : // ============================================================================
87 :
88 : #endif
89 :
90 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|