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 CGM_HXX_
25 #define CGM_HXX_
26 
27 #include <com/sun/star/frame/XModel.hpp>
28 
29 // ---------------------------------------------------------------
30 #undef CGM_USER_BREAKPOINT
31 
32 #define CGM_IMPORT_CGM		0x00000001
33 
34 #define CGM_EXPORT_IMPRESS	0x00000100
35 #define CGM_EXPORT_META		0x00000200
36 //#define CGM_EXPORT_COMMENT	0x00000400
37 
38 // ---------------------------------------------------------------
39 
40 #include <tools/solar.h>
41 #include <rtl/ustring.hxx>
42 #include <tools/list.hxx>
43 #include "cgmtypes.hxx"
44 
45 // ---------------------------------------------------------------
46 
47 class	List;
48 class	Bundle;
49 class	Graphic;
50 class	SvStream;
51 class	CGMChart;
52 class	CGMBitmap;
53 class	CGMOutAct;
54 class	CGMElements;
55 class	BitmapColor;
56 class	GDIMetaFile;
57 class	VirtualDevice;
58 class	CGMBitmapDescriptor;
59 
60 class CGM
61 {
62 		friend class CGMChart;
63 		friend class CGMBitmap;
64 		friend class CGMElements;
65 		friend class CGMOutAct;
66 		friend class CGMImpressOutAct;
67 
68 		double				mnOutdx;				// Ausgabe Groesse in 1/100TH mm
69 		double				mnOutdy;				// auf das gemappt wird
70 		double				mnVDCXadd;
71 		double				mnVDCYadd;
72 		double				mnVDCXmul;
73 		double				mnVDCYmul;
74 		double				mnVDCdx;
75 		double				mnVDCdy;
76 		double				mnXFraction;
77 		double				mnYFraction;
78 		sal_Bool				mbAngReverse;			// AngularDirection
79 
80 		Graphic*			mpGraphic;				// ifdef CGM_EXPORT_META
81 		SvStream*			mpCommentOut;			// ifdef CGM_EXPORT_COMMENT
82 
83 		sal_Bool				mbStatus;
84 		sal_Bool				mbMetaFile;
85 		sal_Bool				mbIsFinished;
86 		sal_Bool				mbPicture;
87 		sal_Bool				mbPictureBody;
88 		sal_Bool				mbFigure;
89 		sal_Bool				mbFirstOutPut;
90 		sal_uInt32				mnAct4PostReset;
91 		CGMBitmap*			mpBitmapInUse;
92 		CGMChart*			mpChart;				// if sal_True->"SHWSLIDEREC"
93 													//	otherwise "BEGINPIC" commands
94 													// controlls page inserting
95 		CGMElements*		pElement;
96 		CGMElements*		pCopyOfE;
97 		CGMOutAct*			mpOutAct;
98 		List				maDefRepList;
99 		List				maDefRepSizeList;
100 
101 		sal_uInt8*				mpSource;		// source buffer that is not increased
102 											// ( instead use mnParaCount to index )
103 		sal_uInt32				mnParaSize;		// actual parameter size which has been done so far
104 		sal_uInt32				mnActCount;		// increased by each action
105 		sal_uInt8*				mpBuf;			// source stream operation -> then this is allocated for
106 											//							  the temp input buffer
107 
108 		sal_uInt32				mnMode;			// source description
109 		sal_uInt32				mnEscape;		//
110 		sal_uInt32				mnElementClass;	//
111 		sal_uInt32				mnElementID;	//
112 		sal_uInt32				mnElementSize;	// full parameter size for the latest action
113 
114 		void				ImplCGMInit();
115 		sal_uInt32			ImplGetUI16( sal_uInt32 nAlign = 0 );
116 		sal_uInt8			ImplGetByte( sal_uInt32 nSource, sal_uInt32 nPrecision );
117 		long				ImplGetI( sal_uInt32 nPrecision );
118 		sal_uInt32			ImplGetUI( sal_uInt32 nPrecision );
119 		void				ImplGetSwitch4( sal_uInt8* pSource, sal_uInt8* pDest );
120 		void				ImplGetSwitch8( sal_uInt8* pSource, sal_uInt8* pDest );
121 		double				ImplGetFloat( RealPrecision, sal_uInt32 nRealSize );
122 		sal_uInt32			ImplGetBitmapColor( sal_Bool bDirectColor = sal_False );
123 		void				ImplSetMapMode();
124 		void				ImplMapDouble( double& );
125 		void				ImplMapX( double& );
126 		void				ImplMapY( double& );
127 		void				ImplMapPoint( FloatPoint& );
128 		inline double		ImplGetIY();
129 		inline double		ImplGetFY();
130 		inline double		ImplGetIX();
131 		inline double		ImplGetFX();
132 		sal_uInt32				ImplGetPointSize();
133 		void				ImplGetPoint( FloatPoint& rFloatPoint, sal_Bool bMap = sal_False );
134 		void				ImplGetRectangle( FloatRect&, sal_Bool bMap = sal_False );
135 		void				ImplGetRectangleNS( FloatRect& );
136 		void				ImplGetVector( double* );
137 		double				ImplGetOrientation( FloatPoint& rCenter, FloatPoint& rPoint );
138 		void				ImplSwitchStartEndAngle( double& rStartAngle, double& rEndAngle );
139 		sal_Bool				ImplGetEllipse( FloatPoint& rCenter, FloatPoint& rRadius, double& rOrientation );
140 
141 		void				ImplDefaultReplacement();
142 		void 				ImplDoClass();
143 		void				ImplDoClass0();
144 		void				ImplDoClass1();
145 		void				ImplDoClass2();
146 		void				ImplDoClass3();
147 		void				ImplDoClass4();
148 		void				ImplDoClass5();
149 		void				ImplDoClass6();
150 		void				ImplDoClass7();
151 		void				ImplDoClass8();
152 		void				ImplDoClass9();
153 		void				ImplDoClass15();
154 
155 	public:
156 
157 							~CGM();
158 
159 							CGM( sal_uInt32 nMode, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & rModel );
160 #ifdef CGM_EXPORT_META
161 		VirtualDevice*		mpVirDev;
162 		GDIMetaFile* 		mpGDIMetaFile;
163 #endif
164 		void				ImplComment( sal_uInt32, const char* );
165 		sal_uInt32				GetBackGroundColor();
IsValid()166 		sal_Bool				IsValid() { return mbStatus; };
IsFinished()167 		sal_Bool				IsFinished() { return mbIsFinished; };
168 		sal_Bool				Write( SvStream& rIStm );
169 
170 		friend SvStream& operator>>( SvStream& rOStm, CGM& rCGM );
171 
172 };
173 #endif
174 
175