Welcome to NeoOffice developer notes and announcements
NeoOffice
Developer notes and announcements
 
 

Download or installation problems? Try these steps
Problems after upgrading to NeoOffice 2017? Try these steps


Support
· NeoOffice Support
· NeoWiki


Announcements
· Twitter @NeoOffice


Downloads
· Download NeoOffice


RSS Feeds
· Announcements Only
· All Posts


  
NeoOffice :: View topic - sxw file conversion for Mac not using openoffice.org
sxw file conversion for Mac not using openoffice.org
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    NeoOffice Forum Index -> OpenOffice.org X11 Testing
View previous topic :: View next topic  
Author Message
suzon
Guest





PostPosted: Tue Feb 08, 2005 4:36 pm    Post subject: sxw file conversion for Mac not using openoffice.org Reply with quote

Rolling Eyes 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.
Very Happy
Back to top
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Wed Feb 09, 2005 2:19 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Thu Feb 17, 2005 2:35 am    Post subject: Reply with quote

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:
Code:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

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 Sad

- yoxi
Back to top
View user's profile Send private message
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: Thu Feb 17, 2005 4:53 am    Post subject: Reply with quote

yoxi wrote:
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 Sad


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 wpd2sxw infile 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. Very Happy

Smokey

_________________
"[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
Back to top
View user's profile Send private message Visit poster's website
jakeOSX
Ninja
Ninja


Joined: Aug 12, 2003
Posts: 1373

PostPosted: Thu Feb 17, 2005 5:27 am    Post subject: Reply with quote

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)

anyway, that should work for you just fine.
Back to top
View user's profile Send private message
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Thu Feb 17, 2005 10:58 am    Post subject: Reply with quote

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...

- yoxi
Back to top
View user's profile Send private message
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: Thu Feb 17, 2005 5:29 pm    Post subject: Reply with quote

yoxi wrote:
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 Smile

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


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Fri Feb 18, 2005 1:36 am    Post subject: Reply with quote

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:
Code:
sed -e 's/<\/p>//g' -e 's/<head>/<head><meta http-equiv=\"Content-Type\" content=\"text\/html\; charset=utf-8\">/g' -e 's/\ \;//g' -e 's/<p class=\"P1\">/<p class=\"P2\">/g' ooo.html > ooo2.html; mv ooo2.html ooo.html

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.

- yoxi
Back to top
View user's profile Send private message
Terry Teague
Guest





PostPosted: Fri Feb 18, 2005 2:05 am    Post subject: Re: script for oo2txt Reply with quote

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.

Regards, Terry
Back to top
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Fri Feb 18, 2005 9:00 am    Post subject: Reply with quote

Hi terry

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.

Thanks for the various suggestions, folks.

- yoxi
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    NeoOffice Forum Index -> OpenOffice.org X11 Testing All times are GMT - 7 Hours
Page 1 of 1

 
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

Powered by phpBB © 2001, 2005 phpBB Group

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © Planamesa Inc.
NeoOffice is a registered trademark of Planamesa Inc. and may not be used without permission.
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.02 Seconds