Corrected memory.cpp checkpoint bug; added Tex2RTF
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1306 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
227
utils/tex2rtf/src/bmputils.h
Normal file
227
utils/tex2rtf/src/bmputils.h
Normal file
@@ -0,0 +1,227 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: bmputils.h
|
||||
// Purpose: Utilities for manipulating bitmap and metafile images for
|
||||
// the purposes of conversion to RTF
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 7.9.93
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
|
||||
'C', 'D', 'E', 'F' };
|
||||
|
||||
void DecToHex(int dec, char *buf)
|
||||
{
|
||||
int firstDigit = (int)(dec/16.0);
|
||||
int secondDigit = (int)(dec - (firstDigit*16.0));
|
||||
buf[0] = hexArray[firstDigit];
|
||||
buf[1] = hexArray[secondDigit];
|
||||
buf[2] = 0;
|
||||
}
|
||||
|
||||
static unsigned int getshort(FILE *fp)
|
||||
{
|
||||
int c, c1;
|
||||
c = getc(fp); c1 = getc(fp);
|
||||
return ((unsigned int) c) + (((unsigned int) c1) << 8);
|
||||
}
|
||||
|
||||
static unsigned long getint(FILE *fp)
|
||||
{
|
||||
int c, c1, c2, c3;
|
||||
c = getc(fp); c1 = getc(fp); c2 = getc(fp); c3 = getc(fp);
|
||||
return (long)((long) c) +
|
||||
(((long) c1) << 8) +
|
||||
(((long) c2) << 16) +
|
||||
(((long) c3) << 24);
|
||||
}
|
||||
|
||||
bool GetBMPHeader(FILE *fp, int *Width, int *Height, int *Planes, int *BitsPerPixel)
|
||||
{
|
||||
unsigned long bfSize, bfOffBits, biSize, biWidth, biHeight, biPlanes;
|
||||
unsigned long biBitCount, biCompression, biSizeImage, biXPelsPerMeter;
|
||||
unsigned long biYPelsPerMeter, biClrUsed, biClrImportant;
|
||||
|
||||
/* read the file type (first two bytes) */
|
||||
int c = getc(fp); int c1 = getc(fp);
|
||||
if (c!='B' || c1!='M') { return FALSE; }
|
||||
|
||||
bfSize = getint(fp);
|
||||
getshort(fp); /* reserved and ignored */
|
||||
getshort(fp);
|
||||
bfOffBits = getint(fp);
|
||||
|
||||
biSize = getint(fp);
|
||||
biWidth = getint(fp);
|
||||
biHeight = getint(fp);
|
||||
biPlanes = getshort(fp);
|
||||
biBitCount = getshort(fp);
|
||||
biCompression = getint(fp);
|
||||
biSizeImage = getint(fp);
|
||||
biXPelsPerMeter = getint(fp);
|
||||
biYPelsPerMeter = getint(fp);
|
||||
biClrUsed = getint(fp);
|
||||
biClrImportant = getint(fp);
|
||||
|
||||
*Width = (int)biWidth;
|
||||
*Height = (int)biHeight;
|
||||
*Planes = (int)biPlanes;
|
||||
*BitsPerPixel = (int)biBitCount;
|
||||
|
||||
// fseek(fp, bfOffBits, SEEK_SET);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int scanLineWidth = 0;
|
||||
|
||||
bool OutputBitmapHeader(FILE *fd, bool isWinHelp = FALSE)
|
||||
{
|
||||
int Width, Height, Planes, BitsPerPixel;
|
||||
if (!GetBMPHeader(fd, &Width, &Height, &Planes, &BitsPerPixel))
|
||||
return FALSE;
|
||||
|
||||
scanLineWidth = (int)((float)Width/(8.0/(float)BitsPerPixel));
|
||||
if ((float)((int)(scanLineWidth/2.0)) != (float)(scanLineWidth/2.0))
|
||||
scanLineWidth ++;
|
||||
|
||||
int goalW = 15*Width;
|
||||
int goalH = 15*Height;
|
||||
|
||||
TexOutput("{\\pict");
|
||||
if (isWinHelp) TexOutput("\\wbitmap0");
|
||||
else TexOutput("\\dibitmap");
|
||||
|
||||
char buf[50];
|
||||
TexOutput("\\picw"); sprintf(buf, "%d", Width); TexOutput(buf);
|
||||
TexOutput("\\pich"); sprintf(buf, "%d", Height); TexOutput(buf);
|
||||
TexOutput("\\wbmbitspixel"); sprintf(buf, "%d", BitsPerPixel); TexOutput(buf);
|
||||
TexOutput("\\wbmplanes"); sprintf(buf, "%d", Planes); TexOutput(buf);
|
||||
TexOutput("\\wbmwidthbytes"); sprintf(buf, "%d", scanLineWidth); TexOutput(buf);
|
||||
TexOutput("\\picwgoal"); sprintf(buf, "%d", goalW); TexOutput(buf);
|
||||
TexOutput("\\pichgoal"); sprintf(buf, "%d", goalH); TexOutput(buf);
|
||||
TexOutput("\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
bool OutputBitmapData(FILE *fd)
|
||||
{
|
||||
fseek(fd, 14, SEEK_SET);
|
||||
int bytesSoFar = 0;
|
||||
int ch = getc(fd);
|
||||
char hexBuf[3];
|
||||
while (ch != EOF)
|
||||
{
|
||||
if (bytesSoFar == scanLineWidth)
|
||||
{
|
||||
bytesSoFar = 0;
|
||||
TexOutput("\n");
|
||||
}
|
||||
DecToHex(ch, hexBuf);
|
||||
TexOutput(hexBuf);
|
||||
bytesSoFar ++;
|
||||
ch = getc(fd);
|
||||
}
|
||||
TexOutput("\n}\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
struct mfPLACEABLEHEADER {
|
||||
DWORD key;
|
||||
HANDLE hmf;
|
||||
RECT bbox;
|
||||
WORD inch;
|
||||
DWORD reserved;
|
||||
WORD checksum;
|
||||
};
|
||||
|
||||
// Returns size in TWIPS
|
||||
bool GetMetafileHeader(FILE *handle, int *width, int *height)
|
||||
{
|
||||
char buffer[40];
|
||||
mfPLACEABLEHEADER *theHeader = (mfPLACEABLEHEADER *)&buffer;
|
||||
fread((void *)theHeader, sizeof(char), sizeof(mfPLACEABLEHEADER), handle);
|
||||
if (theHeader->key != 0x9AC6CDD7)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
float widthInUnits = (float)theHeader->bbox.right - theHeader->bbox.left;
|
||||
float heightInUnits = (float)theHeader->bbox.bottom - theHeader->bbox.top;
|
||||
*width = (int)((widthInUnits*1440.0)/theHeader->inch);
|
||||
*height = (int)((heightInUnits*1440.0)/theHeader->inch);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool OutputMetafileHeader(FILE *handle, bool isWinHelp, int userWidth, int userHeight)
|
||||
{
|
||||
int Width, Height;
|
||||
if (!GetMetafileHeader(handle, &Width, &Height))
|
||||
return FALSE;
|
||||
|
||||
scanLineWidth = 64;
|
||||
int goalW = Width;
|
||||
int goalH = Height;
|
||||
|
||||
// Scale to user's dimensions if we have the information
|
||||
if (userWidth > 0 && userHeight == 0)
|
||||
{
|
||||
double scaleFactor = ((double)userWidth/(double)goalW);
|
||||
goalW = userWidth;
|
||||
goalH = (int)((goalH * scaleFactor) + 0.5);
|
||||
}
|
||||
else if (userWidth == 0 && userHeight > 0)
|
||||
{
|
||||
double scaleFactor = ((double)userHeight/(double)goalH);
|
||||
goalH = userHeight;
|
||||
goalW = (int)((goalW * scaleFactor) + 0.5);
|
||||
}
|
||||
else if (userWidth > 0 && userHeight > 0)
|
||||
{
|
||||
goalW = userWidth;
|
||||
goalH = userHeight;
|
||||
}
|
||||
|
||||
TexOutput("{\\pict");
|
||||
TexOutput("\\wmetafile8");
|
||||
|
||||
char buf[50];
|
||||
TexOutput("\\picw"); sprintf(buf, "%d", Width); TexOutput(buf);
|
||||
TexOutput("\\pich"); sprintf(buf, "%d", Height); TexOutput(buf);
|
||||
TexOutput("\\picwgoal"); sprintf(buf, "%d", goalW); TexOutput(buf);
|
||||
TexOutput("\\pichgoal"); sprintf(buf, "%d", goalH); TexOutput(buf);
|
||||
TexOutput("\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool OutputMetafileData(FILE *handle)
|
||||
{
|
||||
int bytesSoFar = 0;
|
||||
char hexBuf[3];
|
||||
int ch;
|
||||
do
|
||||
{
|
||||
ch = getc(handle);
|
||||
if (bytesSoFar == scanLineWidth)
|
||||
{
|
||||
bytesSoFar = 0;
|
||||
TexOutput("\n");
|
||||
}
|
||||
if (ch != EOF)
|
||||
{
|
||||
DecToHex(ch, hexBuf);
|
||||
TexOutput(hexBuf);
|
||||
bytesSoFar ++;
|
||||
}
|
||||
} while (ch != EOF);
|
||||
TexOutput("\n}\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
BIN
utils/tex2rtf/src/books.bmp
Normal file
BIN
utils/tex2rtf/src/books.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
10
utils/tex2rtf/src/dos.def
Normal file
10
utils/tex2rtf/src/dos.def
Normal file
@@ -0,0 +1,10 @@
|
||||
NAME TEX2RTF
|
||||
DESCRIPTION 'Tex2Rtf'
|
||||
;
|
||||
EXETYPE DOS
|
||||
;
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE MULTIPLE
|
||||
;
|
||||
HEAPSIZE 1024
|
||||
STACKSIZE 8192
|
2982
utils/tex2rtf/src/htmlutil.cpp
Normal file
2982
utils/tex2rtf/src/htmlutil.cpp
Normal file
File diff suppressed because it is too large
Load Diff
62
utils/tex2rtf/src/makefile.b32
Normal file
62
utils/tex2rtf/src/makefile.b32
Normal file
@@ -0,0 +1,62 @@
|
||||
#
|
||||
# File: makefile.b32
|
||||
# Author: Julian Smart
|
||||
# Created: 1993
|
||||
# Updated:
|
||||
# Copyright:
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds tex2rtf
|
||||
|
||||
# WXWIN and BCCDIR are set by parent make
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
!include $(WXDIR)\src\makeb32.env
|
||||
|
||||
WXLIBDIR = $(WXDIR)\lib
|
||||
WXINC = $(WXDIR)\include\msw
|
||||
WXLIB = $(WXLIBDIR)\wx32.lib
|
||||
LIBS=$(WXLIB) cw32 import32 ole2w32
|
||||
|
||||
TARGET=tex2rtf
|
||||
|
||||
!if "$(FINAL)" == "0"
|
||||
LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib
|
||||
OPT = -Od
|
||||
DEBUG_FLAGS= -v
|
||||
!else
|
||||
LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib
|
||||
OPT = -Od
|
||||
DEBUG_FLAGS =
|
||||
!endif
|
||||
CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG)
|
||||
|
||||
OBJECTS = tex2rtf.obj tex2any.obj texutils.obj rtfutils.obj xlputils.obj htmlutil.obj readshg.obj table.obj
|
||||
|
||||
$(TARGET).exe: $(OBJECTS) $(TARGET).res
|
||||
tlink32 $(LINKFLAGS) @&&!
|
||||
c0w32.obj $(OBJECTS)
|
||||
$(TARGET)
|
||||
nul
|
||||
$(LIBS)
|
||||
$(TARGET).def
|
||||
$(TARGET).res
|
||||
!
|
||||
|
||||
.$(SRCSUFF).obj:
|
||||
bcc32 $(CPPFLAGS) -c {$< }
|
||||
|
||||
.c.obj:
|
||||
bcc32 $(CPPFLAGS) -P- -c {$< }
|
||||
|
||||
$(TARGET).res : $(TARGET).rc $(WXDIR)\include\wx\msw\wx.rc
|
||||
brc32 -r /i$(BCCDIR)\include /i$(WXDIR)\include $(TARGET)
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.rws
|
||||
|
19
utils/tex2rtf/src/makefile.bcc
Normal file
19
utils/tex2rtf/src/makefile.bcc
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# File: makefile.bcc
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
#
|
||||
# Builds a BC++ 16-bit sample
|
||||
|
||||
!if "$(WXWIN)" == ""
|
||||
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
|
||||
!endif
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=tex2rtf
|
||||
OBJECTS = tex2rtf.obj tex2any.obj texutils.obj rtfutils.obj xlputils.obj htmlutil.obj readshg.obj table.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.bcc
|
||||
|
17
utils/tex2rtf/src/makefile.dos
Normal file
17
utils/tex2rtf/src/makefile.dos
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# File: makefile.dos
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
#
|
||||
# Makefile : Builds 16-bit sample, VC++ 1.5
|
||||
# Use FINAL=1 argument to nmake to build final version with no debugging
|
||||
# info
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=tex2rtf
|
||||
OBJECTS = tex2rtf.obj tex2any.obj texutils.obj rtfutils.obj xlputils.obj htmlutil.obj readshg.obj table.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.msc
|
||||
|
61
utils/tex2rtf/src/makefile.g95
Normal file
61
utils/tex2rtf/src/makefile.g95
Normal file
@@ -0,0 +1,61 @@
|
||||
#
|
||||
# File: makefile.g95
|
||||
# Author: Julian Smart
|
||||
# Created: 1996
|
||||
# Updated:
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile for Tex2RTF (GNU-WIN32)
|
||||
|
||||
WXDIR = ../../..
|
||||
|
||||
# All common UNIX compiler flags and options are now in
|
||||
# this central makefile.
|
||||
include $(WXDIR)/src/makeg95.env
|
||||
|
||||
OBJECTS = $(OBJDIR)/tex2rtf.$(OBJSUFF) $(OBJDIR)/texutils.$(OBJSUFF) $(OBJDIR)/tex2any.$(OBJSUFF)\
|
||||
$(OBJDIR)/htmlutil.$(OBJSUFF) $(OBJDIR)/rtfutils.$(OBJSUFF) $(OBJDIR)/xlputils.$(OBJSUFF)\
|
||||
$(OBJDIR)/table.$(OBJSUFF) $(OBJDIR)/readshg.$(OBJSUFF)\
|
||||
$(OBJDIR)/tex2rtf_resources.$(OBJSUFF)
|
||||
|
||||
all: $(OBJDIR) tex2rtf$(GUISUFFIX)$(EXESUFF)
|
||||
|
||||
INC = $(COMPPATHS) -I$(WXDIR)/include/msw -I$(WXDIR)/include/base -I../../wxhelp/src
|
||||
CPPFLAGS = $(XINCLUDE) $(INC) $(OPTIONS) $(GUI) -DDEBUG='$(DEBUG)' $(DEBUGFLAGS) $(WARN) $(OPT)
|
||||
|
||||
$(OBJDIR):
|
||||
mkdir $(OBJDIR)
|
||||
|
||||
tex2rtf$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB)
|
||||
$(CC) $(LDFLAGS) -o tex2rtf$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS)
|
||||
|
||||
$(OBJDIR)/tex2rtf.$(OBJSUFF): tex2rtf.$(SRCSUFF) tex2rtf.h tex2any.h
|
||||
$(CC) -c $(CPPFLAGS) -o $@ tex2rtf.$(SRCSUFF)
|
||||
|
||||
$(OBJDIR)/texutils.$(OBJSUFF): texutils.$(SRCSUFF) tex2rtf.h tex2any.h
|
||||
$(CC) -c $(CPPFLAGS) -o $@ texutils.$(SRCSUFF)
|
||||
|
||||
$(OBJDIR)/tex2any.$(OBJSUFF): tex2any.$(SRCSUFF) tex2any.h
|
||||
$(CC) -c $(CPPFLAGS) -o $@ tex2any.$(SRCSUFF)
|
||||
|
||||
$(OBJDIR)/htmlutil.$(OBJSUFF): htmlutil.$(SRCSUFF) tex2any.h
|
||||
$(CC) -c $(CPPFLAGS) -o $@ htmlutil.$(SRCSUFF)
|
||||
|
||||
$(OBJDIR)/rtfutils.$(OBJSUFF): rtfutils.$(SRCSUFF) tex2any.h
|
||||
$(CC) -c $(CPPFLAGS) -o $@ rtfutils.$(SRCSUFF)
|
||||
|
||||
$(OBJDIR)/xlputils.$(OBJSUFF): xlputils.$(SRCSUFF) tex2any.h
|
||||
$(CC) -c $(CPPFLAGS) -o $@ xlputils.$(SRCSUFF)
|
||||
|
||||
$(OBJDIR)/table.$(OBJSUFF): table.$(SRCSUFF) tex2any.h
|
||||
$(CC) -c $(CPPFLAGS) -o $@ table.$(SRCSUFF)
|
||||
|
||||
$(OBJDIR)/readshg.$(OBJSUFF): readshg.$(SRCSUFF) readshg.h
|
||||
$(CC) -c $(CPPFLAGS) -o $@ readshg.$(SRCSUFF)
|
||||
|
||||
$(OBJDIR)/tex2rtf_resources.o: tex2rtf.rc
|
||||
$(RESCOMP) -i tex2rtf.rc -o $(OBJDIR)/tex2rtf_resources.o $(RESFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) tex2rtf$(GUISUFFIX).exe core *.rsc *.res
|
141
utils/tex2rtf/src/makefile.nt
Normal file
141
utils/tex2rtf/src/makefile.nt
Normal file
@@ -0,0 +1,141 @@
|
||||
#
|
||||
# File: makefile.nt
|
||||
# Author: Julian Smart
|
||||
# Created: 1993
|
||||
# Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds Tex2RTF on Windows Windows 95/NT
|
||||
#
|
||||
!include <..\..\..\src\ntwxwin.mak>
|
||||
|
||||
TEX2RTFDIR = $(WXDIR)\utils\tex2rtf
|
||||
TEX2RTFINC = $(TEX2RTFDIR)\src
|
||||
PROGRAM=tex2rtf
|
||||
DOCDIR=$(WXDIR)\docs
|
||||
LOCALDOCDIR=$(WXDIR)\utils\tex2rtf\docs
|
||||
THISDIR=$(TEX2RTFDIR)\src
|
||||
|
||||
OBJECTS = tex2rtf.obj tex2any.obj texutils.obj rtfutils.obj xlputils.obj htmlutil.obj readshg.obj table.obj
|
||||
|
||||
all: tex2rtf.exe
|
||||
|
||||
wx:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.nt
|
||||
cd $(TEX2RTFDIR)\src
|
||||
|
||||
$(PROGRAM).exe: $(WXLIB) $(OBJECTS) $(PROGRAM).res
|
||||
$(link) @<<
|
||||
-out:$(PROGRAM).exe
|
||||
$(LINKFLAGS)
|
||||
$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res
|
||||
$(LIBS)
|
||||
<<
|
||||
|
||||
$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc
|
||||
$(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc
|
||||
|
||||
tex2any.obj: tex2any.$(SRCSUFF) tex2any.h
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
texutils.obj: texutils.$(SRCSUFF) tex2any.h
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
tex2rtf.obj: tex2rtf.$(SRCSUFF) bmputils.h tex2rtf.h tex2any.h
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
rtfutils.obj: rtfutils.$(SRCSUFF) tex2rtf.h bmputils.h tex2any.h readshg.h table.h
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
table.obj: table.$(SRCSUFF) table.h
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
readshg.obj: readshg.$(SRCSUFF) readshg.h
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
xlputils.obj: xlputils.$(SRCSUFF) tex2rtf.h rtfutils.h tex2any.h
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
htmlutil.obj: htmlutil.$(SRCSUFF) tex2rtf.h tex2any.h table.h
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase *.sbr
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.pdb
|
||||
|
||||
cleanall:
|
||||
erase *.exe *.obj *.pch *.res
|
||||
|
||||
DOCSOURCES=$(LOCALDOCDIR)\tex2rtf.tex
|
||||
|
||||
html: $(DOCDIR)\html\tex2rtf\t2rtf.htm
|
||||
hlp: $(DOCDIR)\winhelp\tex2rtf.hlp
|
||||
pdfrtf: $(DOCDIR)\pdf\tex2rtf.rtf
|
||||
ps: $(WXDIR)\docs\ps\tex2rtf.ps
|
||||
|
||||
$(DOCDIR)\winhelp\tex2rtf.hlp: $(LOCALDOCDIR)\tex2rtf.rtf $(LOCALDOCDIR)\tex2rtf.hpj
|
||||
cd $(LOCALDOCDIR)
|
||||
-erase tex2rtf.ph
|
||||
hc tex2rtf
|
||||
copy tex2rtf.hlp $(DOCDIR)\winhelp\tex2rtf.hlp
|
||||
copy tex2rtf.cnt $(DOCDIR)\winhelp\tex2rtf.cnt
|
||||
cd $(THISDIR)
|
||||
|
||||
$(LOCALDOCDIR)\tex2rtf.rtf: $(DOCSOURCES)
|
||||
cd $(LOCALDOCDIR)
|
||||
-start /w tex2rtf $(LOCALDOCDIR)\tex2rtf.tex $(LOCALDOCDIR)\tex2rtf.rtf -twice -winhelp
|
||||
cd $(THISDIR)
|
||||
|
||||
$(DOCDIR)\pdf\tex2rtf.rtf: $(DOCSOURCES)
|
||||
cd $(LOCALDOCDIR)
|
||||
-copy *.bmp *.wmf $(DOCDIR)\pdf
|
||||
-start /w tex2rtf $(LOCALDOCDIR)\tex2rtf.tex $(DOCDIR)\pdf\tex2rtf.rtf -twice -rtf
|
||||
cd $(THISDIR)
|
||||
|
||||
$(DOCDIR)\html\tex2rtf\t2rtf.htm: $(DOCSOURCES)
|
||||
cd $(LOCALDOCDIR)
|
||||
-mkdir $(DOCDIR)\html\tex2rtf
|
||||
-start /w tex2rtf $(LOCALDOCDIR)\tex2rtf.tex $(DOCDIR)\html\tex2rtf\t2rtf.htm -twice -html
|
||||
-erase $(DOCDIR)\html\tex2rtf\*.con
|
||||
-erase $(DOCDIR)\html\tex2rtf\*.ref
|
||||
cd $(THISDIR)
|
||||
|
||||
$(LOCALDOCDIR)\tex2rtf.dvi: $(DOCSOURCES)
|
||||
cd $(LOCALDOCDIR)
|
||||
-latex tex2rtf
|
||||
-latex tex2rtf
|
||||
-makeindx tex2rtf
|
||||
-bibtex tex2rtf
|
||||
-latex tex2rtf
|
||||
-latex tex2rtf
|
||||
cd $(THISDIR)
|
||||
|
||||
$(WXDIR)\docs\ps\tex2rtf.ps: $(LOCALDOCDIR)\tex2rtf.dvi
|
||||
cd $(LOCALDOCDIR)
|
||||
-dvips32 -o tex2rtf.ps tex2rtf
|
||||
copy tex2rtf.ps $(WXDIR)\docs\ps\tex2rtf.ps
|
||||
cd $(THISDIR)
|
||||
|
||||
|
17
utils/tex2rtf/src/makefile.unx
Normal file
17
utils/tex2rtf/src/makefile.unx
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# File: makefile.unx
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Julian Smart
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile for Tex2RTF (Unix)
|
||||
|
||||
PROGRAM=tex2rtf
|
||||
|
||||
OBJECTS = tex2rtf.o tex2any.o texutils.o rtfutils.o xlputils.o htmlutil.o readshg.o table.o
|
||||
|
||||
include ../../../src/makeprog.env
|
||||
|
14
utils/tex2rtf/src/makefile.wat
Normal file
14
utils/tex2rtf/src/makefile.wat
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Makefile for WATCOM
|
||||
#
|
||||
# 8 Nov 1994
|
||||
#
|
||||
|
||||
WXDIR = $(%WXWIN)
|
||||
|
||||
PROGRAM = tex2rtf
|
||||
OBJECTS = tex2rtf.obj tex2any.obj texutils.obj rtfutils.obj xlputils.obj htmlutil.obj readshg.obj table.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.wat
|
||||
|
||||
|
98
utils/tex2rtf/src/makengui.nt
Normal file
98
utils/tex2rtf/src/makengui.nt
Normal file
@@ -0,0 +1,98 @@
|
||||
# From: Juan Altmayer Pizzorno[SMTP:juan@vms.gmd.de]
|
||||
# Sent: 31 May 1996 10:11
|
||||
# To: J.Smart@ed.ac.uk
|
||||
# Subject: Changes to Tex2RTF
|
||||
#
|
||||
# Hello,
|
||||
#
|
||||
# Recently I've been looking for a way to create and maintain documentation on
|
||||
# multiple platforms out of a single source -- specifically, something that
|
||||
# prints nicely and can be converted to WinHelp and HTML. I liked the approach
|
||||
# of Tex2RTF, so I set off to give it a try... I found out it would crash
|
||||
# when submitted to a certain LaTeX file I created. I wanted to find out why,
|
||||
# so I went on and worked on compiling on my PC: Windows NT 4.0 beta, Visual
|
||||
# C++ 4.1a. Since all I was interested on was the convertion utility, I tried
|
||||
# to make it work without a GUI. It didn't compile immediately, but after a
|
||||
# few small changes it now works like a charm. Unfortunately it doesn't crash
|
||||
# anymore, so I can't tell why it used to... Anyway, I wanted to contribute
|
||||
# the changes back: I'm appending two files to this message, the first a
|
||||
# description of the changes, and the second a quick-and-dirty makefile that
|
||||
# doesn't require wxWindows to run. Please do write to me if you have any
|
||||
# questions or anything.
|
||||
#
|
||||
# Last but not least, it's great that you took the time and wrote Tex2RTF!!
|
||||
#
|
||||
# Quick-and-dirty makefile for building Tex2RTF without the wx
|
||||
# libraries on a Windows NT machine. If you want to use it for
|
||||
# "real", please update the dependancies between object and include
|
||||
# files. Created for Windows NT 4.0 and Visual C++ 4.1.
|
||||
#
|
||||
# Juan Altmayer Pizzorno, May 1996
|
||||
#
|
||||
|
||||
syslibs=kernel32.lib advapi32.lib
|
||||
|
||||
cxxflags=/nologo /MD /W0 /O2 /Zi /D "WIN32" /D "_WIN32" /D "_DEBUG" /c
|
||||
linkflags=$(syslibs) /out:$@ /nologo /debug
|
||||
|
||||
!if "$(PROCESSOR_ARCHITECTURE)" == "x86"
|
||||
cxxflags=$(cxxflags) /G5 # optimize for pentium
|
||||
!endif
|
||||
|
||||
cxx=cl
|
||||
link=link
|
||||
remove=del
|
||||
cxxflags=$(cxxflags) /I wxwin /D wx_msw /D WINVER=0x0400 /D WIN95=0
|
||||
cxxflags=$(cxxflags) /D "NO_GUI"
|
||||
|
||||
objects=tex2any.obj texutils.obj tex2rtf.obj rtfutils.obj table.obj readshg.obj xlputils.obj htmlutil.obj
|
||||
objects=$(objects) wb_hash.obj wb_list.obj wb_obj.obj wb_utils.obj
|
||||
|
||||
all : tex2rtf.exe
|
||||
|
||||
clean :
|
||||
-$(remove) *.obj
|
||||
|
||||
cleanall : clean
|
||||
-$(remove) *.exe *.pdb *.ilk
|
||||
|
||||
tex2rtf.exe : $(objects)
|
||||
$(link) $(linkflags) $(objects)
|
||||
|
||||
tex2any.obj : tex2any.cpp tex2any.h
|
||||
$(cxx) $(cxxflags) tex2any.cpp
|
||||
|
||||
texutils.obj : texutils.cpp tex2any.h
|
||||
$(cxx) $(cxxflags) texutils.cpp
|
||||
|
||||
tex2rtf.obj : tex2rtf.cpp bmputils.h tex2rtf.h tex2any.h
|
||||
$(cxx) $(cxxflags) tex2rtf.cpp
|
||||
|
||||
rtfutils.obj : rtfutils.cpp tex2rtf.h bmputils.h tex2any.h readshg.h table.h
|
||||
$(cxx) $(cxxflags) rtfutils.cpp
|
||||
|
||||
table.obj : table.cpp table.h
|
||||
$(cxx) $(cxxflags) table.cpp
|
||||
|
||||
readshg.obj : readshg.cpp readshg.h
|
||||
$(cxx) $(cxxflags) readshg.cpp
|
||||
|
||||
xlputils.obj : xlputils.cpp tex2rtf.h rtfutils.h tex2any.h
|
||||
$(cxx) $(cxxflags) xlputils.cpp
|
||||
|
||||
htmlutil.obj : htmlutil.cpp tex2rtf.h tex2any.h table.h
|
||||
$(cxx) $(cxxflags) htmlutil.cpp
|
||||
|
||||
wb_hash.obj : wxwin\wb_hash.cpp
|
||||
$(cxx) $(cxxflags) wxwin\wb_hash.cpp
|
||||
|
||||
wb_list.obj : wxwin\wb_list.cpp
|
||||
$(cxx) $(cxxflags) wxwin\wb_list.cpp
|
||||
|
||||
wb_obj.obj : wxwin\wb_obj.cpp
|
||||
$(cxx) $(cxxflags) wxwin\wb_obj.cpp
|
||||
|
||||
wb_utils.obj : wxwin\wb_utils.cpp
|
||||
$(cxx) $(cxxflags) wxwin\wb_utils.cpp
|
||||
|
||||
|
23
utils/tex2rtf/src/maths.cpp
Normal file
23
utils/tex2rtf/src/maths.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* File: maths.cc
|
||||
* Purpose: Beginnings of a maths parser for LaTeX.
|
||||
* NOT IMPLEMENTED. I'm still thinking how best to do this...
|
||||
*
|
||||
*/
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx_prec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include "tex2any.h"
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
163
utils/tex2rtf/src/readshg.cpp
Normal file
163
utils/tex2rtf/src/readshg.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: readshg.cpp
|
||||
// Purpose: Petr Smilauer's .SHG (Segmented Hypergraphics file) reading
|
||||
// code.
|
||||
// Note: .SHG is undocumented (anywhere!) so this is
|
||||
// reverse-engineering
|
||||
// and guesswork at its best.
|
||||
// Author: Petr Smilauer
|
||||
// Modified by:
|
||||
// Created: 01/01/99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Petr Smilauer
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "readshg.h"
|
||||
#include "tex2any.h"
|
||||
|
||||
// Returns the number of hotspots, and the array of hotspots.
|
||||
// E.g.
|
||||
// HotSpots *array;
|
||||
// int n = ParseSHG("thing.shg", &array);
|
||||
|
||||
int ParseSHG( const char* fileName, HotSpot **hotspots)
|
||||
{ FILE* fSHG = fopen( fileName, "rb");
|
||||
long offset;
|
||||
int nHotspots = 0;
|
||||
|
||||
if(fSHG == 0)
|
||||
return 0;
|
||||
nHotspots = 0;
|
||||
//first, look at offset OFF_OFFSET to get another offset :-)
|
||||
fseek( fSHG, OFF_OFFSET, SEEK_SET);
|
||||
offset = 0L; // init whole 4-byte variable
|
||||
fread( &offset, 2, 1, fSHG); // get the offset in first two bytes..
|
||||
if(offset == 0) // if zero, used next DWORD field
|
||||
fread( &offset, 4, 1, fSHG);// this is our offset for very long DIB
|
||||
offset += 9; // don't know hot this delta comes-about
|
||||
if(fseek( fSHG, offset, SEEK_SET) != 0)
|
||||
{
|
||||
fclose( fSHG);
|
||||
return -1; // this is probably because incorrect offset calculation.
|
||||
}
|
||||
fread( &nHotspots, 2, 1, fSHG);
|
||||
|
||||
*hotspots = new HotSpot[nHotspots];
|
||||
|
||||
int nMacroStrings = 0;
|
||||
|
||||
fread( &nMacroStrings, 2, 1, fSHG); // we can ignore the macros, as this is
|
||||
// repeated later, but we need to know how much to skip
|
||||
fseek( fSHG, 2, SEEK_CUR); // skip another 2 bytes I do not understand ;-)
|
||||
|
||||
ShgInfoBlock sib;
|
||||
int i;
|
||||
|
||||
int sizeOf = sizeof( ShgInfoBlock);
|
||||
|
||||
for( i = 0 ; i < nHotspots ; ++i)
|
||||
{
|
||||
fread( &sib, sizeOf, 1, fSHG); // read one hotspot' info
|
||||
// analyse it:
|
||||
(*hotspots)[i].type = (HotspotType)(sib.hotspotType & 0xFB);
|
||||
(*hotspots)[i].left = sib.left;
|
||||
(*hotspots)[i].top = sib.top;
|
||||
(*hotspots)[i].right = sib.left + sib.width;
|
||||
(*hotspots)[i].bottom = sib.top + sib.height;
|
||||
(*hotspots)[i].IsVisible = ((sib.hotspotType & 4) == 0);
|
||||
(*hotspots)[i].szHlpTopic_Macro[0] = '\0';
|
||||
}
|
||||
// we have it...now read-off the macro-string block
|
||||
if(nMacroStrings > 0)
|
||||
fseek( fSHG, nMacroStrings, SEEK_CUR); //nMacroStrings is byte offset...
|
||||
// and, at the last, read through the strings: hotspot-id[ignored], then topic/macro
|
||||
int c;
|
||||
for( i = 0 ; i < nHotspots ; ++i)
|
||||
{
|
||||
while( (c = fgetc( fSHG)) != 0)
|
||||
;
|
||||
// now read it:
|
||||
int j = 0;
|
||||
while( (c = fgetc( fSHG)) != 0)
|
||||
{
|
||||
(*hotspots)[i].szHlpTopic_Macro[j] = c;
|
||||
++j;
|
||||
}
|
||||
(*hotspots)[i].szHlpTopic_Macro[j] = 0;
|
||||
}
|
||||
fclose( fSHG);
|
||||
return nHotspots;
|
||||
}
|
||||
|
||||
|
||||
// Convert Windows .SHG file to HTML map file
|
||||
|
||||
bool SHGToMap(char *filename, char *defaultFile)
|
||||
{
|
||||
// Test the SHG parser
|
||||
HotSpot *hotspots = NULL;
|
||||
int n = ParseSHG(filename, &hotspots);
|
||||
if (n == 0)
|
||||
return FALSE;
|
||||
|
||||
char buf[100];
|
||||
sprintf(buf, "Converting .SHG file to HTML map file: there are %d hotspots in %s.", n, filename);
|
||||
OnInform(buf);
|
||||
|
||||
char outBuf[256];
|
||||
strcpy(outBuf, filename);
|
||||
StripExtension(outBuf);
|
||||
strcat(outBuf, ".map");
|
||||
|
||||
FILE *fd = fopen(outBuf, "w");
|
||||
if (!fd)
|
||||
{
|
||||
OnError("Could not open .map file for writing.");
|
||||
delete[] hotspots;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fprintf(fd, "default %s\n", defaultFile);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
char *refFilename = "??";
|
||||
|
||||
TexRef *texRef = FindReference(hotspots[i].szHlpTopic_Macro);
|
||||
if (texRef)
|
||||
refFilename = texRef->refFile;
|
||||
else
|
||||
{
|
||||
char buf[300];
|
||||
sprintf(buf, "Warning: could not find hotspot reference %s", hotspots[i].szHlpTopic_Macro);
|
||||
OnInform(buf);
|
||||
}
|
||||
fprintf(fd, "rect %s %d %d %d %d\n", refFilename, (int)hotspots[i].left, (int)hotspots[i].top,
|
||||
(int)hotspots[i].right, (int)hotspots[i].bottom);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
|
||||
fclose(fd);
|
||||
|
||||
delete[] hotspots;
|
||||
return TRUE;
|
||||
}
|
||||
|
64
utils/tex2rtf/src/readshg.h
Normal file
64
utils/tex2rtf/src/readshg.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: readshg.h
|
||||
// Purpose: Petr Smilauer's .SHG (Segmented Hypergraphics file) reading
|
||||
// code.
|
||||
// Note: .SHG is undocumented (anywhere!) so this is
|
||||
// reverse-engineering
|
||||
// and guesswork at its best.
|
||||
// Author: Petr Smilauer
|
||||
// Modified by:
|
||||
// Created: 01/01/99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Petr Smilauer
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef readshgh
|
||||
#define readshgh
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef enum { TypePopup = 0xE2, TypeJump = 0xE3, TypeMacro = 0xC8} HotspotType;
|
||||
|
||||
#define NOT_VISIBLE 0x04
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char hotspotType;// combines HotspotType /w NOT_VISIBLE if appropriate
|
||||
unsigned char flag; // NOT_VISIBLE or 0 ??
|
||||
unsigned char skip; // 0, always??
|
||||
unsigned short left,
|
||||
top,
|
||||
width, // left+width/top+height give right/bottom,
|
||||
height; // =>right and bottom edge are not 'included'
|
||||
unsigned char magic[4]; // wonderful numbers: for macros, this seems
|
||||
// (at least first 2 bytes) to represent offset into macro-strings block.
|
||||
} ShgInfoBlock; // whole block is just 15 bytes long. How weird!
|
||||
|
||||
#define OFF_OFFSET 0x20 // this is offset, where WORD (?) lies
|
||||
#define OFFSET_DELTA 9 // we must add this to get real offset from file beginning
|
||||
|
||||
struct HotSpot
|
||||
{
|
||||
HotspotType type;
|
||||
unsigned int left,
|
||||
top,
|
||||
right,
|
||||
bottom;
|
||||
char szHlpTopic_Macro[65];
|
||||
bool IsVisible;
|
||||
};
|
||||
|
||||
// Returns the number of hotspots, and the array of hotspots.
|
||||
// E.g.
|
||||
// HotSpots *array;
|
||||
// int n = ParseSHG("thing.shg", &array);
|
||||
|
||||
extern int ParseSHG( const char* fileName, HotSpot **hotspots);
|
||||
|
||||
// Converts Windows .SHG file to HTML map file
|
||||
extern bool SHGToMap(char *filename, char *defaultFile);
|
||||
|
||||
#endif
|
||||
|
5250
utils/tex2rtf/src/rtfutils.cpp
Normal file
5250
utils/tex2rtf/src/rtfutils.cpp
Normal file
File diff suppressed because it is too large
Load Diff
60
utils/tex2rtf/src/rtfutils.h
Normal file
60
utils/tex2rtf/src/rtfutils.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: rtfutils.h
|
||||
// Purpose: RTF-specific code
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 7.9.93
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Write a suitable RTF header.
|
||||
*
|
||||
*/
|
||||
|
||||
void WriteRTFHeader(FILE *fd);
|
||||
|
||||
/*
|
||||
* Given a TexChunk with a string value, scans through the string
|
||||
* converting Latex-isms into RTF-isms, such as 2 newlines -> \par,
|
||||
* and inserting spaces at the start of lines since in Latex, a newline
|
||||
* implies a space, but not in RTF.
|
||||
*
|
||||
*/
|
||||
|
||||
void ProcessText2RTF(TexChunk *chunk);
|
||||
|
||||
/*
|
||||
* Scan through all chunks starting from the given one,
|
||||
* calling ProcessText2RTF to convert Latex-isms to RTF-isms.
|
||||
* This should be called after Tex2Any has parsed the file,
|
||||
* and before TraverseDocument is called.
|
||||
*
|
||||
*/
|
||||
|
||||
void Text2RTF(TexChunk *chunk);
|
||||
|
||||
|
||||
/*
|
||||
* Keeping track of environments to restore the styles after \pard.
|
||||
* Push strings like "\qc" onto stack.
|
||||
*
|
||||
*/
|
||||
|
||||
void PushEnvironmentStyle(char *style);
|
||||
|
||||
void PopEnvironmentStyle(void);
|
||||
|
||||
// Write out the styles, most recent first.
|
||||
void WriteEnvironmentStyles(void);
|
||||
|
||||
// Called on start/end of macro examination
|
||||
void DefaultRtfOnMacro(char *name, int no_args, bool start);
|
||||
|
||||
// Called on start/end of argument examination
|
||||
bool DefaultRtfOnArgument(char *macro_name, int arg_no, bool start);
|
||||
|
||||
// Reset memory of which levels have 'books' (for WinHelp 4 contents file)
|
||||
void ResetContentsLevels(int level);
|
156
utils/tex2rtf/src/table.cpp
Normal file
156
utils/tex2rtf/src/table.cpp
Normal file
@@ -0,0 +1,156 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: table.cpp
|
||||
// Purpose: Utilities for manipulating tables
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 01/01/99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <wx/hash.h>
|
||||
|
||||
#if wxUSE_IOSTREAMH
|
||||
#include <iostream.h>
|
||||
#include <fstream.h>
|
||||
#else
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include "tex2any.h"
|
||||
#include "table.h"
|
||||
|
||||
ColumnData TableData[40];
|
||||
bool inTabular = FALSE;
|
||||
|
||||
bool startRows = FALSE;
|
||||
bool tableVerticalLineLeft = FALSE;
|
||||
bool tableVerticalLineRight = FALSE;
|
||||
int noColumns = 0; // Current number of columns in table
|
||||
int ruleTop = 0;
|
||||
int ruleBottom = 0;
|
||||
int currentRowNumber = 0;
|
||||
|
||||
/*
|
||||
* Parse table argument
|
||||
*
|
||||
*/
|
||||
|
||||
bool ParseTableArgument(char *value)
|
||||
{
|
||||
noColumns = 0;
|
||||
int i = 0;
|
||||
int len = strlen(value);
|
||||
bool isBorder = FALSE;
|
||||
while (i < len)
|
||||
{
|
||||
int ch = value[i];
|
||||
if (ch == '|')
|
||||
{
|
||||
i ++;
|
||||
isBorder = TRUE;
|
||||
}
|
||||
else if (ch == 'l')
|
||||
{
|
||||
TableData[noColumns].leftBorder = isBorder;
|
||||
TableData[noColumns].rightBorder = FALSE;
|
||||
TableData[noColumns].justification = 'l';
|
||||
TableData[noColumns].width = 2000; // Estimate
|
||||
TableData[noColumns].absWidth = FALSE;
|
||||
// TableData[noColumns].spacing = ??
|
||||
noColumns ++;
|
||||
i ++;
|
||||
isBorder = FALSE;
|
||||
}
|
||||
else if (ch == 'c')
|
||||
{
|
||||
TableData[noColumns].leftBorder = isBorder;
|
||||
TableData[noColumns].rightBorder = FALSE;
|
||||
TableData[noColumns].justification = 'c';
|
||||
TableData[noColumns].width = defaultTableColumnWidth; // Estimate
|
||||
TableData[noColumns].absWidth = FALSE;
|
||||
// TableData[noColumns].spacing = ??
|
||||
noColumns ++;
|
||||
i ++;
|
||||
isBorder = FALSE;
|
||||
}
|
||||
else if (ch == 'r')
|
||||
{
|
||||
TableData[noColumns].leftBorder = isBorder;
|
||||
TableData[noColumns].rightBorder = FALSE;
|
||||
TableData[noColumns].justification = 'r';
|
||||
TableData[noColumns].width = 2000; // Estimate
|
||||
TableData[noColumns].absWidth = FALSE;
|
||||
// TableData[noColumns].spacing = ??
|
||||
noColumns ++;
|
||||
i ++;
|
||||
isBorder = FALSE;
|
||||
}
|
||||
else if (ch == 'p')
|
||||
{
|
||||
i ++;
|
||||
int j = 0;
|
||||
char numberBuf[50];
|
||||
ch = value[i];
|
||||
if (ch == '{')
|
||||
{
|
||||
i++;
|
||||
ch = value[i];
|
||||
}
|
||||
|
||||
while ((i < len) && (isdigit(ch) || ch == '.'))
|
||||
{
|
||||
numberBuf[j] = ch;
|
||||
j ++;
|
||||
i ++;
|
||||
ch = value[i];
|
||||
}
|
||||
// Assume we have 2 characters for units
|
||||
numberBuf[j] = value[i];
|
||||
j ++; i++;
|
||||
numberBuf[j] = value[i];
|
||||
j ++; i++;
|
||||
numberBuf[j] = 0;
|
||||
if (value[i] == '}') i++;
|
||||
|
||||
TableData[noColumns].leftBorder = isBorder;
|
||||
TableData[noColumns].rightBorder = FALSE;
|
||||
TableData[noColumns].justification = 'l';
|
||||
TableData[noColumns].width = 20*ParseUnitArgument(numberBuf);
|
||||
TableData[noColumns].absWidth = TRUE;
|
||||
// TableData[noColumns].spacing = ??
|
||||
noColumns ++;
|
||||
isBorder = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *buf = new char[strlen(value) + 80];
|
||||
sprintf(buf, "Tabular first argument \"%s\" too complex!", value);
|
||||
OnError(buf);
|
||||
delete[] buf;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (isBorder)
|
||||
TableData[noColumns-1].rightBorder = TRUE;
|
||||
return TRUE;
|
||||
}
|
36
utils/tex2rtf/src/table.h
Normal file
36
utils/tex2rtf/src/table.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: table.h
|
||||
// Purpose: Table utilities
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 7.9.93
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Table dimensions
|
||||
*
|
||||
*/
|
||||
|
||||
struct ColumnData
|
||||
{
|
||||
char justification; // l, r, c
|
||||
int width; // -1 or a width in twips
|
||||
int spacing; // Space between columns in twips
|
||||
bool leftBorder;
|
||||
bool rightBorder;
|
||||
bool absWidth; // If FALSE (the default), don't use an absolute width if you can help it.
|
||||
};
|
||||
|
||||
extern ColumnData TableData[];
|
||||
extern bool inTabular;
|
||||
extern bool startRows;
|
||||
extern bool tableVerticalLineLeft;
|
||||
extern bool tableVerticalLineRight;
|
||||
extern int noColumns; // Current number of columns in table
|
||||
extern int ruleTop;
|
||||
extern int ruleBottom;
|
||||
extern int currentRowNumber;
|
||||
extern bool ParseTableArgument(char *value);
|
3482
utils/tex2rtf/src/tex2any.cpp
Normal file
3482
utils/tex2rtf/src/tex2any.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1067
utils/tex2rtf/src/tex2any.h
Normal file
1067
utils/tex2rtf/src/tex2any.h
Normal file
File diff suppressed because it is too large
Load Diff
1077
utils/tex2rtf/src/tex2rtf.cpp
Normal file
1077
utils/tex2rtf/src/tex2rtf.cpp
Normal file
File diff suppressed because it is too large
Load Diff
8
utils/tex2rtf/src/tex2rtf.def
Normal file
8
utils/tex2rtf/src/tex2rtf.def
Normal file
@@ -0,0 +1,8 @@
|
||||
NAME TEX2RTF
|
||||
DESCRIPTION 'Tex2Rtf'
|
||||
EXETYPE WINDOWS
|
||||
STUB 'WINSTUB.EXE'
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE MULTIPLE
|
||||
HEAPSIZE 3000
|
||||
STACKSIZE 20000
|
157
utils/tex2rtf/src/tex2rtf.h
Normal file
157
utils/tex2rtf/src/tex2rtf.h
Normal file
@@ -0,0 +1,157 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tex2any.h
|
||||
// Purpose: tex2RTF conversion header
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 7.9.93
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef NO_GUI
|
||||
// Define a new application type
|
||||
class MyApp: public wxApp
|
||||
{ public:
|
||||
bool OnInit();
|
||||
int OnExit();
|
||||
};
|
||||
|
||||
// Define a new frame type
|
||||
class MyFrame: public wxFrame
|
||||
{ public:
|
||||
wxTextCtrl *textWindow;
|
||||
MyFrame(wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||
void OnMenuCommand(int id);
|
||||
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
void OnExit(wxCommandEvent& event);
|
||||
void OnGo(wxCommandEvent& event);
|
||||
void OnSetInput(wxCommandEvent& event);
|
||||
void OnSetOutput(wxCommandEvent& event);
|
||||
void OnSaveFile(wxCommandEvent& event);
|
||||
void OnViewOutput(wxCommandEvent& event);
|
||||
void OnViewLatex(wxCommandEvent& event);
|
||||
void OnLoadMacros(wxCommandEvent& event);
|
||||
void OnShowMacros(wxCommandEvent& event);
|
||||
void OnModeRTF(wxCommandEvent& event);
|
||||
void OnModeWinHelp(wxCommandEvent& event);
|
||||
void OnModeHTML(wxCommandEvent& event);
|
||||
void OnModeXLP(wxCommandEvent& event);
|
||||
void OnHelp(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include "wx/dde.h"
|
||||
|
||||
class Tex2RTFConnection: public wxDDEConnection
|
||||
{
|
||||
public:
|
||||
Tex2RTFConnection(char *buf, int size);
|
||||
~Tex2RTFConnection(void);
|
||||
bool OnExecute(const wxString& topic, char *data, int size, int format);
|
||||
char *OnRequest(const wxString& topic, const wxString& item, int *size, int format);
|
||||
};
|
||||
|
||||
class Tex2RTFServer: public wxDDEServer
|
||||
{
|
||||
public:
|
||||
wxConnectionBase *OnAcceptConnection(const wxString& topic);
|
||||
};
|
||||
|
||||
#endif // __WXMSW__
|
||||
|
||||
#endif // NO_GUI
|
||||
|
||||
/*
|
||||
* Itemize/enumerate structure: put on a stack for
|
||||
* getting the indentation right
|
||||
*
|
||||
*/
|
||||
|
||||
#define LATEX_ENUMERATE 1
|
||||
#define LATEX_ITEMIZE 2
|
||||
#define LATEX_DESCRIPTION 3
|
||||
#define LATEX_TWOCOL 5
|
||||
#define LATEX_INDENT 6
|
||||
|
||||
class ItemizeStruc: public wxObject
|
||||
{
|
||||
public:
|
||||
int listType;
|
||||
int currentItem;
|
||||
int indentation;
|
||||
int labelIndentation;
|
||||
inline ItemizeStruc(int lType, int indent = 0, int labIndent = 0)
|
||||
{ listType = lType; currentItem = 0;
|
||||
indentation = indent; labelIndentation = labIndent; }
|
||||
};
|
||||
|
||||
// ID for the menu quit command
|
||||
#define TEX_QUIT 1
|
||||
#define TEX_GO 2
|
||||
|
||||
#define TEX_SET_INPUT 3
|
||||
#define TEX_SET_OUTPUT 4
|
||||
|
||||
#define TEX_VIEW_LATEX 5
|
||||
#define TEX_VIEW_OUTPUT 6
|
||||
|
||||
#define TEX_VIEW_CUSTOM_MACROS 7
|
||||
#define TEX_LOAD_CUSTOM_MACROS 8
|
||||
|
||||
#define TEX_MODE_RTF 9
|
||||
#define TEX_MODE_WINHELP 10
|
||||
#define TEX_MODE_HTML 11
|
||||
#define TEX_MODE_XLP 12
|
||||
|
||||
#define TEX_HELP 13
|
||||
#define TEX_ABOUT 14
|
||||
#define TEX_SAVE_FILE 15
|
||||
|
||||
extern TexChunk *currentMember;
|
||||
extern bool startedSections;
|
||||
extern char *contentsString;
|
||||
extern bool suppressNameDecoration;
|
||||
extern wxList itemizeStack;
|
||||
|
||||
extern FILE *Contents;
|
||||
extern FILE *Chapters;
|
||||
extern FILE *Sections;
|
||||
extern FILE *Subsections;
|
||||
extern FILE *Subsubsections;
|
||||
|
||||
extern char *InputFile;
|
||||
extern char *OutputFile;
|
||||
extern char *MacroFile;
|
||||
|
||||
extern char *FileRoot;
|
||||
extern char *ContentsName; // Contents page from last time around
|
||||
extern char *TmpContentsName; // Current contents page
|
||||
extern char *TmpFrameContentsName; // Current frame contents page
|
||||
extern char *WinHelpContentsFileName; // WinHelp .cnt file
|
||||
extern char *RefName; // Reference file name
|
||||
extern char *bulletFile;
|
||||
|
||||
#ifndef NO_GUI
|
||||
void ChooseOutputFile(bool force = FALSE);
|
||||
void ChooseInputFile(bool force = FALSE);
|
||||
#endif
|
||||
|
||||
void RTFOnMacro(int macroId, int no_args, bool start);
|
||||
bool RTFOnArgument(int macroId, int arg_no, bool start);
|
||||
|
||||
void HTMLOnMacro(int macroId, int no_args, bool start);
|
||||
bool HTMLOnArgument(int macroId, int arg_no, bool start);
|
||||
|
||||
void XLPOnMacro(int macroId, int no_args, bool start);
|
||||
bool XLPOnArgument(int macroId, int arg_no, bool start);
|
||||
|
||||
bool RTFGo(void);
|
||||
bool HTMLGo(void);
|
||||
bool XLPGo(void);
|
||||
|
||||
#define ltHARDY 10000
|
BIN
utils/tex2rtf/src/tex2rtf.ico
Normal file
BIN
utils/tex2rtf/src/tex2rtf.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 766 B |
17
utils/tex2rtf/src/tex2rtf.ini
Normal file
17
utils/tex2rtf/src/tex2rtf.ini
Normal file
@@ -0,0 +1,17 @@
|
||||
runTwice = yes
|
||||
titleFontSize = 12
|
||||
authorFontSize = 10
|
||||
chapterFontSize = 12
|
||||
sectionFontSize = 12
|
||||
subsectionFontSize = 12
|
||||
; RTF only
|
||||
headerRule = yes
|
||||
footerRule = yes
|
||||
useHeadingStyles = yes
|
||||
listItemIndent=40
|
||||
truncateFilenames = FALSE
|
||||
winHelpContents = yes
|
||||
winHelpVersion = 4 ; 3 for Windows 3.x, 4 for Windows 95
|
||||
generateHPJ = true
|
||||
\overview [2] { \image{}{books.bmp}\helpref{#1}{#2}}
|
||||
; Some stuff
|
4
utils/tex2rtf/src/tex2rtf.rc
Normal file
4
utils/tex2rtf/src/tex2rtf.rc
Normal file
@@ -0,0 +1,4 @@
|
||||
aaa ICON "tex2rtf.ico"
|
||||
tex2rtf ICON "tex2rtf.ico"
|
||||
#include "wx/msw/wx.rc"
|
||||
|
42
utils/tex2rtf/src/tex2rtf.xpm
Normal file
42
utils/tex2rtf/src/tex2rtf.xpm
Normal file
@@ -0,0 +1,42 @@
|
||||
/* XPM */
|
||||
static char *tex2rtf_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 32 32 3 1",
|
||||
/* colors */
|
||||
". c #000000",
|
||||
"# c #c0c0c0",
|
||||
"a c #ffffff",
|
||||
/* pixels */
|
||||
"aaaaaaaaaaaaaaaaaaaaa.aaaaaaa..a",
|
||||
"aaaaaaaaaaaaaaaaaaaaa..aaaaa.aa.",
|
||||
"aaaaaaaaaaaaaaaaaaaa#.a.aaaa.aa.",
|
||||
"aaaaaaaaaaaaaaaaaaaa#..a.aaaaa.a",
|
||||
"aaaaaaaaaaaaaaaaaaaa#...a.aaaa.a",
|
||||
"aaaaaaaaaaaaaaaaa........a.aaaaa",
|
||||
"aaaaaaaaaaaaa....aaaa.....a.aa.a",
|
||||
"aaaaaaaaaaa..aaaa..........a.aaa",
|
||||
"aaaaaaaaa..aa...............a.aa",
|
||||
"aaaaaaaa.aa..................a.a",
|
||||
"aaaaaaa.a.....................#a",
|
||||
"aaaaaa.a.....................###",
|
||||
"aaaaa.a.....................###a",
|
||||
"aaaa.......................###aa",
|
||||
"aaaa..............###.....###aaa",
|
||||
"aaa...........#######....###aaaa",
|
||||
"aaa.........#####aaa#...###aaaaa",
|
||||
"aa........###aaaaaaaa..a##aaaaaa",
|
||||
"aa.......##aaaaaaaaaa.aa#aaaaaaa",
|
||||
"aa......##aaaaaaaaaaaaaaaaaaaaaa",
|
||||
"a......##aaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"a.....##aaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"a.....#aaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"a....#aaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"a....aaaa.aaaaaaaaaaaaaaaaaaaaaa",
|
||||
"a......a.a.a...aaa..a..aaaaaaaaa",
|
||||
"a...a.aa...aa.aaaaa.a.aaaaaaaaaa",
|
||||
"a...a.a.aaa.a.....aa.aaaaaaaaaaa",
|
||||
"aa.aa.aa.aaaa.a.aaa.a.aaaaaaaaaa",
|
||||
"aa.a.....aaaa.a..a..a..aaaaaaaaa",
|
||||
"aaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaa",
|
||||
"aaaaaaaaaaaaaa....aaaaaaaaaaaaaa"
|
||||
};
|
1635
utils/tex2rtf/src/texutils.cpp
Normal file
1635
utils/tex2rtf/src/texutils.cpp
Normal file
File diff suppressed because it is too large
Load Diff
30
utils/tex2rtf/src/wxhlpblk.h
Normal file
30
utils/tex2rtf/src/wxhlpblk.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* File: wxhlpblk.h
|
||||
* Purpose: Text blocks used in wxHelp
|
||||
* Author: Julian Smart
|
||||
* Created: 1993
|
||||
* Updated:
|
||||
* Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||
*/
|
||||
|
||||
/* sccsid[] = "%W% %G%" */
|
||||
|
||||
#ifndef wxhlpblkh
|
||||
#define wxhlpblkh
|
||||
|
||||
#define hyBLOCK_NORMAL 1
|
||||
#define hyBLOCK_RED 2
|
||||
#define hyBLOCK_BLUE 3
|
||||
#define hyBLOCK_GREEN 4
|
||||
#define hyBLOCK_LARGE_HEADING 5
|
||||
#define hyBLOCK_SMALL_HEADING 6
|
||||
#define hyBLOCK_ITALIC 7
|
||||
#define hyBLOCK_BOLD 8
|
||||
#define hyBLOCK_INVISIBLE_SECTION 9
|
||||
#define hyBLOCK_LARGE_VISIBLE_SECTION 10
|
||||
#define hyBLOCK_SMALL_VISIBLE_SECTION 11
|
||||
#define hyBLOCK_SMALL_TEXT 12
|
||||
#define hyBLOCK_RED_ITALIC 13
|
||||
#define hyBLOCK_TELETYPE 14
|
||||
|
||||
#endif // wxhlpblkh
|
1219
utils/tex2rtf/src/xlputils.cpp
Normal file
1219
utils/tex2rtf/src/xlputils.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user