LIBREOFFICE XRAY БЛЯДЬ
XrayTool60_en
Если файл существует, а при StarDesktop.loadComponentFromURL выдаётся нечто похожее
BASIC runtime error. An exception occurred Type: com.sun.star.lang.IllegalArgumentException Message: Unsupported URL <D:\file.xls>: "from LoadEnv::initializeLoading".
то это может быть потому, что перед file path нужно добавить "file:///"
Dim empty_array()
result_doc = StarDesktop.loadComponentFromURL("file:///" + result_doc_path,"_blank",0,empty_array())
Добрый день, уважаемый. Увидел вот такое сообщение при попытке отправить почту?
При этом ты точно знаешь, что адрес корректный и что с других ящиков всё отправляется?
Причина проста - яндекс заблокировал почту за "рассылку спама".
Это совершенно новый ящик и ты не отправлял с этого адреса ни единого письма? Аналогично, я тоже. Но, к счастью, эту проблему ещё можно исправить.
Вот инструкция к выполнению:
1. Регистрируемся на gmail.com
2. Всё работает.
Не нравится gmail? Что ж, можно понять. В этом случае поможет настройка собственного почтового сервера или что-нибудь из этого списка:
| Ни бе ни ме | Проверено и работает (платные) | Проверено и работает (бесплатные) |
|---|---|---|
mailstart.com post.cz mboxes.com starmail.com chez.com au.ru |
supernews.com pobox.com mymail.com stealthmail.com uni.de prxy.com |
gmail.com eudoramail.com www.mail.lycos.com gmx.de hotmail.com |
| Непроверено | Проверено и НЕ работает |
|---|---|
|
5ballov.ru aeterna.ru aim.com algxmail.com ameritech.net aol.com att.net autorambler.ru bigmir.net bk.ru charter.net clear.net.nz cox.net email.it fastmail.com.au fastmail.fm flash.net fmgirl.com fotoplenka.ru free.fr fromru.com front.ru games.com gmail.com gmx.de gmx.net googlemail.com hotbox.ru hotmail.co.nz hotmail.com hotmail.ru hotpop.com imapmail.org inbox.ru interia.pl km.ru krovatka.su land.ru lenta.ru libero.it list.ru live.com love.com mail.ru mail15.com mail333.com megabox.ru memori.ru meta.ua msn.com myrambler.ru myrealbox.com naui.net newmail.ru nfmail.com nightmail.ru nl.rogers.com nm.ru nvbell.net nxt.ru o2.pl olympus.ru operamail.com orange.net pacbell.net photofile.ru pisem.net pochta.com pochta.ru pochtamt.ru pop3.ru post.ru pplmail.com premoweb.com prodigy.net qip.ru qwerty rambler.ru rbcmail.ru rikt.ru ro.ru rocketmail.com rogers.com sbcglobal.net seznam.cz sibnet.ru sky.com sky.ru skynet.be smtp.ru snet.net softhome.net startfree.com su29.ru swbell.net talktalk.net telenet.be telus.net tlen.pl ua.fm ukr.net unliminet.de verizon.net wans.net web.de wow.com wp.pl xtra.co.nz ya.ru yahoo.ca yahoo.co.id yahoo.co.in yahoo.co.kr yahoo.co.nz yahoo.co.th yahoo.co.uk yahoo.com yahoo.com.ar yahoo.com.au yahoo.com.br yahoo.com.cn yahoo.com.hk yahoo.com.mx yahoo.com.my yahoo.com.ph yahoo.com.sg yahoo.com.tw yahoo.com.vn yahoo.de yahoo.dk yahoo.es yahoo.fr yahoo.ie yahoo.it yahoo.no yahoo.pl yahoo.se yahoomail.com yandex.ru ymail.com zebra.lt ziza.ru 123iran.com 1Ru.net 37.com 420email.com 4degreez.com 4-music-today.com a.ua abha.cc accountant.com actingbiz.com adexec.com AEmail4U.com africamail.com Aggressive.com ahsa.ws alex4all.com allergist.com allhiphop.com alumnidirector.com anatomicrock.com animeone.com anjungcafe.com aol.com arar.ws archaeologist.com arcticmail.com artlover.com asia.com a-teens.net ausi.com AussieMail.com australiamail.com autoindia.com autopm.com AviationEmail.com Bakililar.az Barnaul.info barriolife.com BaseballExpert.net b-boy.com beautifulboy.com Belgorod.tv berlin.com bgay.com bicycledata.com bicycling.com bigheavyworld.com bigmailbox.net bigmir.net bikerheaven.net bikerider.com bikermail.com billssite.com Biysk.biz bk.ru blackandchristian.com BlazeMail.com bmx.lv bmxtrix.com boarderzone.com boatnerd.com BodyBuilders.com bolbox.com BornAgain.com bowl.com box.az BuildTraffic.com Bust.com butch-femme.org byke.com CarJunky.com CatholicEmail.com catlover.com catlovers.com CBGB.com certifiedbitches.com championboxing.com chatway.com Cheatcc.com cheerful.com chemist.com Chernogolovka.com clerk.com cliffhanger.com columnist.com comic.com ComputerMail.net congiu.net consultant.com coolshit.com CoolYork.com counsellor.com cutey.com cycledata.com darkforces.com DarkSites.com DCEmail.com deliveryman.com diplomats.com dirtythird.com DocEmail.com doctor.com doglover.com dr.com dr-dre.com dreamstop.com dublin.com earthling.net earthling.net eclub.lv EcologyFund.com egypt.net eLiteral.com email.com email.ru emailfast.com eminemfans.com envirocitizen.com eritrea.cc escapeartist.com europe.com execs.com FastestCar.com feelingnaughty.com financier.com firemyst.com fit.lv fm.com.ua freemail.com.ua fromru.com front.ru fudge.com fujairah.ws gala.net gardener.com gmail.com GoBot.com goddess.com goldmail.ru gospelcity.com greatautos.org guy.com hairdresser.net haitisurf.com HappyHippie.com happyhippo.com hateinthebox.com hebron.tv Herzeleid.com hiphopmail.com HomeWorking.org HorseMail.com hotbox.ru hotmail.com hotmail.ru HotSheet.com hot-shot.com houseofhorrors.com hrono.ru hugkiss.com hullnumber.com human.lv icqfoto.ru iname.com inbox.ru inet.ua inorbit.com insurer.com intimatefire.com InvestingFan.com iphon.biz irow.com itua.info Ivanovo.biz jazzemail.com journalist.com juanitabynum.com Kaluga.tv kanoodle.com Kazan.biz K-earthmail.com Khalsa.com kickboxing.com kidrock.com kinkyemail.com Kirov.info Knac.com Kolyma.org Kostroma.biz Kursk.biz LadyFire.com land.ru latinogreeks.com lawyer.com leesville.com legislator.com Lipetsk.biz Lipetsk.info Lipetsk.tv list.ru lmail.ru lobbyist.com london.com loveable.com loveemail.com lovers-mail.com LoveToHike.com lowrider.com lubnan.ws madeniggaz.net madrid.com Magadan.info Magadan.tv mail.com mail.ru Mail.vu mail15.com mail333.com mailbomb.com Mari-el.biz marillion.net mascara.ws Math.com megarave.com MeowMail.com mesra.net meta.ua mindless.com minister.com ModernWife.com moscowmail.com motley.com MuchoMail.com Mugglenet.com munich.com Murmansk.biz Murmansk.tv muscat.ws music.com Nativeweb.org NetZoola.com newmail.ru nicedriveway.com nightmail.ru nm.ru Norilsk.biz Norilsk.info Norilsk.tv Nsk.biz nycmail.com Obninsk.biz Obninsk.info Obninsk.net Obninsk.tv Obrazovanie.com Obrazovanie.net Obrazovanie.org Omsk.biz OpenDiary.com optician.com Orel.tv Orenburg.tv pcbee.com pediatrician.com Penza.biz Penza.info Penza.tv persian.com petrofind.com peugeot-club.org Phreaker.net pinkcity.net pisem.net playful.com pochta.ru pochtamt.ru poetic.com PoliceOne.com pookmail.com poop.com pop3.ru popstar.com post.com Postamatik.com potsmokersnet.com presidency.com priest.com primetap.com programmer.net project420.com prolife.net Pskov.biz Pskov.tv publicist.com puppetweb.com Radio.fm rambler.ru rapstar.com rapworld.com rastamall.com ratedx.net rbcmail.ru realtyagent.com refer.ru registerednurses.com repairman.com representative.com rescueteam.com RiverSongs.net romance106fm.com rome.com Rostov.tv Runet.biz safat.ws saintly.com samerica.com sanfranmail.com Saratov.tv saveourplanet.org scientist.com seductive.com ShowFans.com singalongcenter.com singapore.com slayerized.com Sluggy.net smartstocks.com Smolensk.biz Smolensk.info Smolensk.tv smtp.ru sociologist.com sok.lv specialoperations.com speedymail.net spells.com SpinFinder.com SQATester.com Stavropol.biz Stavropol.tv streetracing.com sugarray.com superintendents.net supermail.ru Surf.co.nz surfguiden.com Surgut.biz Surgut.tv sweetwishes.com Tambov.tv TeachFitness.com teamster.net TechEmail.com techie.com technologist.com teenchatnow.com the5thquarter.com theblackmarket.com TheDogHouseMail.com TheFreeSite.com TheGuilds.org TNbusiness.com tokyo.com tombstone.ws Tomsk.biz Tomsk.info Tomsk.tv TopNurses.net topping.com.ua ToughGuy.net TranceAddict.com Triathlete.com Tula.info Tumen.biz tut.by Tver.biz Tver.info Tver.tv tvmail.ru tx.am u2tours.com ua.fm Ufa.biz UltimateEmail.com umpire.com Upakovka.com Upakovka.org usa.com vitalogy.org Volga.tv VolleyballMail.com whatisthis.com whoever.com winning.com witty.com wmail.ru womenmail.ru WomensMail.net WowMail.com wrestlezone.com http://www.mailru.com/ Вы получаете сразу два адреса - <имя>@mailru.com, <имя>@pisem.net. Размер почтового ящика - 20 Мб, размер отправляемого письма - до 15 Мб, размер присоединяемого файла - до 10 Мб. Можно забирать почту по протоколам POP3 и IMAP4, есть переадресовка и режим шифрации данных (SSL). http://www.chat.ru/ http://www.mail.ru/ http://www.newmail.ru/(или http://www.hotmail.ru/) http://www.mail.com/ http://www.az.ru/ http://www.netcity.ru/ |
zdnetmail.com i-connect.ru null.ru altavista.com zuzzurello.com geocities.com freemail.nl iname.com iforward.com milmail.com mailshuttle.com pemail.net freestamp.com apmail.com singpost.com planetall.com wonder-net.com free-org.com stones.com copacabana.com callsign.net cybermail.net gyral.com inovasi.com forfree.at drotposta.hu apmail.com singpost.com planetall.com wonder-net.com switchboard.com yclub.com busymail.com extenda.net passagen.se atlink.com nettaxi.com thedorm.com post1.com indocities.com altern.org emumail.net mailexcite.com letterbox.com coollist.com road-mail.com goplay.com myownemail.com mrpost.com get-mail.com valise.com flashemail.com n2mail.com vcmail.com office-email.com 123emailme.com hugedomains.com dccmail.com relaymail.net softhome.com pol.com nicknames.com netbox.com vanityemail.com backpackers.net thewww.com send.com |
Этот список - копипаст, прошу строго не судить.
Put links into a plain text file separated by newlines and save as *.m3u. Then open it with vlc.
video - Create a playlist of URLs in VLC - Super User
Sub Main
Dim Str As String
Dim Parsed As Object
Str = GetDocFullPath() ' "/home/user/document.ods" '
Parsed = ParseFilePath(Str)
MsgBox("FileDir:" + Parsed.FileDir) ' "/home/user/" '
MsgBox("FileName:" + Parsed.FileName) ' "document.ods" '
MsgBox("FileDirName:" + Parsed.FileDirName) ' "user" '
MsgBox("FileFullPath:" + Parsed.FileFullPath) ' "/home/user/document.ods" '
MsgBox("FileExtension:" + Parsed.FileExtension) ' "ods" '
MsgBox("FileDirNoSlash:" + Parsed.FileDirNoSlash) ' "/home/user" '
MsgBox("FileNameNoExtension:" + Parsed.FileNameNoExtension) ' "document" '
End Sub
Type FilePathParsedByParseFilePathFunction
FileDir As String
FileName As String
FileDirName As String
FileFullPath As String
FileExtension As String
FileDirNoSlash As String
FileNameNoExtension As String
End Type
Function ParseFilePath(ByVal FullPath As String) As Object
Dim i As Long
Dim PathLen As Long
Dim PathURL As String
Dim DirLenDiff As Long
Dim BaseNameLen As Long
Dim BaseDirectory As String
Dim BaseNameExtDiff As Long
Dim BaseNameLastDotIndex As Long
' Fetching file base name from FullPath '
' Converting to URL for Linux/Windows compatibility. '
' URL notation does not allow certain special characters to be used. '
' These are either replaced by other characters or encoded. A slash '
' (/) is used as a path separator. For example, a file referred to as '
' C:\My File.sxw on the local host in "Windows notation" becomes '
' file:///C|/My%20File.sxw in URL notation. '
' https://help.libreoffice.org/Basic/Basic_Glossary '
PathURL = ConvertToURL(FullPath)
ParseFilePath = CreateObject("FilePathParsedByParseFilePathFunction")
ParseFilePath.FileFullPath = FullPath
' FullPath could be mistakenly converted to http. For example: '
' ConvertToURL("many.dots.in.file.name.ods") will be misinterpreted. '
If Left(PathURL,7) <> "file://" Then
PathURL = ConvertToURL("/" + FullPath)
End If
PathLen = Len(PathURL)
For i = PathLen To 1 Step -1
If Mid(PathURL,i,1) = "/" Then
ParseFilePath.FileName = ConvertFromURL(Right(PathURL,PathLen - i))
Exit For
End If
Next i
' Finding last occurence of "." in the file name. First symbol is ignored '
' due to filenames starting with dot (.htaccess) have no extension. '
BaseNameLen = Len(ParseFilePath.FileName)
BaseNameLastDotIndex = BaseNameLen
For i = BaseNameLen To 2 Step -1
If Mid(ParseFilePath.FileName,i,1) = "." Then
BaseNameLastDotIndex = i
Exit For
End If
Next i
ParseFilePath.FileExtension = Right(ParseFilePath.FileName,BaseNameLen - BaseNameLastDotIndex)
BaseNameExtDiff = BaseNameLen - Len(ParseFilePath.FileExtension) - 1
If BaseNameExtDiff < 0 Then
BaseNameExtDiff = 0
End If
ParseFilePath.FileNameNoExtension = Left(ParseFilePath.FileName,BaseNameExtDiff)
' Getting directory name with slash and without. '
DirLenDiff = Len(FullPath) - Len(ParseFilePath.FileName)
ParseFilePath.FileDir = Left(FullPath,DirLenDiff)
DirLenDiff = DirLenDiff - 1
If DirLenDiff < 0 Then
DirLenDiff = 0
End If
ParseFilePath.FileDirNoSlash = Left(FullPath,DirLenDiff)
' Getting file directory name. '
PathURL = ConvertToURL(ParseFilePath.FileDirNoSlash)
If Left(PathURL,7) <> "file://" Then
PathURL = ConvertToURL("/" + ParseFilePath.FileDirNoSlash)
End If
PathLen = Len(PathURL)
For i = PathLen To 1 Step -1
If Mid(PathURL,i,1) = "/" Then
ParseFilePath.FileDirName = ConvertFromURL(Right(PathURL,PathLen - i))
Exit For
End If
Next i
End Function
' Returns document full path if document has a path. Returns empty string if '
' document has no path and IgnoreNoPathError flag is set to TRUE. '
Function GetDocFullPath(Optional IgnoreNoPathError as Boolean) As String
' Default behavior is to return empty string if document location is empty.'
' This can happen if document is new and not saved thus do not have a path.'
If NOT ThisComponent.hasLocation() AND IgnoreNoPathError <> TRUE Then
' Err.Raise is not valid statement but will generate error anyway. '
Err.Raise("Document has no path. Probably because is not saved.")
End If
GetDocFullPath = ConvertFromURL(ThisComponent.getLocation())
End Function
Описание:
Вышепредставленный программный код на бейсике для макросов либреофиса можно использовать чтобы парсить полный путь к файлу, получая из него все необходимые части: имя файла, расширение, имя директории, путь без имени файла, имя файла без расширения и т.п.
Sub Main
Dim str As String
str = GetDocFullPath()
MsgBox(str + " -> " + GetFileExtension(str))
' "/home/user/document.ods -> ods" '
str = "C:\Windows\system32\drivers\etc\hosts"
MsgBox(str + " -> " + GetFileExtension(str))
' "C:\Windows\system32\drivers\etc\hosts -> " '
str = "C:\Windows\system32\drivers\etc\hosts.ods.zip"
MsgBox(str + " -> " + GetFileExtension(str))
' "C:\Windows\system32\drivers\etc\hosts.ods.zip -> zip" '
str = "many.dots.in.file.name.ods"
MsgBox(str + " -> " + GetFileExtension(str))
' "many.dots.in.file.name.ods -> ods" '
str = "test.ods"
MsgBox(str + " -> " + GetFileExtension(str))
' "test.ods -> ods" '
str = ".htaccess"
MsgBox(str + " -> " + GetFileExtension(str))
' ".htaccess -> " '
str = ""
MsgBox(str + " -> " + GetFileExtension(str))
' " -> " '
End Sub
' Returns extension by filename. '
' Notice that files starting with dot (.htaccess) have no extension. '
Function GetFileExtension(ByVal FullPath As String) As String
Dim i As Long
Dim PathLen As Long
Dim PathURL As String
Dim BaseName As String
Dim BaseNameLen As Long
Dim BaseNameLastDotIndex As Long
' Fetching file base name from FullPath '
' Converting to URL for Linux/Windows compatibility. '
' URL notation does not allow certain special characters to be used. '
' These are either replaced by other characters or encoded. A slash '
' (/) is used as a path separator. For example, a file referred to as '
' C:\My File.sxw on the local host in "Windows notation" becomes '
' file:///C|/My%20File.sxw in URL notation. '
' https://help.libreoffice.org/Basic/Basic_Glossary '
PathURL = ConvertToURL(FullPath)
' FullPath could be mistakenly converted to http. For example: '
' ConvertToURL("many.dots.in.file.name.ods") will be misinterpreted. '
If Left(PathURL,7) <> "file://" Then
PathURL = ConvertToURL("/" + FullPath)
End If
PathLen = Len(PathURL)
For i = PathLen To 1 Step -1
If Mid(PathURL,i,1) = "/" Then
BaseName = ConvertFromURL(Right(PathURL,PathLen - i))
Exit For
End If
Next i
' Finding last occurence of "." in the file name. First symbol is ignored '
' due to filenames starting with dot (.htaccess) have no extension. '
BaseNameLen = Len(BaseName)
BaseNameLastDotIndex = BaseNameLen
For i = BaseNameLen To 2 Step -1
If Mid(BaseName,i,1) = "." Then
BaseNameLastDotIndex = i
Exit For
End If
Next i
GetFileExtension = Right(BaseName,BaseNameLen - BaseNameLastDotIndex)
End Function
' Returns document full path if document has a path. Returns empty string if '
' document has no path and IgnoreNoPathError flag is set to TRUE. '
Function GetDocFullPath(Optional IgnoreNoPathError as Boolean) As String
' Default behavior is to return empty string if document location is empty.'
' This can happen if document is new and not saved thus do not have a path.'
If NOT ThisComponent.hasLocation() AND IgnoreNoPathError <> TRUE Then
' Err.Raise is not valid statement but will generate error anyway. '
Err.Raise("Document has no path. Probably because is not saved.")
End If
GetDocFullPath = ConvertFromURL(ThisComponent.getLocation())
End Function
Описание:
Вышепредставленный программный код на бейсике для макросов либреофиса возвращает строку, содержащую расширение файла, или пустую строку, если у файла нет расширения. Данная функция полезна в случае когда нужно узнать расширение по имени файла, либо по полному пути к файлу.
Libreoffice has built-in function to explode strings called Split. To join array into string there is an opposite "implode" function Join.
Sub Main Dim str As String Dim arr() As String str = "Calc||Microsoft Excel 97/2000/XP|xls|MS Excel 97" arr = Split(str,"|") MsgBox(arr(0)) ' "Calc" ' MsgBox(arr(4)) ' "MS Excel 97" ' MsgBox(Join(arr,",")) ' "Calc,,Microsoft Excel 97/2000/XP,xls,MS Excel 97" ' End Sub
Описание:
Вышепредставленный программный код на бейсике для макросов либреофиса для разделения строк использует аналоги PHP-функций explode и implode, называемые Split и Join. Split разделяет строку при помощи разделителя в массив, а Join собирает массив в строку, объединяя указанным разделителем.
Sub Main
Dim str As String
str = GetDocFullPath() ' "/home/user/document.ods" '
MsgBox(GetBaseDirectory(str)) ' "/home/user/" '
MsgBox(GetBaseDirectory(str,TRUE)) ' "/home/user" '
str = "C:\Windows\system32\drivers\etc\hosts"
MsgBox(GetBaseDirectory(str)) ' "C:\Windows\system32\drivers\etc\" '
MsgBox(GetBaseDirectory(str,TRUE)) ' "C:\Windows\system32\drivers\etc" '
str = "test.ods"
MsgBox(GetBaseDirectory(str)) ' "" as there is no base directory '
MsgBox(GetBaseDirectory(str,TRUE)) ' "" as there is no base directory '
str = "many.dots.in.file.name.ods"
MsgBox(GetBaseDirectory(str)) ' "" as there is no base directory '
MsgBox(GetBaseDirectory(str,TRUE)) ' "" as there is no base directory '
End Sub
' Returns the base directory of the given path. '
' For example "/home/user/document.ods" input will return "/home/user/". '
' If DropTrailingSlash is TRUE, the example above will return "/home/user". '
' ByVal keyword prevents FullPath from modification because by default '
' arguments are passed by reference. '
Function GetBaseDirectory(ByVal FullPath As String, Optional DropTrailingSlash As Boolean) As String
Dim i As Long
Dim PathLen As Long
Dim PathURL As String
Dim LenDiff As Long
Dim BaseName As String
' Converting to URL for Linux/Windows compatibility. '
' URL notation does not allow certain special characters to be used. '
' These are either replaced by other characters or encoded. A slash '
' (/) is used as a path separator. For example, a file referred to as '
' C:\My File.sxw on the local host in "Windows notation" becomes '
' file:///C|/My%20File.sxw in URL notation. '
' https://help.libreoffice.org/Basic/Basic_Glossary '
PathURL = ConvertToURL(FullPath)
' FullPath could be mistakenly converted to http. For example: '
' ConvertToURL("name.with.many.dots.myext") will be misinterpreted. '
If Left(PathURL,7) <> "file://" Then
PathURL = ConvertToURL("/" + FullPath)
End If
PathLen = Len(PathURL)
For i = PathLen To 1 Step -1
If Mid(PathURL,i,1) = "/" Then
BaseName = ConvertFromURL(Right(PathURL,PathLen - i))
Exit For
End If
Next i
If DropTrailingSlash = TRUE Then
BaseName = "/" + BaseName
End If
LenDiff = Len(FullPath) - Len(BaseName)
If LenDiff < 0 Then
LenDiff = 0
End If
GetBaseDirectory = Left(FullPath,LenDiff)
End Function
' Returns document full path if document has a path. Returns empty string if '
' document has no path and IgnoreNoPathError flag is set to TRUE. '
Function GetDocFullPath(Optional IgnoreNoPathError as Boolean) As String
' Default behavior is to return empty string if document location is empty.'
' This can happen if document is new and not saved thus do not have a path.'
If NOT ThisComponent.hasLocation() AND IgnoreNoPathError <> TRUE Then
' Err.Raise is not valid statement but will generate error anyway. '
Err.Raise("Document has no path. Probably because is not saved.")
End If
GetDocFullPath = ConvertFromURL(ThisComponent.getLocation())
End Function
Описание:
Вышепредставленный программный код на бейсике для макросов либреофиса можно использовать чтобы из полного пути к файлу получить директорию в которой находится файл.
Ошибка может произойти и поставить в тупик в том случае, если определение функции расположено ранее её первого вызова и при этом вызов осуществлен без обязательных аргументов. Например:
Sub Main Dim str As String str = GetDocFullPath() MsgBox(GetFileBaseName(str)) End Sub Function GetDocFullPath(sInput as String) As String GetDocFullPath = ConvertFromURL(ThisComponent.getLocation()) End Function
Код выше сгенерирует ошибку
BASIC syntax error.
Symbol GetDocFullPath already defined differently.
Если же переместить местами определение функции, то ошибки уже не появится
Function GetDocFullPath(sInput as String) As String GetDocFullPath = ConvertFromURL(ThisComponent.getLocation()) End Function Sub Main Dim str As String str = GetDocFullPath() MsgBox(GetFileBaseName(str)) End Sub
Но можно и нужно в первую очередь исправить сам некорректный вызов функции, тогда и проблемы не будет.
Sub Main
Dim str As String
str = GetDocFullPath("BLABLABLA")
MsgBox(GetFileBaseName(str))
End Sub
Function GetDocFullPath(sInput as String) As String
GetDocFullPath = ConvertFromURL(ThisComponent.getLocation())
End Function
Sub Main
Dim str As String
str = GetDocFullPath() ' "/home/user/document.ods" '
MsgBox(GetFileBaseName(str)) ' "document.ods" '
str = "C:\Windows\system32\drivers\etc\hosts"
MsgBox(GetFileBaseName(str)) ' "hosts" '
str = "test.ods"
MsgBox(GetFileBaseName(str)) ' "test.ods" '
str = "many.dots.in.file.name.ods"
MsgBox(GetFileBaseName(str)) ' "many.dots.in.file.name.ods" '
End Sub
' Returns the filename of the given path. '
' For example "/home/user/document.ods" input will return "document.ods". '
' ByVal keyword prevents FullPath from modification because by default '
' arguments are passed by reference. '
Function GetFileBaseName(ByVal FullPath As String) As String
Dim i As Long
Dim PathLen As Long
Dim PathURL As String
' Converting to URL for Linux/Windows compatibility. '
' URL notation does not allow certain special characters to be used. '
' These are either replaced by other characters or encoded. A slash '
' (/) is used as a path separator. For example, a file referred to as '
' C:\My File.sxw on the local host in "Windows notation" becomes '
' file:///C|/My%20File.sxw in URL notation. '
' https://help.libreoffice.org/Basic/Basic_Glossary '
PathURL = ConvertToURL(FullPath)
' FullPath could be mistakenly converted to http. For example: '
' ConvertToURL("many.dots.in.file.name.ods") will be misinterpreted. '
If Left(PathURL,7) <> "file://" Then
PathURL = ConvertToURL("/" + FullPath)
End If
PathLen = Len(PathURL)
For i = PathLen To 1 Step -1
If Mid(PathURL,i,1) = "/" Then
GetFileBaseName = ConvertFromURL(Right(PathURL,PathLen - i))
Exit For
End If
Next i
End Function
' Returns document full path if document has a path. Returns empty string if '
' document has no path and IgnoreNoPathError flag is set to TRUE. '
Function GetDocFullPath(Optional IgnoreNoPathError as Boolean) As String
' Default behavior is to return empty string if document location is empty.'
' This can happen if document is new and not saved thus do not have a path.'
If NOT ThisComponent.hasLocation() AND IgnoreNoPathError <> TRUE Then
' Err.Raise is not valid statement but will generate error anyway. '
Err.Raise("Document has no path. Probably because is not saved.")
End If
GetDocFullPath = ConvertFromURL(ThisComponent.getLocation())
End Function
Описание:
Вышепредставленный программный код на бейсике для макросов либреофиса можно использовать чтобы получить имя файла и его расширение из полного пути к файлу.
