Due to bug 39298, I've made a small macro to replace some characters in documents. If the filename of the document contains commas, the following error is displayed: "Type: com.sun.star.lang.IllegalArgumentException Message: URL seems to be an unsupported one" The error is at line: oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array()) If I remove the comma from the filename, the macro is running correctly. The command I'm using: libreoffice --nocrashreport --nodefault --nologo --nofirststartwizard --norestore "macro:///Standard.Module1.ReplaceNBHyphenHTML(/home/cristi/A string, a comma.doc)" The macro I'm using: Function MakePropertyValue( Optional cName As String, Optional uValue ) _ As com.sun.star.beans.PropertyValue Dim oPropertyValue As New com.sun.star.beans.PropertyValue If Not IsMissing( cName ) Then oPropertyValue.Name = cName EndIf If Not IsMissing( uValue ) Then oPropertyValue.Value = uValue EndIf MakePropertyValue() = oPropertyValue End Function Sub ReplaceNBHyphenHTML(cFile) cURL = ConvertToURL( cFile ) GlobalScope.BasicLibraries.LoadLibrary("Tools") oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array()) oReplace = ThisComponent.createReplaceDescriptor() oReplace.SearchCaseSensitive = True oReplace.SearchString = chr(clng("&H2011")) oReplace.ReplaceString = "-" ThisComponent.ReplaceAll(oReplace) sFile = GetFileNameWithoutExtension(oDoc.url) + ".html" sURL = ConvertToURL( sFile ) oDoc.storeAsURL(sURL, Array(MakePropertyValue("FilterName", "HTML (StarWriter)"),)) oDoc.close( True ) End Sub
@cristi falcas: From where is information that comma should be allowed? Does that problem really only affect macros related to writer?
I only tested with writer. There is another bug for calc (42308) about links to files that have commas in the name. About the question if commas should be allowed, it most certainly is a bug, because it should support all filenames valid on the operating system.
I have added into script this: Sub Test ReplaceNBHyphenHTML("/home/s/Hit,1.odt") End Sub When I start script from Basic IDE, it works correctly (file Hit,1.odt exist) In this case (IDE) line oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array()) produces error with any name if file not exist. No problem with comma When start from command line, problem appears. IMHO problem is with processing command line. Information about loadComponentFromURL is here http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide/StarDesktop About command line is here http://wiki.services.openoffice.org/wiki/Framework/Article/Command_Line_Arguments
@Noel: Can you help? Please set Status to ASSIGNED and add yourself to "Assigned To" if you accept this Bug
I'll look into it
ok, marking this as notabug ',' is an argument delimiter, you need to quote the argument if you don't want it to get parsed into separate arguments e.g. "macro:///Standard.Module1.ReplaceNBHyphenHTML(\"/home/cristi/A string, a comma.doc\")" works perfectly well for me
I have reproducible crash of LibreOffice when attempt to copy-paste this macro Separate bugreport for this: Bug 47265 - Basic IDE: LibreOffice crashes after adding new macro Currently I afraid to start 3.6.0 master via gdb because computer hangs (too much RAM needed for symbols). But if it is important, I will do some attempts. Tell me if needed.