You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@openoffice.apache.org by khammonh <kh...@gmail.com> on 2015/12/07 08:19:22 UTC

Re: XStorable object thrown an exception with error code 283

Thank Bernard
On Menu Tools > Options, Load/Save > General
we can set only filter but not Destination folder nor Filename .
I still prefer programmatically method so that the user wouldn't have to 
worry file folder location, file name and filter once they click SaveAs menu 
a proper
value of properties of SaveFile Dialog has been set and display . I see a 
dialog box class in OpenOffice namespace , I think there is SaveFile Dialog 
associate with document but it suppose to be
private member that we can't directly access but it should be an interface 
that we could get access to those properties of this dialog instant. So far 
I couldn't find it in the documentation (Wiki) .
Did you ever set these properties programmatically.

Regards


-----Original Message----- 
From: Bernard Marcelly
Sent: Monday, November 30, 2015 8:32 PM
To: api@openoffice.apache.org
Subject: Re: XStorable object thrown an exception with error code 283

Hi,
This is, in OpenOffice Basic, an equivalent to OpenOffice Basic 
ConvertToURL()

Function convertAddressToURL(SystemPath As String)
Dim fcp As Object

' I suppose you know how to instantiate a service in your language...
fcp = CreateUnoService("com.sun.star.ucb.FileContentProvider")
convertAddressToURL = fcp.getFileURLFromSystemPath("", SystemPath)
End Function

Compare your simple method to this example with a non-ASCII character:

Dim s As String, t As String

s = "C:\Composers\Camille Saint-Saëns"
t = convertAddressToURL(s)
MsgBox t

> If possible I would like to get access to
> SaveFile Dialog of this document and set FileName property as well as File
> filter so the user just click save as and close the document.

Without any programming:
Menu Tools > Options, Load/Save > General
Document type : Spreadsheet
Always save as : Microsoft Excel 97/2000/XP

Regards/Bernard

khammonh a écrit le 2015-11-30 06:41 :
> Bonjour Bernard et merci bien pour votre conseil , Je suis desole que je
> n'ecrire pas bien en Francais . Depuis 20 ans que je ne parle pas et 
> n'ecrire
> pas en Francais donc je vais ecrirer en Anglais tout de suit.
>
> I couldn't find the class from which I could cast (convert) to
> unoidl.com.sun.star.ucb.XFileIdentifierConverter as the method you 
> mentioned
> here is the member of this interface and interface as we know couldn't
> instantiate with a sub New so it is not possible to invoke the method 
> without a
> proper casting . So I did the conversion the URL from file path by using
> String.Replace function it work perfectly and I can save as URL.
> By doing this the instant of Spreadsheet object still alive and need to 
> close .
> Actually I don't want to confuse the user with this (they may not aware 
> that the
> file has been saved programmatically as they still see the document name
> untitled at the top left Corner)  . If possible I would like to get access 
> to
> SaveFile Dialog of this document and set FileName property as well as File
> filter so the user just click save as and close the document.
> Any suggestion or advise.
>
> Regards
> Khammonh
>
> -----Original Message----- From: Bernard Marcelly
> Sent: Saturday, November 28, 2015 3:13 AM
> To: api@openoffice.apache.org
> Subject: Re: XStorable object thrown an exception with error code 283
>
> Hi,
> An URL is not a Windows address preceded by "file:///".
> Even if you change \ into / it may still be incorrect, depending on the
> characters in the path.
> Example:
>       C:\Docs OpenOffice\Report_20151127
> URL : file:///C:/Docs%20OpenOffice/Report_20151127
> You can convert a system address into an URL with method
> getFileURLFromSystemPath() of service com.sun.star.ucb.FileContentProvider
>
> If the argument Filter is absent, you provide a null object. This is not
> incorrect, you must provide at least an empty array.
> The Overwrite option is True by default, so you don't need it.
>
> Bernard
>
>
> khammonh a écrit le 2015-11-27 10:18 :
>> Hi there
>> I have some problem when implementing Interface XStorable of
>> unoidl.com.sun.star.frame class .
>> I developed my own Library base on SDK here are method body of SaveDocAs 
>> and
>> SaveDocToFile
>>
>> Public Sub SaveDocAs(ByVal FileName As String, Optional ByVal Filter As
>> SpreadSheetFileFilter = SpreadSheetFileFilter.MS_Excel_97)
>>            Dim Store As XStorable
>>            Dim Prop() As PropertyValue = {New PropertyValue, New 
>> PropertyValue}
>>            'Dim MyUrl As String = FileName
>>            Dim MyUrl As String = "file:///" + FileName
>>            Store = CType(m_mxDocument, XStorable)
>>            If Filter = SpreadSheetFileFilter.DefaultOpenOffice Then
>>                Prop = Nothing
>>            Else
>>                Prop(0).Name = "FilterName"
>>                Prop(0).Value = New uno.Any(ParserFilter(Filter))
>>                Prop(1).Name = "Overwrite"
>>                Prop(1).Value = New uno.Any(True)
>>            End If
>>
>>            Store.storeAsURL(MyUrl, Prop)
>>        End Sub
>>
>> Public Sub SaveDocToFile(ByVal FileName As String, Optional ByVal Filter 
>> As
>> SpreadSheetFileFilter = SpreadSheetFileFilter.MS_Excel_97)
>>             Dim Store As XStorable
>>             Dim Prop() As PropertyValue = {New PropertyValue, New 
>> PropertyValue}
>>             Dim MyUrl As String = "file:///" + FileName
>>             Store = CType(m_mxDocument, XStorable)
>>             Prop(0).Name = "FilterName"
>>             Prop(0).Value = New uno.Any(ParserFilter(Filter))
>>             Prop(1).Name = "Overwrite"
>>             Prop(1).Value = New uno.Any(True)
>>             Store.storeToURL(MyUrl, Prop)
>>         End Sub
>>
>> when invoke this method on client application with the code fragment 
>> bellow
>>
>>                ExcelAttach = ExcelRoot & "\" & "Report_" &
>> ReportDate.ToShortDateString
>>
>>                 OO.SaveDocToFile(ExcelAttach,
>> OOClass.SpreadSheetHelper.SpreadSheetFileFilter.MS_Excel_97)
>> where ExcelAttach is a file path
>> I got an exception with error code 283
>>
>> Actually the document is opened by the app from a template file then the 
>> app
>> filled the sheets with content and need to save this file with above 
>> mentioned
>> method.
>> If I could set file location and filter of Document SaveFile dialog it 
>> would
>> be more easy then use these 2 methods . But I don’t know how to interact 
>> with
>> SaveFile dialog of OpenOffice .
>> Please if any body can help me.
>>
>> Thank in advance.
>>
>> Regards
>> Khammonh
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
> For additional commands, e-mail: api-help@openoffice.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
> For additional commands, e-mail: api-help@openoffice.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org