• R/O
  • SSH

wp2latex: Commit

WP2LaTeX sources.


Commit MetaInfo

Revision49350998eaae7fe63151043e4bd30d0959a46e32 (tree)
Zeit2022-05-29 19:23:25
AutorFojtik
CommiterFojtik

Log Message

Attempt to convert WorldTransform in EMF.

Ändern Zusammenfassung

Diff

diff -r fadb556dc9cb -r 49350998eaae trunk/sources.cc/atoms/include/struct.h
--- a/trunk/sources.cc/atoms/include/struct.h Tue May 24 21:48:45 2022 +0200
+++ b/trunk/sources.cc/atoms/include/struct.h Sun May 29 12:23:25 2022 +0200
@@ -28,12 +28,13 @@
2828
2929 #ifdef EXPAND_OPS
3030 #ifdef LO_ENDIAN
31- #define RdWORD_LoEnd(num,f) fread((num),1,2,f)
32- #define RdDWORD_LoEnd(num,f) fread((num),1,4,f)
33- #define RdQWORD_LoEnd(num,f) fread((num),1,8,f)
31+ #define RdWORD_LoEnd(pnum,f) fread((pnum),1,2,f)
32+ #define RdDWORD_LoEnd(pnum,f) fread((pnum),1,4,f)
33+ #define RdQWORD_LoEnd(pnum,f) fread((pnum),1,8,f)
3434 #define WrWORD_LoEnd(num,f) fwrite((&num),1,2,f)
3535 #define WrDWORD_LoEnd(num,f) fwrite((&num),1,4,f)
3636 #define WrQWORD_LoEnd(num,f) fwrite((&num),1,8,f)
37+ #define RdFLOAT_LoEnd(num,f) fread((pnum),1,4,f)
3738 #endif
3839 #ifdef HI_ENDIAN
3940 #define RdWORD_HiEnd(num,f) fread((num),1,2,f)
@@ -86,6 +87,10 @@
8687 #endif
8788 #endif
8889
90+#ifndef RdFLOAT_LoEnd
91+ int RdFLOAT_LoEnd(float *flt, FILE *f);
92+#endif
93+
8994 WORD fil_sreadU16(const BYTE *in);
9095 DWORD fil_sreadU32(const BYTE *in);
9196
diff -r fadb556dc9cb -r 49350998eaae trunk/sources.cc/atoms/struct.c
--- a/trunk/sources.cc/atoms/struct.c Tue May 24 21:48:45 2022 +0200
+++ b/trunk/sources.cc/atoms/struct.c Sun May 29 12:23:25 2022 +0200
@@ -159,7 +159,7 @@
159159 /* Read a double word from binary file in a HighEndian Format
160160 * parameters: FILE *f : binary input file
161161 * return: DWORD *num : readed double word */
162-int RdDWORD_HiEnd( DWORD *num, FILE *f )
162+int RdDWORD_HiEnd(DWORD *num, FILE *f)
163163 {
164164 #ifdef LO_ENDIAN
165165 const int i = fread(num,1,4,f);
@@ -186,7 +186,7 @@
186186 /* Read a quad word from binary file in a HighEndian Format
187187 * parameters: FILE *f : binary input file
188188 * return: DWORD *num : readed double word */
189-int RdQWORD_HiEnd(QWORD_ *num, FILE *f )
189+int RdQWORD_HiEnd(QWORD_ *num, FILE *f)
190190 {
191191 #ifdef LO_ENDIAN
192192 const int i = fread(num,1,8,f);
@@ -261,7 +261,7 @@
261261 /* Write a word to the binary file in a HighEndian Format
262262 * parameters: FILE *f : binary input file
263263 * WORD num : word to be written */
264-int WrWORD_HiEnd( WORD num, FILE *f )
264+int WrWORD_HiEnd(WORD num, FILE *f)
265265 {
266266 #ifdef HI_ENDIAN
267267 return(fwrite(&num,1,2,f));
@@ -279,7 +279,7 @@
279279 /* Write a double word to the binary file in a HiEndian Format
280280 * parameters: FILE *f : binary input file
281281 * DWORD num : double word to be written */
282-int WrDWORD_HiEnd(DWORD num, FILE *f )
282+int WrDWORD_HiEnd(DWORD num, FILE *f)
283283 {
284284 #ifdef HI_ENDIAN
285285 return(fwrite(&num,1,4,f));
@@ -305,7 +305,7 @@
305305 /* Write a quad word to the binary file in a HiEndian Format
306306 * parameters: FILE *f : binary input file
307307 * DWORD num : double word to be written */
308-int WrQWORD_HiEnd(QWORD_ num, FILE *f )
308+int WrQWORD_HiEnd(QWORD_ num, FILE *f)
309309 {
310310 #ifdef HI_ENDIAN
311311 return(fwrite(&num,1,8,f));
@@ -334,7 +334,7 @@
334334 /* Write a quad word to the binary file in a LowEndian Format
335335 * parameters: FILE *f : binary input file
336336 * DWORD num : double word to be written */
337-int WrQWORD_LoEnd(QWORD_ num, FILE *f )
337+int WrQWORD_LoEnd(QWORD_ num, FILE *f)
338338 {
339339 #ifdef LO_ENDIAN
340340 return(fwrite(&num,1,8,f));
@@ -360,7 +360,7 @@
360360
361361
362362 /** Read a WORD from byte stream. */
363-WORD fil_sreadU16 (const BYTE *in)
363+WORD fil_sreadU16(const BYTE *in)
364364 {
365365 #ifdef LO_ENDIAN
366366 return *(WORD *)in;
@@ -372,7 +372,7 @@
372372
373373
374374 /** Read a DWORD from byte stream. */
375-DWORD fil_sreadU32 (const BYTE *in)
375+DWORD fil_sreadU32(const BYTE *in)
376376 {
377377 #ifdef LO_ENDIAN
378378 return *(DWORD *)in;
@@ -498,3 +498,28 @@
498498 return(writed);
499499 }
500500
501+
502+#ifndef RdFLOAT_LoEnd
503+/* Read a double word from binary file in a LowEndian Format into a current endian.
504+ * parameters: FILE *f : binary input file
505+ * return: DWORD *num : readed double word */
506+int RdFLOAT_LoEnd(float *pnum, FILE *f)
507+{
508+#ifdef LO_ENDIAN
509+ return(fread(pnum,1,4,f));
510+#endif
511+#ifdef HI_ENDIAN
512+const int i = fread(pnum,1,4,f);
513+ BYTESWAP_uint32(*pnum);
514+return i;
515+#endif
516+#if !defined(LO_ENDIAN) && !defined(HI_ENDIAN)
517+unsigned char b;
518+ if(!fread( &b, 1,1,f)) return 0; *(DWORD*)pnum=(DWORD)b;
519+ if(!fread( &b, 1,1,f)) return 1; *(DWORD*)pnum+=(DWORD)b * 256l;
520+ if(!fread( &b, 1,1,f)) return 2; *(DWORD*)pnum+=(DWORD)b * 256l * 256l;
521+ if(!fread( &b, 1,1,f)) return 3; *(DWORD*)pnum+=(DWORD)b * 256l * 256l * 256l;
522+return 4;
523+#endif
524+}
525+#endif
diff -r fadb556dc9cb -r 49350998eaae trunk/sources.cc/pass1wmf.cc
--- a/trunk/sources.cc/pass1wmf.cc Tue May 24 21:48:45 2022 +0200
+++ b/trunk/sources.cc/pass1wmf.cc Sun May 29 12:23:25 2022 +0200
@@ -2211,12 +2211,35 @@
22112211 } EMFRECORD;
22122212
22132213
2214+/** Functor class for EMF world transform. */
2215+class TransformEMF: public AbstractTransformXY
2216+{
2217+public:
2218+ float M11, M12, M21, M22;
2219+ float Dx, Dy;
2220+
2221+ TransformEMF(void) {M11=M22=1; M21=M12=Dx=Dy=0;}
2222+
2223+ virtual void ApplyTransform(float &x, float &y) const;
2224+
2225+ float TopPBottom;
2226+};
2227+
2228+
2229+void TransformEMF::ApplyTransform(float &x, float &y) const
2230+{
2231+ const float xNew = M11*x + M21*y + Dx;
2232+ y = M12*x + M22*y + Dy;
2233+ x = xNew;
2234+}
2235+
22142236
22152237 class TconvertedPass1_EMF: public TconvertedPass1_xMF
22162238 {
22172239 public:
22182240 SDWORD PositionX, PositionY;
22192241 CpTranslator *ConvertUnicode;
2242+ TransformEMF WorldTx;
22202243
22212244 TconvertedPass1_EMF(void) {PositionX = PositionY = 0;}
22222245
@@ -2231,6 +2254,8 @@
22312254 void parse_ExtCreatePen(void);
22322255 void parse_ExtTextOutW(VectorList &VectList);
22332256 void parse_LineTo(VectorList &VectList);
2257+ void parse_ModifyWorldTransform(void);
2258+ void parse_SetWorldTransform(void);
22342259 void parse_MoveToEX(void);
22352260 void parse_PolyBezier16(VectorList &VectList);
22362261 void parse_Polygon16(VectorList &VectList);
@@ -2804,6 +2829,7 @@
28042829 VectorEllipse *pVecEllipse = new VectorEllipse(Scale*BottomRect, Scale*TopRect, Scale*RightRect, Scale*LeftRect);
28052830 pVecEllipse->AttribFromPSS(PSS);
28062831
2832+ pVecEllipse->Transform(WorldTx);
28072833 VectList.AddObject(pVecEllipse);
28082834
28092835 strcpy(ObjType,ObjName+1);
@@ -2884,8 +2910,11 @@
28842910
28852911 if(pTextCont->isEmpty())
28862912 delete pTextCont;
2887- else
2888- VectList.AddObject(pTextCont);
2913+ else
2914+ {
2915+ pTextCont->Transform(WorldTx);
2916+ VectList.AddObject(pTextCont);
2917+ }
28892918 pTextCont = NULL;
28902919
28912920 /*
@@ -2970,6 +2999,72 @@
29702999 }
29713000
29723001
3002+void TconvertedPass1_EMF::parse_ModifyWorldTransform(void)
3003+{
3004+#ifdef DEBUG
3005+ fprintf(log,"\n#TconvertedPass1_EMF::parse_ModifyWorldTransform() ");fflush(log);
3006+#endif
3007+static const char ObjName[] = "!MODIFYWORLDTRANSFORM";
3008+float M11b, M12b, M21b, M22b;
3009+float Dxb, Dyb;
3010+
3011+
3012+ if(EmfRec.Size < 8+6*4)
3013+ {
3014+ strcpy(ObjType,ObjName);
3015+ return;
3016+ }
3017+
3018+ RdFLOAT_LoEnd(&M11b,wpd);
3019+ RdFLOAT_LoEnd(&M12b,wpd);
3020+ RdFLOAT_LoEnd(&M21b,wpd);
3021+ RdFLOAT_LoEnd(&M22b,wpd);
3022+ RdFLOAT_LoEnd(&Dxb,wpd);
3023+ RdFLOAT_LoEnd(&Dyb,wpd);
3024+
3025+ const float NewM11 = M11b*WorldTx.M11 + M21b*WorldTx.M12;
3026+ const float NewM21 = M11b*WorldTx.M21 + M21b*WorldTx.M22;
3027+ const float NewDx = M11b*WorldTx.Dx + M21b*WorldTx.Dy + Dxb;
3028+
3029+ const float NewM12 = M12b*WorldTx.M11 + M22b*WorldTx.M12;
3030+ const float NewM22 = M12b*WorldTx.M21 + M22b*WorldTx.M22;
3031+ const float NewDy = M12b*WorldTx.Dx + M22b*WorldTx.Dy + Dyb;
3032+
3033+ WorldTx.M11 = NewM11;
3034+ WorldTx.M21 = NewM21;
3035+ WorldTx.M12 = NewM12;
3036+ WorldTx.M22 = NewM22;
3037+ WorldTx.Dx = NewDx;
3038+ WorldTx.Dy = NewDy;
3039+
3040+ strcpy(ObjType,ObjName+1);
3041+}
3042+
3043+
3044+void TconvertedPass1_EMF::parse_SetWorldTransform(void)
3045+{
3046+#ifdef DEBUG
3047+ fprintf(log,"\n#TconvertedPass1_EMF::parse_SetWorldTransform() ");fflush(log);
3048+#endif
3049+static const char ObjName[] = "!SETWORLDTRANSFORM";
3050+
3051+ if(EmfRec.Size < 8+6*4)
3052+ {
3053+ strcpy(ObjType,ObjName);
3054+ return;
3055+ }
3056+
3057+ RdFLOAT_LoEnd(&WorldTx.M11,wpd);
3058+ RdFLOAT_LoEnd(&WorldTx.M12,wpd);
3059+ RdFLOAT_LoEnd(&WorldTx.M21,wpd);
3060+ RdFLOAT_LoEnd(&WorldTx.M22,wpd);
3061+ RdFLOAT_LoEnd(&WorldTx.Dx,wpd);
3062+ RdFLOAT_LoEnd(&WorldTx.Dy,wpd);
3063+
3064+ strcpy(ObjType,ObjName+1);
3065+}
3066+
3067+
29733068 void TconvertedPass1_EMF::parse_MoveToEX(void)
29743069 {
29753070 #ifdef DEBUG
@@ -3017,6 +3112,7 @@
30173112
30183113 memcpy(&pVecLine->LineColor, &PSS.LineColor, sizeof(PSS.LineColor));
30193114 pVecLine->Close = false;
3115+ pVecLine->Transform(WorldTx);
30203116 VectList.AddObject(pVecLine); pVecLine=NULL;
30213117
30223118 sprintf(ObjType,"%s(%d;%d)", ObjName+1, LineX, LineY);
@@ -3066,6 +3162,7 @@
30663162 Points = NULL;
30673163 pVecPoly->AttribFromPSS(PSS);
30683164 pVecPoly->Close = true;
3165+ pVecPoly->Transform(WorldTx);
30693166 VectList.AddObject(pVecPoly); pVecPoly=NULL;
30703167
30713168 strcpy(ObjType,ObjName+1);
@@ -3105,6 +3202,7 @@
31053202
31063203 pVecPoly->AttribFromPSS(PSS);
31073204 pVecPoly->Close = false;
3205+ pVecPoly->Transform(WorldTx);
31083206 VectList.AddObject(pVecPoly); pVecPoly=NULL;
31093207
31103208 strcpy(ObjType,ObjName+1);
@@ -3149,6 +3247,7 @@
31493247
31503248 pVecCurve->AttribFromPSS(PSS);
31513249 pVecCurve->Close = false;
3250+ pVecCurve->Transform(WorldTx);
31523251 VectList.AddObject(pVecCurve); pVecCurve=NULL;
31533252
31543253 strcpy(ObjType,ObjName+1);
@@ -3210,6 +3309,7 @@
32103309 Points = NULL;
32113310 pVecPoly->AttribFromPSS(PSS);
32123311 pVecPoly->Close = true;
3312+ pVecPoly->Transform(WorldTx);
32133313 VectList.AddObject(pVecPoly); pVecPoly=NULL;
32143314 }
32153315
@@ -3259,6 +3359,7 @@
32593359
32603360 pVecPoly->AttribFromPSS(PSS);
32613361 pVecPoly->Close = false;
3362+ pVecPoly->Transform(WorldTx);
32623363 VectList.AddObject(pVecPoly); pVecPoly=NULL;
32633364
32643365 strcpy(ObjType,ObjName+1);
@@ -3294,8 +3395,9 @@
32943395 const float Scale = GetScale2PSU((TMapMode)MapMode);
32953396
32963397 VectorRectangle *pVectRec = new VectorRectangle(Scale*BottomRect, Scale*TopRect, Scale*LeftRect, Scale*RightRect);
3297- pVectRec->AttribFromPSS(PSS);
3298- VectList.AddObject(pVectRec);
3398+ pVectRec->AttribFromPSS(PSS);
3399+ pVectRec->Transform(WorldTx);
3400+ VectList.AddObject(pVectRec);
32993401
33003402 strcpy(ObjType,ObjName+1);
33013403 return;
@@ -3540,6 +3642,7 @@
35403642 pVectRec->FillColor = PixColor;
35413643 pVectRec->BrushStyle = FILL_SOLID;
35423644 pVectRec->LineStyle = 0;
3645+ pVectRec->Transform(WorldTx);
35433646 VectList.AddObject(pVectRec);
35443647
35453648 strcpy(ObjType,ObjName+1);
@@ -3804,8 +3907,8 @@
38043907 case EMR_SCALEWINDOWEXTEX: strcpy(ObjType,"!SCALEWINDOWEXTEX"); break; // 0x00000020
38053908 case EMR_SAVEDC: strcpy(ObjType,"!SAVEDC"); break; // 0x00000021
38063909 case EMR_RESTOREDC: strcpy(ObjType,"!RESTOREDC"); break; // 0x00000022
3807- case EMR_SETWORLDTRANSFORM: strcpy(ObjType,"!SETWORLDTRANSFORM"); break; // 0x00000023
3808- case EMR_MODIFYWORLDTRANSFORM: strcpy(ObjType,"!MODIFYWORLDTRANSFORM"); break; // 0x00000024
3910+ case EMR_SETWORLDTRANSFORM: parse_SetWorldTransform(); break; // 0x00000023
3911+ case EMR_MODIFYWORLDTRANSFORM: parse_ModifyWorldTransform(); break; // 0x00000024
38093912 case EMR_SELECTOBJECT: parse_SelectObject(); break; // 0x00000025
38103913 case EMR_CREATEPEN: parse_CreatePen(); break; // 0x00000026
38113914 case EMR_CREATEBRUSHINDIRECT: parse_CreateBrushIndirect(); break; // 0x00000027
diff -r fadb556dc9cb -r 49350998eaae trunk/sources.cc/wp2latex.h
--- a/trunk/sources.cc/wp2latex.h Tue May 24 21:48:45 2022 +0200
+++ b/trunk/sources.cc/wp2latex.h Sun May 29 12:23:25 2022 +0200
@@ -17,8 +17,8 @@
1717
1818 #define LineLength 80 /* Split lines after more than LineLength charcters */
1919
20-#define VersionWP2L "3.107"
21-#define VersionDate "24 May 2022" /* day (space) month (space) full year */
20+#define VersionWP2L "3.pre108"
21+#define VersionDate "29 May 2022" /* day (space) month (space) full year */
2222
2323
2424 /* Constants for a flag InputPS */
Show on old repository browser