-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 'feture/iwork-build' (#99) from feture/iwork-build…
… into develop Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/99
- Loading branch information
Showing
20 changed files
with
4,454 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
#include "IWork.h" | ||
#include "../DesktopEditor/common/File.h" | ||
|
||
#include <libetonyek/libetonyek.h> | ||
#include <libodfgen/OdtGenerator.hxx> | ||
#include <libodfgen/OdsGenerator.hxx> | ||
#include <libodfgen/OdpGenerator.hxx> | ||
#include <libodfgen/test/StringDocumentHandler.hxx> | ||
|
||
#include <memory> | ||
#include <iostream> | ||
#include <fstream> | ||
|
||
class CIWorkFile_Private | ||
{ | ||
public: | ||
std::wstring m_sTempDirectory; | ||
|
||
public: | ||
CIWorkFile_Private() | ||
{ | ||
} | ||
~CIWorkFile_Private() | ||
{ | ||
} | ||
}; | ||
|
||
CIWorkFile::CIWorkFile() | ||
{ | ||
m_internal = new CIWorkFile_Private(); | ||
} | ||
|
||
CIWorkFile::~CIWorkFile() | ||
{ | ||
delete m_internal; | ||
} | ||
|
||
IWorkFileType CIWorkFile::GetType(const std::wstring& sFile) | ||
{ | ||
std::string sFileA = U_TO_UTF8(sFile); | ||
std::shared_ptr<librevenge::RVNGInputStream> input; | ||
if (librevenge::RVNGDirectoryStream::isDirectory(sFileA.c_str())) | ||
input.reset(new librevenge::RVNGDirectoryStream(sFileA.c_str())); | ||
else | ||
input.reset(new librevenge::RVNGFileStream(sFileA.c_str())); | ||
|
||
libetonyek::EtonyekDocument::Type type = libetonyek::EtonyekDocument::TYPE_UNKNOWN; | ||
const libetonyek::EtonyekDocument::Confidence confidence = libetonyek::EtonyekDocument::isSupported(input.get(), &type); | ||
|
||
if (libetonyek::EtonyekDocument::CONFIDENCE_NONE == confidence) | ||
return IWorkFileType::None; | ||
|
||
switch (type) | ||
{ | ||
case libetonyek::EtonyekDocument::TYPE_PAGES: | ||
return IWorkFileType::Pages; | ||
case libetonyek::EtonyekDocument::TYPE_NUMBERS: | ||
return IWorkFileType::Numbers; | ||
case libetonyek::EtonyekDocument::TYPE_KEYNOTE: | ||
return IWorkFileType::Keynote; | ||
default: | ||
break; | ||
} | ||
|
||
return IWorkFileType::None; | ||
} | ||
|
||
int CIWorkFile::Convert2Odf(const std::wstring& sFile, const std::wstring& sOutputFile) | ||
{ | ||
std::string sFileA = U_TO_UTF8(sFile); | ||
std::shared_ptr<librevenge::RVNGInputStream> input; | ||
if (librevenge::RVNGDirectoryStream::isDirectory(sFileA.c_str())) | ||
input.reset(new librevenge::RVNGDirectoryStream(sFileA.c_str())); | ||
else | ||
input.reset(new librevenge::RVNGFileStream(sFileA.c_str())); | ||
|
||
libetonyek::EtonyekDocument::Type type = libetonyek::EtonyekDocument::TYPE_UNKNOWN; | ||
const libetonyek::EtonyekDocument::Confidence confidence = libetonyek::EtonyekDocument::isSupported(input.get(), &type); | ||
|
||
if (libetonyek::EtonyekDocument::CONFIDENCE_NONE == confidence) | ||
return -1; | ||
|
||
const std::string sOutputFileA = U_TO_UTF8(sOutputFile); | ||
|
||
switch (type) | ||
{ | ||
case libetonyek::EtonyekDocument::TYPE_PAGES: | ||
{ | ||
StringDocumentHandler content; | ||
OdtGenerator generator; | ||
generator.addDocumentHandler(&content, ODF_FLAT_XML); | ||
|
||
bool bRes = libetonyek::EtonyekDocument::parse(input.get(), &generator); | ||
if (!bRes) | ||
return 1; | ||
|
||
std::wofstream output(sOutputFileA.c_str()); | ||
output << content.cstr(); | ||
return 0; | ||
} | ||
case libetonyek::EtonyekDocument::TYPE_NUMBERS: | ||
{ | ||
StringDocumentHandler content; | ||
OdsGenerator generator; | ||
generator.addDocumentHandler(&content, ODF_FLAT_XML); | ||
|
||
bool bRes = libetonyek::EtonyekDocument::parse(input.get(), &generator); | ||
if (!bRes) | ||
return 1; | ||
|
||
std::wofstream output(sOutputFileA.c_str()); | ||
output << content.cstr(); | ||
return 0; | ||
} | ||
case libetonyek::EtonyekDocument::TYPE_KEYNOTE: | ||
{ | ||
StringDocumentHandler content; | ||
OdpGenerator generator; | ||
generator.addDocumentHandler(&content, ODF_FLAT_XML); | ||
|
||
bool bRes = libetonyek::EtonyekDocument::parse(input.get(), &generator); | ||
if (!bRes) | ||
return 1; | ||
|
||
std::wofstream output(sOutputFileA.c_str()); | ||
output << content.cstr(); | ||
return 0; | ||
} | ||
default: | ||
break; | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
void CIWorkFile::SetTmpDirectory(const std::wstring& sFolder) | ||
{ | ||
m_internal->m_sTempDirectory = sFolder; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef _IWORKFILE_IWORKFILE_H | ||
#define _IWORKFILE_IWORKFILE_H | ||
|
||
#include <string> | ||
|
||
#ifndef IWORK_USE_DYNAMIC_LIBRARY | ||
#define IWORK_FILE_DECL_EXPORT | ||
#else | ||
#include "../DesktopEditor/common/base_export.h" | ||
#define IWORK_FILE_DECL_EXPORT Q_DECL_EXPORT | ||
#endif | ||
|
||
enum class IWorkFileType | ||
{ | ||
Pages = 0, | ||
Numbers = 1, | ||
Keynote = 2, | ||
|
||
None = 255 | ||
}; | ||
|
||
class CIWorkFile_Private; | ||
class IWORK_FILE_DECL_EXPORT CIWorkFile | ||
{ | ||
private: | ||
CIWorkFile_Private* m_internal; | ||
public: | ||
CIWorkFile(); | ||
~CIWorkFile(); | ||
|
||
IWorkFileType GetType(const std::wstring& sFile); | ||
int Convert2Odf(const std::wstring& sFile, const std::wstring& sOutputFile); | ||
void SetTmpDirectory(const std::wstring& sFolder); | ||
}; | ||
|
||
#endif // _IWORKFILE_IWORKFILE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
QT -= core | ||
QT -= gui | ||
|
||
VERSION = 0.0.0.1 | ||
TARGET = IWorkFile | ||
TEMPLATE = lib | ||
|
||
CONFIG += shared | ||
CONFIG += plugin | ||
|
||
DEFINES += IWORK_USE_DYNAMIC_LIBRARY | ||
|
||
CORE_ROOT_DIR = $$PWD/.. | ||
PWD_ROOT_DIR = $$PWD | ||
include($$CORE_ROOT_DIR/Common/base.pri) | ||
|
||
ADD_DEPENDENCY(kernel, UnicodeConverter) | ||
|
||
INCLUDEPATH += \ | ||
$$PWD | ||
|
||
# BOOST | ||
CONFIG += core_boost_regex | ||
include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri) | ||
|
||
# ZLIB | ||
CONFIG += build_all_zlib build_zlib_as_sources | ||
include($$PWD/../OfficeUtils/OfficeUtils.pri) | ||
|
||
# LIBXML | ||
CONFIG += core_static_link_xml_full | ||
CONFIG += core_only_libxml | ||
include($$PWD/../DesktopEditor/xml/build/qt/libxml2.pri) | ||
|
||
# | ||
include($$CORE_ROOT_DIR/Common/3dParty/apple/apple.pri) | ||
|
||
# TEST | ||
HEADERS += $$ODF_LIB_ROOT/test/StringDocumentHandler.h | ||
SOURCES += $$ODF_LIB_ROOT/test/StringDocumentHandler.cxx | ||
|
||
SOURCES += IWork.cpp | ||
|
||
HEADERS += IWork.h |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* (c) Copyright Ascensio System SIA 2010-2023 | ||
* | ||
* This program is a free software product. You can redistribute it and/or | ||
* modify it under the terms of the GNU Affero General Public License (AGPL) | ||
* version 3 as published by the Free Software Foundation. In accordance with | ||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect | ||
* that Ascensio System SIA expressly excludes the warranty of non-infringement | ||
* of any third-party rights. | ||
* | ||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied | ||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For | ||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html | ||
* | ||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish | ||
* street, Riga, Latvia, EU, LV-1050. | ||
* | ||
* The interactive user interfaces in modified source and object code versions | ||
* of the Program must display Appropriate Legal Notices, as required under | ||
* Section 5 of the GNU AGPL version 3. | ||
* | ||
* Pursuant to Section 7(b) of the License you must retain the original Product | ||
* logo when distributing the program. Pursuant to Section 7(e) we decline to | ||
* grant you any rights under trademark law for use of our trademarks. | ||
* | ||
* All the Product's GUI elements, including illustrations and icon sets, as | ||
* well as technical writing content are licensed under the terms of the | ||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License | ||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode | ||
* | ||
*/ | ||
|
||
#include "../IWork.h" | ||
#include "../../DesktopEditor/common/File.h" | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
CIWorkFile oFile; | ||
|
||
std::wstring sExamplesDir = NSFile::GetProcessDirectory() + L"/../examples"; | ||
oFile.Convert2Odf(sExamplesDir + L"/new.pages", sExamplesDir + L"/out_new.odt"); | ||
oFile.Convert2Odf(sExamplesDir + L"/old.pages", sExamplesDir + L"/out_old.odt"); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
CONFIG -= qt | ||
QT -= core gui | ||
|
||
TARGET = test | ||
CONFIG += console | ||
CONFIG -= app_bundle | ||
TEMPLATE = app | ||
|
||
CORE_ROOT_DIR = $$PWD/../.. | ||
PWD_ROOT_DIR = $$PWD | ||
include($$CORE_ROOT_DIR/Common/base.pri) | ||
|
||
ADD_DEPENDENCY(UnicodeConverter, kernel, IWorkFile) | ||
|
||
core_linux:include($$PWD/../../Common/3dParty/icu/icu.pri) | ||
core_windows:LIBS += -lgdi32 -ladvapi32 -luser32 -lshell32 | ||
|
||
SOURCES += main.cpp | ||
|
||
DESTDIR = $$PWD/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Ignore everything in this directory | ||
glm | ||
mdds | ||
librevenge | ||
libodfgen | ||
libetonyek | ||
# Except this file | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
INCLUDEPATH += $$PWD | ||
|
||
# LIBREVENGE | ||
REVENGE_LIB_ROOT = $$PWD/librevenge | ||
|
||
INCLUDEPATH += \ | ||
$$REVENGE_LIB_ROOT/inc | ||
|
||
HEADERS += $$files($$REVENGE_LIB_ROOT/inc/*.h, true) | ||
HEADERS += $$files($$REVENGE_LIB_ROOT/src/lib/*.h, true) | ||
SOURCES += $$files($$REVENGE_LIB_ROOT/src/lib/*.cpp, true) | ||
|
||
# LIBODFGEN | ||
ODF_LIB_ROOT = $$PWD/libodfgen | ||
|
||
INCLUDEPATH += \ | ||
$$ODF_LIB_ROOT/inc | ||
|
||
HEADERS += $$files($$ODF_LIB_ROOT/inc/libodfgen/*.hxx, true) | ||
HEADERS += $$files($$ODF_LIB_ROOT/src/*.hxx, true) | ||
SOURCES += $$files($$ODF_LIB_ROOT/src/*.cxx, true) | ||
|
||
# LIBETONYEK | ||
ETONYEK_LIB_ROOT = $$PWD/libetonyek | ||
|
||
INCLUDEPATH += \ | ||
$$ETONYEK_LIB_ROOT/inc \ | ||
$$ETONYEK_LIB_ROOT/src/lib \ | ||
$$ETONYEK_LIB_ROOT/src/lib/contexts \ | ||
$$PWD/mdds/include \ | ||
$$PWD/glm | ||
|
||
HEADERS += $$files($$ETONYEK_LIB_ROOT/inc/libetonyek/*.h, true) | ||
HEADERS += $$files($$ETONYEK_LIB_ROOT/src/lib/*.h, true) | ||
SOURCES += $$files($$ETONYEK_LIB_ROOT/src/lib/*.cpp, true) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import sys | ||
sys.path.append('../../../../build_tools/scripts') | ||
import base | ||
import os | ||
|
||
if not base.is_dir("glm"): | ||
base.cmd("git", ["clone", "https://github.com/g-truc/glm.git"]) | ||
base.cmd_in_dir("glm", "git", ["checkout", "33b4a621a697a305bc3a7610d290677b96beb181", "--quiet"]) | ||
|
||
if not base.is_dir("mdds"): | ||
base.cmd("git", ["clone", "https://github.com/kohei-us/mdds.git"]) | ||
base.cmd_in_dir("mdds", "git", ["checkout", "0783158939c6ce4b0b1b89e345ab983ccb0f0ad0"], "--quiet") | ||
|
||
#the linux code uses an implementation for c++ 17, so we just put this implementation | ||
if ("linux" == base.host_platform()): | ||
base.replaceInFile("./mdds/include/mdds/global.hpp", "namespace mdds {", "namespace std { template<bool __v> using bool_constant = integral_constant<bool, __v>; }\n\nnamespace mdds {") | ||
|
||
if not base.is_dir("librevenge"): | ||
base.cmd("git", ["clone", "https://github.com/Distrotech/librevenge.git"]) | ||
base.cmd_in_dir("librevenge", "git", ["checkout", "becd044b519ab83893ad6398e3cbb499a7f0aaf4", "--quiet"]) | ||
|
||
stat_windows = "" | ||
stat_windows += "#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)\n" | ||
stat_windows += "#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)\n" | ||
stat_windows += "#endif\n" | ||
stat_windows += "#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)\n" | ||
stat_windows += "#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)\n" | ||
stat_windows += "#endif\n" | ||
|
||
base.replaceInFile("./librevenge/src/lib/RVNGDirectoryStream.cpp", "#include <librevenge-stream/librevenge-stream.h>", | ||
"#include <librevenge-stream/librevenge-stream.h>\n\n" + stat_windows) | ||
|
||
if not base.is_dir("libodfgen"): | ||
base.cmd("git", ["clone", "https://github.com/Distrotech/libodfgen.git"]) | ||
base.cmd_in_dir("libodfgen", "git", ["checkout", "8ef8c171ebe3c5daebdce80ee422cf7bb96aa3bc", "--quiet"]) | ||
|
||
if not base.is_dir("libetonyek"): | ||
base.cmd("git", ["clone", "https://github.com/LibreOffice/libetonyek.git"]) | ||
base.cmd_in_dir("libetonyek", "git", ["checkout", "cb396b4a9453a457469b62a740d8fb933c9442c3", "--quiet"]) | ||
|
||
base.replaceInFile("./libetonyek/src/lib/IWORKTable.cpp", "is_tree_valid", "valid_tree") | ||
|
||
cmd_args = sys.argv[1:] | ||
use_gperf = False | ||
|
||
for arg in cmd_args: | ||
if '--gperf' == arg: | ||
use_gperf = True | ||
|
||
if use_gperf: | ||
base_gperf_args = ["--compare-strncmp", "--enum", "--null-strings", "--readonly-tables", "--language", "C++"] | ||
base_gperf_files = ["IWORKToken.gperf", "KEY1Token.gperf", "KEY2Token.gperf", "NUM1Token.gperf", "PAG1Token.gperf"] | ||
|
||
for file in base_gperf_files: | ||
base.cmd_in_dir("./libetonyek/src/lib", "gperf", base_gperf_args + [file, "--output-file", file[0:file.find(".")] + ".inc"]) | ||
else: | ||
base.copy_dir_content("./headers", "./libetonyek/src/lib") | ||
|
||
|
||
|
Oops, something went wrong.