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 *****
6 Sub ConvertWriterTables()
7 Dim CellString as String
8 Dim oParagraphs as Object
13 oParagraphs = oDocument.Text.CreateEnumeration
14 While oParagraphs.HasMoreElements
15 oPara = oParagraphs.NextElement
16 If NOT oPara.supportsService(
"com.sun.star.text.Paragraph
") Then
17 ' Note: As cells might be splitted or merged
18 ' you cannot refer to them via their indices
19 sCellNames = oPara.CellNames
20 For i =
0 To Ubound(sCellNames)
21 If sCellNames(i)
<> "" Then
22 oCell = oPara.getCellByName(sCellNames(i))
23 If CheckFormatType(oCell) Then
24 SwitchNumberFormat(oCell, oFormats, sEuroSign)
25 ModifyObjectValuewithCurrFactor(oCell)
34 Sub ModifyObjectValuewithCurrFactor(oDocObject as Object)
35 oDocObjectValue = oDocObject.Value
36 oDocObject.Value = oDocObjectValue/CurrFactor
40 Sub ConvertTextFields()
41 Dim oTextFields as Object
42 Dim oTextField as Object
44 Dim oDocObjectValue as double
45 Dim InstanceNames(
500) as String
46 Dim CurInstanceName as String
47 Dim MaxIndex as Integer
49 oTextfields = oDocument.getTextfields.CreateEnumeration
50 While oTextFields.hasmoreElements
51 oTextField = oTextFields.NextElement
52 If oTextField.PropertySetInfo.HasPropertybyName(
"NumberFormat
") Then
53 If CheckFormatType(oTextField) Then
54 If oTextField.PropertySetInfo.HasPropertybyName(
"Value
") Then
55 If Not oTextField.SupportsService(
"com.sun.star.text.TextField.GetExpression
") Then
56 oTextField.Content = CStr(Round(oTextField.Value/CurrFactor,
2))
58 ElseIf oTextField.TextFieldMaster.PropertySetInfo.HasPropertyByName(
"Value
") Then
59 CurInstanceName = oTextField.TextFieldMaster.InstanceName
60 If Not FieldinArray(InstanceNames(), MaxIndex, CurInstanceName) Then
61 oTextField.TextFieldMaster.Content = CStr(Round(oTextField.TextFieldMaster.Value/CurrFactor,
2))
62 InstanceNames(MaxIndex) = CurInstanceName
63 MaxIndex = MaxIndex +
1
66 SwitchNumberFormat(oTextField, oFormats, sEuroSign)
70 oDocument.GetTextFields.refresh()