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