Reimported cff reads fine.

Groups reads fine for strokes.
preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent 2666115b19
commit ae900677bd
  1. 18
      src/adaptors/UBCFFSubsetAdaptor.cpp
  2. 19
      src/adaptors/UBSvgSubsetAdaptor.cpp

@ -249,6 +249,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgRect(const QDomElement &elem
painter.end(); painter.end();
UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName())); UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
svgItem->setUuid(QUuid::createUuid());
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
@ -299,6 +300,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgEllipse(const QDomElement &e
painter.end(); painter.end();
UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName())); UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
svgItem->setUuid(QUuid::createUuid());
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
@ -382,7 +384,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e
UBGraphicsPolygonItem *graphicsPolygon = mCurrentScene->polygonToPolygonItem(polygon); UBGraphicsPolygonItem *graphicsPolygon = mCurrentScene->polygonToPolygonItem(polygon);
graphicsPolygon->setBrush(brush); graphicsPolygon->setBrush(brush);
//graphicsPolygon->setPen(pen);
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
@ -414,7 +415,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e
UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName())); UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
svgItem->setUuid(QUuid::createUuid());
svgItem->resetTransform(); svgItem->resetTransform();
if (!textTransform.isNull()) { if (!textTransform.isNull()) {
transform = transformFromString(textTransform, svgItem); transform = transformFromString(textTransform, svgItem);
@ -524,6 +525,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
//add resulting svg file to scene //add resulting svg file to scene
UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName())); UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName()));
svgItem->setUuid(QUuid::createUuid());
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
@ -1132,7 +1134,7 @@ UBGraphicsGroupContainerItem *UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbGro
{ {
if (uuid.size() > QUuid().toString().length()) // create stroke group if (uuid.size() > QUuid().toString().length()) // create stroke group
{ {
currentStrokeIdentifier = uuid.left(QUuid().toString().length()); currentStrokeIdentifier = uuid.left(QUuid().toString().length()-1);
UBGraphicsPolygonItem *strokeByUuid = qgraphicsitem_cast<UBGraphicsPolygonItem *>(mCurrentScene->itemForUuid(QUuid(uuid.right(QUuid().toString().length())))); UBGraphicsPolygonItem *strokeByUuid = qgraphicsitem_cast<UBGraphicsPolygonItem *>(mCurrentScene->itemForUuid(QUuid(uuid.right(QUuid().toString().length()))));
if (strokeByUuid) if (strokeByUuid)
@ -1147,7 +1149,7 @@ UBGraphicsGroupContainerItem *UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbGro
foreach (QString key, strokesGroupsContainer.keys()) foreach (QString key, strokesGroupsContainer.keys().toSet())
{ {
UBGraphicsStrokesGroup* pStrokesGroup = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* pStrokesGroup = new UBGraphicsStrokesGroup();
UBGraphicsStroke *currentStroke = new UBGraphicsStroke(); UBGraphicsStroke *currentStroke = new UBGraphicsStroke();
@ -1164,13 +1166,17 @@ UBGraphicsGroupContainerItem *UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbGro
} }
if (currentStroke->polygons().empty()) if (currentStroke->polygons().empty())
delete currentStroke; delete currentStroke;
if (pStrokesGroup->childItems().count()) if (pStrokesGroup->childItems().count())
mCurrentScene->addItem(pStrokesGroup); mCurrentScene->addItem(pStrokesGroup);
else else
delete pStrokesGroup; delete pStrokesGroup;
if (pStrokesGroup) if (pStrokesGroup)
group->addToGroup(pStrokesGroup); {
QGraphicsItem *strokeGroup = qgraphicsitem_cast<QGraphicsItem *>(pStrokesGroup);
groupContainer.append(strokeGroup);
}
} }
foreach(QGraphicsItem* item, groupContainer) foreach(QGraphicsItem* item, groupContainer)
@ -1180,7 +1186,7 @@ UBGraphicsGroupContainerItem *UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbGro
{ {
mCurrentScene->addItem(group); mCurrentScene->addItem(group);
if (!groupContainer.count()) if (1 == group->childItems().count())
{ {
group->destroy(false); group->destroy(false);
} }

@ -1005,7 +1005,10 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup()
mXmlReader.readNext(); mXmlReader.readNext();
while (!mXmlReader.atEnd()) while (!mXmlReader.atEnd())
{ {
if (mXmlReader.isStartElement()) if (mXmlReader.isEndElement()) {
mXmlReader.readNext();
break;
} else if (mXmlReader.isStartElement())
{ {
if (mXmlReader.name() == tGroup) if (mXmlReader.name() == tGroup)
{ {
@ -1030,7 +1033,7 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup()
} }
else // item else // item
{ {
group->addToGroup(curItem); groupContainer.append(curItem);
} }
}else { }else {
mXmlReader.skipCurrentElement(); mXmlReader.skipCurrentElement();
@ -1040,8 +1043,7 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup()
} }
} }
foreach (QString key, strokesGroupsContainer.keys().toSet())
foreach (QString key, strokesGroupsContainer.keys())
{ {
UBGraphicsStrokesGroup* pStrokesGroup = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* pStrokesGroup = new UBGraphicsStrokesGroup();
UBGraphicsStroke *currentStroke = new UBGraphicsStroke(); UBGraphicsStroke *currentStroke = new UBGraphicsStroke();
@ -1058,13 +1060,17 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup()
} }
if (currentStroke->polygons().empty()) if (currentStroke->polygons().empty())
delete currentStroke; delete currentStroke;
if (pStrokesGroup->childItems().count()) if (pStrokesGroup->childItems().count())
mScene->addItem(pStrokesGroup); mScene->addItem(pStrokesGroup);
else else
delete pStrokesGroup; delete pStrokesGroup;
if (pStrokesGroup) if (pStrokesGroup)
group->addToGroup(pStrokesGroup); {
QGraphicsItem *strokeGroup = qgraphicsitem_cast<QGraphicsItem *>(pStrokesGroup);
groupContainer.append(strokeGroup);
}
} }
foreach(QGraphicsItem* item, groupContainer) foreach(QGraphicsItem* item, groupContainer)
@ -1074,12 +1080,11 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup()
{ {
mScene->addItem(group); mScene->addItem(group);
if (!groupContainer.count()) if (1 == group->childItems().count())
{ {
group->destroy(false); group->destroy(false);
} }
} }
return group; return group;
} }

Loading…
Cancel
Save