| <?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("Enter an identifier for the variable element:","Enter Variable ID") |
| |
| If ID="" Then |
| Exit Sub |
| End If |
| |
| thiscomponent.getcurrentcontroller.select(oCurStart) |
| InsertTag("VAR_","<VAR ID="""+ID+""">") |
| thiscomponent.getcurrentcontroller.select(oCurEnd) |
| InsertTag("_VAR","</VAR>") |
| End Sub |
| |
| Sub InsertInlineGraphic |
| If not IsHelpFile Then |
| msgbox(strErr_NoHelpFile) |
| Exit Sub |
| End If |
| sFName = OpenGraphics |
| If sFName <> "" Then |
| sAlt = InputBox("Enter an alternative Text for the graphical element."+chr(13)+"This can be changed later in the image properties.","ALT description","<ALT DESCRIPTION>") |
| sID = "img_id"+CreateID |
| InsertTag("IMG_","<IMG ID="""+sID+""">") |
| InsertGraphicFile(sFName,sID,sAlt) |
| InsertTag("_IMG","</IMG>") |
| End If |
| End Sub |
| |
| Sub InsertGraphic |
| |
| If not IsHelpFile Then |
| msgbox(strErr_NoHelpFile) |
| Exit Sub |
| End If |
| |
| GlobalScope.BasicLibraries.loadLibrary("Tools") |
| sFName = OpenGraphics |
| If sFName <> "" Then |
| DocRoot = ReadConfig("HelpPrefix") |
| ' msgbox("DocRoot "+DocRoot+chr(13)+"FName "+sFName) |
| |
| If not(IsSubDir(sFName,DocRoot)) Then |
| msgbox("Image is located outside of your Document Root"+chr(13)+DocRoot,48,"Warning") |
| End If |
| |
| sAlt = InputBox("Enter an alternative Text for the graphical element."+chr(13)+"This can be changed later in the image properties.","ALT description","<ALT DESCRIPTION>") |
| ' sCap = InputBox("Enter a caption for the image (optional)","Caption","") |
| sID = CreateID |
| CR |
| InsertTag("IMG_","<IMG ID="""+"img_id"+sID+""">") |
| InsertGraphicFile(sFName,"img_id"+sID,sAlt) |
| ' If sCap <> "" Then |
| ' InsertCaption(sCap,"cap_id"+sID) |
| ' End If |
| InsertTag("_IMG","</IMG>") |
| 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("com.sun.star.text.GraphicObject") |
| oGrp.GraphicURL = sURL |
| oGrp.AnchorType = 1 |
| oGrp.Name = sName |
| oGrp.Title = sAlt |
| oCur.Text.InsertTextContent(oCur,oGrp,true) |
| End Sub |
| |
| Sub SpecifyCaption |
| 'check if the image allows captions |
| If thiscomponent.getcurrentcontroller.getselection.ImplementationName = "SwXTextGraphicObject" Then |
| msgbox "Please press ESCAPE to deselect the image and recall the menu item" |
| Exit Sub |
| End If |
| If IsBlockImage Then |
| If not(HasCaption) Then |
| sCap = InputBox("Enter a caption for the image (optional)","Caption","") |
| If sCap <> "" Then |
| sID = GetImageID |
| sID = "cap"+right(sID, Len(sID)-3) |
| GoLeft(1) |
| InsertCaption(sCap, sID) |
| End If |
| Else |
| msgbox "Image has a caption already.",0,"D'oh!" |
| End If |
| Else |
| msgbox "Only block images may have captions.",0,"D'oh!" |
| End If |
| End Sub |
| |
| Sub InsertCaption(sCap As String, sID as String) |
| InsertTag("IMGCAPTION_","<IMGCAPTION id="""+sID+""">") |
| InsertText(sCap) |
| InsertTag("_IMGCAPTION","</IMGCAPTION>") |
| 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 ("Create a hidden tip?",3+32,"Extended Tip") |
| |
| If Ret=2 or Ret=3 Then |
| Exit Sub |
| End If |
| |
| thiscomponent.getcurrentcontroller.select(oCurStart) |
| If Ret=6 Then |
| InsertTag("AHID_","<AHID hid="""+ID+""">") |
| ElseIf Ret=7 Then |
| InsertTag("AVIS_","<AVIS hid="""+ID+""">") |
| End If |
| thiscomponent.getcurrentcontroller.select(oCurEnd) |
| If Ret=6 Then |
| InsertTag("_AHID","</AHID>") |
| ElseIf Ret=7 Then |
| InsertTag("_AVIS","</AVIS>") |
| End If |
| End Sub |
| |
| Sub InsertSort |
| CR |
| SetParaStyle("hlp_aux_sort") |
| InsertTag("SORT_","<SORT order=""asc"">","hlp_aux_sort") |
| GoLeft(1) |
| GoDown(1) |
| msgbox "Remember to also specify the closing SORT tag!",48,"Don't forget to close the tag" |
| End Sub |
| |
| Sub CloseSort |
| CR |
| SetParaStyle("hlp_aux_sort") |
| InsertTag("_SORT","</SORT>","hlp_aux_sort") |
| 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("Please specify a section name/identifier:")) |
| |
| If sSectionName = "" Then |
| Exit Sub |
| End If |
| |
| If sSectionName = "" Then |
| msgbox "No (valid) identifier -- no section."+chr(13)+"Hint: Use only A-Z,a-z,0-9 and _",48,"D'oh!" |
| Exit Sub |
| End If |
| |
| document = ThisComponent.CurrentController.Frame |
| dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") |
| |
| dim args(6) as new com.sun.star.beans.PropertyValue |
| args(0).Name = "RegionName" |
| args(0).Value = sSectionName |
| args(1).Name = "RegionCondition" |
| args(1).Value = "" |
| args(2).Name = "RegionHidden" |
| args(2).Value = false |
| args(3).Name = "RegionProtect" |
| args(3).Value = false |
| args(4).Name = "LinkName" |
| args(4).Value = "" |
| args(5).Name = "FilterName" |
| args(5).Value = "" |
| args(6).Name = "SubRegion" |
| args(6).Value = "" |
| |
| dispatcher.executeDispatch(document, ".uno:InsertSection", "", 0, args()) |
| |
| If oCur.GetString <> "" Then |
| thiscomponent.getcurrentcontroller.select(oCurStart) |
| CR_before |
| GoUp(1) |
| InsertTag("SECTION_","<SECTION id="""+sSectionName+""">") |
| SetParaStyle("hlp_aux_section") |
| |
| thiscomponent.getcurrentcontroller.select(oCurEnd) |
| CR |
| SetParaStyle("hlp_aux_section") |
| InsertTag("_SECTION","</SECTION>") |
| Else |
| GoUp(1) |
| InsertTagCR("SECTION_","<SECTION id="""+sSectionName+""">","hlp_aux_section") |
| CR |
| SetParaStyle("hlp_aux_section") |
| InsertTag("_SECTION","</SECTION>") |
| GoUp(1) |
| SetParaStyle("hlp_default") |
| 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 <> "" Then |
| msgbox "Error in paragraph status:"+chr(13)+sMsg,48,"Error" |
| Exit Sub |
| End If |
| |
| |
| If (sID = "") Then |
| msgbox "Paragraph has no ID. Assigning ID.",48,"Info" |
| InsertNewParaData |
| thiscomponent.getcurrentcontroller.select(oSel(0)) |
| arParaData = GetParaData |
| sID = arParaData(0) |
| slocalize = arParaData(1) |
| sMsg = arParaData(2) |
| End If |
| |
| If slocalize = "no" Then |
| SetParaData(sID,"yes") |
| Else |
| SetParaData(sID,"no") |
| End If |
| |
| thiscomponent.getcurrentcontroller.select(oSel(0)) |
| |
| End Sub |
| |
| |
| Sub LocalizeImage |
| oSel = thiscomponent.getcurrentcontroller.getselection |
| If oSel(0).ImplementationName <> "SwXTextGraphicObject" Then |
| msgbox "Please select an image" |
| Else |
| If Instr(oSel(0).Name," ")>0 Then |
| oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name," ")-1) |
| End If |
| oSel(0).Name = oSel(0).Name + " localize=""true""" |
| End If |
| SetBorder |
| End Sub |
| |
| |
| Sub UnLocalizeImage |
| oSel = thiscomponent.getcurrentcontroller.getselection |
| If oSel(0).ImplementationName <> "SwXTextGraphicObject" Then |
| msgbox "Please select an image" |
| Else |
| |
| If Instr(oSel(0).Name," ")>0 Then |
| oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name," ")-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("com.sun.star.frame.DispatchHelper") |
| |
| dim args(6) as new com.sun.star.beans.PropertyValue |
| args(0).Name = "RegionName" |
| args(0).Value = "howtoget" |
| args(1).Name = "RegionCondition" |
| args(1).Value = "" |
| args(2).Name = "RegionHidden" |
| args(2).Value = false |
| args(3).Name = "RegionProtect" |
| args(3).Value = false |
| args(4).Name = "LinkName" |
| args(4).Value = "" |
| args(5).Name = "FilterName" |
| args(5).Value = "" |
| args(6).Name = "SubRegion" |
| args(6).Value = "" |
| |
| dispatcher.executeDispatch(document, ".uno:InsertSection", "", 0, args()) |
| GoUp(1) |
| InsertTagCR("SECTION_","<SECTION id=""howtoget"">","hlp_aux_section") |
| CR |
| SetParaStyle("hlp_aux_section") |
| InsertTag("_SECTION","</SECTION>") |
| GoUp(1) |
| SetParaStyle("hlp_default") |
| ' Embed.Main(false) |
| End Sub |
| |
| Sub InsertRelatedTopics |
| |
| If not IsHelpFile Then |
| msgbox(strErr_NoHelpFile) |
| Exit Sub |
| End If |
| |
| document = ThisComponent.CurrentController.Frame |
| dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") |
| |
| dim args(6) as new com.sun.star.beans.PropertyValue |
| args(0).Name = "RegionName" |
| args(0).Value = "relatedtopics" |
| args(1).Name = "RegionCondition" |
| args(1).Value = "" |
| args(2).Name = "RegionHidden" |
| args(2).Value = false |
| args(3).Name = "RegionProtect" |
| args(3).Value = false |
| args(4).Name = "LinkName" |
| args(4).Value = "" |
| args(5).Name = "FilterName" |
| args(5).Value = "" |
| args(6).Name = "SubRegion" |
| args(6).Value = "" |
| |
| dispatcher.executeDispatch(document, ".uno:InsertSection", "", 0, args()) |
| GoUp(1) |
| InsertTagCR("SECTION_","<SECTION id=""relatedtopics"">","hlp_aux_section") |
| CR |
| SetParaStyle("hlp_aux_section") |
| InsertTag("_SECTION","</SECTION>") |
| GoUp(1) |
| SetParaStyle("hlp_default") |
| 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("com.sun.star.frame.DispatchHelper") |
| |
| rem ---------------------------------------------------------------------- |
| dim args1(7) as new com.sun.star.beans.PropertyValue |
| args1(0).Name = "BorderOuter.LeftBorder" |
| args1(0).Value = Array(0,0,0,0) |
| args1(1).Name = "BorderOuter.LeftDistance" |
| args1(1).Value = 10 |
| args1(2).Name = "BorderOuter.RightBorder" |
| args1(2).Value = Array(0,0,0,0) |
| args1(3).Name = "BorderOuter.RightDistance" |
| args1(3).Value = 0 |
| args1(4).Name = "BorderOuter.TopBorder" |
| args1(4).Value = Array(0,0,0,0) |
| args1(5).Name = "BorderOuter.TopDistance" |
| args1(5).Value = 0 |
| args1(6).Name = "BorderOuter.BottomBorder" |
| args1(6).Value = Array(0,0,0,0) |
| args1(7).Name = "BorderOuter.BottomDistance" |
| args1(7).Value = 0 |
| |
| dispatcher.executeDispatch(document, ".uno:BorderOuter", "", 0, args1()) |
| |
| rem ---------------------------------------------------------------------- |
| dim args2(4) as new com.sun.star.beans.PropertyValue |
| args2(0).Name = "BorderInner.Horizontal" |
| args2(0).Value = Array(0,0,0,0) |
| args2(1).Name = "BorderInner.Vertical" |
| args2(1).Value = Array(0,0,0,0) |
| args2(2).Name = "BorderInner.Flags" |
| args2(2).Value = 2 |
| args2(3).Name = "BorderInner.ValidFlags" |
| args2(3).Value = 63 |
| args2(4).Name = "BorderInner.DefaultDistance" |
| args2(4).Value = 0 |
| |
| dispatcher.executeDispatch(document, ".uno:BorderInner", "", 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("com.sun.star.frame.DispatchHelper") |
| |
| rem ---------------------------------------------------------------------- |
| dim args1(7) as new com.sun.star.beans.PropertyValue |
| args1(0).Name = "BorderOuter.LeftBorder" |
| args1(0).Value = Array(15167232,0,88,0) |
| args1(1).Name = "BorderOuter.LeftDistance" |
| args1(1).Value = 101 |
| args1(2).Name = "BorderOuter.RightBorder" |
| args1(2).Value = Array(15167232,0,88,0) |
| args1(3).Name = "BorderOuter.RightDistance" |
| args1(3).Value = 101 |
| args1(4).Name = "BorderOuter.TopBorder" |
| args1(4).Value = Array(15167232,0,88,0) |
| args1(5).Name = "BorderOuter.TopDistance" |
| args1(5).Value = 101 |
| args1(6).Name = "BorderOuter.BottomBorder" |
| args1(6).Value = Array(15167232,0,88,0) |
| args1(7).Name = "BorderOuter.BottomDistance" |
| args1(7).Value = 101 |
| |
| dispatcher.executeDispatch(document, ".uno:BorderOuter", "", 0, args1()) |
| |
| rem ---------------------------------------------------------------------- |
| dim args2(4) as new com.sun.star.beans.PropertyValue |
| args2(0).Name = "BorderInner.Horizontal" |
| args2(0).Value = Array(0,0,0,0) |
| args2(1).Name = "BorderInner.Vertical" |
| args2(1).Value = Array(0,0,0,0) |
| args2(2).Name = "BorderInner.Flags" |
| args2(2).Value = 2 |
| args2(3).Name = "BorderInner.ValidFlags" |
| args2(3).Value = 127 |
| args2(4).Name = "BorderInner.DefaultDistance" |
| args2(4).Value = 0 |
| |
| dispatcher.executeDispatch(document, ".uno:BorderInner", "", 0, args2()) |
| |
| |
| end sub |
| </script:module> |