Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
0dc42208
Commit
0dc42208
authored
Jan 30, 2004
by
Mike McCormack
Committed by
Alexandre Julliard
Jan 30, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove global variables from the richedit control.
parent
04279d18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
229 additions
and
121 deletions
+229
-121
reader.c
dlls/richedit/reader.c
+0
-0
richedit.c
dlls/richedit/richedit.c
+0
-0
rtf.h
dlls/richedit/rtf.h
+170
-64
text-writer.c
dlls/richedit/text-writer.c
+59
-57
No files found.
dlls/richedit/reader.c
View file @
0dc42208
This diff is collapsed.
Click to expand it.
dlls/richedit/richedit.c
View file @
0dc42208
This diff is collapsed.
Click to expand it.
dlls/richedit/rtf.h
View file @
0dc42208
...
...
@@ -10,8 +10,6 @@
#include "winuser.h"
#include "richedit.h"
void
RTFSetEditStream
(
EDITSTREAM
*
es
);
/* The following defines are automatically generated. Do not edit. */
...
...
@@ -420,21 +418,6 @@ void RTFSetEditStream(EDITSTREAM *es);
*/
/*
* Information pertaining to last token read by RTFToken. The
* text is exactly as it occurs in the input file, e.g., "\{"
* will be found in rtfTextBuf as "\{", even though it means "{".
* These variables are also set when styles are reprocessed.
*/
extern
char
*
rtfTextBuf
;
/* text of token */
extern
int
rtfTextLen
;
/* length of token in rtfTextBuf */
extern
int
rtfClass
;
/* token class */
extern
int
rtfMajor
;
/* token major number */
extern
int
rtfMinor
;
/* token minor number */
extern
int
rtfParam
;
/* control symbol parameter */
extern
int
rtfFormat
;
/* either SF_RTF or SF_TEXT */
# ifdef THINK_C
# define rtfNoParam (-32768)
/* 16-bit max. neg. value */
# endif
...
...
@@ -442,8 +425,8 @@ extern int rtfFormat; /* either SF_RTF or SF_TEXT */
# define rtfNoParam (-1000000)
# endif
extern
long
rtfLineNum
;
/* input line number */
extern
int
rtfLinePos
;
/* input line position */
/*
* For some reason, the no-style number is 222
...
...
@@ -1391,46 +1374,167 @@ struct RTFStyleElt
};
typedef
void
(
*
RTFFuncPtr
)
();
/* generic function pointer */
#include "charlist.h"
/*
* Return pointer to new element of type t, or NULL
* if no memory available.
*/
# define New(t) ((t *) RTFAlloc ((int) sizeof (t)))
/* maximum number of character values representable in a byte */
# define charSetSize 256
/* charset stack size */
# define maxCSStack 10
struct
_RTF_Info
;
typedef
struct
_RTF_Info
RTF_Info
;
typedef
void
(
*
RTFFuncPtr
)
(
RTF_Info
*
);
/* generic function pointer */
struct
_RTF_Info
{
/*
* Public variables (listed in rtf.h)
*/
/*
* Information pertaining to last token read by RTFToken. The
* text is exactly as it occurs in the input file, e.g., "\{"
* will be found in rtfTextBuf as "\{", even though it means "{".
* These variables are also set when styles are reprocessed.
*/
int
rtfClass
;
int
rtfMajor
;
int
rtfMinor
;
int
rtfParam
;
int
rtfFormat
;
char
*
rtfTextBuf
;
int
rtfTextLen
;
long
rtfLineNum
;
int
rtfLinePos
;
/*
* Private stuff
*/
int
pushedChar
;
/* pushback char if read too far */
int
pushedClass
;
/* pushed token info for RTFUngetToken() */
int
pushedMajor
;
int
pushedMinor
;
int
pushedParam
;
char
*
pushedTextBuf
;
int
prevChar
;
int
bumpLine
;
RTFFont
*
fontList
;
/* these lists MUST be */
RTFColor
*
colorList
;
/* initialized to NULL */
RTFStyle
*
styleList
;
char
*
inputName
;
char
*
outputName
;
EDITSTREAM
editstream
;
CHARLIST
inputCharList
;
/*
* These arrays are used to map RTF input character values onto the standard
* character names represented by the values. Input character values are
* used as indices into the arrays to produce standard character codes.
*/
char
*
genCharSetFile
;
int
genCharCode
[
charSetSize
];
/* general */
int
haveGenCharSet
;
char
*
symCharSetFile
;
int
symCharCode
[
charSetSize
];
/* symbol */
int
haveSymCharSet
;
int
curCharSet
;
int
*
curCharCode
;
/*
* By default, the reader is configured to handle charset mapping invisibly,
* including reading the charset files and switching charset maps as necessary
* for Symbol font.
*/
int
autoCharSetFlags
;
/*
* Stack for keeping track of charset map on group begin/end. This is
* necessary because group termination reverts the font to the previous
* value, which may implicitly change it.
*/
int
csStack
[
maxCSStack
];
int
csTop
;
RTFFuncPtr
ccb
[
rtfMaxClass
];
/* class callbacks */
RTFFuncPtr
dcb
[
rtfMaxDestination
];
/* destination callbacks */
RTFFuncPtr
readHook
;
RTFFuncPtr
panicProc
;
FILE
*
(
*
libFileOpen
)
();
char
*
outMap
[
rtfSC_MaxChar
];
CHARLIST
charlist
;
};
/*
* Public RTF reader routines
*/
void
RTFInit
();
void
RTFSetInputName
();
char
*
RTFGetInputName
();
void
RTFSetOutputName
();
char
*
RTFGetOutputName
();
void
RTFSetClassCallback
();
RTFFuncPtr
RTFGetClassCallback
();
void
RTFSetDestinationCallback
();
RTFFuncPtr
RTFGetDestinationCallback
();
void
RTFRead
();
int
RTFGetToken
();
/* writer should rarely need this */
void
RTFUngetToken
();
int
RTFPeekToken
();
void
RTFSetToken
();
void
RTFSetReadHook
();
RTFFuncPtr
RTFGetReadHook
();
void
RTFRouteToken
();
void
RTFSkipGroup
();
void
RTFExpandStyle
();
int
RTFCheckCM
();
int
RTFCheckCMM
();
int
RTFCheckMM
();
RTFFont
*
RTFGetFont
();
RTFColor
*
RTFGetColor
();
RTFStyle
*
RTFGetStyle
();
void
RTFInit
(
RTF_Info
*
);
void
RTFSetInputName
(
RTF_Info
*
,
char
*
);
char
*
RTFGetInputName
(
RTF_Info
*
);
void
RTFSetOutputName
(
RTF_Info
*
,
char
*
);
char
*
RTFGetOutputName
(
RTF_Info
*
);
void
RTFSetClassCallback
(
RTF_Info
*
,
int
,
RTFFuncPtr
);
RTFFuncPtr
RTFGetClassCallback
(
RTF_Info
*
,
int
);
void
RTFSetDestinationCallback
(
RTF_Info
*
,
int
,
RTFFuncPtr
);
RTFFuncPtr
RTFGetDestinationCallback
(
RTF_Info
*
,
int
);
void
RTFRead
(
RTF_Info
*
);
int
RTFGetToken
(
RTF_Info
*
);
/* writer should rarely need this */
void
RTFUngetToken
(
RTF_Info
*
);
int
RTFPeekToken
(
RTF_Info
*
);
void
RTFSetToken
(
RTF_Info
*
,
int
,
int
,
int
,
int
,
char
*
);
void
RTFSetReadHook
(
RTF_Info
*
,
RTFFuncPtr
);
RTFFuncPtr
RTFGetReadHook
(
RTF_Info
*
);
void
RTFRouteToken
(
RTF_Info
*
);
void
RTFSkipGroup
(
RTF_Info
*
);
void
RTFExpandStyle
(
RTF_Info
*
,
int
);
int
RTFCheckCM
(
RTF_Info
*
,
int
,
int
);
int
RTFCheckCMM
(
RTF_Info
*
,
int
,
int
,
int
);
int
RTFCheckMM
(
RTF_Info
*
,
int
,
int
);
RTFFont
*
RTFGetFont
(
RTF_Info
*
,
int
);
RTFColor
*
RTFGetColor
(
RTF_Info
*
,
int
);
RTFStyle
*
RTFGetStyle
(
RTF_Info
*
,
int
);
# define RTFAlloc(size) _RTFAlloc ((int) size)
char
*
_RTFAlloc
();
char
*
RTFStrSave
();
void
RTFFree
();
int
RTFCharToHex
(
char
);
int
RTFHexToChar
();
void
RTFSetMsgProc
();
void
RTFSetPanicProc
();
char
*
_RTFAlloc
(
int
);
char
*
RTFStrSave
(
char
*
);
void
RTFFree
(
char
*
);
int
RTFCharToHex
(
char
);
int
RTFHexToChar
(
int
);
void
RTFSetMsgProc
(
RTFFuncPtr
);
void
RTFSetPanicProc
(
RTF_Info
*
,
RTFFuncPtr
);
/*
* The following messing around is used to allow RTFMsg() and RTFPanic()
...
...
@@ -1439,20 +1543,22 @@ void RTFSetPanicProc ();
* stdarg.h.
*/
void
RTFMsg
(
char
*
fmt
,
...);
void
RTFPanic
(
char
*
fmt
,
...);
void
RTFMsg
(
RTF_Info
*
,
char
*
fmt
,
...);
void
RTFPanic
(
RTF_Info
*
,
char
*
fmt
,
...);
int
RTFReadOutputMap
();
int
RTFReadCharSetMap
();
void
RTFSetCharSetMap
();
int
RTFStdCharCode
();
char
*
RTFStdCharName
();
int
RTFMapChar
();
int
RTFGetCharSet
();
void
RTFSetCharSet
();
int
RTFReadOutputMap
(
RTF_Info
*
,
char
*
[],
int
);
int
RTFReadCharSetMap
(
RTF_Info
*
,
int
);
void
RTFSetCharSetMap
(
RTF_Info
*
,
char
*
,
int
);
int
RTFStdCharCode
(
RTF_Info
*
,
char
*
);
char
*
RTFStdCharName
(
RTF_Info
*
,
int
);
int
RTFMapChar
(
RTF_Info
*
,
int
);
int
RTFGetCharSet
(
RTF_Info
*
);
void
RTFSetCharSet
(
RTF_Info
*
,
int
);
/*char *RTFGetLibPrefix();*/
void
RTFSetOpenLibFileProc
();
FILE
*
RTFOpenLibFile
();
void
RTFSetOpenLibFileProc
(
RTF_Info
*
,
FILE
*
(
*
)());
FILE
*
RTFOpenLibFile
(
RTF_Info
*
,
char
*
,
char
*
);
void
RTFSetEditStream
(
RTF_Info
*
,
EDITSTREAM
*
es
);
#endif
dlls/richedit/text-writer.c
View file @
0dc42208
...
...
@@ -45,20 +45,22 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
richedit
);
static
void
TextClass
();
static
void
ControlClass
();
static
void
Destination
();
static
void
SpecialChar
();
static
void
PutStdChar
();
static
void
PutLitChar
();
static
void
PutLitStr
();
static
void
TextClass
(
RTF_Info
*
info
);
static
void
ControlClass
(
RTF_Info
*
info
);
static
void
Destination
(
RTF_Info
*
info
);
static
void
SpecialChar
(
RTF_Info
*
info
);
static
void
PutStdChar
(
RTF_Info
*
info
,
int
stdCode
);
static
void
PutLitChar
(
RTF_Info
*
info
,
int
c
);
static
void
PutLitStr
(
RTF_Info
*
info
,
char
*
s
);
#if 0
static char *outMap[rtfSC_MaxChar];
static CHARLIST charlist = {0, NULL, NULL};
#endif
int
RTFToBuffer
(
char
*
pBuffer
,
int
nBufferSize
);
int
RTFToBuffer
(
char
*
pBuffer
,
int
nBufferSize
)
/*int RTFToBuffer(char* pBuffer, int nBufferSize); */
int
RTFToBuffer
(
RTF_Info
*
info
,
char
*
pBuffer
,
int
nBufferSize
)
{
/* check if the buffer is big enough to hold all characters */
...
...
@@ -66,13 +68,13 @@ int RTFToBuffer(char* pBuffer, int nBufferSize)
TRACE
(
"
\n
"
);
if
(
nBufferSize
<
charlist
.
nCount
+
1
)
{
return
charlist
.
nCount
+
CHARLIST_CountChar
(
&
charlist
,
'\n'
)
+
1
;
if
(
nBufferSize
<
info
->
charlist
.
nCount
+
1
)
{
return
info
->
charlist
.
nCount
+
CHARLIST_CountChar
(
&
info
->
charlist
,
'\n'
)
+
1
;
}
while
(
charlist
.
nCount
)
while
(
info
->
charlist
.
nCount
)
{
*
pBuffer
=
CHARLIST_Dequeue
(
&
charlist
);
*
pBuffer
=
CHARLIST_Dequeue
(
&
info
->
charlist
);
if
(
*
pBuffer
==
'\n'
)
{
*
pBuffer
=
'\r'
;
...
...
@@ -92,19 +94,19 @@ int RTFToBuffer(char* pBuffer, int nBufferSize)
*/
void
WriterInit
()
WriterInit
(
RTF_Info
*
info
)
{
RTFReadOutputMap
(
outMap
,
1
);
RTFReadOutputMap
(
info
,
info
->
outMap
,
1
);
}
int
BeginFile
()
BeginFile
(
RTF_Info
*
info
)
{
/* install class callbacks */
RTFSetClassCallback
(
rtfText
,
TextClass
);
RTFSetClassCallback
(
rtfControl
,
ControlClass
);
RTFSetClassCallback
(
info
,
rtfText
,
TextClass
);
RTFSetClassCallback
(
info
,
rtfControl
,
ControlClass
);
return
(
1
);
}
...
...
@@ -119,38 +121,38 @@ BeginFile ()
*/
static
void
TextClass
()
TextClass
(
RTF_Info
*
info
)
{
char
buf
[
rtfBufSiz
];
TRACE
(
"
\n
"
);
if
(
rtfFormat
==
SF_TEXT
)
PutLitChar
(
rtfMajor
);
else
if
(
rtfMinor
!=
rtfSC_nothing
)
PutStdChar
(
rtfMinor
);
if
(
info
->
rtfFormat
==
SF_TEXT
)
PutLitChar
(
info
,
info
->
rtfMajor
);
else
if
(
info
->
rtfMinor
!=
rtfSC_nothing
)
PutStdChar
(
info
,
info
->
rtfMinor
);
else
{
if
(
rtfMajor
<
128
)
/* in ASCII range */
sprintf
(
buf
,
"[[%c]]"
,
rtfMajor
);
if
(
info
->
rtfMajor
<
128
)
/* in ASCII range */
sprintf
(
buf
,
"[[%c]]"
,
info
->
rtfMajor
);
else
sprintf
(
buf
,
"[[
\\
'%02x]]"
,
rtfMajor
);
PutLitStr
(
buf
);
sprintf
(
buf
,
"[[
\\
'%02x]]"
,
info
->
rtfMajor
);
PutLitStr
(
info
,
buf
);
}
}
static
void
ControlClass
()
ControlClass
(
RTF_Info
*
info
)
{
TRACE
(
"
\n
"
);
switch
(
rtfMajor
)
switch
(
info
->
rtfMajor
)
{
case
rtfDestination
:
Destination
();
Destination
(
info
);
break
;
case
rtfSpecialChar
:
SpecialChar
();
SpecialChar
(
info
);
break
;
}
}
...
...
@@ -163,12 +165,12 @@ ControlClass ()
*/
static
void
Destination
()
Destination
(
RTF_Info
*
info
)
{
TRACE
(
"
\n
"
);
switch
(
rtfMinor
)
switch
(
info
->
rtfMinor
)
{
case
rtfPict
:
case
rtfFNContSep
:
...
...
@@ -183,7 +185,7 @@ Destination ()
case
rtfIComment
:
case
rtfIVersion
:
case
rtfIDoccomm
:
RTFSkipGroup
();
RTFSkipGroup
(
info
);
break
;
}
}
...
...
@@ -195,52 +197,52 @@ Destination ()
* can be controlled by the text-map file.
*/
void
SpecialChar
()
void
SpecialChar
(
RTF_Info
*
info
)
{
TRACE
(
"
\n
"
);
switch
(
rtfMinor
)
switch
(
info
->
rtfMinor
)
{
case
rtfPage
:
case
rtfSect
:
case
rtfRow
:
case
rtfLine
:
case
rtfPar
:
PutLitChar
(
'\n'
);
PutLitChar
(
info
,
'\n'
);
break
;
case
rtfCell
:
PutStdChar
(
rtfSC_space
);
/* make sure cells are separated */
PutStdChar
(
info
,
rtfSC_space
);
/* make sure cells are separated */
break
;
case
rtfNoBrkSpace
:
PutStdChar
(
rtfSC_nobrkspace
);
PutStdChar
(
info
,
rtfSC_nobrkspace
);
break
;
case
rtfTab
:
PutLitChar
(
'\t'
);
PutLitChar
(
info
,
'\t'
);
break
;
case
rtfNoBrkHyphen
:
PutStdChar
(
rtfSC_nobrkhyphen
);
PutStdChar
(
info
,
rtfSC_nobrkhyphen
);
break
;
case
rtfBullet
:
PutStdChar
(
rtfSC_bullet
);
PutStdChar
(
info
,
rtfSC_bullet
);
break
;
case
rtfEmDash
:
PutStdChar
(
rtfSC_emdash
);
PutStdChar
(
info
,
rtfSC_emdash
);
break
;
case
rtfEnDash
:
PutStdChar
(
rtfSC_endash
);
PutStdChar
(
info
,
rtfSC_endash
);
break
;
case
rtfLQuote
:
PutStdChar
(
rtfSC_quoteleft
);
PutStdChar
(
info
,
rtfSC_quoteleft
);
break
;
case
rtfRQuote
:
PutStdChar
(
rtfSC_quoteright
);
PutStdChar
(
info
,
rtfSC_quoteright
);
break
;
case
rtfLDblQuote
:
PutStdChar
(
rtfSC_quotedblleft
);
PutStdChar
(
info
,
rtfSC_quotedblleft
);
break
;
case
rtfRDblQuote
:
PutStdChar
(
rtfSC_quotedblright
);
PutStdChar
(
info
,
rtfSC_quotedblright
);
break
;
}
}
...
...
@@ -255,7 +257,7 @@ void SpecialChar ()
* obvious and provides incentive to fix it. :-)
*/
void
PutStdChar
(
int
stdCode
)
void
PutStdChar
(
RTF_Info
*
info
,
int
stdCode
)
{
char
*
oStr
=
(
char
*
)
NULL
;
...
...
@@ -266,28 +268,28 @@ void PutStdChar (int stdCode)
*/
TRACE
(
"
\n
"
);
oStr
=
outMap
[
stdCode
];
oStr
=
info
->
outMap
[
stdCode
];
if
(
oStr
==
(
char
*
)
NULL
)
/* no output sequence in map */
{
sprintf
(
buf
,
"[[%s]]"
,
RTFStdCharName
(
stdCode
));
sprintf
(
buf
,
"[[%s]]"
,
RTFStdCharName
(
info
,
stdCode
));
oStr
=
buf
;
}
PutLitStr
(
oStr
);
PutLitStr
(
info
,
oStr
);
}
void
PutLitChar
(
int
c
)
void
PutLitChar
(
RTF_Info
*
info
,
int
c
)
{
CHARLIST_Enqueue
(
&
charlist
,
(
char
)
c
);
CHARLIST_Enqueue
(
&
info
->
charlist
,
(
char
)
c
);
/* fputc (c, ostream); */
}
static
void
PutLitStr
(
char
*
s
)
static
void
PutLitStr
(
RTF_Info
*
info
,
char
*
s
)
{
for
(;
*
s
;
s
++
)
{
CHARLIST_Enqueue
(
&
charlist
,
*
s
);
CHARLIST_Enqueue
(
&
info
->
charlist
,
*
s
);
}
/* fputs (s, ostream); */
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment