diff --git a/DesktopEditor/doctrenderer/docbuilder.java/.gitignore b/DesktopEditor/doctrenderer/docbuilder.java/.gitignore new file mode 100644 index 0000000000..f51d072bd6 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/.gitignore @@ -0,0 +1,3 @@ +result.docx +*.class +*.jar diff --git a/DesktopEditor/doctrenderer/docbuilder.java/make.py b/DesktopEditor/doctrenderer/docbuilder.java/make.py new file mode 100644 index 0000000000..06f07170f1 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/make.py @@ -0,0 +1,50 @@ +import os +import argparse +import re +import platform + +# NOTE: In JDK 8 and earlier, `javac` does not create the directories specified in the -d option if they do not already exist +# So we need to create them manually +def makedirs(dir): + if not os.path.exists(dir): + os.makedirs(dir) + return + +# return all files with extension `ext` in directory `dir` as string +def getFilesInDir(dir, ext): + files = ''; + for file in os.listdir(dir): + if file.endswith(ext): + # for non-windows systems '$'-symbol in file names should be escaped + if platform.system().lower() != 'windows': + file = re.sub(r'\$', r'\\$', file) + files += ' ' + dir + '/' + file + + return files + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Build Java wrapper for docbuilder library') + parser.add_argument('-H', '--headers', action='store_true', help='Generate C++ JNI header files') + parser.add_argument('-n', '--no-jar', dest='no_jar', action='store_true', help='Build only classes without JAR archive') + args = parser.parse_args() + + file_dir = os.path.dirname(os.path.realpath(__file__)); + os.chdir(file_dir + '/src/java') + + java_files = getFilesInDir('docbuilder', '.java') + java_files += getFilesInDir('docbuilder/utils', '.java') + + # BUILD + classes_dir = file_dir + '/build/classes' + makedirs(classes_dir + '/docbuilder/utils') + headers_dir = file_dir + '/src/jni' + # build all Java classes + os.system('javac -d ' + classes_dir + (' -h ' + headers_dir if args.headers else '') + java_files) + + # PACKING TO JAR + if not args.no_jar: + os.chdir(classes_dir) + class_files = getFilesInDir('docbuilder', '.class') + class_files += getFilesInDir('docbuilder/utils', '.class') + makedirs('../libs') + os.system('jar -cvf ../libs/docbuilder.jar ' + class_files) diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilder.java b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilder.java new file mode 100644 index 0000000000..1f252d4198 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilder.java @@ -0,0 +1,142 @@ +package docbuilder; + +import docbuilder.utils.NativeLibraryLoader; + +public class CDocBuilder { + public CDocBuilder() { + c_internal = c_Create(); + } + + protected void finalize() { + c_Destroy(c_internal); + } + + public int openFile(String path, String params) { + return c_OpenFile(c_internal, path, params); + } + + public boolean createFile(int type) { + return c_CreateFileByType(c_internal, type); + } + + public boolean createFile(String extension) { + return c_CreateFileByExtension(c_internal, extension); + } + + public void setTmpFolder(String folder) { + c_SetTmpFolder(c_internal, folder); + } + + public int saveFile(int type, String path) { + return c_SaveFileByType(c_internal, type, path); + } + + public int saveFile(int type, String path, String params) { + return c_SaveFileByTypeWithParams(c_internal, type, path, params); + } + + public int saveFile(String extension, String path) { + return c_SaveFileByExtension(c_internal, extension, path); + } + + public int saveFile(String extension, String path, String params) { + return c_SaveFileByExtensionWithParams(c_internal, extension, path, params); + } + + public void closeFile() { + c_CloseFile(c_internal); + } + + public boolean executeCommand(String command) { + return c_ExecuteCommand(c_internal, command); + } + + public boolean executeCommand(String command, CDocBuilderValue retValue) { + return c_ExecuteCommandWithRetValue(c_internal, command, retValue.c_internal); + } + + public boolean run(String path) { + return c_Run(c_internal, path); + } + + public boolean runText(String commands) { + return c_RunText(c_internal, commands); + } + + public void setProperty(String param, String value) { + c_SetProperty(c_internal, param, value); + } + + public void writeData(String path, String value, boolean append) { + c_WriteData(c_internal, path, value, append); + } + + public boolean isSaveWithDoctrendererMode() { + return c_IsSaveWithDoctrendererMode(c_internal); + } + + public String getVersion() { + return c_GetVersion(c_internal); + } + + public CDocBuilderContext getContext() { + return new CDocBuilderContext(c_GetContext(c_internal)); + } + + public static void initialize() { + c_Initialize(); + } + + public static void initialize(String directory) { + if (directory.isEmpty()) + directory = NativeLibraryLoader.getLibPath().toString(); + c_InitializeWithDirectory(directory); + } + + public static void dispose() { + c_Dispose(); + } + + // Native code + static { + docbuilder.utils.NativeLibraryLoader.loadLibraries(); + } + + long c_internal = 0; + + private static native long c_Create(); + private static native void c_Destroy(long self); + + private static native int c_OpenFile(long self, String path, String params); + private static native boolean c_CreateFileByType(long self, int type); + private static native boolean c_CreateFileByExtension(long self, String extension); + + private static native void c_SetTmpFolder(long self, String folder); + + private static native int c_SaveFileByType(long self, int type, String path); + private static native int c_SaveFileByTypeWithParams(long self, int type, String path, String params); + private static native int c_SaveFileByExtension(long self, String extension, String path); + private static native int c_SaveFileByExtensionWithParams(long self, String extension, String path, String params); + + private static native void c_CloseFile(long self); + + private static native boolean c_ExecuteCommand(long self, String command); + private static native boolean c_ExecuteCommandWithRetValue(long self, String command, long retValue); + + private static native boolean c_Run(long self, String path); + private static native boolean c_RunText(long self, String commands); + + private static native void c_SetProperty(long self, String param, String value); + + private static native void c_WriteData(long self, String path, String value, boolean append); + + private static native boolean c_IsSaveWithDoctrendererMode(long self); + + private static native String c_GetVersion(long self); + + private static native long c_GetContext(long self); + + private static native void c_Initialize(); + private static native void c_InitializeWithDirectory(String directory); + private static native void c_Dispose(); +} diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilderContext.java b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilderContext.java new file mode 100644 index 0000000000..68b199f3ee --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilderContext.java @@ -0,0 +1,69 @@ +package docbuilder; + +public class CDocBuilderContext { + public CDocBuilderContext() { + c_internal = c_Create(); + } + + CDocBuilderContext(long internal) { + c_internal = internal; + } + + public CDocBuilderContext(CDocBuilderContext other) { + c_internal = c_Copy(other.c_internal); + } + + protected void finalize() { + c_Destroy(c_internal); + } + + public CDocBuilderValue createUndefined() { + return new CDocBuilderValue(c_CreateUndefined(c_internal)); + } + + public CDocBuilderValue createNull() { + return new CDocBuilderValue(c_CreateNull(c_internal)); + } + + public CDocBuilderValue createObject() { + return new CDocBuilderValue(c_CreateObject(c_internal)); + } + + public CDocBuilderValue createArray(int length) { + return new CDocBuilderValue(c_CreateArray(c_internal, length)); + } + + public CDocBuilderValue getGlobal() { + return new CDocBuilderValue(c_GetGlobal(c_internal)); + } + + public CDocBuilderContextScope createScope() { + return new CDocBuilderContextScope(c_CreateScope(c_internal)); + } + + public boolean isError() { + return c_IsError(c_internal); + } + + // Native code + static { + docbuilder.utils.NativeLibraryLoader.loadLibraries(); + } + + long c_internal = 0; + + private static native long c_Create(); + private static native long c_Copy(long other); + private static native void c_Destroy(long self); + + private static native long c_CreateUndefined(long self); + private static native long c_CreateNull(long self); + private static native long c_CreateObject(long self); + private static native long c_CreateArray(long self, int length); + + private static native long c_GetGlobal(long self); + + private static native long c_CreateScope(long self); + + private static native boolean c_IsError(long self); +} diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilderContextScope.java b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilderContextScope.java new file mode 100644 index 0000000000..e50742f35f --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilderContextScope.java @@ -0,0 +1,36 @@ +package docbuilder; + +public class CDocBuilderContextScope { + public CDocBuilderContextScope() { + c_internal = c_Create(); + } + + CDocBuilderContextScope(long internal) { + c_internal = internal; + } + + public CDocBuilderContextScope(CDocBuilderContextScope other) { + c_internal = c_Copy(other.c_internal); + } + + protected void finalize() { + c_Destroy(c_internal); + } + + public void close() { + c_Close(c_internal); + } + + // Native code + static { + docbuilder.utils.NativeLibraryLoader.loadLibraries(); + } + + long c_internal = 0; + + private static native long c_Create(); + private static native long c_Copy(long other); + private static native void c_Destroy(long self); + + private static native void c_Close(long self); +} diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilderValue.java b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilderValue.java new file mode 100644 index 0000000000..ba17a2ef53 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/CDocBuilderValue.java @@ -0,0 +1,278 @@ +package docbuilder; + +public class CDocBuilderValue { + public CDocBuilderValue() { + c_internal = c_Create(); + } + + CDocBuilderValue(long internal) { + c_internal = internal; + } + + public CDocBuilderValue(CDocBuilderValue other) { + c_internal = c_Copy(other.c_internal); + } + + protected void finalize() + { + c_Destroy(c_internal); + } + + public boolean isEmpty() + { + return c_IsEmpty(c_internal); + } + + public void clear() + { + c_Clear(c_internal); + } + + public boolean isNull() + { + return c_IsNull(c_internal); + } + + public boolean isUndefined() + { + return c_IsUndefined(c_internal); + } + + public boolean isInt() + { + return c_IsInt(c_internal); + } + + public boolean isDouble() + { + return c_IsDouble(c_internal); + } + + public boolean isString() + { + return c_IsString(c_internal); + } + + public boolean isFunction() + { + return c_IsFunction(c_internal); + } + + public boolean isObject() + { + return c_IsObject(c_internal); + } + + public boolean isArray() + { + return c_IsArray(c_internal); + } + + public int getLength() + { + return c_GetLength(c_internal); + } + + public boolean toBool() + { + return c_ToBool(c_internal); + } + + public int toInt() + { + return c_ToInt(c_internal); + } + + public double toDouble() + { + return c_ToDouble(c_internal); + } + + public String toString() + { + return c_ToString(c_internal); + } + + public CDocBuilderValue getProperty(String name) { + return new CDocBuilderValue(c_GetProperty(c_internal, name)); + } + + public CDocBuilderValue get(String name) { + return new CDocBuilderValue(c_GetProperty(c_internal, name)); + } + + public CDocBuilderValue get(int index) { + return new CDocBuilderValue(c_GetByIndex(c_internal, index)); + } + + public void setProperty(String name, Object value) { + CDocBuilderValue docBuilderValue = getValueFromObject(value); + c_SetProperty(c_internal, name, docBuilderValue.c_internal); + } + + public void set(String name, Object value) { + CDocBuilderValue docBuilderValue = getValueFromObject(value); + c_SetProperty(c_internal, name, docBuilderValue.c_internal); + } + + public void set(int index, Object value) { + CDocBuilderValue docBuilderValue = getValueFromObject(value); + c_SetByIndex(c_internal, index, docBuilderValue.c_internal); + } + + public CDocBuilderValue(boolean value) { + c_internal = c_CreateWithBool(value); + } + + public CDocBuilderValue(int value) { + c_internal = c_CreateWithInt(value); + } + + public CDocBuilderValue(double value) { + c_internal = c_CreateWithDouble(value); + } + + public CDocBuilderValue(String value) { + c_internal = c_CreateWithString(value); + } + + public CDocBuilderValue(Object[] values) { + int length = values.length; + c_internal = c_CreateArray(length); + for (int i = 0; i < length; i++) { + this.set(i, getValueFromObject(values[i])); + } + } + + static CDocBuilderValue getValueFromObject(Object obj) { + if (obj instanceof CDocBuilderValue) { + return (CDocBuilderValue)obj; + } else if (obj instanceof Boolean) { + return new CDocBuilderValue((Boolean)obj); + } else if (obj instanceof Integer) { + return new CDocBuilderValue((Integer)obj); + } else if (obj instanceof Double) { + return new CDocBuilderValue((Double)obj); + } else if (obj instanceof String) { + return new CDocBuilderValue((String)obj); + } else if (obj instanceof Object[]) { + return new CDocBuilderValue((Object[])obj); + } else { + throw new IllegalArgumentException("Unsupported type for CDocBuilderValue"); + } + } + + public static CDocBuilderValue createUndefined() { + return new CDocBuilderValue(c_CreateUndefined()); + } + + public static CDocBuilderValue createNull() { + return new CDocBuilderValue(c_CreateNull()); + } + + public static CDocBuilderValue createArray(int length) { + return new CDocBuilderValue(c_CreateArray(length)); + } + + public CDocBuilderValue call(String name) { + return new CDocBuilderValue(c_Call0(c_internal, name)); + } + + public CDocBuilderValue call(String name, Object p1) { + CDocBuilderValue pValue1 = getValueFromObject(p1); + return new CDocBuilderValue(c_Call1(c_internal, name, pValue1.c_internal)); + } + + public CDocBuilderValue call(String name, Object p1, Object p2) { + CDocBuilderValue pValue1 = getValueFromObject(p1); + CDocBuilderValue pValue2 = getValueFromObject(p2); + return new CDocBuilderValue(c_Call2(c_internal, name, pValue1.c_internal, pValue2.c_internal)); + } + + public CDocBuilderValue call(String name, Object p1, Object p2, Object p3) { + CDocBuilderValue pValue1 = getValueFromObject(p1); + CDocBuilderValue pValue2 = getValueFromObject(p2); + CDocBuilderValue pValue3 = getValueFromObject(p3); + return new CDocBuilderValue(c_Call3(c_internal, name, pValue1.c_internal, pValue2.c_internal, pValue3.c_internal)); + } + + public CDocBuilderValue call(String name, Object p1, Object p2, Object p3, Object p4) { + CDocBuilderValue pValue1 = getValueFromObject(p1); + CDocBuilderValue pValue2 = getValueFromObject(p2); + CDocBuilderValue pValue3 = getValueFromObject(p3); + CDocBuilderValue pValue4 = getValueFromObject(p4); + return new CDocBuilderValue(c_Call4(c_internal, name, pValue1.c_internal, pValue2.c_internal, pValue3.c_internal, pValue4.c_internal)); + } + + public CDocBuilderValue call(String name, Object p1, Object p2, Object p3, Object p4, Object p5) { + CDocBuilderValue pValue1 = getValueFromObject(p1); + CDocBuilderValue pValue2 = getValueFromObject(p2); + CDocBuilderValue pValue3 = getValueFromObject(p3); + CDocBuilderValue pValue4 = getValueFromObject(p4); + CDocBuilderValue pValue5 = getValueFromObject(p5); + return new CDocBuilderValue(c_Call5(c_internal, name, pValue1.c_internal, pValue2.c_internal, pValue3.c_internal, pValue4.c_internal, pValue5.c_internal)); + } + + public CDocBuilderValue call(String name, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) { + CDocBuilderValue pValue1 = getValueFromObject(p1); + CDocBuilderValue pValue2 = getValueFromObject(p2); + CDocBuilderValue pValue3 = getValueFromObject(p3); + CDocBuilderValue pValue4 = getValueFromObject(p4); + CDocBuilderValue pValue5 = getValueFromObject(p5); + CDocBuilderValue pValue6 = getValueFromObject(p6); + return new CDocBuilderValue(c_Call6(c_internal, name, pValue1.c_internal, pValue2.c_internal, pValue3.c_internal, pValue4.c_internal, pValue5.c_internal, pValue6.c_internal)); + } + + // Native code + static { + docbuilder.utils.NativeLibraryLoader.loadLibraries(); + } + + long c_internal = 0; + + private static native long c_Create(); + private static native long c_Copy(long other); + private static native void c_Destroy(long self); + + private static native boolean c_IsEmpty(long self); + private static native void c_Clear(long self); + + private static native boolean c_IsNull(long self); + private static native boolean c_IsUndefined(long self); + private static native boolean c_IsInt(long self); + private static native boolean c_IsDouble(long self); + private static native boolean c_IsString(long self); + private static native boolean c_IsFunction(long self); + private static native boolean c_IsObject(long self); + private static native boolean c_IsArray(long self); + + private static native int c_GetLength(long self); + + private static native boolean c_ToBool(long self); + private static native int c_ToInt(long self); + private static native double c_ToDouble(long self); + private static native String c_ToString(long self); + + private static native long c_GetProperty(long self, String name); + private static native long c_GetByIndex(long self, int index); + + private static native void c_SetProperty(long self, String name, long value); + private static native void c_SetByIndex(long self, int index, long value); + + private static native long c_CreateWithBool(boolean value); + private static native long c_CreateWithInt(int value); + private static native long c_CreateWithDouble(double value); + private static native long c_CreateWithString(String value); + + private static native long c_CreateUndefined(); + private static native long c_CreateNull(); + private static native long c_CreateArray(int length); + + private static native long c_Call0(long self, String name); + private static native long c_Call1(long self, String name, long p1); + private static native long c_Call2(long self, String name, long p1, long p2); + private static native long c_Call3(long self, String name, long p1, long p2, long p3); + private static native long c_Call4(long self, String name, long p1, long p2, long p3, long p4); + private static native long c_Call5(long self, String name, long p1, long p2, long p3, long p4, long p5); + private static native long c_Call6(long self, String name, long p1, long p2, long p3, long p4, long p5, long p6); +} diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/FileTypes.java b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/FileTypes.java new file mode 100644 index 0000000000..138248181b --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/FileTypes.java @@ -0,0 +1,47 @@ +package docbuilder; + +public class FileTypes { + public class Document { + private static final int MASK = 0x0040; + public static final int DOCX = MASK + 0x0001; + public static final int DOC = MASK + 0x0002; + public static final int ODT = MASK + 0x0003; + public static final int RTF = MASK + 0x0004; + public static final int TXT = MASK + 0x0005; + public static final int DOTX = MASK + 0x000c; + public static final int OTT = MASK + 0x000f; + public static final int HTML = MASK + 0x0012; + public static final int OFORM_PDF = MASK + 0x0017; + } + + public class Presentation { + private static final int MASK = 0x0080; + public static final int PPTX = MASK + 0x0001; + public static final int PPT = MASK + 0x0002; + public static final int ODP = MASK + 0x0003; + public static final int PPSX = MASK + 0x0004; + public static final int POTX = MASK + 0x0007; + public static final int OTP = MASK + 0x000a; + } + + public class Spreadsheet { + private static final int MASK = 0x0100; + public static final int XLSX = MASK + 0x0001; + public static final int XLS = MASK + 0x0002; + public static final int ODS = MASK + 0x0003; + public static final int CSV = MASK + 0x0004; + public static final int XLTX = MASK + 0x0006; + public static final int OTS = MASK + 0x0009; + } + + public class Graphics { + private static final int PDF_MASK = 0x0200; + public static final int PDF = PDF_MASK + 0x0001; + public static final int PDFA = PDF_MASK + 0x0009; + + private static final int IMAGE_MASK = 0x0400; + public static final int JPG = IMAGE_MASK + 0x0001; + public static final int PNG = IMAGE_MASK + 0x0005; + public static final int BMP = IMAGE_MASK + 0x0008; + } +} diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/utils/NativeLibraryLoader.java b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/utils/NativeLibraryLoader.java new file mode 100644 index 0000000000..3ea326d46e --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/java/docbuilder/utils/NativeLibraryLoader.java @@ -0,0 +1,86 @@ +package docbuilder.utils; + +import java.io.File; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; + +public class NativeLibraryLoader { + // helper class for retrieving information about current OS + public static class OSChecker { + private static String osName = System.getProperty("os.name").toLowerCase(); + + public static boolean isWindows() { + return (osName.indexOf("win") >= 0); + } + + public static boolean isMac() { + return (osName.indexOf("mac") >= 0); + } + + public static boolean isLinux() { + return (osName.indexOf("nix") >= 0 || osName.indexOf("nux") >= 0 || osName.indexOf("aix") > 0); + } + } + + static { + try { + Path libDirPath = getLibPath(); + // load icu libraries + if (OSChecker.isWindows()) { + System.load(libDirPath.resolve("icudt58.dll").toString()); + System.load(libDirPath.resolve("icuuc58.dll").toString()); + } else if (OSChecker.isMac()) { + System.load(libDirPath.resolve("libicudata.58.dylib").toString()); + System.load(libDirPath.resolve("libicuuc.58.dylib").toString()); + } else if (OSChecker.isLinux()) { + System.load(libDirPath.resolve("libicudata.so.58").toString()); + System.load(libDirPath.resolve("libicuuc.so.58").toString()); + } else { + throw new RuntimeException("Unsupported OS"); + } + + String[] libs = {"UnicodeConverter", "kernel", "kernel_network", "graphics", "doctrenderer", "docbuilder.jni"}; + + String prefix = ""; + if (OSChecker.isMac() || OSChecker.isLinux()) { + prefix = "lib"; + } + + String extension = ""; + if (OSChecker.isWindows()) { + extension = ".dll"; + } else if (OSChecker.isMac()) { + extension = ".dylib"; + } else { + extension = ".so"; + } + + for (String lib : libs) { + System.load(libDirPath.resolve(prefix + lib + extension).toString()); + } + } catch (UnsatisfiedLinkError e) { + throw new RuntimeException("Cannot load dynamic libraries. Check if JAR file is in the same directory as all docbuilder libraries."); + } + } + + // Returns path to the directory containing current JAR + public static Path getLibPath() + { + URL url = NativeLibraryLoader.class.getProtectionDomain().getCodeSource().getLocation(); + try { + File jarFile = new File(url.toURI()); + Path jarPath = jarFile.toPath(); + Path libDirPath = jarPath.getParent(); + + return libDirPath; + } catch (URISyntaxException exception) { + // Very unlikely to be happened + throw new RuntimeException("Cannot convert URI of the NativeLibraryLoader.class to URL"); + } + } + + public static void loadLibraries() { + // No-op, just to force the class loading + } +} diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilder.cpp b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilder.cpp new file mode 100644 index 0000000000..4873c76436 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilder.cpp @@ -0,0 +1,179 @@ +#include "docbuilder_CDocBuilder.h" + +#include + +#include "docbuilder.h" +// for wchar_t <=> char conversion +#include "../../../../common/File.h" + +using namespace NSDoctRenderer; + +static std::wstring wstringFromJavaString(JNIEnv* env, jstring jstr) +{ + const char* strUtf = env->GetStringUTFChars(jstr, nullptr); + std::wstring wstr = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)strUtf, (LONG)strlen(strUtf)); + env->ReleaseStringUTFChars(jstr, strUtf); + return wstr; +} + +jlong Java_docbuilder_CDocBuilder_c_1Create(JNIEnv* env, jclass cls) +{ + return reinterpret_cast(new CDocBuilder()); +} + +void Java_docbuilder_CDocBuilder_c_1Destroy(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + delete pSelf; +} + +jint Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jclass cls, jlong self, jstring path, jstring params) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + std::wstring strPath = wstringFromJavaString(env, path); + std::wstring strParams = wstringFromJavaString(env, params); + return (jint)pSelf->OpenFile(strPath.c_str(), strParams.c_str()); +} + +jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByType(JNIEnv* env, jclass cls, jlong self, jint type) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->CreateFile((int)type); +} + +jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + std::wstring strExtension = wstringFromJavaString(env, extension); + return (jboolean)pSelf->CreateFile(strExtension.c_str()); +} + +void Java_docbuilder_CDocBuilder_c_1SetTmpFolder(JNIEnv* env, jclass cls, jlong self, jstring folder) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + std::wstring strFolder = wstringFromJavaString(env, folder); + pSelf->SetTmpFolder(strFolder.c_str()); +} + +jint Java_docbuilder_CDocBuilder_c_1SaveFileByType(JNIEnv* env, jclass cls, jlong self, jint type, jstring path) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + std::wstring strPath = wstringFromJavaString(env, path); + return (jint)pSelf->SaveFile((int)type, strPath.c_str()); +} + +jint Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(JNIEnv* env, jclass cls, jlong self, jint type, jstring path, jstring params) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + std::wstring strPath = wstringFromJavaString(env, path); + std::wstring strParams = wstringFromJavaString(env, params); + return (jint)pSelf->SaveFile((int)type, strPath.c_str(), strParams.c_str()); +} + +jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + std::wstring strExtension = wstringFromJavaString(env, extension); + std::wstring strPath = wstringFromJavaString(env, path); + return (jint)pSelf->SaveFile(strExtension.c_str(), strPath.c_str()); +} + +jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path, jstring params) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + std::wstring strExtension = wstringFromJavaString(env, extension); + std::wstring strPath = wstringFromJavaString(env, path); + std::wstring strParams = wstringFromJavaString(env, params); + return (jint)pSelf->SaveFile(strExtension.c_str(), strPath.c_str(), strParams.c_str()); +} + +void Java_docbuilder_CDocBuilder_c_1CloseFile(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + pSelf->CloseFile(); +} + +jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommand(JNIEnv* env, jclass cls, jlong self, jstring command) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + std::wstring strCommand = wstringFromJavaString(env, command); + return (jboolean)pSelf->ExecuteCommand(strCommand.c_str()); +} + +jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue(JNIEnv* env, jclass cls, jlong self, jstring command, jlong retValue) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + std::wstring strCommand = wstringFromJavaString(env, command); + CDocBuilderValue* pRetValue = reinterpret_cast(retValue); + return (jboolean)pSelf->ExecuteCommand(strCommand.c_str(), pRetValue); +} + +jboolean Java_docbuilder_CDocBuilder_c_1Run(JNIEnv* env, jclass cls, jlong self, jstring path) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + std::wstring strPath = wstringFromJavaString(env, path); + return (jboolean)pSelf->Run(strPath.c_str()); +} + +jboolean Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, jclass cls, jlong self, jstring commands) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + const char* strUtfCommands = env->GetStringUTFChars(commands, nullptr); + jboolean result = (jboolean)pSelf->RunTextA(strUtfCommands); + env->ReleaseStringUTFChars(commands, strUtfCommands); + return result; +} + +void Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring param, jstring value) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + const char* strUtfParam = env->GetStringUTFChars(param, nullptr); + std::wstring strValue = wstringFromJavaString(env, value); + pSelf->SetProperty(strUtfParam, strValue.c_str()); + env->ReleaseStringUTFChars(param, strUtfParam); +} + +void Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jclass cls, jlong self, jstring path, jstring data, jboolean append) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + std::wstring strPath = wstringFromJavaString(env, path); + std::wstring strData = wstringFromJavaString(env, data); + pSelf->WriteData(strPath.c_str(), strData.c_str(), (bool)append); +} + +jboolean Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->IsSaveWithDoctrendererMode(); +} + +jstring Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + char* strUtfVersion = pSelf->GetVersion(); + jstring jstrVersion = env->NewStringUTF(strUtfVersion); + delete[] strUtfVersion; + return jstrVersion; +} + +jlong Java_docbuilder_CDocBuilder_c_1GetContext(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilder* pSelf = reinterpret_cast(self); + return reinterpret_cast(new CDocBuilderContext(pSelf->GetContext())); +} + +void Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls) +{ + CDocBuilder::Initialize(); +} + +void Java_docbuilder_CDocBuilder_c_1InitializeWithDirectory(JNIEnv* env, jclass cls, jstring directory) +{ + std::wstring strDirectory = wstringFromJavaString(env, directory); + CDocBuilder::Initialize(strDirectory.c_str()); +} + +void Java_docbuilder_CDocBuilder_c_1Dispose(JNIEnv* env, jclass cls) +{ + CDocBuilder::Dispose(); +} diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilder.h b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilder.h new file mode 100644 index 0000000000..f7fce7a1eb --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilder.h @@ -0,0 +1,197 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class docbuilder_CDocBuilder */ + +#ifndef _Included_docbuilder_CDocBuilder +#define _Included_docbuilder_CDocBuilder +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: docbuilder_CDocBuilder + * Method: c_Create + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1Create + (JNIEnv *, jclass); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_Destroy + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Destroy + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_OpenFile + * Signature: (JLjava/lang/String;Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1OpenFile + (JNIEnv *, jclass, jlong, jstring, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_CreateFileByType + * Signature: (JI)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1CreateFileByType + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_CreateFileByExtension + * Signature: (JLjava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1CreateFileByExtension + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_SetTmpFolder + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetTmpFolder + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_SaveFileByType + * Signature: (JILjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByType + (JNIEnv *, jclass, jlong, jint, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_SaveFileByTypeWithParams + * Signature: (JILjava/lang/String;Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams + (JNIEnv *, jclass, jlong, jint, jstring, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_SaveFileByExtension + * Signature: (JLjava/lang/String;Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtension + (JNIEnv *, jclass, jlong, jstring, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_SaveFileByExtensionWithParams + * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams + (JNIEnv *, jclass, jlong, jstring, jstring, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_CloseFile + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1CloseFile + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_ExecuteCommand + * Signature: (JLjava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommand + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_ExecuteCommandWithRetValue + * Signature: (JLjava/lang/String;J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue + (JNIEnv *, jclass, jlong, jstring, jlong); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_Run + * Signature: (JLjava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1Run + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_RunText + * Signature: (JLjava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1RunText + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_SetProperty + * Signature: (JLjava/lang/String;Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetProperty + (JNIEnv *, jclass, jlong, jstring, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_WriteData + * Signature: (JLjava/lang/String;Ljava/lang/String;Z)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1WriteData + (JNIEnv *, jclass, jlong, jstring, jstring, jboolean); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_IsSaveWithDoctrendererMode + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_GetVersion + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilder_c_1GetVersion + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_GetContext + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContext + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_Initialize + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Initialize + (JNIEnv *, jclass); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_InitializeWithDirectory + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1InitializeWithDirectory + (JNIEnv *, jclass, jstring); + +/* + * Class: docbuilder_CDocBuilder + * Method: c_Dispose + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Dispose + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContext.cpp b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContext.cpp new file mode 100644 index 0000000000..8398d14c37 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContext.cpp @@ -0,0 +1,64 @@ +#include "docbuilder_CDocBuilderContext.h" + +#include "docbuilder.h" + +using namespace NSDoctRenderer; + +jlong Java_docbuilder_CDocBuilderContext_c_1Create(JNIEnv* env, jclass cls) +{ + return reinterpret_cast(new CDocBuilderContext()); +} + +jlong Java_docbuilder_CDocBuilderContext_c_1Copy(JNIEnv* env, jclass cls, jlong other) +{ + CDocBuilderContext* pOther = reinterpret_cast(other); + return reinterpret_cast(new CDocBuilderContext(*pOther)); +} + +void Java_docbuilder_CDocBuilderContext_c_1Destroy(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderContext* pSelf = reinterpret_cast(self); + delete pSelf; +} + +jlong Java_docbuilder_CDocBuilderContext_c_1CreateUndefined(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderContext* pSelf = reinterpret_cast(self); + return reinterpret_cast(new CDocBuilderValue(pSelf->CreateUndefined())); +} + +jlong Java_docbuilder_CDocBuilderContext_c_1CreateNull(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderContext* pSelf = reinterpret_cast(self); + return reinterpret_cast(new CDocBuilderValue(pSelf->CreateNull())); +} + +jlong Java_docbuilder_CDocBuilderContext_c_1CreateObject(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderContext* pSelf = reinterpret_cast(self); + return reinterpret_cast(new CDocBuilderValue(pSelf->CreateObject())); +} + +jlong Java_docbuilder_CDocBuilderContext_c_1CreateArray(JNIEnv* env, jclass cls, jlong self, jint length) +{ + CDocBuilderContext* pSelf = reinterpret_cast(self); + return reinterpret_cast(new CDocBuilderValue(pSelf->CreateArray((int)length))); +} + +jlong Java_docbuilder_CDocBuilderContext_c_1GetGlobal(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderContext* pSelf = reinterpret_cast(self); + return reinterpret_cast(new CDocBuilderValue(pSelf->GetGlobal())); +} + +jlong Java_docbuilder_CDocBuilderContext_c_1CreateScope(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderContext* pSelf = reinterpret_cast(self); + return reinterpret_cast(new CDocBuilderContextScope(pSelf->CreateScope())); +} + +jboolean Java_docbuilder_CDocBuilderContext_c_1IsError(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderContext* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->IsError(); +} diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContext.h b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContext.h new file mode 100644 index 0000000000..43e72ee4f1 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContext.h @@ -0,0 +1,93 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class docbuilder_CDocBuilderContext */ + +#ifndef _Included_docbuilder_CDocBuilderContext +#define _Included_docbuilder_CDocBuilderContext +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: docbuilder_CDocBuilderContext + * Method: c_Create + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Create + (JNIEnv *, jclass); + +/* + * Class: docbuilder_CDocBuilderContext + * Method: c_Copy + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Copy + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderContext + * Method: c_Destroy + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContext_c_1Destroy + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderContext + * Method: c_CreateUndefined + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateUndefined + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderContext + * Method: c_CreateNull + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateNull + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderContext + * Method: c_CreateObject + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateObject + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderContext + * Method: c_CreateArray + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateArray + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: docbuilder_CDocBuilderContext + * Method: c_GetGlobal + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1GetGlobal + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderContext + * Method: c_CreateScope + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateScope + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderContext + * Method: c_IsError + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderContext_c_1IsError + (JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContextScope.cpp b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContextScope.cpp new file mode 100644 index 0000000000..c63c69ae48 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContextScope.cpp @@ -0,0 +1,28 @@ +#include "docbuilder_CDocBuilderContextScope.h" + +#include "docbuilder.h" + +using namespace NSDoctRenderer; + +jlong Java_docbuilder_CDocBuilderContextScope_c_1Create(JNIEnv* env, jclass cls) +{ + return reinterpret_cast(new CDocBuilderContextScope()); +} + +jlong Java_docbuilder_CDocBuilderContextScope_c_1Copy(JNIEnv* env, jclass cls, jlong other) +{ + CDocBuilderContextScope* pOther = reinterpret_cast(other); + return reinterpret_cast(new CDocBuilderContextScope(*pOther)); +} + +void Java_docbuilder_CDocBuilderContextScope_c_1Destroy(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderContextScope* pSelf = reinterpret_cast(self); + delete pSelf; +} + +void Java_docbuilder_CDocBuilderContextScope_c_1Close(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderContextScope* pSelf = reinterpret_cast(self); + pSelf->Close(); +} diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContextScope.h b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContextScope.h new file mode 100644 index 0000000000..3ead55b861 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderContextScope.h @@ -0,0 +1,45 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class docbuilder_CDocBuilderContextScope */ + +#ifndef _Included_docbuilder_CDocBuilderContextScope +#define _Included_docbuilder_CDocBuilderContextScope +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: docbuilder_CDocBuilderContextScope + * Method: c_Create + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Create + (JNIEnv *, jclass); + +/* + * Class: docbuilder_CDocBuilderContextScope + * Method: c_Copy + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Copy + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderContextScope + * Method: c_Destroy + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Destroy + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderContextScope + * Method: c_Close + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Close + (JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderValue.cpp b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderValue.cpp new file mode 100644 index 0000000000..cfb3099ea9 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderValue.cpp @@ -0,0 +1,273 @@ +#include "docbuilder_CDocBuilderValue.h" + +#include + +#include "docbuilder.h" +// for wchar_t <=> char conversion +#include "../../../../common/File.h" + +using namespace NSDoctRenderer; + +jlong Java_docbuilder_CDocBuilderValue_c_1Create(JNIEnv* env, jclass cls) +{ + return reinterpret_cast(new CDocBuilderValue()); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1Copy(JNIEnv* env, jclass cls, jlong other) +{ + CDocBuilderValue* pOther = reinterpret_cast(other); + return reinterpret_cast(new CDocBuilderValue(*pOther)); +} + +void Java_docbuilder_CDocBuilderValue_c_1Destroy(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + delete pSelf; +} + +jboolean Java_docbuilder_CDocBuilderValue_c_1IsEmpty(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->IsEmpty(); +} + +void Java_docbuilder_CDocBuilderValue_c_1Clear(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + pSelf->Clear(); +} + +jboolean Java_docbuilder_CDocBuilderValue_c_1IsNull(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->IsNull(); +} + +jboolean Java_docbuilder_CDocBuilderValue_c_1IsUndefined(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->IsUndefined(); +} + +jboolean Java_docbuilder_CDocBuilderValue_c_1IsInt(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->IsInt(); +} + +jboolean Java_docbuilder_CDocBuilderValue_c_1IsDouble(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->IsDouble(); +} + +jboolean Java_docbuilder_CDocBuilderValue_c_1IsString(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->IsString(); +} + +jboolean Java_docbuilder_CDocBuilderValue_c_1IsFunction(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->IsFunction(); +} + +jboolean Java_docbuilder_CDocBuilderValue_c_1IsObject(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->IsObject(); +} + +jboolean Java_docbuilder_CDocBuilderValue_c_1IsArray(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->IsArray(); +} + +jint Java_docbuilder_CDocBuilderValue_c_1GetLength(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jint)pSelf->GetLength(); +} + +jboolean Java_docbuilder_CDocBuilderValue_c_1ToBool(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jboolean)pSelf->ToBool(); +} + +jint Java_docbuilder_CDocBuilderValue_c_1ToInt(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jint)pSelf->ToInt(); +} + +jdouble Java_docbuilder_CDocBuilderValue_c_1ToDouble(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + return (jdouble)pSelf->ToDouble(); +} + +jstring Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* env, jclass cls, jlong self) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + CString strValue = pSelf->ToString(); + std::string strUtfData = NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(strValue.c_str(), (LONG)wcslen(strValue.c_str())); + return env->NewStringUTF(strUtfData.c_str()); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv* env, jclass cls, jlong self, jstring name) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + const char* strUtfName = env->GetStringUTFChars(name, nullptr); + CDocBuilderValue* pValue = new CDocBuilderValue(pSelf->Get(strUtfName)); + env->ReleaseStringUTFChars(name, strUtfName); + return reinterpret_cast(pValue); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1GetByIndex(JNIEnv* env, jclass cls, jlong self, jint index) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + CDocBuilderValue* pValue = new CDocBuilderValue(pSelf->Get((int)index)); + return reinterpret_cast(pValue); +} + +void Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring name, jlong value) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + CDocBuilderValue* pValue = reinterpret_cast(value); + const char* strUtfName = env->GetStringUTFChars(name, nullptr); + std::wstring strName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)strUtfName, (LONG)strlen(strUtfName)); + pSelf->Set(strName.c_str(), *pValue); + env->ReleaseStringUTFChars(name, strUtfName); +} + +void Java_docbuilder_CDocBuilderValue_c_1SetByIndex(JNIEnv* env, jclass cls, jlong self, jint index, jlong value) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + CDocBuilderValue* pValue = reinterpret_cast(value); + pSelf->Set((int)index, *pValue); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithBool(JNIEnv* env, jclass cls, jboolean value) +{ + return reinterpret_cast(new CDocBuilderValue((bool)value)); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithInt(JNIEnv* env, jclass cls, jint value) +{ + return reinterpret_cast(new CDocBuilderValue((int)value)); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble(JNIEnv* env, jclass cls, jdouble value) +{ + return reinterpret_cast(new CDocBuilderValue((double)value)); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNIEnv* env, jclass cls, jstring str) +{ + const char* strUtf = env->GetStringUTFChars(str, nullptr); + CDocBuilderValue* pValue = new CDocBuilderValue(strUtf); + env->ReleaseStringUTFChars(str, strUtf); + return reinterpret_cast(pValue); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1CreateUndefined(JNIEnv* env, jclass cls) +{ + return reinterpret_cast(new CDocBuilderValue(CDocBuilderValue::CreateUndefined())); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1CreateNull(JNIEnv* env, jclass cls) +{ + return reinterpret_cast(new CDocBuilderValue(CDocBuilderValue::CreateNull())); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1CreateArray(JNIEnv* env, jclass cls, jint length) +{ + return reinterpret_cast(new CDocBuilderValue(CDocBuilderValue::CreateArray((int)length))); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, jclass cls, jlong self, jstring name) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + const char* strUtfName = env->GetStringUTFChars(name, nullptr); + CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName)); + env->ReleaseStringUTFChars(name, strUtfName); + return reinterpret_cast(pReturnValue); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + CDocBuilderValue* pParam1 = reinterpret_cast(p1); + const char* strUtfName = env->GetStringUTFChars(name, nullptr); + CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1)); + env->ReleaseStringUTFChars(name, strUtfName); + return reinterpret_cast(pReturnValue); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + CDocBuilderValue* pParam1 = reinterpret_cast(p1); + CDocBuilderValue* pParam2 = reinterpret_cast(p2); + const char* strUtfName = env->GetStringUTFChars(name, nullptr); + CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1, *pParam2)); + env->ReleaseStringUTFChars(name, strUtfName); + return reinterpret_cast(pReturnValue); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + CDocBuilderValue* pParam1 = reinterpret_cast(p1); + CDocBuilderValue* pParam2 = reinterpret_cast(p2); + CDocBuilderValue* pParam3 = reinterpret_cast(p3); + const char* strUtfName = env->GetStringUTFChars(name, nullptr); + CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1, *pParam2, *pParam3)); + env->ReleaseStringUTFChars(name, strUtfName); + return reinterpret_cast(pReturnValue); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + CDocBuilderValue* pParam1 = reinterpret_cast(p1); + CDocBuilderValue* pParam2 = reinterpret_cast(p2); + CDocBuilderValue* pParam3 = reinterpret_cast(p3); + CDocBuilderValue* pParam4 = reinterpret_cast(p4); + const char* strUtfName = env->GetStringUTFChars(name, nullptr); + CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1, *pParam2, *pParam3, *pParam4)); + env->ReleaseStringUTFChars(name, strUtfName); + return reinterpret_cast(pReturnValue); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1Call5(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + CDocBuilderValue* pParam1 = reinterpret_cast(p1); + CDocBuilderValue* pParam2 = reinterpret_cast(p2); + CDocBuilderValue* pParam3 = reinterpret_cast(p3); + CDocBuilderValue* pParam4 = reinterpret_cast(p4); + CDocBuilderValue* pParam5 = reinterpret_cast(p5); + const char* strUtfName = env->GetStringUTFChars(name, nullptr); + CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1, *pParam2, *pParam3, *pParam4, *pParam5)); + env->ReleaseStringUTFChars(name, strUtfName); + return reinterpret_cast(pReturnValue); +} + +jlong Java_docbuilder_CDocBuilderValue_c_1Call6(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5, jlong p6) +{ + CDocBuilderValue* pSelf = reinterpret_cast(self); + CDocBuilderValue* pParam1 = reinterpret_cast(p1); + CDocBuilderValue* pParam2 = reinterpret_cast(p2); + CDocBuilderValue* pParam3 = reinterpret_cast(p3); + CDocBuilderValue* pParam4 = reinterpret_cast(p4); + CDocBuilderValue* pParam5 = reinterpret_cast(p5); + CDocBuilderValue* pParam6 = reinterpret_cast(p6); + const char* strUtfName = env->GetStringUTFChars(name, nullptr); + CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1, *pParam2, *pParam3, *pParam4, *pParam5, *pParam6)); + env->ReleaseStringUTFChars(name, strUtfName); + return reinterpret_cast(pReturnValue); +} diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderValue.h b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderValue.h new file mode 100644 index 0000000000..2e0c8e4eb0 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_CDocBuilderValue.h @@ -0,0 +1,301 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class docbuilder_CDocBuilderValue */ + +#ifndef _Included_docbuilder_CDocBuilderValue +#define _Included_docbuilder_CDocBuilderValue +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_Create + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Create + (JNIEnv *, jclass); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_Copy + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Copy + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_Destroy + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Destroy + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_IsEmpty + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsEmpty + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_Clear + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Clear + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_IsNull + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsNull + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_IsUndefined + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsUndefined + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_IsInt + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsInt + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_IsDouble + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsDouble + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_IsString + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsString + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_IsFunction + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsFunction + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_IsObject + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsObject + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_IsArray + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsArray + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_GetLength + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1GetLength + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_ToBool + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1ToBool + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_ToInt + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1ToInt + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_ToDouble + * Signature: (J)D + */ +JNIEXPORT jdouble JNICALL Java_docbuilder_CDocBuilderValue_c_1ToDouble + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_ToString + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilderValue_c_1ToString + (JNIEnv *, jclass, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_GetProperty + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetProperty + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_GetByIndex + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetByIndex + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_SetProperty + * Signature: (JLjava/lang/String;J)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetProperty + (JNIEnv *, jclass, jlong, jstring, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_SetByIndex + * Signature: (JIJ)V + */ +JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetByIndex + (JNIEnv *, jclass, jlong, jint, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_CreateWithBool + * Signature: (Z)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithBool + (JNIEnv *, jclass, jboolean); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_CreateWithInt + * Signature: (I)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithInt + (JNIEnv *, jclass, jint); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_CreateWithDouble + * Signature: (D)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble + (JNIEnv *, jclass, jdouble); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_CreateWithString + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithString + (JNIEnv *, jclass, jstring); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_CreateUndefined + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateUndefined + (JNIEnv *, jclass); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_CreateNull + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateNull + (JNIEnv *, jclass); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_CreateArray + * Signature: (I)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateArray + (JNIEnv *, jclass, jint); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_Call0 + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call0 + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_Call1 + * Signature: (JLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call1 + (JNIEnv *, jclass, jlong, jstring, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_Call2 + * Signature: (JLjava/lang/String;JJ)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call2 + (JNIEnv *, jclass, jlong, jstring, jlong, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_Call3 + * Signature: (JLjava/lang/String;JJJ)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call3 + (JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_Call4 + * Signature: (JLjava/lang/String;JJJJ)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call4 + (JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_Call5 + * Signature: (JLjava/lang/String;JJJJJ)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call5 + (JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong, jlong, jlong); + +/* + * Class: docbuilder_CDocBuilderValue + * Method: c_Call6 + * Signature: (JLjava/lang/String;JJJJJJ)J + */ +JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call6 + (JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong, jlong, jlong, jlong); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_jni.pro b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_jni.pro new file mode 100644 index 0000000000..6fe624560f --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/src/jni/docbuilder_jni.pro @@ -0,0 +1,42 @@ +QT -= core +QT -= gui + +TARGET = docbuilder.jni + +TEMPLATE = lib + +CONFIG += shared +CONFIG += plugin + +CORE_ROOT_DIR = $$PWD/../../../../.. +PWD_ROOT_DIR = $$PWD + +include($$CORE_ROOT_DIR/Common/base.pri) +include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri) + +ADD_DEPENDENCY(graphics, kernel, kernel_network, UnicodeConverter, doctrenderer) + +INCLUDEPATH += ../../.. + +# Specify JDK path here +JDK_PATH = "C:/Program Files/Java/jdk-22" + +INCLUDEPATH += $$JDK_PATH/include + +core_windows:JAVA_ARCH = win32 +core_linux:JAVA_ARCH = linux +core_mac:JAVA_ARCH = darwin + +INCLUDEPATH += $$JDK_PATH/include/$$JAVA_ARCH + +SOURCES += \ + docbuilder_CDocBuilderValue.cpp \ + docbuilder_CDocBuilder.cpp \ + docbuilder_CDocBuilderContextScope.cpp \ + docbuilder_CDocBuilderContext.cpp + +HEADERS += \ + docbuilder_CDocBuilderValue.h \ + docbuilder_CDocBuilder.h \ + docbuilder_CDocBuilderContextScope.h \ + docbuilder_CDocBuilderContext.h diff --git a/DesktopEditor/doctrenderer/docbuilder.java/test/Program.java b/DesktopEditor/doctrenderer/docbuilder.java/test/Program.java new file mode 100644 index 0000000000..ce734e5f03 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/test/Program.java @@ -0,0 +1,44 @@ +import docbuilder.*; + +public class Program { + public static void main(String[] args) { + String resultPath = "result.docx"; + + test(resultPath); + + // Need to explicitly call System.gc() because finalizers might not automatically get called + // Note: Even System.gc() can not guarantee that finalizers will be actually called. Possible memory leaks! + System.gc(); + } + + public static void test(String resultPath) { + CDocBuilder.initialize(""); + CDocBuilder builder = new CDocBuilder(); + builder.createFile(FileTypes.Document.DOCX); + + CDocBuilderContext context = builder.getContext(); + CDocBuilderContextScope scope = context.createScope(); + + CDocBuilderValue global = context.getGlobal(); + + CDocBuilderValue api = global.get("Api"); + CDocBuilderValue document = api.call("GetDocument"); + CDocBuilderValue paragraph1 = api.call("CreateParagraph"); + + paragraph1.call("SetSpacingAfter", 1000, false); + paragraph1.call("AddText", "Hello from Java!"); + + CDocBuilderValue paragraph2 = api.call("CreateParagraph"); + paragraph2.call("AddText", "Goodbye!"); + + CDocBuilderValue[] paragraphs = { paragraph1, paragraph2 }; + CDocBuilderValue content = new CDocBuilderValue(paragraphs); + + document.call("InsertContent", content); + + builder.saveFile(FileTypes.Document.DOCX, resultPath); + builder.closeFile(); + + CDocBuilder.dispose(); + } +} diff --git a/DesktopEditor/doctrenderer/docbuilder.java/test/make_test.py b/DesktopEditor/doctrenderer/docbuilder.java/test/make_test.py new file mode 100644 index 0000000000..9af45c86a1 --- /dev/null +++ b/DesktopEditor/doctrenderer/docbuilder.java/test/make_test.py @@ -0,0 +1,29 @@ +import os +import argparse + +# NOTE: In JDK 8 and earlier, `javac` does not create the directories specified in the -d option if they do not already exist +# So we need to create them manually +def makedirs(dir): + if not os.path.exists(dir): + os.makedirs(dir) + return + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Build and run the test example for docbuilder Java wrapper') + parser.add_argument('-r', '--run', dest='builder_dir', metavar='', help='Run the test example with specified docbuilder directory') + args = parser.parse_args() + + file_dir = os.path.dirname(os.path.realpath(__file__)); + os.chdir(file_dir) + + java_file = 'Program.java' + + if args.builder_dir: + builder_dir = args.builder_dir + os.system('java -cp ' + builder_dir + '/docbuilder.jar' + os.pathsep + 'build/classes Program') + else: + makedirs('build/classes') + os.system('javac -d build/classes -cp ../build/libs/docbuilder.jar ' + java_file) + print('Program was built successfully') + print('Run it with: java -cp \"/path/to/docbuilder/docbuilder.jar' + os.pathsep + 'build/classes\" Program') + print('Or just run: python make_test.py --run \"/path/to/docbuilder\"') diff --git a/DesktopEditor/doctrenderer/docbuilder.python/src/docbuilder_functions.cpp b/DesktopEditor/doctrenderer/docbuilder.python/src/docbuilder_functions.cpp index 24bb38523f..6df39de00e 100644 --- a/DesktopEditor/doctrenderer/docbuilder.python/src/docbuilder_functions.cpp +++ b/DesktopEditor/doctrenderer/docbuilder.python/src/docbuilder_functions.cpp @@ -95,7 +95,7 @@ const wchar_t* CDocBuilderValue_ToString(CDocBuilderValue* self) CString strValue = self->ToString(); size_t len = wcslen(strValue.c_str()); wchar_t* strRes = new wchar_t[len + 1]; - memcpy(strRes, strValue.c_str(), (len + 1) + sizeof(wchar_t)); + memcpy(strRes, strValue.c_str(), (len + 1) * sizeof(wchar_t)); return strRes; }