mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 02:40:38 +00:00
Moved text conversion classes to separate bundle
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10755 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9b9c1ae290
commit
60a7ef53c8
22 changed files with 409 additions and 844 deletions
|
@ -4,3 +4,4 @@ config.cache
|
|||
config.make
|
||||
gnustep-gui.spec
|
||||
gnustep-gui-debug.spec
|
||||
gui.make
|
||||
|
|
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2001-08-21 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/NSAttributedString.m (converter_bundles): New function
|
||||
to find bundles that do text conversion.
|
||||
(converter_class): Use it.
|
||||
* Source/GNUmakefile: Update to remove Parsers files
|
||||
|
||||
* TextConverters/RTF/*: New files moved from Source/Parsers.
|
||||
Builds bundle for RTF text conversion.
|
||||
|
||||
2001-08-21 Pierre-Yves <pyrivail@spocky.imada.sdu.dk>
|
||||
|
||||
* Source/NSTableColumn.m
|
||||
|
|
|
@ -43,7 +43,7 @@ include ./Version
|
|||
#
|
||||
# The list of subproject directories
|
||||
#
|
||||
SUBPROJECTS = Source Images Model Tools Panels PrinterTypes
|
||||
SUBPROJECTS = Source Images Model Tools Panels PrinterTypes TextConverters
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
|
||||
|
|
|
@ -38,9 +38,7 @@ include ../config.make
|
|||
LIBRARY_NAME = libgnustep-gui
|
||||
|
||||
# The Objective-C source files to be compiled
|
||||
libgnustep-gui_C_FILES = \
|
||||
Parsers/rtfGrammer.tab.c \
|
||||
Parsers/rtfScanner.c
|
||||
libgnustep-gui_C_FILES =
|
||||
|
||||
# The Objective-C source files to be compiled
|
||||
libgnustep-gui_OBJC_FILES = Functions.m \
|
||||
|
@ -156,9 +154,7 @@ GSFontInfo.m \
|
|||
GSTable.m \
|
||||
GSHbox.m \
|
||||
GSVbox.m \
|
||||
GSSimpleLayoutManager.m \
|
||||
Parsers/attributedStringConsumer.m \
|
||||
Parsers/RTFProducer.m
|
||||
GSSimpleLayoutManager.m
|
||||
|
||||
ifneq ($(FOUNDATION_LIB), fd)
|
||||
libgnustep-gui_OBJC_FILES += NSPasteboard.m
|
||||
|
|
|
@ -35,11 +35,8 @@
|
|||
# otherwise the normal makefile rules will not be performed.
|
||||
#
|
||||
|
||||
./$(GNUSTEP_OBJ_DIR)/Parsers:
|
||||
$(MKDIRS) ./$(GNUSTEP_OBJ_DIR)/Parsers
|
||||
|
||||
# Things to do before compiling
|
||||
before-all:: ./$(GNUSTEP_OBJ_DIR)/Parsers
|
||||
# before-all::
|
||||
|
||||
# Things to do after compiling
|
||||
# after-all::
|
||||
|
@ -78,9 +75,6 @@ after-distclean::
|
|||
#
|
||||
# GNUstep GUI Library specific targets
|
||||
|
||||
Parsers/rtfGrammer.tab.c: Parsers/rtfGrammer.y
|
||||
$(BISON) $(BISON_FLAGS) $<
|
||||
|
||||
#
|
||||
# Make list of class names for DLL exports. I'm not sure how to make this
|
||||
# work with the correct dependencies, so for now it should be regenerated
|
||||
|
|
|
@ -56,11 +56,6 @@ ifneq ($(BACKEND_BUNDLE),)
|
|||
ADDITIONAL_CPPFLAGS += -DBACKEND_BUNDLE=1
|
||||
endif
|
||||
|
||||
|
||||
BISON_FLAGS = -d -p GSRTF
|
||||
BISON = BISON_SIMPLE=Parsers/bison.simple bison
|
||||
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
ADDITIONAL_OBJCFLAGS = -Wall
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSRange.h>
|
||||
#include <Foundation/NSBundle.h>
|
||||
#include <Foundation/NSFileManager.h>
|
||||
#include <AppKit/NSAttributedString.h>
|
||||
#include <AppKit/NSParagraphStyle.h>
|
||||
#include <AppKit/NSTextAttachment.h>
|
||||
|
@ -99,6 +101,62 @@ static inline void cache_init ()
|
|||
}
|
||||
}
|
||||
|
||||
/* Return the class that handles format from the first bundle it finds */
|
||||
static
|
||||
Class converter_bundles(NSString *format, BOOL producer)
|
||||
{
|
||||
Class converter_class = Nil;
|
||||
NSEnumerator *benum;
|
||||
NSString *dpath;
|
||||
|
||||
/* Find the bundle paths */
|
||||
benum = [NSStandardLibraryPaths() objectEnumerator];
|
||||
while ((dpath = [benum nextObject]))
|
||||
{
|
||||
NSEnumerator *direnum;
|
||||
NSString *path;
|
||||
dpath = [dpath stringByAppendingPathComponent: @"Bundles"];
|
||||
dpath = [dpath stringByAppendingPathComponent: @"TextConverters"];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath: dpath])
|
||||
direnum = [[NSFileManager defaultManager] enumeratorAtPath: dpath];
|
||||
else
|
||||
direnum = nil;
|
||||
while (direnum && (path = [direnum nextObject]))
|
||||
{
|
||||
Class bclass;
|
||||
NSString *full_path;
|
||||
NSBundle *aBundle;
|
||||
if ([[path pathExtension] isEqual: @"bundle"] == NO)
|
||||
continue;
|
||||
full_path = [dpath stringByAppendingPathComponent: path];
|
||||
aBundle = [NSBundle bundleWithPath: full_path];
|
||||
if (aBundle && ((bclass = [aBundle principalClass])))
|
||||
{
|
||||
if ([bclass respondsToSelector:
|
||||
@selector(classForFormat:producer:)])
|
||||
{
|
||||
converter_class = (Class)[bclass classForFormat: format
|
||||
producer: producer];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *converter_name;
|
||||
if (producer)
|
||||
converter_name = [format stringByAppendingString: @"Producer"];
|
||||
else
|
||||
converter_name = [format stringByAppendingString: @"Consumer"];
|
||||
converter_class = [aBundle classNamed: converter_name];
|
||||
}
|
||||
}
|
||||
if (converter_class)
|
||||
break;
|
||||
}
|
||||
if (converter_class)
|
||||
break;
|
||||
}
|
||||
return converter_class;
|
||||
}
|
||||
|
||||
/*
|
||||
Return a suitable converter for the text format supplied as argument.
|
||||
If producer is YES a class capable of writting that format is returned,
|
||||
|
@ -118,10 +176,9 @@ static Class converter_class(NSString *format, BOOL producer)
|
|||
found = [p_classes objectForKey: format];
|
||||
if (found == Nil)
|
||||
{
|
||||
if ([format isEqual: @"RTF"])
|
||||
found = NSClassFromString(@"RTFProducer");
|
||||
else if ([format isEqual: @"RTFD"])
|
||||
found = NSClassFromString(@"RTFDProducer");
|
||||
found = converter_bundles(format, producer);
|
||||
if (found != Nil)
|
||||
NSDebugLog(@"Found converter %@ for format %@", found, format);
|
||||
if (found != Nil)
|
||||
[p_classes setObject: found forKey: format];
|
||||
}
|
||||
|
@ -135,10 +192,9 @@ static Class converter_class(NSString *format, BOOL producer)
|
|||
found = [c_classes objectForKey: format];
|
||||
if (found == Nil)
|
||||
{
|
||||
if ([format isEqual: @"RTF"])
|
||||
found = NSClassFromString(@"RTFConsumer");
|
||||
else if ([format isEqual: @"RTFD"])
|
||||
found = NSClassFromString(@"RTFDConsumer");
|
||||
found = converter_bundles(format, producer);
|
||||
if (found != Nil)
|
||||
NSDebugLog(@"Found converter %@ for format %@", found, format);
|
||||
if (found != Nil)
|
||||
[c_classes setObject: found forKey: format];
|
||||
}
|
||||
|
|
|
@ -1,693 +0,0 @@
|
|||
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
|
||||
#line 3 "/usr/local/share/bison.simple"
|
||||
|
||||
/* Skeleton output parser for bison,
|
||||
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* As a special exception, when this file is copied by Bison into a
|
||||
Bison output file, you may use that output file without restriction.
|
||||
This special exception was added by the Free Software Foundation
|
||||
in version 1.24 of Bison. */
|
||||
|
||||
#ifndef alloca
|
||||
#ifdef __GNUC__
|
||||
#define alloca __builtin_alloca
|
||||
#else /* not GNU C. */
|
||||
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
|
||||
#include <alloca.h>
|
||||
#else /* not sparc */
|
||||
#if defined (MSDOS) && !defined (__TURBOC__)
|
||||
#include <malloc.h>
|
||||
#else /* not MSDOS, or __TURBOC__ */
|
||||
#if defined(_AIX)
|
||||
#include <malloc.h>
|
||||
#pragma alloca
|
||||
#else /* not MSDOS, __TURBOC__, or _AIX */
|
||||
#ifdef __hpux
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
void *alloca (unsigned int);
|
||||
};
|
||||
#else /* not __cplusplus */
|
||||
void *alloca ();
|
||||
#endif /* not __cplusplus */
|
||||
#endif /* __hpux */
|
||||
#endif /* not _AIX */
|
||||
#endif /* not MSDOS, or __TURBOC__ */
|
||||
#endif /* not sparc. */
|
||||
#endif /* not GNU C. */
|
||||
#endif /* alloca not defined. */
|
||||
|
||||
/* This is the parser code that is written into each bison parser
|
||||
when the %semantic_parser declaration is not specified in the grammar.
|
||||
It was written by Richard Stallman by simplifying the hairy parser
|
||||
used when %semantic_parser is specified. */
|
||||
|
||||
/* Note: there must be only one dollar sign in this file.
|
||||
It is replaced by the list of actions, each action
|
||||
as one case of the switch. */
|
||||
|
||||
#define yyerrok (yyerrstatus = 0)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define YYEMPTY -2
|
||||
#define YYEOF 0
|
||||
#define YYACCEPT return(0)
|
||||
#define YYABORT return(1)
|
||||
#define YYERROR goto yyerrlab1
|
||||
/* Like YYERROR except do call yyerror.
|
||||
This remains here temporarily to ease the
|
||||
transition to the new meaning of YYERROR, for GCC.
|
||||
Once GCC version 2 has supplanted version 1, this can go. */
|
||||
#define YYFAIL goto yyerrlab
|
||||
#define YYRECOVERING() (!!yyerrstatus)
|
||||
#define YYBACKUP() \
|
||||
do \
|
||||
if (yychar == YYEMPTY && yylen == 1) \
|
||||
{ yychar = (token), yylval = (value); \
|
||||
yychar1 = YYTRANSLATE (yychar); \
|
||||
YYPOPSTACK; \
|
||||
goto yybackup; \
|
||||
} \
|
||||
else \
|
||||
{ yyerror ("syntax error: cannot back up"); YYERROR; } \
|
||||
while (0)
|
||||
|
||||
#define YYTERROR 1
|
||||
#define YYERRCODE 256
|
||||
|
||||
#ifndef YYPURE
|
||||
#define YYLEX yylex()
|
||||
#endif
|
||||
|
||||
#ifdef YYPURE
|
||||
#ifdef YYLSP_NEEDED
|
||||
#ifdef YYLEX_PARAM
|
||||
#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
|
||||
#else
|
||||
#define YYLEX yylex(&yylval, &yylloc)
|
||||
#endif
|
||||
#else /* not YYLSP_NEEDED */
|
||||
#ifdef YYLEX_PARAM
|
||||
#define YYLEX yylex(&yylval, YYLEX_PARAM)
|
||||
#else
|
||||
#define YYLEX yylex(&yylval)
|
||||
#endif
|
||||
#endif /* not YYLSP_NEEDED */
|
||||
#endif
|
||||
|
||||
/* If nonreentrant, generate the variables here */
|
||||
|
||||
#ifndef YYPURE
|
||||
|
||||
int yychar; /* the lookahead symbol */
|
||||
YYSTYPE yylval; /* the semantic value of the */
|
||||
/* lookahead symbol */
|
||||
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE yylloc; /* location data for the lookahead */
|
||||
/* symbol */
|
||||
#endif
|
||||
|
||||
int yynerrs; /* number of parse errors so far */
|
||||
#endif /* not YYPURE */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
int yydebug; /* nonzero means print parse trace */
|
||||
/* Since this is uninitialized, it does not stop multiple parsers
|
||||
from coexisting. */
|
||||
#endif
|
||||
|
||||
/* YYINITDEPTH indicates the initial size of the parser's stacks */
|
||||
|
||||
#ifndef YYINITDEPTH
|
||||
#define YYINITDEPTH 200
|
||||
#endif
|
||||
|
||||
/* YYMAXDEPTH is the maximum size the stacks can grow to
|
||||
(effective only if the built-in stack extension method is used). */
|
||||
|
||||
#if YYMAXDEPTH == 0
|
||||
#undef YYMAXDEPTH
|
||||
#endif
|
||||
|
||||
#ifndef YYMAXDEPTH
|
||||
#define YYMAXDEPTH 10000
|
||||
#endif
|
||||
|
||||
/* Prevent warning if -Wstrict-prototypes. */
|
||||
#ifdef __GNUC__
|
||||
/*int yyparse ();*/
|
||||
#endif
|
||||
|
||||
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
|
||||
#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
|
||||
#else /* not GNU C or C++ */
|
||||
#ifndef __cplusplus
|
||||
|
||||
/* This is the most reliable way to avoid incompatibilities
|
||||
in available built-in functions on various systems. */
|
||||
static void
|
||||
__yy_memcpy (to, from, count)
|
||||
char *to;
|
||||
char *from;
|
||||
int count;
|
||||
{
|
||||
register char *f = from;
|
||||
register char *t = to;
|
||||
register int i = count;
|
||||
|
||||
while (i-- > 0)
|
||||
*t++ = *f++;
|
||||
}
|
||||
|
||||
#else /* __cplusplus */
|
||||
|
||||
/* This is the most reliable way to avoid incompatibilities
|
||||
in available built-in functions on various systems. */
|
||||
static void
|
||||
__yy_memcpy (char *to, char *from, int count)
|
||||
{
|
||||
register char *f = from;
|
||||
register char *t = to;
|
||||
register int i = count;
|
||||
|
||||
while (i-- > 0)
|
||||
*t++ = *f++;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#line 196 "/usr/local/share/bison.simple"
|
||||
|
||||
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
||||
into yyparse. The argument should have type void *.
|
||||
It should actually point to an object.
|
||||
Grammar actions can access the variable by casting it
|
||||
to the proper pointer type. */
|
||||
|
||||
typedef void *VOIDP;
|
||||
#ifdef YYPARSE_PARAM
|
||||
#ifdef __cplusplus
|
||||
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
|
||||
#define YYPARSE_PARAM_DECL
|
||||
#else /* not __cplusplus */
|
||||
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
|
||||
#define YYPARSE_PARAM_DECL VOIDP YYPARSE_PARAM;
|
||||
#endif /* not __cplusplus */
|
||||
#else /* not YYPARSE_PARAM */
|
||||
#define YYPARSE_PARAM_ARG
|
||||
#define YYPARSE_PARAM_DECL
|
||||
#endif /* not YYPARSE_PARAM */
|
||||
|
||||
int
|
||||
yyparse(YYPARSE_PARAM_ARG)
|
||||
YYPARSE_PARAM_DECL
|
||||
{
|
||||
register int yystate;
|
||||
register int yyn;
|
||||
register short *yyssp;
|
||||
register YYSTYPE *yyvsp;
|
||||
int yyerrstatus; /* number of tokens to shift before error messages enabled */
|
||||
int yychar1 = 0; /* lookahead token as an internal (translated) token number */
|
||||
|
||||
short yyssa[YYINITDEPTH]; /* the state stack */
|
||||
YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
|
||||
|
||||
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
|
||||
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
|
||||
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
|
||||
YYLTYPE *yyls = yylsa;
|
||||
YYLTYPE *yylsp;
|
||||
|
||||
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
|
||||
#else
|
||||
#define YYPOPSTACK (yyvsp--, yyssp--)
|
||||
#endif
|
||||
|
||||
int yystacksize = YYINITDEPTH;
|
||||
|
||||
#ifdef YYPURE
|
||||
int yychar;
|
||||
YYSTYPE yylval;
|
||||
int yynerrs;
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE yylloc;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
YYSTYPE yyval; /* the variable used to return */
|
||||
/* semantic values from the action */
|
||||
/* routines */
|
||||
|
||||
int yylen;
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Starting parse\n");
|
||||
#endif
|
||||
|
||||
yystate = 0;
|
||||
yyerrstatus = 0;
|
||||
yynerrs = 0;
|
||||
yychar = YYEMPTY; /* Cause a token to be read. */
|
||||
|
||||
/* Initialize stack pointers.
|
||||
Waste one element of value and location stack
|
||||
so that they stay on the same level as the state stack.
|
||||
The wasted elements are never initialized. */
|
||||
|
||||
yyssp = yyss - 1;
|
||||
yyvsp = yyvs;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp = yyls;
|
||||
#endif
|
||||
|
||||
/* Push a new state, which is found in yystate . */
|
||||
/* In all cases, when you get here, the value and location stacks
|
||||
have just been pushed. so pushing a state here evens the stacks. */
|
||||
yynewstate:
|
||||
|
||||
*++yyssp = yystate;
|
||||
|
||||
if (yyssp >= yyss + yystacksize - 1)
|
||||
{
|
||||
/* Give user a chance to reallocate the stack */
|
||||
/* Use copies of these so that the &'s don't force the real ones into memory. */
|
||||
YYSTYPE *yyvs1 = yyvs;
|
||||
short *yyss1 = yyss;
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE *yyls1 = yyls;
|
||||
#endif
|
||||
|
||||
/* Get the current used size of the three stacks, in elements. */
|
||||
int size = yyssp - yyss + 1;
|
||||
|
||||
#ifdef yyoverflow
|
||||
/* Each stack pointer address is followed by the size of
|
||||
the data in use in that stack, in bytes. */
|
||||
#ifdef YYLSP_NEEDED
|
||||
/* This used to be a conditional around just the two extra args,
|
||||
but that might be undefined if yyoverflow is a macro. */
|
||||
yyoverflow("parser stack overflow",
|
||||
&yyss1, size * sizeof (*yyssp),
|
||||
&yyvs1, size * sizeof (*yyvsp),
|
||||
&yyls1, size * sizeof (*yylsp),
|
||||
&yystacksize);
|
||||
#else
|
||||
yyoverflow("parser stack overflow",
|
||||
&yyss1, size * sizeof (*yyssp),
|
||||
&yyvs1, size * sizeof (*yyvsp),
|
||||
&yystacksize);
|
||||
#endif
|
||||
|
||||
yyss = yyss1; yyvs = yyvs1;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yyls = yyls1;
|
||||
#endif
|
||||
#else /* no yyoverflow */
|
||||
/* Extend the stack our own way. */
|
||||
if (yystacksize >= YYMAXDEPTH)
|
||||
{
|
||||
yyerror("parser stack overflow");
|
||||
return 2;
|
||||
}
|
||||
yystacksize *= 2;
|
||||
if (yystacksize > YYMAXDEPTH)
|
||||
yystacksize = YYMAXDEPTH;
|
||||
yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
|
||||
__yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
|
||||
yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
|
||||
__yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
|
||||
#ifdef YYLSP_NEEDED
|
||||
yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
|
||||
__yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
|
||||
#endif
|
||||
#endif /* no yyoverflow */
|
||||
|
||||
yyssp = yyss + size - 1;
|
||||
yyvsp = yyvs + size - 1;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp = yyls + size - 1;
|
||||
#endif
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Stack size increased to %d\n", yystacksize);
|
||||
#endif
|
||||
|
||||
if (yyssp >= yyss + yystacksize - 1)
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Entering state %d\n", yystate);
|
||||
#endif
|
||||
|
||||
goto yybackup;
|
||||
yybackup:
|
||||
|
||||
/* Do appropriate processing given the current state. */
|
||||
/* Read a lookahead token if we need one and don't already have one. */
|
||||
/* yyresume: */
|
||||
|
||||
/* First try to decide what to do without reference to lookahead token. */
|
||||
|
||||
yyn = yypact[yystate];
|
||||
if (yyn == YYFLAG)
|
||||
goto yydefault;
|
||||
|
||||
/* Not known => get a lookahead token if don't already have one. */
|
||||
|
||||
/* yychar is either YYEMPTY or YYEOF
|
||||
or a valid token in external form. */
|
||||
|
||||
if (yychar == YYEMPTY)
|
||||
{
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Reading a token: ");
|
||||
#endif
|
||||
yychar = YYLEX;
|
||||
}
|
||||
|
||||
/* Convert token to internal form (in yychar1) for indexing tables with */
|
||||
|
||||
if (yychar <= 0) /* This means end of input. */
|
||||
{
|
||||
yychar1 = 0;
|
||||
yychar = YYEOF; /* Don't call YYLEX any more */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Now at end of input.\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
yychar1 = YYTRANSLATE(yychar);
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
|
||||
/* Give the individual parser a way to print the precise meaning
|
||||
of a token, for further debugging info. */
|
||||
#ifdef YYPRINT
|
||||
YYPRINT (stderr, yychar, yylval);
|
||||
#endif
|
||||
fprintf (stderr, ")\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
yyn += yychar1;
|
||||
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
|
||||
goto yydefault;
|
||||
|
||||
yyn = yytable[yyn];
|
||||
|
||||
/* yyn is what to do for this token type in this state.
|
||||
Negative => reduce, -yyn is rule number.
|
||||
Positive => shift, yyn is new state.
|
||||
New state is final state => don't bother to shift,
|
||||
just return success.
|
||||
0, or most negative number => error. */
|
||||
|
||||
if (yyn < 0)
|
||||
{
|
||||
if (yyn == YYFLAG)
|
||||
goto yyerrlab;
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
else if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
if (yyn == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
/* Shift the lookahead token. */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
|
||||
#endif
|
||||
|
||||
/* Discard the token being shifted unless it is eof. */
|
||||
if (yychar != YYEOF)
|
||||
yychar = YYEMPTY;
|
||||
|
||||
*++yyvsp = yylval;
|
||||
#ifdef YYLSP_NEEDED
|
||||
*++yylsp = yylloc;
|
||||
#endif
|
||||
|
||||
/* count tokens shifted since error; after three, turn off error status. */
|
||||
if (yyerrstatus) yyerrstatus--;
|
||||
|
||||
yystate = yyn;
|
||||
goto yynewstate;
|
||||
|
||||
/* Do the default action for the current state. */
|
||||
yydefault:
|
||||
|
||||
yyn = yydefact[yystate];
|
||||
if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
/* Do a reduction. yyn is the number of a rule to reduce with. */
|
||||
yyreduce:
|
||||
yylen = yyr2[yyn];
|
||||
if (yylen > 0)
|
||||
yyval = yyvsp[1-yylen]; /* implement default value of the action */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf (stderr, "Reducing via rule %d (line %d), ",
|
||||
yyn, yyrline[yyn]);
|
||||
|
||||
/* Print the symbols being reduced, and their result. */
|
||||
for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
|
||||
fprintf (stderr, "%s ", yytname[yyrhs[i]]);
|
||||
fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
|
||||
}
|
||||
#endif
|
||||
|
||||
$ /* the action file gets copied in in place of this dollarsign */
|
||||
#line 498 "/usr/local/share/bison.simple"
|
||||
|
||||
yyvsp -= yylen;
|
||||
yyssp -= yylen;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp -= yylen;
|
||||
#endif
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
short *ssp1 = yyss - 1;
|
||||
fprintf (stderr, "state stack now");
|
||||
while (ssp1 != yyssp)
|
||||
fprintf (stderr, " %d", *++ssp1);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
*++yyvsp = yyval;
|
||||
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp++;
|
||||
if (yylen == 0)
|
||||
{
|
||||
yylsp->first_line = yylloc.first_line;
|
||||
yylsp->first_column = yylloc.first_column;
|
||||
yylsp->last_line = (yylsp-1)->last_line;
|
||||
yylsp->last_column = (yylsp-1)->last_column;
|
||||
yylsp->text = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
yylsp->last_line = (yylsp+yylen-1)->last_line;
|
||||
yylsp->last_column = (yylsp+yylen-1)->last_column;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now "shift" the result of the reduction.
|
||||
Determine what state that goes to,
|
||||
based on the state we popped back to
|
||||
and the rule number reduced by. */
|
||||
|
||||
yyn = yyr1[yyn];
|
||||
|
||||
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
|
||||
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
|
||||
yystate = yytable[yystate];
|
||||
else
|
||||
yystate = yydefgoto[yyn - YYNTBASE];
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
yyerrlab: /* here on detecting error */
|
||||
|
||||
if (! yyerrstatus)
|
||||
/* If not already recovering from an error, report this error. */
|
||||
{
|
||||
++yynerrs;
|
||||
|
||||
#ifdef YYERROR_VERBOSE
|
||||
yyn = yypact[yystate];
|
||||
|
||||
if (yyn > YYFLAG && yyn < YYLAST)
|
||||
{
|
||||
int size = 0;
|
||||
char *msg;
|
||||
int x, count;
|
||||
|
||||
count = 0;
|
||||
/* Start X at -yyn if nec to avoid negative indexes in yycheck. */
|
||||
for (x = (yyn < 0 ? -yyn : 0);
|
||||
x < (sizeof(yytname) / sizeof(char *)); x++)
|
||||
if (yycheck[x + yyn] == x)
|
||||
size += strlen(yytname[x]) + 15, count++;
|
||||
msg = (char *) malloc(size + 15);
|
||||
if (msg != 0)
|
||||
{
|
||||
strcpy(msg, "parse error");
|
||||
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (x = (yyn < 0 ? -yyn : 0);
|
||||
x < (sizeof(yytname) / sizeof(char *)); x++)
|
||||
if (yycheck[x + yyn] == x)
|
||||
{
|
||||
strcat(msg, count == 0 ? ", expecting `" : " or `");
|
||||
strcat(msg, yytname[x]);
|
||||
strcat(msg, "'");
|
||||
count++;
|
||||
}
|
||||
}
|
||||
yyerror(msg);
|
||||
free(msg);
|
||||
}
|
||||
else
|
||||
yyerror ("parse error; also virtual memory exceeded");
|
||||
}
|
||||
else
|
||||
#endif /* YYERROR_VERBOSE */
|
||||
yyerror("parse error");
|
||||
}
|
||||
|
||||
goto yyerrlab1;
|
||||
yyerrlab1: /* here on error raised explicitly by an action */
|
||||
|
||||
if (yyerrstatus == 3)
|
||||
{
|
||||
/* if just tried and failed to reuse lookahead token after an error, discard it. */
|
||||
|
||||
/* return failure if at end of input */
|
||||
if (yychar == YYEOF)
|
||||
YYABORT;
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
|
||||
#endif
|
||||
|
||||
yychar = YYEMPTY;
|
||||
}
|
||||
|
||||
/* Else will try to reuse lookahead token
|
||||
after shifting the error token. */
|
||||
|
||||
yyerrstatus = 3; /* Each real token shifted decrements this */
|
||||
|
||||
goto yyerrhandle;
|
||||
|
||||
yyerrdefault: /* current state does not do anything special for the error token. */
|
||||
|
||||
#if 0
|
||||
/* This is wrong; only states that explicitly want error tokens
|
||||
should shift them. */
|
||||
yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
|
||||
if (yyn) goto yydefault;
|
||||
#endif
|
||||
|
||||
yyerrpop: /* pop the current state because it cannot handle the error token */
|
||||
|
||||
if (yyssp == yyss) YYABORT;
|
||||
yyvsp--;
|
||||
yystate = *--yyssp;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp--;
|
||||
#endif
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
short *ssp1 = yyss - 1;
|
||||
fprintf (stderr, "Error: state stack now");
|
||||
while (ssp1 != yyssp)
|
||||
fprintf (stderr, " %d", *++ssp1);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
yyerrhandle:
|
||||
|
||||
yyn = yypact[yystate];
|
||||
if (yyn == YYFLAG)
|
||||
goto yyerrdefault;
|
||||
|
||||
yyn += YYTERROR;
|
||||
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
|
||||
goto yyerrdefault;
|
||||
|
||||
yyn = yytable[yyn];
|
||||
if (yyn < 0)
|
||||
{
|
||||
if (yyn == YYFLAG)
|
||||
goto yyerrpop;
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
else if (yyn == 0)
|
||||
goto yyerrpop;
|
||||
|
||||
if (yyn == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Shifting error token, ");
|
||||
#endif
|
||||
|
||||
*++yyvsp = yylval;
|
||||
#ifdef YYLSP_NEEDED
|
||||
*++yylsp = yylloc;
|
||||
#endif
|
||||
|
||||
yystate = yyn;
|
||||
goto yynewstate;
|
||||
}
|
36
TextConverters/GNUmakefile
Normal file
36
TextConverters/GNUmakefile
Normal file
|
@ -0,0 +1,36 @@
|
|||
#
|
||||
# Makefile for TextConverters bundles
|
||||
#
|
||||
# Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Adam Fedor <fedor@gnu.org>
|
||||
#
|
||||
# This file is part of the GNUstep GUI Library.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# If you are interested in a warranty or support for this source code,
|
||||
# contact Scott Christley at scottc@net-community.com
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
#
|
||||
# The list of subproject directories
|
||||
#
|
||||
SUBPROJECTS = RTF
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
41
TextConverters/RTF/GNUmakefile
Normal file
41
TextConverters/RTF/GNUmakefile
Normal file
|
@ -0,0 +1,41 @@
|
|||
# GNUmakefile
|
||||
#
|
||||
# Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Adam Fedor <fedor@gnu.org>
|
||||
#
|
||||
# This file is part of GNUstep
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
BUNDLE_NAME = RTFConverter
|
||||
BUNDLE_INSTALL_DIR =$(GNUSTEP_BUNDLES)/TextConverters
|
||||
|
||||
RTFConverter_OBJC_FILES = \
|
||||
RTFConsumer.m RTFProducer.m
|
||||
|
||||
RTFConverter_C_FILES = \
|
||||
rtfGrammer.tab.c rtfScanner.c
|
||||
|
||||
RTFConverter_PRINCIPAL_CLASS = RTFConsumer
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||
|
||||
-include GNUmakefile.postamble
|
||||
|
32
TextConverters/RTF/GNUmakefile.postamble
Normal file
32
TextConverters/RTF/GNUmakefile.postamble
Normal file
|
@ -0,0 +1,32 @@
|
|||
# GNUmakefile.postamble
|
||||
#
|
||||
# Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Philippe C.D. Robert <prh@3dkit.org>
|
||||
#
|
||||
# This file is part of GNUstep
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# If you are interested in a warranty or support for this source code,
|
||||
# contact Scott Christley at scottc@net-community.com
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
BISON_FLAGS = -d -p GSRTF
|
||||
BISON = BISON_SIMPLE=bison.simple bison
|
||||
|
||||
# This parser doesn't compile with newer bison programs. Needs to be fixed...
|
||||
#rtfGrammer.tab.c: rtfGrammer.y
|
||||
# $(BISON) $(BISON_FLAGS) $<
|
73
TextConverters/RTF/GNUmakefile.preamble
Normal file
73
TextConverters/RTF/GNUmakefile.preamble
Normal file
|
@ -0,0 +1,73 @@
|
|||
# GNUmakefile.preamble
|
||||
#
|
||||
# Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Philippe C.D. Robert <prh@3dkit.org>
|
||||
#
|
||||
# This file is part of GNUstep
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# If you are interested in a warranty or support for this source code,
|
||||
# contact Scott Christley at scottc@net-community.com
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#
|
||||
# Makefile.preamble
|
||||
#
|
||||
# Project specific makefile variables, and additional
|
||||
#
|
||||
# Do not put any Makefile rules in this file, instead they should
|
||||
# be put into Makefile.postamble.
|
||||
#
|
||||
|
||||
#
|
||||
# Flags dealing with compiling and linking
|
||||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS +=
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
ADDITIONAL_OBJCFLAGS +=
|
||||
|
||||
# Additional flags to pass to the C compiler
|
||||
ADDITIONAL_CFLAGS +=
|
||||
#ADDITIONAL_CFLAGS +=
|
||||
|
||||
# Additional include directories the compiler should search
|
||||
ADDITIONAL_INCLUDE_DIRS +=-I../../Headers
|
||||
|
||||
# Additional LDFLAGS to pass to the linker
|
||||
#ADDITIONAL_LDFLAGS +=
|
||||
|
||||
# Additional library directories the linker should search
|
||||
#ADDITIONAL_LIB_DIRS +=
|
||||
|
||||
#ADDITIONAL_TOOL_LIBS +=
|
||||
|
||||
#
|
||||
# Flags dealing with installing and uninstalling
|
||||
#
|
||||
|
||||
# Additional directories to be created during installation
|
||||
#ADDITIONAL_INSTALL_DIRS +=
|
||||
|
||||
#
|
||||
# Local configuration
|
||||
#
|
||||
|
||||
|
||||
|
|
@ -27,8 +27,9 @@
|
|||
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "Parsers/rtfConsumer.h"
|
||||
#include "Parsers/rtfConsumerFunctions.h"
|
||||
#include "RTFConsumer.h"
|
||||
#include "RTFConsumerFunctions.h"
|
||||
#include "RTFProducer.h"
|
||||
|
||||
/* we have to satisfy the scanner with a stream reading function */
|
||||
typedef struct {
|
||||
|
@ -225,6 +226,28 @@ readNSString (StringContext *ctxt)
|
|||
|
||||
@implementation RTFConsumer
|
||||
|
||||
/* RTFConsumer is the principal class and thus implements this */
|
||||
+ (Class) classForFormat: (NSString *)format producer: (BOOL)flag
|
||||
{
|
||||
Class cClass = Nil;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if ([format isEqual: @"RTFD"])
|
||||
cClass = [RTFDProducer class];
|
||||
else if ([format isEqual: @"RTF"])
|
||||
cClass = [RTFProducer class];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([format isEqual: @"RTFD"])
|
||||
cClass = [RTFDConsumer class];
|
||||
else if ([format isEqual: @"RTF"])
|
||||
cClass = [RTFConsumer class];
|
||||
}
|
||||
return cClass;
|
||||
}
|
||||
|
||||
+ (NSAttributedString*) parseFile: (NSFileWrapper *)wrapper
|
||||
documentAttributes: (NSDictionary **)dict
|
||||
{
|
|
@ -28,7 +28,7 @@
|
|||
#ifndef rtfConsumerFunctions_h_INCLUDE
|
||||
#define rtfConsumerFunctions_h_INCLUDE
|
||||
|
||||
#include "Parsers/rtfScanner.h"
|
||||
#include "rtfScanner.h"
|
||||
|
||||
/* general statements:
|
||||
measurement is usually in twips: one twentieth of a point (this is about 0.01764 mm)
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
/* A Bison parser, made from Parsers/rtfGrammer.y
|
||||
/* A Bison parser, made from rtfGrammer.y
|
||||
by GNU Bison version 1.25
|
||||
*/
|
||||
|
||||
|
@ -86,7 +86,7 @@
|
|||
#define RTFfamilyDecor 327
|
||||
#define RTFfamilyTech 328
|
||||
|
||||
#line 35 "Parsers/rtfGrammer.y"
|
||||
#line 35 "rtfGrammer.y"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -109,7 +109,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "Parsers/rtfScanner.h"
|
||||
#include "rtfScanner.h"
|
||||
|
||||
/* this context is passed to the interface functions */
|
||||
typedef void * GSRTFctxt;
|
||||
|
@ -118,10 +118,10 @@ typedef void * GSRTFctxt;
|
|||
|
||||
#define YYERROR_VERBOSE
|
||||
|
||||
#include "rtfConsumerFunctions.h"
|
||||
#include "RTFConsumerFunctions.h"
|
||||
|
||||
|
||||
#line 70 "Parsers/rtfGrammer.y"
|
||||
#line 70 "rtfGrammer.y"
|
||||
typedef union {
|
||||
int number;
|
||||
const char *text;
|
||||
|
@ -961,99 +961,99 @@ yyreduce:
|
|||
switch (yyn) {
|
||||
|
||||
case 1:
|
||||
#line 159 "Parsers/rtfGrammer.y"
|
||||
#line 159 "rtfGrammer.y"
|
||||
{ GSRTFstart(ctxt); ;
|
||||
break;}
|
||||
case 2:
|
||||
#line 159 "Parsers/rtfGrammer.y"
|
||||
#line 159 "rtfGrammer.y"
|
||||
{ GSRTFstop(ctxt); ;
|
||||
break;}
|
||||
case 4:
|
||||
#line 162 "Parsers/rtfGrammer.y"
|
||||
#line 162 "rtfGrammer.y"
|
||||
{ yyval.number = 1; ;
|
||||
break;}
|
||||
case 5:
|
||||
#line 163 "Parsers/rtfGrammer.y"
|
||||
#line 163 "rtfGrammer.y"
|
||||
{ yyval.number = 2; ;
|
||||
break;}
|
||||
case 6:
|
||||
#line 164 "Parsers/rtfGrammer.y"
|
||||
#line 164 "rtfGrammer.y"
|
||||
{ yyval.number = 3; ;
|
||||
break;}
|
||||
case 7:
|
||||
#line 165 "Parsers/rtfGrammer.y"
|
||||
#line 165 "rtfGrammer.y"
|
||||
{ yyval.number = 4; ;
|
||||
break;}
|
||||
case 12:
|
||||
#line 172 "Parsers/rtfGrammer.y"
|
||||
#line 172 "rtfGrammer.y"
|
||||
{ GSRTFmangleText(ctxt, yyvsp[0].text); free((void *)yyvsp[0].text); ;
|
||||
break;}
|
||||
case 14:
|
||||
#line 176 "Parsers/rtfGrammer.y"
|
||||
#line 176 "rtfGrammer.y"
|
||||
{ GSRTFopenBlock(ctxt, NO); ;
|
||||
break;}
|
||||
case 15:
|
||||
#line 176 "Parsers/rtfGrammer.y"
|
||||
#line 176 "rtfGrammer.y"
|
||||
{ GSRTFcloseBlock(ctxt, NO); ;
|
||||
break;}
|
||||
case 16:
|
||||
#line 177 "Parsers/rtfGrammer.y"
|
||||
#line 177 "rtfGrammer.y"
|
||||
{ GSRTFopenBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 17:
|
||||
#line 177 "Parsers/rtfGrammer.y"
|
||||
#line 177 "rtfGrammer.y"
|
||||
{ GSRTFcloseBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 18:
|
||||
#line 178 "Parsers/rtfGrammer.y"
|
||||
#line 178 "rtfGrammer.y"
|
||||
{ GSRTFopenBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 19:
|
||||
#line 178 "Parsers/rtfGrammer.y"
|
||||
#line 178 "rtfGrammer.y"
|
||||
{ GSRTFcloseBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 20:
|
||||
#line 179 "Parsers/rtfGrammer.y"
|
||||
#line 179 "rtfGrammer.y"
|
||||
{ GSRTFopenBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 21:
|
||||
#line 179 "Parsers/rtfGrammer.y"
|
||||
#line 179 "rtfGrammer.y"
|
||||
{ GSRTFcloseBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 22:
|
||||
#line 180 "Parsers/rtfGrammer.y"
|
||||
#line 180 "rtfGrammer.y"
|
||||
{ GSRTFopenBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 23:
|
||||
#line 180 "Parsers/rtfGrammer.y"
|
||||
#line 180 "rtfGrammer.y"
|
||||
{ GSRTFcloseBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 24:
|
||||
#line 181 "Parsers/rtfGrammer.y"
|
||||
#line 181 "rtfGrammer.y"
|
||||
{ GSRTFopenBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 25:
|
||||
#line 181 "Parsers/rtfGrammer.y"
|
||||
#line 181 "rtfGrammer.y"
|
||||
{ GSRTFcloseBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 26:
|
||||
#line 182 "Parsers/rtfGrammer.y"
|
||||
#line 182 "rtfGrammer.y"
|
||||
{ GSRTFopenBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 27:
|
||||
#line 182 "Parsers/rtfGrammer.y"
|
||||
#line 182 "rtfGrammer.y"
|
||||
{ GSRTFcloseBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 28:
|
||||
#line 183 "Parsers/rtfGrammer.y"
|
||||
#line 183 "rtfGrammer.y"
|
||||
{ GSRTFopenBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 29:
|
||||
#line 183 "Parsers/rtfGrammer.y"
|
||||
#line 183 "rtfGrammer.y"
|
||||
{ GSRTFcloseBlock(ctxt, YES); ;
|
||||
break;}
|
||||
case 31:
|
||||
#line 192 "Parsers/rtfGrammer.y"
|
||||
#line 192 "rtfGrammer.y"
|
||||
{ int font;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1063,7 +1063,7 @@ case 31:
|
|||
GSRTFfontNumber(ctxt, font); ;
|
||||
break;}
|
||||
case 32:
|
||||
#line 199 "Parsers/rtfGrammer.y"
|
||||
#line 199 "rtfGrammer.y"
|
||||
{ int size;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1073,7 +1073,7 @@ case 32:
|
|||
GSRTFfontSize(ctxt, size); ;
|
||||
break;}
|
||||
case 33:
|
||||
#line 206 "Parsers/rtfGrammer.y"
|
||||
#line 206 "rtfGrammer.y"
|
||||
{ int width;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1083,7 +1083,7 @@ case 33:
|
|||
GSRTFpaperWidth(ctxt, width);;
|
||||
break;}
|
||||
case 34:
|
||||
#line 213 "Parsers/rtfGrammer.y"
|
||||
#line 213 "rtfGrammer.y"
|
||||
{ int height;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1093,7 +1093,7 @@ case 34:
|
|||
GSRTFpaperHeight(ctxt, height);;
|
||||
break;}
|
||||
case 35:
|
||||
#line 220 "Parsers/rtfGrammer.y"
|
||||
#line 220 "rtfGrammer.y"
|
||||
{ int margin;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1103,7 +1103,7 @@ case 35:
|
|||
GSRTFmarginLeft(ctxt, margin);;
|
||||
break;}
|
||||
case 36:
|
||||
#line 227 "Parsers/rtfGrammer.y"
|
||||
#line 227 "rtfGrammer.y"
|
||||
{ int margin;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1113,7 +1113,7 @@ case 36:
|
|||
GSRTFmarginRight(ctxt, margin); ;
|
||||
break;}
|
||||
case 37:
|
||||
#line 234 "Parsers/rtfGrammer.y"
|
||||
#line 234 "rtfGrammer.y"
|
||||
{ int margin;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1123,7 +1123,7 @@ case 37:
|
|||
GSRTFmarginTop(ctxt, margin); ;
|
||||
break;}
|
||||
case 38:
|
||||
#line 241 "Parsers/rtfGrammer.y"
|
||||
#line 241 "rtfGrammer.y"
|
||||
{ int margin;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1133,7 +1133,7 @@ case 38:
|
|||
GSRTFmarginButtom(ctxt, margin); ;
|
||||
break;}
|
||||
case 39:
|
||||
#line 248 "Parsers/rtfGrammer.y"
|
||||
#line 248 "rtfGrammer.y"
|
||||
{ int indent;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1143,7 +1143,7 @@ case 39:
|
|||
GSRTFfirstLineIndent(ctxt, indent); ;
|
||||
break;}
|
||||
case 40:
|
||||
#line 255 "Parsers/rtfGrammer.y"
|
||||
#line 255 "rtfGrammer.y"
|
||||
{ int indent;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1153,7 +1153,7 @@ case 40:
|
|||
GSRTFleftIndent(ctxt, indent);;
|
||||
break;}
|
||||
case 41:
|
||||
#line 262 "Parsers/rtfGrammer.y"
|
||||
#line 262 "rtfGrammer.y"
|
||||
{ int indent;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1163,7 +1163,7 @@ case 41:
|
|||
GSRTFrightIndent(ctxt, indent);;
|
||||
break;}
|
||||
case 42:
|
||||
#line 269 "Parsers/rtfGrammer.y"
|
||||
#line 269 "rtfGrammer.y"
|
||||
{ int location;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1173,23 +1173,23 @@ case 42:
|
|||
GSRTFtabstop(ctxt, location);;
|
||||
break;}
|
||||
case 43:
|
||||
#line 276 "Parsers/rtfGrammer.y"
|
||||
#line 276 "rtfGrammer.y"
|
||||
{ GSRTFalignCenter(ctxt); ;
|
||||
break;}
|
||||
case 44:
|
||||
#line 277 "Parsers/rtfGrammer.y"
|
||||
#line 277 "rtfGrammer.y"
|
||||
{ GSRTFalignJustified(ctxt); ;
|
||||
break;}
|
||||
case 45:
|
||||
#line 278 "Parsers/rtfGrammer.y"
|
||||
#line 278 "rtfGrammer.y"
|
||||
{ GSRTFalignLeft(ctxt); ;
|
||||
break;}
|
||||
case 46:
|
||||
#line 279 "Parsers/rtfGrammer.y"
|
||||
#line 279 "rtfGrammer.y"
|
||||
{ GSRTFalignRight(ctxt); ;
|
||||
break;}
|
||||
case 47:
|
||||
#line 280 "Parsers/rtfGrammer.y"
|
||||
#line 280 "rtfGrammer.y"
|
||||
{ int space;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1199,19 +1199,19 @@ case 47:
|
|||
GSRTFspaceAbove(ctxt, space); ;
|
||||
break;}
|
||||
case 48:
|
||||
#line 287 "Parsers/rtfGrammer.y"
|
||||
#line 287 "rtfGrammer.y"
|
||||
{ GSRTFlineSpace(ctxt, yyvsp[0].cmd.parameter); ;
|
||||
break;}
|
||||
case 49:
|
||||
#line 288 "Parsers/rtfGrammer.y"
|
||||
#line 288 "rtfGrammer.y"
|
||||
{ GSRTFdefaultParagraph(ctxt); ;
|
||||
break;}
|
||||
case 50:
|
||||
#line 289 "Parsers/rtfGrammer.y"
|
||||
#line 289 "rtfGrammer.y"
|
||||
{ GSRTFstyle(ctxt, yyvsp[0].cmd.parameter); ;
|
||||
break;}
|
||||
case 51:
|
||||
#line 290 "Parsers/rtfGrammer.y"
|
||||
#line 290 "rtfGrammer.y"
|
||||
{ int color;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1221,7 +1221,7 @@ case 51:
|
|||
GSRTFcolorbg(ctxt, color); ;
|
||||
break;}
|
||||
case 52:
|
||||
#line 297 "Parsers/rtfGrammer.y"
|
||||
#line 297 "rtfGrammer.y"
|
||||
{ int color;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1231,7 +1231,7 @@ case 52:
|
|||
GSRTFcolorfg(ctxt, color); ;
|
||||
break;}
|
||||
case 53:
|
||||
#line 304 "Parsers/rtfGrammer.y"
|
||||
#line 304 "rtfGrammer.y"
|
||||
{ int script;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1241,7 +1241,7 @@ case 53:
|
|||
GSRTFsubscript(ctxt, script); ;
|
||||
break;}
|
||||
case 54:
|
||||
#line 311 "Parsers/rtfGrammer.y"
|
||||
#line 311 "rtfGrammer.y"
|
||||
{ int script;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty)
|
||||
|
@ -1251,7 +1251,7 @@ case 54:
|
|||
GSRTFsuperscript(ctxt, script); ;
|
||||
break;}
|
||||
case 55:
|
||||
#line 318 "Parsers/rtfGrammer.y"
|
||||
#line 318 "rtfGrammer.y"
|
||||
{ BOOL on;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty || yyvsp[0].cmd.parameter)
|
||||
|
@ -1261,7 +1261,7 @@ case 55:
|
|||
GSRTFbold(ctxt, on); ;
|
||||
break;}
|
||||
case 56:
|
||||
#line 325 "Parsers/rtfGrammer.y"
|
||||
#line 325 "rtfGrammer.y"
|
||||
{ BOOL on;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty || yyvsp[0].cmd.parameter)
|
||||
|
@ -1271,7 +1271,7 @@ case 56:
|
|||
GSRTFitalic(ctxt, on); ;
|
||||
break;}
|
||||
case 57:
|
||||
#line 332 "Parsers/rtfGrammer.y"
|
||||
#line 332 "rtfGrammer.y"
|
||||
{ BOOL on;
|
||||
|
||||
if (yyvsp[0].cmd.isEmpty || yyvsp[0].cmd.parameter)
|
||||
|
@ -1281,74 +1281,74 @@ case 57:
|
|||
GSRTFunderline(ctxt, on); ;
|
||||
break;}
|
||||
case 58:
|
||||
#line 339 "Parsers/rtfGrammer.y"
|
||||
#line 339 "rtfGrammer.y"
|
||||
{ GSRTFunderline(ctxt, NO); ;
|
||||
break;}
|
||||
case 59:
|
||||
#line 340 "Parsers/rtfGrammer.y"
|
||||
#line 340 "rtfGrammer.y"
|
||||
{ GSRTFdefaultCharacterStyle(ctxt); ;
|
||||
break;}
|
||||
case 60:
|
||||
#line 341 "Parsers/rtfGrammer.y"
|
||||
#line 341 "rtfGrammer.y"
|
||||
{ GSRTFparagraph(ctxt); ;
|
||||
break;}
|
||||
case 61:
|
||||
#line 342 "Parsers/rtfGrammer.y"
|
||||
#line 342 "rtfGrammer.y"
|
||||
{ GSRTFparagraph(ctxt); ;
|
||||
break;}
|
||||
case 62:
|
||||
#line 343 "Parsers/rtfGrammer.y"
|
||||
#line 343 "rtfGrammer.y"
|
||||
{ GSRTFgenericRTFcommand(ctxt, yyvsp[0].cmd); ;
|
||||
break;}
|
||||
case 67:
|
||||
#line 361 "Parsers/rtfGrammer.y"
|
||||
#line 361 "rtfGrammer.y"
|
||||
{ GSRTFregisterFont(ctxt, yyvsp[0].text, yyvsp[-2].number, yyvsp[-3].cmd.parameter);
|
||||
free((void *)yyvsp[0].text); ;
|
||||
break;}
|
||||
case 73:
|
||||
#line 374 "Parsers/rtfGrammer.y"
|
||||
#line 374 "rtfGrammer.y"
|
||||
{ yyval.number = RTFfamilyNil - RTFfamilyNil; ;
|
||||
break;}
|
||||
case 74:
|
||||
#line 375 "Parsers/rtfGrammer.y"
|
||||
#line 375 "rtfGrammer.y"
|
||||
{ yyval.number = RTFfamilyRoman - RTFfamilyNil; ;
|
||||
break;}
|
||||
case 75:
|
||||
#line 376 "Parsers/rtfGrammer.y"
|
||||
#line 376 "rtfGrammer.y"
|
||||
{ yyval.number = RTFfamilySwiss - RTFfamilyNil; ;
|
||||
break;}
|
||||
case 76:
|
||||
#line 377 "Parsers/rtfGrammer.y"
|
||||
#line 377 "rtfGrammer.y"
|
||||
{ yyval.number = RTFfamilyModern - RTFfamilyNil; ;
|
||||
break;}
|
||||
case 77:
|
||||
#line 378 "Parsers/rtfGrammer.y"
|
||||
#line 378 "rtfGrammer.y"
|
||||
{ yyval.number = RTFfamilyScript - RTFfamilyNil; ;
|
||||
break;}
|
||||
case 78:
|
||||
#line 379 "Parsers/rtfGrammer.y"
|
||||
#line 379 "rtfGrammer.y"
|
||||
{ yyval.number = RTFfamilyDecor - RTFfamilyNil; ;
|
||||
break;}
|
||||
case 79:
|
||||
#line 380 "Parsers/rtfGrammer.y"
|
||||
#line 380 "rtfGrammer.y"
|
||||
{ yyval.number = RTFfamilyTech - RTFfamilyNil; ;
|
||||
break;}
|
||||
case 83:
|
||||
#line 397 "Parsers/rtfGrammer.y"
|
||||
#line 397 "rtfGrammer.y"
|
||||
{
|
||||
GSRTFaddColor(ctxt, yyvsp[-3].cmd.parameter, yyvsp[-2].cmd.parameter, yyvsp[-1].cmd.parameter);
|
||||
free((void *)yyvsp[0].text);
|
||||
;
|
||||
break;}
|
||||
case 84:
|
||||
#line 402 "Parsers/rtfGrammer.y"
|
||||
#line 402 "rtfGrammer.y"
|
||||
{
|
||||
GSRTFaddDefaultColor(ctxt);
|
||||
free((void *)yyvsp[0].text);
|
||||
;
|
||||
break;}
|
||||
case 85:
|
||||
#line 411 "Parsers/rtfGrammer.y"
|
||||
#line 411 "rtfGrammer.y"
|
||||
{ yylsp[0].first_line; ;
|
||||
break;}
|
||||
}
|
||||
|
@ -1549,7 +1549,7 @@ yyerrhandle:
|
|||
yystate = yyn;
|
||||
goto yynewstate;
|
||||
}
|
||||
#line 414 "Parsers/rtfGrammer.y"
|
||||
#line 414 "rtfGrammer.y"
|
||||
|
||||
|
||||
/* some C code here */
|
|
@ -54,16 +54,17 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "Parsers/rtfScanner.h"
|
||||
#include "rtfScanner.h"
|
||||
|
||||
/* this context is passed to the interface functions */
|
||||
typedef void * GSRTFctxt;
|
||||
#define YYPARSE_PARAM ctxt, lctxt
|
||||
#define YYLEX_PARAM lctxt
|
||||
#define CTXT ctxt
|
||||
|
||||
#define YYERROR_VERBOSE
|
||||
|
||||
#include "rtfConsumerFunctions.h"
|
||||
#include "RTFConsumerFunctions.h"
|
||||
|
||||
%}
|
||||
|
||||
|
@ -156,7 +157,7 @@ typedef void * GSRTFctxt;
|
|||
|
||||
%%
|
||||
|
||||
rtfFile: '{' { GSRTFstart(ctxt); } RTFstart rtfCharset rtfIngredients { GSRTFstop(ctxt); } '}'
|
||||
rtfFile: '{' { GSRTFstart(CTXT); } RTFstart rtfCharset rtfIngredients { GSRTFstop(CTXT); } '}'
|
||||
;
|
||||
|
||||
rtfCharset: RTFansi { $$ = 1; }
|
||||
|
@ -169,18 +170,18 @@ rtfIngredients: /* empty */
|
|||
| rtfIngredients rtfFontList
|
||||
| rtfIngredients rtfColorDef
|
||||
| rtfIngredients rtfStatement
|
||||
| rtfIngredients RTFtext { GSRTFmangleText(ctxt, $2); free((void *)$2); }
|
||||
| rtfIngredients RTFtext { GSRTFmangleText(CTXT, $2); free((void *)$2); }
|
||||
| rtfIngredients rtfBlock
|
||||
;
|
||||
|
||||
rtfBlock: '{' { GSRTFopenBlock(ctxt, NO); } rtfIngredients '}' { GSRTFcloseBlock(ctxt, NO); }
|
||||
| '{' { GSRTFopenBlock(ctxt, YES); } RTFignore rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
|
||||
| '{' { GSRTFopenBlock(ctxt, YES); } RTFinfo rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
|
||||
| '{' { GSRTFopenBlock(ctxt, YES); } RTFstylesheet rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
|
||||
| '{' { GSRTFopenBlock(ctxt, YES); } RTFfootnote rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
|
||||
| '{' { GSRTFopenBlock(ctxt, YES); } RTFheader rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
|
||||
| '{' { GSRTFopenBlock(ctxt, YES); } RTFfooter rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
|
||||
| '{' { GSRTFopenBlock(ctxt, YES); } RTFpict rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
|
||||
rtfBlock: '{' { GSRTFopenBlock(CTXT, NO); } rtfIngredients '}' { GSRTFcloseBlock(CTXT, NO); }
|
||||
| '{' { GSRTFopenBlock(CTXT, YES); } RTFignore rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
||||
| '{' { GSRTFopenBlock(CTXT, YES); } RTFinfo rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
||||
| '{' { GSRTFopenBlock(CTXT, YES); } RTFstylesheet rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
||||
| '{' { GSRTFopenBlock(CTXT, YES); } RTFfootnote rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
||||
| '{' { GSRTFopenBlock(CTXT, YES); } RTFheader rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
||||
| '{' { GSRTFopenBlock(CTXT, YES); } RTFfooter rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
||||
| '{' { GSRTFopenBlock(CTXT, YES); } RTFpict rtfIngredients '}' { GSRTFcloseBlock(CTXT, YES); }
|
||||
| '{' '}' /* empty */
|
||||
;
|
||||
|
||||
|
@ -195,152 +196,152 @@ rtfStatement: RTFfont { int font;
|
|||
font = 0;
|
||||
else
|
||||
font = $1.parameter;
|
||||
GSRTFfontNumber(ctxt, font); }
|
||||
GSRTFfontNumber(CTXT, font); }
|
||||
| RTFfontSize { int size;
|
||||
|
||||
if ($1.isEmpty)
|
||||
size = 24;
|
||||
else
|
||||
size = $1.parameter;
|
||||
GSRTFfontSize(ctxt, size); }
|
||||
GSRTFfontSize(CTXT, size); }
|
||||
| RTFpaperWidth { int width;
|
||||
|
||||
if ($1.isEmpty)
|
||||
width = 12240;
|
||||
else
|
||||
width = $1.parameter;
|
||||
GSRTFpaperWidth(ctxt, width);}
|
||||
GSRTFpaperWidth(CTXT, width);}
|
||||
| RTFpaperHeight { int height;
|
||||
|
||||
if ($1.isEmpty)
|
||||
height = 15840;
|
||||
else
|
||||
height = $1.parameter;
|
||||
GSRTFpaperHeight(ctxt, height);}
|
||||
GSRTFpaperHeight(CTXT, height);}
|
||||
| RTFmarginLeft { int margin;
|
||||
|
||||
if ($1.isEmpty)
|
||||
margin = 1800;
|
||||
else
|
||||
margin = $1.parameter;
|
||||
GSRTFmarginLeft(ctxt, margin);}
|
||||
GSRTFmarginLeft(CTXT, margin);}
|
||||
| RTFmarginRight { int margin;
|
||||
|
||||
if ($1.isEmpty)
|
||||
margin = 1800;
|
||||
else
|
||||
margin = $1.parameter;
|
||||
GSRTFmarginRight(ctxt, margin); }
|
||||
GSRTFmarginRight(CTXT, margin); }
|
||||
| RTFmarginTop { int margin;
|
||||
|
||||
if ($1.isEmpty)
|
||||
margin = 1440;
|
||||
else
|
||||
margin = $1.parameter;
|
||||
GSRTFmarginTop(ctxt, margin); }
|
||||
GSRTFmarginTop(CTXT, margin); }
|
||||
| RTFmarginButtom { int margin;
|
||||
|
||||
if ($1.isEmpty)
|
||||
margin = 1440;
|
||||
else
|
||||
margin = $1.parameter;
|
||||
GSRTFmarginButtom(ctxt, margin); }
|
||||
GSRTFmarginButtom(CTXT, margin); }
|
||||
| RTFfirstLineIndent { int indent;
|
||||
|
||||
if ($1.isEmpty)
|
||||
indent = 0;
|
||||
else
|
||||
indent = $1.parameter;
|
||||
GSRTFfirstLineIndent(ctxt, indent); }
|
||||
GSRTFfirstLineIndent(CTXT, indent); }
|
||||
| RTFleftIndent { int indent;
|
||||
|
||||
if ($1.isEmpty)
|
||||
indent = 0;
|
||||
else
|
||||
indent = $1.parameter;
|
||||
GSRTFleftIndent(ctxt, indent);}
|
||||
GSRTFleftIndent(CTXT, indent);}
|
||||
| RTFrightIndent { int indent;
|
||||
|
||||
if ($1.isEmpty)
|
||||
indent = 0;
|
||||
else
|
||||
indent = $1.parameter;
|
||||
GSRTFrightIndent(ctxt, indent);}
|
||||
GSRTFrightIndent(CTXT, indent);}
|
||||
| RTFtabstop { int location;
|
||||
|
||||
if ($1.isEmpty)
|
||||
location = 0;
|
||||
else
|
||||
location = $1.parameter;
|
||||
GSRTFtabstop(ctxt, location);}
|
||||
| RTFalignCenter { GSRTFalignCenter(ctxt); }
|
||||
| RTFalignJustified { GSRTFalignJustified(ctxt); }
|
||||
| RTFalignLeft { GSRTFalignLeft(ctxt); }
|
||||
| RTFalignRight { GSRTFalignRight(ctxt); }
|
||||
GSRTFtabstop(CTXT, location);}
|
||||
| RTFalignCenter { GSRTFalignCenter(CTXT); }
|
||||
| RTFalignJustified { GSRTFalignJustified(CTXT); }
|
||||
| RTFalignLeft { GSRTFalignLeft(CTXT); }
|
||||
| RTFalignRight { GSRTFalignRight(CTXT); }
|
||||
| RTFspaceAbove { int space;
|
||||
|
||||
if ($1.isEmpty)
|
||||
space = 0;
|
||||
else
|
||||
space = $1.parameter;
|
||||
GSRTFspaceAbove(ctxt, space); }
|
||||
| RTFlineSpace { GSRTFlineSpace(ctxt, $1.parameter); }
|
||||
| RTFdefaultParagraph { GSRTFdefaultParagraph(ctxt); }
|
||||
| RTFstyle { GSRTFstyle(ctxt, $1.parameter); }
|
||||
GSRTFspaceAbove(CTXT, space); }
|
||||
| RTFlineSpace { GSRTFlineSpace(CTXT, $1.parameter); }
|
||||
| RTFdefaultParagraph { GSRTFdefaultParagraph(CTXT); }
|
||||
| RTFstyle { GSRTFstyle(CTXT, $1.parameter); }
|
||||
| RTFcolorbg { int color;
|
||||
|
||||
if ($1.isEmpty)
|
||||
color = 0;
|
||||
else
|
||||
color = $1.parameter;
|
||||
GSRTFcolorbg(ctxt, color); }
|
||||
GSRTFcolorbg(CTXT, color); }
|
||||
| RTFcolorfg { int color;
|
||||
|
||||
if ($1.isEmpty)
|
||||
color = 0;
|
||||
else
|
||||
color = $1.parameter;
|
||||
GSRTFcolorfg(ctxt, color); }
|
||||
GSRTFcolorfg(CTXT, color); }
|
||||
| RTFsubscript { int script;
|
||||
|
||||
if ($1.isEmpty)
|
||||
script = 6;
|
||||
else
|
||||
script = $1.parameter;
|
||||
GSRTFsubscript(ctxt, script); }
|
||||
GSRTFsubscript(CTXT, script); }
|
||||
| RTFsuperscript { int script;
|
||||
|
||||
if ($1.isEmpty)
|
||||
script = 6;
|
||||
else
|
||||
script = $1.parameter;
|
||||
GSRTFsuperscript(ctxt, script); }
|
||||
GSRTFsuperscript(CTXT, script); }
|
||||
| RTFbold { BOOL on;
|
||||
|
||||
if ($1.isEmpty || $1.parameter)
|
||||
on = YES;
|
||||
else
|
||||
on = NO;
|
||||
GSRTFbold(ctxt, on); }
|
||||
GSRTFbold(CTXT, on); }
|
||||
| RTFitalic { BOOL on;
|
||||
|
||||
if ($1.isEmpty || $1.parameter)
|
||||
on = YES;
|
||||
else
|
||||
on = NO;
|
||||
GSRTFitalic(ctxt, on); }
|
||||
GSRTFitalic(CTXT, on); }
|
||||
| RTFunderline { BOOL on;
|
||||
|
||||
if ($1.isEmpty || $1.parameter)
|
||||
on = YES;
|
||||
else
|
||||
on = NO;
|
||||
GSRTFunderline(ctxt, on); }
|
||||
| RTFunderlineStop { GSRTFunderline(ctxt, NO); }
|
||||
| RTFplain { GSRTFdefaultCharacterStyle(ctxt); }
|
||||
| RTFparagraph { GSRTFparagraph(ctxt); }
|
||||
| RTFrow { GSRTFparagraph(ctxt); }
|
||||
| RTFOtherStatement { GSRTFgenericRTFcommand(ctxt, $1); }
|
||||
GSRTFunderline(CTXT, on); }
|
||||
| RTFunderlineStop { GSRTFunderline(CTXT, NO); }
|
||||
| RTFplain { GSRTFdefaultCharacterStyle(CTXT); }
|
||||
| RTFparagraph { GSRTFparagraph(CTXT); }
|
||||
| RTFrow { GSRTFparagraph(CTXT); }
|
||||
| RTFOtherStatement { GSRTFgenericRTFcommand(CTXT, $1); }
|
||||
;
|
||||
|
||||
/*
|
||||
|
@ -358,7 +359,7 @@ rtfFonts:
|
|||
|
||||
/* the first RTFfont tags the font with a number */
|
||||
/* RTFtext introduces the fontName */
|
||||
rtfFontStatement: RTFfont rtfFontFamily rtfFontAttrs RTFtext { GSRTFregisterFont(ctxt, $4, $2, $1.parameter);
|
||||
rtfFontStatement: RTFfont rtfFontFamily rtfFontAttrs RTFtext { GSRTFregisterFont(CTXT, $4, $2, $1.parameter);
|
||||
free((void *)$4); }
|
||||
;
|
||||
|
||||
|
@ -395,12 +396,12 @@ rtfColors: /* empty */
|
|||
/* We get the ';' as RTFText */
|
||||
rtfColorStatement: RTFred RTFgreen RTFblue RTFtext
|
||||
{
|
||||
GSRTFaddColor(ctxt, $1.parameter, $2.parameter, $3.parameter);
|
||||
GSRTFaddColor(CTXT, $1.parameter, $2.parameter, $3.parameter);
|
||||
free((void *)$4);
|
||||
}
|
||||
| RTFtext
|
||||
{
|
||||
GSRTFaddDefaultColor(ctxt);
|
||||
GSRTFaddDefaultColor(CTXT);
|
||||
free((void *)$1);
|
||||
}
|
||||
;
|
|
@ -26,8 +26,8 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "Parsers/rtfScanner.h"
|
||||
#include "Parsers/rtfGrammer.tab.h"
|
||||
#include "rtfScanner.h"
|
||||
#include "rtfGrammer.tab.h"
|
||||
|
||||
// <§> scanner types and helpers
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue