1vJ7IguEWBfVakYkVCE5n3 changeset

Changeset363935623035 (b)
ParentNone (a)
ab
0+Sub TextToHyperlink()
0+        selection = ThisComponent.CurrentSelection
0+        Select Case (selection.ImplementationName)
0+                Case "ScCellObj"
0+                        ReplaceHyperlink(selection)
0+                Case "ScCellRangeObj"
0+                        RangeReplaceHyperlink(selection.RangeAddress)
0+                Case "ScCellRangesObj"
0+                        For Each address In selection.RangeAddresses
0+                                RangeReplaceHyperlink(address)                 
0+                        Next
0+        End Select
0+End Sub
0+
0+Sub RangeReplaceHyperlink(ByVal address)
0+        sheet = ThisComponent.Sheets(address.Sheet)
0+        For y = address.StartRow To address.EndRow
0+                For x = address.StartColumn To address.EndColumn
0+                        ReplaceHyperlink(sheet.getCellByPosition(x, y))
0+                Next
0+        Next
0+End Sub
0+
0+Sub ReplaceHyperlink(ByVal cell)
0+        If (cell.String = "") Then
0+                Exit Sub
0+        End If
0+        hyperlink = ThisComponent.createInstance("com.sun.star.text.TextField.URL")
0+        hyperlink.Representation = cell.String
0+        hyperlink.URL = cell.String
0+        cell.Text.insertTextContent(cell.createTextCursor(), hyperlink, True)
0+End Sub
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--- Revision None
+++ Revision 363935623035
@@ -0,0 +1,32 @@
+Sub TextToHyperlink()
+ selection = ThisComponent.CurrentSelection
+ Select Case (selection.ImplementationName)
+ Case "ScCellObj"
+ ReplaceHyperlink(selection)
+ Case "ScCellRangeObj"
+ RangeReplaceHyperlink(selection.RangeAddress)
+ Case "ScCellRangesObj"
+ For Each address In selection.RangeAddresses
+ RangeReplaceHyperlink(address)
+ Next
+ End Select
+End Sub
+
+Sub RangeReplaceHyperlink(ByVal address)
+ sheet = ThisComponent.Sheets(address.Sheet)
+ For y = address.StartRow To address.EndRow
+ For x = address.StartColumn To address.EndColumn
+ ReplaceHyperlink(sheet.getCellByPosition(x, y))
+ Next
+ Next
+End Sub
+
+Sub ReplaceHyperlink(ByVal cell)
+ If (cell.String = "") Then
+ Exit Sub
+ End If
+ hyperlink = ThisComponent.createInstance("com.sun.star.text.TextField.URL")
+ hyperlink.Representation = cell.String
+ hyperlink.URL = cell.String
+ cell.Text.insertTextContent(cell.createTextCursor(), hyperlink, True)
+End Sub