Subversion Repositories Scribus

Compare Revisions

Regard whitespace Rev 20460 → Rev 20461

/trunk/Scribus/scribus/third_party/rtf-qt/AbstractRtfOutput.h
22,10 → 22,9
#include <QString>
#include <QVariant>
#include <QColor>
#include <QTextImageFormat>
 
#include "FontTableEntry.h"
#include "StyleSheetTableEntry.h"
class ParagraphStyle;
/**
Namespace for the public interface for the RtfReader classes
*/
311,7 → 310,8
virtual void addTabStop( const int value, const int type ) = 0;
virtual void appendToColourTable( const QColor &colour ) = 0;
virtual void insertFontTableEntry( FontTableEntry fontTableEntry, quint32 fontTableIndex ) = 0;
virtual void insertStyleSheetTableEntry( quint32 stylesheetTableIndex, StyleSheetTableEntry stylesheetTableEntry ) = 0;
virtual void insertStyleSheetTableEntry( quint32 stylesheetTableIndex, ParagraphStyle stylesheetTableEntry ) = 0;
virtual void useStyleSheetTableEntry(const int styleIndex) = 0;
 
virtual void startGroup();
virtual void endGroup();
/trunk/Scribus/scribus/third_party/rtf-qt/DocumentDestination.cpp
126,7 → 126,7
else if ((controlWord == "sb") && hasValue)
m_output->setSpaceBefore(value);
else if (controlWord == "sb")
m_output->setSpaceAfter(0);
m_output->setSpaceBefore(0);
else if ((controlWord == "sa") && hasValue)
m_output->setSpaceAfter(value);
else if (controlWord == "sa")
160,9 → 160,9
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 if ((controlWord == "s") && hasValue)
m_output->useStyleSheetTableEntry(value);
else if ((controlWord == "\'") && hasValue)
{
// qDebug() << "special character value:" << value;
/trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.cpp
19,14 → 19,20
 
#include "rtfreader.h"
#include "controlword.h"
#include "commonstrings.h"
 
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_currentStyleHandleNumber = 0; /* default */
m_textStyle.setParent(CommonStrings::DefaultParagraphStyle);
m_textStyle.setLineSpacingMode(ParagraphStyle::AutomaticLineSpacing);
m_textStyle.charStyle().setFontSize(120.0);
QList<ParagraphStyle::TabRecord> tbs;
tbs.clear();
m_textStyle.setTabValues(tbs);
}
 
StyleSheetDestination::~StyleSheetDestination()
35,51 → 41,159
 
