automatic font selection in macro

classic Classic list List threaded Threaded
6 messages Options
Thomas Blasejewicz-3 Thomas Blasejewicz-3
Reply | Threaded
Open this post in threaded view
|

automatic font selection in macro

Good morning
I have another strange question.
Work related I have to insert not infrequently symbols into texts.
To make work easier, I have already created a number of macros to insert
for example the symbol "micro" into a text using a keyboard shortcut.

Problem:
Let's say, I created the macro in a document that happened to use
"Arial" as font and later want to use it in a document that uses "Times
Roman". The macro I created then inserts an "Arial font micro" into the
Times Roman text, which then looks out of place.

Is there a trick to create macros, so that the inserted symbol matches
the surrounding font?
I have tried all sorts of things, but could not yet find a solution.
It is not really a "problem", but such an automatic font adjustment
would be nice/helpful.

Thank you.
Thomas

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy

Andrew Douglas Pitonyak Andrew Douglas Pitonyak
Reply | Threaded
Open this post in threaded view
|

Re: automatic font selection in macro

if I wrote a macro that inserts the letter 'X', I would not expect the insertion to specify the font unless I went out of my way to do so.

I am interested in seeing the macro that you are using.

I'm not able right now to try to find a macro that would do what you want, but if you can't find one let me know, and I will see if I can provide one for you after I look at the macro you are using now.

Understand, however, the next two days for me will be hit or miss on availability.



⁣Sent from BlueMail ​

On Feb 12, 2019, 9:55 PM, at 9:55 PM, Thomas Blasejewicz <[hidden email]> wrote:

>Good morning
>I have another strange question.
>Work related I have to insert not infrequently symbols into texts.
>To make work easier, I have already created a number of macros to
>insert
>for example the symbol "micro" into a text using a keyboard shortcut.
>
>Problem:
>Let's say, I created the macro in a document that happened to use
>"Arial" as font and later want to use it in a document that uses "Times
>
>Roman". The macro I created then inserts an "Arial font micro" into the
>
>Times Roman text, which then looks out of place.
>
>Is there a trick to create macros, so that the inserted symbol matches
>the surrounding font?
>I have tried all sorts of things, but could not yet find a solution.
>It is not really a "problem", but such an automatic font adjustment
>would be nice/helpful.
>
>Thank you.
>Thomas
>
>--
>To unsubscribe e-mail to: [hidden email]
>Problems?
>https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
>Posting guidelines + more:
>https://wiki.documentfoundation.org/Netiquette
>List archive: https://listarchives.libreoffice.org/global/users/
>Privacy Policy: https://www.documentfoundation.org/privacy

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Thomas Blasejewicz-3 Thomas Blasejewicz-3
Reply | Threaded
Open this post in threaded view
|

Re: automatic font selection in macro

On 2019/02/13 13:26, Andrew Pitonyak wrote:
> if I wrote a macro that inserts the letter 'X', I would not expect the
> insertion to specify the font unless I went out of my way to do so.
>
> I am interested in seeing the macro that you are using.

Well, I am not actually "writing" the macro - I have no idea how to do
that.
I use "Tools -> Macros -> Record macro" and open the "insert special
characters dialog box".
THIS is where the problem is.
As far as I can tell, there is no way NOT to select a font in that dialog.
On top you have the "Search / Font / Subset" fields.
"Font" gives you a list of fonts, but not the choice of "none /
automatic" etc. - or allows you to delete the currently selected font.
I had been hoping to find that kind of choice.

Mr. Pitonyak. Please don't worry. I am not in a hurry. I have been
pondering this for years already ...

Thank you.
Thomas Blasejewicz







>
>
>
> Sent from BlueMail <http://www.bluemail.me/r?b=14470>
> On Feb 12, 2019, at 9:55 PM, Thomas Blasejewicz <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Good morning
>     I have another strange question.
>     Work related I have to insert not infrequently symbols into texts.
>     To make work easier, I have already created a number of macros to insert
>     for example the symbol "micro" into a text using a keyboard shortcut.
>
>     Problem:
>     Let's say, I created the macro in a document that happened to use
>     "Arial" as font and later want to use it in a document that uses "Times
>     Roman". The macro I created then inserts an "Arial font micro" into the
>     Times Roman text, which then looks out of place.
>
>     Is there a trick to create macros, so that the inserted symbol matches
>     the surrounding font?
>     I have tried all sorts of things, but could not yet find a solution.
>     It is not really a "problem", but such an automatic font adjustment
>     would be nice/helpful.
>
>     Thank you.
>     Thomas
>


