xref: /aoo42x/main/svtools/source/inc/xpmread.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _XPMREAD_HXX
29 #define _XPMREAD_HXX
30 
31 #ifndef _BITMAP_HXX
32 #include <vcl/bitmap.hxx>
33 #endif
34 
35 #ifdef _XPMPRIVATE
36 
37 #define XPMTEMPBUFSIZE		0x00008000
38 #define XPMSTRINGBUF		0x00008000
39 
40 #define XPMIDENTIFIER		0x00000001			// mnIdentifier includes on of the six phases
41 #define XPMDEFINITION		0x00000002			// the XPM format consists of
42 #define XPMVALUES			0x00000003
43 #define XPMCOLORS			0x00000004
44 #define XPMPIXELS			0x00000005
45 #define XPMEXTENSIONS		0x00000006
46 #define XPMENDEXT			0x00000007
47 
48 
49 #define XPMREMARK			0x00000001			// defines used by mnStatus
50 #define XPMDOUBLE			0x00000002
51 #define XPMSTRING			0x00000004
52 #define XPMFINISHED			0x00000008
53 
54 #define XPMCASESENSITIVE	0x00000001
55 #define XPMCASENONSENSITIVE 0x00000002
56 
57 // ---------
58 // - Enums -
59 // ---------
60 
61 enum ReadState
62 {
63 	XPMREAD_OK,
64 	XPMREAD_ERROR,
65 	XPMREAD_NEED_MORE
66 };
67 
68 // -------------
69 // - XPMReader -
70 // -------------
71 
72 class BitmapWriteAccess;
73 class Graphic;
74 
75 class XPMReader : public GraphicReader
76 {
77 private:
78 
79 	SvStream&			mrIStm;
80 	Bitmap				maBmp;
81 	BitmapWriteAccess*	mpAcc;
82 	Bitmap				maMaskBmp;
83 	BitmapWriteAccess*	mpMaskAcc;
84 	long				mnLastPos;
85 
86 	sal_uLong				mnWidth;
87 	sal_uLong				mnHeight;
88 	sal_uLong				mnColors;
89 	sal_uLong				mnCpp;								// characters per pix
90 	sal_Bool				mbTransparent;
91 	sal_Bool				mbStatus;
92 	sal_uLong				mnStatus;
93 	sal_uLong				mnIdentifier;
94 	sal_uInt8				mcThisByte;
95 	sal_uInt8				mcLastByte;
96 	sal_uLong				mnTempAvail;
97 	sal_uInt8*				mpTempBuf;
98 	sal_uInt8*				mpTempPtr;
99 	sal_uInt8*				mpFastColorTable;
100 	sal_uInt8*				mpColMap;
101 	sal_uLong				mnStringSize;
102 	sal_uInt8*				mpStringBuf;
103 	sal_uLong				mnParaSize;
104 	sal_uInt8*				mpPara;
105 
106 	sal_Bool				ImplGetString( void );
107 	sal_Bool				ImplGetColor( sal_uLong );
108 	sal_Bool				ImplGetScanLine( sal_uLong );
109 	sal_Bool				ImplGetColSub( sal_uInt8* );
110 	sal_Bool				ImplGetColKey( sal_uInt8 );
111 	void				ImplGetRGBHex( sal_uInt8*, sal_uLong );
112 	sal_Bool				ImplGetPara( sal_uLong numb );
113 	sal_Bool				ImplCompare( sal_uInt8*, sal_uInt8*, sal_uLong, sal_uLong nmode = XPMCASENONSENSITIVE );
114 	sal_uLong				ImplGetULONG( sal_uLong nPara );
115 
116 public:
117 						XPMReader( SvStream& rStm );
118 	virtual				~XPMReader();
119 
120 	ReadState			ReadXPM( Graphic& rGraphic );
121 };
122 
123 #endif // _XPMPRIVATE
124 
125 // -------------
126 // - ImportXPM -
127 // -------------
128 
129 sal_Bool ImportXPM( SvStream& rStream, Graphic& rGraphic );
130 
131 #endif // _XPMREAD_HXX
132