Ask Your Question
0

Display unicode from basic macro (Solved) [closed]

asked 2014-11-22 19:03:42 +0200

Pansmanser gravatar image

updated 2015-08-29 20:26:29 +0200

Alex Kemp gravatar image

I have a macro (simplified version below-edited, thanks rautamiekka) to insert certain special characters into a writer document. The macro prompts for user input (an Ascii character) selects the required unicode character and inserts it in the document. Although it worked in the past, the in the latest version of LO (4.2.7) the prompt does not display the unicode characters properly. Any ideas why this is (not) happening?

    sub InsertSpecial
rem insert a special character from a menu
  DIM s$, s1$, s2$, oText As Object, oVCurs As Object

  oText = ThisComponent.Text
  oVCurs = ThisComponent.CurrentController.getViewCursor()

  s = "A ∀        B ∵       T ∴" & Chr$(10)
  s2 = InputBox(s,"Insert Special Character","A")
  If s2 = "" Then Exit Sub
  s1 = UCase(Left(s2,1))

  Select Case s1
    Case "A" : s1 = "∀"
    Case "B" : s1 = "∵"
    Case "T" : s1 = "∴"
  End Select
  oText.insertString(oVCurs, s1, False)
  oText.insertString(oVCurs, Mid(s2, 2), False)

end sub
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-03-06 18:09:31.098194

Comments

4.2.7 is latest Still version, but the very newest is 4.4.0 RC1, and if you don't count pre-releases, 4.3.3 is very newest, but 4.2.7 is definitely not newest.

As for your code, you have to add 4 spaces befeore each line, including empty lines, to have it considered a code.

rautamiekka gravatar imagerautamiekka ( 2014-11-22 19:16:42 +0200 )edit

Thanks Rautamiekka, I see that 4.3.3 is out. However, 4.2.7 is the latest version offered by Synaptic.

Pansmanser gravatar imagePansmanser ( 2014-11-22 20:40:21 +0200 )edit

Yeah, cuz the Still branch equals stable. If you're running Ubuntu or Ubuntu-based, you can use https://launchpad.net/~libreoffice/+a... . Whether it'll work for Debian I can't say, and I have no clue about other distros/package systems.

rautamiekka gravatar imagerautamiekka ( 2014-11-22 21:02:10 +0200 )edit

Problem persists in 4.3.4.

Pansmanser gravatar imagePansmanser ( 2014-11-23 13:36:49 +0200 )edit

In what way do you trigger (call) the sub?

Does the promp (input box) show up properly, except the special characters?

Did you try to debug the sub (setting breakpoints or inserting output statements)?

I cannot test with every version, but can confirm that the sub works fine under Win 8.1 in PortableLibreOffice V4.3.3.

Lupp gravatar imageLupp ( 2014-11-23 15:04:43 +0200 )edit

Thanks, Lupp, that is interesting that it works in your set-up. The sub is called from a keyboard shortcut in Writer under Ubuntu 14.04. Everything works correctly except the display of special characters in the input box. They display correctly in the listing. Debugging reveals that the string 's' contains what it should contain. I'm not sure what else I can check.

Pansmanser gravatar imagePansmanser ( 2014-11-24 12:26:54 +0200 )edit

It's a pity that I don't know enough about the handling of fonts by different types or layers of executables. This under Linux even more. But what you tell seems to point to the question: Has the basic code while being interpreted (executed) access to the font(s) containing the special characters and/or are the fonts used by basic correctly replaced if necessary?

What do you get in the Writer document if make your selection blind?

Lupp gravatar imageLupp ( 2014-11-24 22:30:53 +0200 )edit

Yes, your question expresses my deductions, but more clearly. However, I do not know how to proceed, and I don't understand 'make your selection blind'. Help me with that, please.

Pansmanser gravatar imagePansmanser ( 2014-11-25 11:14:07 +0200 )edit

No secret meanings. The input box is showing, I think, everything except the special characters (SCs). You will see an "A", e.g. as a hint that hitting the A-key will produce one of the SCs (which itself i not displayed). Hitting now that key actually is, what I called "blind selection". Is anything inserted into your text after hitting "A" (e.g.)?

Lupp gravatar imageLupp ( 2014-11-25 12:35:15 +0200 )edit
1

LibreOffice is dedicated to be and to exclusively use free software, this including the fonts. So should be Ubuntu. The default font for Writer under windows is 'Liberation Serif', for Calc 'Liberation Sans'. Both these fonts do not contain the three special symbols of your example (U+2200, U+2235, U+2234). On my windows system there is active a replacement mechanism which is obviously working sufficiently: Look for an Ubuntu specialist to get advice best.

Lupp gravatar imageLupp ( 2014-11-25 13:21:17 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2014-11-23 12:04:37 +0200

Lupp gravatar image

updated 2014-11-23 12:08:06 +0200

If there are just a few (mathematical) symbols you need you might also consider installing the 'Compose Special Characters' extension and configure some shortcuts instead of programming a Sub using an input box.

This will, of course, not be the appropriate way if you want to deliver the feature contained in your documents.

edit flag offensive delete link more

Comments

Thanks, Lupp. I use shortcut keys quite a lot on the Ubuntu desktop and for accents in Writer. But rather a lot of special characters (20+) in my original Writer macro. My memory not sufficient for so many shortcuts!

Pansmanser gravatar imagePansmanser ( 2014-11-23 13:19:21 +0200 )edit
0

answered 2014-11-28 19:51:34 +0200

Pansmanser gravatar image

Thanks to Lupp, I have an answer. In the macro edit screen, I selected Tools-Options-LO-Fonts, and in the lower half of the window changed the font from 'Automatic' to 'Liberation Mono.' I don't know what the default font was, but the symbols are all displaying correctly now.

edit flag offensive delete link more

Comments

OK. This is not working again. Now I don't know how I made it work. Aargh!

Pansmanser gravatar imagePansmanser ( 2014-12-20 13:20:43 +0200 )edit

This time, I think I have solved it. From any LO screen, select Tools-Options-LO-View and uncheck "Use system font for user interface."

Pansmanser gravatar imagePansmanser ( 2014-12-28 22:21:24 +0200 )edit

Question Tools

1 follower

Stats

Asked: 2014-11-22 19:03:42 +0200

Seen: 1,053 times

Last updated: Nov 28 '14