View Issue Details

IDProjectCategoryView StatusLast Update
0001606ScribusScripterpublic2006-01-10 14:04
ReporterTomK32 Assigned Tosubik  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.2cvs 
Fixed in Version1.3.2cvs 
Summary0001606: setStyle changes complete frame style despite selection
DescriptionIf I use selectText() I'd expect setStyle() to work like setFont() and change only the paragraphs selected not the whole text frame.

The solution is to move Deselect() a bit down.
TagsNo tags attached.
Patch

Relationships

has duplicate 0002758 closedsubik Setting different paragraph-style in one textframe from scripter doesn't work 
child of 0003813 acknowledged Metabug: Scripter 

Activities

subik

2005-01-31 19:23

manager   ~0003567

the Deselect() method does a little bit "other" deselection than you propably know. It erases selection of the object(s) in page - not the selection in text frame.
I'm sorry but (if I'm right of course) Scripter isn't currently able to apply style into selection. It's something like boolean - all text is or isn't styled.

It depends on the Scribus core ScribusApp::setNewAbStyle(int) which is too hard and dangerous to rewrite in 1.2.x series.

But maybe I moronish myself in fron of you ;)
I'll study it one more day.

TomK32

2005-02-07 15:52

reporter   ~0003644

that is my solution, working really fine:

               if (!found) {
                        // whoops, the user specified an invalid style, complain loudly.
                        PyErr_SetString(NotFoundError, QObject::tr("Style not found","pyth
on error"));
                        return NULL;
                }

        int Apm = Carrier->doc->AppMode;
        if (item->HasSel) {
            Carrier->doc->AppMode = 7;
        }

        // Now apply the style.
        Carrier->doc->ActPage = item->OwnPage;
        Carrier->doc->ActPage->SelectItemNr(item->ItemNr);

        Carrier->setNewAbStyle(styleid);
        Carrier->doc->AppMode = Apm;

        Carrier->doc->ActPage->Deselect(true);

plinnell

2005-04-08 07:29

viewer   ~0004157

subik is this fixed in 1.2.2 ?

subik

2005-04-08 07:56

manager   ~0004168

patched.
I'm not sure still If we understand each other - it applies style on the paragraph only - not selected text.

TomK32

2005-04-08 08:15

reporter   ~0004170

Last edited: 2005-04-08 08:16

yes it changes the paragraph, also if you append text it will have the same style.

for the docs I'd suggest to add a note that setStyle should be used BEFORE actually adding the paragraph and applying fonts or other stuff.

ringerc

2005-10-27 11:19

reporter   ~0007233

Last edited: 2005-10-27 11:26

Reopening as I think this is still in 1.3.x (as per ML discussion). The following doesn't seem to work:

<create a frame and select it, create a style named "test">

setText("blah\nblah\nblah\n")
selectText(5,7)
setStyle("test")

as it sets the style on the whole frame rather than the selected range. The problem is not with selectText(...), as that works just fine if you (eg) 'setTextColor("Blue")'.

ringerc

2005-10-27 11:34

reporter   ~0007234

Reminder sent to: TomK32

Adding you to the monitor list after IRC discussion.

rdebel

2005-10-28 06:16

reporter   ~0007243

Please see also Bug 2770: When having selected multiple frames, the style is only applied to the first one.

subik

2005-10-30 12:06

manager   ~0007264

Scripter calls Scribus internals methods only. There is no handling of the paragraph styles in text selection.

void ScribusApp::setNewAbStyle(int a)
void ScribusView::SetAbStyle(int s)
void ScribusView::chAbStyle(PageItem *currItem, int s)

esp. the last one method is where is everything handled. I'll discuss it with Franz because it should require changes in these methods... stay tuned volks.

subik

2005-10-31 08:16

manager   ~0007277

Reminder sent to: fschmid

Franz, could you provide your oppinion on this RFE, please?

fschmid

2005-10-31 09:55

developer   ~0007280

In my opinion setStyle() should
a) change only the selected text paragraphs if any
b) if now paragraphs are selected it should change the style for all selected textframes.

TomK32

2005-11-02 09:19

reporter   ~0007308

it's much fast now, but please add this patch too:

Index: cmdobj.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp,v
retrieving revision 1.11.2.41
diff -u -r1.11.2.41 cmdobj.cpp
--- cmdobj.cpp 1 Nov 2005 19:42:17 -0000 1.11.2.41
+++ cmdobj.cpp 2 Nov 2005 09:19:44 -0000
@@ -81,7 +81,7 @@
                return NULL;
        if(!checkHaveDocument())
                return NULL;
