Soft.xba (3e02b54d) Soft.xba (b53bcc32)
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<!--***********************************************************
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<!--***********************************************************
4 *
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
21 *
22 ***********************************************************-->
23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Soft" script:language="StarBasic">Option Explicit
22 ***********************************************************-->
23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Soft" script:language="StarBasic">Option Explicit
24REM ***** BASIC *****
24REM ***** BASIC *****
25
26
27Sub CreateStyleEnumeration()
28 EmptySelection()
29 EmptyListbox(DialogModel.lstSelection)
30 CurSheetName = oDocument.CurrentController.GetActiveSheet.Name
31 MakeStyleEnumeration(False)
32 DialogModel.lblSelection.Label = sTEMPLATES

--- 7 unchanged lines hidden (view full) ---

40 StyleIndex = -1
41 oStyles = oDocument.StyleFamilies.GetbyIndex(0)
42 For m = 0 To oStyles.count-1
43 oStyle = oStyles.GetbyIndex(m)
44 StyleName = oStyle.Name
45 If CheckFormatType(oStyle) Then
46 If Not bAddToListBox Then
47 AddSingleItemToListbox(DialogModel.lstSelection, Stylename)
25
26
27Sub CreateStyleEnumeration()
28 EmptySelection()
29 EmptyListbox(DialogModel.lstSelection)
30 CurSheetName = oDocument.CurrentController.GetActiveSheet.Name
31 MakeStyleEnumeration(False)
32 DialogModel.lblSelection.Label = sTEMPLATES

--- 7 unchanged lines hidden (view full) ---

40 StyleIndex = -1
41 oStyles = oDocument.StyleFamilies.GetbyIndex(0)
42 For m = 0 To oStyles.count-1
43 oStyle = oStyles.GetbyIndex(m)
44 StyleName = oStyle.Name
45 If CheckFormatType(oStyle) Then
46 If Not bAddToListBox Then
47 AddSingleItemToListbox(DialogModel.lstSelection, Stylename)
48 Else
48 Else
49 SwitchNumberFormat(ostyle, oFormats, sEuroSign)
50 End If
51 StyleIndex = StyleIndex + 1
52 If StyleIndex &gt; Ubound(StyleRangeAssignMentList()) Then
53 Redim Preserve StyleRangeAssignmentList(StyleIndex)
54 End If
55 StyleRangeAssignmentList(StyleIndex) = &quot;&lt;STYLENAME&gt;&quot; &amp; Stylename &amp; &quot;&lt;/STYLENAME&gt;&quot; &amp; _
56 &quot;&lt;DEFINED&gt;FALSE&lt;/DEFINED&gt;&quot; &amp; &quot;&lt;RANGES&gt;&lt;/RANGES&gt;&quot; &amp;_

--- 55 unchanged lines hidden (view full) ---

112 RangeString = &quot;&lt;RANGES&gt;&quot;
113 MaxIndex = oSheets.Count-1
114 For i = 0 To MaxIndex
115 oSheet = oSheets(i)
116 SheetName = oSheet.Name
117 oRanges = osheet.CellFormatRanges.CreateEnumeration
118 While oRanges.hasMoreElements
119 oRange = oRanges.NextElement
49 SwitchNumberFormat(ostyle, oFormats, sEuroSign)
50 End If
51 StyleIndex = StyleIndex + 1
52 If StyleIndex &gt; Ubound(StyleRangeAssignMentList()) Then
53 Redim Preserve StyleRangeAssignmentList(StyleIndex)
54 End If
55 StyleRangeAssignmentList(StyleIndex) = &quot;&lt;STYLENAME&gt;&quot; &amp; Stylename &amp; &quot;&lt;/STYLENAME&gt;&quot; &amp; _
56 &quot;&lt;DEFINED&gt;FALSE&lt;/DEFINED&gt;&quot; &amp; &quot;&lt;RANGES&gt;&lt;/RANGES&gt;&quot; &amp;_

--- 55 unchanged lines hidden (view full) ---

