View Issue Details

IDProjectCategoryView StatusLast Update
0008772ScribusStylespublic2017-07-11 21:59
Reportercezaryece Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
PlatformLinuxOSKubuntuOS VersionKarmic 9.10
Product Version1.5.0svn 
Summary0008772: Applying style by Properties/Text/Styles clear text attributes
DescriptionI have text paragraph with various text attributes for few words (bold for example).
I apply some new style from Styles droplist in Properties/Text/Styles without clearing text attributes but these attributes are cleared.
If I open text in Text Editor and apply some style then text attributes are preserved.
TagsNo tags attached.
Patch

Relationships

has duplicate 0014785 closedjghali Applying paragraph style to frame cleans character formatting. 
has duplicate 0014908 closedjghali changing paragraph styles causes subscripts to be dropped to become normal text. 
related to 0012800 confirmed Loss of italics formatting after importing *.odt files and applying paragraph styles 

Activities

jghali

2010-02-05 10:07

administrator   ~0023204

Last edited: 2010-02-05 10:09

This was a design decision made to ease work with old docs made with Scribus 1.3.3.x and previous versions. As a consequence :
- applying a paragraph style reset direct formatting applied on selected paragraph and direct formatting applied on paragraph characters. Applied character styles are preserved.
- applying a character style will reset any direct formatting which has been applied on selected characters.

As that decision allowed to solve a number of bugs, there are few chances that gonna be changed.

cezaryece

2010-02-07 11:37

updater   ~0023216

I think it can be customizable behavior in preferences or even in Properties/Text/Style Settings.
I dont work with old Scribus docs, so this way make my work harder instead. I prefer direct formating from text document (eg. OpenOffice doc) is preserved after applying paragraph styles.

jghali

2010-02-07 12:01

administrator   ~0023217

Last edited: 2010-02-07 12:01

>> I think it can be customizable behavior in preferences

No, it would hit low level code which doesn't know anything about prefs (and must not).

cezaryece

2010-10-26 13:21

updater  

clear.paragraph.styles.diff (5,250 bytes)   
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(wersja 15654)
+++ scribus/scribusdoc.cpp	(kopia robocza)
@@ -6169,7 +6169,7 @@
 {
 	ParagraphStyle newStyle;
 	newStyle.setParent(name.isEmpty()? Style::INHERIT_PARENT : name);
-	itemSelection_ApplyParagraphStyle(newStyle, customSelection, true);
+    itemSelection_ApplyParagraphStyle(newStyle, customSelection);
 }
 
 
@@ -6861,6 +6861,7 @@
 
 void ScribusDoc::itemSelection_EraseParagraphStyle(Selection* customSelection)
 {
+
 	Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
 	assert(itemSelection!=0);
 	uint selectedItemCount=itemSelection->count();
@@ -6869,11 +6870,13 @@
 	UndoTransaction* activeTransaction = NULL;
 	if (selectedItemCount > 1)
 		activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, tr( "remove direct paragraph formatting" ), Um::IFont));
