Would it be possible to make a change to WPXInputStream::getDocumentOLEStream() to include a parameter for the name of the stream? It would make the class more generic. As far as I can tell, this is the only change that libwps requires to share basic code with libwpd. The change is basically (full patch attached):

-WPXInputStream * GSFInputStream::getDocumentOLEStream()
+WPXInputStream * GSFInputStream::getDocumentOLEStream(char * streamName)

If you don't like that, how about keeping the old method, adding a new method, and the old one calls the new method?

WPXInputStream * GSFInputStream::getDocumentOLEStream()
+WPXInputStream * GSFInputStream::getDocumentOLEStream(char * streamName)


In this phase, libwps is still a patch on libwpd. It makes it easy to test libwps by just patching the libwpd.so and then running OpenOffice.org, Abiword, and KWord. Actually with this small change, Abiword accepts .wps documents (if they are renamed to .wpd). However, OpenOffice.org would need the equivalent change to its getDocumentOleStream() here, and then it could use that code for both libwps and libwpd.

http://go-oo.org/lxr/source/sw/writerperfect/source/stream/WPXSvStream.h#017 http://go-oo.org/lxr/source/sw/writerperfect/source/stream/WPXSvStream.cxx#110 http://go-oo.org/lxr/source/sw/writerperfect/source/filter/WordPerfectImportFilter.cxx#211

KWord doesn't work with the modified "libwpd+wps", and it seems to be because their PImport::convert() copies the whole document to WPXMemoryInputStream where getDocumentOLEStream() always returns NULL. It's a problem since all Works documents in over 10 years use OLE. Any suggestions? Should KWord just not use WPXMemoryInputStream?

http://websvn.kde.org/trunk/koffice/filters/kword/wordperfect/import/wpimport.cc?rev=540439&view=auto

BTW, the Works 3/4 format file filter is coming along and understands a good amount of formatting. It's available from SVN at http://libwpd.sourceforge.net . If you don't mind, I might release a modified libwpd RPM for people to try. (It would be labeled unofficial and experimental.)


Andrew
diff -up lib.original/GSFStream.cpp lib/GSFStream.cpp
--- lib.original/GSFStream.cpp	2005-12-05 06:53:48.000000000 -0700
+++ lib/GSFStream.cpp	2006-09-03 18:16:44.000000000 -0600
@@ -83,7 +83,7 @@ bool GSFInputStream::isOLEStream()
 	return false;
 }
 
-WPXInputStream * GSFInputStream::getDocumentOLEStream()
+WPXInputStream * GSFInputStream::getDocumentOLEStream(char * streamName)
 {
 	WPXInputStream *documentStream = NULL;
 
@@ -92,7 +92,7 @@ WPXInputStream * GSFInputStream::getDocu
 
 	if (m_ole)
 	{
-		GsfInput *document = gsf_infile_child_by_name(m_ole, "PerfectOffice_MAIN");
+		GsfInput *document = gsf_infile_child_by_name(m_ole, streamName);
 		if (document) 
 		{
 			documentStream = new GSFInputStream(document);
diff -up lib.original/GSFStream.h lib/GSFStream.h
--- lib.original/GSFStream.h	2005-12-05 06:53:48.000000000 -0700
+++ lib/GSFStream.h	2006-09-03 18:16:44.000000000 -0600
@@ -35,7 +35,7 @@ public:
 	virtual ~GSFInputStream();
 
 	virtual bool isOLEStream();
-	virtual WPXInputStream * getDocumentOLEStream();
+	virtual WPXInputStream * getDocumentOLEStream(char * streamName);
 
 	virtual const uint8_t *read(size_t numBytes, size_t &numBytesRead);
 	virtual int seek(long offset, WPX_SEEK_TYPE seekType);
diff -up lib.original/WPDocument.cpp lib/WPDocument.cpp
--- lib.original/WPDocument.cpp	2006-07-14 14:34:52.000000000 -0600
+++ lib/WPDocument.cpp	2006-09-03 18:18:26.000000000 -0600
@@ -75,7 +75,7 @@ WPDConfidence WPDocument::isFileFormatSu
 	// BIG BIG NOTE: very unsafe on partial content!!!
 	if (input->isOLEStream())
 	{
-		document = input->getDocumentOLEStream();
+		document = input->getDocumentOLEStream("PerfectOffice_MAIN");
 		if (document)
 			isDocumentOLE = true;
 		else
@@ -186,7 +186,7 @@ WPDResult WPDocument::parse(WPXInputStre
 	WPD_DEBUG_MSG(("WPDocument::parse()\n"));
 	if (input->isOLEStream())
 	{
-		document = input->getDocumentOLEStream();
+		document = input->getDocumentOLEStream("PerfectOffice_MAIN");
 		if (document)
 			isDocumentOLE = true;
 		else
diff -up lib.original/WPXMemoryStream.h lib/WPXMemoryStream.h
--- lib.original/WPXMemoryStream.h	2006-07-14 14:34:53.000000000 -0600
+++ lib/WPXMemoryStream.h	2006-09-03 18:16:44.000000000 -0600
@@ -33,7 +33,7 @@ public:
 	virtual ~WPXMemoryInputStream();
 
 	virtual bool isOLEStream() { return false; }
-	virtual WPXInputStream * getDocumentOLEStream() { return NULL; }
+	virtual WPXInputStream * getDocumentOLEStream(char * streamName) { return NULL; }
 	
 	const virtual uint8_t *read(size_t numBytes, size_t &numBytesRead);
 	virtual int seek(long offset, WPX_SEEK_TYPE seekType);
diff -up lib.original/WPXStream.h lib/WPXStream.h
--- lib.original/WPXStream.h	2006-07-14 14:34:53.000000000 -0600
+++ lib/WPXStream.h	2006-09-03 18:16:44.000000000 -0600
@@ -52,7 +52,7 @@ public:
 	\return Should be a NULL pointer, if the \c PerfectOffice_MAIN stream does not exist inside the OLE2 storage
 	or if the input stream is not an OLE2 storage.
 	*/
-	virtual WPXInputStream * getDocumentOLEStream() = 0;
+	virtual WPXInputStream * getDocumentOLEStream(char * streamName) = 0;
 
 	/**
 	Tries to read a given number of bytes starting from the current position inside the input stream.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Libwpd-devel mailing list
Libwpd-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libwpd-devel

Reply via email to