void StyleSheetDestination::handleControlWord( const QString &controlWord, bool hasValue, const int value )
{
if ( controlWord == "ql" ) {
m_style.setTextAlignment( LeftAligned);
} else if ( ( controlWord == "li" ) && hasValue ) {
m_style.setLeftIndent( value );
} else if ( ( controlWord == "ri" ) && hasValue ) {
m_style.setRightIndent( value );
} else if ( controlWord == "ltrch" ) {
m_style.setLayoutDirection( Qt::LeftToRight );
} else if ( controlWord == "rtlch" ) {
m_style.setLayoutDirection( Qt::RightToLeft );
} else if ( ( controlWord == "s" ) && hasValue ) {
if (controlWord == "ql")
m_textStyle.setAlignment(ParagraphStyle::Leftaligned);
else if (controlWord == "qj")
m_textStyle.setAlignment(ParagraphStyle::Justified);
else if (controlWord == "qc")
m_textStyle.setAlignment(ParagraphStyle::Centered);
else if (controlWord == "qr")
m_textStyle.setAlignment(ParagraphStyle::Rightaligned);
else if ((controlWord == "li") && hasValue)
m_textStyle.setLeftMargin(pixelsFromTwips(value));
else if ((controlWord == "ri") && hasValue)
m_textStyle.setRightMargin(pixelsFromTwips(value));
else if ((controlWord == "sb") && hasValue)
m_textStyle.setGapBefore(pixelsFromTwips(value));
else if (controlWord == "sb")
m_textStyle.setGapBefore(pixelsFromTwips(0));
else if ((controlWord == "sa") && hasValue)
m_textStyle.setGapAfter(pixelsFromTwips(value));
else if (controlWord == "sa")
m_textStyle.setGapAfter(pixelsFromTwips(0));
else if (controlWord == "sl")
{
if (value == 0)
m_textStyle.setLineSpacingMode(ParagraphStyle::AutomaticLineSpacing);
else
{
m_textStyle.setLineSpacingMode(ParagraphStyle::FixedLineSpacing);
m_textStyle.setLineSpacing(pixelsFromTwips(qAbs(value)));
}
}
else if (controlWord == "fs")
{
if (hasValue && ( value != 0))
m_textStyle.charStyle().setFontSize(value * 5.0);
else
m_textStyle.charStyle().setFontSize(120.0);
}
else if (controlWord == "f")
m_textStyle.charStyle().setFontVariant(QString("%1").arg(value));
else if (controlWord == "ul")
{
StyleFlag styleEffects = m_textStyle.charStyle().effects();
if (!hasValue || (hasValue && value != 0))
styleEffects |= ScStyle_Underline;
else
styleEffects &= ~ScStyle_Underline;
m_textStyle.charStyle().setFeatures(styleEffects.featureList());
}
else if (controlWord == "ulw")
{
StyleFlag styleEffects = m_textStyle.charStyle().effects();
if (!hasValue || (hasValue && value != 0))
styleEffects |= ScStyle_UnderlineWords;
else
styleEffects &= ~ScStyle_UnderlineWords;
m_textStyle.charStyle().setFeatures(styleEffects.featureList());
}
else if (controlWord == "outl")
{
StyleFlag styleEffects = m_textStyle.charStyle().effects();
if (!hasValue || (hasValue && value != 0))
styleEffects |= ScStyle_Outline;
else
styleEffects &= ~ScStyle_Outline;
m_textStyle.charStyle().setFeatures(styleEffects.featureList());
}
else if (controlWord == "shad")
{
StyleFlag styleEffects = m_textStyle.charStyle().effects();
if (!hasValue || (hasValue && value != 0))
styleEffects |= ScStyle_Shadowed;
else
styleEffects &= ~ScStyle_Shadowed;
m_textStyle.charStyle().setFeatures(styleEffects.featureList());
}
else if (controlWord == "scaps")
{
StyleFlag styleEffects = m_textStyle.charStyle().effects();
if (!hasValue || (hasValue && value != 0))
styleEffects |= ScStyle_SmallCaps;
else
styleEffects &= ~ScStyle_SmallCaps;
m_textStyle.charStyle().setFeatures(styleEffects.featureList());
}
else if (controlWord == "caps")
{
StyleFlag styleEffects = m_textStyle.charStyle().effects();
if (!hasValue || (hasValue && value != 0))
styleEffects |= ScStyle_AllCaps;
else
styleEffects &= ~ScStyle_AllCaps;
m_textStyle.charStyle().setFeatures(styleEffects.featureList());
}
else if (controlWord == "strike")
{
StyleFlag styleEffects = m_textStyle.charStyle().effects();
if (!hasValue || (hasValue && value != 0))
styleEffects |= ScStyle_Strikethrough;
else
styleEffects &= ~ScStyle_Strikethrough;
m_textStyle.charStyle().setFeatures(styleEffects.featureList());
}
else if (controlWord == "super")
{
StyleFlag styleEffects = m_textStyle.charStyle().effects();
styleEffects |= ScStyle_Superscript;
m_textStyle.charStyle().setFeatures(styleEffects.featureList());
}
else if (controlWord == "sub")
{
StyleFlag styleEffects = m_textStyle.charStyle().effects();
styleEffects |= ScStyle_Subscript;
m_textStyle.charStyle().setFeatures(styleEffects.featureList());
}
else if (controlWord == "charscalex")
m_textStyle.charStyle().setScaleH(value * 10.0);
else if (controlWord == "dn")
m_textStyle.charStyle().setBaselineOffset((-value * 10000 / 2) / m_textStyle.charStyle().fontSize());
else if (controlWord == "up")
m_textStyle.charStyle().setBaselineOffset((value * 10000 / 2) / m_textStyle.charStyle().fontSize());
else if (controlWord == "expnd")
m_textStyle.charStyle().setTracking((value * 10000 / 4) / m_textStyle.charStyle().fontSize());
else if (controlWord == "expndtw")
m_textStyle.charStyle().setTracking((pixelsFromTwips(value) * 10000) / m_textStyle.charStyle().fontSize());
else if ((controlWord == "s") && hasValue)
m_currentStyleHandleNumber = value;
} else if ( ( controlWord == "sb" ) && hasValue ) {
m_style.setTopMargin( value );
} else if ( controlWord == "sb" ) {
// qDebug() << "space before default (0)";
} else {
if ( ControlWord::isDestination( controlWord ) ) {
// qDebug() << "unhandled **Destination** control word in StyleSheetDestination:" << controlWord;
} else {
// else
// qDebug() << "unhandled control word in StyleSheetDestination:" << controlWord;
}
}
}
 
