View Issue Details

IDProjectCategoryView StatusLast Update
0014453ScribusScripterpublic2016-12-14 00:00
Reportergpittman Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
Product Version1.5.3.svn 
Target VersionFixed in Version 
Summary0014453: Scripter command setStyle() doesn't work
DescriptionsetStyle() is supposed to change the Paragraph Style of text in a selected or named frame.
If text is not selected, it should set the style for the entire frame. It doesn't.
Steps To ReproduceMake a document with a text frame, enter or load some text.
Create a Paragraph Style with a particular NAME.
Select the frame, run the uploaded script (the script is designed to work on one or more selected frames).
Enter the NAME of the Style in the valueDialog which appears.

Result: typically there will be some assignment of the style but not the entire frame. It seems that only the last paragraph will have a change in style.

Another curious feature is that if you select and delete the last paragraph, the last paragraph remaining will change to the assigned style.
TagsNo tags attached.
PatchNo

Relationships

related to 0008957 assignedjainbasil [patch] Add setTextPreserveStyle() that wont default back to the default style. (Silimar to Scribus 1.3.3 setText) 
related to 0009273 acknowledged Additional scripter methods for paragraph and style handling 

Activities

gpittman

2016-12-11 20:18

developer  

changetextstyle.py (1,516 bytes)

gpittman

2016-12-13 23:45

developer  

changetextstyleV2.py (1,625 bytes)

gpittman

2016-12-13 23:47

developer   ~0042972

I've uploaded another version of the script, which attempts to select all the text in the frame, but still only part of the text had the style changed. In a 3-paragraph portion of text, only the middle paragraph had the style changed.

gpittman

2016-12-13 23:51

developer   ~0042973

Last edited: 2016-12-13 23:56

View 2 revisions

Here is an excerpt from cmdobj.cpp, beginning at line 622, that seems to be the actual point of application of the style, after various error checks:

        // for current item only
        if (ScCore->primaryMainWindow()->doc->m_Selection->count() == 0 || (strlen(name) > 0))
        {
            // quick hack to always apply on the right frame - pv
            ScCore->primaryMainWindow()->view->Deselect(true);
            //CB I dont think we need to draw here. Its faster if we dont.
            ScCore->primaryMainWindow()->view->SelectItem(item, false);
            // Now apply the style.
            int mode = ScCore->primaryMainWindow()->doc->appMode;
            ScCore->primaryMainWindow()->doc->appMode = modeEdit;
            ScCore->primaryMainWindow()->setNewParStyle(QString::fromUtf8(style));
            ScCore->primaryMainWindow()->doc->appMode = mode;
        }

I don't know why this isn't working but it obviously isn't.

I tried changing the bool values to the opposite, but this made no difference.

gpittman

2016-12-14 00:00

developer   ~0042976

If I run the script with the frame in Edit Contents mode, the paragraph style is applied to the paragraph where the cursor is.

Issue History

Date Modified Username Field Change
2016-12-11 20:17 gpittman New Issue
2016-12-11 20:18 gpittman File Added: changetextstyle.py
2016-12-11 21:04 Kunda Relationship added related to 0008957
2016-12-11 21:07 Kunda Relationship added related to 0009273
2016-12-13 23:45 gpittman File Added: changetextstyleV2.py
2016-12-13 23:47 gpittman Note Added: 0042972
2016-12-13 23:51 gpittman Note Added: 0042973
2016-12-13 23:56 gpittman Note Edited: 0042973 View Revisions
2016-12-14 00:00 gpittman Note Added: 0042976