Refactoring

This commit is contained in:
Oleg Korshul
2021-10-05 21:03:46 +03:00
parent 3f73c12f83
commit 39f6dda5d8
5 changed files with 111 additions and 692 deletions

View File

@ -5,38 +5,40 @@ import sys
sys.path.append("../../../../../build_tools/scripts")
import base
import os
import json
if not base.is_file("raster.o"):
base.cmd("python", ["raster_make.py"])
if not base.is_file("raster.o"):
print("raster_make.py error")
exit(0)
if not base.is_file("./raster.o"):
base.cmd("python", ["raster_make.py"])
if not base.is_file("./raster.o"):
print("raster_make.py error")
exit(0)
base.configure_common_apps()
if base.is_dir("./temp"):
base.delete_dir("./temp")
base.create_dir("./temp")
if base.is_dir("./o"):
base.delete_dir("./o")
base.create_dir("./o")
# fetch emsdk
command_prefix = "" if ("windows" == base.host_platform()) else "./"
if not base.is_dir("emsdk"):
base.cmd("git", ["clone", "https://github.com/emscripten-core/emsdk.git"])
os.chdir("emsdk")
base.cmd(command_prefix + "emsdk", ["install", "latest"])
base.cmd(command_prefix + "emsdk", ["activate", "latest"])
os.chdir("../")
base.cmd("git", ["clone", "https://github.com/emscripten-core/emsdk.git"])
os.chdir("emsdk")
base.cmd(command_prefix + "emsdk", ["install", "latest"])
base.cmd(command_prefix + "emsdk", ["activate", "latest"])
os.chdir("../")
if not base.is_dir("xml"):
base.copy_dir("../../../xml", "./xml")
base.replaceInFile("./xml/libxml2/libxml.h", "xmlNop(void)", "xmlNop(void* context, char* buffer, int len)")
base.replaceInFile("./xml/libxml2/xmlIO.c", "xmlNop(void)", "xmlNop(void* context, char* buffer, int len)")
base.replaceInFile("./xml/src/xmllight_private.h", "#include \"../../common/", "#include \"../../../../../common/")
base.replaceInFile("./xml/include/xmlutils.h", "#include \"../../common/", "#include \"../../../../../common/")
base.copy_dir("../../../xml", "./xml")
base.replaceInFile("./xml/libxml2/libxml.h", "xmlNop(void)", "xmlNop(void* context, char* buffer, int len)")
base.replaceInFile("./xml/libxml2/xmlIO.c", "xmlNop(void)", "xmlNop(void* context, char* buffer, int len)")
base.replaceInFile("./xml/src/xmllight_private.h", "#include \"../../common/", "#include \"../../../../../common/")
base.replaceInFile("./xml/include/xmlutils.h", "#include \"../../common/", "#include \"../../../../../common/")
# compile
compiler_flags = ["-O3",
# "-fno-rtti", cryptopp использует typeid
"-Wno-unused-command-line-argument",
"-s WASM=1",
"-s ALLOW_MEMORY_GROWTH=1",
"-s FILESYSTEM=0",
@ -54,68 +56,67 @@ exported_functions = ["_malloc",
"_GetLinks",
"_GetStructure"]
libGraphics_src_path = "../../"
input_graphics_sources = ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp"]
compile_files_array = []
libFontEngine_src_path = "../../../fontengine/"
input_fontengine_sources = ["GlyphString.cpp", "FontManager.cpp", "FontFile.cpp", "FontPath.cpp", "ApplicationFonts.cpp"]
compile_files_array.append("g")
compile_files_array.append("../../")
compile_files_array.append(["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp"])
libAgg_src_path = "../../../agg-2.4/src/"
input_agg_sources = ["agg_arc.cpp", "agg_vcgen_stroke.cpp", "agg_vcgen_dash.cpp", "agg_trans_affine.cpp", "agg_curves.cpp"]
compile_files_array.append("fe")
compile_files_array.append("../../../fontengine/")
compile_files_array.append(["GlyphString.cpp", "FontManager.cpp", "FontFile.cpp", "FontPath.cpp", "ApplicationFonts.cpp"])
libFreetype_src_path = "../../../freetype-2.10.4/src/"
input_freetype_sources = ["base/ftinit.c", "base/ftlcdfil.c", "base/ftobjs.c", "base/ftglyph.c", "base/ftoutln.c", "base/ftutil.c", "base/ftgloadr.c", "base/ftfntfmt.c", "base/ftcalc.c", "base/ftbitmap.c", "base/ftstream.c", "base/fthash.c", "base/ftdebug.c", "base/fttrigon.c", "base/ftadvanc.c", "base/ftpsprop.c", "base/ftrfork.c", "bdf/bdfdrivr.c", "bdf/bdflib.c", "smooth/ftsmooth.c", "smooth/ftgrays.c", "../builds/unix/ftsystem.c", "autofit/afmodule.c", "autofit/afhints.c", "autofit/afloader.c", "autofit/afglobal.c", "autofit/afshaper.c", "autofit/afranges.c", "autofit/afdummy.c", "autofit/aflatin.c", "autofit/afcjk.c", "autofit/afindic.c", "autofit/afangles.c", "autofit/afblue.c", "autofit/afwarp.c", "truetype/ttdriver.c", "truetype/ttgload.c", "truetype/ttpload.c", "truetype/ttobjs.c", "truetype/ttgxvar.c", "truetype/ttinterp.c", "type1/t1driver.c", "type1/t1afm.c", "type1/t1load.c", "type1/t1gload.c", "type1/t1objs.c", "type1/t1parse.c", "cff/cffdrivr.c", "cff/cffgload.c", "cff/cffload.c", "cff/cffcmap.c", "cff/cffparse.c", "cff/cffobjs.c", "cid/cidriver.c", "cid/cidobjs.c", "cid/cidgload.c", "cid/cidload.c", "cid/cidparse.c", "pfr/pfrdrivr.c", "pfr/pfrobjs.c", "pfr/pfrload.c", "pfr/pfrgload.c", "pfr/pfrcmap.c", "pfr/pfrsbit.c", "type42/t42drivr.c", "type42/t42objs.c", "type42/t42parse.c", "winfonts/winfnt.c", "pcf/pcfdrivr.c", "pcf/pcfread.c", "pcf/pcfutil.c", "psaux/psauxmod.c", "psaux/psobjs.c", "psaux/t1decode.c", "psaux/psft.c", "psaux/afmparse.c", "psaux/t1cmap.c", "psaux/cffdecode.c", "psaux/psconv.c", "psaux/psfont.c", "psaux/psblues.c", "psaux/psintrp.c", "psaux/pserror.c", "psaux/psstack.c", "psaux/pshints.c", "psaux/psarrst.c", "psaux/psread.c", "psnames/psmodule.c", "pshinter/pshmod.c", "pshinter/pshrec.c", "pshinter/pshglob.c", "pshinter/pshalgo.c", "raster/ftrend1.c", "raster/ftraster.c", "sfnt/sfdriver.c", "sfnt/ttpost.c", "sfnt/sfobjs.c", "sfnt/ttload.c", "sfnt/ttbdf.c", "sfnt/ttmtx.c", "sfnt/ttkern.c", "sfnt/sfwoff.c", "sfnt/ttcmap.c", "sfnt/ttsbit.c", "sfnt/sfwoff2.c", "sfnt/ttcolr.c", "sfnt/woff2tags.c", "sfnt/ttcpal.c", "gzip/ftgzip.c", "lzw/ftlzw.c"]
compile_files_array.append("a")
compile_files_array.append("../../../agg-2.4/src/")
compile_files_array.append(["agg_arc.cpp", "agg_vcgen_stroke.cpp", "agg_vcgen_dash.cpp", "agg_trans_affine.cpp", "agg_curves.cpp"])
libCommon_src_path = "../../../common/"
input_common_sources = ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp"]
compile_files_array.append("f")
compile_files_array.append("../../../freetype-2.10.4/src/")
compile_files_array.append(["base/ftinit.c", "base/ftlcdfil.c", "base/ftobjs.c", "base/ftglyph.c", "base/ftoutln.c", "base/ftutil.c", "base/ftgloadr.c", "base/ftfntfmt.c", "base/ftcalc.c", "base/ftbitmap.c", "base/ftstream.c", "base/fthash.c", "base/ftdebug.c", "base/fttrigon.c", "base/ftadvanc.c", "base/ftpsprop.c", "base/ftrfork.c", "bdf/bdfdrivr.c", "bdf/bdflib.c", "smooth/ftsmooth.c", "smooth/ftgrays.c", "../builds/unix/ftsystem.c", "autofit/afmodule.c", "autofit/afhints.c", "autofit/afloader.c", "autofit/afglobal.c", "autofit/afshaper.c", "autofit/afranges.c", "autofit/afdummy.c", "autofit/aflatin.c", "autofit/afcjk.c", "autofit/afindic.c", "autofit/afangles.c", "autofit/afblue.c", "autofit/afwarp.c", "truetype/ttdriver.c", "truetype/ttgload.c", "truetype/ttpload.c", "truetype/ttobjs.c", "truetype/ttgxvar.c", "truetype/ttinterp.c", "type1/t1driver.c", "type1/t1afm.c", "type1/t1load.c", "type1/t1gload.c", "type1/t1objs.c", "type1/t1parse.c", "cff/cffdrivr.c", "cff/cffgload.c", "cff/cffload.c", "cff/cffcmap.c", "cff/cffparse.c", "cff/cffobjs.c", "cid/cidriver.c", "cid/cidobjs.c", "cid/cidgload.c", "cid/cidload.c", "cid/cidparse.c", "pfr/pfrdrivr.c", "pfr/pfrobjs.c", "pfr/pfrload.c", "pfr/pfrgload.c", "pfr/pfrcmap.c", "pfr/pfrsbit.c", "type42/t42drivr.c", "type42/t42objs.c", "type42/t42parse.c", "winfonts/winfnt.c", "pcf/pcfdrivr.c", "pcf/pcfread.c", "pcf/pcfutil.c", "psaux/psauxmod.c", "psaux/psobjs.c", "psaux/t1decode.c", "psaux/psft.c", "psaux/afmparse.c", "psaux/t1cmap.c", "psaux/cffdecode.c", "psaux/psconv.c", "psaux/psfont.c", "psaux/psblues.c", "psaux/psintrp.c", "psaux/pserror.c", "psaux/psstack.c", "psaux/pshints.c", "psaux/psarrst.c", "psaux/psread.c", "psnames/psmodule.c", "pshinter/pshmod.c", "pshinter/pshrec.c", "pshinter/pshglob.c", "pshinter/pshalgo.c", "raster/ftrend1.c", "raster/ftraster.c", "sfnt/sfdriver.c", "sfnt/ttpost.c", "sfnt/sfobjs.c", "sfnt/ttload.c", "sfnt/ttbdf.c", "sfnt/ttmtx.c", "sfnt/ttkern.c", "sfnt/sfwoff.c", "sfnt/ttcmap.c", "sfnt/ttsbit.c", "sfnt/sfwoff2.c", "sfnt/ttcolr.c", "sfnt/woff2tags.c", "sfnt/ttcpal.c", "gzip/ftgzip.c", "lzw/ftlzw.c"])
libIcu_src_path = "../../../../Common/3dParty/icu/icu/source/common/"
input_icu_sources = ["ucnv.c", "ustr_wcs.cpp", "ucnv_err.c", "ucnv_bld.cpp", "ustrtrns.cpp", "ucnv_cb.c", "udata.cpp", "ucnv_io.cpp", "uhash.c", "udatamem.c", "cmemory.c", "ustring.cpp", "umutex.cpp", "putil.cpp", "ustr_cnv.cpp", "ucnvmbcs.cpp", "ucnvlat1.c", "ucnv_u16.c", "ucnv_u8.c", "ucnv_u32.c", "ucnv_u7.c", "ucln_cmn.cpp", "ucnv2022.cpp", "ucnv_lmb.c", "ucnvhz.c", "ucnvscsu.c", "ucnvisci.c", "ucnvbocu.cpp", "ucnv_ct.c", "ucnv_cnv.c", "stringpiece.cpp", "charstr.cpp", "umapfile.c", "ucmndata.c", "ucnv_ext.cpp", "uobject.cpp", "umath.c", "ubidi_props.c", "uchar.c", "uinvchar.c", "usprep.cpp", "unistr.cpp", "uniset_props.cpp", "loadednormalizer2impl.cpp", "filterednormalizer2.cpp", "utrie2.cpp", "normalizer2.cpp", "normalizer2impl.cpp", "utrie.cpp", "ucase.cpp", "uniset.cpp", "ruleiter.cpp", "parsepos.cpp", "util.cpp", "uprops.cpp", "uvector.cpp", "unames.cpp", "propname.cpp", "utrie2_builder.cpp", "unifunct.cpp", "bmpset.cpp", "unisetspan.cpp", "unifilt.cpp", "patternprops.cpp", "utf_impl.c", "ustrcase.cpp", "cstring.c", "bytestrie.cpp"]
compile_files_array.append("c")
compile_files_array.append("../../../common/")
compile_files_array.append(["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp"])
libXps_src_path = "../../../../XpsFile/XpsLib/"
input_xps_sources = ["Document.cpp", "XpsPage.cpp", "StaticResources.cpp", "Utils.cpp", "WString.cpp", "ContextState.cpp"]
compile_files_array.append("i")
compile_files_array.append("../../../../Common/3dParty/icu/icu/source/common/")
compile_files_array.append(["ucnv.c", "ustr_wcs.cpp", "ucnv_err.c", "ucnv_bld.cpp", "ustrtrns.cpp", "ucnv_cb.c", "udata.cpp", "ucnv_io.cpp", "uhash.c", "udatamem.c", "cmemory.c", "ustring.cpp", "umutex.cpp", "putil.cpp", "ustr_cnv.cpp", "ucnvmbcs.cpp", "ucnvlat1.c", "ucnv_u16.c", "ucnv_u8.c", "ucnv_u32.c", "ucnv_u7.c", "ucln_cmn.cpp", "ucnv2022.cpp", "ucnv_lmb.c", "ucnvhz.c", "ucnvscsu.c", "ucnvisci.c", "ucnvbocu.cpp", "ucnv_ct.c", "ucnv_cnv.c", "stringpiece.cpp", "charstr.cpp", "umapfile.c", "ucmndata.c", "ucnv_ext.cpp", "uobject.cpp", "umath.c", "ubidi_props.c", "uchar.c", "uinvchar.c", "usprep.cpp", "unistr.cpp", "uniset_props.cpp", "loadednormalizer2impl.cpp", "filterednormalizer2.cpp", "utrie2.cpp", "normalizer2.cpp", "normalizer2impl.cpp", "utrie.cpp", "ucase.cpp", "uniset.cpp", "ruleiter.cpp", "parsepos.cpp", "util.cpp", "uprops.cpp", "uvector.cpp", "unames.cpp", "propname.cpp", "utrie2_builder.cpp", "unifunct.cpp", "bmpset.cpp", "unisetspan.cpp", "unifilt.cpp", "patternprops.cpp", "utf_impl.c", "ustrcase.cpp", "cstring.c", "bytestrie.cpp"])
libDjVu_src_path = "../../../../DjVuFile/libdjvu/"
input_djvu_sources = ["Arrays.cpp", "BSByteStream.cpp", "BSEncodeByteStream.cpp", "ByteStream.cpp", "DataPool.cpp", "debug.cpp", "DjVmDir.cpp", "DjVmDir0.cpp", "DjVmDoc.cpp", "DjVmNav.cpp", "DjVuAnno.cpp", "DjVuDocEditor.cpp", "DjVuDocument.cpp", "DjVuDumpHelper.cpp", "DjVuErrorList.cpp", "DjVuFile.cpp", "DjVuFileCache.cpp", "DjVuGlobal.cpp", "DjVuGlobalMemory.cpp", "DjVuImage.cpp", "DjVuInfo.cpp", "DjVuMessageLite.cpp", "DjVuNavDir.cpp", "DjVuPalette.cpp", "DjVuPort.cpp", "DjVuText.cpp", "DjVuToPS.cpp", "GBitmap.cpp", "GContainer.cpp", "GException.cpp", "GIFFManager.cpp", "GMapAreas.cpp", "GPixmap.cpp", "GRect.cpp", "GScaler.cpp", "GSmartPointer.cpp", "DjVuGString.cpp", "GThreads.cpp", "GUnicode.cpp", "IFFByteStream.cpp", "IW44EncodeCodec.cpp", "IW44Image.cpp", "JB2EncodeCodec.cpp", "JB2Image.cpp", "JPEGDecoder.cpp", "MMRDecoder.cpp", "MMX.cpp", "UnicodeByteStream.cpp", "XMLParser.cpp", "XMLTags.cpp", "ZPCodec.cpp"]
compile_files_array.append("o")
compile_files_array.append("../../../../OfficeUtils/src/")
compile_files_array.append(["OfficeUtils.cpp", "ZipBuffer.cpp", "ZipUtilsCP.cpp"])
libWasmDjVu_src_path = "../../../../DjVuFile/wasm/libdjvu/"
input_wasmdjvu_sources = ["atomic.cpp", "DjVuMessage.cpp", "GOS.cpp", "GURL.cpp"]
compile_files_array.append("m")
compile_files_array.append("../../../../OfficeUtils/src/zlib-1.2.11/contrib/minizip/")
compile_files_array.append(["ioapi.c", "miniunz.c", "minizip.c", "mztools.c", "unzip.c", "zip.c", "ioapibuf.c"])
libOfficeUtils_src_path = "../../../../OfficeUtils/src/"
input_officeutils_sources = ["OfficeUtils.cpp", "ZipBuffer.cpp", "ZipUtilsCP.cpp"]
compile_files_array.append("z")
compile_files_array.append("../../../../OfficeUtils/src/zlib-1.2.11/")
compile_files_array.append(["adler32.c", "crc32.c", "deflate.c", "infback.c", "inffast.c", "inflate.c", "inftrees.c", "trees.c", "zutil.c", "compress.c"])
libMinizip_src_path = "../../../../OfficeUtils/src/zlib-1.2.11/contrib/minizip/"
input_minizip_sources = ["ioapi.c", "miniunz.c", "minizip.c", "mztools.c", "unzip.c", "zip.c", "ioapibuf.c"]
compile_files_array.append("x")
compile_files_array.append("./")
compile_files_array.append(["xml/src/xmllight.cpp", "xml/src/xmldom.cpp", "xml/build/qt/libxml2_all.c", "xml/build/qt/libxml2_all2.c"])
libZlib_src_path = "../../../../OfficeUtils/src/zlib-1.2.11/"
input_zlib_sources = ["adler32.c", "crc32.c", "deflate.c", "infback.c", "inffast.c", "inflate.c", "inftrees.c", "trees.c", "zutil.c", "compress.c"]
compile_files_array.append("p")
compile_files_array.append("../../../../PdfReader/")
compile_files_array.append(["PdfReader.cpp", "Src/Adaptors.cpp", "Src/GfxClip.cpp", "Src/RendererOutputDev.cpp", "lib/fofi/FofiBase.cc", "lib/fofi/FofiEncodings.cc", "lib/fofi/FofiIdentifier.cc", "lib/fofi/FofiTrueType.cc", "lib/fofi/FofiType1.cc", "lib/fofi/FofiType1C.cc", "lib/goo/FixedPoint.cc", "lib/goo/gfile.cc", "lib/goo/GHash.cc", "lib/goo/GList.cc", "lib/goo/gmem.cc", "lib/goo/gmempp.cc", "lib/goo/GString.cc", "lib/goo/parseargs.c", "lib/goo/Trace.cc", "lib/splash/Splash.cc", "lib/splash/SplashBitmap.cc", "lib/splash/SplashClip.cc", "lib/splash/SplashFont.cc", "lib/splash/SplashFontEngine.cc", "lib/splash/SplashFontFile.cc", "lib/splash/SplashFontFileID.cc", "lib/splash/SplashFTFont.cc", "lib/splash/SplashFTFontEngine.cc", "lib/splash/SplashFTFontFile.cc", "lib/splash/SplashPath.cc", "lib/splash/SplashPattern.cc", "lib/splash/SplashScreen.cc", "lib/splash/SplashState.cc", "lib/splash/SplashXPath.cc", "lib/splash/SplashXPathScanner.cc", "lib/xpdf/AcroForm.cc", "lib/xpdf/Annot.cc", "lib/xpdf/Array.cc", "lib/xpdf/BuiltinFont.cc", "lib/xpdf/BuiltinFontTables.cc", "lib/xpdf/Catalog.cc", "lib/xpdf/CharCodeToUnicode.cc", "lib/xpdf/CMap.cc", "lib/xpdf/Decrypt.cc", "lib/xpdf/Dict.cc", "lib/xpdf/DisplayState.cc", "lib/xpdf/Error.cc", "lib/xpdf/FontEncodingTables.cc", "lib/xpdf/Function.cc", "lib/xpdf/Gfx.cc", "lib/xpdf/GfxFont.cc", "lib/xpdf/GfxState.cc", "lib/xpdf/GlobalParams.cc", "lib/xpdf/ImageOutputDev.cc", "lib/xpdf/JArithmeticDecoder.cc", "lib/xpdf/JBIG2Stream.cc", "lib/xpdf/JPXStream.cc", "lib/xpdf/Lexer.cc", "lib/xpdf/Link.cc", "lib/xpdf/NameToCharCode.cc", "lib/xpdf/Object.cc", "lib/xpdf/OptionalContent.cc", "lib/xpdf/Outline.cc", "lib/xpdf/OutputDev.cc", "lib/xpdf/Page.cc", "lib/xpdf/Parser.cc", "lib/xpdf/PDF417Barcode.cc", "lib/xpdf/PDFCore.cc", "lib/xpdf/PDFDoc.cc", "lib/xpdf/PDFDocEncoding.cc", "lib/xpdf/PreScanOutputDev.cc", "lib/xpdf/PSOutputDev.cc", "lib/xpdf/PSTokenizer.cc", "lib/xpdf/SecurityHandler.cc", "lib/xpdf/ShadingImage.cc", "lib/xpdf/SplashOutputDev.cc", "lib/xpdf/Stream.cc", "lib/xpdf/TextOutputDev.cc", "lib/xpdf/TextString.cc", "lib/xpdf/TileCache.cc", "lib/xpdf/TileCompositor.cc", "lib/xpdf/TileMap.cc", "lib/xpdf/UnicodeMap.cc", "lib/xpdf/UnicodeRemapping.cc", "lib/xpdf/UnicodeTypeTable.cc", "lib/xpdf/UTF8.cc", "lib/xpdf/WebFont.cc", "lib/xpdf/XFAScanner.cc", "lib/xpdf/XRef.cc", "lib/xpdf/Zoox.cc"])
input_xml_sources = ["xml/src/xmllight.cpp", "xml/src/xmldom.cpp", "xml/build/qt/libxml2_all.c", "xml/build/qt/libxml2_all2.c"]
compile_files_array.append("x")
compile_files_array.append("../../../../XpsFile/")
compile_files_array.append(["XpsFile.cpp", "XpsLib/Document.cpp", "XpsLib/XpsPage.cpp", "XpsLib/StaticResources.cpp", "XpsLib/Utils.cpp", "XpsLib/WString.cpp", "XpsLib/ContextState.cpp"])
libPdfReader_src_path = "../../../../PdfReader/"
input_pdfreader_sources = ["Src/Adaptors.cpp", "Src/GfxClip.cpp", "Src/RendererOutputDev.cpp", "lib/fofi/FofiBase.cc", "lib/fofi/FofiEncodings.cc", "lib/fofi/FofiIdentifier.cc", "lib/fofi/FofiTrueType.cc", "lib/fofi/FofiType1.cc", "lib/fofi/FofiType1C.cc", "lib/goo/FixedPoint.cc", "lib/goo/gfile.cc", "lib/goo/GHash.cc", "lib/goo/GList.cc", "lib/goo/gmem.cc", "lib/goo/gmempp.cc", "lib/goo/GString.cc", "lib/goo/parseargs.c", "lib/goo/Trace.cc", "lib/splash/Splash.cc", "lib/splash/SplashBitmap.cc", "lib/splash/SplashClip.cc", "lib/splash/SplashFont.cc", "lib/splash/SplashFontEngine.cc", "lib/splash/SplashFontFile.cc", "lib/splash/SplashFontFileID.cc", "lib/splash/SplashFTFont.cc", "lib/splash/SplashFTFontEngine.cc", "lib/splash/SplashFTFontFile.cc", "lib/splash/SplashPath.cc", "lib/splash/SplashPattern.cc", "lib/splash/SplashScreen.cc", "lib/splash/SplashState.cc", "lib/splash/SplashXPath.cc", "lib/splash/SplashXPathScanner.cc", "lib/xpdf/AcroForm.cc", "lib/xpdf/Annot.cc", "lib/xpdf/Array.cc", "lib/xpdf/BuiltinFont.cc", "lib/xpdf/BuiltinFontTables.cc", "lib/xpdf/Catalog.cc", "lib/xpdf/CharCodeToUnicode.cc", "lib/xpdf/CMap.cc", "lib/xpdf/Decrypt.cc", "lib/xpdf/Dict.cc", "lib/xpdf/DisplayState.cc", "lib/xpdf/Error.cc", "lib/xpdf/FontEncodingTables.cc", "lib/xpdf/Function.cc", "lib/xpdf/Gfx.cc", "lib/xpdf/GfxFont.cc", "lib/xpdf/GfxState.cc", "lib/xpdf/GlobalParams.cc", "lib/xpdf/ImageOutputDev.cc", "lib/xpdf/JArithmeticDecoder.cc", "lib/xpdf/JBIG2Stream.cc", "lib/xpdf/JPXStream.cc", "lib/xpdf/Lexer.cc", "lib/xpdf/Link.cc", "lib/xpdf/NameToCharCode.cc", "lib/xpdf/Object.cc", "lib/xpdf/OptionalContent.cc", "lib/xpdf/Outline.cc", "lib/xpdf/OutputDev.cc", "lib/xpdf/Page.cc", "lib/xpdf/Parser.cc", "lib/xpdf/PDF417Barcode.cc", "lib/xpdf/PDFCore.cc", "lib/xpdf/PDFDoc.cc", "lib/xpdf/PDFDocEncoding.cc", "lib/xpdf/PreScanOutputDev.cc", "lib/xpdf/PSOutputDev.cc", "lib/xpdf/PSTokenizer.cc", "lib/xpdf/SecurityHandler.cc", "lib/xpdf/ShadingImage.cc", "lib/xpdf/SplashOutputDev.cc", "lib/xpdf/Stream.cc", "lib/xpdf/TextOutputDev.cc", "lib/xpdf/TextString.cc", "lib/xpdf/TileCache.cc", "lib/xpdf/TileCompositor.cc", "lib/xpdf/TileMap.cc", "lib/xpdf/UnicodeMap.cc", "lib/xpdf/UnicodeRemapping.cc", "lib/xpdf/UnicodeTypeTable.cc", "lib/xpdf/UTF8.cc", "lib/xpdf/WebFont.cc", "lib/xpdf/XFAScanner.cc", "lib/xpdf/XRef.cc", "lib/xpdf/Zoox.cc"]
compile_files_array.append("d")
compile_files_array.append("../../../../DjVuFile/libdjvu/")
compile_files_array.append(["../DjVu.cpp", "../DjVuFileImplementation.cpp", "Arrays.cpp", "BSByteStream.cpp", "BSEncodeByteStream.cpp", "ByteStream.cpp", "DataPool.cpp", "debug.cpp", "DjVmDir.cpp", "DjVmDir0.cpp", "DjVmDoc.cpp", "DjVmNav.cpp", "DjVuAnno.cpp", "DjVuDocEditor.cpp", "DjVuDocument.cpp", "DjVuDumpHelper.cpp", "DjVuErrorList.cpp", "DjVuFile.cpp", "DjVuFileCache.cpp", "DjVuGlobal.cpp", "DjVuGlobalMemory.cpp", "DjVuImage.cpp", "DjVuInfo.cpp", "DjVuMessageLite.cpp", "DjVuNavDir.cpp", "DjVuPalette.cpp", "DjVuPort.cpp", "DjVuText.cpp", "DjVuToPS.cpp", "GBitmap.cpp", "GContainer.cpp", "GException.cpp", "GIFFManager.cpp", "GMapAreas.cpp", "GPixmap.cpp", "GRect.cpp", "GScaler.cpp", "GSmartPointer.cpp", "DjVuGString.cpp", "GThreads.cpp", "GUnicode.cpp", "IFFByteStream.cpp", "IW44EncodeCodec.cpp", "IW44Image.cpp", "JB2EncodeCodec.cpp", "JB2Image.cpp", "JPEGDecoder.cpp", "MMRDecoder.cpp", "MMX.cpp", "UnicodeByteStream.cpp", "XMLParser.cpp", "XMLTags.cpp", "ZPCodec.cpp"])
input_libs_sources = ["../../../../UnicodeConverter/UnicodeConverter.cpp", "../../../../XpsFile/XpsFile.cpp", "../../../../DjVuFile/DjVu.cpp", "../../../../DjVuFile/DjVuFileImplementation.cpp", "../../../../PdfReader/PdfReader.cpp"]
compile_files_array.append("d")
compile_files_array.append("../../../../DjVuFile/wasm/libdjvu/")
compile_files_array.append(["atomic.cpp", "DjVuMessage.cpp", "GOS.cpp", "GURL.cpp"])
# sources
sources = []
# graphics
# fontengine
# agg
# freetype
# common
# icu
# xps
# djvu
# wasm djvu
# officeutils
# minizip
# zlib
# xml
# pdfReader
# libs
sources.append("raster.o")
sources.append("wasm/src/drawingfile.cpp")
compile_files_array.append("u")
compile_files_array.append("../../../../UnicodeConverter/")
compile_files_array.append(["UnicodeConverter.cpp"])
compiler_flags.append("-I../../../agg-2.4/include -I../../../cximage/jasper/include -I../../../cximage/jpeg -I../../../cximage/png -I../../../freetype-2.10.4/include -I../../../freetype-2.10.4/include/freetype -I../../../../OfficeUtils/src/zlib-1.2.11 -I../../../../Common/3dParty/icu/icu/source/common -I../../../xml/libxml2/include -I../../../xml/build/qt -I../../../../OfficeUtils/src/zlib-1.2.11/contrib/minizip -I../../../../PdfReader/lib/goo -I../../../../PdfReader/lib/fofi -I../../../../PdfReader/lib/splash -I../../../../PdfReader/lib")
compiler_flags.append("-D__linux__ -D_LINUX -DUNIX -DFT2_BUILD_LIBRARY -DHAVE_FCNTL_H -DFT_CONFIG_OPTION_SYSTEM_ZLIB -DBUILDING_WASM_MODULE -DU_COMMON_IMPLEMENTATION")
@ -125,169 +126,60 @@ compiler_flags.append("-DHAVE_VA_COPY -DLIBXML_READER_ENABLED -DLIBXML_PUSH_ENAB
# arguments
arguments = ""
for item in compiler_flags:
arguments += (item + " ")
arguments += (item + " ")
# command
windows_bat = []
# sources
sources = []
sources.append("raster.o")
sources.append("wasm/src/drawingfile.cpp")
compile_files_array_len = len(compile_files_array)
external_file = []
prefix_call = ""
if base.host_platform() == "windows":
windows_bat.append("call emsdk/emsdk_env.bat")
libs = ""
for item in input_graphics_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(os.path.basename(item))[0] + ".o -c " + arguments + libGraphics_src_path + item)
libs += ("temp/" + os.path.splitext(os.path.basename(item))[0] + ".o ")
for item in input_fontengine_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(item)[0] + ".o -c " + arguments + libFontEngine_src_path + item)
libs += ("temp/" + os.path.splitext(item)[0] + ".o ")
for item in input_agg_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(item)[0] + ".o -c " + arguments + libAgg_src_path + item)
libs += ("temp/" + os.path.splitext(item)[0] + ".o ")
for item in input_freetype_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(os.path.basename(item))[0] + ".o -c " + arguments + libFreetype_src_path + item)
libs += ("temp/" + os.path.splitext(os.path.basename(item))[0] + ".o ")
for item in input_common_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(item)[0] + ".o -c " + arguments + libCommon_src_path + item)
libs += ("temp/" + os.path.splitext(item)[0] + ".o ")
for item in input_icu_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(item)[0] + ".o -c " + arguments + libIcu_src_path + item)
libs += ("temp/" + os.path.splitext(item)[0] + ".o ")
for item in input_xps_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(item)[0] + ".o -c " + arguments + libXps_src_path + item)
libs += ("temp/" + os.path.splitext(item)[0] + ".o ")
for item in input_djvu_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(item)[0] + ".o -c " + arguments + libDjVu_src_path + item)
libs += ("temp/" + os.path.splitext(item)[0] + ".o ")
for item in input_wasmdjvu_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(item)[0] + ".o -c " + arguments + libWasmDjVu_src_path + item)
libs += ("temp/" + os.path.splitext(item)[0] + ".o ")
for item in input_officeutils_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(item)[0] + ".o -c " + arguments + libOfficeUtils_src_path + item)
libs += ("temp/" + os.path.splitext(item)[0] + ".o ")
for item in input_minizip_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(item)[0] + ".o -c " + arguments + libMinizip_src_path + item)
libs += ("temp/" + os.path.splitext(item)[0] + ".o ")
for item in input_zlib_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(item)[0] + ".o -c " + arguments + libZlib_src_path + item)
libs += ("temp/" + os.path.splitext(item)[0] + ".o ")
for item in input_xml_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(os.path.basename(item))[0] + ".o -c " + arguments + item)
libs += ("temp/" + os.path.splitext(os.path.basename(item))[0] + ".o ")
for item in input_pdfreader_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(os.path.basename(item))[0] + ".o -c " + arguments + libPdfReader_src_path + item)
libs += ("temp/" + os.path.splitext(os.path.basename(item))[0] + ".o ")
for item in input_libs_sources:
windows_bat.append("call emcc -o temp/" + os.path.splitext(os.path.basename(item))[0] + ".o -c " + arguments + item)
libs += ("temp/" + os.path.splitext(os.path.basename(item))[0] + ".o ")
arguments += "-s EXPORTED_FUNCTIONS=\"["
for item in exported_functions:
arguments += ("'" + item + "',")
arguments = arguments[:-1]
arguments += "]\" "
for item in sources:
arguments += (item + " ")
windows_bat.append("call emcc -o drawingfile.js " + arguments + libs)
prefix_call = "call "
external_file.append("call emsdk/emsdk_env.bat")
else:
windows_bat.append("#!/bin/bash")
windows_bat.append("source ./emsdk/emsdk_env.sh")
external_file.append("#!/bin/bash")
external_file.append("source ./emsdk/emsdk_env.sh")
libs = ""
for item in input_graphics_sources:
windows_bat.append("emcc -o temp/" + os.path.basename(item) + ".o -c " + arguments + libGraphics_src_path + item)
libs += ("temp/" + os.path.basename(item) + ".o ")
for item in input_fontengine_sources:
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libFontEngine_src_path + item)
libs += ("temp/" + item + ".o ")
for item in input_agg_sources:
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libAgg_src_path + item)
libs += ("temp/" + item + ".o ")
for item in input_freetype_sources:
windows_bat.append("emcc -o temp/" + os.path.basename(item) + ".o -c " + arguments + libFreetype_src_path + item)
libs += ("temp/" + os.path.basename(item) + ".o ")
for item in input_common_sources:
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libCommon_src_path + item)
libs += ("temp/" + item + ".o ")
for item in input_icu_sources:
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libIcu_src_path + item)
libs += ("temp/" + item + ".o ")
for item in input_xps_sources:
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libXps_src_path + item)
libs += ("temp/" + item + ".o ")
for item in input_djvu_sources:
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libDjVu_src_path + item)
libs += ("temp/" + item + ".o ")
for item in input_wasmdjvu_sources:
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libWasmDjVu_src_path + item)
libs += ("temp/" + item + ".o ")
for item in input_officeutils_sources:
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libOfficeUtils_src_path + item)
libs += ("temp/" + item + ".o ")
for item in input_minizip_sources:
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libMinizip_src_path + item)
libs += ("temp/" + item + ".o ")
for item in input_zlib_sources:
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libZlib_src_path + item)
libs += ("temp/" + item + ".o ")
for item in input_xml_sources:
windows_bat.append("emcc -o temp/" + os.path.basename(item) + ".o -c " + arguments + item)
libs += ("temp/" + os.path.basename(item) + ".o ")
for item in input_pdfreader_sources:
windows_bat.append("emcc -o temp/" + os.path.basename(item) + ".o -c " + arguments + libPdfReader_src_path + item)
libs += ("temp/" + os.path.basename(item) + ".o ")
for item in input_libs_sources:
windows_bat.append("call emcc -o temp/" + os.path.basename(item) + ".o -c " + arguments + item)
libs += ("temp/" + os.path.basename(item) + ".o ")
arguments += "-s EXPORTED_FUNCTIONS=\"["
for item in exported_functions:
arguments += ("'" + item + "',")
arguments = arguments[:-1]
arguments += "]\" "
file_index = 0
libs = ""
while file_index < compile_files_array_len:
objects_dir = compile_files_array[file_index]
base_dir = compile_files_array[file_index + 1]
files = compile_files_array[file_index + 2]
file_index += 3
base.create_dir("./o/" + objects_dir)
for item in files:
file_name = os.path.splitext(os.path.basename(item))[0]
external_file.append(prefix_call + "emcc -o o/" + objects_dir + "/" + file_name + ".o -c " + arguments + base_dir + item)
libs += ("o/" + objects_dir + "/" + file_name + ".o ")
arguments += "-s EXPORTED_FUNCTIONS=\"["
for item in exported_functions:
arguments += ("'" + item + "',")
arguments = arguments[:-1]
arguments += "]\" "
for item in sources:
arguments += (item + " ")
external_file.append("call emcc -o drawingfile.js " + arguments + libs)
for item in sources:
arguments += (item + " ")
windows_bat.append("emcc -o drawingfile.js " + arguments + libs)
base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", "\n{\n UDataMemory tData;", "\n{\n#ifdef BUILDING_WASM_MODULE\nreturn NULL;\n#endif\n UDataMemory tData;")
base.run_as_bat(windows_bat)
base.run_as_bat(external_file)
base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", "\n{\n#ifdef BUILDING_WASM_MODULE\nreturn NULL;\n#endif\n UDataMemory tData;", "\n{\n UDataMemory tData;")
# finalize
base.replaceInFile("./drawingfile.js", "function getBinaryPromise(){", "function getBinaryPromise2(){")
graphics_js_content = base.readFile("./drawingfile.js")
base.replaceInFile("./drawingfile.js", "__ATPOSTRUN__=[];", "__ATPOSTRUN__=[function(){window[\"AscViewer\"] && window[\"AscViewer\"][\"onLoadModule\"] && window[\"AscViewer\"][\"onLoadModule\"]();}];")
module_js_content = base.readFile("./drawingfile.js")
engine_base_js_content = base.readFile("./wasm/js/drawingfile_base.js")
string_utf8_content = base.readFile("./../../../../Common/js/string_utf8.js")
engine_js_content = engine_base_js_content.replace("//module", graphics_js_content)
engine_js_content = engine_base_js_content.replace("//module", module_js_content)
engine_js_content = engine_js_content.replace("//string_utf8", string_utf8_content)
# write new version
@ -296,6 +188,6 @@ base.copy_file("./drawingfile.wasm", "./deploy/drawingfile.wasm")
base.delete_file("drawingfile.js")
base.delete_file("drawingfile.wasm")
base.delete_dir("./temp")
base.delete_dir("./o")
base.delete_dir("./xml")
# base.delete_file("raster.o")
# base.delete_file("./raster.o")

View File

@ -1,160 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* 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-12 Ernesta Birznieka-Upisha
* 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
*
*/
(function(window, undefined) {
var printErr = undefined;
var FS = undefined;
var print = undefined;
var getBinaryPromise = null;
if (window["AscDesktopEditor"] && document.currentScript && 0 == document.currentScript.src.indexOf("file:///"))
{
// fetch not support file:/// scheme
window.fetch = undefined;
getBinaryPromise = function() {
var wasmPath = "ascdesktop://fonts/" + wasmBinaryFile.substr(8);
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', wasmPath, true);
xhr.responseType = 'arraybuffer';
if (xhr.overrideMimeType)
xhr.overrideMimeType('text/plain; charset=x-user-defined');
else
xhr.setRequestHeader('Accept-Charset', 'x-user-defined');
xhr.onload = function () {
if (this.status == 200) {
resolve(new Uint8Array(this.response));
}
};
xhr.send(null);
});
}
}
else
{
getBinaryPromise = function() {
return getBinaryPromise2();
}
}
//string_utf8
//module
/**
*
* @param config
* @constructor
* @extends {AscViewer.IFile}
*/
function CFile()
{
AscViewer.IFile.call(this);
}
CFile.prototype = Object.create(AscViewer.IFile.prototype);
CFile.prototype.constructor = CFile;
CFile.prototype.loadFromData = function(arrayBuffer)
{
var data = new Uint8Array(arrayBuffer);
var _stream = Module["_malloc"](data.length);
Module["HEAP8"].set(data, _stream);
this.nativeFile = Module["_Open"](_stream, data.length);
this.stream = _stream;
return this.getInfo();
};
CFile.prototype.getInfo = function()
{
if (!this.nativeFile)
return false;
var _info = Module["_GetInfo"](this.nativeFile);
if (!_info)
return false;
var _pages = Module["HEAP32"][_info >> 2];
var _buffer = new Int32Array(Module["HEAP8"].buffer, _info, 1 + 3 * _pages);
var _cur = 1;
for (var i = 0; i < _pages; i++)
{
this.pages.push({ W : _buffer[_cur++], H : _buffer[_cur++], Dpi : _buffer[_cur++] });
}
this.free(_info);
return this.pages.length > 0;
};
CFile.prototype.getPagePixmap = function(pageIndex, width, height)
{
return Module["_GetPixmap"](this.nativeFile, pageIndex, width, height);
};
CFile.prototype.getGlyphs = function(pageIndex, width, height)
{
};
CFile.prototype.getLinks = function(pageIndex, width, height)
{
return [];
};
CFile.prototype.structure = function()
{
return [];
};
CFile.prototype.close = function()
{
Module["_Close"](this.nativeFile);
this.nativeFile = 0;
this.pages = [];
if (this.stream > 0)
Module["_free"](this.stream);
this.stream = -1;
};
CFile.prototype.memory = function()
{
return Module["HEAP8"];
};
CFile.prototype.free = function(pointer)
{
Module["_free"](pointer);
};
window["AscViewer"].PdfFile = CFile;
})(window, undefined);

View File

@ -1,312 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* 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-12 Ernesta Birznieka-Upisha
* 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
*
*/
(function(window, undefined) {
var printErr = undefined;
var FS = undefined;
var print = undefined;
var getBinaryPromise = null;
if (window["AscDesktopEditor"] && document.currentScript && 0 == document.currentScript.src.indexOf("file:///"))
{
// fetch not support file:/// scheme
window.fetch = undefined;
getBinaryPromise = function() {
var wasmPath = "ascdesktop://fonts/" + wasmBinaryFile.substr(8);
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', wasmPath, true);
xhr.responseType = 'arraybuffer';
if (xhr.overrideMimeType)
xhr.overrideMimeType('text/plain; charset=x-user-defined');
else
xhr.setRequestHeader('Accept-Charset', 'x-user-defined');
xhr.onload = function () {
if (this.status == 200) {
resolve(new Uint8Array(this.response));
}
};
xhr.send(null);
});
}
}
else
{
getBinaryPromise = function() {
return getBinaryPromise2();
}
}
//string_utf8
//module
/**
*
* @param config
* @constructor
* @extends {AscViewer.IFile}
*/
function CFile()
{
AscViewer.IFile.call(this);
}
CFile.prototype = Object.create(AscViewer.IFile.prototype);
CFile.prototype.constructor = CFile;
CFile.prototype.loadFromData = function(arrayBuffer)
{
var data = new Uint8Array(arrayBuffer);
var _stream = Module["_malloc"](data.length);
Module["HEAP8"].set(data, _stream);
this.nativeFile = Module["_Open"](_stream, data.length);
Module["_free"](_stream);
return this.getInfo();
};
CFile.prototype.getInfo = function()
{
if (!this.nativeFile)
return false;
var _info = Module["_GetInfo"](this.nativeFile);
if (!_info)
return false;
var _pages = Module["HEAP32"][_info >> 2];
var _buffer = new Int32Array(Module["HEAP8"].buffer, _info, 1 + 3 * _pages);
var _cur = 1;
for (var i = 0; i < _pages; i++)
{
this.pages.push({ W : _buffer[_cur++], H : _buffer[_cur++], Dpi : _buffer[_cur++] });
}
this.free(_info);
return this.pages.length > 0;
};
CFile.prototype.getPagePixmap = function(pageIndex, width, height)
{
return Module["_GetPixmap"](this.nativeFile, pageIndex, width, height);
};
CFile.prototype.getGlyphs = function(pageIndex, width, height)
{
var glyphs = Module["_GetGlyphs"](this.nativeFile, pageIndex, width, height);
if (glyphs == null)
return;
var lenArray = new Int32Array(Module["HEAP8"].buffer, glyphs, 4);
var len = lenArray[0];
len -= 4;
if (len <= 0)
return;
this.pages[pageIndex].Lines = [];
var buffer = new Uint8Array(Module["HEAP8"].buffer, glyphs + 4, len);
var index = 0;
var Line = -1;
var prevY = -1;
while (index < len)
{
var lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _fontName = "".fromUtf8(buffer, index, lenRec);
index += lenRec;
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _fontSize = parseFloat("".fromUtf8(buffer, index, lenRec));
index += lenRec;
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
let amount = lenRec;
for (var i = 0; i < amount; i++)
{
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _X = parseFloat("".fromUtf8(buffer, index, lenRec));
index += lenRec;
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _Y = parseFloat("".fromUtf8(buffer, index, lenRec));
if (_Y != prevY)
{
if (Line >= 0)
this.pages[pageIndex].Lines[Line].Glyphs.sort((prev, next) => prev.X - next.X);
Line++;
this.pages[pageIndex].Lines.push({ Glyphs : [] });
prevY = _Y;
}
index += lenRec;
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
this.pages[pageIndex].Lines[Line].Glyphs.push({
fontName : _fontName,
fontSize : _fontSize,
X : _X * 1.015,
Y : _Y * 1.015,
UChar : String.fromCharCode(lenRec)
});
}
}
this.pages[pageIndex].Lines.sort((prev, next) => prev.Glyphs[0].Y - next.Glyphs[0].Y);
prevY = -1;
var prevFontName = "";
var prevFontSize = "";
for (let i = 0; i < this.pages[pageIndex].Lines.length; i++)
{
for (let j = 0; j < this.pages[pageIndex].Lines[i].Glyphs.length; j++)
{
let glyph = this.pages[pageIndex].Lines[i].Glyphs[j];
if (glyph.fontName == prevFontName)
delete glyph.fontName;
else
prevFontName = glyph.fontName;
if (glyph.fontSize == prevFontSize && j != 0)
delete glyph.fontSize;
else
prevFontSize = glyph.fontSize;
if (glyph.Y == prevY && j != 0)
delete glyph.Y;
else
prevY = glyph.Y;
}
}
Module["_free"](glyphs);
};
CFile.prototype.getLinks = function(pageIndex, width, height)
{
var res = [];
var ext = Module["_GetLinks"](this.nativeFile, pageIndex, width, height);
var lenArray = new Int32Array(Module["HEAP8"].buffer, ext, 4);
if (lenArray == null)
return res;
var len = lenArray[0];
len -= 4;
if (len <= 0)
return res;
var index = 0;
var buffer = new Uint8Array(Module["HEAP8"].buffer, ext + 4, len);
while (index < len)
{
var lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _Link = "".fromUtf8(buffer, index, lenRec);
index += lenRec;
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _X = parseFloat("".fromUtf8(buffer, index, lenRec));
index += lenRec;
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _Y = parseFloat("".fromUtf8(buffer, index, lenRec));
index += lenRec;
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _W = parseFloat("".fromUtf8(buffer, index, lenRec));
index += lenRec;
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _H = parseFloat("".fromUtf8(buffer, index, lenRec));
index += lenRec;
res.push({ X : _X * 1.015, Y : _Y * 1.015, W : _W, H : _H, Link : _Link});
}
Module["_free"](ext);
return res;
};
CFile.prototype.structure = function()
{
var res = [];
var str = Module["_GetStructure"](this.nativeFile);
var lenArray = new Int32Array(Module["HEAP8"].buffer, str, 4);
if (lenArray == null)
return res;
var len = lenArray[0];
len -= 4;
if (len <= 0)
return res;
var buffer = new Uint8Array(Module["HEAP8"].buffer, str + 4, len);
var index = 0;
var Line = -1;
var prevY = -1;
while (index < len)
{
var lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _Page = lenRec;
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _Level = lenRec;
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _Y = parseFloat("".fromUtf8(buffer, index, lenRec));
index += lenRec;
lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
index += 4;
var _Description = "".fromUtf8(buffer, index, lenRec);
index += lenRec;
res.push({ page : _Page, level : _Level, Y : _Y, description : _Description});
}
Module["_free"](str);
return res;
};
CFile.prototype.close = function()
{
Module["_Close"](this.nativeFile);
this.nativeFile = 0;
this.pages = [];
};
CFile.prototype.memory = function()
{
return Module["HEAP8"];
};
CFile.prototype.free = function(pointer)
{
Module["_free"](pointer);
};
window["AscViewer"].XpsFile = CFile;
})(window, undefined);

File diff suppressed because one or more lines are too long