+
 	for (uint aa = 0; aa < selectedItemCount; ++aa)
 	{
 		PageItem *currItem = itemSelection->itemAt(aa);
 //		int currItemTextCount = currItem->lastInFrame() + 1 - currItem->firstInFrame();
 //		if (currItemTextCount > 0 && ( appMode == modeEdit || !FRAMESELECTION_EDITS_DEFAULTSTYLE))
+
 		int currItemTextCount = currItem->itemText.length();
 		if ((currItemTextCount > 0) && (appMode == modeEdit))
 		{
@@ -6918,7 +6921,63 @@
 	changed();
 	regionsChanged()->update(QRectF());
 }
+void ScribusDoc::itemSelection_ResetParagraphStyle(Selection* customSelection)
+{
+    Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
+    assert(itemSelection!=0);
+    uint selectedItemCount=itemSelection->count();
+    if (selectedItemCount == 0)
+        return;
+    UndoTransaction* activeTransaction = NULL;
+    if (selectedItemCount > 1)
+        activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, tr( "remove direct paragraph formatting" ), Um::IFont));
+    for (uint aa = 0; aa < selectedItemCount; ++aa)
+    {
+        PageItem *currItem = itemSelection->itemAt(aa);
+        int currItemTextCount = currItem->itemText.length();
 
+        ParagraphStyle oldStyle = currItem->itemText.defaultStyle();
+
+        if ((currItemTextCount == 0) || (appMode != modeEdit))
+        {
+            ParagraphStyle dstyle(currItem->itemText.defaultStyle());
+            dstyle.applyStyle(oldStyle);
+            currItem->itemText.setDefaultStyle(dstyle);
+        }
+        if (currItemTextCount > 0)
+        {
+            int start = currItem->asPathText() ? currItem->itemText.startOfItem(currItem->firstInFrame()) : 0;
+            int stop  = currItem->asPathText() ? currItem->itemText.endOfItem(currItem->lastInFrame()) :  currItemTextCount;
+            if (appMode == modeEdit)
+            {
+                start = currItem->itemText.startOfSelection();
+                stop = currItem->itemText.endOfSelection();
+                if (start >= stop)
+                    start = stop = qMax(0, qMin(currItem->itemText.length(), currItem->CPos));
+            }
+            for (int pos=start; pos < stop; ++pos)
+            {
+                if (currItem->itemText.text(pos) == SpecialChars::PARSEP)
+                {
+                    currItem->itemText.applyStyle(pos, oldStyle, true);
+                }
+            }
+            currItem->itemText.applyStyle(stop, oldStyle, true);
+            currItem->invalid = true;
+        }
+        if (currItem->asPathText())
+            currItem->updatePolyClip();
+        currItem->invalidateLayout();
+    }
+    if (activeTransaction)
+    {
+        activeTransaction->commit();
+        delete activeTransaction;
+        activeTransaction = NULL;
+    }
+    changed();
+    regionsChanged()->update(QRectF());
+}
 void ScribusDoc::itemSelection_ApplyParagraphStyle(const ParagraphStyle & newStyle, Selection* customSelection, bool rmDirectFormatting)
 {
 	Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h	(wersja 15654)
+++ scribus/scribusdoc.h	(kopia robocza)
@@ -919,6 +919,7 @@
 	void itemSelection_ApplyCharStyle(const CharStyle & newstyle, Selection* customSelection=0);
 	void itemSelection_SetCharStyle(const CharStyle & newstyle, Selection* customSelection=0);
 	void itemSelection_EraseParagraphStyle(Selection* customSelection=0);
+    void itemSelection_ResetParagraphStyle(Selection* customSelection=0);
 	void itemSelection_EraseCharStyle(Selection* customSelection=0);
 
 	void itemSelection_SetNamedParagraphStyle(const QString & name, Selection* customSelection=0);
Index: scribus/ui/propertiespalette.cpp
===================================================================
--- scribus/ui/propertiespalette.cpp	(wersja 15654)
+++ scribus/ui/propertiespalette.cpp	(kopia robocza)
@@ -4364,7 +4364,7 @@
 		return;
 	if (HaveDoc)
 	{
-		doc->itemSelection_EraseParagraphStyle();
+        doc->itemSelection_ResetParagraphStyle();
 		CharStyle emptyCStyle;
 		doc->itemSelection_SetCharStyle(emptyCStyle);
 	}
clear.paragraph.styles.diff (5,250 bytes)   

cezaryece

2010-10-26 13:21

updater   ~0024735

Please test behaviour of Scribus after patch I have included.
Now changing Paragraph Style in Properties Palette dont touch character formatting. Instead "Clear paragraph formatting" button clear all character formatting for paragraph where is cursor placed or for selection of paragraphs (whole paragraphs, not only for selected text).
How it works for you, how feel with it?

I don't know if it works well in all cases (text on path?) and if I code it in good manner. At now I only ask for take a look at a way how clearing works now and if it satisfy all.

ale

2010-10-31 18:46

manager   ~0024769

chat on this topic:

<jghali> cezaryece: old 1.3.3.x docs use basically direct formatting, applying paragraph style won't work on those docs with that patch.
this is the reason of the current behavior.

<cezaryece> jghali: maybe new Scribus should rewrite old docs during opening it into new format

<jghali> cezaryece: not realistic, style were faked in 1.3.3.x, only direct formatting did exists then, by rewriting that, you have more chance of breaking all docs than anything

<a_l_e> imo, the files should be in a good shape not later than after having been written once with the new version...
keeping old structures in new format and hacking around them in the whole application is a very bad idea...

<cezaryece> agree with you, compatibility is not more important than productivity and logic
if old file have to be opened in special manner, lets make some filter for it, but do not change whole application behavior for it

ale

2010-10-31 18:47

manager   ~0024770

the result with the patch is what i would expect from scribus, given the current drop down and buttons available.
otherwise, there is no reason to have a wipe button, if applying the style does exactly the same.

jghali

2010-10-31 21:17

administrator   ~0024772

>> there is no reason to have a wipe button, if applying the style does exactly the same.

No it does not. Applying a paragraph style will clear direct formatting applied on characters, but not character styles applied on them. The wipe paragraph style button will clear only direct formatting applied on the paragraph style itself.

jghali

2010-10-31 21:40

administrator   ~0024775

Last edited: 2010-10-31 21:43

>> imo, the files should be in a good shape not later than after having been written once with the new version...

Not realistic and even possible. Example 1 : in 1.3.3.x one could apply several paragraph style on different portion of a paragraph, character style being not existent at that time. In such case, 1.3.3.x formatting can only be translated by direct formatting in 1.3.4+. Example 2 : text style at frame level behavior has also completely changed, in 1.3.4+ style parameters you may define at frame level apply to the whole text chain which may run across several frames. Not in 1.3.x. This also can be translated only by direct formatting in 1.3.4+.

subeditor

2010-11-01 09:55

reporter   ~0024778

in 1.3.3.x one could apply several paragraph style on different portion of a paragraph - but that was nonsense truly said! It's like one man with several different blood types. Why should you keep early mistakes? Such position will keep Scribus ugly for long time!

jghali

2010-11-01 10:32

administrator   ~0024779

Last edited: 2010-11-01 10:40

>> in 1.3.3.x one could apply several paragraph style on different portion of a paragraph - but that was nonsense truly said! It's like one man with several different blood types. Why should you keep early mistakes? Such position will keep Scribus ugly for long time!

Yes, because 1.3.3x had no character styles. We have not kept those mistakes but in 1.3.4+ we have to use direct formatting to preserve document visual aspect when opening 1.2.x - 1.3.x docs.

cezaryece

2010-11-21 13:08

updater  

clear.paragraph.stylesFIXED.diff (5,267 bytes)   
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(wersja 15654)
+++ scribus/scribusdoc.cpp	(kopia robocza)
@@ -6169,7 +6169,7 @@
 {
 	ParagraphStyle newStyle;
 	newStyle.setParent(name.isEmpty()? Style::INHERIT_PARENT : name);
-	itemSelection_ApplyParagraphStyle(newStyle, customSelection, true);
+    itemSelection_ApplyParagraphStyle(newStyle, customSelection);
 }
 
 
@@ -6861,6 +6861,7 @@
 
 void ScribusDoc::itemSelection_EraseParagraphStyle(Selection* customSelection)
 {
+
 	Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
 	assert(itemSelection!=0);
 	uint selectedItemCount=itemSelection->count();
@@ -6869,11 +6870,13 @@
 	UndoTransaction* activeTransaction = NULL;
 	if (selectedItemCount > 1)
 		activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, tr( "remove direct paragraph formatting" ), Um::IFont));
