From a77937cdfd47b9b0e450894e1af63b0099fac66f Mon Sep 17 00:00:00 2001 From: Ivan Ilyin Date: Fri, 11 May 2012 16:32:49 +0200 Subject: [PATCH] export ubz is as previous again --- src/adaptors/UBSvgSubsetAdaptor.cpp | 221 +++++++++++++-------------- src/adaptors/UBSvgSubsetAdaptor.h | 1 - src/domain/UBGraphicsPolygonItem.cpp | 16 +- src/domain/UBGraphicsPolygonItem.h | 2 +- 4 files changed, 115 insertions(+), 125 deletions(-) diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 417e835d..b7381aad 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -1041,162 +1041,153 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene() openStroke = 0; } - UBGraphicsGroupContainerItem *groupItem = qgraphicsitem_cast(item); + UBGraphicsPixmapItem *pixmapItem = qgraphicsitem_cast (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 (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 (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 (item); + if (audioItem && audioItem->isVisible()) { + audioItemToLinkedAudio(audioItem); + continue; + } - return true; -} + UBGraphicsAppleWidgetItem *appleWidgetItem = qgraphicsitem_cast (item); -bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::parseCommonItems(QGraphicsItem *item) -{ - UBGraphicsPixmapItem *pixmapItem = qgraphicsitem_cast (item); + if (appleWidgetItem && appleWidgetItem->isVisible()) + { + graphicsAppleWidgetToSvg(appleWidgetItem); + continue; + } - if (pixmapItem && pixmapItem->isVisible()) - { - pixmapItemToLinkedImage(pixmapItem); - return true; - } + UBGraphicsW3CWidgetItem *w3cWidgetItem = qgraphicsitem_cast (item); - UBGraphicsSvgItem *svgItem = qgraphicsitem_cast (item); + if (w3cWidgetItem && w3cWidgetItem->isVisible()) + { + graphicsW3CWidgetToSvg(w3cWidgetItem); + continue; + } - if (svgItem && svgItem->isVisible()) - { - svgItemToLinkedSvg(svgItem); - return true; - } + UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast (item); - UBGraphicsVideoItem *videoItem = qgraphicsitem_cast (item); + if (pdfItem && pdfItem->isVisible()) + { + pdfItemToLinkedPDF(pdfItem); + continue; + } - if (videoItem && videoItem->isVisible()) - { - videoItemToLinkedVideo(videoItem); - return true; - } + UBGraphicsTextItem *textItem = qgraphicsitem_cast (item); - UBGraphicsAudioItem* audioItem = qgraphicsitem_cast (item); - if (audioItem && audioItem->isVisible()) { - audioItemToLinkedAudio(audioItem); - return true; - } + if (textItem && textItem->isVisible()) + { + textItemToSvg(textItem); + continue; + } - UBGraphicsAppleWidgetItem *appleWidgetItem = qgraphicsitem_cast (item); + UBGraphicsCurtainItem *curtainItem = qgraphicsitem_cast (item); - if (appleWidgetItem && appleWidgetItem->isVisible()) - { - graphicsAppleWidgetToSvg(appleWidgetItem); - return true; - } + if (curtainItem && curtainItem->isVisible()) + { + curtainItemToSvg(curtainItem); + continue; + } - UBGraphicsW3CWidgetItem *w3cWidgetItem = qgraphicsitem_cast (item); + UBGraphicsRuler *ruler = qgraphicsitem_cast (item); - if (w3cWidgetItem && w3cWidgetItem->isVisible()) - { - graphicsW3CWidgetToSvg(w3cWidgetItem); - return true; - } + if (ruler && ruler->isVisible()) + { + rulerToSvg(ruler); + continue; + } - UBGraphicsPDFItem *pdfItem = qgraphicsitem_cast (item); + UBGraphicsCache* cache = qgraphicsitem_cast(item); + if(cache && cache->isVisible()) + { + cacheToSvg(cache); + continue; + } - if (pdfItem && pdfItem->isVisible()) - { - pdfItemToLinkedPDF(pdfItem); - return true; - } + UBGraphicsCompass *compass = qgraphicsitem_cast (item); - UBGraphicsTextItem *textItem = qgraphicsitem_cast (item); + if (compass && compass->isVisible()) + { + compassToSvg(compass); + continue; + } - if (textItem && textItem->isVisible()) - { - textItemToSvg(textItem); - return true; - } + UBGraphicsProtractor *protractor = qgraphicsitem_cast (item); - UBGraphicsCurtainItem *curtainItem = qgraphicsitem_cast (item); + if (protractor && protractor->isVisible()) + { + protractorToSvg(protractor); + continue; + } - if (curtainItem && curtainItem->isVisible()) - { - curtainItemToSvg(curtainItem); - return true; - } + UBGraphicsTriangle *triangle = qgraphicsitem_cast (item); - UBGraphicsRuler *ruler = qgraphicsitem_cast (item); + if (triangle && triangle->isVisible()) + { + triangleToSvg(triangle); + continue; + } - if (ruler && ruler->isVisible()) - { - rulerToSvg(ruler); - return true; - } + UBGraphicsGroupContainerItem *groupItem = qgraphicsitem_cast(item); - UBGraphicsCache* cache = qgraphicsitem_cast(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 (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 (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 (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"); diff --git a/src/adaptors/UBSvgSubsetAdaptor.h b/src/adaptors/UBSvgSubsetAdaptor.h index 6514cf20..188bba2f 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.h +++ b/src/adaptors/UBSvgSubsetAdaptor.h @@ -156,7 +156,6 @@ class UBSvgSubsetAdaptor UBSvgSubsetWriter(UBDocumentProxy* proxy, UBGraphicsScene* pScene, const int pageIndex); bool persistScene(); - bool parseCommonItems(QGraphicsItem *item); virtual ~UBSvgSubsetWriter(){} diff --git a/src/domain/UBGraphicsPolygonItem.cpp b/src/domain/UBGraphicsPolygonItem.cpp index 9c6dee10..1fc87f6a 100644 --- a/src/domain/UBGraphicsPolygonItem.cpp +++ b/src/domain/UBGraphicsPolygonItem.cpp @@ -189,18 +189,18 @@ void UBGraphicsPolygonItem::paint ( QPainter * painter, const QStyleOptionGraphi QGraphicsPolygonItem::paint(painter, option, widget); } -QPainterPath UBGraphicsPolygonItem::shape() const -{ +//QPainterPath UBGraphicsPolygonItem::shape() const +//{ - QPainterPath path; - path.addRect(boundingRect()); +// QPainterPath path; +// path.addRect(boundingRect()); - return path; +// return path; -// static QPainterPath shapePath = QGraphicsPolygonItem::shape(); +//// static QPainterPath shapePath = QGraphicsPolygonItem::shape(); -// return shapePath; -} +//// return shapePath; +//} UBGraphicsScene* UBGraphicsPolygonItem::scene() diff --git a/src/domain/UBGraphicsPolygonItem.h b/src/domain/UBGraphicsPolygonItem.h index 851092b2..663658f2 100644 --- a/src/domain/UBGraphicsPolygonItem.h +++ b/src/domain/UBGraphicsPolygonItem.h @@ -118,7 +118,7 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem protected: void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget); - QPainterPath shape () const; +// QPainterPath shape () const; private: