r20679 by fschmid -

scribus-commit scribus-commit at lists.scribus.net
Tue Jan 12 20:15:17 UTC 2016


Author: fschmid
Date: Tue Jan 12 20:15:17 2016
New Revision: 20679

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20679
Log:
Try to fix Bug #13636: Style Manager doesn't support certain fonts

Modified:
    trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.cpp
    trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.h

Modified: trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20679&path=/trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.cpp
==============================================================================
--- trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.cpp	(original)
+++ trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.cpp	Tue Jan 12 20:15:17 2016
@@ -25,7 +25,7 @@
 namespace RtfReader
 {
 
-	StyleSheetDestination::StyleSheetDestination(Reader *reader, AbstractRtfOutput *output, const QString &name) : Destination(reader, output, name)
+	StyleSheetDestination::StyleSheetDestination(Reader *reader, AbstractRtfOutput *output, const QString &name) : Destination(reader, output, name), m_uc_Value(1)
 	{
 		m_currentStyleHandleNumber = 0; /* default */
 		m_textStyle.setParent(CommonStrings::DefaultParagraphStyle);
@@ -173,13 +173,35 @@
 			m_currentStyleParent = value;
 		else if ((controlWord == "s") && hasValue)
 			m_currentStyleHandleNumber = value;
+		else if ((controlWord == "u") && hasValue)
+		{
+			m_styleName.append(m_output->getCurrentCodec()->fromUnicode(QChar(value)));
+			m_charactersToSkip = m_uc_Value; /* TODO: this should be driven by \uc, default to 1 */
+		}
+		else if ((controlWord == "uc") && hasValue)
+			m_uc_Value = value;
 	//	else
 	//		qDebug() << "unhandled control word in StyleSheetDestination:" << controlWord;
 	}
 
 	void StyleSheetDestination::handlePlainText(const QByteArray &plainText)
 	{
-		if (plainText == ";")
+		QByteArray pT = plainText;
+		if (m_charactersToSkip > 0)
+		{
+		//	qDebug() << "skipping" << m_charactersToSkip << "of" << plainText;
+			if (m_charactersToSkip >= plainText.size())
+			{
+				m_charactersToSkip -= plainText.size();
+				return;
+			}
+			else if (plainText.size() > m_charactersToSkip)
+			{
+				pT.remove(0, m_charactersToSkip);
+				m_charactersToSkip = 0;
+			}
+		}
+		if (pT == ";")
 		{
 			m_stylesTable.insert(m_currentStyleHandleNumber, m_currentStyleParent);
 			m_output->insertStyleSheetTableEntry(m_currentStyleHandleNumber, m_textStyle);
@@ -194,14 +216,14 @@
 			m_styleName = "";
 			m_currentStyleParent = -1;
 		}
-		else if (plainText.endsWith(";"))
+		else if (pT.endsWith(";"))
 		{
 			// probably a style name with a terminating delimiter
-			int delimiterPosition = plainText.indexOf(";");
-			if (delimiterPosition == (plainText.length() - 1))
+			int delimiterPosition = pT.indexOf(";");
+			if (delimiterPosition == (pT.length() - 1))
 			{
 				// It is at the end, chop it off
-				QByteArray styleName = plainText.left(delimiterPosition);
+				QByteArray styleName = pT.left(delimiterPosition);
 				m_styleName.append(styleName);
 				m_textStyle.setName(m_output->getCurrentCodec()->toUnicode(m_styleName));
 				m_stylesTable.insert(m_currentStyleHandleNumber, m_currentStyleParent);
@@ -224,7 +246,7 @@
 			}
 		}
 		else
-			m_styleName.append(plainText);
+			m_styleName.append(pT);
 	}
 
 	void StyleSheetDestination::aboutToEndDestination()

Modified: trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20679&path=/trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.h
==============================================================================
--- trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.h	(original)
+++ trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.h	Tue Jan 12 20:15:17 2016
@@ -44,6 +44,8 @@
 			ParagraphStyle m_textStyle;
 			QByteArray m_styleName;
 			QHash<quint32, int> m_stylesTable;
+			int m_charactersToSkip;
+			int m_uc_Value;
 	};
 }
 




More information about the scribus-commit mailing list