Patch to make Abiword use file extension to determine type

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
Guest

Patch to make Abiword use file extension to determine type

#1 Post by Guest »

Hi everybody!

Let me just start by saying that I really like Puppy and I admire the work you all do to make it even better. I installed Puppy on my usb pen-drive, booted up my laptop - and it just worked. I live in the world of Windows usually (not my choice) so I probably wouldn't have a first clue what to do if it didn't. Anyway, I've been following events since somewhere around version 0.98 and I always start the day by checking the puppy news page. A couple of days ago Barry posted something about a problem with Abiword not recognizing file types correctly and I read the response from the developers and thought I would give it a stab. Note that I'm far from a C++ guru and it took me a while to understand what was going on, but I think I now may have a working patch. I added a new switch called --useextension which overrides Abiword's file type detection mechanism. To print a file using this method would look something like this:

abiword --print=outputfile --useextension=.doc mydocument.doc

I developed the patch on Windows, but I have compiled Abiword successfully with the patch on Linux (Ubuntu 5.04). Since I'm embarrassingly ignorant when it comes to Linux, I can't tell you if it does the job or not. The archive contains only the patched sources:
  • ../abi/src/wp/ap/unix/ap_UnixApp.cpp
    ../abi/src/wp/ap/xp/ap_Args.h
    ../abi/src/wp/ap/xp/ap_Args.cpp
    ../abi/src/wp/ap/xp/ap_Convert.h
    ../abi/src/wp/ap/xp/ap_Convert.cpp
/Jonas

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#2 Post by BarryK »

Jonas,
That's great!
I have just downloaded it, tonight I'll compile it and test it in Puppy.
Things are moving along!

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#3 Post by BarryK »

Jonas,
Okay, I have compiled and tested it.
At first, it wasn't working ... :(
but, what I was doing was just trying to open a document, like:

# ./AbiWord-2.2 --useextension=.txt index.html

however then I realised that you haven't implemented filetype override for opening and viewing a document, only for commandline conversion...

# ./AbiWord-2.2 --print=index.ps --useextension=.txt index.html

...hey, it works :D
(in that example, Gsview shows the html code, not the end result)

Okay, this will be in Pup 1.0.3.
It looks like printing will be all go!

Jonas, you have posted above as "Guest". Could I have a name for mention in the News page?

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

Jonas provides a whale of a time

#4 Post by Lobster »

Hey good job Jonas,

We need printing. The marketing team is working on rosettes for winner pups. Not quite ready yet . . .

For now we bow our heads in awe . . .

Them Pups - so smart . . .
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

josa
Posts: 3
Joined: Wed 25 May 2005, 20:36
Location: Sweden

#5 Post by josa »

I'm registered as josa, but somehow I got logged out before I pressed the submit button. Your assumption is right, it's only printing that uses the extra parameter. If it's to any use I can try implementing it for file import/open, but I think that will be slightly more difficult.

/Jonas

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#6 Post by BarryK »

Jonas,
I posted a message to Abiword Bugzilla, here:

http://bugzilla.abisource.com/show_bug.cgi?id=8996

They have replied, could we provide patch files, using diff.

I've never done this before... anyone clued up on creating patches,
or difference files?

I've attached a tarball with the modified and the original files.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#7 Post by GuestToo »

i have never made a patch file

i think you run diff to make a patch file, something like:

diff oldfile.c newfile.c > myabi.patch

then a person can patch his source before compiling by typing:

patch -p1 < myabi.patch

here's a patch i used for bash 2.05b ... it patches bash so bash can find and execute rox appdirs as if they were executables (they are really dirs) ... this patched bash works ok in Puppy
http://www.kerofin.demon.co.uk/rox/patc ... dirs.patch

josa
Posts: 3
Joined: Wed 25 May 2005, 20:36
Location: Sweden

#8 Post by josa »

Barry,

What I did was to implement the idea outlined in the bug report with a bare minimum of changes to avoid breaking anything. If they (the Abiword developers) want to make a more thorough implementation of this new feature I fully understand. Since the change was so tiny I can write a manual diff here (I also attatched the real diffs). I should also mention that I only changed the Unix/Linux version of the application since this was intended for Puppy only.

ap_Convert.h
Line 50: changed print() to take an additional parameter (szFileExtension)

Code: Select all

void print(const char * file, GR_Graphics * pGraphics, const char * szFileExtension);
ap_Convert.cpp
Line 358: changed print() to take an additional parameter (szFileExtension)

Code: Select all

void AP_Convert::print(const char * szFile, GR_Graphics * pGraphics, const char * szFileExtension)
Line 362: changed this line and added som more lines to handle the extra parameter.

Code: Select all

UT_Error err;
if( !szFileExtension )
   err = pDoc->readFromFile(szFile, IEFT_Unknown, m_impProps.utf8_str());
else
   err = pDoc->readFromFile(szFile, IE_Imp::fileTypeForSuffix(szFileExtension), m_impProps.utf8_str());
ap_Args.h
Added an extra member variable:

Code: Select all

static const char * m_sFileExtension;
ap_Args.cpp
Initialized the extra member variable:

Code: Select all

const char * AP_Args::m_sFileExtension = NULL;
Added an extra entry in poptOption (right before the "name" parameter):

Code: Select all

{"useextension", '\0', POPT_ARG_STRING, &m_sFileExtension, 0, "Override document type detection by specifying a file extension", NULL},
ap_UnixApp.cpp
Line 1595: added the new parameter to the argument list

Code: Select all

conv.print (Args->m_sFile, pGraphics, Args->m_sFileExtension);
/Jonas
Last edited by josa on Sat 06 Aug 2005, 22:42, edited 1 time in total.

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#9 Post by BarryK »

Thanks, I'll let them know.

They are working on Abiword 2.4 and didn't want to introduce any more features, as they are at "feature freeze" stage ...but, I may have persuaded them to sneak this one in!

josa
Posts: 3
Joined: Wed 25 May 2005, 20:36
Location: Sweden

#10 Post by josa »

Well, it looks like the patch is approved by the Abiword developers with minor changes and will be added to the next release...

/Jonas

Post Reply