diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index 3bc20888..315852ed 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -62,6 +62,7 @@ #include "core/UBSetting.h" #include "core/UBPersistenceManager.h" #include "core/UBApplication.h" +#include "core/UBTextTools.h" #include "document/UBDocumentContainer.h" @@ -301,7 +302,7 @@ QUuid UBSvgSubsetAdaptor::sceneUuid(UBDocumentProxy* proxy, const int pageIndex) UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const QByteArray& pArray) { - UBSvgSubsetReader reader(proxy, pArray); + UBSvgSubsetReader reader(proxy, UBTextTools::cleanHtmlCData(QString(pArray)).toAscii()); return reader.loadScene(); } @@ -2457,7 +2458,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::textItemToSvg(UBGraphicsTextItem* it // Note: don't use mXmlWriter.writeCDATA(htmlString); because it doesn't escape characters sequences correctly. // Texts copied from other programs like Open-Office can truncate the svg file. - mXmlWriter.writeCharacters(item->toHtml()); + //mXmlWriter.writeCharacters(item->toHtml()); + mXmlWriter.writeCharacters(UBTextTools::cleanHtmlCData(item->toHtml())); mXmlWriter.writeEndElement(); //itemTextContent mXmlWriter.writeEndElement(); //foreignObject diff --git a/src/core/core.pri b/src/core/core.pri index ea545157..12d752f3 100644 --- a/src/core/core.pri +++ b/src/core/core.pri @@ -13,7 +13,8 @@ HEADERS += src/core/UB.h \ src/core/UBApplicationController.h \ src/core/UBDownloadManager.h \ src/core/UBDownloadThread.h \ - src/core/UBOpenSankoreImporter.h + src/core/UBOpenSankoreImporter.h \ + src/core/UBTextTools.h SOURCES += src/core/main.cpp \ src/core/UBApplication.cpp \ @@ -29,6 +30,7 @@ SOURCES += src/core/main.cpp \ src/core/UBApplicationController.cpp \ src/core/UBDownloadManager.cpp \ src/core/UBDownloadThread.cpp \ - src/core/UBOpenSankoreImporter.cpp + src/core/UBOpenSankoreImporter.cpp \ + src/core/UBTextTools.cpp diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index e72d2b64..e80a8561 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -36,6 +36,7 @@ #include "core/UBApplicationController.h" #include "core/UBDisplayManager.h" #include "core/UBPersistenceManager.h" +#include "core/UBTextTools.h" #include "gui/UBMagnifer.h" #include "gui/UBMainWindow.h" @@ -1629,7 +1630,7 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q { UBGraphicsTextItem *textItem = new UBGraphicsTextItem(); textItem->setPlainText(""); - textItem->setHtml(pString); + textItem->setHtml(UBTextTools::cleanHtml(pString)); addItem(textItem); textItem->show();