update dev300-m58
[ooovba.git] / wizards / source / euro / Writer.xba
blob0d153b7058e2f0b0fea0299896e230e5d6da2e79
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
9 Dim oPara as Object
10 Dim i as integer
11 Dim sCellNames()
12 Dim oCell as Object
13 oParagraphs = oDocument.Text.CreateEnumeration
14 While oParagraphs.HasMoreElements
15 oPara = oParagraphs.NextElement
16 If NOT oPara.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
17 &apos; Note: As cells might be splitted or merged
18 &apos; you cannot refer to them via their indices
19 sCellNames = oPara.CellNames
20 For i = 0 To Ubound(sCellNames)
21 If sCellNames(i) &lt;&gt; &quot;&quot; Then
22 oCell = oPara.getCellByName(sCellNames(i))
23 If CheckFormatType(oCell) Then
24 SwitchNumberFormat(oCell, oFormats, sEuroSign)
25 ModifyObjectValuewithCurrFactor(oCell)
26 End If
27 End If
28 Next
29 End If
30 Wend
31 End Sub
34 Sub ModifyObjectValuewithCurrFactor(oDocObject as Object)
35 oDocObjectValue = oDocObject.Value
36 oDocObject.Value = oDocObjectValue/CurrFactor
37 End Sub
40 Sub ConvertTextFields()
41 Dim oTextFields as Object
42 Dim oTextField as Object
43 Dim FieldValue
44 Dim oDocObjectValue as double
45 Dim InstanceNames(500) as String
46 Dim CurInstanceName as String
47 Dim MaxIndex as Integer
48 MaxIndex = 0
49 oTextfields = oDocument.getTextfields.CreateEnumeration
50 While oTextFields.hasmoreElements
51 oTextField = oTextFields.NextElement
52 If oTextField.PropertySetInfo.HasPropertybyName(&quot;NumberFormat&quot;) Then
53 If CheckFormatType(oTextField) Then
54 If oTextField.PropertySetInfo.HasPropertybyName(&quot;Value&quot;) Then
55 If Not oTextField.SupportsService(&quot;com.sun.star.text.TextField.GetExpression&quot;) Then
56 oTextField.Content = CStr(Round(oTextField.Value/CurrFactor,2))
57 End If
58 ElseIf oTextField.TextFieldMaster.PropertySetInfo.HasPropertyByName(&quot;Value&quot;) 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
64 End If
65 End If
66 SwitchNumberFormat(oTextField, oFormats, sEuroSign)
67 End If
68 End If
69 Wend
70 oDocument.GetTextFields.refresh()
71 End Sub
72 </script:module>