Document format suggestion



I was writing up some of my thoughts on a word processor when I came up
with what I think is a pretty good model for document format conversions.
(I'm sure that other people have thought of it, but I wanted to put
it forward anyway.)  FYI, "Bob" is the hypothetical word processor.
Here's the snippet.

	Docment-type implementors: This is perhaps the most complicated
	part of Bob.  Bob needs to be able to take external docs which
	reside somewhere in the VFS and create a new Bob-doc based
	on them.  Similarly, Bob-docs need to be converted into the
	various external doc formats and sent somewhere in the VFS.
	One of these will be the Bob-XML flavor.  Another would be the
	postscript flavor (potentially bidirectional if someone converts
	ps2ascii to a filter), which would also be used with ghostview
	for print preview.  Others would be PDF, HTML, M$Word, Word
	Perfect and ASCII.

	It would be nice if these were themselves components, so that
	other programs, like the GIMP, Gnumeric, etc., can use them to
	write out their docs as well.

	I think of a document-type implementor, and I think of the formats
	to which he knows how to export.  To import an HTML doc, you would
	instantiate the HTML implementor, tell him the location of the
	document, and then tell him to export it to a BOB format.  You then
	create a new Bob instance on the resulting document, which is a new
	open document in your WP.  Another approach might be that the HTML
	doc implementor might know how to talk to a Bob object, and so he
	starts up a Bob instance and sends him a bunch of directives like:

		format->bold=TRUE;
		document->new_word="bananna";
		format->bold=FALSE;

	Which one is better?  Do you talk object-to-object, and have the
	target object pickle the document, or do you pickle the document
	yourself and then pass that to another object?	I personally
	prefer the object-to- object approach, as I think that it's easier
	to program.  I propose this model for incorporatin into GNOME.

	I really like this model for document conversion.  The Gnumeric-
	to-Bob conversion happens by a Gnumeric object leading a Bob object
	through creating a Bob document.  This happens when Gnumeric exports
	to Bob format, or when Bob imports from Gnumeric format.

	Neat idea: You have all of your document components registered
	somewhere.  When someone wants to import a document into Bob,
	how do you present them with the list of available formats?
	It's easy; you examine each object in the registry and see who
	supports Bob.  Even better, though, is that you can go beyond
	this.  For each document type which knows how to export to Bob,
	look for other types which can in turn export to that type!
	Break any cycles, remove any duplications, and you now have
	a new set of document types which are supported!  You should
	display these in gray, below the direct conversion options,
	because they will probably not be as good and they will take
	longer, but they are still possible.

	In this way, say Bob can export LaTeX but not postscript.
	PS would still be listed as an output option, but in gray and at
	the bottom.  Bob would have noticed that the LaTeX object can,
	in turn, convert to DVI, and that the DVI object can, in turn,
	convert to PS.  LaTeX is listed as a first-order export target,
	and DVI and PS are listed as second-order export targets.  This
	is an easy way to support other formats quickly until they are
	supported natively in your document component.

What do people think of this idea?  Am I on crack, or would this be
a good way to support document conversion, importing, and exporting
through all of GNOME?

--
Todd Graham Lewis            32°49'N,83°36'W          (800) 719-4664, x2804
******Linux******         MindSpring Enterprises      tlewis@mindspring.net



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]