Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 23 Nov 2014, 07:08
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
Patch to make Abiword use file extension to determine type
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [10 Posts]  
Author Message
Guest
Guest


PostPosted: Wed 25 May 2005, 17:35    Post subject:  Patch to make Abiword use file extension to determine type  

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
Back to top
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7082
Location: Perth, Western Australia

PostPosted: Thu 26 May 2005, 02:47    Post subject:  

Jonas,
That's great!
I have just downloaded it, tonight I'll compile it and test it in Puppy.
Things are moving along!
Back to top
View user's profile Send private message Visit poster's website 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7082
Location: Perth, Western Australia

PostPosted: Thu 26 May 2005, 04:57    Post subject:  

Jonas,
Okay, I have compiled and tested it.
At first, it wasn't working ... Sad
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 Very Happy
(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?
Back to top
View user's profile Send private message Visit poster's website 
Lobster
Official Crustacean


Joined: 04 May 2005
Posts: 15117
Location: Paradox Realm

PostPosted: Thu 26 May 2005, 05:54    Post subject: Jonas provides a whale of a time  

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 WIKI
Back to top
View user's profile Send private message Visit poster's website 
josa

Joined: 25 May 2005
Posts: 3
Location: Sweden

PostPosted: Thu 26 May 2005, 07:25    Post subject:  

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
Back to top
View user's profile Send private message 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7082
Location: Perth, Western Australia

PostPosted: Fri 27 May 2005, 07:54    Post subject:  

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.
Back to top
View user's profile Send private message Visit poster's website 
GuestToo
Puppy Master

Joined: 04 May 2005
Posts: 4078

PostPosted: Fri 27 May 2005, 16:34    Post subject:  

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/patch/bash-2.05b-appdirs.patch
Back to top
View user's profile Send private message 
josa

Joined: 25 May 2005
Posts: 3
Location: Sweden

PostPosted: Fri 27 May 2005, 17:18    Post subject:  

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:

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:

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:

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:

static const char * m_sFileExtension;


ap_Args.cpp
Initialized the extra member variable:
Code:

const char * AP_Args::m_sFileExtension = NULL;

Added an extra entry in poptOption (right before the "name" parameter):
Code:

{"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:

conv.print (Args->m_sFile, pGraphics, Args->m_sFileExtension);


/Jonas

Last edited by josa on Sat 06 Aug 2005, 18:42; edited 1 time in total
Back to top
View user's profile Send private message 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7082
Location: Perth, Western Australia

PostPosted: Sat 28 May 2005, 10:01    Post subject:  

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!
Back to top
View user's profile Send private message Visit poster's website 
josa

Joined: 25 May 2005
Posts: 3
Location: Sweden

PostPosted: Tue 07 Jun 2005, 12:50    Post subject:  

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

/Jonas
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [10 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0716s ][ Queries: 12 (0.0069s) ][ GZIP on ]