void StyleSheetDestination::handlePlainText( const QByteArray &plainText )
{
if ( plainText == ";" ) {
m_output->insertStyleSheetTableEntry( m_currentStyleHandleNumber, m_style );
} else if ( plainText.endsWith( ";" ) ) {
if (plainText == ";")
m_output->insertStyleSheetTableEntry(m_currentStyleHandleNumber, m_textStyle);
else if (plainText.endsWith(";"))
{
// probably a style name with a terminating delimiter
int delimiterPosition = plainText.indexOf( ";" );
if ( delimiterPosition == ( plainText.length() - 1) ) {
if (delimiterPosition == (plainText.length() - 1))
{
// It is at the end, chop it off
QString styleName = plainText.left( delimiterPosition );
m_style.setStyleName( styleName );
m_output->insertStyleSheetTableEntry( m_currentStyleHandleNumber, m_style );
} else {
m_textStyle.setName(styleName);
m_output->insertStyleSheetTableEntry(m_currentStyleHandleNumber, m_textStyle);
}
else
{
// we were not expecting a name with a delimiter other than at the end
// qDebug() << "Style name with embedded delimiter: " << plainText;
}
} else {
// plain font name
m_style.setStyleName( plainText );
}
else
m_textStyle.setName(plainText);
}
 
void StyleSheetDestination::aboutToEndDestination()
86,4 → 200,9
{
// TODO
}
 
double StyleSheetDestination::pixelsFromTwips(const int twips)
{
return twips / 1440.0 * 72.0;
}
}
/trunk/Scribus/scribus/third_party/rtf-qt/StyleSheetDestination.h
22,7 → 22,8
#include <QColor>
 
#include "Destination.h"
#include "StyleSheetTableEntry.h"
#include "styles/charstyle.h"
#include "styles/paragraphstyle.h"
namespace RtfReader
{
class Reader;
31,16 → 32,15
{
public:
StyleSheetDestination( Reader *reader, AbstractRtfOutput *output, const QString &name );
 
virtual ~StyleSheetDestination();
 
virtual void handleControlWord( const QString &controlWord, bool hasValue, const int value );
virtual void handlePlainText(const QByteArray &plainText );
virtual void aboutToEndDestination();
 
protected:
double pixelsFromTwips(const int twips);
quint32 m_currentStyleHandleNumber;
StyleSheetTableEntry m_style;
ParagraphStyle m_textStyle;
};
}
 
/trunk/Scribus/scribus/third_party/rtf-qt/sladocumentrtfoutput.cpp
376,11 → 376,31
 
}
 
void SlaDocumentRtfOutput::insertStyleSheetTableEntry(quint32 stylesheetTableIndex, StyleSheetTableEntry stylesheetTableEntry)
void SlaDocumentRtfOutput::insertStyleSheetTableEntry(quint32 stylesheetTableIndex, ParagraphStyle stylesheetTableEntry)
{
// qDebug() << "insertStyleSheetTableEntry";
m_stylesTable.insert(stylesheetTableIndex, stylesheetTableEntry);
}
 
void SlaDocumentRtfOutput::useStyleSheetTableEntry(const int styleIndex)
{
if (m_stylesTable.contains(styleIndex))
{
ParagraphStyle newStyle = m_stylesTable[styleIndex];
int fontInd = newStyle.charStyle().fontVariant().toInt();
newStyle.charStyle().setFontVariant("");
setFont(fontInd);
StyleSet<ParagraphStyle>tmp;
tmp.create(newStyle);
m_Doc->redefineStyles(tmp, false);
ParagraphStyle newStyle2;
newStyle2.setParent(m_stylesTable[styleIndex].name());
m_textStyle.pop();
m_textStyle.push(newStyle2);
m_textCharStyle.pop();
m_textCharStyle.push(newStyle2.charStyle());
}
}
 
void SlaDocumentRtfOutput::resetParagraphFormat()
{
QString pStyle = CommonStrings::DefaultParagraphStyle;
/trunk/Scribus/scribus/third_party/rtf-qt/sladocumentrtfoutput.h
77,7 → 77,8
virtual void setTextDirectionRightToLeft();
virtual void appendToColourTable(const QColor &colour);
virtual void insertFontTableEntry(FontTableEntry fontTableEntry, quint32 fontTableIndex);
virtual void insertStyleSheetTableEntry(quint32 stylesheetTableIndex, StyleSheetTableEntry stylesheetTableEntry);
virtual void insertStyleSheetTableEntry(quint32 stylesheetTableIndex, ParagraphStyle stylesheetTableEntry);
virtual void useStyleSheetTableEntry(const int styleIndex);
virtual void resetParagraphFormat();
virtual void resetCharacterProperties();
virtual void setParagraphAlignmentLeft();
104,6 → 105,7
QList<QString> m_colourTable;
QHash<int, FontTableEntry> m_fontTable;
QHash<int, FontTableEntry> m_fontTableReal;
QHash<int, ParagraphStyle> m_stylesTable;
QList<QByteArray> m_codecList;
};
}