Posted: Tue Feb 08, 2005 4:36 pm Post subject: sxw file conversion for Mac not using openoffice.org
i'd like to open sxw files received by email, without having to install openoffice.org on my mac. is it possible to convert these files? and how?
i tried to change the extension by .zip and .rar but got xml files which were just all code. i need to read these document urgently.
thank you to get back to me asap.
Visit this link to download a little script app that will convert writer/calc docs into either text or html format. It's not completely working - converting to html works, converting to text throws up an error. But with html you get all your information in readable form, which is what you want. Don't expect complex formatting to come out normal!
Once you've installed oo2txt into /usr/bin, save your mail-attached ooo file to the desktop, open a Terminal window and navigate to the desktop (cd ~/Desktop), then type e.g.:
oo2txt ooofile.sxw html > newname.html
This will write newname.html on your desktop where you can open it in a browser.
- yoxi
Last edited by yoxi on Thu Feb 17, 2005 2:37 am; edited 1 time in total
I'm working on (read: trawling for help on forums!) writing a bash script that runs oo2txt on a selected OOo file in Finder and then clears out some of the junk that makes the resulting html page hard to read - unnecessary tags and so on. Most particularly, the html needs a meta tag:
inserted into the head, as oo2txt generates a utf-8 html file, so safari needs the meta tag in order to display the unicode characters properly.
I'll keep you posted on this - currently, actually getting the bash script to take the path of the selected file from osascript in the first place is the stumbling block
I'll keep you posted on this - currently, actually getting the bash script to take the path of the selected file from osascript in the first place is the stumbling block
You know about "POSIX path" and "POSIX file" path transformations in AppleScript, right? And "quoted form", to handle spaces and other characters? That's what I do in my AppleScript to pass dropped files to wpd2sxw:
Code:
do shell script "/opt/wpcnv/bin/wpd2sxw " & quoted form of POSIX path of (cnvFile as alias) & " " & newPath
That's the part doing the actual wpd2sxwinfile outfile.
...POSIX file takes a UNIX path and converts it back to a Mac-style one.
'Course Terry's the real AppleScript guru in these parts.
Smokey _________________ "[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
i found a oo.o doc reader written in java... uh, somewhere. i think just did a google search if i remember. got it for work, since i can't install oo.o on my work machine, but apparently the JVM isn't up to speed either (has to have 1.4)
Yeah, thing is, I'm not writing an applescript (the AS part of my setup works fine) I'm trying to write a bash script that takes the current selected file from Finder using osascript. feh... I'll get there...
Yeah, thing is, I'm not writing an applescript (the AS part of my setup works fine) I'm trying to write a bash script
Right, I understood that
yoxi wrote:
that takes the current selected file from Finder using osascript. feh... I'll get there...
osascript=AppleScript (unless you have another osa language installed), so you could do the same thing. Or perhaps I don't understand where the problem is--actually getting the selected file rather than so much the path?
Smokey _________________ "[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
The problem is that what works fine directly from applescript fails when I invoke it through osascript in bash - I get fascinating error messages like:
Code:
osascript[2129] *** _NSAutoreleaseNoPool(): Object 0x393510 of class NSCFString autoreleased with no pool in place - just leaking
'/Win98/salvia/Accounts/anapanasati/anapanasati.sxc'
so it knows which selected file in Finder I'm talking about, it just won't play croquet with it.
Why in the first place? well, the html code comes out of oo2txt a bit spaz, so I wanted to run a few seds on it to clean it up. So I started with an AS to select the file, do shell script oo2txt on it, and then do shell script sed - this is the sed command:
Could I find a way to get AS to run this sed command? Absolutely not - I think it's all the quotes in it. So I'm trying to do the whole thing in bash instead, which is why I want the osascript 'get full path' to work, and it won't. Sigh, I say again.
Posted: Fri Feb 18, 2005 2:05 am Post subject: Re: script for oo2txt
yoxi wrote:
Why in the first place? well, the html code comes out of oo2txt a bit spaz, so I wanted to run a few seds on it to clean it up. So I started with an AS to select the file, do shell script oo2txt on it, and then do shell script sed - this is the sed command [deleted]:
Could I find a way to get AS to run this sed command? Absolutely not - I think it's all the quotes in it. So I'm trying to do the whole thing in bash instead, which is why I want the osascript 'get full path' to work, and it won't. Sigh, I say again.
Obviously there lots of ways to do this, and I don't want to discourage you from trying things.
What is the audience for your script? If you don't want to deal with AppleScript, and just want to use a shell script, you could just instruct users to run your script as follows :
1. Launch Terminal
2. Type (but don't press Return yet) : yoxis_famous_script
3. Type a space character
4. From Finder, drag the OpenOffice.org/NeoOffice.org document to the Terminal window
5. Press Return
As for the 'sed' problem - when I am faced with tricky 'sed' quoting problems what I sometimes do is echo the 'sed' commands without the tricky quoting to a temporary file, then use the "-f" option of 'sed' to make the 'sed' program come from the specified temporary file.
Finally, there might be alternative solutions than rolling your own. I'm involved with the Tidy HTML open source project, and Tidy is designed for this kind of cleaning up of HTML (although admittedly I haven't tried it on OOo converted documents). For more info, visit : http://tidy.sourceforge.net
If you have specific questions about any of this stuff, I will will try to help.
This is all getting kind of involved - ah, the interconnectedness of things! I've just been told about Tidy by koncept over at the OSXFAQ bbs, but unfortunately the html that oo2txt generates for spreadsheets is so evil that Tidy refuses to have it sit on its lap until someone else wipes its bottom first.
This little 'project' is currently just for the use of me and my work colleague, and for the moment I'll put up with my iKey assemblage that mixes bash and AS. I've tried and failed to get sed to work from within a do shell script, even using sed -f. In the end, it could well be that it's iKey that's causing the problem. Meanwhile my inelegant option does work... all I really want is to hit a key combo and have a selected file displayed quickly, and that's what I've got... but dammit! I should probably really be doing this in perl, or python, or lisp or something - I'm stuck at home ill and bored at the moment.
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 cannot download files in this forum