xref: /trunk/main/sc/source/filter/inc/xlstring.hxx (revision 402c6fde)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_XLSTRING_HXX
25 #define SC_XLSTRING_HXX
26 
27 #include "ftools.hxx"
28 
29 // Constants and enumerations =================================================
30 
31 /** Flags used to specify import/export mode of strings. */
32 typedef sal_uInt16 XclStrFlags;
33 
34 const XclStrFlags EXC_STR_DEFAULT           = 0x0000;   /// Default string settings.
35 const XclStrFlags EXC_STR_FORCEUNICODE      = 0x0001;   /// Always use UCS-2 characters (default: try to compress). BIFF8 only.
36 const XclStrFlags EXC_STR_8BITLENGTH        = 0x0002;   /// 8-bit string length field (default: 16-bit).
37 const XclStrFlags EXC_STR_SMARTFLAGS        = 0x0004;   /// Omit flags on empty string (default: read/write always). BIFF8 only.
38 const XclStrFlags EXC_STR_SEPARATEFORMATS   = 0x0008;   /// Import: Keep old formats when reading unformatted string (default: clear formats); Export: Write unformatted string.
39 const XclStrFlags EXC_STR_NOHEADER          = 0x0010;   /// Export: Don't write the length and flag fields.
40 
41 // ----------------------------------------------------------------------------
42 
43 const sal_uInt16 EXC_STR_MAXLEN_8BIT        = 0x00FF;
44 const sal_uInt16 EXC_STR_MAXLEN             = 0xFFFF;
45 
46 const sal_uInt8 EXC_STRF_16BIT              = 0x01;
47 const sal_uInt8 EXC_STRF_FAREAST            = 0x04;
48 const sal_uInt8 EXC_STRF_RICH               = 0x08;
49 const sal_uInt8 EXC_STRF_UNKNOWN            = 0xF2;
50 
51 // Fixed-size characters
52 const sal_uInt8 EXC_LF_C                    = '\x0A';       /// LF character (used for line break).
53 const sal_uInt16 EXC_LF                     = EXC_LF_C;     /// LF character (unicode).
54 const sal_uInt8 EXC_NUL_C                   = '\x00';       /// NUL character.
55 const sal_uInt16 EXC_NUL                    = EXC_NUL_C;    /// NUL character (unicode).
56 
57 // Rich-string formatting runs ================================================
58 
59 /** Represents a formatting run for rich-strings.
60 
61     An Excel formatting run stores the first formatted character in a
62     rich-string and the index of a font used to format this and the following
63     characters.
64  */
65 struct XclFormatRun
66 {
67     sal_uInt16          mnChar;         /// First character this format applies to.
68     sal_uInt16          mnFontIdx;      /// Excel font index for the next characters.
69 
XclFormatRunXclFormatRun70     explicit inline     XclFormatRun() : mnChar( 0 ), mnFontIdx( 0 ) {}
XclFormatRunXclFormatRun71     explicit inline     XclFormatRun( sal_uInt16 nChar, sal_uInt16 nFontIdx ) :
72                             mnChar( nChar ), mnFontIdx( nFontIdx ) {}
73 };
74 
operator ==(const XclFormatRun & rLeft,const XclFormatRun & rRight)75 inline bool operator==( const XclFormatRun& rLeft, const XclFormatRun& rRight )
76 {
77     return (rLeft.mnChar == rRight.mnChar) && (rLeft.mnFontIdx == rRight.mnFontIdx);
78 }
79 
operator <(const XclFormatRun & rLeft,const XclFormatRun & rRight)80 inline bool operator<( const XclFormatRun& rLeft, const XclFormatRun& rRight )
81 {
82     return (rLeft.mnChar < rRight.mnChar) || ((rLeft.mnChar == rRight.mnChar) && (rLeft.mnFontIdx < rRight.mnFontIdx));
83 }
84 
85 // ----------------------------------------------------------------------------
86 
87 /** A vector with all formatting runs for a rich-string. */
88 typedef ::std::vector< XclFormatRun > XclFormatRunVec;
89 
90 // ============================================================================
91 
92 #endif
93 
94