Page 1 of 1

Text Area Size in Draw/Impress

PostPosted: Wed Aug 19, 2015 3:38 pm
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

Re: Text Area Size in Draw/Impress

PostPosted: Sun Sep 06, 2015 8:44 am
by Zizi64
A similar topic with some informations:
https://forum.openoffice.org/en/forum/v ... 10&t=31303

Re: Text Area Size in Draw/Impress

PostPosted: Sun Sep 06, 2015 10:31 pm
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

Re: Text Area Size in Draw/Impress

PostPosted: Sun Sep 06, 2015 11:00 pm
by Zizi64
Can you upload your example .odg file and your macro here?

Re: Text Area Size in Draw/Impress

PostPosted: Mon Sep 07, 2015 8:12 am
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

Re: Text Area Size in Draw/Impress

PostPosted: Tue Sep 08, 2015 8:55 am
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   Expand viewCollapse view
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...

Re: Text Area Size in Draw/Impress

PostPosted: Tue Sep 08, 2015 9:08 am
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