Fixed export images to CFF.

Added UUIDs for each imported item.
Supported groups.
preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent ae900677bd
commit b49a01d981
  1. 8
      plugins/cffadaptor/src/UBCFFAdaptor.cpp
  2. 68
      src/adaptors/UBCFFSubsetAdaptor.cpp
  3. 1
      src/adaptors/UBCFFSubsetAdaptor.h
  4. 2
      src/adaptors/UBSvgSubsetAdaptor.cpp

@ -1277,7 +1277,13 @@ bool UBCFFAdaptor::UBToCFFConverter::setCFFAttribute(const QString &attributeNam
if (attributeName.contains(aUBZUuid)) if (attributeName.contains(aUBZUuid))
{ {
QString id = "{" +ubzElement.attribute(aUBZParent)+"}" + "{"+ubzElement.attribute(aUBZUuid)+"}"; QString parentId = ubzElement.attribute(aUBZParent);
QString id;
if (!parentId.isEmpty())
id = "{" + parentId + "}" + "{" + ubzElement.attribute(aUBZUuid)+"}";
else
id = "{" + ubzElement.attribute(aUBZUuid)+"}";
svgElement.setAttribute(aID, id); svgElement.setAttribute(aID, id);
} }
else else

@ -249,7 +249,11 @@ 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());
QString uuid = QUuid::createUuid().toString();
mRefToUuidMap.insert(element.attribute(aId), uuid);
svgItem->setUuid(QUuid(uuid));
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
@ -300,7 +304,11 @@ 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());
QString uuid = QUuid::createUuid().toString();
mRefToUuidMap.insert(element.attribute(aId), uuid);
svgItem->setUuid(QUuid(uuid));
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
@ -395,6 +403,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e
mCurrentScene->addItem(graphicsPolygon); mCurrentScene->addItem(graphicsPolygon);
graphicsPolygon->setUuid(itemUuid); graphicsPolygon->setUuid(itemUuid);
mRefToUuidMap.insert(element.attribute(aId), itemUuid);
} }
else // single CFF else // single CFF
@ -415,7 +424,11 @@ 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());
QUuid uuid = QUuid::createUuid().toString();
mRefToUuidMap.insert(element.attribute(aId), uuid);
svgItem->setUuid(uuid);
svgItem->resetTransform(); svgItem->resetTransform();
if (!textTransform.isNull()) { if (!textTransform.isNull()) {
transform = transformFromString(textTransform, svgItem); transform = transformFromString(textTransform, svgItem);
@ -508,6 +521,9 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement &
} }
mCurrentScene->addItem(graphicsPolygon); mCurrentScene->addItem(graphicsPolygon);
graphicsPolygon->setUuid(itemUuid);
mRefToUuidMap.insert(element.attribute(aId), itemUuid);
} }
else // simple CFF else // simple CFF
{ {
@ -525,7 +541,11 @@ 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());
QString uuid = QUuid::createUuid().toString();
mRefToUuidMap.insert(element.attribute(aId), uuid);
svgItem->setUuid(QUuid(uuid));
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
@ -678,6 +698,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgText(const QDomElement &elem
//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()));
QString uuid = QUuid::createUuid().toString();
mRefToUuidMap.insert(element.attribute(aId), uuid);
svgItem->setUuid(QUuid(uuid));
svgItem->resetTransform(); svgItem->resetTransform();
repositionSvgItem(svgItem, width, height, x + transform.m31(), y + transform.m32(), transform); repositionSvgItem(svgItem, width, height, x + transform.m31(), y + transform.m32(), transform);
hashSceneItem(element, svgItem); hashSceneItem(element, svgItem);
@ -791,6 +815,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgTextarea(const QDomElement &
UBGraphicsTextItem *svgItem = mCurrentScene->addTextHtml(doc.toHtml()); UBGraphicsTextItem *svgItem = mCurrentScene->addTextHtml(doc.toHtml());
svgItem->resize(width, height); svgItem->resize(width, height);
QString uuid = QUuid::createUuid().toString();
mRefToUuidMap.insert(element.attribute(aId), uuid);
svgItem->setUuid(QUuid(uuid));
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
@ -840,6 +868,11 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgImage(const QDomElement &ele
} }
UBGraphicsPixmapItem *pixItem = mCurrentScene->addPixmap(pix, NULL); UBGraphicsPixmapItem *pixItem = mCurrentScene->addPixmap(pix, NULL);
QString uuid = QUuid::createUuid().toString();
mRefToUuidMap.insert(element.attribute(aId), uuid);
pixItem->setUuid(QUuid(uuid));
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
@ -887,6 +920,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgFlash(const QDomElement &ele
UBGraphicsWidgetItem *flashItem = mCurrentScene->addW3CWidget(QUrl::fromLocalFile(flashUrl)); UBGraphicsWidgetItem *flashItem = mCurrentScene->addW3CWidget(QUrl::fromLocalFile(flashUrl));
flashItem->setSourceUrl(urlPath); flashItem->setSourceUrl(urlPath);
QString uuid = QUuid::createUuid().toString();
mRefToUuidMap.insert(element.attribute(aId), uuid);
flashItem->setUuid(QUuid(uuid));
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
@ -924,14 +961,15 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgAudio(const QDomElement &ele
concreteUrl = QUrl::fromLocalFile(audioPath); concreteUrl = QUrl::fromLocalFile(audioPath);
} }
QUuid uuid = QUuid::createUuid(); QString uuid = QUuid::createUuid().toString();
mRefToUuidMap.insert(element.attribute(aId), uuid);
QString destFile; QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument( bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(
mCurrentScene->document(), mCurrentScene->document(),
concreteUrl.toLocalFile(), concreteUrl.toLocalFile(),
UBPersistenceManager::audioDirectory, UBPersistenceManager::audioDirectory,
uuid, QUuid(uuid),
destFile); destFile);
if (!b) if (!b)
{ {
@ -940,6 +978,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgAudio(const QDomElement &ele
concreteUrl = QUrl::fromLocalFile(destFile); concreteUrl = QUrl::fromLocalFile(destFile);
UBGraphicsMediaItem *audioItem = mCurrentScene->addAudio(concreteUrl, false); UBGraphicsMediaItem *audioItem = mCurrentScene->addAudio(concreteUrl, false);
QTransform transform; QTransform transform;
QString textTransform = parentOfAudio.attribute(aTransform); QString textTransform = parentOfAudio.attribute(aTransform);
@ -977,15 +1016,15 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgVideo(const QDomElement &ele
concreteUrl = QUrl::fromLocalFile(videoPath); concreteUrl = QUrl::fromLocalFile(videoPath);
} }
QUuid uuid = QUuid::createUuid(); QString uuid = QUuid::createUuid().toString();
mRefToUuidMap.insert(element.attribute(aId), uuid);
QString destFile; QString destFile;
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument( bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(
mCurrentScene->document(), mCurrentScene->document(),
concreteUrl.toLocalFile(), concreteUrl.toLocalFile(),
UBPersistenceManager::videoDirectory, UBPersistenceManager::videoDirectory,
uuid, QUuid(uuid),
destFile); destFile);
if (!b) if (!b)
{ {
@ -994,6 +1033,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgVideo(const QDomElement &ele
concreteUrl = QUrl::fromLocalFile(destFile); concreteUrl = QUrl::fromLocalFile(destFile);
UBGraphicsMediaItem *videoItem = mCurrentScene->addVideo(concreteUrl, false); UBGraphicsMediaItem *videoItem = mCurrentScene->addVideo(concreteUrl, false);
QTransform transform; QTransform transform;
QString textTransform = element.attribute(aTransform); QString textTransform = element.attribute(aTransform);
@ -1129,13 +1169,15 @@ UBGraphicsGroupContainerItem *UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbGro
group->addToGroup(parseIwbGroup(currentStrokeElement)); group->addToGroup(parseIwbGroup(currentStrokeElement));
else else
{ {
QString uuid = currentStrokeElement.attribute(aRef);
QString ref = currentStrokeElement.attribute(aRef);
QString uuid = mRefToUuidMap[ref];
if (!uuid.isEmpty()) if (!uuid.isEmpty())
{ {
if (uuid.size() > QUuid().toString().length()) // create stroke group if (ref.size() > QUuid().toString().length()) // create stroke group
{ {
currentStrokeIdentifier = uuid.left(QUuid().toString().length()-1); currentStrokeIdentifier = ref.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(ref.right(QUuid().toString().length()))));
if (strokeByUuid) if (strokeByUuid)
strokesGroupsContainer.insert(currentStrokeIdentifier, strokeByUuid); strokesGroupsContainer.insert(currentStrokeIdentifier, strokeByUuid);

@ -74,6 +74,7 @@ private:
QDomDocument mDOMdoc; QDomDocument mDOMdoc;
QDomNode mCurrentDOMElement; QDomNode mCurrentDOMElement;
QHash<QString, UBGraphicsItem*> persistedItems; QHash<QString, UBGraphicsItem*> persistedItems;
QMap<QString, QString> mRefToUuidMap;
QDir mTmpFlashDir; QDir mTmpFlashDir;
void addItemToGSection(QGraphicsItem *item); void addItemToGSection(QGraphicsItem *item);

@ -1015,7 +1015,7 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup()
qDebug() << "came across the group id is" << mXmlReader.attributes().value(aId); qDebug() << "came across the group id is" << mXmlReader.attributes().value(aId);
UBGraphicsGroupContainerItem *curGroup = readGroup(); UBGraphicsGroupContainerItem *curGroup = readGroup();
if (curGroup) if (curGroup)
group->addToGroup(curGroup); groupContainer.append(curGroup);
} }
else if (mXmlReader.name() == tElement) else if (mXmlReader.name() == tElement)
{ {

Loading…
Cancel
Save