Set fontsize of textbox, not the frame in Draw in Basic

Keyboard macros or custom scripts

Set fontsize of textbox, not the frame in Draw in Basic

Postby RandB » Sun Jul 17, 2016 6:54 am

How do I set the fontsize of a textbox. The only thing I can find is to set the CharHeight, but the way I am doing it, it only sets the CharHeight of the frame. My text never changes, because I am only changing the frame. How do I get into the textbox?
I am using Basic and working in Draw.
LibreOffice 5.0.3.2
OSX 10.11.2
RandB
 
Posts: 5
Joined: Wed Jan 20, 2016 8:35 pm

Re: Set fontsize of textbox, not the frame in Draw in Basic

Postby FJCC » Mon Jul 18, 2016 2:13 am

In a Draw document that contains only a textbox, this works for me to change the font
Code: Select all   Expand viewCollapse view
  oDrawPages = ThisComponent.getDrawPages()
  oDP1 = oDrawPages.getByIndex(0)
  oBox = oDP1.getByIndex(0)
 
  oBox.CharHeight = 36.0
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7084
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Set fontsize of textbox, not the frame in Draw in Basic

Postby RandB » Mon Jul 18, 2016 9:28 pm

Thanks, but that is what I had. Changing that does not change the fontsize of my textbox, that changes the fontsize of the frame. So the visible size of the text never changes. How do I drill down from the frame into the textbox?

Here is what my XLM of this textbox looks like.
Code: Select all   Expand viewCollapse view
<draw:page draw:name="page1" draw:style-name="dp1" draw:master-page-name="Default"><draw:frame draw:style-name="gr2" draw:text-style-name="P3" draw:layer="layout" svg:width="5.916cm" svg:height="2.618cm" svg:x="5.902cm" svg:y="5.6cm"><draw:text-box><text:p text:style-name="P2">Large</text:p></draw:text-box></draw:frame></draw:page>
LibreOffice 5.0.3.2
OSX 10.11.2
RandB
 
Posts: 5
Joined: Wed Jan 20, 2016 8:35 pm

Re: Set fontsize of textbox, not the frame in Draw in Basic

Postby FJCC » Mon Jul 18, 2016 11:35 pm

The attached document has a macro that toggles the font size in the textbox between sizes 18 and 36. Does it work for you?
 Edit: I tested the macro before posting the file and it worked. After closing and reopening the file, the macro doesn't work. I'll have to look into this later. Perhaps I'm losing m mind. 
Attachments
FontChange.odg
(10.01 KiB) Downloaded 92 times
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7084
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Set fontsize of textbox, not the frame in Draw in Basic

Postby RandB » Tue Jul 19, 2016 1:50 am

Before I ran the macro, the frame and textbox had the same style. (P1)
Code: Select all   Expand viewCollapse view
<draw:frame draw:style-name="gr1" draw:text-style-name="P1" draw:layer="layout" svg:width="4.953cm" svg:height="3.302cm" svg:x="2.397cm" svg:y="3.54cm">
<draw:text-box><text:p text:style-name="P1">The Text</text:p>
</draw:text-box>
</draw:frame></draw:page>

After you run the macro you see the fontsize was changed in the frame to style P2, but the textbox size is still P1. What you see, is the textbox, so changing the font size of the frame does nothing.
Code: Select all   Expand viewCollapse view
<draw:frame draw:style-name="gr1" draw:text-style-name="P2" draw:layer="layout" svg:width="4.953cm" svg:height="3.302cm" svg:x="2.397cm" svg:y="3.54cm">
<draw:text-box><text:p text:style-name="P1"><text:span text:style-name="T1">The Text</text:span></text:p>
</draw:text-box>

If you want to see it in Draw. Then run the macro. Then Click in the textbox to get a text cursor. Look at the properties and it shows fontsize 36.
Now click on the border where you get the little squares, you are now looking at the frame. Look at the properties and it shows fontsize 18. The Macro change the frame to 18 not the textbox.

This was my problem we need to change the textbox, not the frame.
LibreOffice 5.0.3.2
OSX 10.11.2
RandB
 
Posts: 5
Joined: Wed Jan 20, 2016 8:35 pm

Re: Set fontsize of textbox, not the frame in Draw in Basic

Postby FJCC » Tue Jul 19, 2016 6:33 am

I checked that this macro
Code: Select all   Expand viewCollapse view
oDrawPages = ThisComponent.getDrawPages()
oDP1 = oDrawPages.getByIndex(0)
oBox = oDP1.getByIndex(0)

If oBox.CharHeight = 36.0 then
   oBox.CharHeight = 18
Else
   oBox.CharHeight = 36.0
End If

does toggle the font size on a new document similar to what I posted earlier both before and after saving the document. After closing the document and reopening, it does not work. I don't have time right now to investigate that further and I'm not at all sure just what I would do.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7084
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Set fontsize of textbox, not the frame in Draw in Basic

Postby gmapp » Wed Nov 14, 2018 2:40 pm

I bumped into the same problem and searching I found this topic. Any ideas on how to solve the problem (change the style properties of the text and not of the frame that contains the text)?

Thanks
OpenOffice 4, Windows 10
gmapp
 
Posts: 1
Joined: Wed Nov 14, 2018 2:31 pm


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 3 guests