- int i = ScApp->doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, pageUnitXToDocX(x), pageUnitYToDocY(y), b, h, ScApp->doc->toolSettings.dWidth, "None", ScApp->doc->toolSettings.dPenText, true);
+ int i = ScApp->doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, pageUnitXToDocX(x), pageUnitYToDocY(y), ValueToPoint(b), ValueToPoint(h), ScApp->doc->toolSettings.dWidth, "None", ScApp->doc->toolSettings.dPenText, true);
        if (ItemExists(QString::fromUtf8(Name)))
        {
                PyErr_SetString(NameExistsError, QObject::tr("An object with the requested name already exists.","python error"));
@@ -512,10 +512,15 @@
                        PyErr_SetString(NotFoundError, QObject::tr("Style not found.","python error"));
                        return NULL;
                }
+
+ int Apm = ScApp->doc->appMode;
+ ScApp->doc->appMode = modeEdit;
+
                // for current item only
                if (ScApp->view->SelItem.count() == 0 || name != "")
                {
- // quick hack to always apply on the right frame - pv
+
+ // quick hack to always apply on the right frame - pv
                        ScApp->view->Deselect(true);
                        //CB I dont think we need to draw here. Its faster if we dont.
                        ScApp->view->SelectItem(item, false);
@@ -527,7 +532,7 @@
                        for (int i = 0; i < ScApp->view->SelItem.count(); ++i)
                                ScApp->view->chAbStyle(ScApp->view->SelItem.at(i), styleid);
                }
-
+ ScApp->doc->appMode = Apm;
        }
        else
        {

rdebel

2005-11-23 06:38

reporter   ~0007516

Is this fixed now? To me (latest 1.3anoncvs) it seems not. This is a pity since you really have _no_ possibilities to set different par-styles in one frame from scripter and no workaround is available. So perhaps a first "dirty hack" could be that the setstyle _only_ applies to selectedParagraphs. If you want to set the style of many frame you have to cycle through them.
Or did I something wrong?

subik

2005-12-08 19:51

manager   ~0007673

I've made some changes into 1.3 devel cvs. It needs a very heavy testing because it affects all style changes - you can change style in selection from scripter and gui too (in edit mode). I've test it but I'm sure I missed some combinations... can you test it, please?

rdebel

2005-12-12 14:04

reporter   ~0007715

Setting different styles in one frame does work now, also setting one style vor many frames.
Thank you for your work!

Issue History

Date Modified Username Field Change
2005-01-31 09:11 TomK32 New Issue
2005-01-31 15:18 subik Status new => assigned
2005-01-31 15:18 subik Assigned To => subik
2005-01-31 19:23 subik Note Added: 0003567
2005-02-07 15:52 TomK32 Note Added: 0003644
2005-04-08 07:29 plinnell Note Added: 0004157
2005-04-08 07:29 plinnell Product Version 1.2.1 => 1.2.2cvs
2005-04-08 07:56 subik Note Added: 0004168
2005-04-08 08:15 TomK32 Note Added: 0004170
2005-04-08 08:16 TomK32 Note Edited: 0004170
2005-04-08 09:17 subik Status assigned => resolved
2005-04-08 09:17 subik Fixed in Version => 1.2.2cvs
2005-04-08 09:17 subik Resolution open => fixed
2005-04-16 09:34 cbradney Status resolved => closed
2005-10-25 21:28 cbradney Relationship added related to 0002758
2005-10-27 11:19 ringerc Note Added: 0007233
2005-10-27 11:19 ringerc Status closed => acknowledged
2005-10-27 11:22 ringerc Note Edited: 0007233
2005-10-27 11:26 ringerc Note Edited: 0007233
2005-10-27 11:34 ringerc Note Added: 0007234
2005-10-28 06:16 rdebel Note Added: 0007243
2005-10-30 12:06 subik Note Added: 0007264
2005-10-31 08:16 subik Note Added: 0007277
2005-10-31 09:55 fschmid Note Added: 0007280
2005-11-02 09:19 TomK32 Note Added: 0007308
2005-11-23 06:38 rdebel Note Added: 0007516
2005-12-08 19:51 subik Note Added: 0007673
2005-12-08 19:54 subik Relationship replaced has duplicate 0002758
2005-12-12 14:04 rdebel Note Added: 0007715
2005-12-25 11:02 subik Status acknowledged => resolved
2005-12-25 11:02 subik Fixed in Version 1.2.2cvs => 1.3.3cvs
2005-12-26 19:19 plinnell Fixed in Version 1.3.3cvs => 1.3.2cvs
2006-01-10 14:04 cbradney Status resolved => closed
2006-05-13 21:19 christoph_s Relationship added child of 0003813