112 RangeString = &quot;&lt;RANGES&gt;&quot;
113 MaxIndex = oSheets.Count-1
114 For i = 0 To MaxIndex
115 oSheet = oSheets(i)
116 SheetName = oSheet.Name
117 oRanges = osheet.CellFormatRanges.CreateEnumeration
118 While oRanges.hasMoreElements
119 oRange = oRanges.NextElement
120 If oRange.getPropertyState(&quot;NumberFormat&quot;) = 1 Then
120 If oRange.getPropertyState(&quot;NumberFormat&quot;) = 1 Then
121 If oRange.CellStyle = CurStyleName Then
122 oRangeAddress = oRange.RangeAddress
123 RangeName = RetrieveRangeNamefromAddress(oRange)
124 RangeString = RangeString &amp; RangeName &amp; &quot;,&quot;
125 StyleCellCount = StyleCellCount + CountRangeCells(oRange)
126 End If
127 End If
128 Wend
129 Next i
130 If StyleCellCount &gt; 0 Then
121 If oRange.CellStyle = CurStyleName Then
122 oRangeAddress = oRange.RangeAddress
123 RangeName = RetrieveRangeNamefromAddress(oRange)
124 RangeString = RangeString &amp; RangeName &amp; &quot;,&quot;
125 StyleCellCount = StyleCellCount + CountRangeCells(oRange)
126 End If
127 End If
128 Wend
129 Next i
130 If StyleCellCount &gt; 0 Then
131 TotCellCount = TotCellCount + StyleCellCount
131 TotCellCount = TotCellCount + StyleCellCount
132 RangeString = RTrimStr(RangeString,&quot;,&quot;)
133 RangeString = RangeString &amp; &quot;&lt;/RANGES&gt;&quot;
134 CellCountString = &quot;&lt;CELLCOUNT&gt;&quot; &amp; StyleCellCount &amp; &quot;&lt;/CELLCOUNT&quot;
135 AssignString = ReplaceString(AssignString, RangeString,&quot;&lt;RANGES&gt;&lt;/RANGES&gt;&quot;)
136 AssignString = ReplaceString(AssignString, CellCountString,&quot;&lt;CELLCOUNT&gt;0&lt;/CELLCOUNT&gt;&quot;)
137 End If
138 AssignString = ReplaceString(AssignString, &quot;&lt;DEFINED&gt;TRUE&lt;/DEFINED&gt;&quot;, &quot;&lt;DEFINED&gt;FALSE&lt;/DEFINED&gt;&quot;)
139 StyleRangeAssignmentList(n) = AssignString
132 RangeString = RTrimStr(RangeString,&quot;,&quot;)
133 RangeString = RangeString &amp; &quot;&lt;/RANGES&gt;&quot;
134 CellCountString = &quot;&lt;CELLCOUNT&gt;&quot; &amp; StyleCellCount &amp; &quot;&lt;/CELLCOUNT&quot;
135 AssignString = ReplaceString(AssignString, RangeString,&quot;&lt;RANGES&gt;&lt;/RANGES&gt;&quot;)
136 AssignString = ReplaceString(AssignString, CellCountString,&quot;&lt;CELLCOUNT&gt;0&lt;/CELLCOUNT&gt;&quot;)
137 End If
138 AssignString = ReplaceString(AssignString, &quot;&lt;DEFINED&gt;TRUE&lt;/DEFINED&gt;&quot;, &quot;&lt;DEFINED&gt;FALSE&lt;/DEFINED&gt;&quot;)
139 StyleRangeAssignmentList(n) = AssignString
140End Sub
140End Sub
141
142
143&apos; deletes a styletemplate from the Collection that selects the ranges
144Sub DeselectStyle(DeSelStyleName as String, n as Integer)
145Dim i as Integer
146Dim RangeName as String
147Dim SelectString as String
148Dim AssignString as String
149Dim StyleRangeList() as String
150Dim MaxIndex as Integer
151 SelectString =&quot;&lt;SELECTED&gt;FALSE&lt;/SELECTED&gt;&quot;
152 AssignString = StyleRangeAssignmentList(n)
153 RangeString = FindPartString(AssignString,&quot;&lt;RANGES&gt;&quot;,&quot;&lt;/RANGES&gt;&quot;,1)
154 StyleRangeList() = ArrayoutofString(RangeString,&quot;,&quot;)
155 MaxIndex = Ubound(StyleRangeList())
156 For i = 0 To MaxIndex
157 RangeName = StyleRangeList(i)
158 If oSelRanges.HasbyName(RangeName) Then
141
142
143&apos; deletes a styletemplate from the Collection that selects the ranges
144Sub DeselectStyle(DeSelStyleName as String, n as Integer)
145Dim i as Integer
146Dim RangeName as String
147Dim SelectString as String
148Dim AssignString as String
149Dim StyleRangeList() as String
150Dim MaxIndex as Integer
151 SelectString =&quot;&lt;SELECTED&gt;FALSE&lt;/SELECTED&gt;&quot;
152 AssignString = StyleRangeAssignmentList(n)
153 RangeString = FindPartString(AssignString,&quot;&lt;RANGES&gt;&quot;,&quot;&lt;/RANGES&gt;&quot;,1)
154 StyleRangeList() = ArrayoutofString(RangeString,&quot;,&quot;)
155 MaxIndex = Ubound(StyleRangeList())
156 For i = 0 To MaxIndex
157 RangeName = StyleRangeList(i)
158 If oSelRanges.HasbyName(RangeName) Then
159 oSelRanges.RemovebyName(RangeName)
159 oSelRanges.RemovebyName(RangeName)
160 End If
161 Next i
162 AssignString = ReplaceString(AssignString, &quot;&lt;SELECTED&gt;FALSE&lt;/SELECTED&gt;&quot;, &quot;&lt;SELECTED&gt;TRUE&lt;/SELECTED&gt;&quot;)
163 StyleRangeAssignmentList(n) = AssignString
160 End If
161 Next i
162 AssignString = ReplaceString(AssignString, &quot;&lt;SELECTED&gt;FALSE&lt;/SELECTED&gt;&quot;, &quot;&lt;SELECTED&gt;TRUE&lt;/SELECTED&gt;&quot;)
163 StyleRangeAssignmentList(n) = AssignString
164End Sub
164End Sub
165
166
167Function RetrieveRangeNamefromAddress(oRange as Object) as String
168Dim Rangename as String
169Dim oAddressRanges as Object
170 oAddressRanges = oDocument.createInstance(&quot;com.sun.star.sheet.SheetCellRanges&quot;)
171 oAddressRanges.InsertbyName(&quot;&quot;,oRange)
165
166
167Function RetrieveRangeNamefromAddress(oRange as Object) as String
168Dim Rangename as String
169Dim oAddressRanges as Object
170 oAddressRanges = oDocument.createInstance(&quot;com.sun.star.sheet.SheetCellRanges&quot;)
171 oAddressRanges.InsertbyName(&quot;&quot;,oRange)
172 Rangename = oAddressRanges.RangeAddressesasString
172 Rangename = oAddressRanges.RangeAddressesasString
173&apos; Msgbox &quot;Adresse: &quot; &amp; oRangeAddress.StartColumn &amp; &quot; ; &quot; &amp; oRangeAddress.EndColumn &amp; &quot; ; &quot; &amp; oRangeAddress.StartRow &amp; &quot; ; &quot; &amp; oRangeAddress.EndRow &amp; chr(13) &amp; RangeName
174&apos; oAddressRanges.RemovebyName(RangeName)
175 RetrieveRangeNamefromAddress = Rangename
176End Function
177
178
179&apos; creates a sheet object from an according sectionname
173&apos; Msgbox &quot;Adresse: &quot; &amp; oRangeAddress.StartColumn &amp; &quot; ; &quot; &amp; oRangeAddress.EndColumn &amp; &quot; ; &quot; &amp; oRangeAddress.StartRow &amp; &quot; ; &quot; &amp; oRangeAddress.EndRow &amp; chr(13) &amp; RangeName
174&apos; oAddressRanges.RemovebyName(RangeName)
175 RetrieveRangeNamefromAddress = Rangename
176End Function
177
178
179&apos; creates a sheet object from an according sectionname
180Function RetrieveSheetoutofRangeName(TableText as String)
180Function RetrieveSheetoutofRangeName(TableText as String)
181Dim DescriptionList() as String
182Dim SheetName as String
183Dim MaxIndex as integer
184 &apos; find out in which sheet the range is
185 DescriptionList() = ArrayOutofString(TableText,&quot;.&quot;,MaxIndex)
186 SheetName = DescriptionList(0)
187 SheetName = DeleteStr(SheetName,&quot;&apos;&quot;)
188 &apos; set the viewcursor on this sheet
189 RetrieveSheetoutofRangeName = oSheets.GetbyName(SheetName)
190End Function
191
192
193&apos; creates a rangeobject from an according rangename
181Dim DescriptionList() as String
182Dim SheetName as String
183Dim MaxIndex as integer
184 &apos; find out in which sheet the range is
185 DescriptionList() = ArrayOutofString(TableText,&quot;.&quot;,MaxIndex)
186 SheetName = DescriptionList(0)
187 SheetName = DeleteStr(SheetName,&quot;&apos;&quot;)
188 &apos; set the viewcursor on this sheet
189 RetrieveSheetoutofRangeName = oSheets.GetbyName(SheetName)
190End Function
191
192
193&apos; creates a rangeobject from an according rangename
194Function RetrieveRangeoutofRangeName(TableText as String)
194Function RetrieveRangeoutofRangeName(TableText as String)
195 oSheet = RetrieveSheetoutofRangeName(TableText)
196 oRange = oSheet.GetCellRangebyName(TableText)
197 RetrieveRangeoutofRangeName = oRange
198End Function
199
200
201Sub ConvertTheSoftWay(StyleList(), bDeSelect as Boolean)
202Dim i as Integer

