PKGBUILDs/extra/calligra/0001-switch-to-librevenge-based-import-libs.patch
2014-06-14 19:52:25 +00:00

882 lines
34 KiB
Diff

From 8e8f99cc314435f100d367f41c110becd19d3885 Mon Sep 17 00:00:00 2001
From: David Tardon <dtardon@redhat.com>
Date: Tue, 27 May 2014 16:15:52 +0200
Subject: [PATCH] switch to librevenge-based import libs
---
CMakeLists.txt | 10 ++++++
cmake/modules/FindLibEtonyek.cmake | 6 ++--
cmake/modules/FindLibOdfGen.cmake | 6 ++--
cmake/modules/FindLibRevenge.cmake | 37 +++++++++++++++++++++
cmake/modules/FindLibVisio.cmake | 6 ++--
cmake/modules/FindLibWpd.cmake | 22 +++----------
cmake/modules/FindLibWpg.cmake | 6 ++--
cmake/modules/FindLibWps.cmake | 6 ++--
filters/flow/visio/import/CMakeLists.txt | 3 +-
filters/flow/visio/import/VSDXImport.cpp | 9 ++---
filters/flow/wpg/import/CMakeLists.txt | 3 +-
filters/flow/wpg/import/WPGImport.cpp | 9 ++---
filters/karbon/wpg/CMakeLists.txt | 4 +--
filters/karbon/wpg/WPGImport.cpp | 39 ++++++++--------------
filters/libodfhandler/DiskDocumentHandler.cxx | 13 ++++----
filters/libodfhandler/DiskDocumentHandler.hxx | 8 ++---
filters/libodfhandler/OutputFileHelper.cxx | 6 ++--
filters/libodfhandler/OutputFileHelper.hxx | 9 ++---
filters/libodfhandler/StdOutHandler.cxx | 13 ++++----
filters/libodfhandler/StdOutHandler.hxx | 8 ++---
filters/stage/keynote/import/CMakeLists.txt | 5 +--
filters/stage/keynote/import/KeyImport.cpp | 15 +++++----
filters/words/wordperfect/import/CMakeLists.txt | 3 +-
filters/words/wordperfect/import/WPDImport.cpp | 44 ++++++++++++++-----------
filters/words/works/import/CMakeLists.txt | 3 +-
filters/words/works/import/WPSImport.cpp | 18 +++++-----
26 files changed, 177 insertions(+), 134 deletions(-)
create mode 100644 cmake/modules/FindLibRevenge.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5b6b764..c337864 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -697,6 +697,16 @@ macro_optional_find_package(Okular)
macro_log_feature(OKULAR_FOUND "Okular" "Okular ODP Plugin" "http://okular.kde.org/" FALSE "" "Required to build the Okular OpenDocument Presenter plugin")
##
+## Test for librevenge
+##
+macro_optional_find_package(LibRevenge)
+macro_log_feature(LIBREVENGE_FOUND "LibRevenge"
+ "A base library for writing document import filters"
+ "http://sf.net/p/libwpd/librevenge/" FALSE ""
+ "Required by various import filters"
+)
+
+##
## Test for libodfgen
##
macro_optional_find_package(LibOdfGen)
diff --git a/cmake/modules/FindLibEtonyek.cmake b/cmake/modules/FindLibEtonyek.cmake
index 5b78964..ad10d79 100644
--- a/cmake/modules/FindLibEtonyek.cmake
+++ b/cmake/modules/FindLibEtonyek.cmake
@@ -10,16 +10,16 @@
include(LibFindMacros)
libfind_package(LIBETONYEK LibWpd)
-libfind_pkg_check_modules(LIBETONYEK_PKGCONF libetonyek-0.0)
+libfind_pkg_check_modules(LIBETONYEK_PKGCONF libetonyek-0.1)
find_path(LIBETONYEK_INCLUDE_DIR
NAMES libetonyek/libetonyek.h
HINTS ${LIBETONYEK_PKGCONF_INCLUDE_DIRS} ${LIBETONYEK_PKGCONF_INCLUDEDIR}
- PATH_SUFFIXES libetonyek-0.0
+ PATH_SUFFIXES libetonyek-0.1
)
find_library(LIBETONYEK_LIBRARY
- NAMES etonyek etonyek-0.0
+ NAMES etonyek etonyek-0.1
HINTS ${LIBETONYEK_PKGCONF_LIBRARY_DIRS} ${LIBETONYEK_PKGCONF_LIBDIR}
)
diff --git a/cmake/modules/FindLibOdfGen.cmake b/cmake/modules/FindLibOdfGen.cmake
index 9ab80d1..355c345 100644
--- a/cmake/modules/FindLibOdfGen.cmake
+++ b/cmake/modules/FindLibOdfGen.cmake
@@ -9,16 +9,16 @@
# Redistribution and use is allowed according to the terms of the BSD license.
include(LibFindMacros)
-libfind_pkg_check_modules(LIBODFGEN_PKGCONF libodfgen-0.0)
+libfind_pkg_check_modules(LIBODFGEN_PKGCONF libodfgen-0.1)
find_path(LIBODFGEN_INCLUDE_DIR
NAMES libodfgen/libodfgen.hxx
HINTS ${LIBODFGEN_PKGCONF_INCLUDE_DIRS} ${LIBODFGEN_PKGCONF_INCLUDEDIR}
- PATH_SUFFIXES libodfgen-0.0
+ PATH_SUFFIXES libodfgen-0.1
)
find_library(LIBODFGEN_LIBRARY
- NAMES odfgen-0.0
+ NAMES odfgen-0.1
HINTS ${LIBODFGEN_PKGCONF_LIBRARY_DIRS} ${LIBODFGEN_PKGCONF_LIBDIR}
)
diff --git a/cmake/modules/FindLibRevenge.cmake b/cmake/modules/FindLibRevenge.cmake
new file mode 100644
index 0000000..8ed18b1
--- /dev/null
+++ b/cmake/modules/FindLibRevenge.cmake
@@ -0,0 +1,37 @@
+# - Try to find the librevenge
+# Once done this will define
+#
+# LIBREVENGE_FOUND - system has LIBREVENGE
+# LIBREVENGE_INCLUDE_DIRS - the LIBREVENGE include directory
+# LIBREVENGE_LIBRARIES - Link these to use LIBREVENGE
+# LIBREVENGE_DEFINITIONS - Compiler switches required for using LIBREVENGE
+#
+
+include(LibFindMacros)
+libfind_pkg_check_modules(REVENGE_PKGCONF librevenge-0.0)
+
+find_path(REVENGE_INCLUDE_DIR
+ NAMES librevenge/librevenge.h
+ HINTS ${REVENGE_PKGCONF_INCLUDE_DIRS} ${REVENGE_PKGCONF_INCLUDEDIR}
+ PATH_SUFFIXES librevenge-0.0
+)
+
+find_path(REVENGE_STREAM_INCLUDE_DIR
+ NAMES librevenge-stream/librevenge-stream.h
+ HINTS ${REVENGE_STREAM_PKGCONF_INCLUDE_DIRS} ${REVENGE_STREAM_PKGCONF_INCLUDEDIR}
+ PATH_SUFFIXES librevenge-0.0
+)
+
+find_library(REVENGE_LIBRARY
+ NAMES revenge librevenge revenge-0.0 librevenge-0.0
+ HINTS ${REVENGE_STREAM_PKGCONF_LIBRARY_DIRS} ${REVENGE_STREAM_PKGCONF_LIBDIR}
+)
+
+find_library(REVENGE_STREAM_LIBRARY
+ NAMES revenge-stream librevenge-stream revenge-stream-0.0 librevenge-stream-0.0
+ HINTS ${REVENGE_PKGCONF_LIBRARY_DIRS} ${REVENGE_PKGCONF_LIBDIR}
+)
+
+set(LIBREVENGE_PROCESS_LIBS REVENGE_LIBRARY REVENGE_STREAM_LIBRARY)
+set(LIBREVENGE_PROCESS_INCLUDES REVENGE_INCLUDE_DIR REVENGE_STREAM_INCLUDE_DIR)
+libfind_process(LIBREVENGE)
diff --git a/cmake/modules/FindLibVisio.cmake b/cmake/modules/FindLibVisio.cmake
index a8533ee..49871b3 100644
--- a/cmake/modules/FindLibVisio.cmake
+++ b/cmake/modules/FindLibVisio.cmake
@@ -12,16 +12,16 @@
include(LibFindMacros)
libfind_package(LIBWPD LibWpd)
libfind_package(LIBWPG LibWpg)
-libfind_pkg_check_modules(LIBVISIO_PKGCONF libvisio-0.0)
+libfind_pkg_check_modules(LIBVISIO_PKGCONF libvisio-0.1)
find_path(LIBVISIO_INCLUDE_DIR
NAMES libvisio/libvisio.h
HINTS ${LIBVISIO_PKGCONF_INCLUDE_DIRS} ${LIBVISIO_PKGCONF_INCLUDEDIR}
- PATH_SUFFIXES libvisio-0.0
+ PATH_SUFFIXES libvisio-0.1
)
find_library(LIBVISIO_LIBRARY
- NAMES visio visio-0.0
+ NAMES visio visio-0.1
HINTS ${LIBVISIO_PKGCONF_LIBRARY_DIRS} ${LIBVISIO_PKGCONF_LIBDIR}
)
diff --git a/cmake/modules/FindLibWpd.cmake b/cmake/modules/FindLibWpd.cmake
index 2a324cc..ed9bc26 100644
--- a/cmake/modules/FindLibWpd.cmake
+++ b/cmake/modules/FindLibWpd.cmake
@@ -8,31 +8,19 @@
#
include(LibFindMacros)
-libfind_pkg_check_modules(WPD_PKGCONF libwpd-0.9)
-libfind_pkg_check_modules(WPD_STREAM_PKGCONF libwpd-stream-0.9)
+libfind_pkg_check_modules(WPD_PKGCONF libwpd-0.10)
find_path(WPD_INCLUDE_DIR
NAMES libwpd/libwpd.h
HINTS ${WPD_PKGCONF_INCLUDE_DIRS} ${WPD_PKGCONF_INCLUDEDIR}
- PATH_SUFFIXES libwpd-0.9
-)
-
-find_path(WPD_STREAM_INCLUDE_DIR
- NAMES libwpd-stream/libwpd-stream.h
- HINTS ${WPD_STREAM_PKGCONF_INCLUDE_DIRS} ${WPD_STREAM_PKGCONF_INCLUDEDIR}
- PATH_SUFFIXES libwpd-0.9
+ PATH_SUFFIXES libwpd-0.10
)
find_library(WPD_LIBRARY
- NAMES wpd libwpd wpd-0.9 libwpd-0.9
+ NAMES wpd libwpd wpd-0.10 libwpd-0.10
HINTS ${WPD_PKGCONF_LIBRARY_DIRS} ${WPD_PKGCONF_LIBDIR}
)
-find_library(WPD_STREAM_LIBRARY
- NAMES wpd-stream libwpd-stream wpd-stream-0.9 libwpd-stream-0.9
- HINTS ${WPD_STREAM_PKGCONF_LIBRARY_DIRS} ${WPD_STREAM_PKGCONF_LIBDIR}
-)
-
-set(LIBWPD_PROCESS_LIBS WPD_LIBRARY WPD_STREAM_LIBRARY)
-set(LIBWPD_PROCESS_INCLUDES WPD_INCLUDE_DIR WPD_STREAM_INCLUDE_DIR)
+set(LIBWPD_PROCESS_LIBS WPD_LIBRARY)
+set(LIBWPD_PROCESS_INCLUDES WPD_INCLUDE_DIR)
libfind_process(LIBWPD)
diff --git a/cmake/modules/FindLibWpg.cmake b/cmake/modules/FindLibWpg.cmake
index 56d9302..16c2a1c 100644
--- a/cmake/modules/FindLibWpg.cmake
+++ b/cmake/modules/FindLibWpg.cmake
@@ -11,16 +11,16 @@
include(LibFindMacros)
libfind_package(LIBWPG LibWpd)
-libfind_pkg_check_modules(LIBWPG_PKGCONF libwpg-0.2)
+libfind_pkg_check_modules(LIBWPG_PKGCONF libwpg-0.3)
find_path(LIBWPG_INCLUDE_DIR
NAMES libwpg/libwpg.h
HINTS ${LIBWPG_PKGCONF_INCLUDE_DIRS} ${LIBWPG_PKGCONF_INCLUDEDIR}
- PATH_SUFFIXES libwpg-0.2
+ PATH_SUFFIXES libwpg-0.3
)
find_library(LIBWPG_LIBRARY
- NAMES wpg wpg-0.2
+ NAMES wpg wpg-0.3
HINTS ${LIBWPG_PKGCONF_LIBRARY_DIRS} ${LIBWPG_PKGCONF_LIBDIR}
)
diff --git a/cmake/modules/FindLibWps.cmake b/cmake/modules/FindLibWps.cmake
index 149f34c..f8c8225 100644
--- a/cmake/modules/FindLibWps.cmake
+++ b/cmake/modules/FindLibWps.cmake
@@ -10,16 +10,16 @@
include(LibFindMacros)
libfind_package(LIBWPS LibWpd)
-libfind_pkg_check_modules(LIBWPS_PKGCONF libwps-0.2)
+libfind_pkg_check_modules(LIBWPS_PKGCONF libwps-0.3)
find_path(LIBWPS_INCLUDE_DIR
NAMES libwps/libwps.h
HINTS ${LIBWPS_PKGCONF_INCLUDE_DIRS} ${LIBWPS_PKGCONF_INCLUDEDIR}
- PATH_SUFFIXES libwps-0.2
+ PATH_SUFFIXES libwps-0.3
)
find_library(LIBWPS_LIBRARY
- NAMES wps wps-0.2
+ NAMES wps wps-0.3
HINTS ${LIBWPS_PKGCONF_LIBRARY_DIRS} ${LIBWPS_PKGCONF_LIBDIR}
)
diff --git a/filters/flow/visio/import/CMakeLists.txt b/filters/flow/visio/import/CMakeLists.txt
index 1de4385..4c2a391 100644
--- a/filters/flow/visio/import/CMakeLists.txt
+++ b/filters/flow/visio/import/CMakeLists.txt
@@ -1,6 +1,7 @@
include_directories(
../../../libodfhandler/
${LIBODFGEN_INCLUDE_DIRS}
+ ${LIBREVENGE_INCLUDE_DIRS}
${LIBVISIO_INCLUDE_DIRS}
${KOMAIN_INCLUDES}
)
@@ -15,7 +16,7 @@ set(vsdx2odg_PART_SRCS
kde4_add_plugin(calligra_filter_vsdx2odg ${vsdx2odg_PART_SRCS})
-target_link_libraries(calligra_filter_vsdx2odg komain ${LIBODFGEN_LIBRARIES} ${LIBVISIO_LIBRARIES})
+target_link_libraries(calligra_filter_vsdx2odg komain ${LIBODFGEN_LIBRARIES} ${LIBREVENGE_LIBRARIES} ${LIBVISIO_LIBRARIES})
install(TARGETS calligra_filter_vsdx2odg DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES calligra_filter_vsdx2odg.desktop DESTINATION ${SERVICES_INSTALL_DIR})
diff --git a/filters/flow/visio/import/VSDXImport.cpp b/filters/flow/visio/import/VSDXImport.cpp
index 70a54d9..eb3a208 100644
--- a/filters/flow/visio/import/VSDXImport.cpp
+++ b/filters/flow/visio/import/VSDXImport.cpp
@@ -17,7 +17,7 @@
#include "VSDXImport.h"
#include <libvisio/libvisio.h>
-#include <libodfgen/OdgGenerator.hxx>
+#include <libodfgen/libodfgen.hxx>
#include "OutputFileHelper.hxx"
#include <KoFilterChain.h>
@@ -39,7 +39,7 @@ public:
~OdgOutputFileHelper() {}
private:
- bool _isSupportedFormat(WPXInputStream *input, const char * /* password */)
+ bool _isSupportedFormat(librevenge::RVNGInputStream *input, const char * /* password */)
{
if (!libvisio::VisioDocument::isSupported(input))
{
@@ -49,9 +49,10 @@ private:
return true;
}
- bool _convertDocument(WPXInputStream *input, const char * /* password */, OdfDocumentHandler *handler, OdfStreamType streamType)
+ bool _convertDocument(librevenge::RVNGInputStream *input, const char * /* password */, OdfDocumentHandler *handler, OdfStreamType streamType)
{
- OdgGenerator exporter(handler, streamType);
+ OdgGenerator exporter;
+ exporter.addDocumentHandler(handler, streamType);
return libvisio::VisioDocument::parse(input, &exporter);
}
};
diff --git a/filters/flow/wpg/import/CMakeLists.txt b/filters/flow/wpg/import/CMakeLists.txt
index 524d1b1..e2ee2a5 100644
--- a/filters/flow/wpg/import/CMakeLists.txt
+++ b/filters/flow/wpg/import/CMakeLists.txt
@@ -1,6 +1,7 @@
include_directories(
../../../libodfhandler/
${LIBODFGEN_INCLUDE_DIRS}
+ ${LIBREVENGE_INCLUDE_DIRS}
${LIBVISIO_INCLUDE_DIRS}
${KOMAIN_INCLUDES}
)
@@ -15,7 +16,7 @@ set(wpg2odg_PART_SRCS
kde4_add_plugin(calligra_filter_wpg2odg ${wpg2odg_PART_SRCS})
-target_link_libraries(calligra_filter_wpg2odg komain ${LIBODFGEN_LIBRARIES} ${LIBWPG_LIBRARIES})
+target_link_libraries(calligra_filter_wpg2odg komain ${LIBODFGEN_LIBRARIES} ${LIBREVENGE_LIBRARIES} ${LIBWPG_LIBRARIES})
install(TARGETS calligra_filter_wpg2odg DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES calligra_filter_wpg2odg.desktop DESTINATION ${SERVICES_INSTALL_DIR})
diff --git a/filters/flow/wpg/import/WPGImport.cpp b/filters/flow/wpg/import/WPGImport.cpp
index b4e0fa7..563ae6e 100644
--- a/filters/flow/wpg/import/WPGImport.cpp
+++ b/filters/flow/wpg/import/WPGImport.cpp
@@ -17,7 +17,7 @@
#include "WPGImport.h"
#include <libwpg/libwpg.h>
-#include <libodfgen/OdgGenerator.hxx>
+#include <libodfgen/libodfgen.hxx>
#include "OutputFileHelper.hxx"
#include <KoFilterChain.h>
@@ -39,7 +39,7 @@ public:
~OdgOutputFileHelper() {}
private:
- bool _isSupportedFormat(WPXInputStream *input, const char * /* password */)
+ bool _isSupportedFormat(librevenge::RVNGInputStream *input, const char * /* password */)
{
if (!libwpg::WPGraphics::isSupported(input))
{
@@ -49,9 +49,10 @@ private:
return true;
}
- bool _convertDocument(WPXInputStream *input, const char * /* password */, OdfDocumentHandler *handler, OdfStreamType streamType)
+ bool _convertDocument(librevenge::RVNGInputStream *input, const char * /* password */, OdfDocumentHandler *handler, OdfStreamType streamType)
{
- OdgGenerator exporter(handler, streamType);
+ OdgGenerator exporter;
+ exporter.addDocumentHandler(handler, streamType);
return libwpg::WPGraphics::parse(input, &exporter);
}
};
diff --git a/filters/karbon/wpg/CMakeLists.txt b/filters/karbon/wpg/CMakeLists.txt
index 5f578e9..ffa7742 100644
--- a/filters/karbon/wpg/CMakeLists.txt
+++ b/filters/karbon/wpg/CMakeLists.txt
@@ -1,11 +1,11 @@
-include_directories(${CMAKE_BINARY_DIR}/filters/ ${LIBWPD_INCLUDE_DIRS} ${LIBWPG_INCLUDE_DIR}/)
+include_directories(${CMAKE_BINARY_DIR}/filters/ ${LIBREVENGE_INCLUDE_DIRS} ${LIBWPG_INCLUDE_DIR}/)
set(wpg2svg_PART_SRCS WPGImport.cpp)
kde4_add_plugin(calligra_filter_wpg2svg ${wpg2svg_PART_SRCS})
-target_link_libraries(calligra_filter_wpg2svg komain ${LIBWPG_LIBRARIES} ${LIBWPG_STREAM_LIBRARIES} ${LIBWPD_LIBRARIES})
+target_link_libraries(calligra_filter_wpg2svg komain ${LIBWPG_LIBRARIES} ${LIBREVENGE_LIBRARIES})
install(TARGETS calligra_filter_wpg2svg DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES calligra_filter_wpg2svg.desktop DESTINATION ${SERVICES_INSTALL_DIR})
diff --git a/filters/karbon/wpg/WPGImport.cpp b/filters/karbon/wpg/WPGImport.cpp
index f1852ee..4457bec 100644
--- a/filters/karbon/wpg/WPGImport.cpp
+++ b/filters/karbon/wpg/WPGImport.cpp
@@ -32,14 +32,12 @@
#include <QString>
#include <QFile>
+#include <librevenge/librevenge.h>
+#include <librevenge-stream/librevenge-stream.h>
+
#include <libwpg/libwpg.h>
-#if LIBWPG_VERSION_MINOR<2
-#include <libwpg/WPGStreamImplementation.h>
-#else
-#include <libwpd-stream/libwpd-stream.h>
-#include <libwpd/libwpd.h>
-#endif
+#include <cassert>
#include <iostream>
K_PLUGIN_FACTORY(WPGImportFactory, registerPlugin<WPGImport>();)
@@ -63,39 +61,29 @@ KoFilter::ConversionStatus WPGImport::convert(const QByteArray& from, const QByt
if (to != "image/svg+xml")
return KoFilter::NotImplemented;
-#if LIBWPG_VERSION_MINOR<2
- WPXInputStream* input = new libwpg::WPGFileStream(m_chain->inputFile().toLocal8Bit());
- if (input->isOLEStream()) {
- WPXInputStream* olestream = input->getDocumentOLEStream();
- if (olestream) {
- delete input;
- input = olestream;
- }
- }
- libwpg::WPGString output;
-#else
- WPXInputStream* input = new WPXFileStream(m_chain->inputFile().toLocal8Bit());
- if (input->isOLEStream()) {
- WPXInputStream* olestream = input->getDocumentOLEStream("Anything");
+ librevenge::RVNGInputStream* input = new librevenge::RVNGFileStream(m_chain->inputFile().toLocal8Bit());
+ if (input->isStructured()) {
+ librevenge::RVNGInputStream* olestream = input->getSubStreamByName("Anything");
if (olestream) {
delete input;
input = olestream;
}
}
- ::WPXString output;
-#endif
-
if (!libwpg::WPGraphics::isSupported(input)) {
kWarning() << "ERROR: Unsupported file format (unsupported version) or file is encrypted!";
delete input;
return KoFilter::NotImplemented;
}
- if (!libwpg::WPGraphics::generateSVG(input, output)) {
+ ::librevenge::RVNGStringVector output;
+ librevenge::RVNGSVGDrawingGenerator generator(output, "");
+
+ if (!libwpg::WPGraphics::parse(input, &generator)) {
kWarning() << "ERROR: SVG Generation failed!";
delete input;
return KoFilter::ParsingError;
}
+ assert(1 == output.size());
delete input;
@@ -104,7 +92,8 @@ KoFilter::ConversionStatus WPGImport::convert(const QByteArray& from, const QByt
kWarning() << "ERROR: Could not open output file" << m_chain->outputFile();
return KoFilter::InternalError;
}
- outputFile.write(output.cstr());
+ outputFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
+ outputFile.write(output[0].cstr());
outputFile.close();
return KoFilter::OK;
diff --git a/filters/libodfhandler/DiskDocumentHandler.cxx b/filters/libodfhandler/DiskDocumentHandler.cxx
index e035fdc..f8ca273 100644
--- a/filters/libodfhandler/DiskDocumentHandler.cxx
+++ b/filters/libodfhandler/DiskDocumentHandler.cxx
@@ -37,7 +37,7 @@ DiskOdfDocumentHandler::DiskOdfDocumentHandler(FemtoZip *pOutput) :
{
}
-void DiskOdfDocumentHandler::startElement(const char *psName, const WPXPropertyList &xPropList)
+void DiskOdfDocumentHandler::startElement(const char *psName, const librevenge::RVNGPropertyList &xPropList)
{
if (mbIsTagOpened)
{
@@ -46,11 +46,11 @@ void DiskOdfDocumentHandler::startElement(const char *psName, const WPXPropertyL
}
PUTSTRING("<");
PUTSTRING(psName);
- WPXPropertyList::Iter i(xPropList);
+ librevenge::RVNGPropertyList::Iter i(xPropList);
for (i.rewind(); i.next(); )
{
- // filter out libwpd elements
- if (strncmp(i.key(), "libwpd", 6) != 0)
+ // filter out librevenge properties
+ if (strncmp(i.key(), "librevenge", 10) != 0)
{
PUTSTRING(" ");
PUTSTRING(i.key());
@@ -91,14 +91,15 @@ void DiskOdfDocumentHandler::endElement(const char *psName)
}
}
-void DiskOdfDocumentHandler::characters(const WPXString &sCharacters)
+void DiskOdfDocumentHandler::characters(const librevenge::RVNGString &sCharacters)
{
if (mbIsTagOpened)
{
PUTSTRING(">");
mbIsTagOpened = false;
}
- WPXString sEscapedCharacters(sCharacters, true);
+ librevenge::RVNGString sEscapedCharacters;
+ sEscapedCharacters.appendEscapedXML(sCharacters);
if (sEscapedCharacters.len() > 0)
PUTSTRING(sEscapedCharacters.cstr());
}
diff --git a/filters/libodfhandler/DiskDocumentHandler.hxx b/filters/libodfhandler/DiskDocumentHandler.hxx
index 17f7eb7..d52a256 100644
--- a/filters/libodfhandler/DiskDocumentHandler.hxx
+++ b/filters/libodfhandler/DiskDocumentHandler.hxx
@@ -23,7 +23,7 @@
#ifndef _DISKDOCUMENTHANDLER_H
#define _DISKDOCUMENTHANDLER_H
-#include <libodfgen/OdfDocumentHandler.hxx>
+#include <libodfgen/libodfgen.hxx>
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -45,9 +45,9 @@ public:
#endif
virtual void startDocument() {}
virtual void endDocument();
- virtual void startElement(const char *psName, const WPXPropertyList &xPropList);
+ virtual void startElement(const char *psName, const librevenge::RVNGPropertyList &xPropList);
virtual void endElement(const char *psName);
- virtual void characters(const WPXString &sCharacters);
+ virtual void characters(const librevenge::RVNGString &sCharacters);
private:
DiskOdfDocumentHandler(DiskOdfDocumentHandler const &);
@@ -58,7 +58,7 @@ private:
FemtoZip *mpOutput;
#endif
bool mbIsTagOpened;
- WPXString msOpenedTagName;
+ librevenge::RVNGString msOpenedTagName;
};
#endif
diff --git a/filters/libodfhandler/OutputFileHelper.cxx b/filters/libodfhandler/OutputFileHelper.cxx
index 8786d4c..61e48e9 100644
--- a/filters/libodfhandler/OutputFileHelper.cxx
+++ b/filters/libodfhandler/OutputFileHelper.cxx
@@ -37,7 +37,7 @@
#include "DiskDocumentHandler.hxx"
#include "StdOutHandler.hxx"
-#include <libwpd-stream/WPXStreamImplementation.h>
+#include <librevenge-stream/librevenge-stream.h>
struct OutputFileHelperImpl
{
@@ -197,12 +197,12 @@ bool OutputFileHelper::writeChildFile(const char *childFileName, const char *str
bool OutputFileHelper::writeConvertedContent(const char *childFileName, const char *inFileName, const OdfStreamType streamType)
{
- WPXFileStream input(inFileName);
+ librevenge::RVNGFileStream input(inFileName);
if (!_isSupportedFormat(&input, m_impl->mpPassword))
return false;
- input.seek(0, WPX_SEEK_SET);
+ input.seek(0, librevenge::RVNG_SEEK_SET);
OdfDocumentHandler *pHandler;
#ifdef USE_GSF_OUTPUT
diff --git a/filters/libodfhandler/OutputFileHelper.hxx b/filters/libodfhandler/OutputFileHelper.hxx
index a61b9a0..d2632a9 100644
--- a/filters/libodfhandler/OutputFileHelper.hxx
+++ b/filters/libodfhandler/OutputFileHelper.hxx
@@ -22,9 +22,10 @@
#ifndef _OUTPUTFILEHELPER_HXX
#define _OUTPUTFILEHELPER_HXX
-#include <libodfgen/OdfDocumentHandler.hxx>
+#include <libodfgen/libodfgen.hxx>
+
+#include <librevenge-stream/librevenge-stream.h>
-class WPXInputStream;
struct OutputFileHelperImpl;
class OutputFileHelper
@@ -38,8 +39,8 @@ public:
bool writeConvertedContent(const char *childFileName, const char *inFileName, const OdfStreamType streamType);
private:
- virtual bool _isSupportedFormat(WPXInputStream *input, const char *password) = 0;
- virtual bool _convertDocument(WPXInputStream *input, const char *password, OdfDocumentHandler *handler, const OdfStreamType streamType) = 0;
+ virtual bool _isSupportedFormat(librevenge::RVNGInputStream *input, const char *password) = 0;
+ virtual bool _convertDocument(librevenge::RVNGInputStream *input, const char *password, OdfDocumentHandler *handler, const OdfStreamType streamType) = 0;
OutputFileHelperImpl *m_impl;
private:
diff --git a/filters/libodfhandler/StdOutHandler.cxx b/filters/libodfhandler/StdOutHandler.cxx
index 6864266..16e19f0 100644
--- a/filters/libodfhandler/StdOutHandler.cxx
+++ b/filters/libodfhandler/StdOutHandler.cxx
@@ -31,7 +31,7 @@ StdOutHandler::StdOutHandler() :
printf("<?xml version=\"1.0\"?>\n");
}
-void StdOutHandler::startElement(const char *psName, const WPXPropertyList &xPropList)
+void StdOutHandler::startElement(const char *psName, const librevenge::RVNGPropertyList &xPropList)
{
if (mbIsTagOpened)
{
@@ -39,11 +39,11 @@ void StdOutHandler::startElement(const char *psName, const WPXPropertyList &xPro
mbIsTagOpened = false;
}
printf("<%s", psName);
- WPXPropertyList::Iter i(xPropList);
+ librevenge::RVNGPropertyList::Iter i(xPropList);
for (i.rewind(); i.next(); )
{
- // filter out libwpd elements
- if (strncmp(i.key(), "libwpd", 6) != 0)
+ // filter out librevenge properties
+ if (strncmp(i.key(), "librevenge", 10) != 0)
printf(" %s=\"%s\"", i.key(), i()->getStr().cstr());
}
mbIsTagOpened = true;
@@ -73,15 +73,14 @@ void StdOutHandler::endElement(const char *psName)
}
}
-void StdOutHandler::characters(const WPXString &sCharacters)
+void StdOutHandler::characters(const librevenge::RVNGString &sCharacters)
{
if (mbIsTagOpened)
{
printf(">");
mbIsTagOpened = false;
}
- WPXString sEscapedCharacters(sCharacters, true);
- printf("%s", sEscapedCharacters.cstr());
+ printf("%s", librevenge::RVNGString::escapeXML(sCharacters).cstr());
}
void StdOutHandler::endDocument()
diff --git a/filters/libodfhandler/StdOutHandler.hxx b/filters/libodfhandler/StdOutHandler.hxx
index a18189a..44fa1e7 100644
--- a/filters/libodfhandler/StdOutHandler.hxx
+++ b/filters/libodfhandler/StdOutHandler.hxx
@@ -23,7 +23,7 @@
#ifndef _STDOUTHANDLER_H
#define _STDOUTHANDLER_H
-#include <libodfgen/OdfDocumentHandler.hxx>
+#include <libodfgen/libodfgen.hxx>
class StdOutHandler : public OdfDocumentHandler
{
@@ -31,12 +31,12 @@ public:
StdOutHandler();
virtual void startDocument() {}
virtual void endDocument();
- virtual void startElement(const char *psName, const WPXPropertyList &xPropList);
+ virtual void startElement(const char *psName, const librevenge::RVNGPropertyList &xPropList);
virtual void endElement(const char *psName);
- virtual void characters(const WPXString &sCharacters);
+ virtual void characters(const librevenge::RVNGString &sCharacters);
private:
bool mbIsTagOpened;
- WPXString msOpenedTagName;
+ librevenge::RVNGString msOpenedTagName;
};
#endif
diff --git a/filters/words/wordperfect/import/CMakeLists.txt b/filters/words/wordperfect/import/CMakeLists.txt
index 6a0e2d7..ffb3c70 100644
--- a/filters/words/wordperfect/import/CMakeLists.txt
+++ b/filters/words/wordperfect/import/CMakeLists.txt
@@ -1,6 +1,7 @@
include_directories(
../../../libodfhandler/
${LIBODFGEN_INCLUDE_DIRS}
+ ${LIBREVENGE_INCLUDE_DIRS}
${LIBWPD_INCLUDE_DIRS}
${LIBWPG_INCLUDE_DIRS}
${KOMAIN_INCLUDES}
@@ -17,7 +18,7 @@ set(wpd2odt_PART_SRCS
kde4_add_plugin(calligra_filter_wpd2odt ${wpd2odt_PART_SRCS})
target_link_libraries(calligra_filter_wpd2odt
- komain ${LIBODFGEN_LIBRARIES} ${LIBWPD_LIBRARIES} ${LIBWPG_LIBRARIES})
+ komain ${LIBODFGEN_LIBRARIES} ${LIBREVENGE_LIBRARIES} ${LIBWPD_LIBRARIES} ${LIBWPG_LIBRARIES})
install(TARGETS calligra_filter_wpd2odt DESTINATION ${PLUGIN_INSTALL_DIR})
diff --git a/filters/words/wordperfect/import/WPDImport.cpp b/filters/words/wordperfect/import/WPDImport.cpp
index af9d9b6..edf1c91 100644
--- a/filters/words/wordperfect/import/WPDImport.cpp
+++ b/filters/words/wordperfect/import/WPDImport.cpp
@@ -18,8 +18,7 @@
#include <libwpd/libwpd.h>
#include <libwpg/libwpg.h>
-#include <libodfgen/OdtGenerator.hxx>
-#include <libodfgen/OdgGenerator.hxx>
+#include <libodfgen/libodfgen.hxx>
#include <OutputFileHelper.hxx>
#include <KoFilterChain.h>
@@ -31,6 +30,7 @@
#include <QString>
#include <QByteArray>
+#include <cassert>
#include <stdio.h>
class OdtOutputFileHelper : public OutputFileHelper
@@ -41,20 +41,20 @@ public:
~OdtOutputFileHelper() {};
private:
- bool _isSupportedFormat(WPXInputStream *input, const char *password)
+ bool _isSupportedFormat(librevenge::RVNGInputStream *input, const char *password)
{
- WPDConfidence confidence = WPDocument::isFileFormatSupported(input);
- if (WPD_CONFIDENCE_EXCELLENT != confidence && WPD_CONFIDENCE_SUPPORTED_ENCRYPTION != confidence)
+ libwpd::WPDConfidence confidence = libwpd::WPDocument::isFileFormatSupported(input);
+ if (libwpd::WPD_CONFIDENCE_EXCELLENT != confidence && libwpd::WPD_CONFIDENCE_SUPPORTED_ENCRYPTION != confidence)
{
fprintf(stderr, "ERROR: We have no confidence that you are giving us a valid WordPerfect document.\n");
return false;
}
- if (WPD_CONFIDENCE_SUPPORTED_ENCRYPTION == confidence && !password)
+ if (libwpd::WPD_CONFIDENCE_SUPPORTED_ENCRYPTION == confidence && !password)
{
fprintf(stderr, "ERROR: The WordPerfect document is encrypted and you did not give us a password.\n");
return false;
}
- if (confidence == WPD_CONFIDENCE_SUPPORTED_ENCRYPTION && password && (WPD_PASSWORD_MATCH_OK != WPDocument::verifyPassword(input, password)))
+ if (confidence == libwpd::WPD_CONFIDENCE_SUPPORTED_ENCRYPTION && password && (libwpd::WPD_PASSWORD_MATCH_OK != libwpd::WPDocument::verifyPassword(input, password)))
{
fprintf(stderr, "ERROR: The WordPerfect document is encrypted and we either\n");
fprintf(stderr, "ERROR: don't know how to decrypt it or the given password is wrong.\n");
@@ -64,41 +64,47 @@ private:
return true;
}
- 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 generator(svgOutput, "");
+ if (!libwpg::WPGraphics::parse(const_cast<librevenge::RVNGInputStream *>(input.getDataStream()), &generator, fileFormat))
return false;
+ assert(1 == svgOutput.size());
output.clear();
- output.append((unsigned char *)svgOutput.cstr(), strlen(svgOutput.cstr()));
+ const librevenge::RVNGString svgPrefix("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
+ output.append((unsigned char *)svgPrefix.cstr(), svgPrefix.size());
+ output.append((unsigned char *)svgOutput[0].cstr(), svgOutput[0].size());
return true;
}
- bool _convertDocument(WPXInputStream *input, const char *password, OdfDocumentHandler *handler, const OdfStreamType streamType)
+ bool _convertDocument(librevenge::RVNGInputStream *input, const char *password, OdfDocumentHandler *handler, const OdfStreamType streamType)
{
- OdtGenerator collector(handler, streamType);
+ OdtGenerator collector;
+ collector.addDocumentHandler(handler, streamType);
collector.registerEmbeddedObjectHandler("image/x-wpg", &handleEmbeddedWPGObject);
collector.registerEmbeddedImageHandler("image/x-wpg", &handleEmbeddedWPGImage);
- if (WPD_OK == WPDocument::parse(input, &collector, password))
+ if (libwpd::WPD_OK == libwpd::WPDocument::parse(input, &collector, password))
return true;
return false;
}
diff --git a/filters/words/works/import/CMakeLists.txt b/filters/words/works/import/CMakeLists.txt
index 76317ae..2c51937 100644
--- a/filters/words/works/import/CMakeLists.txt
+++ b/filters/words/works/import/CMakeLists.txt
@@ -1,6 +1,7 @@
include_directories(
../../../libodfhandler/
${LIBODFGEN_INCLUDE_DIRS}
+ ${LIBREVENGE_INCLUDE_DIRS}
${LIBWPS_INCLUDE_DIRS}
${KOMAIN_INCLUDES}
)
@@ -15,7 +16,7 @@ set(wps2odt_PART_SRCS
kde4_add_plugin(calligra_filter_wps2odt ${wps2odt_PART_SRCS})
-target_link_libraries(calligra_filter_wps2odt komain ${LIBODFGEN_LIBRARIES} ${LIBWPS_LIBRARIES})
+target_link_libraries(calligra_filter_wps2odt komain ${LIBODFGEN_LIBRARIES} ${LIBREVENGE_LIBRARIES} ${LIBWPS_LIBRARIES})
install(TARGETS calligra_filter_wps2odt DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES calligra_filter_wps2odt.desktop DESTINATION ${SERVICES_INSTALL_DIR})
diff --git a/filters/words/works/import/WPSImport.cpp b/filters/words/works/import/WPSImport.cpp
index c2058e5..545daf3 100644
--- a/filters/words/works/import/WPSImport.cpp
+++ b/filters/words/works/import/WPSImport.cpp
@@ -16,9 +16,9 @@
#include "WPSImport.h"
-#include <libwpd/libwpd.h>
+#include <librevenge/librevenge.h>
#include <libwps/libwps.h>
-#include <libodfgen/OdtGenerator.hxx>
+#include <libodfgen/libodfgen.hxx>
#include "OutputFileHelper.hxx"
#include <KoFilterChain.h>
@@ -40,10 +40,11 @@ public:
~OdtOutputFileHelper() {};
private:
- bool _isSupportedFormat(WPXInputStream *input, const char * /* password */)
+ bool _isSupportedFormat(librevenge::RVNGInputStream *input, const char * /* password */)
{
- WPSConfidence confidence = WPSDocument::isFileFormatSupported(input);
- if (confidence == WPS_CONFIDENCE_NONE || confidence == WPS_CONFIDENCE_POOR)
+ libwps::WPSKind kind = libwps::WPS_TEXT;
+ libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(input, kind);
+ if ((libwps::WPS_TEXT != kind) || (confidence != libwps::WPS_CONFIDENCE_EXCELLENT))
{
fprintf(stderr, "ERROR: We have no confidence that you are giving us a valid Microsoft Works document.\n");
return false;
@@ -52,10 +53,11 @@ private:
return true;
}
- bool _convertDocument(WPXInputStream *input, const char * /* password */, OdfDocumentHandler *handler, const OdfStreamType streamType)
+ bool _convertDocument(librevenge::RVNGInputStream *input, const char * /* password */, OdfDocumentHandler *handler, const OdfStreamType streamType)
{
- OdtGenerator collector(handler, streamType);
- if (WPS_OK == WPSDocument::parse(input, &collector))
+ OdtGenerator collector;
+ collector.addDocumentHandler(handler, streamType);
+ if (libwps::WPS_OK == libwps::WPSDocument::parse(input, &collector))
return true;
return false;
}
--
1.9.3