diff options
author | David Tardon <dtardon@redhat.com> | 2014-05-24 14:21:21 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-05-26 18:49:04 +0200 |
commit | 48c9d7ac7ccdad27067efe0d168e96ff48372631 (patch) | |
tree | 82b808b8c597046ed507aa6e2badd21090090190 /writerperfect/source/writer | |
parent | 2013d184f1cf5928fa4a919d1521c1ae7b053796 (diff) |
rebase all import libs
Change-Id: I9e1fc613816c943f4fb1033185e34e3acf317f1d
Diffstat (limited to 'writerperfect/source/writer')
11 files changed, 93 insertions, 65 deletions
diff --git a/writerperfect/source/writer/AbiWordImportFilter.cxx b/writerperfect/source/writer/AbiWordImportFilter.cxx index 034f2480ffc8..b8aa52442588 100644 --- a/writerperfect/source/writer/AbiWordImportFilter.cxx +++ b/writerperfect/source/writer/AbiWordImportFilter.cxx @@ -24,12 +24,12 @@ using com::sun::star::uno::RuntimeException; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool AbiWordImportFilter::doImportDocument( WPXInputStream &rInput, const rtl::OUString &, WPXDocumentInterface &rGenerator ) +bool AbiWordImportFilter::doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &, librevenge::RVNGTextInterface &rGenerator ) { return libabw::AbiDocument::parse(&rInput, &rGenerator); } -bool AbiWordImportFilter::doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) +bool AbiWordImportFilter::doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) { if (libabw::AbiDocument::isFileFormatSupported(&rInput)) { diff --git a/writerperfect/source/writer/AbiWordImportFilter.hxx b/writerperfect/source/writer/AbiWordImportFilter.hxx index c1a75d503046..6d81423d4d68 100644 --- a/writerperfect/source/writer/AbiWordImportFilter.hxx +++ b/writerperfect/source/writer/AbiWordImportFilter.hxx @@ -33,8 +33,8 @@ public: throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; private: - virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE; - virtual bool doImportDocument( WPXInputStream &rInput, const rtl::OUString &rFilterName, WPXDocumentInterface &rGenerator ) SAL_OVERRIDE; + virtual bool doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE; + virtual bool doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator ) SAL_OVERRIDE; }; OUString AbiWordImportFilter_getImplementationName() diff --git a/writerperfect/source/writer/EBookImportFilter.cxx b/writerperfect/source/writer/EBookImportFilter.cxx index 6c1434761ef1..300376895984 100644 --- a/writerperfect/source/writer/EBookImportFilter.cxx +++ b/writerperfect/source/writer/EBookImportFilter.cxx @@ -24,40 +24,58 @@ using com::sun::star::uno::Exception; using com::sun::star::uno::RuntimeException; using com::sun::star::uno::XComponentContext; -bool EBookImportFilter::doImportDocument( WPXInputStream &rInput, const rtl::OUString &rFilterName, WPXDocumentInterface &rGenerator ) +using libebook::EBOOKDocument; + +bool EBookImportFilter::doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator ) { if (rFilterName == "FictionBook 2") - return libebook::FB2Document::parse(&rInput, &rGenerator); + return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_FICTIONBOOK2); else if (rFilterName == "PalmDoc") - return libebook::PDBDocument::parse(&rInput, &rGenerator); + return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_PALMDOC); else if (rFilterName == "Plucker eBook") - return libebook::PLKRDocument::parse(&rInput, &rGenerator); + return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_PLUCKER); else if (rFilterName == "eReader eBook") - return libebook::PMLDocument::parse(&rInput, &rGenerator); + return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_PEANUTPRESS); else if (rFilterName == "TealDoc") - return libebook::TDDocument::parse(&rInput, &rGenerator); + return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_TEALDOC); else if (rFilterName == "zTXT") - return libebook::ZTXTDocument::parse(&rInput, &rGenerator); + return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_ZTXT); return false; } -bool EBookImportFilter::doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) +bool EBookImportFilter::doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) { rTypeName = ""; - if (libebook::FB2Document::isSupported(&rInput)) - rTypeName = "writer_FictionBook_2"; - else if (libebook::PDBDocument::isSupported(&rInput)) - rTypeName = "writer_PalmDoc"; - else if (libebook::PLKRDocument::isSupported(&rInput)) - rTypeName = "writer_Plucker_eBook"; - else if (libebook::PMLDocument::isSupported(&rInput)) - rTypeName = "writer_eReader_eBook"; - else if (libebook::TDDocument::isSupported(&rInput)) - rTypeName = "writer_TealDoc"; - else if (libebook::ZTXTDocument::isSupported(&rInput)) - rTypeName = "writer_zTXT"; + EBOOKDocument::Type type = EBOOKDocument::TYPE_UNKNOWN; + + if (EBOOKDocument::CONFIDENCE_EXCELLENT == EBOOKDocument::isSupported(&rInput, &type)) + { + switch (type) + { + case EBOOKDocument::TYPE_FICTIONBOOK2 : + rTypeName = "writer_FictionBook_2"; + break; + case EBOOKDocument::TYPE_PALMDOC : + rTypeName = "writer_PalmDoc"; + break; + case EBOOKDocument::TYPE_PLUCKER : + rTypeName = "writer_Plucker_eBook"; + break; + case EBOOKDocument::TYPE_PEANUTPRESS : + rTypeName = "writer_eReader_eBook"; + break; + case EBOOKDocument::TYPE_TEALDOC : + rTypeName = "writer_TealDoc"; + break; + case EBOOKDocument::TYPE_ZTXT : + rTypeName = "writer_zTXT"; + break; + default : + SAL_WARN_IF(type != EBOOKDocument::TYPE_UNKNOWN, "writerperfect", "EBookImportFilter::doDetectFormat: document type " << type << " detected, but ignored"); + } + } return !rTypeName.isEmpty(); } diff --git a/writerperfect/source/writer/EBookImportFilter.hxx b/writerperfect/source/writer/EBookImportFilter.hxx index 693ce31280af..0365fd7d4000 100644 --- a/writerperfect/source/writer/EBookImportFilter.hxx +++ b/writerperfect/source/writer/EBookImportFilter.hxx @@ -33,8 +33,8 @@ public: throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; private: - virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE; - virtual bool doImportDocument( WPXInputStream &rInput, const rtl::OUString &rFilterName, WPXDocumentInterface &rGenerator ) SAL_OVERRIDE; + virtual bool doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE; + virtual bool doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator ) SAL_OVERRIDE; }; OUString EBookImportFilter_getImplementationName() diff --git a/writerperfect/source/writer/ImportFilterBase.cxx b/writerperfect/source/writer/ImportFilterBase.cxx index 59bc8ef0844e..9f1ecc5383ee 100644 --- a/writerperfect/source/writer/ImportFilterBase.cxx +++ b/writerperfect/source/writer/ImportFilterBase.cxx @@ -93,7 +93,8 @@ throw (RuntimeException, std::exception) WPXSvInputStream input( xInputStream ); - OdtGenerator exporter(&xHandler, ODF_FLAT_XML); + OdtGenerator exporter; + exporter.addDocumentHandler(&xHandler, ODF_FLAT_XML); doRegisterHandlers(exporter); diff --git a/writerperfect/source/writer/ImportFilterBase.hxx b/writerperfect/source/writer/ImportFilterBase.hxx index 90dc4e2dd9f1..b54af430f979 100644 --- a/writerperfect/source/writer/ImportFilterBase.hxx +++ b/writerperfect/source/writer/ImportFilterBase.hxx @@ -10,8 +10,8 @@ #include <libodfgen/libodfgen.hxx> -#include <libwpd/libwpd.h> -#include <libwpd-stream/libwpd-stream.h> +#include <librevenge/librevenge.h> +#include <librevenge-stream/librevenge-stream.h> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> @@ -79,8 +79,8 @@ public: throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; private: - virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) = 0; - virtual bool doImportDocument( WPXInputStream &rInput, const rtl::OUString &rFilterName, WPXDocumentInterface &rGenerator ) = 0; + virtual bool doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) = 0; + virtual bool doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator ) = 0; virtual void doRegisterHandlers( OdtGenerator &rGenerator ); private: diff --git a/writerperfect/source/writer/MSWorksImportFilter.cxx b/writerperfect/source/writer/MSWorksImportFilter.cxx index 7aef8e983ecd..75672947b463 100644 --- a/writerperfect/source/writer/MSWorksImportFilter.cxx +++ b/writerperfect/source/writer/MSWorksImportFilter.cxx @@ -24,16 +24,17 @@ using com::sun::star::uno::Exception; using com::sun::star::uno::RuntimeException; using com::sun::star::uno::XComponentContext; -bool MSWorksImportFilter::doImportDocument( WPXInputStream &rInput, const rtl::OUString &, WPXDocumentInterface &rGenerator ) +bool MSWorksImportFilter::doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &, librevenge::RVNGTextInterface &rGenerator ) { - return WPS_OK == WPSDocument::parse(&rInput, &rGenerator); + return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator); } -bool MSWorksImportFilter::doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) +bool MSWorksImportFilter::doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) { - const WPSConfidence confidence = WPSDocument::isFileFormatSupported(&rInput); + libwps::WPSKind kind = libwps::WPS_TEXT; + const libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&rInput, kind); - if ((confidence == WPS_CONFIDENCE_EXCELLENT) || (confidence == WPS_CONFIDENCE_GOOD)) + if ((kind == libwps::WPS_TEXT) && (confidence == libwps::WPS_CONFIDENCE_EXCELLENT)) { rTypeName = "writer_MS_Works_Document"; return true; diff --git a/writerperfect/source/writer/MSWorksImportFilter.hxx b/writerperfect/source/writer/MSWorksImportFilter.hxx index 924e2c207255..b5ddfe4ccf64 100644 --- a/writerperfect/source/writer/MSWorksImportFilter.hxx +++ b/writerperfect/source/writer/MSWorksImportFilter.hxx @@ -33,8 +33,8 @@ public: throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; private: - virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE; - virtual bool doImportDocument( WPXInputStream &rInput, const rtl::OUString &rFilterName, WPXDocumentInterface &rGenerator ) SAL_OVERRIDE; + virtual bool doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE; + virtual bool doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator ) SAL_OVERRIDE; }; OUString MSWorksImportFilter_getImplementationName() diff --git a/writerperfect/source/writer/MWAWImportFilter.cxx b/writerperfect/source/writer/MWAWImportFilter.cxx index 97f414ac0812..ad656c942817 100644 --- a/writerperfect/source/writer/MWAWImportFilter.cxx +++ b/writerperfect/source/writer/MWAWImportFilter.cxx @@ -24,18 +24,19 @@ using com::sun::star::uno::Exception; using com::sun::star::uno::RuntimeException; using com::sun::star::uno::XComponentContext; -static bool handleEmbeddedMWAWObject(const WPXBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedMWAWObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) { - OdgGenerator exporter(pHandler, streamType); + OdgGenerator exporter; + exporter.addDocumentHandler(pHandler, streamType); return MWAWDocument::decodeGraphic(data, &exporter); } -bool MWAWImportFilter::doImportDocument( WPXInputStream &rInput, const rtl::OUString &, WPXDocumentInterface &rGenerator ) +bool MWAWImportFilter::doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &, librevenge::RVNGTextInterface &rGenerator ) { return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator); } -bool MWAWImportFilter::doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) +bool MWAWImportFilter::doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) { rTypeName = ""; diff --git a/writerperfect/source/writer/MWAWImportFilter.hxx b/writerperfect/source/writer/MWAWImportFilter.hxx index 4efe185cab48..62883f9cf40a 100644 --- a/writerperfect/source/writer/MWAWImportFilter.hxx +++ b/writerperfect/source/writer/MWAWImportFilter.hxx @@ -33,8 +33,8 @@ public: throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; private: - virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE; - virtual bool doImportDocument( WPXInputStream &rInput, const rtl::OUString &rFilterName, WPXDocumentInterface &rGenerator ) SAL_OVERRIDE; + virtual bool doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE; + virtual bool doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator ) SAL_OVERRIDE; virtual void doRegisterHandlers( OdtGenerator &rGenerator ) SAL_OVERRIDE; }; diff --git a/writerperfect/source/writer/WordPerfectImportFilter.cxx b/writerperfect/source/writer/WordPerfectImportFilter.cxx index e70eef6ebd86..c741782ae4cb 100644 --- a/writerperfect/source/writer/WordPerfectImportFilter.cxx +++ b/writerperfect/source/writer/WordPerfectImportFilter.cxx @@ -28,8 +28,9 @@ #include <sfx2/passwd.hxx> #include <ucbhelper/content.hxx> -#include <libwpd/libwpd.h> #include <libodfgen/libodfgen.hxx> +#include <libwpd/libwpd.h> +#include <libwpg/libwpg.h> #include "WordPerfectImportFilter.hxx" @@ -57,31 +58,36 @@ using com::sun::star::xml::sax::XParser; using writerperfect::DocumentHandler; using writerperfect::WPXSvInputStream; -static bool handleEmbeddedWPGObject(const WPXBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +static bool handleEmbeddedWPGObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) { - OdgGenerator exporter(pHandler, streamType); + OdgGenerator exporter; + exporter.addDocumentHandler(pHandler, streamType); libwpg::WPGFileFormat fileFormat = libwpg::WPG_AUTODETECT; - if (!libwpg::WPGraphics::isSupported(const_cast<WPXInputStream *>(data.getDataStream()))) + if (!libwpg::WPGraphics::isSupported(const_cast<librevenge::RVNGInputStream *>(data.getDataStream()))) fileFormat = libwpg::WPG_WPG1; - return libwpg::WPGraphics::parse(const_cast<WPXInputStream *>(data.getDataStream()), &exporter, fileFormat); + return libwpg::WPGraphics::parse(const_cast<librevenge::RVNGInputStream *>(data.getDataStream()), &exporter, fileFormat); } -static bool handleEmbeddedWPGImage(const WPXBinaryData &input, WPXBinaryData &output) +static bool handleEmbeddedWPGImage(const librevenge::RVNGBinaryData &input, librevenge::RVNGBinaryData &output) { - WPXString svgOutput; libwpg::WPGFileFormat fileFormat = libwpg::WPG_AUTODETECT; - if (!libwpg::WPGraphics::isSupported(const_cast<WPXInputStream *>(input.getDataStream()))) + if (!libwpg::WPGraphics::isSupported(const_cast<librevenge::RVNGInputStream *>(input.getDataStream()))) fileFormat = libwpg::WPG_WPG1; - if (!libwpg::WPGraphics::generateSVG(const_cast<WPXInputStream *>(input.getDataStream()), svgOutput, fileFormat)) + librevenge::RVNGStringVector svgOutput; + librevenge::RVNGSVGDrawingGenerator aSVGGenerator(svgOutput, ""); + + if (!libwpg::WPGraphics::parse(const_cast<librevenge::RVNGInputStream *>(input.getDataStream()), &aSVGGenerator, fileFormat)) return false; + assert(1 == svgOutput.size()); + output.clear(); - output.append((unsigned char *)svgOutput.cstr(), strlen(svgOutput.cstr())); + output.append(reinterpret_cast<const unsigned char *>(svgOutput[0].cstr()), svgOutput[0].size()); return true; } @@ -106,9 +112,9 @@ bool SAL_CALL WordPerfectImportFilter::importImpl( const Sequence< ::com::sun::s OString aUtf8Passwd; - WPDConfidence confidence = WPDocument::isFileFormatSupported(&input); + libwpd::WPDConfidence confidence = libwpd::WPDocument::isFileFormatSupported(&input); - if (WPD_CONFIDENCE_SUPPORTED_ENCRYPTION == confidence) + if (libwpd::WPD_CONFIDENCE_SUPPORTED_ENCRYPTION == confidence) { int unsuccessfulAttempts = 0; while (true ) @@ -119,7 +125,7 @@ bool SAL_CALL WordPerfectImportFilter::importImpl( const Sequence< ::com::sun::s return false; OUString aPasswd = aPasswdDlg.GetPassword(); aUtf8Passwd = OUStringToOString(aPasswd, RTL_TEXTENCODING_UTF8); - if (WPD_PASSWORD_MATCH_OK == WPDocument::verifyPassword(&input, aUtf8Passwd.getStr())) + if (libwpd::WPD_PASSWORD_MATCH_OK == libwpd::WPDocument::verifyPassword(&input, aUtf8Passwd.getStr())) break; else unsuccessfulAttempts++; @@ -142,10 +148,11 @@ bool SAL_CALL WordPerfectImportFilter::importImpl( const Sequence< ::com::sun::s // writes to in-memory target doc DocumentHandler xHandler(xInternalHandler); - OdtGenerator collector(&xHandler, ODF_FLAT_XML); + OdtGenerator collector; + collector.addDocumentHandler(&xHandler, ODF_FLAT_XML); collector.registerEmbeddedObjectHandler("image/x-wpg", &handleEmbeddedWPGObject); collector.registerEmbeddedImageHandler("image/x-wpg", &handleEmbeddedWPGImage); - if (WPD_OK == WPDocument::parse(&input, &collector, aUtf8Passwd.isEmpty() ? 0 : aUtf8Passwd.getStr())) + if (libwpd::WPD_OK == libwpd::WPDocument::parse(&input, &collector, aUtf8Passwd.isEmpty() ? 0 : aUtf8Passwd.getStr())) return true; return false; } @@ -171,7 +178,7 @@ throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std:: OUString SAL_CALL WordPerfectImportFilter::detect( Sequence< PropertyValue >& Descriptor ) throw( RuntimeException, std::exception ) { - WPDConfidence confidence = WPD_CONFIDENCE_NONE; + libwpd::WPDConfidence confidence = libwpd::WPD_CONFIDENCE_NONE; OUString sTypeName; sal_Int32 nLength = Descriptor.getLength(); sal_Int32 location = nLength; @@ -190,9 +197,9 @@ throw( RuntimeException, std::exception ) WPXSvInputStream input( xInputStream ); - confidence = WPDocument::isFileFormatSupported(&input); + confidence = libwpd::WPDocument::isFileFormatSupported(&input); - if (confidence == WPD_CONFIDENCE_EXCELLENT || confidence == WPD_CONFIDENCE_SUPPORTED_ENCRYPTION) + if (confidence == libwpd::WPD_CONFIDENCE_EXCELLENT || confidence == libwpd::WPD_CONFIDENCE_SUPPORTED_ENCRYPTION) sTypeName = "writer_WordPerfect_Document"; if (!sTypeName.isEmpty()) @@ -289,9 +296,9 @@ throw (RuntimeException, std::exception) OString aUtf8Passwd; - WPDConfidence confidence = WPDocument::isFileFormatSupported(&input); + libwpd::WPDConfidence confidence = libwpd::WPDocument::isFileFormatSupported(&input); - if (WPD_CONFIDENCE_SUPPORTED_ENCRYPTION == confidence) + if (libwpd::WPD_CONFIDENCE_SUPPORTED_ENCRYPTION == confidence) { int unsuccessfulAttempts = 0; while (true ) @@ -302,7 +309,7 @@ throw (RuntimeException, std::exception) return com::sun::star::ui::dialogs::ExecutableDialogResults::CANCEL; msPassword = aPasswdDlg.GetPassword().getStr(); aUtf8Passwd = OUStringToOString(msPassword, RTL_TEXTENCODING_UTF8); - if (WPD_PASSWORD_MATCH_OK == WPDocument::verifyPassword(&input, aUtf8Passwd.getStr())) + if (libwpd::WPD_PASSWORD_MATCH_OK == libwpd::WPDocument::verifyPassword(&input, aUtf8Passwd.getStr())) break; else unsuccessfulAttempts++; |