--- 30 unchanged lines hidden (view full) ---

233 oSelRanges.RemovebyName(RangeName)
234 oDocument.CurrentController.Select(oSelRanges)
235 End If
236 End If
237 Next s
238 SwitchNumberFormat(ostyle, oFormats, sEuroSign)
239 StyleRangeAssignmentList(n) = &quot;&quot;
240 l = GetItemPos(oSelListBox.Model, CurStyleName)
195 oSheet = RetrieveSheetoutofRangeName(TableText)
196 oRange = oSheet.GetCellRangebyName(TableText)
197 RetrieveRangeoutofRangeName = oRange
198End Function
199
200
201Sub ConvertTheSoftWay(StyleList(), bDeSelect as Boolean)
202Dim i as Integer

--- 30 unchanged lines hidden (view full) ---

233 oSelRanges.RemovebyName(RangeName)
234 oDocument.CurrentController.Select(oSelRanges)
235 End If
236 End If
237 Next s
238 SwitchNumberFormat(ostyle, oFormats, sEuroSign)
239 StyleRangeAssignmentList(n) = &quot;&quot;
240 l = GetItemPos(oSelListBox.Model, CurStyleName)
241 oSelListbox.RemoveItems(l,1)
241 oSelListbox.RemoveItems(l,1)
242 Next
243End Sub
244
245
246Function GetAssignedRanges(CurStyleName as String, n as Integer)
247Dim StyleRangeList() as String
248Dim RangeString as String
249Dim AssignString as String
250 n = PartStringInArray(StyleRangeAssignmentList(), CurStyleName, 0)
251 If n &lt;&gt; -1 Then
252 AssignString = StyleRangeAssignmentList(n)
253 RangeString = FindPartString(AssignString,&quot;&lt;RANGES&gt;&quot;, &quot;&lt;/RANGES&gt;&quot;,1)
254 If RangeString &lt;&gt; &quot;&quot; Then
255 StyleRangeList() = ArrayoutofString(RangeString,&quot;,&quot;)
256 End If
257 End If
258 GetAssignedRanges() = StyleRangeList()
259End Function</script:module>
242 Next
243End Sub
244
245
246Function GetAssignedRanges(CurStyleName as String, n as Integer)
247Dim StyleRangeList() as String
248Dim RangeString as String
249Dim AssignString as String
250 n = PartStringInArray(StyleRangeAssignmentList(), CurStyleName, 0)
251 If n &lt;&gt; -1 Then
252 AssignString = StyleRangeAssignmentList(n)
253 RangeString = FindPartString(AssignString,&quot;&lt;RANGES&gt;&quot;, &quot;&lt;/RANGES&gt;&quot;,1)
254 If RangeString &lt;&gt; &quot;&quot; Then
255 StyleRangeList() = ArrayoutofString(RangeString,&quot;,&quot;)
256 End If
257 End If
258 GetAssignedRanges() = StyleRangeList()
259End Function</script:module>