OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Open Textfile written with DOS Editor

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Dominik
Guest





PostPosted: Thu Dec 04, 2003 12:14 am    Post subject: Open Textfile written with DOS Editor Reply with quote

Hello!

In Star Office 5.2 I used this procedure to open a DOS-Textfile:

Dim mFileProperties(1) As New com.sun.star.beans.PropertyValue
Dim oDoc as Object

mFileProperties(0).Name = "FilterName"
mFileProperties(0).Value = "swriter: Text DOS"
mFileProperties(1).Name = "FilterFlags"
mFileProperties(1).Value = ""
oDoc = oDesktop.loadComponentFromURL(sUrl,"_blank",0,mFileProperties())

But in OOo 1.1 this doesn't work because the filter "swriter: Text DOS" doesn't exist.

So, does anybody know how to open a DOS file with the correct character set?
I need it because my company will be using OOo soon...

Bye,
Dominik
Dilorenzo@vogelsang-bandstahl.de

Btw:
I know how to open a CSV file with the correct character set:

Function OpenCSVFile (sUrl As String) As Object

Dim mFileProperties(1) As New com.sun.star.beans.PropertyValue

mFileProperties(0).Name = "FilterName"
mFileProperties(0).Value = "scalc: Text - txt - csv (StarCalc)"
mFileProperties(1).Name = "FilterFlags"
mFileProperties(1).Value = "59/9,34,IBMPC_850,1,1/1/1/1/1/1/1/1"
OpenCSVFile = StarDesktop.loadComponentFromURL(sUrl,"_blank", 0,mFileProperties())
End Function
Back to top
dominik
Guest





PostPosted: Thu Dec 04, 2003 4:45 am    Post subject: Reply with quote

Hello!

I searched the OOo source code the last few hours and now found the solution:

You can open a DOS text file like this:

Dim mFileProperties(1) As New com.sun.star.beans.PropertyValue
Dim oDocConv as Object

mFileProperties(0).Name = "FilterName"
mFileProperties(0).Value = "Text (encoded)"
mFileProperties(1).Name = "FilterOptions"
mFileProperties(1).Value = "DOS,CRLF,,"
oDocConv = StarDesktop.loadComponentFromURL(sUrl,"_blank",0,mFileProperties())

Here's a sub which converts a DOS file to the 'normal' textfile format:

Sub ConvertFile(sUrl as String)
'Converts a DOS-File into a Windows-File
Dim mFileProperties(1) As New com.sun.star.beans.PropertyValue
Dim mFileSaveProps(1) As New com.sun.star.beans.PropertyValue
Dim oDocConv as Object

mFileProperties(0).Name = "FilterName"
mFileProperties(0).Value = "Text (encoded)"
mFileProperties(1).Name = "FilterOptions"
mFileProperties(1).Value = "DOS,CRLF,,"
oDocConv = StarDesktop.loadComponentFromURL(sUrl,"_blank",0,mFileProperties())

mFileSaveProps(0).Name = "Overwrite"
mFileSaveProps(0).Value = TRUE
mFileSaveProps(1).Name = "FilterName"
mFileSaveProps(1).Value = "Text"

oDocConv.storeAsURL(sUrl, mFileSaveProps())

oDocConv.dispose()

End Sub

I hope this is usefull for anybody out there ...
cYa,
Dominik
Dilorenzo@vogelsang-bandstahl.de
Back to top
dominik
Guest





PostPosted: Thu Dec 04, 2003 5:08 am    Post subject: Reply with quote

Sorry,
the solution above only works with OOo 1.0.3 not with version 1.1.

Any idea why?

Thanks in advance,
Dominik
Back to top
dominik
Guest





PostPosted: Thu Dec 04, 2003 5:55 am    Post subject: Reply with quote

...
and finally I've got the solution for OOo 1.1.
Very Happy
instead of DOS use IBM_850:
Quote:

Sub ConvertFile(sUrl as String)
'Converts a DOS-File into a Windows-File
Dim mFileProperties(1) As New com.sun.star.beans.PropertyValue
Dim mFileSaveProps(1) As New com.sun.star.beans.PropertyValue
Dim oDocConv as Object

mFileProperties(0).Name = "FilterName"
mFileProperties(0).Value = "Text (encoded)"
mFileProperties(1).Name = "FilterOptions"
mFileProperties(1).Value = "IBM_850,CRLF,,"
oDocConv = StarDesktop.loadComponentFromURL(sUrl,"_blank",0,mFileProperties())

mFileSaveProps(0).Name = "Overwrite"
mFileSaveProps(0).Value = TRUE
mFileSaveProps(1).Name = "FilterName"
mFileSaveProps(1).Value = "Text"

oDocConv.storeAsURL(sUrl, mFileSaveProps())

oDocConv.dispose()

End Sub
Back to top
avantman42
Super User
Super User


Joined: 28 Jul 2003
Posts: 751
Location: Staffordshire, UK

PostPosted: Thu Dec 04, 2003 5:58 am    Post subject: Reply with quote

dominik wrote:
Sorry,
the solution above only works with OOo 1.0.3 not with version 1.1.

Any idea why?


I've had a quick scan, and can't see any obvious problems. Could you give us some more details about what doesn't work, error messages, where it falls over, etc?

Russ
Back to top
View user's profile Send private message
Dominik
Guest





PostPosted: Thu Dec 04, 2003 6:33 am    Post subject: Reply with quote

The DOS files I have to open are created by old programms running in the steel company I work for.
My company is a German company, so in those DOS-files there are 'umlaute' as , , and (in html: ü ä ...)
With it didn't work I meant these characters weren't imported correct.

If I open such a file without a macro I do these steps:
menu / file / open
filename: DOSfile.txt
filter: Text (encode)
In the following Dialog I choose this charset:
DOS/OS2-850/International

Thanks a lot for thinking about my problem,
but as I allready posted I've got the solution for OOo 1.1 now.
(Charset is IBM_850 not DOS as in OOo 1.0.3)

cYa
Dominik
Dilorenzo@vogelsang-bandstahl.de
Back to top
avantman42
Super User
Super User


Joined: 28 Jul 2003
Posts: 751
Location: Staffordshire, UK

PostPosted: Thu Dec 04, 2003 6:37 am    Post subject: Reply with quote

Dominik wrote:
Thanks a lot for thinking about my problem,
but as I allready posted I've got the solution for OOo 1.1 now.
(Charset is IBM_850 not DOS as in OOo 1.0.3)


Looking at the times, I think you posted your solution as I was writing my post Rolling Eyes

Such is the way with web forums, I guess.

Russ
Back to top
View user's profile Send private message
dominik
General User
General User


Joined: 04 Dec 2003
Posts: 18
Location: Hagen (Westf.), Germany

PostPosted: Thu Dec 04, 2003 6:55 am    Post subject: Reply with quote

To whom it may concern:

Strings for other charsets can be found in this file:

Quote:

OOo_SOURCE\sal\inc\rtl\textenc.h
[/quote]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
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


Powered by phpBB © 2001, 2005 phpBB Group