Skip to content

Commit

Permalink
Moved text conversion classes to separate bundle
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10755 72102866-910b-0410-8b05-ffd578937521
  • Loading branch information
afedor committed Aug 21, 2001
1 parent e4dd491 commit 30d3fd1
Show file tree
Hide file tree
Showing 22 changed files with 409 additions and 844 deletions.
1 change: 1 addition & 0 deletions .cvsignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ config.cache
config.make
gnustep-gui.spec
gnustep-gui-debug.spec
gui.make
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2001-08-21 Adam Fedor <[email protected]>

* 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 <[email protected]>

* Source/NSTableColumn.m
Expand Down
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions Source/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions Source/GNUmakefile.postamble
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions Source/GNUmakefile.preamble
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
72 changes: 64 additions & 8 deletions Source/NSAttributedString.m
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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,
Expand All @@ -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];
}
Expand All @@ -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];
}
Expand Down
Loading

0 comments on commit 30d3fd1

Please sign in to comment.