r22367 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Sun Feb 4 00:12:29 UTC 2018


Author: jghali
Date: Sun Feb  4 00:12:29 2018
New Revision: 22367

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22367
Log:
#15124, part one: fix wrong glyph being used for drop cap if drop cap style use a different font than the rest of paragraph

Modified:
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/text/itextcontext.h
    trunk/Scribus/scribus/text/itextsource.h
    trunk/Scribus/scribus/text/textcontext.cpp
    trunk/Scribus/scribus/text/textcontext.h
    trunk/Scribus/scribus/text/textshaper.cpp

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22367&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Sun Feb  4 00:12:29 2018
@@ -1571,35 +1571,6 @@
 			}
 			//--<#13490
 			CharStyle charStyle = ((itemText.text(a) != SpecialChars::PARSEP) ? itemText.charStyle(a) : style.charStyle());
-
-			//set style for paragraph effects
-			if (itemText.isBlockStart(a))
-			{
-				// FIXME: we should avoid calling setCharStyle() in layout()
-				if (style.hasDropCap() || style.hasBullet() || style.hasNum())
-				{
-					const QString& curParent(style.hasParent() ? style.parent() : style.name());
-					CharStyle newStyle(charStyle);
-					if (style.peCharStyleName().isEmpty())
-						newStyle.setParent(m_Doc->paragraphStyle(curParent).charStyle().name());
-					else if (charStyle.name() != style.peCharStyleName())
-						newStyle.setParent(m_Doc->charStyle(style.peCharStyleName()).name());
-					charStyle.setStyle(newStyle);
-					itemText.setCharStyle(a, 1 , charStyle);
-				}
-				else if (!style.peCharStyleName().isEmpty())
-				{
-					//par effect is cleared but is set dcCharStyleName = clear drop cap char style
-					if (charStyle.parent() == style.peCharStyleName())
-					{
-						const QString& curParent(style.hasParent() ? style.parent() : style.name());
-						if (m_Doc->charStyles().contains(style.peCharStyleName()))
-							charStyle.eraseCharStyle(m_Doc->charStyle(style.peCharStyleName()));
-						charStyle.setParent(m_Doc->paragraphStyle(curParent).charStyle().name());
-						itemText.setCharStyle(a, 1,charStyle);
-					}
-				}
-			}
 
 			double hlcsize10 = charStyle.fontSize() / 10.0;
 			double scaleV = charStyle.scaleV() / 1000.0;

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22367&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h	(original)
+++ trunk/Scribus/scribus/scribusdoc.h	Sun Feb  4 00:12:29 2018
@@ -520,8 +520,8 @@
 	 */
 	void enableCMS(bool enable);
 	
-	const ParagraphStyle& paragraphStyle(const QString& name) { return m_docParagraphStyles.get(name); }
-	const StyleSet<ParagraphStyle>& paragraphStyles()   { return m_docParagraphStyles; }
+	const ParagraphStyle& paragraphStyle(const QString& name) const { return m_docParagraphStyles.get(name); }
+	const StyleSet<ParagraphStyle>& paragraphStyles()  const { return m_docParagraphStyles; }
 	bool isDefaultStyle( const ParagraphStyle& p ) const { return m_docParagraphStyles.isDefault(p); }
 	bool isDefaultStyle( const CharStyle& c ) const { return m_docCharStyles.isDefault(c); }
 // 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }
@@ -621,8 +621,8 @@
 	                                          StyleSet<CharStyle> *tempCharStyles,
 											  QHash<QString, multiLine> *tempLineStyles);
 
