There can be problem if you use Shift+Enter, Tab, multiple spaces etc. in your document, so there is initially Find&Replace for it (array aRepl)!
And set correctly constants cExtension and cAcor at start.
Sub addCurrentList
REM !!! change this constants !!!
const cExtension="NameOfExtension"
const cAcor="acor_ru-RU.dat"
Dim oPathSettings As Object, oPackage As Object, oDom As Object, oNode As Object
Dim oPackageFolder As Object, oPackageStream As Object, oOutputStream As Object, oTempFile As Object
Dim filePath As String, DocumentList As String
dim oProvider as object, oDoc as object, oEnum as object, oPar as object, s$, s1$, s2$, i1&, i2&, oDesc as object, aRepl(), x
oDoc=ThisComponent
oProvider=GetDefaultContext.getByName("/singletons/com.sun.star.deployment.PackageInformationProvider")
filePath=oProvider.getPackageLocation(cExtension) & "/autocorr/" & cAcor
oPackage=createUnoService("com.sun.star.packages.Package")
oPackage.initialize Array(filePath)
DocumentList="DocumentList.xml"
oPackageStream=oPackage.getByHierarchicalName(DocumentList)
oDom=createUnoService("com.sun.star.xml.dom.DocumentBuilder").parse(oPackageStream.inputStream)
rem replace some white characters
aRepl=array( array("\n", "\n"), array("^$", ""), array("\t", ""), array("\s{2,}", "") )
oDesc=oDoc.createReplaceDescriptor
oDesc.SearchRegularExpression=true
for each x in aRepl
with oDesc
.SearchString=x(0)
.ReplaceString=x(1)
end with
oDoc.ReplaceAll(oDesc)
next
rem traverse paragraphs
oEnum=oDoc.Text.createEnumeration()
while oEnum.hasMoreElements()
oPar=oEnum.nextElement()
if oPar.supportsService("com.sun.star.text.Paragraph") then
s=oPar.String
if s<>"" then 'paragraph has text
i1=InStr(s, ":")
if i1>0 then ' : found
i2=InStr(i1, s, ",")
if i2>0 then ' , found
s1=Trim(Left(s, i1-1))
s2=Trim(Mid(s, i1+1, i2-i1-1))
'msgbox s1 & chr(13) & s2
oNode=oDom.documentElement.appendChild(oDom.createElement("block-list:block"))
oNode.setAttribute("block-list:abbreviated-name", s1)
oNode.setAttribute("block-list:name", s2)
end if
end if
end if
end if
wend
oTempFile=createUnoService("com.sun.star.io.TempFile")
oDom.setOutputStream oTempFile.OutputStream
oDom.start
oTempFile.OutputStream.closeOutput
oPackageFolder=oPackage.getByHierarchicalName("")
oPackageStream=oPackage.createInstanceWithArguments(Array(False))
oPackageStream.SetInputStream(oTempFile.InputStream)
oPackageFolder.replaceByName(DocumentList, oPackageStream)
oPackage.commitChanges
End Sub