1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 33e02b54dSAndrew Rist<!--*********************************************************** 4*b53bcc32SMatthias Seidel * 53e02b54dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 63e02b54dSAndrew Rist * or more contributor license agreements. See the NOTICE file 73e02b54dSAndrew Rist * distributed with this work for additional information 83e02b54dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 93e02b54dSAndrew Rist * to you under the Apache License, Version 2.0 (the 103e02b54dSAndrew Rist * "License"); you may not use this file except in compliance 113e02b54dSAndrew Rist * with the License. You may obtain a copy of the License at 12*b53bcc32SMatthias Seidel * 133e02b54dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 14*b53bcc32SMatthias Seidel * 153e02b54dSAndrew Rist * Unless required by applicable law or agreed to in writing, 163e02b54dSAndrew Rist * software distributed under the License is distributed on an 173e02b54dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 183e02b54dSAndrew Rist * KIND, either express or implied. See the License for the 193e02b54dSAndrew Rist * specific language governing permissions and limitations 203e02b54dSAndrew Rist * under the License. 21*b53bcc32SMatthias Seidel * 223e02b54dSAndrew Rist ***********************************************************--> 23*b53bcc32SMatthias Seidel<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Writer" script:language="StarBasic">REM ***** BASIC ***** 24cdf0e10cSrcweir 25cdf0e10cSrcweir 26cdf0e10cSrcweirSub ConvertWriterTables() 27cdf0e10cSrcweirDim CellString as String 28cdf0e10cSrcweirDim oParagraphs as Object 29cdf0e10cSrcweirDim oPara as Object 30cdf0e10cSrcweirDim i as integer 31cdf0e10cSrcweirDim sCellNames() 32cdf0e10cSrcweirDim oCell as Object 33cdf0e10cSrcweir oParagraphs = oDocument.Text.CreateEnumeration 34cdf0e10cSrcweir While oParagraphs.HasMoreElements 35cdf0e10cSrcweir oPara = oParagraphs.NextElement 36cdf0e10cSrcweir If NOT oPara.supportsService("com.sun.star.text.Paragraph") Then 37*b53bcc32SMatthias Seidel ' Note: As cells might be split or merged 38cdf0e10cSrcweir ' you cannot refer to them via their indices 39cdf0e10cSrcweir sCellNames = oPara.CellNames 40cdf0e10cSrcweir For i = 0 To Ubound(sCellNames) 41cdf0e10cSrcweir If sCellNames(i) <> "" Then 42cdf0e10cSrcweir oCell = oPara.getCellByName(sCellNames(i)) 43cdf0e10cSrcweir If CheckFormatType(oCell) Then 44cdf0e10cSrcweir SwitchNumberFormat(oCell, oFormats, sEuroSign) 45cdf0e10cSrcweir ModifyObjectValuewithCurrFactor(oCell) 46cdf0e10cSrcweir End If 47cdf0e10cSrcweir End If 48cdf0e10cSrcweir Next 49cdf0e10cSrcweir End If 50cdf0e10cSrcweir Wend 51cdf0e10cSrcweirEnd Sub 52cdf0e10cSrcweir 53cdf0e10cSrcweir 54cdf0e10cSrcweirSub ModifyObjectValuewithCurrFactor(oDocObject as Object) 55cdf0e10cSrcweir oDocObjectValue = oDocObject.Value 56cdf0e10cSrcweir oDocObject.Value = oDocObjectValue/CurrFactor 57cdf0e10cSrcweirEnd Sub 58cdf0e10cSrcweir 59cdf0e10cSrcweir 60cdf0e10cSrcweirSub ConvertTextFields() 61cdf0e10cSrcweirDim oTextFields as Object 62cdf0e10cSrcweirDim oTextField as Object 63cdf0e10cSrcweirDim FieldValue 64cdf0e10cSrcweirDim oDocObjectValue as double 65cdf0e10cSrcweirDim InstanceNames(500) as String 66cdf0e10cSrcweirDim CurInstanceName as String 67cdf0e10cSrcweirDim MaxIndex as Integer 68cdf0e10cSrcweir MaxIndex = 0 69cdf0e10cSrcweir oTextfields = oDocument.getTextfields.CreateEnumeration 70cdf0e10cSrcweir While oTextFields.hasmoreElements 71cdf0e10cSrcweir oTextField = oTextFields.NextElement 72cdf0e10cSrcweir If oTextField.PropertySetInfo.HasPropertybyName("NumberFormat") Then 73cdf0e10cSrcweir If CheckFormatType(oTextField) Then 74cdf0e10cSrcweir If oTextField.PropertySetInfo.HasPropertybyName("Value") Then 75cdf0e10cSrcweir If Not oTextField.SupportsService("com.sun.star.text.TextField.GetExpression") Then 76cdf0e10cSrcweir oTextField.Content = CStr(Round(oTextField.Value/CurrFactor,2)) 77cdf0e10cSrcweir End If 78cdf0e10cSrcweir ElseIf oTextField.TextFieldMaster.PropertySetInfo.HasPropertyByName("Value") Then 79cdf0e10cSrcweir CurInstanceName = oTextField.TextFieldMaster.InstanceName 80cdf0e10cSrcweir If Not FieldinArray(InstanceNames(), MaxIndex, CurInstanceName) Then 81cdf0e10cSrcweir oTextField.TextFieldMaster.Content = CStr(Round(oTextField.TextFieldMaster.Value/CurrFactor,2)) 82cdf0e10cSrcweir InstanceNames(MaxIndex) = CurInstanceName 83cdf0e10cSrcweir MaxIndex = MaxIndex + 1 84cdf0e10cSrcweir End If 85cdf0e10cSrcweir End If 86cdf0e10cSrcweir SwitchNumberFormat(oTextField, oFormats, sEuroSign) 87cdf0e10cSrcweir End If 88cdf0e10cSrcweir End If 89cdf0e10cSrcweir Wend 90cdf0e10cSrcweir oDocument.GetTextFields.refresh() 91cdf0e10cSrcweirEnd Sub 923e02b54dSAndrew Rist</script:module> 93