View Issue Details

IDProjectCategoryView StatusLast Update
0001741ScribusScripterpublic2005-03-05 16:59
ReporterTomK32 Assigned Tosubik  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.3.0cvs 
Fixed in Version1.3.0cvs 
Summary0001741: textoverflows() not working
Descriptionas it seems textoverflows is kinda buggy, below is my version which return the actual number of overflowing characters.


    char *name = const_cast<char*>("");
    if (!PyArg_ParseTuple(args, "|es", "utf-8", &name))
        return NULL;
    if(!checkHaveDocument())
        return NULL;
    PageItem *item = GetUniqueItem(QString::fromUtf8(name));
    if (item == NULL)
        return NULL;
    if (item->itemType() != PageItem::TextFrame)
    {
        PyErr_SetString(WrongFrameTypeError, QObject::tr("Can't get info from a non-text frame", "python error"));
        return NULL;
    }

    QPixmap pgPix(1, 1);
    ScPainter *painter = new ScPainter(&pgPix, 1, 1);
    painter->translate(0.5, 0.5);
    item->DrawObj(painter, QRect(0, 0, 1, 1));
    painter->end();
    delete painter;
 
    int chars = item->itemText.count();
    int maxchars = item->MaxChars;
    while (item->NextBox != 0) {
        item = item->NextBox;
        chars += item->itemText.count();
        maxchars += item->MaxChars;
    }
    // no overrun
    if (maxchars > chars)
        return 0;
 
    // number of overrunning letters
    return PyInt_FromLong(static_cast<long>(chars - maxchars));
TagsNo tags attached.
Patch

Activities

ringerc

2005-03-02 11:32

reporter   ~0003851

Thanks for that, Tom32k. I'll have to check that out (if subik doesn't beat me to it).

It wouldn't hurt to submit changes as patches in 'diff -u' format, or as text files, rather than pasting them. Mantis sometimes does "interesting" things to text and formatting.

subik

2005-03-03 19:50

manager   ~0003865

it's now like this:

<code>textOverflows</a>(["name", nolinks]) -> integer</code>

Returns the actual number of overflowing characters in text frame "name". If is nolinks set to non zero value it takes only one frame - it doesn't use text frame linking. Without this parameter it search all linking chain.


May raise WrongFrameTypeError if the target frame is not an text frame



it needs testing. I'm too tired fro tonight as I cannot count the characters no more (seeing it twice ;)). I hope it will be closed tomorrow.

subik

2005-03-04 15:37

manager   ~0003872

it's working

Issue History

Date Modified Username Field Change
2005-03-02 08:55 TomK32 New Issue
2005-03-02 11:32 ringerc Note Added: 0003851
2005-03-03 06:52 subik Status new => assigned
2005-03-03 06:52 subik Assigned To => subik
2005-03-03 19:50 subik Note Added: 0003865
2005-03-04 15:37 subik Status assigned => resolved
2005-03-04 15:37 subik Fixed in Version => 1.3.0cvs
2005-03-04 15:37 subik Resolution open => fixed
2005-03-04 15:37 subik Note Added: 0003872
2005-03-05 16:59 cbradney Status resolved => closed