-	const CharStyle& charStyle(const QString& name) { return m_docCharStyles.get(name); }
-	const StyleSet<CharStyle>& charStyles()  { return m_docCharStyles; }
+	const CharStyle& charStyle(const QString& name) const { return m_docCharStyles.get(name); }
+	const StyleSet<CharStyle>& charStyles() const { return m_docCharStyles; }
 	void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false);
 	/**
 	 * @brief Remove any reference to old styles and replace with new name. This needs to be

Modified: trunk/Scribus/scribus/text/itextcontext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22367&path=/trunk/Scribus/scribus/text/itextcontext.h
==============================================================================
--- trunk/Scribus/scribus/text/itextcontext.h	(original)
+++ trunk/Scribus/scribus/text/itextcontext.h	Sun Feb  4 00:12:29 2018
@@ -19,6 +19,7 @@
 class InlineFrame;
 class ExpansionPoint;
 class PageItem;
+class ScribusDoc;
 
 /**
  * This class collects all information that may be used during text layout:
@@ -30,6 +31,7 @@
 class SCRIBUS_API ITextContext {
 
 public:
+	virtual const ScribusDoc* getDoc() const = 0;
 	virtual const PageItem* getFrame() const = 0;
 	virtual double height() const = 0;
 	virtual double width() const = 0;

Modified: trunk/Scribus/scribus/text/itextsource.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22367&path=/trunk/Scribus/scribus/text/itextsource.h
==============================================================================
--- trunk/Scribus/scribus/text/itextsource.h	(original)
+++ trunk/Scribus/scribus/text/itextsource.h	Sun Feb  4 00:12:29 2018
@@ -15,6 +15,7 @@
 class ParagraphStyle;
 class InlineFrame;
 class GlyphCluster;
+class ScribusDoc;
 
 
 class SCRIBUS_API ITextSource {
@@ -33,7 +34,11 @@
 	virtual int nextBlockStart(int pos) const = 0;
 	
 	virtual const CharStyle& charStyle(int pos) const = 0; 
-	virtual const ParagraphStyle& paragraphStyle(int pos) const = 0; 
+	virtual const ParagraphStyle& paragraphStyle(int pos) const = 0;
+
+	virtual void setCharStyle(int pos, uint len, const CharStyle& style) = 0;
+	virtual void setStyle(int pos, const ParagraphStyle& style) = 0;
+
 	virtual LayoutFlags flags(int pos) const = 0;
 	virtual bool hasFlag(int pos, LayoutFlags flag) const = 0;
 	virtual void setFlag(int pos, LayoutFlags flag) = 0;

Modified: trunk/Scribus/scribus/text/textcontext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22367&path=/trunk/Scribus/scribus/text/textcontext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/textcontext.cpp	(original)
+++ trunk/Scribus/scribus/text/textcontext.cpp	Sun Feb  4 00:12:29 2018
@@ -18,6 +18,11 @@
 
 static CharStyle* emptyCStyle;
 static ParagraphStyle*  emptyPStyle;
+
+const ScribusDoc* TextContext::getDoc() const
+{
+	return m_frame->doc();
+}
 
 const CharStyle& TextContext::charStyle() const 
 { 

Modified: trunk/Scribus/scribus/text/textcontext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22367&path=/trunk/Scribus/scribus/text/textcontext.h
==============================================================================
--- trunk/Scribus/scribus/text/textcontext.h	(original)
+++ trunk/Scribus/scribus/text/textcontext.h	Sun Feb  4 00:12:29 2018
@@ -14,10 +14,10 @@
 #include "styles/charstyle.h"
 #include "styles/paragraphstyle.h"
 
-
-class PageItem;
 class ExpansionPoint;
 class InlineFrame;
+class PageItem;
+class ScribusDoc;
 
 class SCRIBUS_API TextContext : public ITextContext {
 	PageItem* m_frame;
@@ -25,6 +25,7 @@
 public:
 	TextContext(PageItem* frame) : m_frame(frame) {}
 
+	virtual const ScribusDoc* getDoc() const;
 	virtual const PageItem* getFrame() const { return m_frame; }  
 	
 	//virtual double height() const  // return getFrame()->height(); }

Modified: trunk/Scribus/scribus/text/textshaper.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22367&path=/trunk/Scribus/scribus/text/textshaper.cpp
==============================================================================
--- trunk/Scribus/scribus/text/textshaper.cpp	(original)
+++ trunk/Scribus/scribus/text/textshaper.cpp	Sun Feb  4 00:12:29 2018
@@ -200,6 +200,38 @@
 		
 		str.replace(SpecialChars::SHYPHEN, SpecialChars::ZWNJ);
 
+		//set style for paragraph effects
+		if (m_story.isBlockStart(i) && (m_context != 0) && (m_context->getDoc() != 0))
+		{
+			const ScribusDoc* doc = m_context->getDoc();
+			const ParagraphStyle& style = m_story.paragraphStyle(i);
+			if (style.hasDropCap() || style.hasBullet() || style.hasNum())
+			{
+				CharStyle charStyle = ((m_story.text(i) != SpecialChars::PARSEP) ? m_story.charStyle(i) : style.charStyle());
+				const QString& curParent(style.hasParent() ? style.parent() : style.name());
+				CharStyle newStyle(charStyle);
+				if (style.peCharStyleName().isEmpty())
+					newStyle.setParent(doc->paragraphStyle(curParent).charStyle().name());
+				else if (charStyle.name() != style.peCharStyleName())
+					newStyle.setParent(doc->charStyle(style.peCharStyleName()).name());
+				charStyle.setStyle(newStyle);
+				m_story.setCharStyle(i, 1, charStyle);
+			}
+			else if (!style.peCharStyleName().isEmpty())
+			{
+				//par effect is cleared but is set dcCharStyleName = clear drop cap char style
+				CharStyle charStyle = ((m_story.text(i) != SpecialChars::PARSEP) ? m_story.charStyle(i) : style.charStyle());
+				if (charStyle.parent() == style.peCharStyleName())
+				{
+					const QString& curParent(style.hasParent() ? style.parent() : style.name());
+					if (doc->charStyles().contains(style.peCharStyleName()))
+						charStyle.eraseCharStyle(doc->charStyle(style.peCharStyleName()));
+					charStyle.setParent(doc->paragraphStyle(curParent).charStyle().name());
+					m_story.setCharStyle(i, 1, charStyle);
+				}
+			}
+		}
+
 		const CharStyle &style = m_story.charStyle(i);
 		int effects = style.effects() & ScStyle_UserStyles;
 		bool hasSmallCap = false;




More information about the scribus-commit mailing list