r14353 by fschmid - Xara Importer: More bits of text handling.
scribus-commit
scribus-commit at lists.scribus.net
Wed Nov 25 19:30:25 CET 2009
Revision: 14353
Author: fschmid
Date: 2009-11-25T09:12:36.940689Z
Commit message: Xara Importer: More bits of text handling.
Changeset:
M /trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
M /trunk/Scribus/scribus/plugins/import/xar/importxar.h
Diffs:
Index: scribus/plugins/import/xar/importxar.cpp
===================================================================
--- scribus/plugins/import/xar/importxar.cpp (revision 14352)
+++ scribus/plugins/import/xar/importxar.cpp (revision 14353)
@@ -73,7 +73,6 @@
interactive = false;
showProgress = false;
}
- baseFile = QDir::cleanPath(QDir::toNativeSeparators(fi.absolutePath()+"/"));
if ( showProgress )
{
ScribusMainWindow* mw=(m_Doc==0) ? ScCore->primaryMainWindow() : m_Doc->scMW();
@@ -395,7 +394,7 @@
}
color.name = "Yellow";
XarColorMap.insert(-9, color);
- ignoreableTags << 2 << 40 << 41 << 43 << 46 << 47 << 53 << 61 << 62 << 63 << 80 << 90 << 91 << 92 << 93 << 111 << 4031;
+ ignoreableTags << 2 << 40 << 41 << 43 << 46 << 47 << 53 << 61 << 62 << 63 << 80 << 90 << 91 << 92 << 93 << 111 << 2200 << 2205 << 4031;
ignoreableTags << 4087 << 4114 << 4115 << 4116 << 4124;
if(progressDialog)
{
@@ -406,7 +405,6 @@
QFile f(fn);
if (f.open(QIODevice::ReadOnly))
{
- oldDocItemCount = m_Doc->Items->count();
int fSize = (int) f.size();
if (progressDialog)
{
@@ -645,6 +643,8 @@
endTextLine();
else if (tag == 2206)
handleLineInfo(ts);
+ else if ((tag == 2902) || (tag == 2903) || (tag == 2904))
+ handleTextAlignment(tag);
else if (tag == 2906)
handleTextFontSize(ts);
else if (tag == 2907)
@@ -754,24 +754,43 @@
ts >> width >> height >> spacing;
XarStyle *gc = m_gc.top();
gc->LineHeight = -spacing / 1000.0;
+ gc->LineWidth = width / 1000.0;
// qDebug() << "Linespacing" << gc->LineHeight;
}
+void XarPlug::handleTextAlignment(quint32 tag)
+{
+ XarStyle *gc = m_gc.top();
+ if (tag == 2902)
+ gc->TextAlignment = 0;
+ else if (tag == 2903)
+ gc->TextAlignment = 1;
+ else if (tag == 2904)
+ gc->TextAlignment = 2;
+}
+
void XarPlug::endTextLine()
{
-// qDebug() << "End of Line";
XarStyle *gc = m_gc.top();
- gc->TextY += gc->LineHeight;
+ TextY += gc->LineHeight;
QPainterPath painterPath;
- painterPath.addText( gc->TextX, gc->TextY, QFont(gc->FontFamily, gc->FontSize), gc->itemText);
+ QFont textFont = QFont(gc->FontFamily, gc->FontSize);
+ textFont.setPixelSize(gc->FontSize);
+ painterPath.addText( TextX, TextY, textFont, gc->itemText);
+ QRectF bound = painterPath.boundingRect();
Coords.resize(0);
Coords.fromQPainterPath(painterPath);
+ if (gc->TextAlignment == 1)
+ Coords.translate(-bound.width() / 2.0, 0);
+ else if (gc->TextAlignment == 2)
+ Coords.translate(-bound.width(), 0);
if (Coords.size() > 0)
{
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, 0, gc->FillCol, CommonStrings::None, true);
finishItem(z);
}
gc->itemText = "";
+// qDebug() << "End of Line, new Y-Pos" << TextY << "Align" << gc->TextAlignment << "Moved by" << gc->LineWidth - txtW;
}
void XarPlug::startSimpleText(QDataStream &ts, quint32 dataLen)
@@ -783,10 +802,9 @@
ts >> flag;
XarStyle *gc = m_gc.top();
gc->itemText = "";
- gc->TextX = textX;
- gc->TextY = docHeight - textY;
+ TextX = textX;
+ TextY = docHeight - textY;
// qDebug() << "Simple Text at" << textX << docHeight - textY;
-
}
void XarPlug::startComplexText(QDataStream &ts, quint32 dataLen)
@@ -804,10 +822,9 @@
ts >> flag;
XarStyle *gc = m_gc.top();
gc->itemText = "";
- gc->TextX = transX;
- gc->TextY = docHeight - transY;
+ TextX = transX;
+ TextY = docHeight - transY;
// qDebug() << "Complex Text at" << transX << docHeight - transY;
-
}
void XarPlug::handleFillRule(QDataStream &ts)
Index: scribus/plugins/import/xar/importxar.h
===================================================================
--- scribus/plugins/import/xar/importxar.h (revision 14352)
+++ scribus/plugins/import/xar/importxar.h (revision 14353)
@@ -39,8 +39,8 @@
itemText(""),
FontSize(12.0),
LineHeight(15.0),
- TextX(0.0),
- TextY(0.0),
+ LineWidth(0.0),
+ TextAlignment(0),
FillCol(CommonStrings::None),
fillRule(true),
FillGradient(VGradient::linear),
@@ -103,8 +103,8 @@
QString itemText;
double FontSize;
double LineHeight;
- double TextX;
- double TextY;
+ double LineWidth;
+ int TextAlignment;
QString FillCol;
bool fillRule;
VGradient FillGradient;
@@ -199,6 +199,7 @@
void handleTextString(QDataStream &ts, quint32 dataLen);
void handleTextChar(QDataStream &ts);
void handleLineInfo(QDataStream &ts);
+ void handleTextAlignment(quint32 tag);
void endTextLine();
void startSimpleText(QDataStream &ts, quint32 dataLen);
void startComplexText(QDataStream &ts, quint32 dataLen);
@@ -246,6 +247,17 @@
void addGraphicContext();
void popGraphicContext();
+ int importerFlags;
+ int recordCounter;
+ int currentLayer;
+ double baseX, baseY;
+ double docWidth;
+ double docHeight;
+ bool firstLayer;
+ double TextX;
+ double TextY;
+ bool interactive;
+ bool cancel;
struct XarColor
{
quint32 colorType;
@@ -257,12 +269,6 @@
double component4;
QString name;
};
- QMap<qint32, XarColor> XarColorMap;
- QMap<qint32, PageItem*> pathMap;
- QList<PageItem*> Elements;
- int recordCounter;
- QList<quint32> atomicTags;
- QList<quint32> ignoreableTags;
struct XarGroup
{
int index;
@@ -270,36 +276,24 @@
bool clipping;
PageItem* groupItem;
};
- QStack<XarGroup> groupStack;
- QStack<XarStyle*> m_gc;
+ QByteArray imageData;
+ QList<PageItem*> Elements;
+ QList<quint32> atomicTags;
+ QList<quint32> ignoreableTags;
+ QMap<qint32, XarColor> XarColorMap;
+ QMap<qint32, PageItem*> pathMap;
QMap<QString, QString> patternMap;
QMap<quint32, QString> patternRef;
QMap<quint32, QString> fontRef;
- QByteArray imageData;
- double baseX, baseY;
- double docWidth;
- double docHeight;
- bool firstLayer;
+ QStack<XarGroup> groupStack;
+ QStack<XarStyle*> m_gc;
QString activeLayer;
- int currentLayer;
-
- QRect currRect;
- int currRectItemNr;
- int currRectType;
- QRect lastImageRect;
QStringList importedColors;
FPointArray clipCoords;
-
FPointArray Coords;
- bool interactive;
MultiProgressDialog * progressDialog;
- bool cancel;
ScribusDoc* m_Doc;
Selection* tmpSel;
- int importerFlags;
- int oldDocItemCount;
- QString baseFile;
- int pctVersion;
public slots:
void cancelRequested() { cancel = true; }
More information about the scribus-commit
mailing list