Version in base suite: 0.7.11-1 Base version: libodsstream_0.7.11-1 Target version: libodsstream_0.8.4-1 Base file: /srv/ftp-master.debian.org/ftp/pool/main/libo/libodsstream/libodsstream_0.7.11-1.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/libo/libodsstream/libodsstream_0.8.4-1.dsc CMakeLists.txt | 6 CMakeStuff/modules/FindQUAZIP.cmake | 50 + CMakeStuff/modules/FindQuaZip.cmake | 41 - CMakeStuff/toolchains/apple-macport-toolchain.cmake | 29 + CMakeStuff/toolchains/mxe-toolchain-olivier.cmake | 7 CMakeStuff/toolchains/mxe-toolchain.cmake | 7 CMakeStuff/toolchains/unix-toolchain.cmake | 8 CMakeStuff/toolchains/win10-mingw64-toolchain.cmake | 25 debian/changelog | 33 + debian/control | 2 debian/ods2tsv.install | 3 debian/ods2tsv.manpages | 2 doc/ods2tsv.1 | 42 - doc/tsv2ods.1 | 22 src/CMakeLists.txt | 19 src/ods2csv.cpp | 10 src/odsstream/odsdocreader.cpp | 34 - src/odsstream/odsdocreader.h | 4 src/odsstream/reader/odscell.h | 7 src/odsstream/saxreader/qxmlstreamreadercontentxml.cpp | 334 +++++++++++++ src/odsstream/saxreader/qxmlstreamreadercontentxml.h | 65 ++ src/odsstream/saxreader/saxhandlercontentxml.cpp | 310 ------------ src/odsstream/saxreader/saxhandlercontentxml.h | 77 --- src/odsstream/tsvdirectorywriter.cpp | 63 +- src/odsstream/tsvdirectorywriter.h | 18 src/odsstream/tsvoutputstream.cpp | 10 src/odsstream/writer/structure/contentxml.cpp | 4 src/odsstream/ziptsvoutputstream.cpp | 148 +++++ src/odsstream/ziptsvoutputstream.h | 65 ++ src/tsv2ods.cpp | 8 test/CMakeLists.txt | 4 test/test_ods.cpp | 430 ++++++++++------- test/test_tsv.cpp | 67 ++ 33 files changed, 1238 insertions(+), 716 deletions(-) diff -Nru libodsstream-0.7.11/CMakeLists.txt libodsstream-0.8.4/CMakeLists.txt --- libodsstream-0.7.11/CMakeLists.txt 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/CMakeLists.txt 2022-10-28 00:27:44.000000000 +0000 @@ -13,11 +13,11 @@ project(${PROJECT} CXX C) set(LIBODSSTREAM_VERSION_MAJOR "0") -set(LIBODSSTREAM_VERSION_MINOR "7") -set(LIBODSSTREAM_VERSION_PATCH "11") +set(LIBODSSTREAM_VERSION_MINOR "8") +set(LIBODSSTREAM_VERSION_PATCH "4") set(LIBODSSTREAM_LIB_NAME "libodsstream") set(LIBODSSTREAM_VERSION "${LIBODSSTREAM_VERSION_MAJOR}.${LIBODSSTREAM_VERSION_MINOR}.${LIBODSSTREAM_VERSION_PATCH}") -set(VERSION 0.7.11) +set(VERSION 0.8.4) set(LIBODSSTREAM_LIB_VERSION ${LIBODSSTREAM_VERSION}) set(LIBODSSTREAM_LIB_SOVERSION ${LIBODSSTREAM_VERSION_MAJOR}) diff -Nru libodsstream-0.7.11/CMakeStuff/modules/FindQUAZIP.cmake libodsstream-0.8.4/CMakeStuff/modules/FindQUAZIP.cmake --- libodsstream-0.7.11/CMakeStuff/modules/FindQUAZIP.cmake 1970-01-01 00:00:00.000000000 +0000 +++ libodsstream-0.8.4/CMakeStuff/modules/FindQUAZIP.cmake 2022-10-28 00:27:44.000000000 +0000 @@ -0,0 +1,50 @@ +# QUAZIP_FOUND - QUAZIP library was found +# QUAZIP_INCLUDE_DIR - Path to QUAZIP include dir +# QUAZIP_INCLUDE_DIRS - Path to QUAZIP and zlib include dir (combined from QUAZIP_INCLUDE_DIR + ZLIB_INCLUDE_DIR) +# QUAZIP_LIBRARIES - List of QUAZIP libraries +# QUAZIP_ZLIB_INCLUDE_DIR - The include dir of zlib headers + + +IF (QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES) + # in cache already + SET(QUAZIP_FOUND TRUE) +ELSE (QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES) + IF (WIN32) + FIND_PATH(QUAZIP_LIBRARY_DIR + WIN32_DEBUG_POSTFIX d + NAMES libquazip.dll + HINTS "C:/Programme/" "C:/Program Files" + PATH_SUFFIXES QUAZIP/lib + ) + FIND_LIBRARY(QUAZIP_QT4_LIBRARIES NAMES libquazip.dll HINTS ${QUAZIP_LIBRARY_DIR}) + FIND_PATH(QUAZIP_INCLUDE_DIR NAMES quazip.h HINTS ${QUAZIP_LIBRARY_DIR}/../ PATH_SUFFIXES quazip) + FIND_PATH(QUAZIP_ZLIB_INCLUDE_DIR NAMES zlib.h) + ELSE(WIN32) + #FIND_PACKAGE(PkgConfig) + # pkg_check_modules(PC_QCA2 QUIET qca2) + #pkg_check_modules(PC_QUAZIP quazip) + FIND_LIBRARY(QUAZIP_QT5_LIBRARIES + WIN32_DEBUG_POSTFIX d + NAMES quazip-qt5 quazip5 + HINTS /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu + ) + SET(QUAZIP_LIBRARIES ${QUAZIP_QT5_LIBRARIES}) + FIND_PATH(QUAZIP_INCLUDE_DIR quazip.h + HINTS /usr/include /usr/local/include + PATH_SUFFIXES quazip quazip5 + ) + FIND_PATH(QUAZIP_ZLIB_INCLUDE_DIR zlib.h HINTS /usr/include /usr/local/include) + ENDIF (WIN32) + INCLUDE(FindPackageHandleStandardArgs) + SET(QUAZIP_INCLUDE_DIRS ${QUAZIP_INCLUDE_DIR} ${QUAZIP_ZLIB_INCLUDE_DIR}) + find_package_handle_standard_args(QUAZIP DEFAULT_MSG QUAZIP_LIBRARIES QUAZIP_INCLUDE_DIR QUAZIP_ZLIB_INCLUDE_DIR QUAZIP_INCLUDE_DIRS) +ENDIF (QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES) + +# Added by FRusconi to maintain code more easily. + +if(NOT TARGET QUAZIP::QUAZIP) + add_library(QUAZIP::QUAZIP UNKNOWN IMPORTED) + set_target_properties(QUAZIP::QUAZIP PROPERTIES + IMPORTED_LOCATION ${QUAZIP_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${QUAZIP_INCLUDE_DIR}) +endif() diff -Nru libodsstream-0.7.11/CMakeStuff/modules/FindQuaZip.cmake libodsstream-0.8.4/CMakeStuff/modules/FindQuaZip.cmake --- libodsstream-0.7.11/CMakeStuff/modules/FindQuaZip.cmake 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/CMakeStuff/modules/FindQuaZip.cmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -# QUAZIP_FOUND - QuaZip library was found -# QUAZIP_INCLUDE_DIR - Path to QuaZip include dir -# QUAZIP_INCLUDE_DIRS - Path to QuaZip and zlib include dir (combined from QUAZIP_INCLUDE_DIR + ZLIB_INCLUDE_DIR) -# QUAZIP_LIBRARIES - List of QuaZip libraries -# QUAZIP_ZLIB_INCLUDE_DIR - The include dir of zlib headers - - -IF (QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES) - # in cache already - SET(QUAZIP_FOUND TRUE) -ELSE (QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES) - IF (WIN32) - FIND_PATH(QUAZIP_LIBRARY_DIR - WIN32_DEBUG_POSTFIX d - NAMES libquazip.dll - HINTS "C:/Programme/" "C:/Program Files" - PATH_SUFFIXES QuaZip/lib - ) - FIND_LIBRARY(QUAZIP_QT4_LIBRARIES NAMES libquazip.dll HINTS ${QUAZIP_LIBRARY_DIR}) - FIND_PATH(QUAZIP_INCLUDE_DIR NAMES quazip.h HINTS ${QUAZIP_LIBRARY_DIR}/../ PATH_SUFFIXES quazip) - FIND_PATH(QUAZIP_ZLIB_INCLUDE_DIR NAMES zlib.h) - ELSE(WIN32) - #FIND_PACKAGE(PkgConfig) - # pkg_check_modules(PC_QCA2 QUIET qca2) - #pkg_check_modules(PC_QUAZIP quazip) - FIND_LIBRARY(QUAZIP_QT5_LIBRARIES - WIN32_DEBUG_POSTFIX d - NAMES quazip-qt5 quazip5 - HINTS /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu - ) - SET(QUAZIP_LIBRARIES ${QUAZIP_QT5_LIBRARIES}) - FIND_PATH(QUAZIP_INCLUDE_DIR quazip.h - HINTS /usr/include /usr/local/include - PATH_SUFFIXES quazip quazip5 - ) - FIND_PATH(QUAZIP_ZLIB_INCLUDE_DIR zlib.h HINTS /usr/include /usr/local/include) - ENDIF (WIN32) - INCLUDE(FindPackageHandleStandardArgs) - SET(QUAZIP_INCLUDE_DIRS ${QUAZIP_INCLUDE_DIR} ${QUAZIP_ZLIB_INCLUDE_DIR}) - find_package_handle_standard_args(QUAZIP DEFAULT_MSG QUAZIP_LIBRARIES QUAZIP_INCLUDE_DIR QUAZIP_ZLIB_INCLUDE_DIR QUAZIP_INCLUDE_DIRS) -ENDIF (QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES) diff -Nru libodsstream-0.7.11/CMakeStuff/toolchains/apple-macport-toolchain.cmake libodsstream-0.8.4/CMakeStuff/toolchains/apple-macport-toolchain.cmake --- libodsstream-0.7.11/CMakeStuff/toolchains/apple-macport-toolchain.cmake 1970-01-01 00:00:00.000000000 +0000 +++ libodsstream-0.8.4/CMakeStuff/toolchains/apple-macport-toolchain.cmake 2022-10-28 00:27:44.000000000 +0000 @@ -0,0 +1,29 @@ +message("APPLE macport environment") +message("Please run the configuration like this:") +message("cmake -DCMAKE_BUILD_TYPE=Debug ../development") + + +set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "/opt/local/include") +set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "/opt/local/lib") + + +set(HOME_DEVEL_DIR "/Users/rusconi/devel") + + +set(LINKER_FLAGS "${LINKER_FLAGS} -Wc++17-compat") + +set(CMAKE_MACOSX_RPATH 0) + + +find_package(ZLIB REQUIRED) + + +find_package(QuaZip QUIET) +if(NOT QUAZIP_FOUND) + message(STATUS "QuaZip not yet found. Searching for it.") + set(QuaZip_DIR ${CMAKE_MODULE_PATH}) + find_package(QuaZip REQUIRED) +endif() + + + diff -Nru libodsstream-0.7.11/CMakeStuff/toolchains/mxe-toolchain-olivier.cmake libodsstream-0.8.4/CMakeStuff/toolchains/mxe-toolchain-olivier.cmake --- libodsstream-0.7.11/CMakeStuff/toolchains/mxe-toolchain-olivier.cmake 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/CMakeStuff/toolchains/mxe-toolchain-olivier.cmake 2022-10-28 00:27:44.000000000 +0000 @@ -27,3 +27,10 @@ message(STATUS "QUAZIP_INCLUDE_DIR :${QUAZIP_INCLUDE_DIR}") + +if(NOT TARGET QUAZIP::QUAZIP) + add_library(QUAZIP::QUAZIP UNKNOWN IMPORTED) + set_target_properties(QUAZIP::QUAZIP PROPERTIES + IMPORTED_LOCATION ${QUAZIP_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${QUAZIP_INCLUDE_DIR}) +endif() diff -Nru libodsstream-0.7.11/CMakeStuff/toolchains/mxe-toolchain.cmake libodsstream-0.8.4/CMakeStuff/toolchains/mxe-toolchain.cmake --- libodsstream-0.7.11/CMakeStuff/toolchains/mxe-toolchain.cmake 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/CMakeStuff/toolchains/mxe-toolchain.cmake 2022-10-28 00:27:44.000000000 +0000 @@ -27,3 +27,10 @@ message(STATUS "QUAZIP_INCLUDE_DIR :${QUAZIP_INCLUDE_DIR}") + +if(NOT TARGET QUAZIP::QUAZIP) + add_library(QUAZIP::QUAZIP UNKNOWN IMPORTED) + set_target_properties(QUAZIP::QUAZIP PROPERTIES + IMPORTED_LOCATION ${QUAZIP_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${QUAZIP_INCLUDE_DIR}) +endif() diff -Nru libodsstream-0.7.11/CMakeStuff/toolchains/unix-toolchain.cmake libodsstream-0.8.4/CMakeStuff/toolchains/unix-toolchain.cmake --- libodsstream-0.7.11/CMakeStuff/toolchains/unix-toolchain.cmake 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/CMakeStuff/toolchains/unix-toolchain.cmake 2022-10-28 00:27:44.000000000 +0000 @@ -14,11 +14,11 @@ find_package(ZLIB REQUIRED) -find_package(QuaZip QUIET) +find_package(QUAZIP QUIET) if(NOT QUAZIP_FOUND) - message(STATUS "QuaZip not yet found. Searching for it.") - set(QuaZip_DIR ${CMAKE_MODULE_PATH}) - find_package(QuaZip REQUIRED) + message(STATUS "QUAZIP not yet found. Searching for it.") + set(QUAZIP_DIR ${CMAKE_MODULE_PATH}) + find_package(QUAZIP REQUIRED) endif() diff -Nru libodsstream-0.7.11/CMakeStuff/toolchains/win10-mingw64-toolchain.cmake libodsstream-0.8.4/CMakeStuff/toolchains/win10-mingw64-toolchain.cmake --- libodsstream-0.7.11/CMakeStuff/toolchains/win10-mingw64-toolchain.cmake 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/CMakeStuff/toolchains/win10-mingw64-toolchain.cmake 2022-10-28 00:27:44.000000000 +0000 @@ -8,17 +8,26 @@ message(STATUS "Building with WIN32 defined.") endif() +set(CMAKE_NO_SYSTEM_FROM_IMPORTED = 1) + +# Fix for the horrible bug of CMake that does not properly source the contents +# of the CMakeFiles/.dir/includes_CXX.rsp response file. This setting makes +# cmake not rely on that file but put all includes directly in the command line +# instead of referring to that response file. +set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 0) +# Exactly the same for libraries. +set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES 0) set(QUAZIP_FOUND 1) -set(QUAZIP_INCLUDE_DIR "${HOME_DEVEL_DIR}/quazip5/development") -set(QUAZIP_LIBRARIES "${HOME_DEVEL_DIR}/quazip5/build-area/mingw64/libquazip5.dll") -if(NOT TARGET QuaZip::QuaZip) - add_library(QuaZip::QuaZip UNKNOWN IMPORTED) - set_target_properties(QuaZip::QuaZip PROPERTIES - IMPORTED_LOCATION "${QUAZIP_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${QUAZIP_INCLUDE_DIR}") +set(QUAZIP_INCLUDE_DIR C:/msys64/mingw64/include/QuaZip-Qt5-1.3) +set(QUAZIP_LIBRARIES C:/msys64/mingw64/bin/libquazip1-qt5.dll) +if(NOT TARGET QUAZIP::QUAZIP) + add_library(QUAZIP::QUAZIP UNKNOWN IMPORTED) + set_target_properties(QUAZIP::QUAZIP PROPERTIES + IMPORTED_LOCATION ${QUAZIP_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${QUAZIP_INCLUDE_DIR}) endif() -message(STATUS "Found QUAZIP: ${QUAZIP_LIBRARIES}") +message(STATUS Found QUAZIP: ${QUAZIP_LIBRARIES}) find_package(ZLIB REQUIRED) diff -Nru libodsstream-0.7.11/debian/changelog libodsstream-0.8.4/debian/changelog --- libodsstream-0.7.11/debian/changelog 2021-01-05 10:27:07.000000000 +0000 +++ libodsstream-0.8.4/debian/changelog 2022-10-28 00:26:21.000000000 +0000 @@ -1,3 +1,36 @@ +libodsstream (0.8.4-1) bullseye; urgency=low + + * New upstream version. + + * Standards-Version: 4.6.1 (routine update). + + -- Filippo Rusconi Fri, 28 Oct 2022 02:26:21 +0200 + +libodsstream (0.8.3-1~bullseye+1) bullseye; urgency=medium + + * bug fix on ZipTsvOutputStream + + -- Olivier Langella Wed, 05 Oct 2022 10:38:55 +0200 + +libodsstream (0.8.2-1) unstable; urgency=low + + * Debian packaging: fix the erroneous distribution (see stanza below). + + -- Filippo Rusconi Mon, 11 Jul 2022 11:12:31 +0200 + +libodsstream (0.8.1-1) bullseye; urgency=low + + * Debian packaging. + + -- Filippo Rusconi Fri, 01 Jul 2022 10:06:37 +0200 + +libodsstream (0.8.0-1) bullseye; urgency=medium + + * fix for integer writing in TSV output + * new Zipped file tsv output ZipTsvOutputStream + + -- Olivier Langella Tue, 28 Jun 2022 11:06:54 +0200 + libodsstream (0.7.11-1) unstable; urgency=low * New upstream release. diff -Nru libodsstream-0.7.11/debian/control libodsstream-0.8.4/debian/control --- libodsstream-0.7.11/debian/control 2021-01-05 10:27:07.000000000 +0000 +++ libodsstream-0.8.4/debian/control 2022-10-28 00:26:21.000000000 +0000 @@ -11,7 +11,7 @@ qtbase5-dev, doxygen, catch2 -Standards-Version: 4.5.0 +Standards-Version: 4.6.1 Vcs-Browser: https://salsa.debian.org/debichem-team/libodsstream Vcs-Git: https://salsa.debian.org/debichem-team/libodsstream.git Homepage: http://pappso.inrae.fr/bioinfo diff -Nru libodsstream-0.7.11/debian/ods2tsv.install libodsstream-0.8.4/debian/ods2tsv.install --- libodsstream-0.7.11/debian/ods2tsv.install 2021-01-05 10:27:07.000000000 +0000 +++ libodsstream-0.8.4/debian/ods2tsv.install 2022-10-28 00:26:21.000000000 +0000 @@ -1 +1,2 @@ -usr/bin/ods2tsv \ No newline at end of file +usr/bin/ods2tsv +usr/bin/tsv2ods diff -Nru libodsstream-0.7.11/debian/ods2tsv.manpages libodsstream-0.8.4/debian/ods2tsv.manpages --- libodsstream-0.7.11/debian/ods2tsv.manpages 2021-01-05 10:27:07.000000000 +0000 +++ libodsstream-0.8.4/debian/ods2tsv.manpages 2022-10-28 00:26:21.000000000 +0000 @@ -1 +1,3 @@ doc/ods2tsv.1 +doc/tsv2ods.1 + diff -Nru libodsstream-0.7.11/doc/ods2tsv.1 libodsstream-0.8.4/doc/ods2tsv.1 --- libodsstream-0.7.11/doc/ods2tsv.1 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/doc/ods2tsv.1 2022-10-28 00:27:44.000000000 +0000 @@ -1,21 +1,21 @@ -.TH ods2tsv 1 "5 dec 2017" -.SH NAME -ods2tsv - convert ods to tsv files -.SH SYNOPSIS -.B ods2tsv [-v] [-h] -.I files -.B ... -.SH DESCRIPTION -.B ods2tsv -command line utility to convert libreoffice open document spreadsheet files (ods) -into directories containing tabulated separated values files (tsv) for each spreadsheet. -.SH OPTIONS -.IP -h -display help message. -.IP -v -display version number. -.SH "SEE ALSO" -.B http://pappso.inra.fr/bioinfo -.SH AUTHOR -This program was written by Olivier Langella. -This manual page was written by Olivier Langella . +.TH ods2tsv 1 "5 dec 2017" +.SH NAME +ods2tsv - convert ods to tsv files +.SH SYNOPSIS +.B ods2tsv [-v] [-h] +.I [ file_name [...] ] +.SH DESCRIPTION +The +.B ods2tsv +command line utility converts libreoffice open document spreadsheet (ods) files +into directories containing tabulation-separated-value (tsv) files for each +spreadsheet in the original ods file. +.SH OPTIONS +.IP -h +display help message. +.IP -v +display version number. +.SH "SEE ALSO" +.B http://pappso.inra.fr/bioinfo +.SH AUTHOR +The program and this man page were written by Olivier Langella . diff -Nru libodsstream-0.7.11/doc/tsv2ods.1 libodsstream-0.8.4/doc/tsv2ods.1 --- libodsstream-0.7.11/doc/tsv2ods.1 1970-01-01 00:00:00.000000000 +0000 +++ libodsstream-0.8.4/doc/tsv2ods.1 2022-10-28 00:27:44.000000000 +0000 @@ -0,0 +1,22 @@ +.TH tsv2ods 1 "1 july 2022" +.SH NAME +tsv2ods - convert tsv files to ods files +.SH SYNOPSIS +.B tsv2ods [-v] [-h] +.I [ file_name [...] ] +.SH DESCRIPTION +The +.B tsv2ods +command line utility converts tabulation-separated-value (tsv) files to +libreoffice open document spreadsheet (ods) files. Each file passed to the +command line will be converted into a new file. +.SH OPTIONS +.IP -h +display help message. +.IP -v +display version number. +.SH "SEE ALSO" +.B http://pappso.inra.fr/bioinfo +.SH AUTHOR +This program was written by Olivier Langella . +This manual page was written by Filippo Rusconi . diff -Nru libodsstream-0.7.11/src/CMakeLists.txt libodsstream-0.8.4/src/CMakeLists.txt --- libodsstream-0.7.11/src/CMakeLists.txt 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/CMakeLists.txt 2022-10-28 00:27:44.000000000 +0000 @@ -4,7 +4,7 @@ set(CPP_FILES odsstream/reader/odscell.cpp odsstream/odsexception.h - odsstream/saxreader/saxhandlercontentxml.cpp + odsstream/saxreader/qxmlstreamreadercontentxml.cpp odsstream/odsdocreader.cpp odsstream/writer/options/odscolorscale.cpp odsstream/writer/options/odstablecellstyle.cpp @@ -20,6 +20,7 @@ odsstream/tsvdirectorywriter.cpp odsstream/tsvoutputstream.cpp odsstream/tsvreader.cpp + odsstream/ziptsvoutputstream.cpp ) @@ -37,16 +38,14 @@ configure_file (${CMAKE_SOURCE_DIR}/src/config.h.cmake ${CMAKE_SOURCE_DIR}/src/config.h) message ("LIBODSSTREAM_LIB_SOVERSION: ${LIBODSSTREAM_LIB_SOVERSION}") -#qt5-default qtbase5-dev -find_package( Qt5Core REQUIRED ) -find_package( Qt5Xml REQUIRED ) -find_package( Qt5Gui REQUIRED ) + +find_package(Qt5 COMPONENTS Gui Xml REQUIRED) # Build the static lib add_library(odsstream-static STATIC ${CPP_FILES}) target_include_directories (odsstream-static PUBLIC - ${QUAZIP_INCLUDE_DIR} + QUAZIP::QUAZIP ) set_target_properties(odsstream-static @@ -55,18 +54,17 @@ ) target_link_libraries(odsstream-static - Qt5::Core Qt5::Xml Qt5::Gui ZLIB::ZLIB - ${QUAZIP_LIBRARIES} + QUAZIP::QUAZIP ) # Build the shared lib add_library(odsstream-shared SHARED ${CPP_FILES}) target_include_directories (odsstream-shared PUBLIC - ${QUAZIP_INCLUDE_DIR} + QUAZIP::QUAZIP ) set_target_properties(odsstream-shared PROPERTIES @@ -77,11 +75,10 @@ target_link_libraries(odsstream-shared - Qt5::Core Qt5::Xml Qt5::Gui ZLIB::ZLIB - ${QUAZIP_LIBRARIES} + QUAZIP::QUAZIP ) diff -Nru libodsstream-0.7.11/src/ods2csv.cpp libodsstream-0.8.4/src/ods2csv.cpp --- libodsstream-0.7.11/src/ods2csv.cpp 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/ods2csv.cpp 2022-10-28 00:27:44.000000000 +0000 @@ -300,7 +300,7 @@ handler.setSeparator(separator); handler.extractSheet(sheetname); handler.setQuoteStrings(parser.isSet(quoteStringsOption)); - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__; + qDebug(); if(directory.isEmpty()) { handler.setOutputStream(outputStream); @@ -341,8 +341,8 @@ { qDebug(); errorStream << "Oops! an error occurred in Ods2Csv. Don't Panic :" - << endl; - errorStream << error.qwhat() << endl; + << Qt::endl; + errorStream << error.qwhat() << Qt::endl; exit(1); app->exit(1); } @@ -351,8 +351,8 @@ { qDebug(); errorStream << "Oops! an error occurred in Ods2Csv. Don't Panic :" - << endl; - errorStream << error.what() << endl; + << Qt::endl; + errorStream << error.what() << Qt::endl; exit(1); app->exit(1); } diff -Nru libodsstream-0.7.11/src/odsstream/odsdocreader.cpp libodsstream-0.8.4/src/odsstream/odsdocreader.cpp --- libodsstream-0.7.11/src/odsstream/odsdocreader.cpp 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/odsdocreader.cpp 2022-10-28 00:27:44.000000000 +0000 @@ -21,7 +21,8 @@ #include "odsexception.h" #include #include -#include "./saxreader/saxhandlercontentxml.h" +#include "saxreader/qxmlstreamreadercontentxml.h" +//#include "./saxreader/saxhandlercontentxml.h" #include OdsDocReader::OdsDocReader(OdsDocHandlerInterface &handler) : _handler(handler) @@ -85,30 +86,25 @@ if(_p_quaZip->getCurrentFileName() == "content.xml") { - SaxHandlerContentXml parser(*this); - - QXmlSimpleReader reader; - reader.setContentHandler(&parser); - reader.setErrorHandler(&parser); - - qDebug() << " Parsing XML input file '" - << _p_quaZip->getCurrentFileName() << "'" << endl; QuaZipFile zip_file(_p_quaZip); - - QXmlInputSource xmlInputSource(&zip_file); - - if(reader.parse(xmlInputSource)) + QXmlStreamReaderContentXml content_reader(*this); + zip_file.open(QIODevice::ReadOnly); + content_reader.setDevice(&zip_file); + content_reader.setNamespaceProcessing(true); + content_reader.read(); + if(content_reader.error()) { - } - else - { - qDebug() << " error " << parser.errorString(); + + zip_file.close(); + qDebug() << " error " << content_reader.errorString(); throw OdsException(QObject::tr("error reading ODS input file :\n") - .append(parser.errorString())); + .append(content_reader.errorString())); } qDebug() << " contentXml : DONE on file '" - << _p_quaZip->getCurrentFileName() << "'" << endl; + << _p_quaZip->getCurrentFileName() << "'"; + + zip_file.close(); } } if(_p_quaZip != nullptr) diff -Nru libodsstream-0.7.11/src/odsstream/odsdocreader.h libodsstream-0.8.4/src/odsstream/odsdocreader.h --- libodsstream-0.7.11/src/odsstream/odsdocreader.h 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/odsdocreader.h 2022-10-28 00:27:44.000000000 +0000 @@ -24,11 +24,11 @@ #include "reader/odscell.h" #include "odsdochandlerinterface.h" -class SaxHandlerContentXml; +class QXmlStreamReaderContentXml; class OdsDocReader { - friend SaxHandlerContentXml; + friend QXmlStreamReaderContentXml; public: /** diff -Nru libodsstream-0.7.11/src/odsstream/reader/odscell.h libodsstream-0.8.4/src/odsstream/reader/odscell.h --- libodsstream-0.7.11/src/odsstream/reader/odscell.h 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/reader/odscell.h 2022-10-28 00:27:44.000000000 +0000 @@ -22,12 +22,12 @@ #include #include //#include -class SaxHandlerContentXml; +class QXmlStreamReaderContentXml; class TsvReader; class OdsCell { - friend SaxHandlerContentXml; + friend QXmlStreamReaderContentXml; friend TsvReader; public: @@ -61,6 +61,3 @@ bool _bool_value; bool _is_empty; }; - - - diff -Nru libodsstream-0.7.11/src/odsstream/saxreader/qxmlstreamreadercontentxml.cpp libodsstream-0.8.4/src/odsstream/saxreader/qxmlstreamreadercontentxml.cpp --- libodsstream-0.7.11/src/odsstream/saxreader/qxmlstreamreadercontentxml.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/saxreader/qxmlstreamreadercontentxml.cpp 2022-10-28 00:27:44.000000000 +0000 @@ -0,0 +1,334 @@ +/** + * \file src/saxreader/qxmlstreamreadercontentxml.h + * \date 28/4/2022 + * \author Olivier Langella + * \brief ODS content XML parser + */ + +/******************************************************************************* + * Copyright (c) 2022 Olivier Langella . + * + * This file is part of libodsstream. + * + * libodsstream is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libodsstream is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with libodsstream. If not, see . + * + ******************************************************************************/ + +#include "qxmlstreamreadercontentxml.h" +#include + +QXmlStreamReaderContentXml::QXmlStreamReaderContentXml(OdsDocReader &ods_reader) + : m_odsReader(ods_reader) +{ +} + +QXmlStreamReaderContentXml::~QXmlStreamReaderContentXml() +{ +} + +bool +QXmlStreamReaderContentXml::read() +{ + + if(readNextStartElement()) + { + qDebug() << qualifiedName(); + /* + * + * */ + if(qualifiedName() == "office:document-content") + { + // + + //30 + while(readNextStartElement()) + { + qDebug() << qualifiedName(); + if(qualifiedName() == "office:body") + { + + // + while(readNextStartElement()) + { + qDebug() << qualifiedName(); + if(qualifiedName() == "office:spreadsheet") + { + // + qDebug() << qualifiedName(); + readTable(); + } + else + { + skipCurrentElement(); + } + } + } + else + { + skipCurrentElement(); + } + } + } + else + { + raiseError(QObject::tr("Not an OASIS content XML")); + skipCurrentElement(); + } + } + return !error(); +} + + +bool +QXmlStreamReaderContentXml::readTable() +{ + + qDebug() << qualifiedName(); + while(readNextStartElement()) + { + + qDebug() << qualifiedName(); + if(qualifiedName() == "table:table") + { + QString spread_sheet_name = + attributes().value("table:name").toString(); + if(spread_sheet_name.isEmpty()) + { + //_errorStr = QObject::tr("spread_sheet_name is + // empty."); + // return false; + } + m_odsReader.startSheet(spread_sheet_name); + + readTableRow(); + } + else + { + // raiseError(QObject::tr("Not an OASIS content XML")); + skipCurrentElement(); + } + } + + return !error(); +} + + +bool +QXmlStreamReaderContentXml::readTableRow() +{ + + // + qDebug() << qualifiedName(); + while(readNextStartElement()) + { + + qDebug() << qualifiedName(); + if(qualifiedName() == "table:table-row") + { + m_odsReader.startLine(); + readTableLine(); + m_odsReader.endLine(); + } + else + { + // raiseError(QObject::tr("Not an OASIS content XML")); + skipCurrentElement(); + } + } + + return !error(); +} + + +bool +QXmlStreamReaderContentXml::readTableLine() +{ + + // + // truc + // + qDebug() << qualifiedName(); + while(readNextStartElement()) + { + + qDebug() << qualifiedName(); + if(qualifiedName() == "table:table-cell") + { + + m_numberColumnsRepeated = 1; + m_currentCell.setOfficeValueType( + attributes().value("office:value-type").toString()); + if(m_currentCell.getOfficeValueType().isEmpty()) + { + m_currentCell.setOfficeValueType( + attributes().value("calcext:value-type").toString()); + } + + + // table:number-columns-repeated="2" + // N.A. + + if(!attributes() + .value("table:number-columns-repeated") + .toString() + .isEmpty()) + { + m_numberColumnsRepeated = + attributes().value("table:number-columns-repeated").toUInt(); + // System.out.println("coucou " + numberColumnsRepeated); + } + + if(!m_currentCell.getOfficeValueType().isEmpty()) + { + + QString dateStr = + attributes().value("office:date-value").toString(); + if(!dateStr.isEmpty()) + { + // qDebug() << "dateStr " << dateStr; + QDateTime date(QDateTime::fromString(dateStr, Qt::ISODate)); + // date.fromString(dateStr,Qt::ISODate); + // qDebug() << " date.fromString " << + // date.toString(Qt::ISODate); + m_currentCell.setDateValue(date); + } + + + if(m_currentCell.getOfficeValueType() == "float") + { + /* + * writer.writeAttribute("office", + * hashNamespaceURI.get("office"), "value-type", + * "float"); writer.writeAttribute("office", + * hashNamespaceURI.get("office"), "value", value); + */ + QString valueStr = + attributes().value("office:value").toString(); + if(valueStr.isEmpty()) + { + raiseError(QObject::tr("office:value is null")); + } + m_currentCell.setValueDouble(valueStr.toDouble()); + } + else if(m_currentCell.getOfficeValueType() == "boolean") + { + // office:boolean-value="false" calcext:value-type="boolean" + // office:value-type="boolean" + QString valueStr = + attributes().value("office:boolean-value").toString(); + m_currentCell.setValueBoolean(false); + if(valueStr.isEmpty()) + { + m_currentCell.setValueBoolean(false); + } + else if(valueStr == "true") + { + m_currentCell.setValueBoolean(true); + } + } + } + + // content cell + + readCellContent(); + + // skipCurrentElement(); + + // end table cell + while(m_numberColumnsRepeated > 0) + { + m_odsReader.setInsideCell(m_currentCell); + m_numberColumnsRepeated--; + } + } + + + else + { + // raiseError(QObject::tr("Not an OASIS content XML")); + skipCurrentElement(); + } + } + + return !error(); +} + + +bool +QXmlStreamReaderContentXml::readCellContent() +{ + + while(readNextStartElement()) + { + + qDebug() << qualifiedName(); + if(qualifiedName() == "office:annotation") + { + } + else if(qualifiedName() == "text:p") + { + readTextP(); + } + else + { + raiseError( + QObject::tr("Not an OASIS content XML %1").arg(qualifiedName())); + } + } + + + return !error(); +} + + +bool +QXmlStreamReaderContentXml::readTextP() +{ + m_currentCell._string_value.append( + readElementText(QXmlStreamReader::IncludeChildElements)); + + return !error(); +} diff -Nru libodsstream-0.7.11/src/odsstream/saxreader/qxmlstreamreadercontentxml.h libodsstream-0.8.4/src/odsstream/saxreader/qxmlstreamreadercontentxml.h --- libodsstream-0.7.11/src/odsstream/saxreader/qxmlstreamreadercontentxml.h 1970-01-01 00:00:00.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/saxreader/qxmlstreamreadercontentxml.h 2022-10-28 00:27:44.000000000 +0000 @@ -0,0 +1,65 @@ +/** + * \file src/saxreader/qxmlstreamreadercontentxml.h + * \date 28/4/2022 + * \author Olivier Langella + * \brief ODS content XML parser + */ + +/******************************************************************************* + * Copyright (c) 2022 Olivier Langella . + * + * This file is part of libodsstream. + * + * libodsstream is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libodsstream is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with libodsstream. If not, see . + * + ******************************************************************************/ + + +#pragma once + +#include +#include "../odsdocreader.h" + +/** + * @todo write docs + */ +class QXmlStreamReaderContentXml : public QXmlStreamReader +{ + public: + /** + * @todo write docs + */ + QXmlStreamReaderContentXml(OdsDocReader &ods_reader); + + /** + * @todo write docs + */ + virtual ~QXmlStreamReaderContentXml(); + + bool read(); + + private: + bool readTable(); + bool readTableRow(); + bool readTableLine(); + bool readCellContent(); + bool readTextP(); + + private: + OdsDocReader &m_odsReader; + + OdsCell m_currentCell; + + uint m_numberColumnsRepeated; +}; diff -Nru libodsstream-0.7.11/src/odsstream/saxreader/saxhandlercontentxml.cpp libodsstream-0.8.4/src/odsstream/saxreader/saxhandlercontentxml.cpp --- libodsstream-0.7.11/src/odsstream/saxreader/saxhandlercontentxml.cpp 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/saxreader/saxhandlercontentxml.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,310 +0,0 @@ -/* - libodsstream is a library to read and write ODS documents as streams - Copyright (C) 2013 Olivier Langella - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . - -*/ - -#include "saxhandlercontentxml.h" -#include - -SaxHandlerContentXml::SaxHandlerContentXml(OdsDocReader &ods_reader) - : _ods_reader(ods_reader) -{ - qDebug() << "SaxHandlerContentXml::SaxHandlerContentXml begin "; -} - -SaxHandlerContentXml::~SaxHandlerContentXml() -{ -} - - -bool -SaxHandlerContentXml::startElement([[maybe_unused]] const QString &namespaceURI, - [[maybe_unused]] const QString &localName, - const QString &qName, - const QXmlAttributes &attributes) -{ - qDebug() << "SaxHandlerContentXml::startElement " << qName; - _tag_stack.push_back(qName); - bool is_ok = true; - - // startElement_rawdata - if(qName == "table:table") - { - // is_ok = startElement_rawdata(attributes); - is_ok = start_element_table(attributes); - } - else if(qName == "table:table-row") - { - is_ok = start_element_table_row(attributes); - } - else if(qName == "table:table-cell") - { - is_ok = start_element_table_cell(attributes); - } - //N.A. - - if(!attributes.value("table:number-columns-repeated").isEmpty()) - { - _number_columns_repeated = - attributes.value("table:number-columns-repeated").toUInt(); - // System.out.println("coucou " + numberColumnsRepeated); - } - - if(!_current_cell.getOfficeValueType().isEmpty()) - { - - QString dateStr = attributes.value("office:date-value"); - if(!dateStr.isEmpty()) - { - // qDebug() << "dateStr " << dateStr; - QDateTime date(QDateTime::fromString(dateStr, Qt::ISODate)); - // date.fromString(dateStr,Qt::ISODate); - // qDebug() << " date.fromString " << date.toString(Qt::ISODate); - _current_cell.setDateValue(date); - } - - - if(_current_cell.getOfficeValueType() == "float") - { - /* - * writer.writeAttribute("office", - * hashNamespaceURI.get("office"), "value-type", - * "float"); writer.writeAttribute("office", - * hashNamespaceURI.get("office"), "value", value); - */ - QString valueStr = attributes.value("office:value"); - if(valueStr.isEmpty()) - { - _errorStr = QObject::tr("office:value is null"); - return false; - } - _current_cell.setValueDouble(valueStr.toDouble()); - } - else if(_current_cell.getOfficeValueType() == "boolean") - { - // office:boolean-value="false" calcext:value-type="boolean" - // office:value-type="boolean" - QString valueStr = attributes.value("office:boolean-value"); - _current_cell.setValueBoolean(false); - if(valueStr.isEmpty()) - { - _current_cell.setValueBoolean(false); - } - else if(valueStr == "true") - { - _current_cell.setValueBoolean(true); - } - } - } - return true; -} - - -bool -SaxHandlerContentXml::end_element_table_cell() -{ - - while(_number_columns_repeated > 0) - { - _ods_reader.setInsideCell(_current_cell); - _number_columns_repeated--; - } - return true; -} - - -bool -SaxHandlerContentXml::characters(const QString &str) -{ - _currentText += str; - return true; -} - -bool -SaxHandlerContentXml::fatalError(const QXmlParseException &exception) -{ - _errorStr = QObject::tr( - "Parse error at line %1, column %2:\n" - "%3") - .arg(exception.lineNumber()) - .arg(exception.columnNumber()) - .arg(exception.message()); - return false; -} - -QString -SaxHandlerContentXml::errorString() const -{ - return _errorStr; -} - -bool -SaxHandlerContentXml::endDocument() -{ - return true; -} - -bool -SaxHandlerContentXml::start_element_office_annotation( - [[maybe_unused ]] const QXmlAttributes &attributes) -{ - _is_annotation = true; - return true; -} - -bool -SaxHandlerContentXml::end_element_office_annotation() -{ - _is_annotation = false; - return true; -} diff -Nru libodsstream-0.7.11/src/odsstream/saxreader/saxhandlercontentxml.h libodsstream-0.8.4/src/odsstream/saxreader/saxhandlercontentxml.h --- libodsstream-0.7.11/src/odsstream/saxreader/saxhandlercontentxml.h 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/saxreader/saxhandlercontentxml.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -/* - libodsstream is a library to read and write ODS documents as streams - Copyright (C) 2013 Olivier Langella - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . - -*/ - -#pragma once - -#include -#include -#include -#include "../odsdocreader.h" - -class SaxHandlerContentXml : public QXmlDefaultHandler -{ - - public: - SaxHandlerContentXml(OdsDocReader &); - virtual ~SaxHandlerContentXml(); - - bool startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &attributes); - - bool endElement(const QString &namespaceURI, - const QString &localName, - const QString &qName); - - bool endDocument(); - - bool characters(const QString &str); - - bool fatalError(const QXmlParseException &exception); - - QString errorString() const; - - private: - bool start_element_table_row(const QXmlAttributes &attributes) const; - bool end_element_table_row() const; - bool start_element_table(const QXmlAttributes &attributes) const; - bool end_element_table() const; - bool start_element_table_cell(const QXmlAttributes &attributes); - bool end_element_table_cell(); - bool start_element_p(const QXmlAttributes &attributes); - bool end_element_p(); - bool end_element_a(); - bool start_element_office_annotation(const QXmlAttributes &attributes); - bool end_element_office_annotation(); - /// the error description variable - QString _errorStr; - - QString _currentText; - - std::vector _tag_stack; - - OdsDocReader &_ods_reader; - - uint _number_columns_repeated; - - OdsCell _current_cell; - - bool _is_annotation = false; -}; diff -Nru libodsstream-0.7.11/src/odsstream/tsvdirectorywriter.cpp libodsstream-0.8.4/src/odsstream/tsvdirectorywriter.cpp --- libodsstream-0.7.11/src/odsstream/tsvdirectorywriter.cpp 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/tsvdirectorywriter.cpp 2022-10-28 00:27:44.000000000 +0000 @@ -71,20 +71,20 @@ void TsvDirectoryWriter::close() { - if(_p_otxtstream != nullptr) + if(mpa_otxtstream != nullptr) { - *_p_otxtstream << _end_of_line; - _p_otxtstream->flush(); + *mpa_otxtstream << _end_of_line; + mpa_otxtstream->flush(); //_p_otxtstream->close(); - delete(_p_otxtstream); - _p_otxtstream = nullptr; + delete(mpa_otxtstream); + mpa_otxtstream = nullptr; } - if(_p_ofile != nullptr) + if(mpa_ofile != nullptr) { - _p_ofile->flush(); - _p_ofile->close(); - delete(_p_ofile); - _p_ofile = nullptr; + mpa_ofile->flush(); + mpa_ofile->close(); + delete(mpa_ofile); + mpa_ofile = nullptr; } } @@ -94,21 +94,28 @@ close(); // qDebug() << " TsvDirectoryWriter::writeSheet " << // _directory.absolutePath(); - _p_ofile = new QFile(QString(_directory.absolutePath()) - .append("/") - .append(sheetName) - .append(this->_file_extension)); + mpa_ofile = new QFile(QString(_directory.absolutePath()) + .append("/") + .append(sheetName) + .append(this->_file_extension)); // qDebug() << " TsvDirectoryWriter::writeSheet " << // QFileInfo(*_p_ofile).absoluteFilePath(); - if(_p_ofile->open(QIODevice::WriteOnly)) + if(mpa_ofile->open(QIODevice::WriteOnly)) { - _p_otxtstream = new QTextStream(_p_ofile); + mpa_otxtstream = new QTextStream(mpa_ofile); } else { throw OdsException(QString("unable to write into file %1") - .arg(QFileInfo(*_p_ofile).absoluteFilePath())); + .arg(QFileInfo(*mpa_ofile).absoluteFilePath())); } + initializeSheet(); +} + +void +TsvDirectoryWriter::initializeSheet() +{ + _tableRowStart = true; _startingSheet = true; } @@ -117,7 +124,7 @@ void TsvDirectoryWriter::ensureSheet() { - if(_p_otxtstream == nullptr) + if(mpa_otxtstream == nullptr) { writeSheet("default"); } @@ -132,13 +139,13 @@ } else { - *_p_otxtstream << _end_of_line; + *mpa_otxtstream << _end_of_line; } _startingSheet = false; _tableRowStart = true; if(m_flushLines) - _p_otxtstream->flush(); + mpa_otxtstream->flush(); } void TsvDirectoryWriter::writeCell(const char *cstr) @@ -151,13 +158,13 @@ ensureSheet(); if(!_tableRowStart) { - *_p_otxtstream << m_separator; + *mpa_otxtstream << m_separator; } _tableRowStart = false; if(m_quoteStrings) { - *_p_otxtstream << QString("\"%1\"").arg( + *mpa_otxtstream << QString("\"%1\"").arg( QString(text).replace("\"", "\"\"")); } else @@ -165,12 +172,12 @@ if(text.contains(_end_of_line) || text.contains(m_separator) || text.contains("\"")) { - *_p_otxtstream << QString("\"%1\"").arg( + *mpa_otxtstream << QString("\"%1\"").arg( QString(text).replace("\"", "\"\"")); } else { - *_p_otxtstream << text; + *mpa_otxtstream << text; } } @@ -183,10 +190,10 @@ ensureSheet(); if(!_tableRowStart) { - *_p_otxtstream << m_separator; + *mpa_otxtstream << m_separator; } _tableRowStart = false; - *_p_otxtstream << text; + *mpa_otxtstream << text; _startingSheet = false; } void @@ -195,7 +202,7 @@ ensureSheet(); if(!_tableRowStart) { - *_p_otxtstream << m_separator; + *mpa_otxtstream << m_separator; } _tableRowStart = false; _startingSheet = false; @@ -203,7 +210,7 @@ void TsvDirectoryWriter::writeCell(std::size_t num) { - writeCell(QString::number(num, 'g', 10)); + writeRawCell(QString::number(num, 'g', 10)); } void TsvDirectoryWriter::writeCell(int num) diff -Nru libodsstream-0.7.11/src/odsstream/tsvdirectorywriter.h libodsstream-0.8.4/src/odsstream/tsvdirectorywriter.h --- libodsstream-0.7.11/src/odsstream/tsvdirectorywriter.h 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/tsvdirectorywriter.h 2022-10-28 00:27:44.000000000 +0000 @@ -36,9 +36,9 @@ virtual ~TsvDirectoryWriter(); - void close() override; + virtual void close() override; - void writeSheet(const QString &sheetName) override; + virtual void writeSheet(const QString &sheetName) override; void writeLine() override; void writeCell(const char *) override; void writeCell(const QString &) override; @@ -97,10 +97,12 @@ protected: TsvDirectoryWriter(); void writeRawCell(const QString &text); + void initializeSheet(); + protected: QString m_separator = "\t"; QString _end_of_line = "\n"; - QTextStream *_p_otxtstream = nullptr; + QTextStream *mpa_otxtstream = nullptr; unsigned int numFloatPrecision = 12; private: @@ -108,12 +110,12 @@ QString _file_extension = ".tsv"; + bool m_quoteStrings = false; + bool m_flushLines = false; + TsvSeparator m_tsvSeparatorEnum = TsvSeparator::tab; + void ensureSheet(); bool _tableRowStart = true; bool _startingSheet = false; - bool m_quoteStrings = false; - bool m_flushLines = false; - TsvSeparator m_tsvSeparatorEnum = TsvSeparator::tab; - QFile *_p_ofile = nullptr; - void ensureSheet(); + QFile *mpa_ofile = nullptr; }; diff -Nru libodsstream-0.7.11/src/odsstream/tsvoutputstream.cpp libodsstream-0.8.4/src/odsstream/tsvoutputstream.cpp --- libodsstream-0.7.11/src/odsstream/tsvoutputstream.cpp 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/tsvoutputstream.cpp 2022-10-28 00:27:44.000000000 +0000 @@ -21,19 +21,19 @@ TsvOutputStream::TsvOutputStream(QTextStream &otxtstream) : TsvDirectoryWriter() { - _p_otxtstream = &otxtstream; + mpa_otxtstream = &otxtstream; } TsvOutputStream::~TsvOutputStream() { // close(); - _p_otxtstream = nullptr; + mpa_otxtstream = nullptr; } void TsvOutputStream::close() { - _p_otxtstream->flush(); + mpa_otxtstream->flush(); } void @@ -47,6 +47,6 @@ { if(_no_sheet_name) return; - *_p_otxtstream << _end_of_line << _end_of_line << "**** " << sheetName - << " ****" << _end_of_line; + *mpa_otxtstream << _end_of_line << _end_of_line << "**** " << sheetName + << " ****" << _end_of_line; } diff -Nru libodsstream-0.7.11/src/odsstream/writer/structure/contentxml.cpp libodsstream-0.8.4/src/odsstream/writer/structure/contentxml.cpp --- libodsstream-0.7.11/src/odsstream/writer/structure/contentxml.cpp 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/writer/structure/contentxml.cpp 2022-10-28 00:27:44.000000000 +0000 @@ -788,9 +788,7 @@ ContentXml::writeCell(const QDate &date, const QString &annotation) { - QDateTime dateTime(date); - - writeCell(dateTime, annotation); + writeCell(date.startOfDay(), annotation); } void diff -Nru libodsstream-0.7.11/src/odsstream/ziptsvoutputstream.cpp libodsstream-0.8.4/src/odsstream/ziptsvoutputstream.cpp --- libodsstream-0.7.11/src/odsstream/ziptsvoutputstream.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/ziptsvoutputstream.cpp 2022-10-28 00:27:44.000000000 +0000 @@ -0,0 +1,148 @@ +/** + * \file src/ziptsvoutputstream.cpp + * \date 27/6/2022 + * \author Olivier Langella + * \brief write TSV files in a zip archive + */ + +/******************************************************************************* + * Copyright (c) 2022 Olivier Langella . + * + * This file is part of libodsstream. + * + * libodsstream is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libodsstream is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with libodsstream. If not, see . + * + ******************************************************************************/ + +#include "ziptsvoutputstream.h" +#include "odsexception.h" +#include +#include +#include + +ZipTsvOutputStream::ZipTsvOutputStream(const QString &zipfilename) + : TsvDirectoryWriter() +{ + + qDebug(); + mpa_fileZipArchive = new QFile(zipfilename); + + if(mpa_fileZipArchive->open(QIODevice::WriteOnly)) + { + } + else + { + throw OdsException( + QString("unable to write into ZIP file %1") + .arg(QFileInfo(*mpa_fileZipArchive).absoluteFilePath())); + } + + qDebug(); + mpa_quaZip = new QuaZip(mpa_fileZipArchive); + bool open_ok = mpa_quaZip->open(QuaZip::mdCreate); + + if(open_ok == false) + { + throw OdsException(QObject::tr("error opening ZIP file.")); + } + + //_p_writer = new QXmlStreamWriter(&outFile); + qDebug(); +} + + +ZipTsvOutputStream::~ZipTsvOutputStream() +{ + qDebug(); + closeCurrentZipSheet(); + close(); + qDebug(); +} + +void +ZipTsvOutputStream::close() +{ + + qDebug(); + + TsvDirectoryWriter::close(); + closeCurrentZipSheet(); + if(mpa_quaZip != nullptr) + { + qDebug(); + mpa_quaZip->close(); + delete mpa_quaZip; + mpa_quaZip = nullptr; + } + if(mpa_fileZipArchive != nullptr) + { + qDebug(); + mpa_fileZipArchive->close(); + delete mpa_fileZipArchive; + mpa_fileZipArchive = nullptr; + } + qDebug(); +} + + +void +ZipTsvOutputStream::closeCurrentZipSheet() +{ + + qDebug(); + if(mpa_outFileInZip != nullptr) + { + qDebug(); + mpa_outFileInZip->close(); + qDebug(); + delete mpa_outFileInZip; + mpa_outFileInZip = nullptr; + qDebug(); + } + qDebug(); +} + + +void +ZipTsvOutputStream::writeSheet(const QString &sheetName) +{ + + qDebug(); + closeCurrentZipSheet(); + if(mpa_outFileInZip == nullptr) + { + mpa_outFileInZip = new QuaZipFile(mpa_quaZip); + QuaZipNewInfo info(QString("%1.tsv").arg(sheetName)); + info.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner | + QFileDevice::ReadGroup); + + if(mpa_outFileInZip->open(QIODevice::WriteOnly, info)) + { + mpa_otxtstream = new QTextStream(mpa_outFileInZip); + } + else + { + throw OdsException( + QString("unable to write into file %1 new sheet %2") + .arg(QFileInfo(*mpa_fileZipArchive).absoluteFilePath()) + .arg(sheetName)); + } + } + else + { + throw OdsException(QString("mpa_outFileInZip == nullptr")); + } + initializeSheet(); + qDebug(); +} diff -Nru libodsstream-0.7.11/src/odsstream/ziptsvoutputstream.h libodsstream-0.8.4/src/odsstream/ziptsvoutputstream.h --- libodsstream-0.7.11/src/odsstream/ziptsvoutputstream.h 1970-01-01 00:00:00.000000000 +0000 +++ libodsstream-0.8.4/src/odsstream/ziptsvoutputstream.h 2022-10-28 00:27:44.000000000 +0000 @@ -0,0 +1,65 @@ +/** + * \file src/ziptsvoutputstream.h + * \date 27/6/2022 + * \author Olivier Langella + * \brief write TSV files in a zip archive + */ + +/******************************************************************************* + * Copyright (c) 2022 Olivier Langella . + * + * This file is part of libodsstream. + * + * libodsstream is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libodsstream is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with libodsstream. If not, see . + * + ******************************************************************************/ + + +#pragma once + +#include "tsvdirectorywriter.h" +#include +#include +/** + * @todo write docs + */ +class ZipTsvOutputStream : public TsvDirectoryWriter +{ + public: + /** + * Default constructor + */ + ZipTsvOutputStream(const QString &zipfilename); + + + /** + * Destructor + */ + virtual ~ZipTsvOutputStream(); + + virtual void writeSheet(const QString &sheetName) override; + + + void close() override; + + + private: + void closeCurrentZipSheet(); + + + private: + QFile *mpa_fileZipArchive = nullptr; + QuaZip *mpa_quaZip = nullptr; + QuaZipFile *mpa_outFileInZip = nullptr; +}; diff -Nru libodsstream-0.7.11/src/tsv2ods.cpp libodsstream-0.8.4/src/tsv2ods.cpp --- libodsstream-0.7.11/src/tsv2ods.cpp 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/src/tsv2ods.cpp 2022-10-28 00:27:44.000000000 +0000 @@ -235,8 +235,8 @@ catch(OdsException &error) { errorStream << "Oops! an error occurred in tsv2ods. Don't Panic :" - << endl; - errorStream << error.qwhat() << endl; + << Qt::endl; + errorStream << error.qwhat() << Qt::endl; exit(1); app->exit(1); } @@ -244,8 +244,8 @@ catch(std::exception &error) { errorStream << "Oops! an error occurred in tsv2ods. Don't Panic :" - << endl; - errorStream << error.what() << endl; + << Qt::endl; + errorStream << error.what() << Qt::endl; exit(1); app->exit(1); } diff -Nru libodsstream-0.7.11/test/CMakeLists.txt libodsstream-0.8.4/test/CMakeLists.txt --- libodsstream-0.7.11/test/CMakeLists.txt 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/test/CMakeLists.txt 2022-10-28 00:27:44.000000000 +0000 @@ -10,10 +10,12 @@ find_package(Qt5 COMPONENTS Core Xml Gui REQUIRED) +find_package(Catch2 REQUIRED) + include_directories(${QUAZIP_INCLUDE_DIR} "${CMAKE_SOURCE_DIR}/src") add_executable(test_ods test_ods.cpp) -target_link_libraries(test_ods Qt5::Core Qt5::Gui ${QUAZIP_LIBRARIES} odsstream-shared) +target_link_libraries(test_ods Catch2::Catch2 Qt5::Core Qt5::Gui ${QUAZIP_LIBRARIES} odsstream-shared) add_test(test_ods "test_ods") diff -Nru libodsstream-0.7.11/test/test_ods.cpp libodsstream-0.8.4/test/test_ods.cpp --- libodsstream-0.7.11/test/test_ods.cpp 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/test/test_ods.cpp 2022-10-28 00:27:44.000000000 +0000 @@ -1,3 +1,6 @@ + +#define CATCH_CONFIG_MAIN +#include #include "config.h" #include #include @@ -7,8 +10,11 @@ #include #include + // make test ARGS="-V -I 1,1" +// ./test/test_ods [ods] -s + using namespace std; class CustomHandler : public OdsDocHandlerInterface @@ -19,14 +25,14 @@ * order to retrieve information about the current data sheet. * */ - virtual void startSheet([[maybe_unused ]] const QString &sheet_name){}; + virtual void startSheet([[maybe_unused]] const QString &sheet_name){}; /** * callback that indicates the end of the current data sheet. Override it if * needed */ virtual void - endSheet() + endSheet() override { qDebug() << "endSheet"; }; @@ -35,13 +41,13 @@ * callback that indicates a new line start. Override it if needed. */ - virtual void startLine(){}; + virtual void startLine() override{}; /** * callback that indicates a line ending. Override it if needed. */ - virtual void endLine(){}; + virtual void endLine() override{}; /** * callback that report the content of the current cell in a dedicated Cell @@ -50,170 +56,280 @@ virtual void setCell(const OdsCell &cell) override { - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ - << cell.toString(); + qDebug() << cell.toString(); }; /** * callback that report the end of the ODS document. Override it if you need * to know that reading is finished. */ - virtual void endDocument(){}; + virtual void endDocument() override{}; }; -int -main([[maybe_unused ]] int argc, [[maybe_unused ]] char **argv) +class CustomHandlerXic : public OdsDocHandlerInterface { + public: + /** + * callback that indicates the begining of a data sheet. Override it in + * order to retrieve information about the current data sheet. + * + */ + virtual void + startSheet([[maybe_unused]] const QString &sheet_name) + { + m_columnNumber = 0; + m_rowNumber = 0; + if(sheet_name != "Feuille1") + { + throw OdsException( + QObject::tr("sheet_name %1 != Feuille1").arg(sheet_name)); + } + }; + + /** + * callback that indicates the end of the current data sheet. Override it if + * needed + */ + virtual void + endSheet() override + { + qDebug() << "endSheet"; + }; + + /** + * callback that indicates a new line start. Override it if needed. + */ + + virtual void + startLine() override + { + m_columnNumber = 0; + }; + + /** + * callback that indicates a line ending. Override it if needed. + */ + + virtual void + endLine() override + { + m_rowNumber++; + }; + + /** + * callback that report the content of the current cell in a dedicated Cell + * object. Override it if you need to retrieve cell content. + */ + virtual void + setCell(const OdsCell &cell) override + { + qDebug() << cell.toString(); + if((m_columnNumber == 0) && (m_rowNumber == 0) && (cell.toString() != "rt")) + { + throw OdsException( + QObject::tr("cell.toString() %1 != rt").arg(cell.toString())); + } + if((m_rowNumber == 0) && (m_columnNumber == 1) && + (cell.toString() != "intensity")) + { + throw OdsException( + QObject::tr("cell.toString() %1 != intensity").arg(cell.toString())); + } + if((m_rowNumber > 0) && (m_columnNumber == 0) && + (cell.getDoubleValue() != m_rowNumber)) + { + throw OdsException( + QObject::tr("cell.getDoubleValue() %1 != m_rowNumber %2") + .arg(cell.getDoubleValue()) + .arg(m_rowNumber)); + } + if((m_rowNumber > 0) && (m_columnNumber == 1) && + (cell.getDoubleValue() != 0)) + { + if((m_rowNumber == 12) && (cell.getDoubleValue() == 5)) + { + } + else if((m_rowNumber == 21) && (cell.getDoubleValue() == 18)) + { + } + else if((m_rowNumber == 22) && (cell.getDoubleValue() == 6)) + { + } + else if((m_rowNumber == 23) && (cell.getDoubleValue() == 3)) + { + } + else if((m_rowNumber == 30) && (cell.getDoubleValue() == 2)) + { + } + else + { + throw OdsException( + QObject::tr("cell.getDoubleValue() %1 != 0 at line %2") + .arg(cell.getDoubleValue()) + .arg(m_rowNumber)); + } + } + m_columnNumber++; + }; + + /** + * callback that report the end of the ODS document. Override it if you need + * to know that reading is finished. + */ + virtual void endDocument() override{}; + + private: + std::size_t m_rowNumber = 0; + std::size_t m_columnNumber = 0; +}; + + +TEST_CASE("Test ODS files.", "[ods]") +{ + // Set the debugging message formatting pattern. qSetMessagePattern(QString("%{file}@%{line}, %{function}(): %{message}")); - try - { - cout << endl << "..:: Test ODS files ::.." << endl; + SECTION("reading /test/data/xic.ods", "[ods]") + { + cout << endl << "..:: Test ODS files ::.." << endl; + + cout << endl << "..:: read ODS file xic.ods ::.." << endl; + CustomHandlerXic handler; + QFile xicfile(QString(CMAKE_SOURCE_DIR).append("/test/data/xic.ods")); + OdsDocReader xicfile_reader(handler); + REQUIRE_NOTHROW(xicfile_reader.parse(&xicfile)); + + xicfile.close(); + + cout << endl << "..:: read ODS file xic.ods is OK ::.." << endl; + } + SECTION("reading other ods", "[ods]") + { + + QFile file("test.ods"); + // file.open(QIODevice::WriteOnly); + OdsDocWriter writer(&file); + + QColor red("red"); + OdsTableCellStyle style; + style.setBackgroundColor(QColor("yellow")); + style.setTextColor(red); + + OdsTableCellStyleRef ref = writer.getTableCellStyleRef(style); + + QString test("truc"); + + writer.writeSheet("classeur"); + + OdsTableSettings settings; + // settings.setHorizontalWindowSplit(4); + settings.setVerticalSplit(1); + writer.setCurrentOdsTableSettings(settings); + + writer.writeCell(test); + // writer.clearTableCellStyleRef(); + writer.setTableCellStyleRef(ref); + writer.writeLine(); + writer.writeEmptyCell(); + writer.setCellAnnotation("ceci est un commentaire n1"); + writer.writeCell("coucou"); + bool vf(0); + writer.writeCell(vf); + writer.clearTableCellStyleRef(); + writer.writeLine(); + writer.writeLine(); + writer.writeLine(); + writer.writeCell(1); + QString start_position = writer.getOdsCellCoordinate(); + writer.writeCell(2); + writer.writeCell(3); + writer.writeCell(4); + writer.writeCell(5); + + writer.writeLine(); + writer.writeCell(6); + writer.writeCell(7); + writer.writeCell(8); + writer.writeCell(9); + writer.writeCell(10); + QString end_position; + end_position = writer.getOdsCellCoordinate(); + + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " + << end_position; + OdsColorScale color_scale(start_position, end_position); + writer.addColorScale(color_scale); + + writer.writeSheet("classeur2"); + + writer.setCurrentOdsTableSettings(settings); + + writer.writeCell(test); + // writer.clearTableCellStyleRef(); + writer.setTableCellStyleRef(ref); + writer.writeLine(); + writer.writeEmptyCell(); + writer.setCellAnnotation("ceci est un commentaire n1"); + writer.writeCell("coucou"); + + QDateTime currentdate(QDateTime::currentDateTime()); + + writer.setCellAnnotation("ceci est un commentaire sur une date"); + writer.writeCell(currentdate); + + writer.clearTableCellStyleRef(); + writer.writeLine(); + writer.writeEmptyCell(); + writer.setCellAnnotation("ceci est un commentaire"); + writer.writeCell("coucou"); + writer.writeCell(vf); + writer.writeCell(currentdate); + + writer.writeCellPercentage(0.2); + + QUrl urltest("http://pappso.inra.fr/"); + writer.writeCell(urltest, "ceci est un lien"); + + writer.writeSheet("test coordinates"); + + QStringList list_coordinates; + for(int i = 0; i < 200; i++) + { + writer.writeCell(i + 1); + list_coordinates << writer.getOdsCellCoordinate(); + } + writer.writeLine(); + for(const QString &coord : list_coordinates) + { + writer.writeCell(coord); + } + settings.setVerticalSplit(1); + writer.setCurrentOdsTableSettings(settings); + settings.setVerticalSplit(2); + writer.setCurrentOdsTableSettings(settings); + + writer.close(); + + file.close(); + + // qDebug() << "coucou"; + CustomHandler handler; + // file.open(); + OdsDocReader reader(handler); + reader.parse(&file); + file.close(); + + QFile file2("test2.ods"); + OdsDocReader reader2(handler); + reader2.parse(&file2); + + file2.close(); + + // SUCCESS - cout << endl << "..:: read ODS file xic.ods ::.." << endl; - CustomHandler handler; - QFile xicfile(QString(CMAKE_SOURCE_DIR).append("/test/data/xic.ods")); - OdsDocReader xicfile_reader(handler); - xicfile_reader.parse(&xicfile); - - xicfile.close(); - - cout << endl << "..:: read ODS file xic.ods is OK ::.." << endl; - - QFile file("test.ods"); - // file.open(QIODevice::WriteOnly); - OdsDocWriter writer(&file); - - QColor red("red"); - OdsTableCellStyle style; - style.setBackgroundColor(QColor("yellow")); - style.setTextColor(red); - - OdsTableCellStyleRef ref = writer.getTableCellStyleRef(style); - - QString test("truc"); - - writer.writeSheet("classeur"); - - OdsTableSettings settings; - // settings.setHorizontalWindowSplit(4); - settings.setVerticalSplit(1); - writer.setCurrentOdsTableSettings(settings); - - writer.writeCell(test); - // writer.clearTableCellStyleRef(); - writer.setTableCellStyleRef(ref); - writer.writeLine(); - writer.writeEmptyCell(); - writer.setCellAnnotation("ceci est un commentaire n1"); - writer.writeCell("coucou"); - bool vf(0); - writer.writeCell(vf); - writer.clearTableCellStyleRef(); - writer.writeLine(); - writer.writeLine(); - writer.writeLine(); - writer.writeCell(1); - QString start_position = writer.getOdsCellCoordinate(); - writer.writeCell(2); - writer.writeCell(3); - writer.writeCell(4); - writer.writeCell(5); - - writer.writeLine(); - writer.writeCell(6); - writer.writeCell(7); - writer.writeCell(8); - writer.writeCell(9); - writer.writeCell(10); - QString end_position; - end_position = writer.getOdsCellCoordinate(); - - qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " - << end_position; - OdsColorScale color_scale(start_position, end_position); - writer.addColorScale(color_scale); - - writer.writeSheet("classeur2"); - - writer.setCurrentOdsTableSettings(settings); - - writer.writeCell(test); - // writer.clearTableCellStyleRef(); - writer.setTableCellStyleRef(ref); - writer.writeLine(); - writer.writeEmptyCell(); - writer.setCellAnnotation("ceci est un commentaire n1"); - writer.writeCell("coucou"); - - QDateTime currentdate(QDateTime::currentDateTime()); - - writer.setCellAnnotation("ceci est un commentaire sur une date"); - writer.writeCell(currentdate); - - writer.clearTableCellStyleRef(); - writer.writeLine(); - writer.writeEmptyCell(); - writer.setCellAnnotation("ceci est un commentaire"); - writer.writeCell("coucou"); - writer.writeCell(vf); - writer.writeCell(currentdate); - - writer.writeCellPercentage(0.2); - - QUrl urltest("http://pappso.inra.fr/"); - writer.writeCell(urltest, "ceci est un lien"); - - writer.writeSheet("test coordinates"); - - QStringList list_coordinates; - for(int i = 0; i < 200; i++) - { - writer.writeCell(i + 1); - list_coordinates << writer.getOdsCellCoordinate(); - } - writer.writeLine(); - for(const QString &coord : list_coordinates) - { - writer.writeCell(coord); - } - settings.setVerticalSplit(1); - writer.setCurrentOdsTableSettings(settings); - settings.setVerticalSplit(2); - writer.setCurrentOdsTableSettings(settings); - - writer.close(); - - file.close(); - - // qDebug() << "coucou"; - - // file.open(); - OdsDocReader reader(handler); - reader.parse(&file); - file.close(); - - QFile file2("test2.ods"); - OdsDocReader reader2(handler); - reader2.parse(&file2); - - file2.close(); - - // SUCCESS - - OdsDocWriter writerb("testbis.ods"); - writerb.writeCell("coucou"); - - writerb.writeCell(urltest, "ceci est un lien"); - } - catch(OdsException &ods_error) - { - std::cerr << QObject::tr("error testing :\n %1") - .arg(ods_error.qwhat()) - .toStdString() - .c_str(); - return 1; - } + OdsDocWriter writerb("testbis.ods"); + writerb.writeCell("coucou"); - return 0; + writerb.writeCell(urltest, "ceci est un lien"); + } } diff -Nru libodsstream-0.7.11/test/test_tsv.cpp libodsstream-0.8.4/test/test_tsv.cpp --- libodsstream-0.7.11/test/test_tsv.cpp 2020-12-21 16:27:58.000000000 +0000 +++ libodsstream-0.8.4/test/test_tsv.cpp 2022-10-28 00:27:44.000000000 +0000 @@ -8,11 +8,14 @@ #include #include #include +#include using namespace std; // make test ARGS="-V -I 2,2" +//./test/test_tsv [TSVZIP] -s + class CustomHandler : public OdsDocHandlerInterface { public: @@ -84,7 +87,7 @@ { TsvDirectoryWriter writer(QDir("test")); - + writer.setFlushLines(true); QString test("truc"); @@ -136,7 +139,7 @@ QTextStream terminalOut(stdout, QIODevice::WriteOnly); TsvOutputStream writero(terminalOut); - + writero.setFlushLines(true); writero.writeSheet("classeur"); @@ -158,3 +161,63 @@ tsv_reader.parse(tsv_file); } } + +TEST_CASE("TSV ZIP test suite.", "[TSVZIP]") +{ + // Set the debugging message formatting pattern. + qSetMessagePattern(QString("%{file}@%{line}, %{function}(): %{message}")); + INFO("begin"); + ZipTsvOutputStream writer("test.zip"); + + INFO("coucou"); + + writer.setFlushLines(true); + + QString test("truc"); + + INFO("coucou2"); + writer.writeSheet("classeur"); + writer.setCellAnnotation("test annot"); + writer.writeCell(test); + writer.writeLine(); + writer.writeEmptyCell(); + writer.writeCell("coucou\" ceci est un quote"); + bool vf(0); + writer.writeCell(vf); + writer.writeCellPercentage(0.23565654545); + + writer.clearTableCellStyleRef(); + writer.writeLine(); + writer.writeLine(); + writer.writeLine(); + writer.writeCell(1); + QString start_position = writer.getOdsCellCoordinate(); + writer.writeCell(2); + writer.writeCell(3); + writer.writeCell(4); + writer.writeCell(5); + + writer.writeLine(); + writer.writeCell(6); + writer.writeCell(7); + writer.writeCell(8); + writer.writeCell(9); + writer.writeCell(10); + QString end_position = writer.getOdsCellCoordinate(); + + OdsColorScale color_scale(start_position, end_position); + writer.addColorScale(color_scale); + + writer.writeSheet("classeur2"); + writer.setCellAnnotation("test annot"); + writer.writeCell(test); + writer.writeLine(); + writer.writeEmptyCell(); + writer.writeCell("coucou"); + + QDateTime currentdate(QDateTime::currentDateTime()); + + writer.writeCell(currentdate); + + writer.close(); +}