Text Area Size in Draw/Impress

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
rgusmero
Posts: 4
Joined: Wed Aug 19, 2015 3:21 pm

Text Area Size in Draw/Impress

Post by rgusmero »

I'm working on a Draw document which contains Shapes and text associated with each Shape. The text is required to fit the shape contour.

I need to figure out, via UNO interface, if there is enough room within the shape contour in order to accomodate all the text. To be more clear, I need to know if all the text will be shown or if a part of it will be truncated during printing because the shape is too small.

I thoroughly searched the dods and the forum but found nothing about the issue.

Thank you in advance for your help,

Riccardo
OpenOffice 4.0 on Windows 7
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Text Area Size in Draw/Impress

Post by Zizi64 »

A similar topic with some informations:
viewtopic.php?f=10&t=31303
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
rgusmero
Posts: 4
Joined: Wed Aug 19, 2015 3:21 pm

Re: Text Area Size in Draw/Impress

Post by rgusmero »

Sorry but I cannot find any pertinent information in the provided link.
My TextAreas are all fixed size. I inject some text and, after it, I need to know if the TA can still accomodate all the text or if there is any overflow.

Any idea?

Riccardo
OpenOffice 4.0 on Windows 7
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Text Area Size in Draw/Impress

Post by Zizi64 »

Can you upload your example .odg file and your macro here?
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
rgusmero
Posts: 4
Joined: Wed Aug 19, 2015 3:21 pm

Re: Text Area Size in Draw/Impress

Post by rgusmero »

Thank you very much for your reply. Please find attached a sample .odg file, containing 2 text areas. In the first case (left), the TA is able to accomodate all the text. In the second (right), some words "overflow" outside the available space. What I need to do is to programmatically detect the second case and alert the user.

Hope this fully explains the problem.

Thanks again,

Riccardo
Attachments
sample.odg
Sample .odg file with 2 text areas and different words count.
(15.63 KiB) Downloaded 264 times
OpenOffice 4.0 on Windows 7
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Text Area Size in Draw/Impress

Post by Zizi64 »

You can adjust the properties of the Basic Shapes manually or by a macro: then the text never will overflow at resizing shape.

By macro:

Code: Select all

Sub SetShapeProperties

 oDoc = thisComponent
 oSelection = oDoc.CurrentSelection(0) 
'the currently selected Object...
  
'... is a Shape?
 if oSelection.supportsService("com.sun.star.drawing.Shape") then 
  
	oSelection.TextAutoGrowHeight = True	
	oSelection.TextAutoGrowWidth = True
	
	
	oSelection.TextFitToSize = 0
	oSelection.TextWordWrap = True
	oSelection.TextContourFrame  = False
	
	oSelection.ParaAdjust = com.sun.star.style.ParagraphAdjust.BLOCK 'STRETCH
	oSelection.ParaLastLineAdjust = com.sun.star.style.ParagraphAdjust.BLOCK

 endif

End Sub
Manually:
Without text overflow.png
Both of these methods work for me in my AOO4.1.1 and LO4.4.5




...But I was surprised:
I can not found all of adjusted properties in the Shape Styles. There is one what I can adjust manually only in the local menu...
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
rgusmero
Posts: 4
Joined: Wed Aug 19, 2015 3:21 pm

Re: Text Area Size in Draw/Impress

Post by rgusmero »

Unfortunately, this is not possible.
In my project, text areas are fixed size due to relative positioning. On the other hand, there are specific requirements on the minimum font size, so I cannot scale down the font either.
The only thing I can do is to alert the user that the text will not fit, but this is something I'm not able to do at the moment, because I could not reach any "metrics" via the API.

Thank you again for your effort!

Riccardo
OpenOffice 4.0 on Windows 7
Post Reply