1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"Writer" script:
language=
"StarBasic">REM ***** BASIC *****
23 Sub ConvertWriterTables()
24 Dim CellString as String
25 Dim oParagraphs as Object
30 oParagraphs = oDocument.Text.CreateEnumeration
31 While oParagraphs.HasMoreElements
32 oPara = oParagraphs.NextElement
33 If NOT oPara.supportsService(
"com.sun.star.text.Paragraph
") Then
34 ' Note: As cells might be splitted or merged
35 ' you cannot refer to them via their indices
36 sCellNames = oPara.CellNames
37 For i =
0 To Ubound(sCellNames)
38 If sCellNames(i)
<> "" Then
39 oCell = oPara.getCellByName(sCellNames(i))
40 If CheckFormatType(oCell) Then
41 SwitchNumberFormat(oCell, oFormats, sEuroSign)
42 ModifyObjectValuewithCurrFactor(oCell)
51 Sub ModifyObjectValuewithCurrFactor(oDocObject as Object)
52 oDocObjectValue = oDocObject.Value
53 oDocObject.Value = oDocObjectValue/CurrFactor
57 Sub ConvertTextFields()
58 Dim oTextFields as Object
59 Dim oTextField as Object
61 Dim oDocObjectValue as double
62 Dim InstanceNames(
500) as String
63 Dim CurInstanceName as String
64 Dim MaxIndex as Integer
66 oTextfields = oDocument.getTextfields.CreateEnumeration
67 While oTextFields.hasmoreElements
68 oTextField = oTextFields.NextElement
69 If oTextField.PropertySetInfo.HasPropertybyName(
"NumberFormat
") Then
70 If CheckFormatType(oTextField) Then
71 If oTextField.PropertySetInfo.HasPropertybyName(
"Value
") Then
72 If Not oTextField.SupportsService(
"com.sun.star.text.TextField.GetExpression
") Then
73 oTextField.Content = CStr(Round(oTextField.Value/CurrFactor,
2))
75 ElseIf oTextField.TextFieldMaster.PropertySetInfo.HasPropertyByName(
"Value
") Then
76 CurInstanceName = oTextField.TextFieldMaster.InstanceName
77 If Not FieldinArray(InstanceNames(), MaxIndex, CurInstanceName) Then
78 oTextField.TextFieldMaster.Content = CStr(Round(oTextField.TextFieldMaster.Value/CurrFactor,
2))
79 InstanceNames(MaxIndex) = CurInstanceName
80 MaxIndex = MaxIndex +
1
83 SwitchNumberFormat(oTextField, oFormats, sEuroSign)
87 oDocument.GetTextFields.refresh()