diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index f73af725..2cc41325 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -1863,14 +1863,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::pixmapItemToLinkedImage(UBGraphicsPi QString path = mDocumentPath + "/" + fileName; - if (!QFile::exists(path)) - { - QDir dir; - dir.mkdir(mDocumentPath + "/" + UBPersistenceManager::imageDirectory); - - pixmapItem->pixmap().toImage().save(path, "PNG"); - } - mXmlWriter.writeAttribute(nsXLink, "href", fileName); graphicsItemToSvg(pixmapItem); @@ -1910,25 +1902,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::svgItemToLinkedSvg(UBGraphicsSvgItem mXmlWriter.writeStartElement("image"); - QString fileName = UBPersistenceManager::imageDirectory + "/" + svgItem->uuid().toString() + ".svg"; - - QString path = mDocumentPath + "/" + fileName; - - if (!QFile::exists(path)) - { - QDir dir; - dir.mkdir(mDocumentPath + "/" + UBPersistenceManager::imageDirectory); - - QFile file(path); - if (!file.open(QIODevice::WriteOnly)) - { - qWarning() << "cannot open file for writing embeded svg content " << path; - return; - } - - file.write(svgItem->fileData()); - } - mXmlWriter.writeAttribute(nsXLink, "href", fileName); graphicsItemToSvg(svgItem); @@ -1984,6 +1957,7 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::pdfItemToLinkedPDF(UBGraphicsPDFItem } file.write(pdfItem->fileData()); + file.close(); } mXmlWriter.writeAttribute(nsXLink, "href", fileName + "#page=" + QString::number(pdfItem->pageNumber())); @@ -2344,11 +2318,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::graphicsWidgetToSvg(UBGraphicsWidget mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "frozen", xmlTrue); } - -// QString snapshotPath = mDocumentPath + "/" + UBPersistenceManager::widgetDirectory + "/" + uuid + ".png"; -// item->takeSnapshot().save(snapshotPath, "PNG"); - - mXmlWriter.writeStartElement(nsXHtml, "iframe"); mXmlWriter.writeAttribute("style", "border: none"); diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index d9f6b8d3..b33427a9 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -1105,6 +1105,21 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl UBGraphicsPixmapItem* pixItem = mActiveScene->addPixmap(pix, NULL, pPos, 1.); pixItem->setSourceUrl(sourceUrl); + QString documentPath = UBApplication::boardController->selectedDocument()->persistencePath(); + + QString fileName = UBPersistenceManager::imageDirectory + "/" + pixItem->uuid().toString() + ".png"; + + QString path = documentPath + "/" + fileName; + + if (!QFile::exists(path)) + { + QDir dir; + dir.mkdir(documentPath + "/" + UBPersistenceManager::imageDirectory); + + pixItem->pixmap().toImage().save(path, "PNG"); + } + + if (isBackground) { mActiveScene->setAsBackgroundObject(pixItem, true); @@ -1123,6 +1138,29 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl qDebug() << "accepting mime type" << mimeType << "as vecto image"; UBGraphicsSvgItem* svgItem = mActiveScene->addSvg(sourceUrl, pPos, pData); + + QString documentPath = UBApplication::boardController->selectedDocument()->persistencePath(); + + QString fileName = UBPersistenceManager::imageDirectory + "/" + svgItem->uuid().toString() + ".svg"; + + QString path = documentPath + "/" + fileName; + + if (!QFile::exists(path)) + { + QDir dir; + dir.mkdir(documentPath + "/" + UBPersistenceManager::imageDirectory); + + QFile file(path); + if (!file.open(QIODevice::WriteOnly)) + { + qWarning() << "cannot open file for writing embeded svg content " << path; + return; + } + + file.write(svgItem->fileData()); + file.close(); + } + svgItem->setSourceUrl(sourceUrl); if (isBackground)