Forbid creating bidirectional links with empty text

This commit is contained in:
Georgy Litvinov 2020-08-31 13:41:59 +02:00
parent 795ce507b7
commit 03b6c75cf3
3 changed files with 24 additions and 3 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Archive" script:language="StarBasic" script:moduleType="normal">Sub archMark17 <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Archive" script:language="StarBasic" script:moduleType="normal">Sub archMark18
End Sub End Sub
@ -53,6 +53,11 @@ Sub createBidirectLink
oAnchor1 = oSelections.getByIndex(1) oAnchor1 = oSelections.getByIndex(1)
oAnchor2 = oSelections.getByIndex(2) oAnchor2 = oSelections.getByIndex(2)
If isAnchorEmpty(oAnchor1) Or isAnchorEmpty(oAnchor2) Then
MsgBox getTranslation(&quot;bidirectLinkSuggestion&quot;)
Exit Sub
EndIf
oAnchor1Name = RND_String() oAnchor1Name = RND_String()
oAnchor2Name = RND_String() oAnchor2Name = RND_String()
createAnchor(oAnchor1,oAnchor1Name) createAnchor(oAnchor1,oAnchor1Name)
@ -61,6 +66,22 @@ Sub createBidirectLink
createLink(oAnchor2,oAnchor2.String,oAnchor1Name) createLink(oAnchor2,oAnchor2.String,oAnchor1Name)
End Sub End Sub
Function isAnchorEmpty(anchor As Object) As Boolean
Dim anchorName As String
anchorName = trim(anchor.String)
If Len(anchorName) = 0 Then
isAnchorEmpty = true
Exit Function
EndIf
If Len(anchorName) = 1 AND Chr(10) = anchorName Then
isAnchorEmpty = true
Exit Function
EndIf
isAnchorEmpty = false
End Function
Sub createAnchor(targetRange as Object,anchorName as String) Sub createAnchor(targetRange as Object,anchorName as String)
dim oViewCursor as object dim oViewCursor as object
dim document as object dim document as object

View file

@ -65,7 +65,7 @@ Function getRussian(identifier As String) As String
getRussian = &quot;Заменить стиль параграфа (с удалением) на выбранный стиль&quot; getRussian = &quot;Заменить стиль параграфа (с удалением) на выбранный стиль&quot;
Exit Function Exit Function
Case &quot;bidirectLinkSuggestion&quot; Case &quot;bidirectLinkSuggestion&quot;
getRussian = &quot;Нужно выделить два объекта для связывания&quot; getRussian = &quot;Выделите два непустых отрывка текста для связывания&quot;
Exit Function Exit Function
Case &quot;convertIndesignPageBreaksConfirmation&quot; Case &quot;convertIndesignPageBreaksConfirmation&quot;
getRussian = &quot;Запустить восстановление разрывов страниц?&quot; getRussian = &quot;Запустить восстановление разрывов страниц?&quot;
@ -298,7 +298,7 @@ Function getEnglish(identifier As String) As String
getEnglish = &quot;Replace paragraph style (with removal) by choosen one&quot; getEnglish = &quot;Replace paragraph style (with removal) by choosen one&quot;
Exit Function Exit Function
Case &quot;bidirectLinkSuggestion&quot; Case &quot;bidirectLinkSuggestion&quot;
getEnglish = &quot;You should select two objects to link&quot; getEnglish = &quot;Select two not empty text excerpts to create bidirectional links&quot;
Exit Function Exit Function
Case &quot;convertIndesignPageBreaksConfirmation&quot; Case &quot;convertIndesignPageBreaksConfirmation&quot;
getEnglish = &quot;Start page break conversion from text?&quot; getEnglish = &quot;Start page break conversion from text?&quot;

Binary file not shown.