diff --git a/plugins/cffadaptor/src/UBCFFAdaptor.cpp b/plugins/cffadaptor/src/UBCFFAdaptor.cpp index 106d2457..f5c84068 100644 --- a/plugins/cffadaptor/src/UBCFFAdaptor.cpp +++ b/plugins/cffadaptor/src/UBCFFAdaptor.cpp @@ -1277,7 +1277,13 @@ bool UBCFFAdaptor::UBToCFFConverter::setCFFAttribute(const QString &attributeNam 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); } else diff --git a/src/adaptors/UBCFFSubsetAdaptor.cpp b/src/adaptors/UBCFFSubsetAdaptor.cpp index e0584b4d..d06c95a7 100644 --- a/src/adaptors/UBCFFSubsetAdaptor.cpp +++ b/src/adaptors/UBCFFSubsetAdaptor.cpp @@ -249,7 +249,11 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgRect(const QDomElement &elem painter.end(); 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; QString textTransform = element.attribute(aTransform); @@ -300,7 +304,11 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgEllipse(const QDomElement &e painter.end(); 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; QString textTransform = element.attribute(aTransform); @@ -395,6 +403,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e mCurrentScene->addItem(graphicsPolygon); graphicsPolygon->setUuid(itemUuid); + mRefToUuidMap.insert(element.attribute(aId), itemUuid); } else // single CFF @@ -415,7 +424,11 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolygon(const QDomElement &e UBGraphicsSvgItem *svgItem = mCurrentScene->addSvg(QUrl::fromLocalFile(generator->fileName())); QTransform transform; 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(); if (!textTransform.isNull()) { transform = transformFromString(textTransform, svgItem); @@ -508,6 +521,9 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement & } mCurrentScene->addItem(graphicsPolygon); + graphicsPolygon->setUuid(itemUuid); + mRefToUuidMap.insert(element.attribute(aId), itemUuid); + } else // simple CFF { @@ -525,7 +541,11 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgPolyline(const QDomElement & //add resulting svg file to scene 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; QString textTransform = element.attribute(aTransform); @@ -678,6 +698,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgText(const QDomElement &elem //add resulting svg file to scene 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(); repositionSvgItem(svgItem, width, height, x + transform.m31(), y + transform.m32(), transform); hashSceneItem(element, svgItem); @@ -791,6 +815,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgTextarea(const QDomElement & UBGraphicsTextItem *svgItem = mCurrentScene->addTextHtml(doc.toHtml()); svgItem->resize(width, height); + QString uuid = QUuid::createUuid().toString(); + mRefToUuidMap.insert(element.attribute(aId), uuid); + svgItem->setUuid(QUuid(uuid)); + QTransform transform; QString textTransform = element.attribute(aTransform); @@ -840,6 +868,11 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgImage(const QDomElement &ele } UBGraphicsPixmapItem *pixItem = mCurrentScene->addPixmap(pix, NULL); + + QString uuid = QUuid::createUuid().toString(); + mRefToUuidMap.insert(element.attribute(aId), uuid); + pixItem->setUuid(QUuid(uuid)); + QTransform transform; QString textTransform = element.attribute(aTransform); @@ -887,6 +920,10 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgFlash(const QDomElement &ele UBGraphicsWidgetItem *flashItem = mCurrentScene->addW3CWidget(QUrl::fromLocalFile(flashUrl)); flashItem->setSourceUrl(urlPath); + QString uuid = QUuid::createUuid().toString(); + mRefToUuidMap.insert(element.attribute(aId), uuid); + flashItem->setUuid(QUuid(uuid)); + QTransform transform; QString textTransform = element.attribute(aTransform); @@ -924,14 +961,15 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgAudio(const QDomElement &ele concreteUrl = QUrl::fromLocalFile(audioPath); } - QUuid uuid = QUuid::createUuid(); + QString uuid = QUuid::createUuid().toString(); + mRefToUuidMap.insert(element.attribute(aId), uuid); QString destFile; bool b = UBPersistenceManager::persistenceManager()->addFileToDocument( mCurrentScene->document(), concreteUrl.toLocalFile(), UBPersistenceManager::audioDirectory, - uuid, + QUuid(uuid), destFile); if (!b) { @@ -940,6 +978,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgAudio(const QDomElement &ele concreteUrl = QUrl::fromLocalFile(destFile); UBGraphicsMediaItem *audioItem = mCurrentScene->addAudio(concreteUrl, false); + QTransform transform; QString textTransform = parentOfAudio.attribute(aTransform); @@ -977,15 +1016,15 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgVideo(const QDomElement &ele concreteUrl = QUrl::fromLocalFile(videoPath); } - QUuid uuid = QUuid::createUuid(); - + QString uuid = QUuid::createUuid().toString(); + mRefToUuidMap.insert(element.attribute(aId), uuid); QString destFile; bool b = UBPersistenceManager::persistenceManager()->addFileToDocument( mCurrentScene->document(), concreteUrl.toLocalFile(), UBPersistenceManager::videoDirectory, - uuid, + QUuid(uuid), destFile); if (!b) { @@ -994,6 +1033,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgVideo(const QDomElement &ele concreteUrl = QUrl::fromLocalFile(destFile); UBGraphicsMediaItem *videoItem = mCurrentScene->addVideo(concreteUrl, false); + QTransform transform; QString textTransform = element.attribute(aTransform); @@ -1129,13 +1169,15 @@ UBGraphicsGroupContainerItem *UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbGro group->addToGroup(parseIwbGroup(currentStrokeElement)); else { - QString uuid = currentStrokeElement.attribute(aRef); + + QString ref = currentStrokeElement.attribute(aRef); + QString uuid = mRefToUuidMap[ref]; 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); - UBGraphicsPolygonItem *strokeByUuid = qgraphicsitem_cast(mCurrentScene->itemForUuid(QUuid(uuid.right(QUuid().toString().length())))); + currentStrokeIdentifier = ref.left(QUuid().toString().length()-1); + UBGraphicsPolygonItem *strokeByUuid = qgraphicsitem_cast(mCurrentScene->itemForUuid(QUuid(ref.right(QUuid().toString().length())))); if (strokeByUuid) strokesGroupsContainer.insert(currentStrokeIdentifier, strokeByUuid); diff --git a/src/adaptors/UBCFFSubsetAdaptor.h b/src/adaptors/UBCFFSubsetAdaptor.h index ca389a49..3a6f89a6 100644 --- a/src/adaptors/UBCFFSubsetAdaptor.h +++ b/src/adaptors/UBCFFSubsetAdaptor.h @@ -74,6 +74,7 @@ private: QDomDocument mDOMdoc; QDomNode mCurrentDOMElement; QHash persistedItems; + QMap mRefToUuidMap; QDir mTmpFlashDir; void addItemToGSection(QGraphicsItem *item); diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 8f0efe67..17e25564 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -1015,7 +1015,7 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup() qDebug() << "came across the group id is" << mXmlReader.attributes().value(aId); UBGraphicsGroupContainerItem *curGroup = readGroup(); if (curGroup) - group->addToGroup(curGroup); + groupContainer.append(curGroup); } else if (mXmlReader.name() == tElement) {