• R/O
  • SSH

wp2latex: Commit

WP2LaTeX sources.


Commit MetaInfo

Revision6d09b5fe105812fe7466fd5af91481415036469f (tree)
Zeit2022-08-20 19:13:59
AutorFojtik
CommiterFojtik

Log Message

Added reference counting for vector attributes.

Ändern Zusammenfassung

Diff

diff -r 5a41d15760ae -r 6d09b5fe1058 trunk/sources.cc/atoms/std_str.cc
--- a/trunk/sources.cc/atoms/std_str.cc Tue Jul 05 11:13:31 2022 +0200
+++ b/trunk/sources.cc/atoms/std_str.cc Sat Aug 20 12:13:59 2022 +0200
@@ -12,6 +12,7 @@
1212 #ifndef __Safe_strchr
1313
1414 #ifdef __Strict_Const_Procs
15+
1516 const char *StrChr(const char *s, int c)
1617 {
1718 if(s==NULL) return(NULL);
diff -r 5a41d15760ae -r 6d09b5fe1058 trunk/sources.cc/images/vecimage.h
--- a/trunk/sources.cc/images/vecimage.h Tue Jul 05 11:13:31 2022 +0200
+++ b/trunk/sources.cc/images/vecimage.h Sat Aug 20 12:13:59 2022 +0200
@@ -166,7 +166,14 @@
166166
167167 class VectorAttribute
168168 {
169-public:
169+protected:
170+ mutable int RefCounter;
171+
172+public:
173+ void AddRef(void) {RefCounter++;}
174+ void Release(void) {if(--RefCounter<=0) delete this;}
175+
176+ VectorAttribute() {RefCounter=1;}
170177 virtual ~VectorAttribute() {}
171178 virtual void prepExport(PS_State *PSS) const = 0;
172179 virtual int getAttribType(void) const {return ATTR_NONE;};
diff -r 5a41d15760ae -r 6d09b5fe1058 trunk/sources.cc/pass1c45.cc
--- a/trunk/sources.cc/pass1c45.cc Tue Jul 05 11:13:31 2022 +0200
+++ b/trunk/sources.cc/pass1c45.cc Sat Aug 20 12:13:59 2022 +0200
@@ -79,8 +79,8 @@
7979 WORD pidx; /* index down password */
8080 BYTE xmask; /* XOR mask */
8181 DWORD len;
82-DWORD pos=ftell(Encrypted);
83-DWORD fsize=filesize(Encrypted);
82+DWORD pos = ftell(Encrypted);
83+DWORD fsize = filesize(Encrypted);
8484
8585 if(ErrorFile==NULL) ErrorFile=stderr;
8686 if((buf=(char *)malloc(4096))==NULL) return;
@@ -89,14 +89,14 @@
8989 pidx = 0; /* start of password */
9090 xmask = length(PassWord)+1; /* start at password length+1 */
9191
92- if (Verbosing >= 1) printf(_("\nDecrypting ...\n\n"));
92+ if(Verbosing >= 1) printf(_("\nDecrypting ...\n\n"));
9393
94- while( pos<fsize )
94+ while(pos<fsize)
9595 {
96- if( fsize-pos > 4096 ) len = 4096;
97- else len = fsize-pos;
96+ if(fsize-pos > 4096) len = 4096;
97+ else len = fsize-pos;
9898
99- if( fread( buf, 1, len, Encrypted ) !=len )
99+ if(fread( buf, 1, len, Encrypted ) !=len)
100100 {
101101 fprintf(ErrorFile,_("\nError: Unexpected end of the input file."));
102102 break;
@@ -108,9 +108,9 @@
108108 if( pidx == length(PassWord) ) pidx = 0;
109109 }
110110
111- if( Decrypted )
111+ if(Decrypted)
112112 {
113- if( fwrite( buf, 1, len, Decrypted ) !=len )
113+ if(fwrite( buf, 1, len, Decrypted ) !=len)
114114 {
115115 fprintf(ErrorFile,_("\nError: Couldn't write %lu bytes to the temporary file.\n"), (long unsigned)len);
116116 break;
@@ -132,19 +132,19 @@
132132 WORD encryption;
133133 string temp_filename;
134134 DWORD DocumentStart; /* position in file */
135-FILE *DecryptedFile=NULL;
135+FILE *DecryptedFile = NULL;
136136 BYTE SmallBuf[16];
137137 TconvertedPass1 *cqPass1;
138138 int RetVal=0;
139139
140- cqPass1=GetConverter("WP5.x");
140+ cqPass1 = GetConverter("WP5.x");
141141 if(cqPass1==NULL)
142142 {
143143 RunError(0x202,"WP5.x"); /* unsupported module wp5 */
144144 return(-1);
145145 }
146146
147- DocumentStart=ftell(wpd);
147+ DocumentStart = ftell(wpd);
148148 fseek(wpd,12,SEEK_SET); //check for encrypted documents
149149
150150 RdWORD_HiEnd(&encryption, wpd);
@@ -218,7 +218,7 @@
218218 TconvertedPass1 *cqPass1;
219219 int RetVal=0;
220220
221- cqPass1=GetConverter("WP3.x");
221+ cqPass1 = GetConverter("WP3.x");
222222 if(cqPass1==NULL)
223223 {
224224 RunError(0x202,"WP3.x"); /* unsupported module wp3 */
diff -r 5a41d15760ae -r 6d09b5fe1058 trunk/sources.cc/pass1wmf.cc
--- a/trunk/sources.cc/pass1wmf.cc Tue Jul 05 11:13:31 2022 +0200
+++ b/trunk/sources.cc/pass1wmf.cc Sat Aug 20 12:13:59 2022 +0200
@@ -173,7 +173,8 @@
173173 VectorAttribute **Attributes;
174174 unsigned Count;
175175
176- ObjectTable() {Count=0; Attributes=NULL;}
176+ ObjectTable() {Count=0; Attributes=NULL;}
177+ ObjectTable(ObjectTable &OT);
177178 ~ObjectTable();
178179
179180 void AddObject(VectorAttribute *NewAttr);
@@ -182,6 +183,25 @@
182183 };
183184
184185
186+ObjectTable::ObjectTable(ObjectTable &OT)
187+{
188+ if(OT.Count==0 || OT.Attributes==NULL)
189+ {
190+ Attributes = NULL;
191+AllocationError:
192+ Count = 0;
193+ return;
194+ }
195+ Attributes = (VectorAttribute**)malloc(OT.Count*sizeof(VectorAttribute*));
196+ if(Attributes==NULL) goto AllocationError;
197+ for(Count=0; Count<OT.Count; Count++)
198+ {
199+ Attributes[Count] = OT.Attributes[Count];
200+ if(Attributes[Count]!=NULL) Attributes[Count]->AddRef();
201+ }
202+}
203+
204+
185205 ObjectTable::~ObjectTable()
186206 {
187207 if(Count>0)
@@ -190,7 +210,7 @@
190210 {
191211 for(unsigned i=0; i<Count; i++)
192212 {
193- delete Attributes[i];
213+ Attributes[i]->Release();
194214 Attributes[i] = NULL;
195215 }
196216 free(Attributes);
@@ -210,7 +230,7 @@
210230 Attributes = (VectorAttribute**)malloc(sizeof(VectorAttribute*));
211231 if(Attributes==NULL)
212232 {
213- delete NewAttr;
233+ NewAttr->Release();
214234 return;
215235 }
216236 Attributes[0] = NewAttr;
@@ -239,7 +259,7 @@
239259 void ObjectTable::DeleteObject(unsigned ObjectIndex)
240260 {
241261 if(ObjectIndex>=Count || Attributes==NULL) return;
242- delete Attributes[ObjectIndex];
262+ Attributes[ObjectIndex]->Release();
243263 Attributes[ObjectIndex] = NULL;
244264 }
245265
@@ -2267,6 +2287,7 @@
22672287 void parse_PolyPolygon16(VectorList &VectList);
22682288 void parse_PolyPolyLine16(VectorList &VectList);
22692289 void parse_Rectangle(VectorList &VectList);
2290+ void parse_SaveDC(void);
22702291 void parse_SelectObject(void);
22712292 void parse_SelectPalette(void);
22722293 void parse_SetBkColor(void);
@@ -3714,6 +3735,23 @@
37143735 }
37153736
37163737
3738+void TconvertedPass1_EMF::parse_SaveDC(void)
3739+{
3740+#ifdef DEBUG
3741+ fprintf(log,"\n#TconvertedPass1_EMF::parse_SaveDC() ");fflush(log);
3742+#endif
3743+static const char ObjName[] = "!SAVEDC";
3744+
3745+ if(EmfRec.Size < 8)
3746+ {
3747+ strcpy(ObjType,ObjName);
3748+ return;
3749+ }
3750+
3751+ strcpy(ObjType,ObjName);
3752+}
3753+
3754+
37173755 void TconvertedPass1_EMF::parse_SetTextColor(void)
37183756 {
37193757 #ifdef DEBUG
@@ -3942,7 +3980,7 @@
39423980 case EMR_INTERSECTCLIPRECT: strcpy(ObjType,"!INTERSECTCLIPRECT"); break; // 0x0000001E
39433981 case EMR_SCALEVIEWPORTEXTEX: strcpy(ObjType,"!SCALEVIEWPORTEXTEX"); break; // 0x0000001F
39443982 case EMR_SCALEWINDOWEXTEX: strcpy(ObjType,"!SCALEWINDOWEXTEX"); break; // 0x00000020
3945- case EMR_SAVEDC: strcpy(ObjType,"!SAVEDC"); break; // 0x00000021
3983+ case EMR_SAVEDC: parse_SaveDC(); break; // 0x00000021
39463984 case EMR_RESTOREDC: strcpy(ObjType,"!RESTOREDC"); break; // 0x00000022
39473985 case EMR_SETWORLDTRANSFORM: parse_SetWorldTransform(); break; // 0x00000023
39483986 case EMR_MODIFYWORLDTRANSFORM: parse_ModifyWorldTransform(); break; // 0x00000024
Show on old repository browser