Text Area Size in Draw/Impress

Java, C++, C#, Delphi, ??? - Using the UNO bridges

Text Area Size in Draw/Impress

Postby rgusmero » Wed Aug 19, 2015 3:38 pm

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
rgusmero
 
Posts: 4
Joined: Wed Aug 19, 2015 3:21 pm

Re: Text Area Size in Draw/Impress

Postby Zizi64 » Sun Sep 06, 2015 8:44 am

A similar topic with some informations:
https://forum.openoffice.org/en/forum/v ... 10&t=31303
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.5; AOO4.1.5
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.
User avatar
Zizi64
Volunteer
 
Posts: 8098
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Text Area Size in Draw/Impress

Postby rgusmero » Sun Sep 06, 2015 10:31 pm

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
rgusmero
 
Posts: 4
Joined: Wed Aug 19, 2015 3:21 pm

Re: Text Area Size in Draw/Impress

Postby Zizi64 » Sun Sep 06, 2015 11:00 pm

Can you upload your example .odg file and your macro here?
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.5; AOO4.1.5
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.
User avatar
Zizi64
Volunteer
 
Posts: 8098
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Text Area Size in Draw/Impress

Postby rgusmero » Mon Sep 07, 2015 8:12 am

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 80 times
OpenOffice 4.0 on Windows 7
rgusmero
 
Posts: 4
Joined: Wed Aug 19, 2015 3:21 pm

Re: Text Area Size in Draw/Impress

Postby Zizi64 » Tue Sep 08, 2015 8:55 am

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...
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.5; AOO4.1.5
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.
User avatar
Zizi64
Volunteer
 
Posts: 8098
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Text Area Size in Draw/Impress

Postby rgusmero » Tue Sep 08, 2015 9:08 am

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
rgusmero
 
Posts: 4
Joined: Wed Aug 19, 2015 3:21 pm


Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest