home *** CD-ROM | disk | FTP | other *** search
/ Kompuutteri Kaikille K-CD 2002 #3 / K-CD_2002-03.iso / OpenOffice / f_0259 / Writer.xba < prev   
Extensible Markup Language  |  2001-06-25  |  3KB  |  75 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Writer" script:language="StarBasic">REM  *****  BASIC  *****
  4.  
  5.  
  6. Sub ConvertWriterTables()
  7. Dim CellString as String
  8. Dim oParagraphs as Object
  9. Dim oPara as Object
  10. Dim i as integer
  11. Dim sCellNames()
  12. Dim oCell as Object
  13. '    oDocument = StarDesktop.ActiveFrame.Controller.Model
  14. '    oFormats = oDocument.NumberFormats
  15.     oParagraphs = oDocument.Text.CreateEnumeration
  16.     While oParagraphs.HasMoreElements
  17.         oPara = oParagraphs.NextElement
  18.         If NOT oPara.supportsService("com.sun.star.text.Paragraph") Then
  19.             ' Note: Da Zellen gesplittet oder zusammengef├╝gt werden k├╢nnen
  20.             ' kann man die Zellen nicht ├╝ber ihre Indizes ansprechen.
  21.             sCellNames = oPara.CellNames
  22.             For i = 0 To Ubound(sCellNames)
  23.                 If sCellNames(i) <> "" Then
  24.                     oCell = oPara.getCellByName(sCellNames(i))
  25.                     If CheckFormatType(oCell) Then
  26.                         SwitchNumberFormat(oCell, oFormats, sEuroSign)
  27.                         ModifyObjectValuewithCurrFactor(oCell)
  28.                     End If
  29.                 End If
  30.             Next
  31.         End If
  32.     Wend
  33. End Sub
  34.  
  35.  
  36.  
  37. Sub ModifyObjectValuewithCurrFactor(oDocObject as Object)
  38.     oDocObjectValue = oDocObject.Value
  39.     oDocObject.Value = oDocObjectValue/CurrFactor
  40. End Sub
  41.  
  42.  
  43.  
  44. Sub ConvertTextFields()
  45. Dim oTextFields as Object
  46. Dim oTextField as Object
  47. Dim FieldValue
  48. Dim oDocObjectValue as double
  49. Dim InstanceNames(500) as String
  50. Dim CurInstanceName as String
  51. Dim MaxIndex as Integer
  52.     MaxIndex = 0
  53.     oTextfields = oDocument.getTextfields.CreateEnumeration
  54.     While oTextFields.hasmoreElements
  55.         oTextField = oTextFields.NextElement
  56.         If oTextField.PropertySetInfo.HasPropertybyName("NumberFormat") Then
  57.             If CheckFormatType(oTextField) Then
  58.                 If oTextField.PropertySetInfo.HasPropertybyName("Value") Then
  59.                     If Not oTextField.SupportsService("com.sun.star.text.TextField.GetExpression") Then
  60.                         oTextField.Content = Str(oTextField.Value/CurrFactor)
  61.                     End If
  62.                 ElseIf oTextField.TextFieldMaster.PropertySetInfo.HasPropertyByName("Value") Then
  63.                     CurInstanceName = oTextField.TextFieldMaster.InstanceName
  64.                     If Not FieldinArray(InstanceNames(), MaxIndex, CurInstanceName) Then
  65.                         oTextField.TextFieldMaster.Content = Str(oTextField.TextFieldMaster.Value/CurrFactor)
  66.                         InstanceNames(MaxIndex) = CurInstanceName
  67.                         MaxIndex = MaxIndex + 1
  68.                     End If
  69.                 End If
  70.                 SwitchNumberFormat(oTextField, oFormats, sEuroSign)
  71.             End If
  72.         End If
  73.     Wend
  74.     oDocument.GetTextFields.refresh()
  75. End Sub</script:module>