https://bugs.documentfoundation.org/show_bug.cgi?id=76295

tommy27 <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|FEATURE REQUEST -AutoText   |Easier way to
                   |and AutoCorrect are not     |back-up/restore AutoText
                   |easy to back-up / restore   |and AutoCorrect items

--- Comment #3 from tommy27 <[email protected]> ---
in the past I've done an autocorrect to calc macro that did something like you
ask.

basically I extracted the  documentlist.xml from the acor.dat file where I had
the autocorrect list and then pasted it's address into the E1 cell of an empty
Calc sheet

here's the code (sorry but comments are in italian so you need to translate
them). I don't know it it's still working... I used it years ago.


Sub AutocorrToCalc 
 dim s as string 
 dim f(1) as string 
 If msgbox("Vuoi continuare?",1)=2 then 
 msgbox("Procedura annullata") 
 exit sub 
 end if 

dim oDoc 
 dim oSheet 
 dim oCell 

oDoc = ThisComponent 
 oSheet = oDoc.Sheets("Foglio1") 
 oCell = oSheet.GetCellRangeByName("E1") 
 ' inserire l'indirizzo del file .xml nella cella E1 del Foglio 1 
 fileName = oCell.String 
 Nome = convertToURL(fileName) 
 Nome2=Nome+".tmp" 
 oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess") 
 'xray oucb 
 txt = createUnoService("com.sun.star.io.TextInputStream") 
 txt2 = createUnoService("com.sun.star.io.TextOutputStream") 

txt.setEncoding("UTF-8") 

if FileExists(Nome) Then 

Pippo=oUcb.openFileRead(Nome) 
 txt.setInputStream(Pippo) 
 Pappo=oUcb.openFileWrite(Nome2) 
 txt2.setOutputStream(Pappo) 

Dim a() as variant 
 while txt.readBytes(a(), 1) = 1 
 if a(0)=62 then 
 txt2.writeBytes(a(),1) 
 a(0)=13 
 txt2.writeBytes(a(),1) 
 a(0)=10 
 end if 
 txt2.writeBytes(a(),1) 
 wend 
 txt.closeInput 
 txt2.closeOutput 

Pippo=oUcb.openFileRead(Nome2) 
 txt.setInputStream(Pippo) 
 s = "" 
 qq = """" 
 row = 0 

while not txt.iseof(1) 
 f(0)="<" 
 f(1)=">" 
 s= txt.ReadLine() 
 'print s 
 pip()=Split(s, ">") 
 l = UBound(pip) 
 for n=0 to l 
 s=pip(n)+">" 
      if InStr(s, "abbreviated-name") then 
          s1 = InStr(s, qq) + 1 
          s2 = InStr(s1, s, qq) + 1 
          s3 = InStr(s2, s, qq) + 1 
              s4 = InStr(s3, s, qq) + 1 

         w1 = mid(s, s1, s2-s1-1) 
          w2 = mid(s, s3, s4-s3-1) 

          oSheet.GetCellByPosition(0, row).String = w1 
            oSheet.GetCellByPosition(1, row).String = w2 

           row = row+1 
            s = "" 
      end if 
 next 
 wend 
 end if 
 txt.closeInput 
 Print "esportazione completata"
 End Sub

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to