Ask Your Question
0

[feature-request] Highlight a phrase and with keycombo put brackets on both sides [closed]

asked 2018-03-19 23:10:24 +0200

AndersFrispel gravatar image

updated 2018-03-19 23:11:56 +0200

As the headline says. When you highlight a phrase you can make it bold, italic etc. It would be awesome if you could also decide to get quotationmarks or brackets at both ends with a single click or keycombo.

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by David
close date 2018-03-20 11:07:13.472939

Comments

1

Hello,

As stated in How to use Ask site, "Feature requests should go directly to Bugzilla as Enhancements

Ratslinger gravatar imageRatslinger ( 2018-03-20 00:05:18 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2018-03-20 07:11:06 +0200

librebel gravatar image

Hello @AndersFrispel,

Pending the enhancement request, you could assign your own Keyboard Shortcut to a macro such as the following:

Sub Writer_Parenthesize( Optional iType )
REM Encloses the current Writer selection within a bracket pair of the specified Type.
    Dim oDocument As Object : oDocument = ThisComponent
    If oDocument.supportsService( "com.sun.star.text.TextDocument" ) Then

        Dim aPOpen()  : aPOpen  = Array( "(", "[", "{", "<", """", "'", "`", "|" )  REM Add at will..
        Dim aPClose() : aPClose = Array( ")", "]", "}", ">", """", "'", "`", "|" )

        If IsMissing( iType ) Then iType = 0
        If iType < 0 Or iType > uBound( aPOpen ) Then iType = 0

        Dim oSelections As Object : oSelections = oDocument.CurrentController.Selection
        If Not oSelections.supportsService( "com.sun.star.text.TextRanges" ) Then Stop
        If oSelections.getCount() = 0 Then Stop

        Dim oSelection As Object  : oSelection  = oSelections.getByIndex( 0 )
        oSelection.Start.setString( aPOpen( iType ) )
        oSelection.End.setString(  aPClose( iType ) )
        oDocument.CurrentController.select( oSelection )
    End If
End Sub

Just copy-paste the macro into your Standard Basic Library, and use the menu "Tools : Customize... : Keyboard" to assign your preferred Shortcut to it. ( used in this way by default, it will enclose the current selection in "(" and ")" type parentheses ).

I'll see if i can make a ContextMenu for use with a Toolbar button, so that the user can select one from the available bracket types.

With Regards, lib

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-03-19 23:10:24 +0200

Seen: 45 times

Last updated: Mar 20 '18