View Issue Details

IDProjectCategoryView StatusLast Update
0008907ScribusScripterpublic2010-03-06 11:14
ReporterOssiLehtinen Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
PlatformLinuxOSUbuntuOS Version9.10
Product Version1.5.0svn 
Summary0008907: A text frame's line count doesn't seem to be updated while a script is running
DescriptionI'm trying to adjust font size and line spacing of a text frame in a script based on the number of lines in the frame.

It appears that getTextLines returns something incorrect. I think it doesn't keep track of changes that have happened during script execution.
Steps To ReproduceI attached a simple script to demonstrate the problem. You need to have an open (empty) document open when running the script.

The script creates first one text frame and inserts some random text. Next it creates another frame and prints the first frames line count in that one. This results in number 0 in the frame, which is obviously incorrect.

If afterwards one runs in the Scribus console

insertText(str(getTextLines("aa")), -1, "bb")

the correct number is entered.

I would try to fix this myself also, as this seriously hampers the usefulness of getTextLines, but frankly, I can't figure out where to look :)
TagsNo tags attached.
Patch

Activities

OssiLehtinen

2010-03-06 10:13

reporter  

getTextLinesProb.py (1,452 bytes)   

OssiLehtinen

2010-03-06 10:20

reporter  

getTextLinesProb2.py (1,475 bytes)   

OssiLehtinen

2010-03-06 10:25

reporter   ~0023463

I noticed something else about this as well. The linecount seems to be updated only if the text frame in question is visible in the ui.

A way to show this is to make a two page document, scroll down so that only the second page is visible, run the script getTextLineProb2.py and then in the console

insertText(str(getTextLines("aa")), -1, "bb")

Now we get only zeros in the second frame as the handled text frames were never visible.

Note: This doesn't seem to have anything to do with the page selection. If I zoom out so that both pages are visible, but keep page 2 selected. The frame gets the correct number after the console command.

p.s. In hindsight, perhaps this isn't a major bug in severity, but it feels major right now :)

OssiLehtinen

2010-03-06 10:51

reporter   ~0023464

Ok after digging around, it seems that one has to call item->layout() in the scripter functions to get things updated.

I tested this with the insertText and setText functions and it appears to work now. This needs to be added to all the text manipulation functions though.

The layout function seems pretty 'big'. I'm worried it might make the scripter a lot slower to call it every time something is done. Perhaps not. An alternative would be to ad another scripter function which would explicitely update the layout info.

OssiLehtinen

2010-03-06 11:13

reporter  

insertTextfix.diff (2,903 bytes)   

OssiLehtinen

2010-03-06 11:14

reporter   ~0023465

I uploaded a patch which adds a function updateLayoutData to the scripter, which will do what the name implies. Don't know if this is the right way to go, but at least it works for me :) Cheers.

Issue History

Date Modified Username Field Change
2010-03-06 10:13 OssiLehtinen New Issue
2010-03-06 10:13 OssiLehtinen File Added: getTextLinesProb.py
2010-03-06 10:20 OssiLehtinen File Added: getTextLinesProb2.py
2010-03-06 10:25 OssiLehtinen Note Added: 0023463
2010-03-06 10:51 OssiLehtinen Note Added: 0023464
2010-03-06 11:13 OssiLehtinen File Added: insertTextfix.diff
2010-03-06 11:14 OssiLehtinen Note Added: 0023465