+
 	for (uint aa = 0; aa < selectedItemCount; ++aa)
 	{
 		PageItem *currItem = itemSelection->itemAt(aa);
 //		int currItemTextCount = currItem->lastInFrame() + 1 - currItem->firstInFrame();
 //		if (currItemTextCount > 0 && ( appMode == modeEdit || !FRAMESELECTION_EDITS_DEFAULTSTYLE))
+
 		int currItemTextCount = currItem->itemText.length();
 		if ((currItemTextCount > 0) && (appMode == modeEdit))
 		{
@@ -6918,7 +6921,63 @@
 	changed();
 	regionsChanged()->update(QRectF());
 }
+void ScribusDoc::itemSelection_ResetParagraphStyle(Selection* customSelection)
+{
+    Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
+    assert(itemSelection!=0);
+    uint selectedItemCount=itemSelection->count();
+    if (selectedItemCount == 0)
+        return;
+    UndoTransaction* activeTransaction = NULL;
+    if (selectedItemCount > 1)
+        activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, tr( "remove direct paragraph formatting" ), Um::IFont));
+    for (uint aa = 0; aa < selectedItemCount; ++aa)
+    {
+        PageItem *currItem = itemSelection->itemAt(aa);
+        int currItemTextCount = currItem->itemText.length();
 
+        if ((currItemTextCount == 0) || (appMode != modeEdit))
+        {
+            ParagraphStyle dstyle(currItem->itemText.defaultStyle());
+            dstyle.applyStyle(currItem->itemText.defaultStyle());
+            currItem->itemText.setDefaultStyle(dstyle);
+        }
+        if (currItemTextCount > 0)
+        {
+            int start = currItem->asPathText() ? currItem->itemText.startOfItem(currItem->firstInFrame()) : 0;
+            int stop  = currItem->asPathText() ? currItem->itemText.endOfItem(currItem->lastInFrame()) :  currItemTextCount;
+            if (appMode == modeEdit)
+            {
+                start = currItem->itemText.startOfSelection();
+                stop = currItem->itemText.endOfSelection();
+                if (start >= stop)
+                    start = stop = qMax(0, qMin(currItem->itemText.length(), currItem->CPos));
+            }
+            for (int pos=start; pos < stop; ++pos)
+            {
+                if (currItem->itemText.text(pos) == SpecialChars::PARSEP)
+                {
+                    currItem->itemText.applyStyle(pos, currItem->itemText.paragraphStyle(pos), true);
+                }
+            }
+            currItem->itemText.applyStyle(stop, currItem->itemText.paragraphStyle(start), true);
+            currItem->invalid = true;
+        }
+        if (currItem->asPathText())
+            currItem->updatePolyClip();
+        currItem->invalidateLayout();
+    }
+    if (activeTransaction)
+    {
+        activeTransaction->commit();
+        delete activeTransaction;
+        activeTransaction = NULL;
+    }
+    changed();
+    regionsChanged()->update(QRectF());
+}
+
 void ScribusDoc::itemSelection_ApplyParagraphStyle(const ParagraphStyle & newStyle, Selection* customSelection, bool rmDirectFormatting)
 {
 	Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h	(wersja 15654)
+++ scribus/scribusdoc.h	(kopia robocza)
@@ -919,6 +919,7 @@
 	void itemSelection_ApplyCharStyle(const CharStyle & newstyle, Selection* customSelection=0);
 	void itemSelection_SetCharStyle(const CharStyle & newstyle, Selection* customSelection=0);
 	void itemSelection_EraseParagraphStyle(Selection* customSelection=0);
+    void itemSelection_ResetParagraphStyle(Selection* customSelection=0);
 	void itemSelection_EraseCharStyle(Selection* customSelection=0);
 
 	void itemSelection_SetNamedParagraphStyle(const QString & name, Selection* customSelection=0);
Index: scribus/ui/propertiespalette.cpp
===================================================================
--- scribus/ui/propertiespalette.cpp	(wersja 15654)
+++ scribus/ui/propertiespalette.cpp	(kopia robocza)
@@ -4364,7 +4364,7 @@
 		return;
 	if (HaveDoc)
 	{
-		doc->itemSelection_EraseParagraphStyle();
+        doc->itemSelection_ResetParagraphStyle();
 		CharStyle emptyCStyle;
 		doc->itemSelection_SetCharStyle(emptyCStyle);
 	}

cezaryece

2010-11-21 13:09

updater   ~0024861

Last edited: 2010-11-21 13:11

I was upload new fixed version of patch.

I think we can make Scribus changing behaviour depend on which version of doc is opened.

ale

2010-12-23 21:35

manager   ~0025187

personally, i think that it should be the task of the converter to make sure that the file is correctly imported...

ale

2012-07-03 11:27

manager   ~0028354

after yesterday's discussion with karto on irc, it's even clearer how wrong the current situation is!
one can correctly import italics and bolds from an odt file, but loses them as soon she tries to apply the paragraph styles?
i'm all for backwards compatibility, but not being able to work with the current documents is at least as bad!
everybody who is loading formatted text will see this as a major issue.

subeditor

2012-07-03 12:11

reporter   ~0028356

BTW, what will happen with italic if there is no italic installed for font used in applied style?

I consider that bugs should be separated from users` requirements. It should greatly simplify development process. Code errors and UX issues are things of different nature.

Eneen

2017-04-28 15:10

reporter   ~0043867

Maybe it's worth removing this limitation. 1.3.4 was released 10 years ago, there is IMO really small chance that anyone uses 1.3.3 currently, especially that 1.3.3 had no character styles.

jghali

2017-04-29 09:05

administrator   ~0043875

1.3.3.x is actually not the whole story. We received also bugs for case where style was defining an attribute, text was defining same attribute but with another value, and applying style failed to change the text attribute to style value. So we have to find a better solution than simply coming back to old situation.

jghali

2017-04-29 09:11

administrator   ~0043876

Imo a beginning of solution would be probably to split more clearly paragraph styles and character styles so that paragraph styles can be applied without any risk of touching character attributes. Not sure this can happen before 1.6.0 tho.

Eneen

2017-04-29 11:42

reporter   ~0043877

I'm not sure how it works elsewhere but maybe priority rule will be better, so style with higher priority will override lower priority:
4. text character style
3. text paragraph style
2. frame character style
1. frame paragraph style

jghali

2017-04-29 11:47

administrator   ~0043878

This is already the priority order in use.

Issue History

Date Modified Username Field Change
2010-02-05 09:51 cezaryece New Issue
2010-02-05 10:07 jghali Note Added: 0023204
2010-02-05 10:09 jghali Note Edited: 0023204
2010-02-05 10:09 jghali Note Edited: 0023204
2010-02-07 11:37 cezaryece Note Added: 0023216
2010-02-07 12:01 jghali Note Added: 0023217
2010-02-07 12:01 jghali Note Edited: 0023217
2010-10-26 13:21 cezaryece File Added: clear.paragraph.styles.diff
2010-10-26 13:21 cezaryece Note Added: 0024735
2010-10-31 18:46 ale Note Added: 0024769
2010-10-31 18:47 ale Note Added: 0024770
2010-10-31 21:17 jghali Note Added: 0024772
2010-10-31 21:40 jghali Note Added: 0024775
2010-10-31 21:40 jghali Note Edited: 0024775
2010-10-31 21:43 jghali Note Edited: 0024775
2010-11-01 09:55 subeditor Note Added: 0024778
2010-11-01 10:32 jghali Note Added: 0024779
2010-11-01 10:39 jghali Note Edited: 0024779
2010-11-01 10:40 jghali Note Edited: 0024779
2010-11-21 13:08 cezaryece File Added: clear.paragraph.stylesFIXED.diff
2010-11-21 13:09 cezaryece Note Added: 0024861
2010-11-21 13:11 cezaryece Note Edited: 0024861
2010-12-23 21:35 ale Note Added: 0025187
2012-07-03 11:27 ale Note Added: 0028354
2012-07-03 12:11 subeditor Note Added: 0028356
2016-01-28 02:51 Kunda Relationship added related to 0012800
2017-04-28 14:04 jghali Relationship added has duplicate 0014785
2017-04-28 15:10 Eneen Note Added: 0043867
2017-04-29 09:05 jghali Note Added: 0043875
2017-04-29 09:11 jghali Note Added: 0043876
2017-04-29 11:42 Eneen Note Added: 0043877
2017-04-29 11:47 jghali Note Added: 0043878
2017-07-11 21:59 jghali Relationship added has duplicate 0014908