1*cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2*cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3*cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Writer" script:language="StarBasic">REM ***** BASIC ***** 4*cdf0e10cSrcweir 5*cdf0e10cSrcweir 6*cdf0e10cSrcweirSub ConvertWriterTables() 7*cdf0e10cSrcweirDim CellString as String 8*cdf0e10cSrcweirDim oParagraphs as Object 9*cdf0e10cSrcweirDim oPara as Object 10*cdf0e10cSrcweirDim i as integer 11*cdf0e10cSrcweirDim sCellNames() 12*cdf0e10cSrcweirDim oCell as Object 13*cdf0e10cSrcweir oParagraphs = oDocument.Text.CreateEnumeration 14*cdf0e10cSrcweir While oParagraphs.HasMoreElements 15*cdf0e10cSrcweir oPara = oParagraphs.NextElement 16*cdf0e10cSrcweir If NOT oPara.supportsService("com.sun.star.text.Paragraph") Then 17*cdf0e10cSrcweir ' Note: As cells might be splitted or merged 18*cdf0e10cSrcweir ' you cannot refer to them via their indices 19*cdf0e10cSrcweir sCellNames = oPara.CellNames 20*cdf0e10cSrcweir For i = 0 To Ubound(sCellNames) 21*cdf0e10cSrcweir If sCellNames(i) <> "" Then 22*cdf0e10cSrcweir oCell = oPara.getCellByName(sCellNames(i)) 23*cdf0e10cSrcweir If CheckFormatType(oCell) Then 24*cdf0e10cSrcweir SwitchNumberFormat(oCell, oFormats, sEuroSign) 25*cdf0e10cSrcweir ModifyObjectValuewithCurrFactor(oCell) 26*cdf0e10cSrcweir End If 27*cdf0e10cSrcweir End If 28*cdf0e10cSrcweir Next 29*cdf0e10cSrcweir End If 30*cdf0e10cSrcweir Wend 31*cdf0e10cSrcweirEnd Sub 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir 34*cdf0e10cSrcweirSub ModifyObjectValuewithCurrFactor(oDocObject as Object) 35*cdf0e10cSrcweir oDocObjectValue = oDocObject.Value 36*cdf0e10cSrcweir oDocObject.Value = oDocObjectValue/CurrFactor 37*cdf0e10cSrcweirEnd Sub 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir 40*cdf0e10cSrcweirSub ConvertTextFields() 41*cdf0e10cSrcweirDim oTextFields as Object 42*cdf0e10cSrcweirDim oTextField as Object 43*cdf0e10cSrcweirDim FieldValue 44*cdf0e10cSrcweirDim oDocObjectValue as double 45*cdf0e10cSrcweirDim InstanceNames(500) as String 46*cdf0e10cSrcweirDim CurInstanceName as String 47*cdf0e10cSrcweirDim MaxIndex as Integer 48*cdf0e10cSrcweir MaxIndex = 0 49*cdf0e10cSrcweir oTextfields = oDocument.getTextfields.CreateEnumeration 50*cdf0e10cSrcweir While oTextFields.hasmoreElements 51*cdf0e10cSrcweir oTextField = oTextFields.NextElement 52*cdf0e10cSrcweir If oTextField.PropertySetInfo.HasPropertybyName("NumberFormat") Then 53*cdf0e10cSrcweir If CheckFormatType(oTextField) Then 54*cdf0e10cSrcweir If oTextField.PropertySetInfo.HasPropertybyName("Value") Then 55*cdf0e10cSrcweir If Not oTextField.SupportsService("com.sun.star.text.TextField.GetExpression") Then 56*cdf0e10cSrcweir oTextField.Content = CStr(Round(oTextField.Value/CurrFactor,2)) 57*cdf0e10cSrcweir End If 58*cdf0e10cSrcweir ElseIf oTextField.TextFieldMaster.PropertySetInfo.HasPropertyByName("Value") Then 59*cdf0e10cSrcweir CurInstanceName = oTextField.TextFieldMaster.InstanceName 60*cdf0e10cSrcweir If Not FieldinArray(InstanceNames(), MaxIndex, CurInstanceName) Then 61*cdf0e10cSrcweir oTextField.TextFieldMaster.Content = CStr(Round(oTextField.TextFieldMaster.Value/CurrFactor,2)) 62*cdf0e10cSrcweir InstanceNames(MaxIndex) = CurInstanceName 63*cdf0e10cSrcweir MaxIndex = MaxIndex + 1 64*cdf0e10cSrcweir End If 65*cdf0e10cSrcweir End If 66*cdf0e10cSrcweir SwitchNumberFormat(oTextField, oFormats, sEuroSign) 67*cdf0e10cSrcweir End If 68*cdf0e10cSrcweir End If 69*cdf0e10cSrcweir Wend 70*cdf0e10cSrcweir oDocument.GetTextFields.refresh() 71*cdf0e10cSrcweirEnd Sub 72*cdf0e10cSrcweir</script:module>