--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Thomas Blasejewicz-3 Thomas Blasejewicz-3
Reply | Threaded
Open this post in threaded view
|

Re: automatic font selection in macro

In reply to this post by Andrew Douglas Pitonyak
Addition
On 2019/02/13 13:26, Andrew Pitonyak wrote:
> if I wrote a macro that inserts the letter 'X', I would not expect the
> insertion to specify the font unless I went out of my way to do so.

* Japanese font -> I was just playing around and this is NOT what I want.
This is what LibreOffice has recorded:

sub insertalpha
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(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Symbols"
args1(0).Value = "α"
args1(1).Name = "FontName"
args1(1).Value = "MS Pゴシック"

dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0, args1())

rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0,
Array())


end sub

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Andrew Douglas Pitonyak Andrew Douglas Pitonyak
Reply | Threaded
Open this post in threaded view
|

Re: automatic font selection in macro

In reply to this post by Thomas Blasejewicz-3

I would have used a text cursor, but, the recorded Macro is trivially modified to remove the font name, you just need to know that you can do that :-)

sub insertAlphaNoFont
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(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Symbols"
args1(0).Value = "α"

dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0, args1())

end Sub

Lot easier than another solution (if you really did need the font name), which would look at the text cursor and pull the current font and use that. Inserting text at a text cursor (view cursor) should also not have needed a font. 

On Wednesday, February 13, 2019 00:51 EST, Thomas Blasejewicz <[hidden email]> wrote:
 On 2019/02/13 13:26, Andrew Pitonyak wrote:
> if I wrote a macro that inserts the letter 'X', I would not expect the
> insertion to specify the font unless I went out of my way to do so.
>
> I am interested in seeing the macro that you are using.

Well, I am not actually "writing" the macro - I have no idea how to do
that.
I use "Tools -> Macros -> Record macro" and open the "insert special
characters dialog box".
THIS is where the problem is.
As far as I can tell, there is no way NOT to select a font in that dialog.
On top you have the "Search / Font / Subset" fields.
"Font" gives you a list of fonts, but not the choice of "none /
automatic" etc. - or allows you to delete the currently selected font.
I had been hoping to find that kind of choice.

Mr. Pitonyak. Please don't worry. I am not in a hurry. I have been
pondering this for years already ...

Thank you.
Thomas Blasejewicz







>
>
>
> Sent from BlueMail <http://www.bluemail.me/r?b=14470>
> On Feb 12, 2019, at 9:55 PM, Thomas Blasejewicz <[hidden email]
> <mailto:[hidden email]>> wrote:
>
> Good morning
> I have another strange question.
> Work related I have to insert not infrequently symbols into texts.
> To make work easier, I have already created a number of macros to insert
> for example the symbol "micro" into a text using a keyboard shortcut.
>
> Problem:
> Let's say, I created the macro in a document that happened to use
> "Arial" as font and later want to use it in a document that uses "Times
> Roman". The macro I created then inserts an "Arial font micro" into the
> Times Roman text, which then looks out of place.
>
> Is there a trick to create macros, so that the inserted symbol matches
> the surrounding font?
> I have tried all sorts of things, but could not yet find a solution.
> It is not really a "problem", but such an automatic font adjustment
> would be nice/helpful.
>
> Thank you.
> Thomas
>


--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy


 

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Luuk Luuk
Reply | Threaded
Open this post in threaded view
|

Re: automatic font selection in macro

In reply to this post by Thomas Blasejewicz-3

On 13-2-2019 06:55, Thomas Blasejewicz wrote:

> Addition
> On 2019/02/13 13:26, Andrew Pitonyak wrote:
>> if I wrote a macro that inserts the letter 'X', I would not expect
>> the insertion to specify the font unless I went out of my way to do so.
>
> * Japanese font -> I was just playing around and this is NOT what I want.
> This is what LibreOffice has recorded:
>
> sub insertalpha
> 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(1) as new com.sun.star.beans.PropertyValue
> args1(0).Name = "Symbols"
> args1(0).Value = "α"
> args1(1).Name = "FontName"
> args1(1).Value = "MS Pゴシック"
>
> dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0, args1())
>
> rem
> ----------------------------------------------------------------------
> rem dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0,
> Array())
>
>
> end sub
>


I created a bug report after reading above.

is here: https://bugs.documentfoundation.org/show_bug.cgi?id=123527

it seems that 'automatic font selection in macro' works as i would
expect. The character inserted seems to be of choosen font, and the font
choosen before entering the 'insert/special character' screen is set back.

But there seems to be (a small) bug in selecting the correct character
from the 'insert/special character' screen.




--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Windows10 / LibreOffice  (latest?)