Skip to content

Commit

Permalink
Merge branch release/v8.3.0 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
papacarlo committed Feb 5, 2025
2 parents 87b5ae8 + 45da53e commit d97d266
Show file tree
Hide file tree
Showing 618 changed files with 42,580 additions and 23,002 deletions.
141 changes: 141 additions & 0 deletions Apple/IWork.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#include "IWork.h"
#include "../DesktopEditor/common/File.h"
#include "../DesktopEditor/common/Directory.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 <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;
}

#if !defined(_WIN32) && !defined(_WIN64)
#define DATA_TYPE_INPUTFILE std::string
#else
#define DATA_TYPE_INPUTFILE std::wstring
#endif

bool GetRVNGInputStream(const DATA_TYPE_INPUTFILE& sFile, std::shared_ptr<librevenge::RVNGInputStream>& oRVNGInputStream, libetonyek::EtonyekDocument::Type& oDocumentType)
{
oRVNGInputStream.reset(new librevenge::RVNGFileStream(sFile.c_str()));

oDocumentType = libetonyek::EtonyekDocument::TYPE_UNKNOWN;
const libetonyek::EtonyekDocument::Confidence confidence = libetonyek::EtonyekDocument::isSupported(oRVNGInputStream.get(), &oDocumentType);

return libetonyek::EtonyekDocument::CONFIDENCE_NONE != confidence;
}

IWorkFileType CIWorkFile::GetType(const std::wstring& sFile) const
{
//TODO:: так как на данный момент мы работает только напрямую с файлом, то работа с директорией нам пока не нужна
if (NSDirectory::PathIsDirectory(sFile))
return IWorkFileType::None;

std::shared_ptr<librevenge::RVNGInputStream> input;
libetonyek::EtonyekDocument::Type oDocumentType;

#if !defined(_WIN32) && !defined(_WIN64)
std::string sFileA = U_TO_UTF8(sFile);
if (!GetRVNGInputStream(sFileA, input, oDocumentType))
return IWorkFileType::None;
#else
if (!GetRVNGInputStream(sFile, input, oDocumentType))
return IWorkFileType::None;
#endif

switch (oDocumentType)
{
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;
}

template<class Generator>
int Convert(const std::wstring& wsOutputFile, std::shared_ptr<librevenge::RVNGInputStream>& ptrInput, const std::wstring& wsPassword = L"", const std::wstring& wsTempDirectory = L"")
{
StringDocumentHandler content;
Generator generator;
generator.addDocumentHandler(&content, ODF_FLAT_XML);

bool bRes = libetonyek::EtonyekDocument::parse(ptrInput.get(), &generator);
if (!bRes)
return 1;

const std::string sOutputFileA = U_TO_UTF8(wsOutputFile);
std::ofstream output(sOutputFileA.c_str());
output << content.cstr();

if (output.bad())
return -1;

return 0;
}

int CIWorkFile::Convert2Odf(const std::wstring& sFile, const std::wstring& sOutputFile) const
{
//TODO:: так как на данный момент мы работает только напрямую с файлом, то работа с директорией нам пока не нужна
if (NSDirectory::PathIsDirectory(sFile))
return -1;

std::shared_ptr<librevenge::RVNGInputStream> input;
libetonyek::EtonyekDocument::Type oDocumentType;

#if !defined(_WIN32) && !defined(_WIN64)
std::string sFileA = U_TO_UTF8(sFile);
if (!GetRVNGInputStream(sFileA, input, oDocumentType))
return -1;
#else
if (!GetRVNGInputStream(sFile, input, oDocumentType))
return -1;
#endif

switch (oDocumentType)
{
case libetonyek::EtonyekDocument::TYPE_PAGES: return Convert<OdtGenerator>(sOutputFile, input);
case libetonyek::EtonyekDocument::TYPE_NUMBERS: return Convert<OdsGenerator>(sOutputFile, input);
case libetonyek::EtonyekDocument::TYPE_KEYNOTE: return Convert<OdpGenerator>(sOutputFile, input);
default:
break;
}

return -1;
}

void CIWorkFile::SetTmpDirectory(const std::wstring& sFolder)
{
m_internal->m_sTempDirectory = sFolder;
}
36 changes: 36 additions & 0 deletions Apple/IWork.h
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) const;
int Convert2Odf(const std::wstring& sFile, const std::wstring& sOutputFile) const;
void SetTmpDirectory(const std::wstring& sFolder);
};

#endif // _IWORKFILE_IWORKFILE_H
46 changes: 46 additions & 0 deletions Apple/IWork.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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

core_android:DEFINES += NOT_USE_PTHREAD_CANCEL USE_FILE32API

# 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.
45 changes: 45 additions & 0 deletions Apple/test/main.cpp
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;
}
20 changes: 20 additions & 0 deletions Apple/test/test.pro
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
8 changes: 8 additions & 0 deletions Common/3dParty/apple/.gitignore
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
36 changes: 36 additions & 0 deletions Common/3dParty/apple/apple.pri
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)

Loading

0 comments on commit d97d266

Please sign in to comment.