xref: /trunk/main/svtools/source/inc/xpmread.hxx (revision 01aa44aa)
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 _XPMREAD_HXX
25 #define _XPMREAD_HXX
26 
27 #ifndef _BITMAP_HXX
28 #include <vcl/bitmap.hxx>
29 #endif
30 
31 #ifdef _XPMPRIVATE
32 
33 #define XPMTEMPBUFSIZE		0x00008000
34 #define XPMSTRINGBUF		0x00008000
35 
36 #define XPMIDENTIFIER		0x00000001			// mnIdentifier includes on of the six phases
37 #define XPMDEFINITION		0x00000002			// the XPM format consists of
38 #define XPMVALUES			0x00000003
39 #define XPMCOLORS			0x00000004
40 #define XPMPIXELS			0x00000005
41 #define XPMEXTENSIONS		0x00000006
42 #define XPMENDEXT			0x00000007
43 
44 
45 #define XPMREMARK			0x00000001			// defines used by mnStatus
46 #define XPMDOUBLE			0x00000002
47 #define XPMSTRING			0x00000004
48 #define XPMFINISHED			0x00000008
49 
50 #define XPMCASESENSITIVE	0x00000001
51 #define XPMCASENONSENSITIVE 0x00000002
52 
53 // ---------
54 // - Enums -
55 // ---------
56 
57 enum ReadState
58 {
59 	XPMREAD_OK,
60 	XPMREAD_ERROR,
61 	XPMREAD_NEED_MORE
62 };
63 
64 // -------------
65 // - XPMReader -
66 // -------------
67 
68 class BitmapWriteAccess;
69 class Graphic;
70 
71 class XPMReader : public GraphicReader
72 {
73 private:
74 
75 	SvStream&			mrIStm;
76 	Bitmap				maBmp;
77 	BitmapWriteAccess*	mpAcc;
78 	Bitmap				maMaskBmp;
79 	BitmapWriteAccess*	mpMaskAcc;
80 	long				mnLastPos;
81 
82 	sal_uLong				mnWidth;
83 	sal_uLong				mnHeight;
84 	sal_uLong				mnColors;
85 	sal_uLong				mnCpp;								// characters per pix
86 	sal_Bool				mbTransparent;
87 	sal_Bool				mbStatus;
88 	sal_uLong				mnStatus;
89 	sal_uLong				mnIdentifier;
90 	sal_uInt8				mcThisByte;
91 	sal_uInt8				mcLastByte;
92 	sal_uLong				mnTempAvail;
93 	sal_uInt8*				mpTempBuf;
94 	sal_uInt8*				mpTempPtr;
95 	sal_uInt8*				mpFastColorTable;
96 	sal_uInt8*				mpColMap;
97 	sal_uLong				mnStringSize;
98 	sal_uInt8*				mpStringBuf;
99 	sal_uLong				mnParaSize;
100 	sal_uInt8*				mpPara;
101 
102 	sal_Bool				ImplGetString( void );
103 	sal_Bool				ImplGetColor( sal_uLong );
104 	sal_Bool				ImplGetScanLine( sal_uLong );
105 	sal_Bool				ImplGetColSub( sal_uInt8* );
106 	sal_Bool				ImplGetColKey( sal_uInt8 );
107 	void				ImplGetRGBHex( sal_uInt8*, sal_uLong );
108 	sal_Bool				ImplGetPara( sal_uLong numb );
109 	sal_Bool				ImplCompare( sal_uInt8*, sal_uInt8*, sal_uLong, sal_uLong nmode = XPMCASENONSENSITIVE );
110 	sal_uLong				ImplGetULONG( sal_uLong nPara );
111 
112 public:
113 						XPMReader( SvStream& rStm );
114 	virtual				~XPMReader();
115 
116 	ReadState			ReadXPM( Graphic& rGraphic );
117 };
118 
119 #endif // _XPMPRIVATE
120 
121 // -------------
122 // - ImportXPM -
123 // -------------
124 
125 sal_Bool ImportXPM( SvStream& rStream, Graphic& rGraphic );
126 
127 #endif // _XPMREAD_HXX
128