blob: 2a1da97ede8bb433ca553b0e7d4e0e41b0775427 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<!--***********************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
***********************************************************-->
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="OtherElements" script:language="StarBasic">REM ***** BASIC *****
Sub Main
End Sub
Sub InsertVariable
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
oSel = thiscomponent.getcurrentcontroller.getselection
oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
oStart = oCur.getStart
oCurStart = oStart.getText.createTextCursorByRange(oStart)
oEnd = oCur.getEnd
oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
ID = inputbox(&quot;Enter an identifier for the variable element:&quot;,&quot;Enter Variable ID&quot;)
If ID=&quot;&quot; Then
Exit Sub
End If
thiscomponent.getcurrentcontroller.select(oCurStart)
InsertTag(&quot;VAR_&quot;,&quot;&lt;VAR ID=&quot;&quot;&quot;+ID+&quot;&quot;&quot;&gt;&quot;)
thiscomponent.getcurrentcontroller.select(oCurEnd)
InsertTag(&quot;_VAR&quot;,&quot;&lt;/VAR&gt;&quot;)
End Sub
Sub InsertInlineGraphic
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
sFName = OpenGraphics
If sFName &lt;&gt; &quot;&quot; Then
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;)
sID = &quot;img_id&quot;+CreateID
InsertTag(&quot;IMG_&quot;,&quot;&lt;IMG ID=&quot;&quot;&quot;+sID+&quot;&quot;&quot;&gt;&quot;)
InsertGraphicFile(sFName,sID,sAlt)
InsertTag(&quot;_IMG&quot;,&quot;&lt;/IMG&gt;&quot;)
End If
End Sub
Sub InsertGraphic
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
GlobalScope.BasicLibraries.loadLibrary(&quot;Tools&quot;)
sFName = OpenGraphics
If sFName &lt;&gt; &quot;&quot; Then
DocRoot = ReadConfig(&quot;HelpPrefix&quot;)
&apos; msgbox(&quot;DocRoot &quot;+DocRoot+chr(13)+&quot;FName &quot;+sFName)
If not(IsSubDir(sFName,DocRoot)) Then
msgbox(&quot;Image is located outside of your Document Root&quot;+chr(13)+DocRoot,48,&quot;Warning&quot;)
End If
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;)
&apos; sCap = InputBox(&quot;Enter a caption for the image (optional)&quot;,&quot;Caption&quot;,&quot;&quot;)
sID = CreateID
CR
InsertTag(&quot;IMG_&quot;,&quot;&lt;IMG ID=&quot;&quot;&quot;+&quot;img_id&quot;+sID+&quot;&quot;&quot;&gt;&quot;)
InsertGraphicFile(sFName,&quot;img_id&quot;+sID,sAlt)
&apos; If sCap &lt;&gt; &quot;&quot; Then
&apos; InsertCaption(sCap,&quot;cap_id&quot;+sID)
&apos; End If
InsertTag(&quot;_IMG&quot;,&quot;&lt;/IMG&gt;&quot;)
End If
End Sub
Sub InsertGraphicFile(sURL As String, sName As String, sAlt As String)
oSel = thiscomponent.getcurrentcontroller.getselection
oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
oDoc = StarDesktop.CurrentComponent
oGrp = oDoc.createInstance(&quot;com.sun.star.text.GraphicObject&quot;)
oGrp.GraphicURL = sURL
oGrp.AnchorType = 1
oGrp.Name = sName
oGrp.Title = sAlt
oCur.Text.InsertTextContent(oCur,oGrp,true)
End Sub
Sub SpecifyCaption
&apos;check if the image allows captions
If thiscomponent.getcurrentcontroller.getselection.ImplementationName = &quot;SwXTextGraphicObject&quot; Then
msgbox &quot;Please press ESCAPE to deselect the image and recall the menu item&quot;
Exit Sub
End If
If IsBlockImage Then
If not(HasCaption) Then
sCap = InputBox(&quot;Enter a caption for the image (optional)&quot;,&quot;Caption&quot;,&quot;&quot;)
If sCap &lt;&gt; &quot;&quot; Then
sID = GetImageID
sID = &quot;cap&quot;+right(sID, Len(sID)-3)
GoLeft(1)
InsertCaption(sCap, sID)
End If
Else
msgbox &quot;Image has a caption already.&quot;,0,&quot;D&apos;oh!&quot;
End If
Else
msgbox &quot;Only block images may have captions.&quot;,0,&quot;D&apos;oh!&quot;
End If
End Sub
Sub InsertCaption(sCap As String, sID as String)
InsertTag(&quot;IMGCAPTION_&quot;,&quot;&lt;IMGCAPTION id=&quot;&quot;&quot;+sID+&quot;&quot;&quot;&gt;&quot;)
InsertText(sCap)
InsertTag(&quot;_IMGCAPTION&quot;,&quot;&lt;/IMGCAPTION&gt;&quot;)
End Sub
Sub InsertExtendedTip
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
oSel = thiscomponent.getcurrentcontroller.getselection
oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
oStart = oCur.getStart
oCurStart = oStart.getText.createTextCursorByRange(oStart)
oEnd = oCur.getEnd
oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
Ret = msgbox (&quot;Create a hidden tip?&quot;,3+32,&quot;Extended Tip&quot;)
If Ret=2 or Ret=3 Then
Exit Sub
End If
thiscomponent.getcurrentcontroller.select(oCurStart)
If Ret=6 Then
InsertTag(&quot;AHID_&quot;,&quot;&lt;AHID hid=&quot;&quot;&quot;+ID+&quot;&quot;&quot;&gt;&quot;)
ElseIf Ret=7 Then
InsertTag(&quot;AVIS_&quot;,&quot;&lt;AVIS hid=&quot;&quot;&quot;+ID+&quot;&quot;&quot;&gt;&quot;)
End If
thiscomponent.getcurrentcontroller.select(oCurEnd)
If Ret=6 Then
InsertTag(&quot;_AHID&quot;,&quot;&lt;/AHID&gt;&quot;)
ElseIf Ret=7 Then
InsertTag(&quot;_AVIS&quot;,&quot;&lt;/AVIS&gt;&quot;)
End If
End Sub
Sub InsertSort
CR
SetParaStyle(&quot;hlp_aux_sort&quot;)
InsertTag(&quot;SORT_&quot;,&quot;&lt;SORT order=&quot;&quot;asc&quot;&quot;&gt;&quot;,&quot;hlp_aux_sort&quot;)
GoLeft(1)
GoDown(1)
msgbox &quot;Remember to also specify the closing SORT tag!&quot;,48,&quot;Don&apos;t forget to close the tag&quot;
End Sub
Sub CloseSort
CR
SetParaStyle(&quot;hlp_aux_sort&quot;)
InsertTag(&quot;_SORT&quot;,&quot;&lt;/SORT&gt;&quot;,&quot;hlp_aux_sort&quot;)
GoLeft(1)
GoDown(1)
End Sub
sub InsertSection
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
dim document as object
dim dispatcher as object
oSel = thiscomponent.getcurrentcontroller.getselection
oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
oStart = oCur.getStart
oCurStart = oStart.getText.createTextCursorByRange(oStart)
oEnd = oCur.getEnd
oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
sSectionName = AlphaNum(inputbox(&quot;Please specify a section name/identifier:&quot;))
If sSectionName = &quot;&quot; Then
Exit Sub
End If
If sSectionName = &quot;&quot; Then
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;
Exit Sub
End If
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
dim args(6) as new com.sun.star.beans.PropertyValue
args(0).Name = &quot;RegionName&quot;
args(0).Value = sSectionName
args(1).Name = &quot;RegionCondition&quot;
args(1).Value = &quot;&quot;
args(2).Name = &quot;RegionHidden&quot;
args(2).Value = false
args(3).Name = &quot;RegionProtect&quot;
args(3).Value = false
args(4).Name = &quot;LinkName&quot;
args(4).Value = &quot;&quot;
args(5).Name = &quot;FilterName&quot;
args(5).Value = &quot;&quot;
args(6).Name = &quot;SubRegion&quot;
args(6).Value = &quot;&quot;
dispatcher.executeDispatch(document, &quot;.uno:InsertSection&quot;, &quot;&quot;, 0, args())
If oCur.GetString &lt;&gt; &quot;&quot; Then
thiscomponent.getcurrentcontroller.select(oCurStart)
CR_before
GoUp(1)
InsertTag(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;&quot;+sSectionName+&quot;&quot;&quot;&gt;&quot;)
SetParaStyle(&quot;hlp_aux_section&quot;)
thiscomponent.getcurrentcontroller.select(oCurEnd)
CR
SetParaStyle(&quot;hlp_aux_section&quot;)
InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
Else
GoUp(1)
InsertTagCR(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;&quot;+sSectionName+&quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_section&quot;)
CR
SetParaStyle(&quot;hlp_aux_section&quot;)
InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
GoUp(1)
SetParaStyle(&quot;hlp_default&quot;)
End If
end sub
Sub ToggleParaL10NStatus
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
oSel = thiscomponent.getcurrentcontroller.getselection
oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
oCur.gotoStartOfParagraph(0)
CharStyle = oCur.charStyleName
arParaData = GetParaData
sID = arParaData(0)
slocalize = arParaData(1)
sMsg = arParaData(2)
If sMsg &lt;&gt; &quot;&quot; Then
msgbox &quot;Error in paragraph status:&quot;+chr(13)+sMsg,48,&quot;Error&quot;
Exit Sub
End If
If (sID = &quot;&quot;) Then
msgbox &quot;Paragraph has no ID. Assigning ID.&quot;,48,&quot;Info&quot;
InsertNewParaData
thiscomponent.getcurrentcontroller.select(oSel(0))
arParaData = GetParaData
sID = arParaData(0)
slocalize = arParaData(1)
sMsg = arParaData(2)
End If
If slocalize = &quot;no&quot; Then
SetParaData(sID,&quot;yes&quot;)
Else
SetParaData(sID,&quot;no&quot;)
End If
thiscomponent.getcurrentcontroller.select(oSel(0))
End Sub
Sub LocalizeImage
oSel = thiscomponent.getcurrentcontroller.getselection
If oSel(0).ImplementationName &lt;&gt; &quot;SwXTextGraphicObject&quot; Then
msgbox &quot;Please select an image&quot;
Else
If Instr(oSel(0).Name,&quot; &quot;)&gt;0 Then
oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name,&quot; &quot;)-1)
End If
oSel(0).Name = oSel(0).Name + &quot; localize=&quot;&quot;true&quot;&quot;&quot;
End If
SetBorder
End Sub
Sub UnLocalizeImage
oSel = thiscomponent.getcurrentcontroller.getselection
If oSel(0).ImplementationName &lt;&gt; &quot;SwXTextGraphicObject&quot; Then
msgbox &quot;Please select an image&quot;
Else
If Instr(oSel(0).Name,&quot; &quot;)&gt;0 Then
oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name,&quot; &quot;)-1)
End If
UnsetBorder
End If
End Sub
Sub ResetAllParaStatusValues
REM ... to be done
End Sub
Sub InsertHowToGet
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
dim args(6) as new com.sun.star.beans.PropertyValue
args(0).Name = &quot;RegionName&quot;
args(0).Value = &quot;howtoget&quot;
args(1).Name = &quot;RegionCondition&quot;
args(1).Value = &quot;&quot;
args(2).Name = &quot;RegionHidden&quot;
args(2).Value = false
args(3).Name = &quot;RegionProtect&quot;
args(3).Value = false
args(4).Name = &quot;LinkName&quot;
args(4).Value = &quot;&quot;
args(5).Name = &quot;FilterName&quot;
args(5).Value = &quot;&quot;
args(6).Name = &quot;SubRegion&quot;
args(6).Value = &quot;&quot;
dispatcher.executeDispatch(document, &quot;.uno:InsertSection&quot;, &quot;&quot;, 0, args())
GoUp(1)
InsertTagCR(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;howtoget&quot;&quot;&gt;&quot;,&quot;hlp_aux_section&quot;)
CR
SetParaStyle(&quot;hlp_aux_section&quot;)
InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
GoUp(1)
SetParaStyle(&quot;hlp_default&quot;)
&apos; Embed.Main(false)
End Sub
Sub InsertRelatedTopics
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
dim args(6) as new com.sun.star.beans.PropertyValue
args(0).Name = &quot;RegionName&quot;
args(0).Value = &quot;relatedtopics&quot;
args(1).Name = &quot;RegionCondition&quot;
args(1).Value = &quot;&quot;
args(2).Name = &quot;RegionHidden&quot;
args(2).Value = false
args(3).Name = &quot;RegionProtect&quot;
args(3).Value = false
args(4).Name = &quot;LinkName&quot;
args(4).Value = &quot;&quot;
args(5).Name = &quot;FilterName&quot;
args(5).Value = &quot;&quot;
args(6).Name = &quot;SubRegion&quot;
args(6).Value = &quot;&quot;
dispatcher.executeDispatch(document, &quot;.uno:InsertSection&quot;, &quot;&quot;, 0, args())
GoUp(1)
InsertTagCR(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;relatedtopics&quot;&quot;&gt;&quot;,&quot;hlp_aux_section&quot;)
CR
SetParaStyle(&quot;hlp_aux_section&quot;)
InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
GoUp(1)
SetParaStyle(&quot;hlp_default&quot;)
End Sub
sub UnsetBorder
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
rem ----------------------------------------------------------------------
dim args1(7) as new com.sun.star.beans.PropertyValue
args1(0).Name = &quot;BorderOuter.LeftBorder&quot;
args1(0).Value = Array(0,0,0,0)
args1(1).Name = &quot;BorderOuter.LeftDistance&quot;
args1(1).Value = 10
args1(2).Name = &quot;BorderOuter.RightBorder&quot;
args1(2).Value = Array(0,0,0,0)
args1(3).Name = &quot;BorderOuter.RightDistance&quot;
args1(3).Value = 0
args1(4).Name = &quot;BorderOuter.TopBorder&quot;
args1(4).Value = Array(0,0,0,0)
args1(5).Name = &quot;BorderOuter.TopDistance&quot;
args1(5).Value = 0
args1(6).Name = &quot;BorderOuter.BottomBorder&quot;
args1(6).Value = Array(0,0,0,0)
args1(7).Name = &quot;BorderOuter.BottomDistance&quot;
args1(7).Value = 0
dispatcher.executeDispatch(document, &quot;.uno:BorderOuter&quot;, &quot;&quot;, 0, args1())
rem ----------------------------------------------------------------------
dim args2(4) as new com.sun.star.beans.PropertyValue
args2(0).Name = &quot;BorderInner.Horizontal&quot;
args2(0).Value = Array(0,0,0,0)
args2(1).Name = &quot;BorderInner.Vertical&quot;
args2(1).Value = Array(0,0,0,0)
args2(2).Name = &quot;BorderInner.Flags&quot;
args2(2).Value = 2
args2(3).Name = &quot;BorderInner.ValidFlags&quot;
args2(3).Value = 63
args2(4).Name = &quot;BorderInner.DefaultDistance&quot;
args2(4).Value = 0
dispatcher.executeDispatch(document, &quot;.uno:BorderInner&quot;, &quot;&quot;, 0, args2())
end sub
sub SetBorder
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
rem ----------------------------------------------------------------------
dim args1(7) as new com.sun.star.beans.PropertyValue
args1(0).Name = &quot;BorderOuter.LeftBorder&quot;
args1(0).Value = Array(15167232,0,88,0)
args1(1).Name = &quot;BorderOuter.LeftDistance&quot;
args1(1).Value = 101
args1(2).Name = &quot;BorderOuter.RightBorder&quot;
args1(2).Value = Array(15167232,0,88,0)
args1(3).Name = &quot;BorderOuter.RightDistance&quot;
args1(3).Value = 101
args1(4).Name = &quot;BorderOuter.TopBorder&quot;
args1(4).Value = Array(15167232,0,88,0)
args1(5).Name = &quot;BorderOuter.TopDistance&quot;
args1(5).Value = 101
args1(6).Name = &quot;BorderOuter.BottomBorder&quot;
args1(6).Value = Array(15167232,0,88,0)
args1(7).Name = &quot;BorderOuter.BottomDistance&quot;
args1(7).Value = 101
dispatcher.executeDispatch(document, &quot;.uno:BorderOuter&quot;, &quot;&quot;, 0, args1())
rem ----------------------------------------------------------------------
dim args2(4) as new com.sun.star.beans.PropertyValue
args2(0).Name = &quot;BorderInner.Horizontal&quot;
args2(0).Value = Array(0,0,0,0)
args2(1).Name = &quot;BorderInner.Vertical&quot;
args2(1).Value = Array(0,0,0,0)
args2(2).Name = &quot;BorderInner.Flags&quot;
args2(2).Value = 2
args2(3).Name = &quot;BorderInner.ValidFlags&quot;
args2(3).Value = 127
args2(4).Name = &quot;BorderInner.DefaultDistance&quot;
args2(4).Value = 0
dispatcher.executeDispatch(document, &quot;.uno:BorderInner&quot;, &quot;&quot;, 0, args2())
end sub
</script:module>