xref: /AOO41X/main/helpauthoring/HelpAuthoring/OtherElements.xba (revision 8809db7a87f97847b57a57f4cd2b0104b2b83182)
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="OtherElements" script:language="StarBasic">REM  *****  BASIC  *****
4
5Sub Main
6
7End Sub
8
9Sub InsertVariable
10
11    If not IsHelpFile Then
12        msgbox(strErr_NoHelpFile)
13        Exit Sub
14    End If
15
16    oSel = thiscomponent.getcurrentcontroller.getselection
17    oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
18    oStart = oCur.getStart
19    oCurStart = oStart.getText.createTextCursorByRange(oStart)
20    oEnd = oCur.getEnd
21    oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
22
23    ID = inputbox(&quot;Enter an identifier for the variable element:&quot;,&quot;Enter Variable ID&quot;)
24
25    If ID=&quot;&quot; Then
26        Exit Sub
27    End If
28
29    thiscomponent.getcurrentcontroller.select(oCurStart)
30    InsertTag(&quot;VAR_&quot;,&quot;&lt;VAR ID=&quot;&quot;&quot;+ID+&quot;&quot;&quot;&gt;&quot;)
31    thiscomponent.getcurrentcontroller.select(oCurEnd)
32    InsertTag(&quot;_VAR&quot;,&quot;&lt;/VAR&gt;&quot;)
33End Sub
34
35Sub InsertInlineGraphic
36    If not IsHelpFile Then
37        msgbox(strErr_NoHelpFile)
38        Exit Sub
39    End If
40    sFName = OpenGraphics
41    If sFName &lt;&gt; &quot;&quot; Then
42        sAlt = InputBox(&quot;Enter an alternative Text for the graphical element.&quot;+chr(13)+&quot;This can be changed later in the image properties.&quot;,&quot;ALT description&quot;,&quot;&lt;ALT DESCRIPTION&gt;&quot;)
43        sID = &quot;img_id&quot;+CreateID
44        InsertTag(&quot;IMG_&quot;,&quot;&lt;IMG ID=&quot;&quot;&quot;+sID+&quot;&quot;&quot;&gt;&quot;)
45        InsertGraphicFile(sFName,sID,sAlt)
46        InsertTag(&quot;_IMG&quot;,&quot;&lt;/IMG&gt;&quot;)
47    End If
48End Sub
49
50Sub InsertGraphic
51
52    If not IsHelpFile Then
53        msgbox(strErr_NoHelpFile)
54        Exit Sub
55    End If
56
57    GlobalScope.BasicLibraries.loadLibrary(&quot;Tools&quot;)
58    sFName = OpenGraphics
59    If sFName &lt;&gt; &quot;&quot; Then
60        DocRoot = ReadConfig(&quot;HelpPrefix&quot;)
61&apos;      msgbox(&quot;DocRoot &quot;+DocRoot+chr(13)+&quot;FName &quot;+sFName)
62
63        If not(IsSubDir(sFName,DocRoot)) Then
64            msgbox(&quot;Image is located outside of your Document Root&quot;+chr(13)+DocRoot,48,&quot;Warning&quot;)
65        End If
66
67        sAlt = InputBox(&quot;Enter an alternative Text for the graphical element.&quot;+chr(13)+&quot;This can be changed later in the image properties.&quot;,&quot;ALT description&quot;,&quot;&lt;ALT DESCRIPTION&gt;&quot;)
68&apos;      sCap = InputBox(&quot;Enter a caption for the image (optional)&quot;,&quot;Caption&quot;,&quot;&quot;)
69        sID = CreateID
70        CR
71        InsertTag(&quot;IMG_&quot;,&quot;&lt;IMG ID=&quot;&quot;&quot;+&quot;img_id&quot;+sID+&quot;&quot;&quot;&gt;&quot;)
72        InsertGraphicFile(sFName,&quot;img_id&quot;+sID,sAlt)
73&apos;      If sCap &lt;&gt; &quot;&quot; Then
74&apos;          InsertCaption(sCap,&quot;cap_id&quot;+sID)
75&apos;      End If
76        InsertTag(&quot;_IMG&quot;,&quot;&lt;/IMG&gt;&quot;)
77    End If
78End Sub
79
80
81Sub InsertGraphicFile(sURL As String, sName As String, sAlt As String)
82    oSel = thiscomponent.getcurrentcontroller.getselection
83    oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
84    oDoc = StarDesktop.CurrentComponent
85    oGrp = oDoc.createInstance(&quot;com.sun.star.text.GraphicObject&quot;)
86    oGrp.GraphicURL = sURL
87    oGrp.AnchorType = 1
88    oGrp.Name = sName
89    oGrp.Title = sAlt
90    oCur.Text.InsertTextContent(oCur,oGrp,true)
91End Sub
92
93Sub SpecifyCaption
94    &apos;check if the image allows captions
95    If thiscomponent.getcurrentcontroller.getselection.ImplementationName = &quot;SwXTextGraphicObject&quot; Then
96        msgbox &quot;Please press ESCAPE to deselect the image and recall the menu item&quot;
97        Exit Sub
98    End If
99    If IsBlockImage Then
100        If not(HasCaption) Then
101            sCap = InputBox(&quot;Enter a caption for the image (optional)&quot;,&quot;Caption&quot;,&quot;&quot;)
102            If sCap &lt;&gt; &quot;&quot; Then
103                sID = GetImageID
104                sID = &quot;cap&quot;+right(sID, Len(sID)-3)
105                GoLeft(1)
106                InsertCaption(sCap, sID)
107            End If
108        Else
109            msgbox &quot;Image has a caption already.&quot;,0,&quot;D&apos;oh!&quot;
110        End If
111    Else
112        msgbox &quot;Only block images may have captions.&quot;,0,&quot;D&apos;oh!&quot;
113    End If
114End Sub
115
116Sub InsertCaption(sCap As String, sID as String)
117        InsertTag(&quot;IMGCAPTION_&quot;,&quot;&lt;IMGCAPTION id=&quot;&quot;&quot;+sID+&quot;&quot;&quot;&gt;&quot;)
118        InsertText(sCap)
119        InsertTag(&quot;_IMGCAPTION&quot;,&quot;&lt;/IMGCAPTION&gt;&quot;)
120End Sub
121
122Sub InsertExtendedTip
123
124    If not IsHelpFile Then
125        msgbox(strErr_NoHelpFile)
126        Exit Sub
127    End If
128
129    oSel = thiscomponent.getcurrentcontroller.getselection
130    oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
131    oStart = oCur.getStart
132    oCurStart = oStart.getText.createTextCursorByRange(oStart)
133    oEnd = oCur.getEnd
134    oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
135
136    Ret = msgbox (&quot;Create a hidden tip?&quot;,3+32,&quot;Extended Tip&quot;)
137
138    If Ret=2 or Ret=3 Then
139        Exit Sub
140    End If
141
142    thiscomponent.getcurrentcontroller.select(oCurStart)
143    If Ret=6 Then
144        InsertTag(&quot;AHID_&quot;,&quot;&lt;AHID hid=&quot;&quot;&quot;+ID+&quot;&quot;&quot;&gt;&quot;)
145    ElseIf Ret=7 Then
146        InsertTag(&quot;AVIS_&quot;,&quot;&lt;AVIS hid=&quot;&quot;&quot;+ID+&quot;&quot;&quot;&gt;&quot;)
147    End If
148    thiscomponent.getcurrentcontroller.select(oCurEnd)
149    If Ret=6 Then
150        InsertTag(&quot;_AHID&quot;,&quot;&lt;/AHID&gt;&quot;)
151    ElseIf Ret=7 Then
152        InsertTag(&quot;_AVIS&quot;,&quot;&lt;/AVIS&gt;&quot;)
153    End If
154End Sub
155
156Sub InsertSort
157    CR
158    SetParaStyle(&quot;hlp_aux_sort&quot;)
159    InsertTag(&quot;SORT_&quot;,&quot;&lt;SORT order=&quot;&quot;asc&quot;&quot;&gt;&quot;,&quot;hlp_aux_sort&quot;)
160    GoLeft(1)
161    GoDown(1)
162    msgbox &quot;Remember to also specify the closing SORT tag!&quot;,48,&quot;Don&apos;t forget to close the tag&quot;
163End Sub
164
165Sub CloseSort
166    CR
167    SetParaStyle(&quot;hlp_aux_sort&quot;)
168    InsertTag(&quot;_SORT&quot;,&quot;&lt;/SORT&gt;&quot;,&quot;hlp_aux_sort&quot;)
169    GoLeft(1)
170    GoDown(1)
171End Sub
172
173sub InsertSection
174
175
176    If not IsHelpFile Then
177        msgbox(strErr_NoHelpFile)
178        Exit Sub
179    End If
180
181    dim document   as object
182    dim dispatcher as object
183
184    oSel = thiscomponent.getcurrentcontroller.getselection
185    oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
186    oStart = oCur.getStart
187    oCurStart = oStart.getText.createTextCursorByRange(oStart)
188    oEnd = oCur.getEnd
189    oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
190
191    sSectionName = AlphaNum(inputbox(&quot;Please specify a section name/identifier:&quot;))
192
193    If sSectionName = &quot;&quot; Then
194        Exit Sub
195    End If
196
197    If sSectionName = &quot;&quot; Then
198        msgbox &quot;No (valid) identifier -- no section.&quot;+chr(13)+&quot;Hint: Use only A-Z,a-z,0-9 and _&quot;,48,&quot;D&apos;oh!&quot;
199        Exit Sub
200    End If
201
202    document   = ThisComponent.CurrentController.Frame
203    dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
204
205    dim args(6) as new com.sun.star.beans.PropertyValue
206    args(0).Name = &quot;RegionName&quot;
207    args(0).Value = sSectionName
208    args(1).Name = &quot;RegionCondition&quot;
209    args(1).Value = &quot;&quot;
210    args(2).Name = &quot;RegionHidden&quot;
211    args(2).Value = false
212    args(3).Name = &quot;RegionProtect&quot;
213    args(3).Value = false
214    args(4).Name = &quot;LinkName&quot;
215    args(4).Value = &quot;&quot;
216    args(5).Name = &quot;FilterName&quot;
217    args(5).Value = &quot;&quot;
218    args(6).Name = &quot;SubRegion&quot;
219    args(6).Value = &quot;&quot;
220
221    dispatcher.executeDispatch(document, &quot;.uno:InsertSection&quot;, &quot;&quot;, 0, args())
222
223    If oCur.GetString &lt;&gt; &quot;&quot; Then
224        thiscomponent.getcurrentcontroller.select(oCurStart)
225        CR_before
226        GoUp(1)
227        InsertTag(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;&quot;+sSectionName+&quot;&quot;&quot;&gt;&quot;)
228        SetParaStyle(&quot;hlp_aux_section&quot;)
229
230        thiscomponent.getcurrentcontroller.select(oCurEnd)
231        CR
232        SetParaStyle(&quot;hlp_aux_section&quot;)
233        InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
234    Else
235        GoUp(1)
236        InsertTagCR(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;&quot;+sSectionName+&quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_section&quot;)
237        CR
238        SetParaStyle(&quot;hlp_aux_section&quot;)
239        InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
240        GoUp(1)
241        SetParaStyle(&quot;hlp_default&quot;)
242    End If
243
244end sub
245
246Sub ToggleParaL10NStatus
247
248    If not IsHelpFile Then
249        msgbox(strErr_NoHelpFile)
250        Exit Sub
251    End If
252
253    oSel = thiscomponent.getcurrentcontroller.getselection
254    oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
255
256    oCur.gotoStartOfParagraph(0)
257    CharStyle = oCur.charStyleName
258
259    arParaData = GetParaData
260    sID = arParaData(0)
261    slocalize = arParaData(1)
262    sMsg = arParaData(2)
263
264    If sMsg &lt;&gt; &quot;&quot; Then
265        msgbox &quot;Error in paragraph status:&quot;+chr(13)+sMsg,48,&quot;Error&quot;
266        Exit Sub
267    End If
268
269
270    If (sID = &quot;&quot;) Then
271        msgbox &quot;Paragraph has no ID. Assigning ID.&quot;,48,&quot;Info&quot;
272        InsertNewParaData
273        thiscomponent.getcurrentcontroller.select(oSel(0))
274        arParaData = GetParaData
275        sID = arParaData(0)
276        slocalize = arParaData(1)
277        sMsg = arParaData(2)
278    End If
279
280    If slocalize = &quot;no&quot; Then
281        SetParaData(sID,&quot;yes&quot;)
282    Else
283        SetParaData(sID,&quot;no&quot;)
284    End If
285
286    thiscomponent.getcurrentcontroller.select(oSel(0))
287
288End Sub
289
290
291Sub LocalizeImage
292    oSel = thiscomponent.getcurrentcontroller.getselection
293    If oSel(0).ImplementationName &lt;&gt; &quot;SwXTextGraphicObject&quot; Then
294        msgbox &quot;Please select an image&quot;
295    Else
296        If Instr(oSel(0).Name,&quot; &quot;)&gt;0 Then
297            oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name,&quot; &quot;)-1)
298        End If
299        oSel(0).Name = oSel(0).Name + &quot; localize=&quot;&quot;true&quot;&quot;&quot;
300    End If
301    SetBorder
302End Sub
303
304
305Sub UnLocalizeImage
306    oSel = thiscomponent.getcurrentcontroller.getselection
307    If oSel(0).ImplementationName &lt;&gt; &quot;SwXTextGraphicObject&quot; Then
308        msgbox &quot;Please select an image&quot;
309    Else
310
311        If Instr(oSel(0).Name,&quot; &quot;)&gt;0 Then
312            oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name,&quot; &quot;)-1)
313        End If
314        UnsetBorder
315    End If
316
317End Sub
318
319
320Sub ResetAllParaStatusValues
321    REM ... to be done
322End Sub
323
324Sub InsertHowToGet
325
326    If not IsHelpFile Then
327        msgbox(strErr_NoHelpFile)
328        Exit Sub
329    End If
330
331    document   = ThisComponent.CurrentController.Frame
332    dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
333
334    dim args(6) as new com.sun.star.beans.PropertyValue
335    args(0).Name = &quot;RegionName&quot;
336    args(0).Value = &quot;howtoget&quot;
337    args(1).Name = &quot;RegionCondition&quot;
338    args(1).Value = &quot;&quot;
339    args(2).Name = &quot;RegionHidden&quot;
340    args(2).Value = false
341    args(3).Name = &quot;RegionProtect&quot;
342    args(3).Value = false
343    args(4).Name = &quot;LinkName&quot;
344    args(4).Value = &quot;&quot;
345    args(5).Name = &quot;FilterName&quot;
346    args(5).Value = &quot;&quot;
347    args(6).Name = &quot;SubRegion&quot;
348    args(6).Value = &quot;&quot;
349
350    dispatcher.executeDispatch(document, &quot;.uno:InsertSection&quot;, &quot;&quot;, 0, args())
351    GoUp(1)
352    InsertTagCR(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;howtoget&quot;&quot;&gt;&quot;,&quot;hlp_aux_section&quot;)
353    CR
354    SetParaStyle(&quot;hlp_aux_section&quot;)
355    InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
356    GoUp(1)
357    SetParaStyle(&quot;hlp_default&quot;)
358&apos;  Embed.Main(false)
359End Sub
360
361Sub InsertRelatedTopics
362
363    If not IsHelpFile Then
364        msgbox(strErr_NoHelpFile)
365        Exit Sub
366    End If
367
368    document   = ThisComponent.CurrentController.Frame
369    dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
370
371    dim args(6) as new com.sun.star.beans.PropertyValue
372    args(0).Name = &quot;RegionName&quot;
373    args(0).Value = &quot;relatedtopics&quot;
374    args(1).Name = &quot;RegionCondition&quot;
375    args(1).Value = &quot;&quot;
376    args(2).Name = &quot;RegionHidden&quot;
377    args(2).Value = false
378    args(3).Name = &quot;RegionProtect&quot;
379    args(3).Value = false
380    args(4).Name = &quot;LinkName&quot;
381    args(4).Value = &quot;&quot;
382    args(5).Name = &quot;FilterName&quot;
383    args(5).Value = &quot;&quot;
384    args(6).Name = &quot;SubRegion&quot;
385    args(6).Value = &quot;&quot;
386
387    dispatcher.executeDispatch(document, &quot;.uno:InsertSection&quot;, &quot;&quot;, 0, args())
388    GoUp(1)
389    InsertTagCR(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;relatedtopics&quot;&quot;&gt;&quot;,&quot;hlp_aux_section&quot;)
390    CR
391    SetParaStyle(&quot;hlp_aux_section&quot;)
392    InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
393    GoUp(1)
394    SetParaStyle(&quot;hlp_default&quot;)
395End Sub
396
397
398sub UnsetBorder
399rem ----------------------------------------------------------------------
400rem define variables
401dim document   as object
402dim dispatcher as object
403rem ----------------------------------------------------------------------
404rem get access to the document
405document   = ThisComponent.CurrentController.Frame
406dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
407
408rem ----------------------------------------------------------------------
409dim args1(7) as new com.sun.star.beans.PropertyValue
410args1(0).Name = &quot;BorderOuter.LeftBorder&quot;
411args1(0).Value = Array(0,0,0,0)
412args1(1).Name = &quot;BorderOuter.LeftDistance&quot;
413args1(1).Value = 10
414args1(2).Name = &quot;BorderOuter.RightBorder&quot;
415args1(2).Value = Array(0,0,0,0)
416args1(3).Name = &quot;BorderOuter.RightDistance&quot;
417args1(3).Value = 0
418args1(4).Name = &quot;BorderOuter.TopBorder&quot;
419args1(4).Value = Array(0,0,0,0)
420args1(5).Name = &quot;BorderOuter.TopDistance&quot;
421args1(5).Value = 0
422args1(6).Name = &quot;BorderOuter.BottomBorder&quot;
423args1(6).Value = Array(0,0,0,0)
424args1(7).Name = &quot;BorderOuter.BottomDistance&quot;
425args1(7).Value = 0
426
427dispatcher.executeDispatch(document, &quot;.uno:BorderOuter&quot;, &quot;&quot;, 0, args1())
428
429rem ----------------------------------------------------------------------
430dim args2(4) as new com.sun.star.beans.PropertyValue
431args2(0).Name = &quot;BorderInner.Horizontal&quot;
432args2(0).Value = Array(0,0,0,0)
433args2(1).Name = &quot;BorderInner.Vertical&quot;
434args2(1).Value = Array(0,0,0,0)
435args2(2).Name = &quot;BorderInner.Flags&quot;
436args2(2).Value = 2
437args2(3).Name = &quot;BorderInner.ValidFlags&quot;
438args2(3).Value = 63
439args2(4).Name = &quot;BorderInner.DefaultDistance&quot;
440args2(4).Value = 0
441
442dispatcher.executeDispatch(document, &quot;.uno:BorderInner&quot;, &quot;&quot;, 0, args2())
443
444
445end sub
446
447
448
449sub SetBorder
450rem ----------------------------------------------------------------------
451rem define variables
452dim document   as object
453dim dispatcher as object
454rem ----------------------------------------------------------------------
455rem get access to the document
456document   = ThisComponent.CurrentController.Frame
457dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
458
459rem ----------------------------------------------------------------------
460dim args1(7) as new com.sun.star.beans.PropertyValue
461args1(0).Name = &quot;BorderOuter.LeftBorder&quot;
462args1(0).Value = Array(15167232,0,88,0)
463args1(1).Name = &quot;BorderOuter.LeftDistance&quot;
464args1(1).Value = 101
465args1(2).Name = &quot;BorderOuter.RightBorder&quot;
466args1(2).Value = Array(15167232,0,88,0)
467args1(3).Name = &quot;BorderOuter.RightDistance&quot;
468args1(3).Value = 101
469args1(4).Name = &quot;BorderOuter.TopBorder&quot;
470args1(4).Value = Array(15167232,0,88,0)
471args1(5).Name = &quot;BorderOuter.TopDistance&quot;
472args1(5).Value = 101
473args1(6).Name = &quot;BorderOuter.BottomBorder&quot;
474args1(6).Value = Array(15167232,0,88,0)
475args1(7).Name = &quot;BorderOuter.BottomDistance&quot;
476args1(7).Value = 101
477
478dispatcher.executeDispatch(document, &quot;.uno:BorderOuter&quot;, &quot;&quot;, 0, args1())
479
480rem ----------------------------------------------------------------------
481dim args2(4) as new com.sun.star.beans.PropertyValue
482args2(0).Name = &quot;BorderInner.Horizontal&quot;
483args2(0).Value = Array(0,0,0,0)
484args2(1).Name = &quot;BorderInner.Vertical&quot;
485args2(1).Value = Array(0,0,0,0)
486args2(2).Name = &quot;BorderInner.Flags&quot;
487args2(2).Value = 2
488args2(3).Name = &quot;BorderInner.ValidFlags&quot;
489args2(3).Value = 127
490args2(4).Name = &quot;BorderInner.DefaultDistance&quot;
491args2(4).Value = 0
492
493dispatcher.executeDispatch(document, &quot;.uno:BorderInner&quot;, &quot;&quot;, 0, args2())
494
495
496end sub
497</script:module>