|
|
|
@ -1041,162 +1041,153 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() |
|
|
|
|
openStroke = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsGroupContainerItem *groupItem = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item); |
|
|
|
|
UBGraphicsPixmapItem *pixmapItem = qgraphicsitem_cast<UBGraphicsPixmapItem*> (item); |
|
|
|
|
|
|
|
|
|
if (groupItem && groupItem->isVisible()) |
|
|
|
|
if (pixmapItem && pixmapItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
qDebug() << "came across the group during the parsing"; |
|
|
|
|
pixmapItemToLinkedImage(pixmapItem); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
parseCommonItems(item); |
|
|
|
|
} |
|
|
|
|
UBGraphicsSvgItem *svgItem = qgraphicsitem_cast<UBGraphicsSvgItem*> (item); |
|
|
|
|
|
|
|
|
|
if (openStroke) |
|
|
|
|
{ |
|
|
|
|
mXmlWriter.writeEndElement(); |
|
|
|
|
groupHoldsInfo = false; |
|
|
|
|
openStroke = 0; |
|
|
|
|
} |
|
|
|
|
if (svgItem && svgItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
svgItemToLinkedSvg(svgItem); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mXmlWriter.writeEndDocument(); |
|
|
|
|
QString fileName = mDocumentPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", mPageIndex + 1); |
|
|
|
|
QFile file(fileName); |
|
|
|
|
UBGraphicsVideoItem *videoItem = qgraphicsitem_cast<UBGraphicsVideoItem*> (item); |
|
|
|
|
|
|
|
|
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) |
|
|
|
|
{ |
|
|
|
|
qCritical() << "cannot open " << fileName << " for writing ..."; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
file.write(buffer.data()); |
|
|
|
|
file.flush(); |
|
|
|
|
file.close(); |
|
|
|
|
if (videoItem && videoItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
videoItemToLinkedVideo(videoItem); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
qDebug() << "ignoring unmodified page" << mPageIndex + 1; |
|
|
|
|
} |
|
|
|
|
UBGraphicsAudioItem* audioItem = qgraphicsitem_cast<UBGraphicsAudioItem*> (item); |
|
|
|
|
if (audioItem && audioItem->isVisible()) { |
|
|
|
|
audioItemToLinkedAudio(audioItem); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
UBGraphicsAppleWidgetItem *appleWidgetItem = qgraphicsitem_cast<UBGraphicsAppleWidgetItem*> (item); |
|
|
|
|
|
|
|
|
|
bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item) |
|
|
|
|
{ |
|
|
|
|
UBGraphicsPixmapItem *pixmapItem = qgraphicsitem_cast<UBGraphicsPixmapItem*> (item); |
|
|
|
|
if (appleWidgetItem && appleWidgetItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
graphicsAppleWidgetToSvg(appleWidgetItem); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (pixmapItem && pixmapItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
pixmapItemToLinkedImage(pixmapItem); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
UBGraphicsW3CWidgetItem *w3cWidgetItem = qgraphicsitem_cast<UBGraphicsW3CWidgetItem*> (item); |
|
|
|
|
|
|
|
|
|
UBGraphicsSvgItem *svgItem = qgraphicsitem_cast<UBGraphicsSvgItem*> (item); |
|
|
|
|
if (w3cWidgetItem && w3cWidgetItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
graphicsW3CWidgetToSvg(w3cWidgetItem); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (svgItem && svgItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
svgItemToLinkedSvg(svgItem); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*> (item); |
|
|
|
|
|
|
|
|
|
UBGraphicsVideoItem *videoItem = qgraphicsitem_cast<UBGraphicsVideoItem*> (item); |
|
|
|
|
if (pdfItem && pdfItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
pdfItemToLinkedPDF(pdfItem); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (videoItem && videoItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
videoItemToLinkedVideo(videoItem); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
UBGraphicsTextItem *textItem = qgraphicsitem_cast<UBGraphicsTextItem*> (item); |
|
|
|
|
|
|
|
|
|
UBGraphicsAudioItem* audioItem = qgraphicsitem_cast<UBGraphicsAudioItem*> (item); |
|
|
|
|
if (audioItem && audioItem->isVisible()) { |
|
|
|
|
audioItemToLinkedAudio(audioItem); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (textItem && textItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
textItemToSvg(textItem); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsAppleWidgetItem *appleWidgetItem = qgraphicsitem_cast<UBGraphicsAppleWidgetItem*> (item); |
|
|
|
|
UBGraphicsCurtainItem *curtainItem = qgraphicsitem_cast<UBGraphicsCurtainItem*> (item); |
|
|
|
|
|
|
|
|
|
if (appleWidgetItem && appleWidgetItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
graphicsAppleWidgetToSvg(appleWidgetItem); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (curtainItem && curtainItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
curtainItemToSvg(curtainItem); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsW3CWidgetItem *w3cWidgetItem = qgraphicsitem_cast<UBGraphicsW3CWidgetItem*> (item); |
|
|
|
|
UBGraphicsRuler *ruler = qgraphicsitem_cast<UBGraphicsRuler*> (item); |
|
|
|
|
|
|
|
|
|
if (w3cWidgetItem && w3cWidgetItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
graphicsW3CWidgetToSvg(w3cWidgetItem); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (ruler && ruler->isVisible()) |
|
|
|
|
{ |
|
|
|
|
rulerToSvg(ruler); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast<UBGraphicsPDFItem*> (item); |
|
|
|
|
UBGraphicsCache* cache = qgraphicsitem_cast<UBGraphicsCache*>(item); |
|
|
|
|
if(cache && cache->isVisible()) |
|
|
|
|
{ |
|
|
|
|
cacheToSvg(cache); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (pdfItem && pdfItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
pdfItemToLinkedPDF(pdfItem); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
UBGraphicsCompass *compass = qgraphicsitem_cast<UBGraphicsCompass*> (item); |
|
|
|
|
|
|
|
|
|
UBGraphicsTextItem *textItem = qgraphicsitem_cast<UBGraphicsTextItem*> (item); |
|
|
|
|
if (compass && compass->isVisible()) |
|
|
|
|
{ |
|
|
|
|
compassToSvg(compass); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (textItem && textItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
textItemToSvg(textItem); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
UBGraphicsProtractor *protractor = qgraphicsitem_cast<UBGraphicsProtractor*> (item); |
|
|
|
|
|
|
|
|
|
UBGraphicsCurtainItem *curtainItem = qgraphicsitem_cast<UBGraphicsCurtainItem*> (item); |
|
|
|
|
if (protractor && protractor->isVisible()) |
|
|
|
|
{ |
|
|
|
|
protractorToSvg(protractor); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (curtainItem && curtainItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
curtainItemToSvg(curtainItem); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
UBGraphicsTriangle *triangle = qgraphicsitem_cast<UBGraphicsTriangle*> (item); |
|
|
|
|
|
|
|
|
|
UBGraphicsRuler *ruler = qgraphicsitem_cast<UBGraphicsRuler*> (item); |
|
|
|
|
if (triangle && triangle->isVisible()) |
|
|
|
|
{ |
|
|
|
|
triangleToSvg(triangle); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ruler && ruler->isVisible()) |
|
|
|
|
{ |
|
|
|
|
rulerToSvg(ruler); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
UBGraphicsGroupContainerItem *groupItem = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item); |
|
|
|
|
|
|
|
|
|
UBGraphicsCache* cache = qgraphicsitem_cast<UBGraphicsCache*>(item); |
|
|
|
|
if(cache && cache->isVisible()) |
|
|
|
|
{ |
|
|
|
|
cacheToSvg(cache); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (groupItem && groupItem->isVisible()) |
|
|
|
|
{ |
|
|
|
|
qDebug() << "came across the group during the parsing"; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsCompass *compass = qgraphicsitem_cast<UBGraphicsCompass*> (item); |
|
|
|
|
if (openStroke) |
|
|
|
|
{ |
|
|
|
|
mXmlWriter.writeEndElement(); |
|
|
|
|
groupHoldsInfo = false; |
|
|
|
|
openStroke = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (compass && compass->isVisible()) |
|
|
|
|
{ |
|
|
|
|
compassToSvg(compass); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
mXmlWriter.writeEndDocument(); |
|
|
|
|
QString fileName = mDocumentPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", mPageIndex + 1); |
|
|
|
|
QFile file(fileName); |
|
|
|
|
|
|
|
|
|
UBGraphicsProtractor *protractor = qgraphicsitem_cast<UBGraphicsProtractor*> (item); |
|
|
|
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) |
|
|
|
|
{ |
|
|
|
|
qCritical() << "cannot open " << fileName << " for writing ..."; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
file.write(buffer.data()); |
|
|
|
|
file.flush(); |
|
|
|
|
file.close(); |
|
|
|
|
|
|
|
|
|
if (protractor && protractor->isVisible()) |
|
|
|
|
{ |
|
|
|
|
protractorToSvg(protractor); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UBGraphicsTriangle *triangle = qgraphicsitem_cast<UBGraphicsTriangle*> (item); |
|
|
|
|
|
|
|
|
|
if (triangle && triangle->isVisible()) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
triangleToSvg(triangle); |
|
|
|
|
return true; |
|
|
|
|
qDebug() << "ignoring unmodified page" << mPageIndex + 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgLine(UBGraphicsPolygonItem* polygonItem, bool groupHoldsInfo) |
|
|
|
|
{ |
|
|
|
|
mXmlWriter.writeStartElement("line"); |
|
|
|
|