Bump version to 4.1-6
[LibreOffice.git] / wizards / source / euro / Writer.xba
blobfa2b024bff392a28235af98c4917f8c9c37e2b2f
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <!--
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 .
19 -->
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
26 Dim oPara as Object
27 Dim i as integer
28 Dim sCellNames()
29 Dim oCell as Object
30 oParagraphs = oDocument.Text.CreateEnumeration
31 While oParagraphs.HasMoreElements
32 oPara = oParagraphs.NextElement
33 If NOT oPara.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
34 &apos; Note: As cells might be splitted or merged
35 &apos; you cannot refer to them via their indices
36 sCellNames = oPara.CellNames
37 For i = 0 To Ubound(sCellNames)
38 If sCellNames(i) &lt;&gt; &quot;&quot; Then
39 oCell = oPara.getCellByName(sCellNames(i))
40 If CheckFormatType(oCell) Then
41 SwitchNumberFormat(oCell, oFormats, sEuroSign)
42 ModifyObjectValuewithCurrFactor(oCell)
43 End If
44 End If
45 Next
46 End If
47 Wend
48 End Sub
51 Sub ModifyObjectValuewithCurrFactor(oDocObject as Object)
52 oDocObjectValue = oDocObject.Value
53 oDocObject.Value = oDocObjectValue/CurrFactor
54 End Sub
57 Sub ConvertTextFields()
58 Dim oTextFields as Object
59 Dim oTextField as Object
60 Dim FieldValue
61 Dim oDocObjectValue as double
62 Dim InstanceNames(500) as String
63 Dim CurInstanceName as String
64 Dim MaxIndex as Integer
65 MaxIndex = 0
66 oTextfields = oDocument.getTextfields.CreateEnumeration
67 While oTextFields.hasmoreElements
68 oTextField = oTextFields.NextElement
69 If oTextField.PropertySetInfo.HasPropertybyName(&quot;NumberFormat&quot;) Then
70 If CheckFormatType(oTextField) Then
71 If oTextField.PropertySetInfo.HasPropertybyName(&quot;Value&quot;) Then
72 If Not oTextField.SupportsService(&quot;com.sun.star.text.TextField.GetExpression&quot;) Then
73 oTextField.Content = CStr(Round(oTextField.Value/CurrFactor,2))
74 End If
75 ElseIf oTextField.TextFieldMaster.PropertySetInfo.HasPropertyByName(&quot;Value&quot;) 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
81 End If
82 End If
83 SwitchNumberFormat(oTextField, oFormats, sEuroSign)
84 End If
85 End If
86 Wend
87 oDocument.GetTextFields.refresh()
88 End Sub
89 </script:module>