mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
505 Commits
fix/OOXml2
...
v9.0.0.78
| Author | SHA1 | Date | |
|---|---|---|---|
| ca53d3d035 | |||
| a4f271d7b0 | |||
| c99b304ec2 | |||
| db57d253d9 | |||
| b48909edaa | |||
| 1bfb055a50 | |||
| 149d3a2030 | |||
| 8bad09ea5a | |||
| 91656095fa | |||
| 9e89e48c07 | |||
| 1c5bd6cbab | |||
| 8ba7535fc8 | |||
| 038fa50194 | |||
| c94a294317 | |||
| d220685cff | |||
| edae000326 | |||
| 2cbc83b389 | |||
| d05afa3106 | |||
| de56349019 | |||
| 821f9cacd0 | |||
| 4f38f17bd1 | |||
| 9f4a145b48 | |||
| eaa0bbf047 | |||
| e78391c68b | |||
| 109a5fe2b4 | |||
| 36b7400e0e | |||
| 8318535aae | |||
| 21f5e09237 | |||
| de9c51a2db | |||
| f42079a55f | |||
| 5e0b5b6e34 | |||
| 9b87eba66b | |||
| 09f2db26e0 | |||
| aa038179cc | |||
| c09d5197b7 | |||
| c6f616d42e | |||
| dcc208257e | |||
| cc369ffbcb | |||
| 93018caf09 | |||
| d80d6c4168 | |||
| 5360487954 | |||
| cd73ab58b1 | |||
| 1119fd4307 | |||
| 0769a5ed3b | |||
| 82ad23840f | |||
| 5cb971d600 | |||
| c66cb32dde | |||
| ab62a3ebcf | |||
| 04d3e94dcc | |||
| 1c4462e2e9 | |||
| 91dc5b8582 | |||
| e9cf55f8db | |||
| 43fc84e6ef | |||
| 5a8bd3f8ce | |||
| 84dda72a13 | |||
| 5819c36cee | |||
| b5b9d948b9 | |||
| 72ac94412d | |||
| 4125e698d6 | |||
| 7c2a95202c | |||
| c3527ad8d4 | |||
| 9fe692b048 | |||
| df66cbbca9 | |||
| d877278d8d | |||
| 41a4edb223 | |||
| 0979902167 | |||
| 20618403b6 | |||
| 131efd2eaa | |||
| 8871c785dd | |||
| 8bbdb30419 | |||
| 15370bcbce | |||
| 48c9a001dd | |||
| 4c806b07a2 | |||
| 6a75bc62f0 | |||
| 6cb7e763d3 | |||
| 0d55fddd02 | |||
| 1dfb9bff3a | |||
| 4dd15a8e80 | |||
| bd60a20b91 | |||
| bd7914e7c7 | |||
| c7fa85602d | |||
| 809effa5df | |||
| 2f42eb6c42 | |||
| 641a505cf8 | |||
| f5f3d2572e | |||
| 68992278ce | |||
| 95476fc998 | |||
| fa5fa35a34 | |||
| c503044fc9 | |||
| 4bef318bd6 | |||
| 6546ae3fd9 | |||
| ac300f57a6 | |||
| c7a4edec03 | |||
| aaeb745ad3 | |||
| 0a85051119 | |||
| 85c60f172c | |||
| 7a9c57038e | |||
| 888f67dab2 | |||
| 87a9b92fea | |||
| 185be63b27 | |||
| 7cd7b03b89 | |||
| 3fe4c2ac21 | |||
| 776569ca81 | |||
| 7b264e940d | |||
| 160e99ab90 | |||
| 6988009971 | |||
| 66bed0e286 | |||
| 36aae7a6ab | |||
| 3f42678932 | |||
| 4bd0a53c9e | |||
| e9162eb230 | |||
| 44684c462e | |||
| 81be9c1c1f | |||
| c84f2a11d5 | |||
| 21451d83e4 | |||
| 21ec043636 | |||
| 83e6e5971c | |||
| aeb78a561e | |||
| 75c0dde6d2 | |||
| 2cb34822cd | |||
| e5c7a043be | |||
| b8cdfa9b36 | |||
| 7893197071 | |||
| f2bda6c81a | |||
| 3d2cb819d5 | |||
| ddb544ce34 | |||
| f441ec5c35 | |||
| d7a8c30461 | |||
| e8bb81b88e | |||
| fee4394d3f | |||
| 744d90e655 | |||
| 5692732901 | |||
| 1aaec18152 | |||
| 266425e817 | |||
| 5b8549db9d | |||
| 8f0a4ebfc9 | |||
| be5627ba60 | |||
| 34f36cefc3 | |||
| 7ceefa54cb | |||
| e4188148ba | |||
| a92bf23081 | |||
| 1d9230b731 | |||
| d2b5299b99 | |||
| 29c8e185ca | |||
| 723e4713fd | |||
| 7e235780fc | |||
| cfbed19648 | |||
| 0e09d4ab7a | |||
| eb37cabb4e | |||
| 4b611b304b | |||
| c5e6fb69c8 | |||
| af5feabdac | |||
| 716cbd42b2 | |||
| eebe3f321a | |||
| 925c40aa80 | |||
| b6741a504f | |||
| 3522897670 | |||
| 6973cb4c54 | |||
| fedf33e2c2 | |||
| a0c49966b9 | |||
| 58f4828563 | |||
| 9e52adeb53 | |||
| aed320e57a | |||
| 96a7e3ac36 | |||
| caa34c540a | |||
| b67ed51103 | |||
| cf91b46ea7 | |||
| 44d76014bf | |||
| dad19380a2 | |||
| 23410ccbf9 | |||
| ce129fe49d | |||
| ed0f4f9e5e | |||
| d8f9aab1ed | |||
| 37fc9784a7 | |||
| 7252d29579 | |||
| d257c68d5f | |||
| 051169b0f5 | |||
| 6a4ba5ec8d | |||
| 9390761867 | |||
| e100f594d7 | |||
| d620a53cd0 | |||
| 1181cb222d | |||
| df0528c69f | |||
| 49da36637d | |||
| 850fd21f09 | |||
| fdc374256a | |||
| ed12f6766d | |||
| 4e7ccd2506 | |||
| c4bcf11d91 | |||
| 72ee82211d | |||
| 2ab94263f2 | |||
| b7a335ef83 | |||
| 410e8100fe | |||
| 3e3ac51f56 | |||
| 2d0bb82f41 | |||
| 005b790e14 | |||
| 4f4f61bb19 | |||
| 6fe0f2828e | |||
| 58074d649d | |||
| 1346f56d67 | |||
| 2652fb4e65 | |||
| 2a5d7a78a3 | |||
| 16c77add4d | |||
| 684e83f0f3 | |||
| a8d8f44cef | |||
| 4ca218486f | |||
| 10bf096b4d | |||
| 3b67e4ee0c | |||
| 670dae5f36 | |||
| 95a5a2ccbc | |||
| 16023ed916 | |||
| 6e6a71e46d | |||
| c9e3c3452f | |||
| 561221102e | |||
| 4dd6d5ffc7 | |||
| 89d965283b | |||
| 6e9500a6e7 | |||
| 71f164b029 | |||
| a438ae3d2e | |||
| 7edb3bd141 | |||
| 37a5ce4781 | |||
| 18b8e3ed7c | |||
| 20a4bcf708 | |||
| c0222c03db | |||
| 52de014e14 | |||
| 80ed0318b6 | |||
| adea12d9f7 | |||
| 3a8601c354 | |||
| 86c994d0a0 | |||
| ba1597a8d5 | |||
| 84ecffa75e | |||
| d83cbfc031 | |||
| 3723ba064c | |||
| 7a3815bc5f | |||
| 08ae28224f | |||
| 4d23382c92 | |||
| ac2562f83e | |||
| e1274dadea | |||
| 4342c245c5 | |||
| 52602f902e | |||
| 56179f70bf | |||
| 9cde3dc699 | |||
| 85b6e2d568 | |||
| 43becd1cdb | |||
| 8791f446b7 | |||
| 6aa68f1c81 | |||
| bd838daa90 | |||
| 484d9342ac | |||
| e9852e812f | |||
| d2ea9521b5 | |||
| e1c1ff3eb4 | |||
| d76dddeda6 | |||
| 1830a1103a | |||
| 631f498532 | |||
| 4957b61033 | |||
| 06f8099497 | |||
| ba9d3bcda5 | |||
| 462556599f | |||
| a7551f69eb | |||
| a3878b3770 | |||
| 7a1c1be599 | |||
| 0796745158 | |||
| b177d01071 | |||
| 06cc67a925 | |||
| 55cae3d38c | |||
| fc540fdf5f | |||
| 06a287dffe | |||
| 6e6ffbf604 | |||
| 3d58a8565a | |||
| 9ed356c103 | |||
| b20cdcd107 | |||
| 4d4a67b15a | |||
| 3d7638c3cc | |||
| cca89624c6 | |||
| ccad697cd8 | |||
| dd60367d01 | |||
| 54bbbbc3d7 | |||
| 9b901f7834 | |||
| 258890352a | |||
| 09567e225e | |||
| 62dbbc6d0d | |||
| 4f59af17b8 | |||
| b9258429f6 | |||
| e8f2c55ad4 | |||
| 4085f58b09 | |||
| 46f6ba4d0a | |||
| f5d2ff992a | |||
| 09b55bd1f1 | |||
| 176053e8d8 | |||
| f28dc0a36a | |||
| 01365f938c | |||
| d168e4594f | |||
| 79145ad0c7 | |||
| cad36a73be | |||
| 0c9fa4709f | |||
| 27d2e40da7 | |||
| 14b09ce582 | |||
| aeeab690b1 | |||
| 54c0943754 | |||
| 016a0a971b | |||
| 49a40fa841 | |||
| f9662752f7 | |||
| 7eb0892ab9 | |||
| bb65d1a90b | |||
| 0136530b93 | |||
| afe55a456f | |||
| a430ba92ad | |||
| efc1149235 | |||
| edcd907749 | |||
| 567cc14bc7 | |||
| 0fc7f2a8b3 | |||
| b14fa1c2a1 | |||
| 2c27cfc720 | |||
| e1b13913ac | |||
| 1d31e5836b | |||
| 9f3ab7cc29 | |||
| 6adf65d3a8 | |||
| 229b263a9f | |||
| 093e1348fa | |||
| b78157487a | |||
| 77b30109f0 | |||
| efd047be74 | |||
| 61abfdb272 | |||
| f5088f43d8 | |||
| 9757220019 | |||
| 6b3c395220 | |||
| 67cb29652d | |||
| d0cb082b33 | |||
| 028157d2ef | |||
| bc0a582bf6 | |||
| 2eff67efc3 | |||
| 84416ef5b6 | |||
| 3428537113 | |||
| d09ab5ecfe | |||
| 447ade207f | |||
| 8bc887142c | |||
| af4e0243d2 | |||
| 4de7ba4e52 | |||
| ddd7628bbe | |||
| 1f86b0265a | |||
| e7a7400801 | |||
| e484db496b | |||
| 5bc1c8d860 | |||
| feeb471aad | |||
| dbdf4bd120 | |||
| 600d2a6ac5 | |||
| cd102c738f | |||
| 70be48fec3 | |||
| c60ff31fd4 | |||
| a93db0e012 | |||
| 7c1636a33e | |||
| f145378002 | |||
| 3ec3aa8575 | |||
| 3227b91a7c | |||
| 4e800f6952 | |||
| 8098fec345 | |||
| 7bfcea0fff | |||
| 4b4845c558 | |||
| b26e3e2fee | |||
| 388951670c | |||
| 826d3fc678 | |||
| ec0ed4d2f0 | |||
| ed63f9cf29 | |||
| 7556d0859d | |||
| 7d3488abc9 | |||
| fff7f4e63f | |||
| fea3910254 | |||
| 2d58b08f0f | |||
| 612142f0ae | |||
| 2a0c84513b | |||
| b7d3464609 | |||
| beb8574dfd | |||
| c22cc89ef0 | |||
| 58255093bf | |||
| 7e8e4586ca | |||
| 6411aed137 | |||
| 50846677d5 | |||
| 650a5c4c1f | |||
| 3b450306f1 | |||
| c67ec5f632 | |||
| 62450ee1fb | |||
| ad301b6f50 | |||
| d251682639 | |||
| 896427db83 | |||
| e03f02103b | |||
| 27c7920def | |||
| a1b0421ec1 | |||
| b7972ea391 | |||
| 662f318d6b | |||
| 9352721ec4 | |||
| eb751507c0 | |||
| 17840c5ed7 | |||
| ff4726e6ec | |||
| 4e9cd74367 | |||
| b8737d2474 | |||
| 2f4b7442c7 | |||
| e2df5a8ab0 | |||
| d97d2668d2 | |||
| d196a15a0e | |||
| 8a86347eb6 | |||
| d6675bb981 | |||
| eba03f9833 | |||
| 45da53e9ae | |||
| 618a7ea09e | |||
| e7a462fb60 | |||
| a33743cff2 | |||
| a83e19cbdf | |||
| 8a991ae24a | |||
| 6caca87b64 | |||
| 1cb56e532c | |||
| aeb657ef25 | |||
| a9b225782d | |||
| d91c6ff830 | |||
| b75a577793 | |||
| b65ed1ccb4 | |||
| 8e4bbb5e27 | |||
| b46df522e9 | |||
| 4a384edf08 | |||
| 8da1a109de | |||
| c2eb402ebf | |||
| dabedf6121 | |||
| dd02c9594b | |||
| 6913cae8f3 | |||
| 894f88e475 | |||
| ba46a97bde | |||
| 87dcea55b1 | |||
| c2dc112949 | |||
| c85713d82a | |||
| 6d970d0706 | |||
| cf047defac | |||
| aa72db079f | |||
| 483ead4243 | |||
| ddd92777b4 | |||
| 07ab24638e | |||
| ffe44155e2 | |||
| 7c2093a4c7 | |||
| 4f6fa2a15c | |||
| 9c70225a9e | |||
| b42e3ad01f | |||
| 3a40dc1f8b | |||
| 6952bedbc3 | |||
| bf299e82bb | |||
| 915790e26e | |||
| e18a26a252 | |||
| 73ccefd720 | |||
| 11385b946d | |||
| 7598e882b8 | |||
| 51cc45d178 | |||
| 9dc3d3ed82 | |||
| 6fe92e1725 | |||
| e512ceedec | |||
| d05a40389e | |||
| ea0494e8c2 | |||
| 127680c988 | |||
| cdbd9bdba3 | |||
| 1910151224 | |||
| cd27981734 | |||
| 9509d5e730 | |||
| 219733c437 | |||
| ad4fee9581 | |||
| 2af29de849 | |||
| 0c847ce1d8 | |||
| f1905b524b | |||
| f742a0ef10 | |||
| 3547ad9c57 | |||
| 0d2248352b | |||
| 012a724069 | |||
| 2e50a2ede4 | |||
| 78d7d40c0a | |||
| dac47c3214 | |||
| be3a84dcf7 | |||
| 22a2079c5f | |||
| fe2bac216f | |||
| d89e94bb8e | |||
| a95aba3ff4 | |||
| a1ebcaea23 | |||
| ab10854dde | |||
| 3f25120e04 | |||
| 44d0a0ca23 | |||
| ec645c0202 | |||
| 63134aa586 | |||
| 8489127f71 | |||
| e024463770 | |||
| 25fa85c218 | |||
| 6e20c656e7 | |||
| a158529c70 | |||
| 87b5ae8f75 | |||
| 1c163421c7 | |||
| d5e7ccac2d | |||
| 925f3614c7 | |||
| 6b21323e8c | |||
| d21d0caa68 | |||
| 63bf1797c0 | |||
| f8ba0c59a6 | |||
| 0553db3a69 | |||
| a7ef6ea3be | |||
| d72b9b47ed | |||
| 7e7186f068 | |||
| 2d61e8bbd2 | |||
| c4c350f1aa | |||
| 2f382d21dc | |||
| a968a3a035 | |||
| deb875337d | |||
| 1b0791364b | |||
| d939aa7247 |
@ -4,6 +4,7 @@ CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
|
||||
core_ios:CONFIG += disable_enum_constexpr_conversion
|
||||
core_android:CONFIG += disable_enum_constexpr_conversion
|
||||
core_mac:CONFIG += disable_enum_constexpr_conversion
|
||||
core_linux_clang:CONFIG += disable_enum_constexpr_conversion
|
||||
|
||||
core_android {
|
||||
INCLUDEPATH += $$PWD/build/android/include
|
||||
|
||||
818
Common/3dParty/harfbuzz/test/main.cpp
Normal file
818
Common/3dParty/harfbuzz/test/main.cpp
Normal file
@ -0,0 +1,818 @@
|
||||
// https://android.googlesource.com/platform/external/harfbuzz/+/ics-mr0/contrib/tables/script-properties.h
|
||||
|
||||
/*
|
||||
* https://unicode.org/reports/tr29/
|
||||
|
||||
As far as a user is concerned, the underlying representation of text is not important,
|
||||
but it is important that an editing interface present a uniform implementation of what
|
||||
the user thinks of as characters. Grapheme clusters can be treated as units, by default,
|
||||
for processes such as the formatting of drop caps, as well as the implementation of text
|
||||
selection, arrow key movement or backspacing through text, and so forth. For example,
|
||||
when a grapheme cluster is represented internally by a character sequence consisting of
|
||||
base character + accents, then using the right arrow key would skip from the start of the
|
||||
base character to the end of the last accent.
|
||||
|
||||
This document defines a default specification for grapheme clusters. It may be customized
|
||||
for particular languages, operations, or other situations. For example, arrow key movement
|
||||
could be tailored by language, or could use knowledge specific to particular fonts to move
|
||||
in a more granular manner, in circumstances where it would be useful to edit individual
|
||||
components. This could apply, for example, to the complex editorial requirements for the
|
||||
Northern Thai script Tai Tham (Lanna). Similarly, editing a grapheme cluster element by
|
||||
element may be preferable in some circumstances. For example, on a given system the backspace
|
||||
key might delete by code point, while the delete key may delete an entire cluster.
|
||||
* */
|
||||
|
||||
#include "../../../core/DesktopEditor/common/File.h"
|
||||
#include "../../../core/DesktopEditor/raster/BgraFrame.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
#include FT_OUTLINE_H
|
||||
|
||||
#include <hb-ft.h>
|
||||
#include <hb-ot.h>
|
||||
#include <hb.h>
|
||||
|
||||
class CDrawer
|
||||
{
|
||||
public:
|
||||
CBgraFrame m_oFrame;
|
||||
BYTE *pixels;
|
||||
int width;
|
||||
int height;
|
||||
int pitch;
|
||||
BYTE Rshift;
|
||||
BYTE Gshift;
|
||||
BYTE Bshift;
|
||||
BYTE Ashift;
|
||||
|
||||
public:
|
||||
CDrawer(int w, int h)
|
||||
{
|
||||
width = w;
|
||||
height = h;
|
||||
pitch = 4 * width;
|
||||
m_oFrame.put_Width(width);
|
||||
m_oFrame.put_Height(height);
|
||||
m_oFrame.put_Stride(pitch);
|
||||
|
||||
int size = 4 * width * height;
|
||||
BYTE *pPixels = new BYTE[size];
|
||||
for (int i = 0; i < size; i += 4)
|
||||
{
|
||||
pPixels[i] = 0xFF;
|
||||
pPixels[i + 1] = 0xFF;
|
||||
pPixels[i + 2] = 0xFF;
|
||||
pPixels[i + 3] = 0xFF;
|
||||
}
|
||||
pixels = pPixels;
|
||||
m_oFrame.put_Data(pPixels);
|
||||
|
||||
Bshift = 24;
|
||||
Gshift = 16;
|
||||
Rshift = 8;
|
||||
Ashift = 0;
|
||||
}
|
||||
void Save()
|
||||
{
|
||||
m_oFrame.SaveFile(NSFile::GetProcessDirectory() + L"/output.png", 4);
|
||||
}
|
||||
};
|
||||
|
||||
#define NUM_EXAMPLES 3
|
||||
|
||||
/* fonts */
|
||||
const char *fonts_paths[NUM_EXAMPLES] = {
|
||||
"C:/Windows/Fonts/calibri.ttf",
|
||||
//"C:/Windows/Fonts/arial.ttf",
|
||||
"C:/Users/korol/AppData/Local/Microsoft/Windows/Fonts/ArabicTest.ttf",
|
||||
"C:/Windows/Fonts/simsun.ttc"
|
||||
};
|
||||
|
||||
#define NUM_GLYPH_TYPES 5
|
||||
const char *num_glyph_types[NUM_GLYPH_TYPES] = {"UNCLASSIFIED", "BASE_GLYPH", "LIGATURE", "MARK", "COMPONENT"};
|
||||
|
||||
/* tranlations courtesy of google */
|
||||
const char *texts[NUM_EXAMPLES] = {
|
||||
"fi",
|
||||
"لا لآ لأ لا",
|
||||
"懶惰的姜貓"
|
||||
};
|
||||
|
||||
const hb_direction_t text_directions[NUM_EXAMPLES] = {
|
||||
HB_DIRECTION_LTR,
|
||||
HB_DIRECTION_RTL,
|
||||
HB_DIRECTION_TTB,
|
||||
};
|
||||
|
||||
const int text_skip[NUM_EXAMPLES] = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
};
|
||||
|
||||
/* XXX: These are not correct, though it doesn't seem to break anything
|
||||
* regardless of their value. */
|
||||
const char *languages[NUM_EXAMPLES] = {
|
||||
"en",
|
||||
"ar",
|
||||
"ch",
|
||||
};
|
||||
|
||||
const hb_script_t scripts[NUM_EXAMPLES] = {
|
||||
HB_SCRIPT_LATIN,
|
||||
HB_SCRIPT_ARABIC,
|
||||
HB_SCRIPT_HAN,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ENGLISH = 0,
|
||||
ARABIC,
|
||||
CHINESE
|
||||
};
|
||||
|
||||
typedef struct _spanner_baton_t
|
||||
{
|
||||
/* rendering part - assumes 32bpp surface */
|
||||
uint32_t *pixels; // set to the glyph's origin.
|
||||
uint32_t *first_pixel, *last_pixel; // bounds check
|
||||
uint32_t pitch;
|
||||
uint32_t rshift;
|
||||
uint32_t gshift;
|
||||
uint32_t bshift;
|
||||
uint32_t ashift;
|
||||
|
||||
/* sizing part */
|
||||
int min_span_x;
|
||||
int max_span_x;
|
||||
int min_y;
|
||||
int max_y;
|
||||
} spanner_baton_t;
|
||||
|
||||
/* This spanner is write only, suitable for write-only mapped buffers,
|
||||
but can cause dark streaks where glyphs overlap, like in arabic scripts.
|
||||
|
||||
Note how spanners don't clip against surface width - resize the window
|
||||
and see what it leads to. */
|
||||
void spanner_wo(int y, int count, const FT_Span *spans, void *user)
|
||||
{
|
||||
spanner_baton_t *baton = (spanner_baton_t *)user;
|
||||
uint32_t *scanline = baton->pixels - y * ((int)baton->pitch / 4);
|
||||
if (scanline < baton->first_pixel)
|
||||
return;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t color = ((spans[i].coverage / 2) << baton->rshift) | ((spans[i].coverage / 2) << baton->gshift) | ((spans[i].coverage / 2) << baton->bshift);
|
||||
|
||||
uint32_t *start = scanline + spans[i].x;
|
||||
if (start + spans[i].len > baton->last_pixel)
|
||||
return;
|
||||
|
||||
for (int x = 0; x < spans[i].len; x++)
|
||||
*start++ = color;
|
||||
}
|
||||
}
|
||||
|
||||
/* This spanner does read/modify/write, trading performance for accuracy.
|
||||
The color here is simply half coverage value in all channels,
|
||||
effectively mid-gray.
|
||||
Suitable for when artifacts mostly do come up and annoy.
|
||||
This might be optimized if one does rmw only for some values of x.
|
||||
But since the whole buffer has to be rw anyway, and the previous value
|
||||
is probably still in the cache, there's little point to. */
|
||||
void spanner_rw(int y, int count, const FT_Span *spans, void *user)
|
||||
{
|
||||
spanner_baton_t *baton = (spanner_baton_t *)user;
|
||||
uint32_t *scanline = baton->pixels - y * ((int)baton->pitch / 4);
|
||||
if (scanline < baton->first_pixel)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t color = ((spans[i].coverage / 2) << baton->rshift) | ((spans[i].coverage / 2) << baton->gshift) | ((spans[i].coverage / 2) << baton->bshift);
|
||||
uint32_t *start = scanline + spans[i].x;
|
||||
if (start + spans[i].len > baton->last_pixel)
|
||||
return;
|
||||
|
||||
for (int x = 0; x < spans[i].len; x++)
|
||||
*start++ |= color;
|
||||
}
|
||||
}
|
||||
|
||||
/* This spanner is for obtaining exact bounding box for the string.
|
||||
Unfortunately this can't be done without rendering it (or pretending to).
|
||||
After this runs, we get min and max values of coordinates used.
|
||||
*/
|
||||
void spanner_sizer(int y, int count, const FT_Span *spans, void *user)
|
||||
{
|
||||
spanner_baton_t *baton = (spanner_baton_t *)user;
|
||||
|
||||
if (y < baton->min_y)
|
||||
baton->min_y = y;
|
||||
if (y > baton->max_y)
|
||||
baton->max_y = y;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (spans[i].x + spans[i].len > baton->max_span_x)
|
||||
baton->max_span_x = spans[i].x + spans[i].len;
|
||||
if (spans[i].x < baton->min_span_x)
|
||||
baton->min_span_x = spans[i].x;
|
||||
}
|
||||
}
|
||||
|
||||
FT_SpanFunc spanner = spanner_wo;
|
||||
|
||||
void ftfdump(FT_Face ftf)
|
||||
{
|
||||
for (int i = 0; i < ftf->num_charmaps; i++)
|
||||
{
|
||||
printf(
|
||||
"%d: %s %s %c%c%c%c plat=%hu id=%hu\n", i, ftf->family_name, ftf->style_name, ftf->charmaps[i]->encoding >> 24, (ftf->charmaps[i]->encoding >> 16) & 0xff,
|
||||
(ftf->charmaps[i]->encoding >> 8) & 0xff, (ftf->charmaps[i]->encoding) & 0xff, ftf->charmaps[i]->platform_id, ftf->charmaps[i]->encoding_id);
|
||||
}
|
||||
}
|
||||
|
||||
/* See http://www.microsoft.com/typography/otspec/name.htm
|
||||
for a list of some possible platform-encoding pairs.
|
||||
We're interested in 0-3 aka 3-1 - UCS-2.
|
||||
Otherwise, fail. If a font has some unicode map, but lacks
|
||||
UCS-2 - it is a broken or irrelevant font. What exactly
|
||||
Freetype will select on face load (it promises most wide
|
||||
unicode, and if that will be slower that UCS-2 - left as
|
||||
an excercise to check. */
|
||||
int force_ucs2_charmap(FT_Face ftf)
|
||||
{
|
||||
for (int i = 0; i < ftf->num_charmaps; i++)
|
||||
if (((ftf->charmaps[i]->platform_id == 0) && (ftf->charmaps[i]->encoding_id == 3)) || ((ftf->charmaps[i]->platform_id == 3) && (ftf->charmaps[i]->encoding_id == 1)))
|
||||
return FT_Set_Charmap(ftf, ftf->charmaps[i]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void hline(CDrawer *s, int min_x, int max_x, int y, uint32_t color)
|
||||
{
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
uint32_t *pix = (uint32_t *)s->pixels + (y * s->pitch) / 4 + min_x;
|
||||
uint32_t *end = (uint32_t *)s->pixels + (y * s->pitch) / 4 + max_x;
|
||||
|
||||
while (pix - 1 != end)
|
||||
*pix++ = color;
|
||||
}
|
||||
|
||||
void vline(CDrawer *s, int min_y, int max_y, int x, uint32_t color)
|
||||
{
|
||||
if (min_y < 0)
|
||||
min_y = 0;
|
||||
|
||||
uint32_t *pix = (uint32_t *)s->pixels + (min_y * s->pitch) / 4 + x;
|
||||
uint32_t *end = (uint32_t *)s->pixels + (max_y * s->pitch) / 4 + x;
|
||||
|
||||
while (pix - s->pitch / 4 != end)
|
||||
{
|
||||
*pix = color;
|
||||
pix += s->pitch / 4;
|
||||
}
|
||||
}
|
||||
|
||||
void assert(const bool &valid)
|
||||
{
|
||||
// TODO:
|
||||
}
|
||||
|
||||
#define MAIN_CC_NO_PRIVATE_API
|
||||
#ifndef MAIN_CC_NO_PRIVATE_API
|
||||
/* Only this part of this mini app uses private API */
|
||||
#include "hb-open-file.hh"
|
||||
#include "hb-ot-layout-gdef-table.hh"
|
||||
#include "hb-ot-layout-gsubgpos.hh"
|
||||
#include "hb-static.cc"
|
||||
|
||||
using namespace OT;
|
||||
|
||||
static void print_layout_info_using_private_api(hb_blob_t *blob)
|
||||
{
|
||||
const char *font_data = hb_blob_get_data(blob, nullptr);
|
||||
hb_blob_t *font_blob = hb_sanitize_context_t().sanitize_blob<OpenTypeFontFile>(blob);
|
||||
const OpenTypeFontFile *sanitized = font_blob->as<OpenTypeFontFile>();
|
||||
if (!font_blob->data)
|
||||
{
|
||||
printf("Sanitization of the file wasn't successful. Exit");
|
||||
exit(1);
|
||||
}
|
||||
const OpenTypeFontFile &ot = *sanitized;
|
||||
|
||||
switch (ot.get_tag())
|
||||
{
|
||||
case OpenTypeFontFile::TrueTypeTag:
|
||||
printf("OpenType font with TrueType outlines\n");
|
||||
break;
|
||||
case OpenTypeFontFile::CFFTag:
|
||||
printf("OpenType font with CFF (Type1) outlines\n");
|
||||
break;
|
||||
case OpenTypeFontFile::TTCTag:
|
||||
printf("TrueType Collection of OpenType fonts\n");
|
||||
break;
|
||||
case OpenTypeFontFile::TrueTag:
|
||||
printf("Obsolete Apple TrueType font\n");
|
||||
break;
|
||||
case OpenTypeFontFile::Typ1Tag:
|
||||
printf("Obsolete Apple Type1 font in SFNT container\n");
|
||||
break;
|
||||
case OpenTypeFontFile::DFontTag:
|
||||
printf("DFont Mac Resource Fork\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown font format\n");
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned num_faces = hb_face_count(blob);
|
||||
printf("%d font(s) found in file\n", num_faces);
|
||||
for (unsigned n_font = 0; n_font < num_faces; ++n_font)
|
||||
{
|
||||
const OpenTypeFontFace &font = ot.get_face(n_font);
|
||||
printf("Font %d of %d:\n", n_font, num_faces);
|
||||
|
||||
unsigned num_tables = font.get_table_count();
|
||||
printf(" %d table(s) found in font\n", num_tables);
|
||||
for (unsigned n_table = 0; n_table < num_tables; ++n_table)
|
||||
{
|
||||
const OpenTypeTable &table = font.get_table(n_table);
|
||||
printf(" Table %2d of %2d: %.4s (0x%08x+0x%08x)\n", n_table, num_tables, (const char *)table.tag, (unsigned)table.offset, (unsigned)table.length);
|
||||
|
||||
switch (table.tag)
|
||||
{
|
||||
|
||||
case HB_OT_TAG_GSUB:
|
||||
case HB_OT_TAG_GPOS:
|
||||
{
|
||||
|
||||
const GSUBGPOS &g = *reinterpret_cast<const GSUBGPOS *>(font_data + table.offset);
|
||||
|
||||
unsigned num_scripts = g.get_script_count();
|
||||
printf(" %d script(s) found in table\n", num_scripts);
|
||||
for (unsigned n_script = 0; n_script < num_scripts; ++n_script)
|
||||
{
|
||||
const Script &script = g.get_script(n_script);
|
||||
printf(" Script %2d of %2d: %.4s\n", n_script, num_scripts, (const char *)g.get_script_tag(n_script));
|
||||
|
||||
if (!script.has_default_lang_sys())
|
||||
printf(" No default language system\n");
|
||||
int num_langsys = script.get_lang_sys_count();
|
||||
printf(" %d language system(s) found in script\n", num_langsys);
|
||||
for (int n_langsys = script.has_default_lang_sys() ? -1 : 0; n_langsys < num_langsys; ++n_langsys)
|
||||
{
|
||||
const LangSys &langsys = n_langsys == -1 ? script.get_default_lang_sys() : script.get_lang_sys(n_langsys);
|
||||
if (n_langsys == -1)
|
||||
printf(" Default Language System\n");
|
||||
else
|
||||
printf(" Language System %2d of %2d: %.4s\n", n_langsys, num_langsys, (const char *)script.get_lang_sys_tag(n_langsys));
|
||||
if (!langsys.has_required_feature())
|
||||
printf(" No required feature\n");
|
||||
else
|
||||
printf(" Required feature index: %d\n", langsys.get_required_feature_index());
|
||||
|
||||
unsigned num_features = langsys.get_feature_count();
|
||||
printf(" %d feature(s) found in language system\n", num_features);
|
||||
for (unsigned n_feature = 0; n_feature < num_features; ++n_feature)
|
||||
{
|
||||
printf(" Feature index %2d of %2d: %d\n", n_feature, num_features, langsys.get_feature_index(n_feature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned num_features = g.get_feature_count();
|
||||
printf(" %d feature(s) found in table\n", num_features);
|
||||
for (unsigned n_feature = 0; n_feature < num_features; ++n_feature)
|
||||
{
|
||||
const Feature &feature = g.get_feature(n_feature);
|
||||
unsigned num_lookups = feature.get_lookup_count();
|
||||
printf(" Feature %2d of %2d: %c%c%c%c\n", n_feature, num_features, HB_UNTAG(g.get_feature_tag(n_feature)));
|
||||
|
||||
printf(" %d lookup(s) found in feature\n", num_lookups);
|
||||
for (unsigned n_lookup = 0; n_lookup < num_lookups; ++n_lookup)
|
||||
{
|
||||
printf(" Lookup index %2d of %2d: %d\n", n_lookup, num_lookups, feature.get_lookup_index(n_lookup));
|
||||
}
|
||||
}
|
||||
|
||||
unsigned num_lookups = g.get_lookup_count();
|
||||
printf(" %d lookup(s) found in table\n", num_lookups);
|
||||
for (unsigned n_lookup = 0; n_lookup < num_lookups; ++n_lookup)
|
||||
{
|
||||
const Lookup &lookup = g.get_lookup(n_lookup);
|
||||
printf(" Lookup %2d of %2d: type %d, props 0x%04X\n", n_lookup, num_lookups, lookup.get_type(), lookup.get_props());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDEF::tableTag:
|
||||
{
|
||||
|
||||
const GDEF &gdef = *reinterpret_cast<const GDEF *>(font_data + table.offset);
|
||||
|
||||
printf(" Has %sglyph classes\n", gdef.has_glyph_classes() ? "" : "no ");
|
||||
printf(" Has %smark attachment types\n", gdef.has_mark_attachment_types() ? "" : "no ");
|
||||
printf(" Has %sattach points\n", gdef.has_attach_points() ? "" : "no ");
|
||||
printf(" Has %slig carets\n", gdef.has_lig_carets() ? "" : "no ");
|
||||
printf(" Has %smark sets\n", gdef.has_mark_sets() ? "" : "no ");
|
||||
|
||||
hb_position_t caret_array[16];
|
||||
unsigned int caret_count = 16;
|
||||
|
||||
unsigned int num_carets = gdef.get_lig_carets(nullptr, HB_DIRECTION_LTR, 302, 0, &caret_count, caret_array);
|
||||
int y = 0;
|
||||
++y;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* end of private API use */
|
||||
#endif
|
||||
|
||||
struct hb_feature_test {
|
||||
hb_tag_t tag;
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// hb_blob_t* blobFileTest = hb_blob_create_from_file("C:/Windows/Fonts/calibri.ttf");
|
||||
// print_layout_info_using_private_api(blobFileTest);
|
||||
|
||||
int ptSize = 40 * 64;
|
||||
int device_hdpi = 72;
|
||||
int device_vdpi = 72;
|
||||
|
||||
/* Init freetype */
|
||||
FT_Library ft_library;
|
||||
assert(!FT_Init_FreeType(&ft_library));
|
||||
|
||||
/* Load our fonts */
|
||||
FT_Face ft_face[NUM_EXAMPLES];
|
||||
assert(!FT_New_Face(ft_library, fonts_paths[0], 0, &ft_face[ENGLISH]));
|
||||
assert(!FT_Set_Char_Size(ft_face[ENGLISH], 0, ptSize, device_hdpi, device_vdpi));
|
||||
ftfdump(ft_face[ENGLISH]); // wonderful world of encodings ...
|
||||
// force_ucs2_charmap(ft_face[ENGLISH]); // which we ignore.
|
||||
|
||||
assert(!FT_New_Face(ft_library, fonts_paths[1], 0, &ft_face[ARABIC]));
|
||||
assert(!FT_Set_Char_Size(ft_face[ARABIC], 0, ptSize, device_hdpi, device_vdpi));
|
||||
ftfdump(ft_face[ARABIC]);
|
||||
// force_ucs2_charmap(ft_face[ARABIC]);
|
||||
|
||||
assert(!FT_New_Face(ft_library, fonts_paths[2], 0, &ft_face[CHINESE]));
|
||||
assert(!FT_Set_Char_Size(ft_face[CHINESE], 0, ptSize, device_hdpi, device_vdpi));
|
||||
ftfdump(ft_face[CHINESE]);
|
||||
// force_ucs2_charmap(ft_face[CHINESE]);
|
||||
|
||||
/* Get our harfbuzz font structs */
|
||||
hb_font_t *hb_ft_font[NUM_EXAMPLES];
|
||||
hb_ft_font[ENGLISH] = hb_ft_font_create(ft_face[ENGLISH], NULL);
|
||||
|
||||
// hb_blob_t* blobFile = hb_blob_create_from_file(sFont1.c_str());
|
||||
// hb_face_t* faceFile = hb_face_create(blobFile, 0);
|
||||
// hb_ft_font[ENGLISH] = hb_font_create(faceFile);
|
||||
|
||||
hb_ft_font[ARABIC] = hb_ft_font_create(ft_face[ARABIC], NULL);
|
||||
hb_ft_font[CHINESE] = hb_ft_font_create(ft_face[CHINESE], NULL);
|
||||
|
||||
hb_ft_font_set_funcs(hb_ft_font[ENGLISH]);
|
||||
hb_ft_font_set_funcs(hb_ft_font[ARABIC]);
|
||||
hb_ft_font_set_funcs(hb_ft_font[CHINESE]);
|
||||
|
||||
/** Setup our SDL window **/
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
int bpp = 32;
|
||||
|
||||
CDrawer oDrawer(width, height);
|
||||
|
||||
/* Create a buffer for harfbuzz to use */
|
||||
hb_buffer_t *buf = hb_buffer_create();
|
||||
for (int i = 0; i < NUM_EXAMPLES; ++i)
|
||||
{
|
||||
if (text_skip[i])
|
||||
continue;
|
||||
|
||||
hb_buffer_set_direction(buf, text_directions[i]); /* or LTR */
|
||||
hb_buffer_set_script(buf, scripts[i]); /* see hb-unicode.h */
|
||||
hb_buffer_set_language(buf, hb_language_from_string(languages[i], strlen(languages[i])));
|
||||
// hb_buffer_set_cluster_level (buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES);
|
||||
// hb_buffer_set_cluster_level (buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
|
||||
hb_buffer_set_cluster_level(buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES);
|
||||
|
||||
hb_feature_test features[] {
|
||||
{HB_TAG('r','l','i','g'), 1},
|
||||
{HB_TAG('l','i','g','a'), 0},
|
||||
{HB_TAG('c','l','i','g'), 1},
|
||||
{HB_TAG('h','l','i','g'), 1},
|
||||
{HB_TAG('d','l','i','g'), 1},
|
||||
{HB_TAG('k','e','r','n'), 2},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
int userfeatures_count = 0;
|
||||
hb_feature_t userfeatures[100];
|
||||
|
||||
hb_feature_test* current_feature = features;
|
||||
while (current_feature->tag != 0)
|
||||
{
|
||||
if (current_feature->value != 2)
|
||||
{
|
||||
userfeatures[userfeatures_count].tag = current_feature->tag;
|
||||
userfeatures[userfeatures_count].value = current_feature->value;
|
||||
userfeatures[userfeatures_count].start = HB_FEATURE_GLOBAL_START;
|
||||
userfeatures[userfeatures_count].end = HB_FEATURE_GLOBAL_END;
|
||||
userfeatures_count++;
|
||||
}
|
||||
current_feature++;
|
||||
}
|
||||
|
||||
/* Layout the text */
|
||||
hb_buffer_add_utf8(buf, texts[i], strlen(texts[i]), 0, strlen(texts[i]));
|
||||
|
||||
// detect script by codes
|
||||
hb_buffer_guess_segment_properties(buf);
|
||||
|
||||
// const char*const pHbShapers[] = { "graphite2", "coretext_aat", "ot", "fallback", nullptr };
|
||||
// bool ok = hb_shape_full(hb_ft_font[i], buf, userfeatures, userfeatures_count, pHbShapers);
|
||||
|
||||
hb_shape(hb_ft_font[i], buf, (userfeatures_count != 0) ? userfeatures : NULL, userfeatures_count);
|
||||
|
||||
unsigned int glyph_count;
|
||||
hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buf, &glyph_count);
|
||||
hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(buf, &glyph_count);
|
||||
|
||||
#if 1
|
||||
hb_position_t caret_array[16];
|
||||
unsigned int caret_count = 16;
|
||||
|
||||
unsigned int num_carets = hb_ot_layout_get_ligature_carets(hb_ft_font[i], text_directions[i], glyph_info[0].codepoint, -1, &caret_count, caret_array);
|
||||
#endif
|
||||
|
||||
/* set up rendering via spanners */
|
||||
spanner_baton_t stuffbaton;
|
||||
|
||||
FT_Raster_Params ftr_params;
|
||||
ftr_params.target = 0;
|
||||
ftr_params.flags = FT_RASTER_FLAG_DIRECT | FT_RASTER_FLAG_AA;
|
||||
ftr_params.user = &stuffbaton;
|
||||
ftr_params.black_spans = 0;
|
||||
ftr_params.bit_set = 0;
|
||||
ftr_params.bit_test = 0;
|
||||
|
||||
/* Calculate string bounding box in pixels */
|
||||
ftr_params.gray_spans = spanner_sizer;
|
||||
|
||||
/* See http://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html */
|
||||
|
||||
int max_x = INT_MIN; // largest coordinate a pixel has been set at, or the pen was advanced to.
|
||||
int min_x = INT_MAX; // smallest coordinate a pixel has been set at, or the pen was advanced to.
|
||||
int max_y = INT_MIN; // this is max topside bearing along the string.
|
||||
int min_y = INT_MAX; // this is max value of (height - topbearing) along the string.
|
||||
/* Naturally, the above comments swap their meaning between horizontal and vertical scripts,
|
||||
since the pen changes the axis it is advanced along.
|
||||
However, their differences still make up the bounding box for the string.
|
||||
Also note that all this is in FT coordinate system where y axis points upwards.
|
||||
*/
|
||||
|
||||
int sizer_x = 0;
|
||||
int sizer_y = 0; /* in FT coordinate system. */
|
||||
|
||||
printf("----------------------------------------------------\n");
|
||||
for (unsigned j = 0; j < glyph_count; ++j)
|
||||
{
|
||||
hb_ot_layout_glyph_class_t glyph_type = hb_ot_layout_get_glyph_class(hb_font_get_face(hb_ft_font[i]), glyph_info[j].codepoint);
|
||||
hb_glyph_flags_t glyph_type_flags = hb_glyph_info_get_glyph_flags(&glyph_info[j]);
|
||||
printf(
|
||||
"glyph(%s, flags: %d): gid:%d, cluster:%d, [%d, %d, %d, %d, %d]\n", num_glyph_types[glyph_type], glyph_type_flags, (int)glyph_info[j].codepoint, (int)glyph_info[j].cluster,
|
||||
glyph_pos[j].x_advance, glyph_pos[j].y_advance, glyph_pos[j].x_offset, glyph_pos[j].y_offset, glyph_pos[j].var);
|
||||
}
|
||||
|
||||
FT_Error fterr;
|
||||
for (unsigned j = 0; j < glyph_count; ++j)
|
||||
{
|
||||
if ((fterr = FT_Load_Glyph(ft_face[i], glyph_info[j].codepoint, 0)))
|
||||
{
|
||||
printf("load %08x failed fterr=%d.\n", glyph_info[j].codepoint, fterr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ft_face[i]->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
printf("glyph->format = %4s\n", (char *)&ft_face[i]->glyph->format);
|
||||
}
|
||||
else
|
||||
{
|
||||
int gx = sizer_x + (glyph_pos[j].x_offset / 64);
|
||||
int gy = sizer_y + (glyph_pos[j].y_offset / 64); // note how the sign differs from the rendering pass
|
||||
|
||||
stuffbaton.min_span_x = INT_MAX;
|
||||
stuffbaton.max_span_x = INT_MIN;
|
||||
stuffbaton.min_y = INT_MAX;
|
||||
stuffbaton.max_y = INT_MIN;
|
||||
|
||||
if ((fterr = FT_Outline_Render(ft_library, &ft_face[i]->glyph->outline, &ftr_params)))
|
||||
printf("FT_Outline_Render() failed err=%d\n", fterr);
|
||||
|
||||
if (stuffbaton.min_span_x != INT_MAX)
|
||||
{
|
||||
/* Update values if the spanner was actually called. */
|
||||
if (min_x > stuffbaton.min_span_x + gx)
|
||||
min_x = stuffbaton.min_span_x + gx;
|
||||
|
||||
if (max_x < stuffbaton.max_span_x + gx)
|
||||
max_x = stuffbaton.max_span_x + gx;
|
||||
|
||||
if (min_y > stuffbaton.min_y + gy)
|
||||
min_y = stuffbaton.min_y + gy;
|
||||
|
||||
if (max_y < stuffbaton.max_y + gy)
|
||||
max_y = stuffbaton.max_y + gy;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The spanner wasn't called at all - an empty glyph, like space. */
|
||||
if (min_x > gx)
|
||||
min_x = gx;
|
||||
if (max_x < gx)
|
||||
max_x = gx;
|
||||
if (min_y > gy)
|
||||
min_y = gy;
|
||||
if (max_y < gy)
|
||||
max_y = gy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sizer_x += glyph_pos[j].x_advance / 64;
|
||||
sizer_y += glyph_pos[j].y_advance / 64; // note how the sign differs from the rendering pass
|
||||
}
|
||||
/* Still have to take into account last glyph's advance. Or not? */
|
||||
if (min_x > sizer_x)
|
||||
min_x = sizer_x;
|
||||
if (max_x < sizer_x)
|
||||
max_x = sizer_x;
|
||||
if (min_y > sizer_y)
|
||||
min_y = sizer_y;
|
||||
if (max_y < sizer_y)
|
||||
max_y = sizer_y;
|
||||
|
||||
/* The bounding box */
|
||||
int bbox_w = max_x - min_x;
|
||||
int bbox_h = max_y - min_y;
|
||||
|
||||
/* Two offsets below position the bounding box with respect to the 'origin',
|
||||
which is sort of origin of string's first glyph.
|
||||
|
||||
baseline_offset - offset perpendecular to the baseline to the topmost (horizontal),
|
||||
or leftmost (vertical) pixel drawn.
|
||||
|
||||
baseline_shift - offset along the baseline, from the first drawn glyph's origin
|
||||
to the leftmost (horizontal), or topmost (vertical) pixel drawn.
|
||||
|
||||
Thus those offsets allow positioning the bounding box to fit the rendered string,
|
||||
as they are in fact offsets from the point given to the renderer, to the top left
|
||||
corner of the bounding box.
|
||||
|
||||
NB: baseline is defined as y==0 for horizontal and x==0 for vertical scripts.
|
||||
(0,0) here is where the first glyph's origin ended up after shaping, not taking
|
||||
into account glyph_pos[0].xy_offset (yeah, my head hurts too).
|
||||
*/
|
||||
|
||||
int baseline_offset;
|
||||
int baseline_shift;
|
||||
|
||||
if (HB_DIRECTION_IS_HORIZONTAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
baseline_offset = max_y;
|
||||
baseline_shift = min_x;
|
||||
}
|
||||
if (HB_DIRECTION_IS_VERTICAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
baseline_offset = min_x;
|
||||
baseline_shift = max_y;
|
||||
}
|
||||
|
||||
/* The pen/baseline start coordinates in window coordinate system
|
||||
- with those text placement in the window is controlled.
|
||||
- note that for RTL scripts pen still goes LTR */
|
||||
int x = 0, y = 50 + i * 75;
|
||||
if (i == ENGLISH)
|
||||
{
|
||||
x = 20;
|
||||
} /* left justify */
|
||||
if (i == ARABIC)
|
||||
{
|
||||
x = width - bbox_w - 20;
|
||||
} /* right justify */
|
||||
if (i == CHINESE)
|
||||
{
|
||||
x = width / 2 - bbox_w / 2;
|
||||
} /* center, and for TTB script h_advance is half-width. */
|
||||
|
||||
/* Draw baseline and the bounding box */
|
||||
/* The below is complicated since we simultaneously
|
||||
convert to the window coordinate system. */
|
||||
int left, right, top, bottom;
|
||||
|
||||
if (HB_DIRECTION_IS_HORIZONTAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
/* bounding box in window coordinates without offsets */
|
||||
left = x;
|
||||
right = x + bbox_w;
|
||||
top = y - bbox_h;
|
||||
bottom = y;
|
||||
|
||||
/* apply offsets */
|
||||
left += baseline_shift;
|
||||
right += baseline_shift;
|
||||
top -= baseline_offset - bbox_h;
|
||||
bottom -= baseline_offset - bbox_h;
|
||||
|
||||
/* draw the baseline */
|
||||
hline(&oDrawer, x, x + bbox_w, y, 0x0000ff00);
|
||||
}
|
||||
|
||||
if (HB_DIRECTION_IS_VERTICAL(hb_buffer_get_direction(buf)))
|
||||
{
|
||||
left = x;
|
||||
right = x + bbox_w;
|
||||
top = y;
|
||||
bottom = y + bbox_h;
|
||||
|
||||
left += baseline_offset;
|
||||
right += baseline_offset;
|
||||
top -= baseline_shift;
|
||||
bottom -= baseline_shift;
|
||||
|
||||
vline(&oDrawer, y, y + bbox_h, x, 0x0000ff00);
|
||||
}
|
||||
|
||||
/* +1/-1 are for the bbox borders be the next pixel outside the bbox itself */
|
||||
hline(&oDrawer, left - 1, right + 1, top - 1, 0xffff0000);
|
||||
hline(&oDrawer, left - 1, right + 1, bottom + 1, 0xffff0000);
|
||||
vline(&oDrawer, top - 1, bottom + 1, left - 1, 0xffff0000);
|
||||
vline(&oDrawer, top - 1, bottom + 1, right + 1, 0xffff0000);
|
||||
|
||||
/* set rendering spanner */
|
||||
ftr_params.gray_spans = spanner;
|
||||
|
||||
/* initialize rendering part of the baton */
|
||||
stuffbaton.pixels = NULL;
|
||||
stuffbaton.first_pixel = (uint32_t *)oDrawer.pixels;
|
||||
stuffbaton.last_pixel = (uint32_t *)(((uint8_t *)oDrawer.pixels) + oDrawer.pitch * oDrawer.height);
|
||||
stuffbaton.pitch = oDrawer.pitch;
|
||||
stuffbaton.rshift = oDrawer.Rshift;
|
||||
stuffbaton.gshift = oDrawer.Gshift;
|
||||
stuffbaton.bshift = oDrawer.Bshift;
|
||||
|
||||
/* render */
|
||||
for (unsigned j = 0; j < glyph_count; ++j)
|
||||
{
|
||||
if ((fterr = FT_Load_Glyph(ft_face[i], glyph_info[j].codepoint, 0)))
|
||||
{
|
||||
printf("load %08x failed fterr=%d.\n", glyph_info[j].codepoint, fterr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ft_face[i]->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
printf("glyph->format = %4s\n", (char *)&ft_face[i]->glyph->format);
|
||||
}
|
||||
else
|
||||
{
|
||||
int gx = x + (glyph_pos[j].x_offset / 64);
|
||||
int gy = y - (glyph_pos[j].y_offset / 64);
|
||||
|
||||
stuffbaton.pixels = (uint32_t *)(((uint8_t *)oDrawer.pixels) + gy * oDrawer.pitch) + gx;
|
||||
|
||||
if ((fterr = FT_Outline_Render(ft_library, &ft_face[i]->glyph->outline, &ftr_params)))
|
||||
printf("FT_Outline_Render() failed err=%d\n", fterr);
|
||||
}
|
||||
}
|
||||
|
||||
x += glyph_pos[j].x_advance / 64;
|
||||
y -= glyph_pos[j].y_advance / 64;
|
||||
}
|
||||
|
||||
/* clean up the buffer, but don't kill it just yet */
|
||||
hb_buffer_clear_contents(buf);
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
hb_buffer_destroy(buf);
|
||||
for (int i = 0; i < NUM_EXAMPLES; ++i)
|
||||
hb_font_destroy(hb_ft_font[i]);
|
||||
|
||||
FT_Done_FreeType(ft_library);
|
||||
|
||||
oDrawer.Save();
|
||||
|
||||
return 0;
|
||||
}
|
||||
19
Common/3dParty/harfbuzz/test/test.pro
Normal file
19
Common/3dParty/harfbuzz/test/test.pro
Normal file
@ -0,0 +1,19 @@
|
||||
CONFIG -= qt
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../../core
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
include($$CORE_ROOT_DIR/DesktopEditor/graphics/pro/freetype.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/harfbuzz/harfbuzz.pri)
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel, graphics)
|
||||
DESTDIR = $$PWD/build
|
||||
|
||||
|
||||
@ -25,3 +25,5 @@ if not base.is_dir("katana-parser"):
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/tokenizer.c", "static inline bool2 katana_is_html_space(char c);", "static inline bool katana_is_html_space(char c);")
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/parser.c", "katanaget_text(parser->scanner)", "/*katanaget_text(parser->scanner)*/\"error\"")
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/parser.c", "#define KATANA_PARSER_STRING(literal) (KatanaParserString){", "#define KATANA_PARSER_STRING(literal) {")
|
||||
# katana may not be able to handle an empty string correctly in some cases (bug#73485)
|
||||
base.replaceInFileUtf8(base_directory + "/katana-parser/src/foundation.c", "size_t len = strlen(str);", "if (NULL == str)\n return;\n size_t len = strlen(str);")
|
||||
|
||||
@ -19,7 +19,6 @@ static std::string nonbreaking_inline = "|a|abbr|acronym|b|bdo|big|cite|code|df
|
||||
static std::string empty_tags = "|area|base|basefont|bgsound|br|command|col|embed|event-source|frame|hr|image|img|input|keygen|link|menuitem|meta|param|source|spacer|track|wbr|";
|
||||
static std::string preserve_whitespace = "|pre|textarea|script|style|";
|
||||
static std::string special_handling = "|html|body|";
|
||||
static std::string no_entity_sub = ""; //"|style|";
|
||||
static std::string treat_like_inline = "|p|";
|
||||
|
||||
static std::vector<std::string> html_tags = {"div","span","a","img","p","h1","h2","h3","h4","h5","h6",
|
||||
@ -436,9 +435,25 @@ static void substitute_xml_entities_into_text(std::string& text)
|
||||
replace_all(text, ">", ">");
|
||||
}
|
||||
|
||||
// After running through Gumbo, the values of type "" are replaced with the corresponding code '0x01'
|
||||
// Since the attribute value does not use control characters (value <= 0x1F),
|
||||
// then just delete them, otherwise XmlUtils::CXmlLiteReader crashes on them.
|
||||
// bug#73486
|
||||
static void remove_control_symbols(std::string& text)
|
||||
{
|
||||
std::string::iterator itFound = std::find_if(text.begin(), text.end(), [](char chValue){ return chValue <= 0x1F; });
|
||||
|
||||
while (itFound != text.end())
|
||||
{
|
||||
itFound = text.erase(itFound);
|
||||
itFound = std::find_if(itFound, text.end(), [](char chValue){ return chValue <= 0x1F; });
|
||||
}
|
||||
}
|
||||
|
||||
// Заменяет сущности " в text
|
||||
static void substitute_xml_entities_into_attributes(std::string& text)
|
||||
{
|
||||
remove_control_symbols(text);
|
||||
substitute_xml_entities_into_text(text);
|
||||
replace_all(text, "\"", """);
|
||||
}
|
||||
@ -486,7 +501,7 @@ static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuil
|
||||
}
|
||||
}
|
||||
|
||||
static void build_attributes(const GumboVector* attribs, bool no_entities, NSStringUtils::CStringBuilderA& atts)
|
||||
static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringBuilderA& atts)
|
||||
{
|
||||
std::vector<std::string> arrRepeat;
|
||||
for (size_t i = 0; i < attribs->length; ++i)
|
||||
@ -532,8 +547,7 @@ static void build_attributes(const GumboVector* attribs, bool no_entities, NSStr
|
||||
std::string qs ="\"";
|
||||
atts.WriteString("=");
|
||||
atts.WriteString(qs);
|
||||
if(!no_entities)
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
atts.WriteString(sVal);
|
||||
atts.WriteString(qs);
|
||||
}
|
||||
@ -542,7 +556,6 @@ static void build_attributes(const GumboVector* attribs, bool no_entities, NSStr
|
||||
static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA& contents, bool bCheckValidNode)
|
||||
{
|
||||
std::string key = "|" + get_tag_name(node) + "|";
|
||||
bool no_entity_substitution = no_entity_sub.find(key) != std::string::npos;
|
||||
bool keep_whitespace = preserve_whitespace.find(key) != std::string::npos;
|
||||
bool is_inline = nonbreaking_inline.find(key) != std::string::npos;
|
||||
bool is_like_inline = treat_like_inline.find(key) != std::string::npos;
|
||||
@ -556,8 +569,7 @@ static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA
|
||||
if (child->type == GUMBO_NODE_TEXT)
|
||||
{
|
||||
std::string val(child->v.text.text);
|
||||
if(!no_entity_substitution)
|
||||
substitute_xml_entities_into_text(val);
|
||||
substitute_xml_entities_into_text(val);
|
||||
|
||||
// Избавление от FF
|
||||
size_t found = val.find_first_of("\014");
|
||||
@ -613,7 +625,6 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
std::string closeTag = "";
|
||||
std::string key = "|" + tagname + "|";
|
||||
bool is_empty_tag = empty_tags.find(key) != std::string::npos;
|
||||
bool no_entity_substitution = no_entity_sub.find(key) != std::string::npos;
|
||||
|
||||
// determine closing tag type
|
||||
if (is_empty_tag)
|
||||
@ -626,7 +637,7 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
|
||||
// build attr string
|
||||
const GumboVector* attribs = &node->v.element.attributes;
|
||||
build_attributes(attribs, no_entity_substitution, oBuilder);
|
||||
build_attributes(attribs, oBuilder);
|
||||
oBuilder.WriteString(close + ">");
|
||||
|
||||
// prettyprint your contents
|
||||
|
||||
@ -68,6 +68,7 @@ public:
|
||||
bool isOOXFormatFile(const std::wstring& fileName, bool unpacked = false);
|
||||
bool isOpenOfficeFormatFile(const std::wstring& fileName, std::wstring& documentID);
|
||||
bool isOnlyOfficeFormatFile(const std::wstring& fileName);
|
||||
bool isMacFormatFile(const std::wstring& fileName);
|
||||
|
||||
bool isDocFormatFile(const std::wstring& fileName);
|
||||
bool isXlsFormatFile(const std::wstring& fileName);
|
||||
@ -80,6 +81,7 @@ public:
|
||||
bool isMS_MITCRYPTOFormatFile(POLE::Storage* storage, std::wstring& documentID);
|
||||
bool isVbaProjectFile(POLE::Storage* storage);
|
||||
bool isMS_OFFCRYPTOFormatFile(const std::wstring& fileName, std::wstring& documentID);
|
||||
bool isHwpFile(POLE::Storage* storage);
|
||||
|
||||
bool iXmlFile(const std::wstring& fileName);
|
||||
|
||||
@ -101,9 +103,11 @@ public:
|
||||
bool isBinaryDoctFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isBinaryXlstFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isBinaryPpttFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isBinaryVsdtFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
|
||||
bool isDjvuFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isMobiFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isFB2FormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isXpsFile(const std::wstring& fileName);
|
||||
bool isOFDFile(const std::wstring& fileName);
|
||||
};
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
|
||||
#include "3dParty/pole/pole.h"
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include "OfficeFileFormatDefines.h"
|
||||
|
||||
@ -222,6 +223,16 @@ bool COfficeFileFormatChecker::isBinaryPpttFormatFile(unsigned char *pBuffer, in
|
||||
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isBinaryVsdtFormatFile(unsigned char* pBuffer, int dwBytes)
|
||||
{
|
||||
if (pBuffer == NULL)
|
||||
return false;
|
||||
|
||||
if ((4 <= dwBytes) && ('V' == pBuffer[0] && 'S' == pBuffer[1] && 'D' == pBuffer[2] && 'Y' == pBuffer[3]))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isPdfFormatFile(unsigned char *pBuffer, int dwBytes, std::wstring &documentID)
|
||||
{
|
||||
if (pBuffer == NULL)
|
||||
@ -451,6 +462,20 @@ bool COfficeFileFormatChecker::isVbaProjectFile(POLE::Storage *storage)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isHwpFile(POLE::Storage* storage)
|
||||
{
|
||||
if (storage == NULL)
|
||||
return false;
|
||||
|
||||
unsigned char buffer[10];
|
||||
|
||||
POLE::Stream stream(storage, L"BodyText/Section0");
|
||||
if (stream.read(buffer, 10) < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isXlsFormatFile(POLE::Storage *storage)
|
||||
{
|
||||
if (storage == NULL)
|
||||
@ -721,6 +746,11 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_VBAPROJECT;
|
||||
return true;
|
||||
}
|
||||
else if (isHwpFile(&storage))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
NSFile::CFileBinary file;
|
||||
if (!file.OpenFile(fileName))
|
||||
@ -767,6 +797,20 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isOFDFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isMacFormatFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
@ -790,6 +834,10 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION;
|
||||
}
|
||||
else if (isBinaryVsdtFormatFile(bufferDetect, sizeRead)) // min size - 4
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_DRAW;
|
||||
}
|
||||
else if (isOOXFlatFormatFile(bufferDetect, sizeRead))
|
||||
{
|
||||
// nFileType;
|
||||
@ -1124,6 +1172,10 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring &fileNa
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY;
|
||||
}
|
||||
else if (isBinaryVsdtFormatFile(pBuffer, nBufferSize))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY;
|
||||
}
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
@ -1133,6 +1185,222 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring &fileNa
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
struct TIWAField
|
||||
{
|
||||
size_t m_unStart;
|
||||
size_t m_unEnd;
|
||||
unsigned m_uIndex;
|
||||
unsigned m_unWireType;
|
||||
uint64_t m_oValue;
|
||||
};
|
||||
|
||||
bool ReadUVar(BYTE* pBuffer, size_t unEndPos, size_t& unPos, uint64_t& unValue)
|
||||
{
|
||||
std::vector<unsigned char> arBytes;
|
||||
arBytes.reserve(8);
|
||||
|
||||
unValue = 0;
|
||||
|
||||
bool bNext = true;
|
||||
while (unPos < unEndPos && bNext)
|
||||
{
|
||||
const unsigned char c = pBuffer[unPos++];
|
||||
arBytes.push_back((unsigned char)(c & ~0x80));
|
||||
bNext = c & 0x80;
|
||||
}
|
||||
|
||||
if (bNext && unPos == unEndPos)
|
||||
return false;
|
||||
|
||||
for (std::vector<unsigned char>::const_reverse_iterator it = arBytes.rbegin(); it != arBytes.rend(); ++it)
|
||||
{
|
||||
if (std::numeric_limits<uint64_t>::max() >> 7 < unValue ||
|
||||
std::numeric_limits<uint64_t>::max() - (unValue << 7) < *it) // overflow
|
||||
return false;
|
||||
|
||||
unValue = (unValue << 7) + *it;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadIWAField(BYTE* pBuffer, size_t unEndPos, size_t& unPos, TIWAField& oIWAField)
|
||||
{
|
||||
if (NULL == pBuffer || unPos + 2 > unEndPos)
|
||||
return false;
|
||||
|
||||
unsigned uSpec;
|
||||
|
||||
uSpec = (unsigned)pBuffer[unPos++];
|
||||
oIWAField.m_unWireType = uSpec & 0x7;
|
||||
|
||||
oIWAField.m_unStart = unPos;
|
||||
|
||||
switch (oIWAField.m_unWireType)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (!ReadUVar(pBuffer, unEndPos, unPos, oIWAField.m_oValue))
|
||||
return false;
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
unPos += 4;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
uint64_t unLen;
|
||||
if (!ReadUVar(pBuffer, unEndPos, unPos, unLen) || unPos + unLen > unEndPos)
|
||||
return false;
|
||||
|
||||
oIWAField.m_unStart = unPos;
|
||||
unPos += unLen;
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
unPos += 2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
oIWAField.m_unEnd = unPos;
|
||||
oIWAField.m_uIndex = uSpec >> 3;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DetectIWorkFormat(const std::wstring& fileName, int &nType)
|
||||
{
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
|
||||
ULONG unSize = 0;
|
||||
BYTE* pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Document.iwa", &pBuffer, unSize);
|
||||
|
||||
if (hresult != S_OK || NULL == pBuffer)
|
||||
return false;
|
||||
|
||||
#define CLEAR_BUFFER_AND_RETURN(return_value)\
|
||||
do{\
|
||||
delete[] pBuffer;\
|
||||
return return_value;\
|
||||
}while(false)
|
||||
|
||||
if (unSize < 13)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
size_t uPos = 6;
|
||||
|
||||
for (; uPos < 12; ++uPos)
|
||||
{
|
||||
if (0x08 == pBuffer[uPos] && 0x01 == pBuffer[uPos + 1])
|
||||
{
|
||||
--uPos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (12 == uPos)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
uint64_t unHeaderLen;
|
||||
if (!ReadUVar(pBuffer, unSize, uPos, unHeaderLen))
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
const size_t uStartPos = uPos;
|
||||
|
||||
if (unHeaderLen < 8 || unSize < unHeaderLen + uStartPos)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
uPos += 2;
|
||||
|
||||
TIWAField oMessageField;
|
||||
|
||||
if (!ReadIWAField(pBuffer, uStartPos + unHeaderLen, uPos, oMessageField) || 2 != oMessageField.m_unWireType ||
|
||||
2 != oMessageField.m_uIndex)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
size_t uSubPos = oMessageField.m_unStart;
|
||||
TIWAField oField;
|
||||
|
||||
if (!ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oField) || 0 != oField.m_unWireType ||
|
||||
1 != oField.m_uIndex)
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
|
||||
switch (oField.m_oValue)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
uint32_t unDataLen = 0;
|
||||
|
||||
TIWAField oTempField;
|
||||
if (ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oTempField) &&
|
||||
ReadIWAField(pBuffer, oMessageField.m_unEnd, uSubPos, oTempField) && 0 == oTempField.m_unWireType &&
|
||||
3 == oTempField.m_uIndex)
|
||||
unDataLen += oTempField.m_oValue;
|
||||
|
||||
size_t unTempPos = uStartPos + unHeaderLen;
|
||||
|
||||
// keynote: presentation ref in 2
|
||||
// number: sheet ref in 1
|
||||
if (ReadIWAField(pBuffer, uStartPos + unDataLen, unTempPos, oTempField) &&
|
||||
(2 != oTempField.m_unWireType || 1 != oTempField.m_uIndex || oTempField.m_unEnd - oTempField.m_unStart < 2))
|
||||
{
|
||||
nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
CLEAR_BUFFER_AND_RETURN(true);
|
||||
}
|
||||
else if (ReadIWAField(pBuffer, uStartPos + unDataLen, unTempPos, oTempField) &&
|
||||
(2 != oTempField.m_unWireType || 2 != oTempField.m_uIndex || oTempField.m_unEnd - oTempField.m_unStart < 2))
|
||||
{
|
||||
nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
CLEAR_BUFFER_AND_RETURN(true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 10000:
|
||||
{
|
||||
nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
CLEAR_BUFFER_AND_RETURN(true);
|
||||
}
|
||||
}
|
||||
|
||||
CLEAR_BUFFER_AND_RETURN(false);
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName)
|
||||
{
|
||||
if (DetectIWorkFormat(fileName, nFileType))
|
||||
return true;
|
||||
|
||||
std::wstring::size_type nExtPos = fileName.rfind(L'.');
|
||||
std::wstring sExt = L"unknown";
|
||||
|
||||
if (nExtPos != std::wstring::npos)
|
||||
sExt = fileName.substr(nExtPos);
|
||||
|
||||
std::transform(sExt.begin(), sExt.end(), sExt.begin(), tolower);
|
||||
|
||||
if (0 == sExt.compare(L".pages"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
else if (0 == sExt.compare(L".numbers"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
else if (0 == sExt.compare(L".key"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring &fileName, std::wstring &documentID)
|
||||
{
|
||||
documentID.clear();
|
||||
@ -1418,6 +1686,8 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".fodp";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP:
|
||||
return L".otp";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG:
|
||||
return L".odg";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
|
||||
return L".xlsx";
|
||||
@ -1449,6 +1719,8 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".djvu";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS:
|
||||
return L".xps";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD:
|
||||
return L".ofd";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_SVG:
|
||||
return L".svg";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLR:
|
||||
@ -1490,12 +1762,15 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_WORD:
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET:
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION:
|
||||
case AVS_OFFICESTUDIO_FILE_CANVAS_DRAW:
|
||||
return L".bin";
|
||||
case AVS_OFFICESTUDIO_FILE_OTHER_OLD_DOCUMENT:
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY:
|
||||
return L".doct";
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY:
|
||||
return L".xlst";
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY:
|
||||
return L".vsdt";
|
||||
case AVS_OFFICESTUDIO_FILE_OTHER_OLD_PRESENTATION:
|
||||
case AVS_OFFICESTUDIO_FILE_OTHER_OLD_DRAWING:
|
||||
case AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY:
|
||||
@ -1584,6 +1859,8 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP_FLAT;
|
||||
if (L".otp" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP;
|
||||
if (L".odg" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG;
|
||||
|
||||
if (L".xlsx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
@ -1623,6 +1900,8 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU;
|
||||
if (L".xps" == ext || L".oxps" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS;
|
||||
if (L"ofd" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD;
|
||||
|
||||
if (L".jpg" == ext || L".jpeg" == ext || L".jpe" == ext || L".jfif" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_IMAGE_JPG;
|
||||
@ -1657,6 +1936,8 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY;
|
||||
if (L".pptt" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY;
|
||||
if (L".vsdt" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY;
|
||||
|
||||
if (L".vsdx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DRAW_VSDX;
|
||||
@ -1759,3 +2040,26 @@ bool COfficeFileFormatChecker::isXpsFile(const std::wstring &fileName)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOFDFile(const std::wstring& fileName)
|
||||
{
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
|
||||
ULONG nBufferSize = 0;
|
||||
BYTE *pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"OFD.xml", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
if (19 <= nBufferSize && NULL != strstr((char *)pBuffer, "ofd:OFD"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD;
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -103,6 +103,7 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRMenu AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0007
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRCanvas AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0008
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDFA AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0009
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x000a
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_IMAGE 0x0400
|
||||
#define AVS_OFFICESTUDIO_FILE_IMAGE_JPG AVS_OFFICESTUDIO_FILE_IMAGE + 0x0001
|
||||
@ -138,12 +139,14 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0001
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_XLSY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0002
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_PPTY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0003
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_VSDY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0004
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS 0x2000
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_WORD AVS_OFFICESTUDIO_FILE_CANVAS + 0x0001
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET AVS_OFFICESTUDIO_FILE_CANVAS + 0x0002
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION AVS_OFFICESTUDIO_FILE_CANVAS + 0x0003
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_PDF AVS_OFFICESTUDIO_FILE_CANVAS + 0x0004
|
||||
#define AVS_OFFICESTUDIO_FILE_CANVAS_DRAW AVS_OFFICESTUDIO_FILE_CANVAS + 0x0005
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW 0x4000
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSDX AVS_OFFICESTUDIO_FILE_DRAW + 0x0001
|
||||
@ -151,4 +154,4 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTX AVS_OFFICESTUDIO_FILE_DRAW + 0x0003
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSDM AVS_OFFICESTUDIO_FILE_DRAW + 0x0004
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSSM AVS_OFFICESTUDIO_FILE_DRAW + 0x0005
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTM AVS_OFFICESTUDIO_FILE_DRAW + 0x0006
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTM AVS_OFFICESTUDIO_FILE_DRAW + 0x0006
|
||||
@ -109,6 +109,31 @@ win32:!contains(QMAKE_TARGET.arch, x86_64): {
|
||||
CONFIG += core_win_32
|
||||
}
|
||||
|
||||
linux-clang-libc++ {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang-libc++")
|
||||
}
|
||||
linux-clang-libc++-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang-libc++")
|
||||
}
|
||||
linux-clang {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang")
|
||||
}
|
||||
linux-clang-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang")
|
||||
}
|
||||
|
||||
linux-g++ {
|
||||
CONFIG += core_linux
|
||||
linux-g++:contains(QMAKE_HOST.arch, x86_64): {
|
||||
@ -196,6 +221,10 @@ core_mac {
|
||||
}
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
QMAKE_CFLAGS += -Wno-implicit-function-declaration
|
||||
}
|
||||
|
||||
# PREFIXES
|
||||
core_windows {
|
||||
CONFIG -= debug_and_release debug_and_release_target
|
||||
@ -416,6 +445,12 @@ message($$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX)
|
||||
# COMPILER
|
||||
CONFIG += c++11
|
||||
|
||||
#CONFIG += enable_cpp_17
|
||||
enable_cpp_17 {
|
||||
CONFIG += c++1z
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
}
|
||||
|
||||
!core_windows {
|
||||
QMAKE_CXXFLAGS += -Wno-register
|
||||
QMAKE_CFLAGS += -Wno-register
|
||||
@ -423,7 +458,11 @@ CONFIG += c++11
|
||||
|
||||
core_linux {
|
||||
core_static_link_libstd {
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
!core_linux_clang {
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
} else {
|
||||
# TODO: add libc++abi?
|
||||
}
|
||||
message(core_static_link_libstd)
|
||||
}
|
||||
plugin {
|
||||
|
||||
@ -207,9 +207,9 @@ namespace agg
|
||||
}
|
||||
|
||||
p[Order::A] = (value_type)((alpha + a) - ((alpha * a + base_mask) >> base_shift));
|
||||
p[Order::R] = (value_type)((alpha * cr + a * r - ((a * r * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
p[Order::G] = (value_type)((alpha * cg + a * g - ((a * g * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
p[Order::B] = (value_type)((alpha * cb + a * b - ((a * b * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
if (r != cr) p[Order::R] = (value_type)((alpha * cr + a * r - ((a * r * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
if (g != cg) p[Order::G] = (value_type)((alpha * cg + a * g - ((a * g * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
if (b != cb) p[Order::B] = (value_type)((alpha * cb + a * b - ((a * b * alpha + base_mask) >> base_shift)) / p[Order::A]);
|
||||
}
|
||||
|
||||
static AGG_INLINE void blend_pix_subpix(value_type* p,
|
||||
|
||||
@ -319,7 +319,14 @@ namespace NSStringUtils
|
||||
{
|
||||
WriteEncodeXmlString(sString.c_str(), (int)sString.length());
|
||||
}
|
||||
|
||||
void CStringBuilder::WriteEncodeXmlString(const std::string& sString)
|
||||
{
|
||||
WriteEncodeXmlString(std::wstring(sString.begin(), sString.end()));
|
||||
}
|
||||
void CStringBuilder::WriteUtf8EncodeXmlString(const std::string& sString)
|
||||
{
|
||||
WriteEncodeXmlString(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sString.c_str(), sString.size()));
|
||||
}
|
||||
void CStringBuilder::WriteEncodeXmlString(const wchar_t* pString, int nCount)
|
||||
{
|
||||
if (sizeof(wchar_t) == 2)
|
||||
|
||||
@ -110,6 +110,9 @@ namespace NSStringUtils
|
||||
void WriteEncodeXmlString(const std::wstring& sString);
|
||||
void WriteEncodeXmlString(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
void WriteEncodeXmlString(const std::string& sString);
|
||||
void WriteUtf8EncodeXmlString(const std::string& sString);
|
||||
|
||||
void WriteEncodeXmlStringHHHH(const std::wstring& sString);
|
||||
void WriteEncodeXmlStringHHHH(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
|
||||
@ -332,6 +332,7 @@
|
||||
* DBL_MAX Maximum floating point number (can be set to an arbitrary value)
|
||||
*/
|
||||
# include <float.h>
|
||||
# include <math.h>
|
||||
|
||||
# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
|
||||
defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
|
||||
|
||||
61
DesktopEditor/doctrenderer/addon/docbuilder_addon.h
Normal file
61
DesktopEditor/doctrenderer/addon/docbuilder_addon.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef DOC_BUILDER_ADDON_PRIVATE
|
||||
#define DOC_BUILDER_ADDON_PRIVATE
|
||||
|
||||
#include <string>
|
||||
#include "../docbuilder.h"
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
class CDocBuilderAddon
|
||||
{
|
||||
private:
|
||||
std::wstring m_sWorkDirectory;
|
||||
public:
|
||||
CDocBuilderAddon(const std::wstring& sWorkDir)
|
||||
{
|
||||
m_sWorkDirectory = sWorkDir;
|
||||
}
|
||||
public:
|
||||
std::wstring GetX2tSaveAddon(NSDoctRenderer::CDocBuilder* builder, const int& filetype)
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
int GetX2tPreSaveError(NSDoctRenderer::CDocBuilder* builder, const int& filetype)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOC_BUILDER_ADDON_PRIVATE
|
||||
@ -33,6 +33,7 @@
|
||||
#include "./../common_deploy.h"
|
||||
#include "../docbuilder.h"
|
||||
#include "../../common/File.h"
|
||||
#include "../../common/SystemUtils.h"
|
||||
|
||||
#ifdef LINUX
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
@ -78,6 +79,15 @@ void parse_args(NSDoctRenderer::CDocBuilder* builder, int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckLicense(const std::wstring& sSrc, const std::wstring& sDst)
|
||||
{
|
||||
if (sDst.empty())
|
||||
return false;
|
||||
NSFile::CFileBinary::Remove(sDst);
|
||||
NSFile::CFileBinary::Copy(sSrc, sDst);
|
||||
return NSFile::CFileBinary::Exists(sDst);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
int wmain(int argc, wchar_t *argv[])
|
||||
#else
|
||||
@ -89,6 +99,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
bool bIsHelp = false;
|
||||
bool bIsFonts = false;
|
||||
bool bIsLicense = false;
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
#ifdef WIN32
|
||||
@ -121,6 +132,33 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
bIsFonts = true;
|
||||
}
|
||||
else if (sParam == "-register")
|
||||
{
|
||||
bIsLicense = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bIsLicense)
|
||||
{
|
||||
std::wstring sLicensePathSrc = UTF8_TO_U(sParam);
|
||||
if (!NSFile::CFileBinary::Exists(sLicensePathSrc))
|
||||
return 1;
|
||||
|
||||
std::wstring sLicensePath = NSSystemUtils::GetEnvVariable(L"ONLYOFFICE_BUILDER_LICENSE");
|
||||
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||
return 0;
|
||||
|
||||
sLicensePath = NSFile::GetProcessDirectory() + L"/license.xml";
|
||||
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||
return 0;
|
||||
|
||||
sLicensePath = NSSystemUtils::GetAppDataDir() + L"/docbuilder/license.xml";
|
||||
if (CheckLicense(sLicensePathSrc, sLicensePath))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsFonts)
|
||||
|
||||
@ -191,7 +191,7 @@ namespace NSDoctRenderer
|
||||
m_strSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
if (!m_strSdkPath.empty())
|
||||
{
|
||||
if (!NSDirectory::Exists(m_strSdkPath))
|
||||
if (0 == m_strSdkPath.find(L"./") || !NSDirectory::Exists(m_strSdkPath))
|
||||
m_strSdkPath = sConfigDir + m_strSdkPath;
|
||||
}
|
||||
|
||||
|
||||
@ -47,14 +47,6 @@ namespace NSDoctRenderer
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
}
|
||||
|
||||
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
|
||||
return m_pInternal->OpenFile(path, params);
|
||||
}
|
||||
int CDocBuilder::SaveFile(const int& type, const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
return m_pInternal->SaveFile(type, path, params);
|
||||
@ -65,7 +57,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
bool CDocBuilder::ExecuteCommand(const wchar_t* command, CDocBuilderValue* retValue)
|
||||
{
|
||||
return m_pInternal->ExecuteCommand(command, retValue);
|
||||
return m_pInternal->ExecuteCommand(command, retValue, false, false);
|
||||
}
|
||||
|
||||
CDocBuilderContext CDocBuilder::GetContext(bool enterContext)
|
||||
|
||||
@ -475,6 +475,13 @@ namespace NSDoctRenderer
|
||||
*/
|
||||
void SetPropertyW(const wchar_t* param, const wchar_t* value);
|
||||
|
||||
/**
|
||||
* GetProperty method.
|
||||
* @param param The parameter name in the Unicode format, the value is always --argument.
|
||||
* @return int value for property
|
||||
*/
|
||||
int GetPropertyInt(const wchar_t* param);
|
||||
|
||||
/**
|
||||
* Writes data to the log file. It is used for logs in JS code.
|
||||
* @param path The path to the file where all the logs will be written.
|
||||
@ -526,6 +533,7 @@ namespace NSDoctRenderer
|
||||
CDocBuilder_Private* m_pInternal;
|
||||
|
||||
friend class CBuilderDocumentEmbed;
|
||||
friend class CBuilderEmbed;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -16,18 +16,18 @@ static std::wstring wstringFromJavaString(JNIEnv* env, jstring jstr)
|
||||
return wstr;
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilder_c_1Create(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilder());
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jclass cls, jlong self, jstring path, jstring params)
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jclass cls, jlong self, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
@ -35,34 +35,34 @@ jint Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jclass cls, jlong self
|
||||
return (jint)pSelf->OpenFile(strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByType(JNIEnv* env, jclass cls, jlong self, jint type)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1CreateFileByType(JNIEnv* env, jclass cls, jlong self, jint type)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return (jboolean)pSelf->CreateFile((int)type);
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1CreateFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(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)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetTmpFolder(JNIEnv* env, jclass cls, jlong self, jstring folder)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(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)
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByType(JNIEnv* env, jclass cls, jlong self, jint type, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(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)
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(JNIEnv* env, jclass cls, jlong self, jint type, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
@ -70,7 +70,7 @@ jint Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(JNIEnv* env, jclass
|
||||
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)
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strExtension = wstringFromJavaString(env, extension);
|
||||
@ -78,7 +78,7 @@ jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv* env, jclass cls,
|
||||
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)
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strExtension = wstringFromJavaString(env, extension);
|
||||
@ -87,20 +87,20 @@ jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams(JNIEnv* env, j
|
||||
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)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1CloseFile(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
pSelf->CloseFile();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommand(JNIEnv* env, jclass cls, jlong self, jstring command)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommand(JNIEnv* env, jclass cls, jlong self, jstring command)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(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)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue(JNIEnv* env, jclass cls, jlong self, jstring command, jlong retValue)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strCommand = wstringFromJavaString(env, command);
|
||||
@ -108,14 +108,14 @@ jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue(JNIEnv* env,
|
||||
return (jboolean)pSelf->ExecuteCommand(strCommand.c_str(), pRetValue);
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1Run(JNIEnv* env, jclass cls, jlong self, jstring path)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1Run(JNIEnv* env, jclass cls, jlong self, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(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)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, jclass cls, jlong self, jstring commands)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
const char* strUtfCommands = env->GetStringUTFChars(commands, nullptr);
|
||||
@ -124,7 +124,7 @@ jboolean Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, jclass cls, jlong s
|
||||
return result;
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring param, jstring value)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring param, jstring value)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
const char* strUtfParam = env->GetStringUTFChars(param, nullptr);
|
||||
@ -133,7 +133,7 @@ void Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, jclass cls, jlong s
|
||||
env->ReleaseStringUTFChars(param, strUtfParam);
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jclass cls, jlong self, jstring path, jstring data, jboolean append)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jclass cls, jlong self, jstring path, jstring data, jboolean append)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
@ -141,13 +141,13 @@ void Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jclass cls, jlong sel
|
||||
pSelf->WriteData(strPath.c_str(), strData.c_str(), (bool)append);
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return (jboolean)pSelf->IsSaveWithDoctrendererMode();
|
||||
}
|
||||
|
||||
jstring Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
char* strUtfVersion = pSelf->GetVersion();
|
||||
@ -156,30 +156,30 @@ jstring Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env, jclass cls, jlong
|
||||
return jstrVersion;
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilder_c_1GetContext(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContext(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(pSelf->GetContext()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilder_c_1GetContextWithEnterParam(JNIEnv* env, jclass cls, jlong self, jboolean enterContext)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContextWithEnterParam(JNIEnv* env, jclass cls, jlong self, jboolean enterContext)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(pSelf->GetContext((bool)enterContext)));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Initialize();
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1InitializeWithDirectory(JNIEnv* env, jclass cls, jstring directory)
|
||||
JNIEXPORT void JNICALL 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)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Dispose(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Dispose();
|
||||
}
|
||||
|
||||
@ -4,60 +4,60 @@
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1Create(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderContext* pOther = reinterpret_cast<CDocBuilderContext*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(*pOther));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderContext_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContext_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateUndefined()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateNull(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateNull(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateNull()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateObject(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateObject(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateObject()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateArray(JNIEnv* env, jclass cls, jlong self, jint length)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateArray(JNIEnv* env, jclass cls, jlong self, jint length)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateArray((int)length)));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1GetGlobal(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1GetGlobal(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->GetGlobal()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateScope(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateScope(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope(pSelf->CreateScope()));
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderContext_c_1IsError(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderContext_c_1IsError(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return (jboolean)pSelf->IsError();
|
||||
|
||||
@ -4,24 +4,24 @@
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContextScope_c_1Create(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContextScope_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderContextScope* pOther = reinterpret_cast<CDocBuilderContextScope*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope(*pOther));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderContextScope_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContextScope* pSelf = reinterpret_cast<CDocBuilderContextScope*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderContextScope_c_1Close(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Close(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContextScope* pSelf = reinterpret_cast<CDocBuilderContextScope*>(self);
|
||||
pSelf->Close();
|
||||
|
||||
@ -8,114 +8,114 @@
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Create(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderValue* pOther = reinterpret_cast<CDocBuilderValue*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(*pOther));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsEmpty(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsEmpty(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsEmpty();
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1Clear(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Clear(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
pSelf->Clear();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsNull(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsNull(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsNull();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsUndefined();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsBool(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsBool(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsBool();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsInt(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsInt(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsInt();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsDouble();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsString(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsString(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsString();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsFunction(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsFunction(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsFunction();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsObject(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsObject(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsObject();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsArray(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsArray(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsArray();
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilderValue_c_1GetLength(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1GetLength(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jint)pSelf->GetLength();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1ToBool(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1ToBool(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->ToBool();
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilderValue_c_1ToInt(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1ToInt(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jint)pSelf->ToInt();
|
||||
}
|
||||
|
||||
jdouble Java_docbuilder_CDocBuilderValue_c_1ToDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jdouble JNICALL Java_docbuilder_CDocBuilderValue_c_1ToDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jdouble)pSelf->ToDouble();
|
||||
}
|
||||
|
||||
jstring Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* env, jclass cls, jlong self)
|
||||
JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CString strValue = pSelf->ToString();
|
||||
@ -123,7 +123,7 @@ jstring Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* env, jclass cls, jl
|
||||
return env->NewStringUTF(strUtfData.c_str());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
@ -132,14 +132,14 @@ jlong Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv* env, jclass cls, j
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1GetByIndex(JNIEnv* env, jclass cls, jlong self, jint index)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetByIndex(JNIEnv* env, jclass cls, jlong self, jint index)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = new CDocBuilderValue(pSelf->Get((int)index));
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring name, jlong value)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring name, jlong value)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = reinterpret_cast<CDocBuilderValue*>(value);
|
||||
@ -149,29 +149,29 @@ void Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* env, jclass cls, jl
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1SetByIndex(JNIEnv* env, jclass cls, jlong self, jint index, jlong value)
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetByIndex(JNIEnv* env, jclass cls, jlong self, jint index, jlong value)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = reinterpret_cast<CDocBuilderValue*>(value);
|
||||
pSelf->Set((int)index, *pValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithBool(JNIEnv* env, jclass cls, jboolean value)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithBool(JNIEnv* env, jclass cls, jboolean value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((bool)value));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithInt(JNIEnv* env, jclass cls, jint value)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithInt(JNIEnv* env, jclass cls, jint value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((int)value));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble(JNIEnv* env, jclass cls, jdouble value)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble(JNIEnv* env, jclass cls, jdouble value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((double)value));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNIEnv* env, jclass cls, jstring str)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNIEnv* env, jclass cls, jstring str)
|
||||
{
|
||||
const char* strUtf = env->GetStringUTFChars(str, nullptr);
|
||||
CDocBuilderValue* pValue = new CDocBuilderValue(strUtf);
|
||||
@ -179,22 +179,22 @@ jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNIEnv* env, jclass c
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateUndefined(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateUndefined(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateUndefined()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateNull(JNIEnv* env, jclass cls)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateNull(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateNull()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateArray(JNIEnv* env, jclass cls, jint length)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateArray(JNIEnv* env, jclass cls, jint length)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateArray((int)length)));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
@ -203,7 +203,7 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -213,7 +213,7 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -224,7 +224,7 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3)
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -236,7 +236,7 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4)
|
||||
JNIEXPORT jlong JNICALL 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<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -249,7 +249,7 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(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)
|
||||
JNIEXPORT jlong JNICALL 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<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
@ -263,7 +263,7 @@ jlong Java_docbuilder_CDocBuilderValue_c_1Call5(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(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)
|
||||
JNIEXPORT jlong JNICALL 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<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
|
||||
@ -2,6 +2,7 @@ import ctypes
|
||||
import os
|
||||
import platform
|
||||
import atexit
|
||||
import subprocess
|
||||
|
||||
OBJECT_HANDLE = ctypes.c_void_p
|
||||
STRING_HANDLE = ctypes.c_void_p
|
||||
@ -382,6 +383,20 @@ class CDocBuilderValue:
|
||||
def __setitem__(self, key, value):
|
||||
self.Set(key, value)
|
||||
|
||||
def __getattr__(self, name):
|
||||
def method(*args):
|
||||
return self.Call(name, *args)
|
||||
return method
|
||||
|
||||
def __len__(self):
|
||||
return self.GetLength()
|
||||
|
||||
def __iter__(self):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not iterable")
|
||||
for i in range(self.GetLength()):
|
||||
yield self.Get(i)
|
||||
|
||||
@staticmethod
|
||||
def CreateUndefined():
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_CreateUndefined()))
|
||||
@ -422,6 +437,36 @@ class CDocBuilderValue:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call6(self._internal, ctypes.c_wchar_p(name), values[0]._internal, values[1]._internal, values[2]._internal, values[3]._internal, values[4]._internal, values[5]._internal)))
|
||||
else:
|
||||
raise TypeError("Call() expects at most 6 arguments")
|
||||
|
||||
def append(self, value):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
self.Set(length, value)
|
||||
return self
|
||||
|
||||
def extend(self, iterable):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
for i, value in enumerate(iterable, start=length):
|
||||
self.Set(i, value)
|
||||
return self
|
||||
|
||||
def insert(self, i, x):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
if i < 0:
|
||||
if abs(i) > length:
|
||||
raise IndexError("list index out of range")
|
||||
i = max(0, length + i)
|
||||
if i >= length:
|
||||
raise IndexError("list index out of range")
|
||||
for idx in range(length, i, -1):
|
||||
self.Set(idx, self.Get(idx - 1))
|
||||
self.Set(i, x)
|
||||
|
||||
|
||||
class CDocBuilder:
|
||||
_initialized = False
|
||||
@ -608,8 +653,17 @@ class FileTypes:
|
||||
PNG = _IMAGE_MASK + 0x0005
|
||||
BMP = _IMAGE_MASK + 0x0008
|
||||
|
||||
# NOTE: do not change builder_path manually!
|
||||
builder_path = os.path.dirname(os.path.realpath(__file__))
|
||||
_loadLibrary(builder_path)
|
||||
CDocBuilder.Initialize(builder_path)
|
||||
|
||||
def registerLibrary(license_path):
|
||||
docbuilder_bin = os.path.join(builder_path, "docbuilder")
|
||||
if ("windows" == platform.system().lower()):
|
||||
docbuilder_bin += ".exe"
|
||||
return subprocess.call([docbuilder_bin, "-register", license_path], stderr=subprocess.STDOUT, shell=True)
|
||||
command = docbuilder_bin + " -register \"" + license_path.replace('\"', '\\\"') + "\""
|
||||
return subprocess.call(command, stderr=subprocess.STDOUT, shell=True)
|
||||
|
||||
atexit.register(CDocBuilder.Dispose)
|
||||
|
||||
@ -13,16 +13,16 @@ scope = context.CreateScope()
|
||||
globalObj = context.GetGlobal()
|
||||
|
||||
api = globalObj['Api']
|
||||
document = api.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
document = api.GetDocument()
|
||||
paragraph1 = api.CreateParagraph()
|
||||
paragraph1.SetSpacingAfter(1000, False)
|
||||
paragraph1.AddText('Hello from Python!')
|
||||
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
paragraph2 = api.CreateParagraph()
|
||||
paragraph2.AddText('Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.Call('InsertContent', content)
|
||||
document.InsertContent(content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('path_to_docbuilder')
|
||||
import docbuilder
|
||||
|
||||
builder = docbuilder.CDocBuilder()
|
||||
|
||||
builder.CreateFile(docbuilder.FileTypes.Document.DOCX)
|
||||
|
||||
context = builder.GetContext()
|
||||
scope = context.CreateScope()
|
||||
|
||||
globalObj = context.GetGlobal()
|
||||
|
||||
api = globalObj['Api']
|
||||
document = api.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.Call('InsertContent', content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
builder.CloseFile()
|
||||
@ -82,7 +82,7 @@ CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
m_context->Dispose();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue)
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContextSrc)
|
||||
{
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
@ -92,14 +92,24 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
std::string commandA = U_TO_UTF8(command);
|
||||
//commandA = "Api." + commandA;
|
||||
|
||||
CJSContextScope scope(m_context);
|
||||
bool isEnterContext = isEnterContextSrc;
|
||||
if (!isEnterContext && !m_context->IsEntered())
|
||||
isEnterContext = true;
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Enter();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
LOGGER_SPEED_LAP("compile_command");
|
||||
|
||||
JSSmart<CJSValue> retNativeVal = m_context->runScript(commandA, try_catch);
|
||||
if(try_catch->Check())
|
||||
{
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (retValue)
|
||||
{
|
||||
@ -110,6 +120,9 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
|
||||
LOGGER_SPEED_LAP("run_command");
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -344,7 +357,17 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
return !bIsBreak;
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams)
|
||||
bool CV8RealTimeWorker::NewSimpleJSInstance()
|
||||
{
|
||||
return InitVariables();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::IsSimpleJSInstance()
|
||||
{
|
||||
return (-1 == m_nFileType);
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams, const bool& isEnterContext)
|
||||
{
|
||||
NSDoctRenderer::DoctRendererFormat::FormatFile _formatDst = NSDoctRenderer::DoctRendererFormat::DOCT;
|
||||
if (type & AVS_OFFICESTUDIO_FILE_PRESENTATION)
|
||||
@ -370,7 +393,9 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
}
|
||||
}
|
||||
|
||||
CJSContextScope scope(m_context);
|
||||
if (isEnterContext)
|
||||
m_context->Enter();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
NSNativeControl::CNativeControl* pNative = NULL;
|
||||
@ -399,7 +424,7 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
bIsSilentMode = true;
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);");
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);", NULL, isEnterContext);
|
||||
|
||||
std::wstring strError;
|
||||
bool bIsError = Doct_renderer_SaveFile_ForBuilder(_formatDst,
|
||||
@ -411,7 +436,10 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
sJsonParams);
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);");
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);", NULL, isEnterContext);
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
|
||||
return bIsError;
|
||||
}
|
||||
@ -1239,8 +1267,29 @@ namespace NSDoctRenderer
|
||||
nCount = nIndex;
|
||||
}
|
||||
|
||||
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
m_pInternal->m_bIsOpenedFromSimpleJS = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
|
||||
return m_pInternal->OpenFile(path, params);
|
||||
}
|
||||
|
||||
bool CDocBuilder::CreateFile(const int& type)
|
||||
{
|
||||
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
m_pInternal->m_bIsOpenedFromSimpleJS = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
@ -1399,7 +1448,7 @@ namespace NSDoctRenderer
|
||||
if (!sJsCommands.empty())
|
||||
{
|
||||
std::wstring sUnicodeCommand = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sJsCommands.c_str(), (LONG)sJsCommands.length());
|
||||
bIsNoError = this->ExecuteCommand(sUnicodeCommand.c_str());
|
||||
bIsNoError = this->m_pInternal->ExecuteCommand(sUnicodeCommand.c_str(), NULL, bIsBuilderJSCloseFile);
|
||||
sJsCommands = "";
|
||||
if (!bIsNoError)
|
||||
return false;
|
||||
@ -1421,6 +1470,10 @@ namespace NSDoctRenderer
|
||||
if (0 == _builder_params[nCheckParam].find(L"jsValue(") && _builder_params[nCheckParam].length() > 9)
|
||||
{
|
||||
std::wstring sParam = _builder_params[nCheckParam].substr(8, _builder_params[nCheckParam].length() - 9);
|
||||
|
||||
if (NULL == m_pInternal->m_pWorker)
|
||||
m_pInternal->CheckWorker();
|
||||
|
||||
_builder_params[nCheckParam] = m_pInternal->m_pWorker->GetJSVariable(sParam);
|
||||
}
|
||||
}
|
||||
@ -1486,7 +1539,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
// Такого быть не должно!!! Так как результат никуда не сохранится. пустое действие.
|
||||
std::wstring sUnicodeCommand = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sJsCommands.c_str(), (LONG)sJsCommands.length());
|
||||
bool bIsNoError = this->ExecuteCommand(sUnicodeCommand.c_str());
|
||||
bool bIsNoError = this->m_pInternal->ExecuteCommand(sUnicodeCommand.c_str(), NULL, true);
|
||||
sJsCommands = "";
|
||||
if (!bIsNoError)
|
||||
return false;
|
||||
@ -1547,6 +1600,15 @@ namespace NSDoctRenderer
|
||||
return this->SetProperty(sA.c_str(), value);
|
||||
}
|
||||
|
||||
int CDocBuilder::GetPropertyInt(const wchar_t* param)
|
||||
{
|
||||
std::wstring sParam = std::wstring(param);
|
||||
std::string sParamA = U_TO_UTF8(sParam);
|
||||
if ("--save-use-only-names" == sParamA)
|
||||
return m_pInternal->m_bIsServerSafeVersion ? 1 : 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CDocBuilder::Initialize(const wchar_t* directory)
|
||||
{
|
||||
std::wstring sDirectory = L"";
|
||||
|
||||
@ -63,6 +63,8 @@
|
||||
|
||||
#include "../common/ProcessEnv.h"
|
||||
|
||||
#include "docbuilder_addon.h"
|
||||
|
||||
#ifdef CreateFile
|
||||
#undef CreateFile
|
||||
#endif
|
||||
@ -435,14 +437,17 @@ public:
|
||||
|
||||
static void _LOGGING_ERROR_(const std::wstring& strType, const std::wstring& strError);
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue = NULL);
|
||||
bool ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue = NULL, const bool& isEnterContext = true);
|
||||
|
||||
std::string GetGlobalVariable();
|
||||
std::wstring GetJSVariable(std::wstring sParam);
|
||||
|
||||
bool OpenFile(const std::wstring& sBasePath, const std::wstring& path, const NSDoctRenderer::DoctRendererEditorType& editorType, NSDoctRenderer::CDoctRendererConfig* config, CV8Params* pParams = NULL);
|
||||
bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L"");
|
||||
bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L"", const bool& isEnterContext = true);
|
||||
bool InitVariables();
|
||||
|
||||
bool NewSimpleJSInstance();
|
||||
bool IsSimpleJSInstance();
|
||||
};
|
||||
|
||||
namespace NSDoctRenderer
|
||||
@ -476,11 +481,13 @@ namespace NSDoctRenderer
|
||||
|
||||
NSDoctRenderer::CDocBuilder* m_pParent;
|
||||
|
||||
bool m_bIsOpenedFromSimpleJS;
|
||||
|
||||
static std::wstring m_sExternalDirectory;
|
||||
public:
|
||||
CDocBuilder_Private() : CDoctRendererConfig(), m_sTmpFolder(NSFile::CFileBinary::GetTempPath()), m_nFileType(-1),
|
||||
m_pWorker(NULL), m_pAdditionalData(NULL), m_bIsInit(false), m_bIsServerSafeVersion(false),
|
||||
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_sCommandsBeforeContextCreated(L"")
|
||||
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_sCommandsBeforeContextCreated(L""), m_bIsOpenedFromSimpleJS(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -639,6 +646,13 @@ namespace NSDoctRenderer
|
||||
{
|
||||
NSDirectory::CreateDirectory(m_sFileDir + L"/media");
|
||||
NSDirectory::CreateDirectory(m_sFileDir + L"/changes");
|
||||
|
||||
if (m_pWorker && m_pWorker->IsSimpleJSInstance() && !m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
@ -929,7 +943,14 @@ namespace NSDoctRenderer
|
||||
LOGGER_SPEED_LAP("open_convert");
|
||||
|
||||
if (0 == nReturnCode)
|
||||
{
|
||||
if (m_pWorker && m_pWorker->IsSimpleJSInstance() && !m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
NSDirectory::DeleteDirectory(m_sFileDir);
|
||||
m_sFileDir = L"";
|
||||
@ -976,10 +997,16 @@ namespace NSDoctRenderer
|
||||
return _path;
|
||||
}
|
||||
|
||||
int SaveFile(const int& type, const std::wstring& path, const wchar_t* params = NULL)
|
||||
int SaveFile(const int& type, const std::wstring& path, const wchar_t* params = NULL, const bool& isEnterContext = true)
|
||||
{
|
||||
Init();
|
||||
|
||||
CDocBuilderAddon oSaveAddon(m_sX2tPath);
|
||||
|
||||
int nPreSaveError = oSaveAddon.GetX2tPreSaveError(m_pParent, m_nFileType);
|
||||
if (0 != nPreSaveError)
|
||||
return nPreSaveError;
|
||||
|
||||
if (-1 == m_nFileType)
|
||||
{
|
||||
CV8RealTimeWorker::_LOGGING_ERROR_(L"error (save)", L"file not opened!");
|
||||
@ -1018,7 +1045,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
|
||||
this->m_pWorker->SaveFileWithChanges(type, m_sFileDir + L"/Editor2.bin", sJsonParams);
|
||||
this->m_pWorker->SaveFileWithChanges(type, m_sFileDir + L"/Editor2.bin", sJsonParams, isEnterContext);
|
||||
sFileBin = L"/Editor2.bin";
|
||||
}
|
||||
|
||||
@ -1063,6 +1090,8 @@ namespace NSDoctRenderer
|
||||
if (!sOptions.empty())
|
||||
oBuilder.WriteString(UTF8_TO_U(sOptions));
|
||||
|
||||
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon(m_pParent, m_nFileType));
|
||||
|
||||
oBuilder.WriteString(L"</TaskQueueDataConvert>");
|
||||
|
||||
std::wstring sXmlConvert = oBuilder.GetData();
|
||||
@ -1216,17 +1245,21 @@ namespace NSDoctRenderer
|
||||
if (NULL == m_pWorker)
|
||||
{
|
||||
NSDoctRenderer::DoctRendererEditorType editorType = GetEditorType();
|
||||
if (NSDoctRenderer::DoctRendererEditorType::INVALID == editorType)
|
||||
return false;
|
||||
|
||||
m_pWorker = new CV8RealTimeWorker(m_pParent, editorType, this);
|
||||
m_pWorker->m_sUtf8ArgumentJSON = m_oParams.m_sArgumentJSON;
|
||||
m_pWorker->m_sGlobalVariable = m_sGlobalVariable;
|
||||
m_pWorker->m_sJSCodeStart = U_TO_UTF8(m_sCommandsBeforeContextCreated);
|
||||
m_sCommandsBeforeContextCreated = L"";
|
||||
|
||||
m_pWorker->m_nFileType = m_nFileType;
|
||||
|
||||
if (-1 != m_nFileType)
|
||||
m_sCommandsBeforeContextCreated = L"";
|
||||
else
|
||||
{
|
||||
m_pWorker->NewSimpleJSInstance();
|
||||
return true;
|
||||
}
|
||||
|
||||
CV8Params oParams;
|
||||
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
|
||||
oParams.DocumentDirectory = m_sFileDir;
|
||||
@ -1242,12 +1275,12 @@ namespace NSDoctRenderer
|
||||
return SaveFile(nType, path, params);
|
||||
}
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL)
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL, const bool& forceExecute = false, const bool& isEnterContext = true)
|
||||
{
|
||||
if (command.length() < 7 && !retValue) // minimum command (!!!)
|
||||
return true;
|
||||
|
||||
if (m_nFileType == -1)
|
||||
if (m_nFileType == -1 && !forceExecute)
|
||||
{
|
||||
m_sCommandsBeforeContextCreated += command;
|
||||
return true;
|
||||
@ -1256,7 +1289,20 @@ namespace NSDoctRenderer
|
||||
Init();
|
||||
|
||||
if (CheckWorker())
|
||||
return m_pWorker->ExecuteCommand(command, retValue);
|
||||
{
|
||||
bool bIsOpenedFromSimpleJSOld = m_bIsOpenedFromSimpleJS;
|
||||
bool bResult = m_pWorker->ExecuteCommand(command, retValue, isEnterContext);
|
||||
if (!bResult && !bIsOpenedFromSimpleJSOld && m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
return m_pWorker->ExecuteCommand(command, retValue, isEnterContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bResult;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
130
DesktopEditor/doctrenderer/doctrenderer.pri
Normal file
130
DesktopEditor/doctrenderer/doctrenderer.pri
Normal file
@ -0,0 +1,130 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
VERSION = 1.0.0.3
|
||||
TARGET = doctrenderer
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
PWD_CUR = $$PWD
|
||||
include($$PWD_CUR/../../Common/base.pri)
|
||||
|
||||
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
DEFINES += JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
|
||||
|
||||
#CONFIG += build_xp
|
||||
#CONFIG += v8_version_60
|
||||
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/config.h \
|
||||
$$PWD_CUR/editors.h \
|
||||
$$PWD_CUR/doctrenderer.h \
|
||||
$$PWD_CUR/docbuilder.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/editors.cpp \
|
||||
$$PWD_CUR/nativecontrol.cpp \
|
||||
$$PWD_CUR/doctrenderer.cpp \
|
||||
$$PWD_CUR/docbuilder.cpp \
|
||||
$$PWD_CUR/docbuilder_p.cpp \
|
||||
$$PWD_CUR/graphics.cpp \
|
||||
$$PWD_CUR/hash.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/../../Common/OfficeFileFormatChecker2.cpp \
|
||||
$$PWD_CUR/../../Common/3dParty/pole/pole.cpp \
|
||||
$$PWD_CUR/../../OOXML/Base/unicode_util.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/docbuilder_p.h \
|
||||
$$PWD_CUR/nativecontrol.h \
|
||||
$$PWD_CUR/graphics.h \
|
||||
$$PWD_CUR/hash.h \
|
||||
$$PWD_CUR/server.h
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/embed/PointerEmbed.h \
|
||||
$$PWD_CUR/embed/ZipEmbed.h \
|
||||
$$PWD_CUR/embed/GraphicsEmbed.h \
|
||||
$$PWD_CUR/embed/MemoryStreamEmbed.h \
|
||||
$$PWD_CUR/embed/NativeControlEmbed.h \
|
||||
$$PWD_CUR/embed/NativeBuilderEmbed.h \
|
||||
$$PWD_CUR/embed/NativeBuilderDocumentEmbed.h \
|
||||
$$PWD_CUR/embed/TextMeasurerEmbed.h \
|
||||
$$PWD_CUR/embed/HashEmbed.h \
|
||||
$$PWD_CUR/embed/Default.h \
|
||||
$$PWD_CUR/js_internal/js_base.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/embed/PointerEmbed.cpp \
|
||||
$$PWD_CUR/embed/ZipEmbed.cpp \
|
||||
$$PWD_CUR/embed/GraphicsEmbed.cpp \
|
||||
$$PWD_CUR/embed/MemoryStreamEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeControlEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeBuilderEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeBuilderDocumentEmbed.cpp \
|
||||
$$PWD_CUR/embed/TextMeasurerEmbed.cpp \
|
||||
$$PWD_CUR/embed/HashEmbed.cpp \
|
||||
$$PWD_CUR/embed/Default.cpp
|
||||
|
||||
# Serialize objects to JS
|
||||
HEADERS += \
|
||||
$$PWD_CUR/json/json.h \
|
||||
$$PWD_CUR/json/json_p.h \
|
||||
$$PWD_CUR/json/json_values.h \
|
||||
$$PWD_CUR/json/serialization.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/json/json.cpp \
|
||||
$$PWD_CUR/json/json_values.cpp
|
||||
|
||||
include($$PWD_CUR/js_internal/js_base.pri)
|
||||
|
||||
!use_javascript_core {
|
||||
build_xp:DESTDIR=$$DESTDIR/xp
|
||||
}
|
||||
|
||||
use_javascript_core {
|
||||
OBJECTIVE_SOURCES += $$PWD_CUR/../common/Mac/NSString+StringUtils.mm
|
||||
}
|
||||
|
||||
# files for embedded classes
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/GraphicsEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/HashEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/MemoryStreamEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeBuilderEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeBuilderDocumentEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeControlEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/PointerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/TextMeasurerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/ZipEmbed.h)
|
||||
|
||||
include($$PWD_CUR/../graphics/pro/textshaper.pri)
|
||||
include($$PWD_CUR/../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
|
||||
|
||||
CONFIG += drawingfile_support
|
||||
drawingfile_support {
|
||||
DEFINES += WASM_SERIALIZER_USE_ALLOCATOR
|
||||
ADD_DEPENDENCY(PdfFile, XpsFile, DjVuFile, DocxRenderer)
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/drawingfile.h \
|
||||
$$PWD_CUR/embed/DrawingFileEmbed.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/../graphics/pro/js/wasm/src/HTMLRendererText.cpp \
|
||||
$$PWD_CUR/embed/DrawingFileEmbed.cpp
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/DrawingFileEmbed.h)
|
||||
}
|
||||
@ -1,128 +1,3 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
INCLUDEPATH += $$PWD/addon
|
||||
|
||||
VERSION = 1.0.0.3
|
||||
TARGET = doctrenderer
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include(../../Common/base.pri)
|
||||
|
||||
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
DEFINES += JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
|
||||
|
||||
#CONFIG += build_xp
|
||||
#CONFIG += v8_version_60
|
||||
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
|
||||
HEADERS += \
|
||||
config.h \
|
||||
editors.h \
|
||||
doctrenderer.h \
|
||||
docbuilder.h
|
||||
|
||||
SOURCES += \
|
||||
editors.cpp \
|
||||
nativecontrol.cpp \
|
||||
doctrenderer.cpp \
|
||||
docbuilder.cpp \
|
||||
docbuilder_p.cpp \
|
||||
graphics.cpp \
|
||||
hash.cpp
|
||||
|
||||
SOURCES += \
|
||||
../../Common/OfficeFileFormatChecker2.cpp \
|
||||
../../Common/3dParty/pole/pole.cpp \
|
||||
../../OOXML/Base/unicode_util.cpp
|
||||
|
||||
HEADERS += \
|
||||
docbuilder_p.h \
|
||||
nativecontrol.h \
|
||||
graphics.h \
|
||||
hash.h \
|
||||
server.h
|
||||
|
||||
HEADERS += \
|
||||
embed/PointerEmbed.h \
|
||||
embed/ZipEmbed.h \
|
||||
embed/GraphicsEmbed.h \
|
||||
embed/MemoryStreamEmbed.h \
|
||||
embed/NativeControlEmbed.h \
|
||||
embed/NativeBuilderEmbed.h \
|
||||
embed/NativeBuilderDocumentEmbed.h \
|
||||
embed/TextMeasurerEmbed.h \
|
||||
embed/HashEmbed.h \
|
||||
embed/Default.h \
|
||||
js_internal/js_base.h
|
||||
|
||||
SOURCES += \
|
||||
embed/PointerEmbed.cpp \
|
||||
embed/ZipEmbed.cpp \
|
||||
embed/GraphicsEmbed.cpp \
|
||||
embed/MemoryStreamEmbed.cpp \
|
||||
embed/NativeControlEmbed.cpp \
|
||||
embed/NativeBuilderEmbed.cpp \
|
||||
embed/NativeBuilderDocumentEmbed.cpp \
|
||||
embed/TextMeasurerEmbed.cpp \
|
||||
embed/HashEmbed.cpp \
|
||||
embed/Default.cpp
|
||||
|
||||
# Serialize objects to JS
|
||||
HEADERS += \
|
||||
json/json.h \
|
||||
json/json_p.h \
|
||||
json/json_values.h \
|
||||
json/serialization.h
|
||||
|
||||
SOURCES += \
|
||||
json/json.cpp \
|
||||
json/json_values.cpp
|
||||
|
||||
include($$PWD/js_internal/js_base.pri)
|
||||
|
||||
!use_javascript_core {
|
||||
build_xp:DESTDIR=$$DESTDIR/xp
|
||||
}
|
||||
|
||||
use_javascript_core {
|
||||
OBJECTIVE_SOURCES += ../common/Mac/NSString+StringUtils.mm
|
||||
}
|
||||
|
||||
# files for embedded classes
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/GraphicsEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/HashEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/MemoryStreamEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeBuilderEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeBuilderDocumentEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeControlEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/PointerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/TextMeasurerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/ZipEmbed.h)
|
||||
|
||||
include(../graphics/pro/textshaper.pri)
|
||||
include(../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
|
||||
|
||||
CONFIG += drawingfile_support
|
||||
drawingfile_support {
|
||||
DEFINES += WASM_SERIALIZER_USE_ALLOCATOR
|
||||
ADD_DEPENDENCY(PdfFile, XpsFile, DjVuFile, DocxRenderer)
|
||||
|
||||
HEADERS += \
|
||||
drawingfile.h \
|
||||
embed/DrawingFileEmbed.h
|
||||
|
||||
SOURCES += \
|
||||
../graphics/pro/js/wasm/src/HTMLRendererText.cpp \
|
||||
embed/DrawingFileEmbed.cpp
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/DrawingFileEmbed.h)
|
||||
}
|
||||
include(doctrenderer.pri)
|
||||
|
||||
@ -171,7 +171,6 @@ public:
|
||||
|
||||
return m_pFile ? true : false;
|
||||
}
|
||||
|
||||
bool OpenFile(BYTE* data, LONG size, const std::wstring& sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
@ -284,6 +283,24 @@ public:
|
||||
return NULL;
|
||||
return m_pFile->ConvertToPixels(nPageIndex, nRasterW, nRasterH, true, m_pFontManager, nBackgroundColor, (nBackgroundColor == 0xFFFFFF) ? false : true);
|
||||
}
|
||||
BYTE* SplitPages(int* arrPageIndex, int nLength, BYTE* data, LONG size)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->SplitPages(arrPageIndex, nLength, data, size);
|
||||
return NULL;
|
||||
}
|
||||
bool MergePages(BYTE* data, LONG size, int nMaxID, const std::string& sPrefixForm)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->MergePages(data, size, nMaxID, sPrefixForm);
|
||||
return false;
|
||||
}
|
||||
bool UnmergePages()
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->UnmergePages();
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE* GetGlyphs(int nPageIndex)
|
||||
{
|
||||
|
||||
@ -160,16 +160,35 @@ void CGraphicsEmbed::SetAppImage(CGraphicsAppImage* appImage)
|
||||
|
||||
JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm)
|
||||
{
|
||||
NSNativeControl::CNativeControl* pControl = NULL;
|
||||
if (!Native->isNull())
|
||||
{
|
||||
pControl = (NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject();
|
||||
JSSmart<CJSObject> pNativeObject = Native->toObject();
|
||||
CJSEmbedObject* pNativeEmbedObject = pNativeObject->getNative();
|
||||
|
||||
if (m_pInternal->m_pAppImage)
|
||||
if (m_pInternal->m_pAppImage && pNativeEmbedObject)
|
||||
{
|
||||
delete m_pInternal->m_pAppImage;
|
||||
m_pInternal->m_pAppImage = new CGraphicsAppImage();
|
||||
m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory);
|
||||
m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory);
|
||||
m_pInternal->m_pAppImage = NULL;
|
||||
}
|
||||
|
||||
if (NULL == m_pInternal->m_pAppImage)
|
||||
m_pInternal->m_pAppImage = new CGraphicsAppImage();
|
||||
|
||||
if (pNativeEmbedObject)
|
||||
{
|
||||
NSNativeControl::CNativeControl* pControl = (NSNativeControl::CNativeControl*)pNativeEmbedObject->getObject();
|
||||
m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory);
|
||||
m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory);
|
||||
}
|
||||
else
|
||||
{
|
||||
JSSmart<CJSValue> checkResources = pNativeObject->get("isResourcesObject");
|
||||
if (checkResources->isBool() && true == checkResources->toBool())
|
||||
{
|
||||
m_pInternal->m_pAppImage->SetFontsDirectory(pNativeObject->get("fontsDirectory")->toStringW());
|
||||
m_pInternal->m_pAppImage->SetImagesDirectory(pNativeObject->get("imagesDirectory")->toStringW());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pInternal->init(width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
|
||||
|
||||
@ -8,7 +8,22 @@ JSSmart<CJSValue> CBuilderEmbed::OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSVa
|
||||
{
|
||||
std::wstring Path = sPath->toStringW();
|
||||
std::wstring Params = sParams->toStringW();
|
||||
|
||||
// Since we now use snapshots, and we can't always determine which editor is needed
|
||||
// (since the code may be BEFORE opening the file). And if the opening came from
|
||||
// builderJS.OpenFile - in this case we skip reopening.
|
||||
NSDoctRenderer::CDocBuilder_Private* pPrivate = GetPrivate();
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
pPrivate->m_bIsOpenedFromSimpleJS = true;
|
||||
|
||||
int ret = m_pBuilder->OpenFile(Path.c_str(), Params.c_str());
|
||||
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
{
|
||||
JSSmart<CJSContext> current = CJSContext::GetCurrent();
|
||||
current->runScript("throw 0;");
|
||||
}
|
||||
|
||||
return CJSContext::createInt(ret);
|
||||
}
|
||||
|
||||
@ -20,7 +35,21 @@ JSSmart<CJSValue> CBuilderEmbed::CreateFile(JSSmart<CJSValue> type)
|
||||
else
|
||||
nFormat = type->toInt32();
|
||||
|
||||
// Since we now use snapshots, and we can't always determine which editor is needed
|
||||
// (since the code may be BEFORE opening the file). And if the opening came from
|
||||
// builderJS.OpenFile - in this case we skip reopening.
|
||||
NSDoctRenderer::CDocBuilder_Private* pPrivate = GetPrivate();
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
pPrivate->m_bIsOpenedFromSimpleJS = true;
|
||||
|
||||
bool ret = m_pBuilder->CreateFile(nFormat);
|
||||
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
{
|
||||
JSSmart<CJSContext> current = CJSContext::GetCurrent();
|
||||
current->runScript("throw 0;");
|
||||
}
|
||||
|
||||
return CJSContext::createBool(ret);
|
||||
}
|
||||
|
||||
@ -41,7 +70,7 @@ JSSmart<CJSValue> CBuilderEmbed::SaveFile(JSSmart<CJSValue> type, JSSmart<CJSVal
|
||||
|
||||
std::wstring sPath = path->toStringW();
|
||||
std::wstring sParams = params->toStringW();
|
||||
int ret = m_pBuilder->SaveFile(nFormat, sPath.c_str(), sParams.empty() ? NULL : sParams.c_str());
|
||||
int ret = GetPrivate()->SaveFile(nFormat, sPath.c_str(), sParams.empty() ? NULL : sParams.c_str(), false);
|
||||
return CJSContext::createInt(ret);
|
||||
}
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ public:
|
||||
~CBuilderEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
NSDoctRenderer::CDocBuilder_Private* GetPrivate() { return m_pBuilder->GetPrivate(); }
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSValue> sParams);
|
||||
|
||||
@ -483,6 +483,12 @@ namespace NSJSBase
|
||||
*/
|
||||
void Exit();
|
||||
|
||||
/**
|
||||
* Сheck if context is current.
|
||||
* This method is not safe.
|
||||
*/
|
||||
bool IsEntered();
|
||||
|
||||
/**
|
||||
* Embeds specified class in JS contexts.
|
||||
* @tparam T Embedded class name.
|
||||
|
||||
@ -374,7 +374,7 @@ namespace NSJSBase
|
||||
|
||||
JSSmart<CJSContext> CJSContext::GetCurrent()
|
||||
{
|
||||
CJSContext* ret = new CJSContext();
|
||||
CJSContext* ret = new CJSContext(false);
|
||||
ret->m_internal->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
|
||||
return ret;
|
||||
}
|
||||
@ -439,6 +439,11 @@ namespace NSJSBase
|
||||
{
|
||||
}
|
||||
|
||||
bool CJSContext::IsEntered()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
class CJSLocalScopePrivate
|
||||
{
|
||||
public:
|
||||
|
||||
@ -255,6 +255,8 @@ namespace NSJSBase
|
||||
m_internal->m_context = v8::Local<v8::Context>::New(isolate, m_internal->m_contextPersistent);
|
||||
if (!m_internal->m_context.IsEmpty())
|
||||
m_internal->m_context->Enter();
|
||||
|
||||
m_internal->m_entered = true;
|
||||
}
|
||||
|
||||
void CJSContext::Exit()
|
||||
@ -271,6 +273,13 @@ namespace NSJSBase
|
||||
else
|
||||
m_internal->m_context = m_internal->m_isolate->GetCurrentContext();
|
||||
m_internal->m_isolate->Exit();
|
||||
|
||||
m_internal->m_entered = false;
|
||||
}
|
||||
|
||||
bool CJSContext::IsEntered()
|
||||
{
|
||||
return m_internal->m_entered;
|
||||
}
|
||||
|
||||
CJSValue* CJSContext::createUndefined()
|
||||
|
||||
@ -857,12 +857,14 @@ namespace NSJSBase
|
||||
v8::Local<v8::Context> m_context;
|
||||
|
||||
v8::StartupData m_startup_data;
|
||||
bool m_entered;
|
||||
|
||||
public:
|
||||
CJSContextPrivate() : m_isolate(NULL)
|
||||
{
|
||||
m_startup_data.data = NULL;
|
||||
m_startup_data.raw_size = 0;
|
||||
m_entered = false;
|
||||
}
|
||||
|
||||
void InsertToGlobal(const std::string& name, v8::FunctionCallback creator)
|
||||
|
||||
@ -451,7 +451,7 @@ namespace NSShaper
|
||||
CheckUnicodeFaceName(face, family_name, family_name_len);
|
||||
|
||||
unsigned int nLen1 = (unsigned int)family_name_len;
|
||||
unsigned int nLen2 = (unsigned int)strlen(face->style_name);
|
||||
unsigned int nLen2 = (unsigned int)((face->style_name != NULL) ? strlen(face->style_name) : 0);
|
||||
|
||||
unsigned int nLen = 28 + nLen1 + 1 + nLen2 + 1 + 1 + (int)face->num_fixed_sizes;
|
||||
|
||||
@ -693,6 +693,13 @@ namespace NSShaper
|
||||
g_userfeatures_init = true;
|
||||
}
|
||||
|
||||
// Turn on ligatures on arabic script
|
||||
if (nScript == HB_SCRIPT_ARABIC ||
|
||||
nScript == HB_SCRIPT_SYRIAC)
|
||||
{
|
||||
nFeatures |= 1;
|
||||
}
|
||||
|
||||
// font
|
||||
hb_font_t* pFont;
|
||||
if (NULL == font)
|
||||
|
||||
@ -94,11 +94,14 @@ void CheckUnicodeFaceName(FT_Face pFace, int*& UName, unsigned int& ULen)
|
||||
bool isBadASCII = false;
|
||||
|
||||
unsigned int face_name_len = 0;
|
||||
while ('\0' != face_name[face_name_len])
|
||||
if (NULL != face_name)
|
||||
{
|
||||
if ('?' == face_name[face_name_len])
|
||||
isBadASCII = true;
|
||||
++face_name_len;
|
||||
while ('\0' != face_name[face_name_len])
|
||||
{
|
||||
if ('?' == face_name[face_name_len])
|
||||
isBadASCII = true;
|
||||
++face_name_len;
|
||||
}
|
||||
}
|
||||
|
||||
if (face_name_len > 6 &&
|
||||
|
||||
@ -594,6 +594,13 @@ WASM_EXPORT unsigned char* ASC_HB_ShapeText(FT_Face pFace, hb_font_t* pFont, cha
|
||||
g_userfeatures_init = true;
|
||||
}
|
||||
|
||||
// Turn on ligatures on arabic script
|
||||
if (nScript == HB_SCRIPT_ARABIC ||
|
||||
nScript == HB_SCRIPT_SYRIAC)
|
||||
{
|
||||
nFeatures |= 1;
|
||||
}
|
||||
|
||||
// font
|
||||
if (NULL == pFont)
|
||||
{
|
||||
|
||||
@ -260,10 +260,13 @@
|
||||
"folder": "../../../OfficeUtils/js",
|
||||
"files": ["../src/ZipBuffer.cpp", "wasm/src/base.cpp", "../src/zlib_addon.c"]
|
||||
},
|
||||
|
||||
{
|
||||
"folder": "../../",
|
||||
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp"]
|
||||
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp", "graphics/Matrix.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../agg-2.4/src/",
|
||||
"files": ["agg_trans_affine.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../raster/",
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
|
||||
CAnnotFieldInfo::CAnnotFieldInfo() : IAdvancedCommand(AdvancedCommandType::Annotaion)
|
||||
{
|
||||
m_nType = -1;
|
||||
m_nType = EAnnotType::Unknown;
|
||||
|
||||
m_nFlag = 0;
|
||||
m_nID = 0;
|
||||
@ -94,118 +94,108 @@ CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
RELEASEOBJECT(m_pWidgetPr);
|
||||
}
|
||||
|
||||
void CAnnotFieldInfo::CreateMarkup()
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
}
|
||||
void CAnnotFieldInfo::SetType(int nType)
|
||||
{
|
||||
m_nType = nType;
|
||||
switch (nType)
|
||||
m_nType = static_cast<EAnnotType>(nType);
|
||||
switch (m_nType)
|
||||
{
|
||||
case 0:
|
||||
case EAnnotType::Text:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pTextPr);
|
||||
m_pTextPr = new CAnnotFieldInfo::CTextAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
case EAnnotType::FreeText:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pFreeTextPr);
|
||||
m_pFreeTextPr = new CAnnotFieldInfo::CFreeTextAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
case EAnnotType::Line:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pLinePr);
|
||||
m_pLinePr = new CAnnotFieldInfo::CLineAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
case 5:
|
||||
case EAnnotType::Square:
|
||||
case EAnnotType::Circle:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pSquareCirclePr);
|
||||
m_pSquareCirclePr = new CAnnotFieldInfo::CSquareCircleAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
case 7:
|
||||
case EAnnotType::PolygonLine:
|
||||
case EAnnotType::PolyLine:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pPolygonLinePr);
|
||||
m_pPolygonLinePr = new CAnnotFieldInfo::CPolygonLineAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case EAnnotType::Highlight:
|
||||
case EAnnotType::Underline:
|
||||
case EAnnotType::Squiggly:
|
||||
case EAnnotType::Strikeout:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pTextMarkupPr);
|
||||
m_pTextMarkupPr = new CAnnotFieldInfo::CTextMarkupAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
case EAnnotType::Stamp:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pStampPr);
|
||||
m_pStampPr = new CAnnotFieldInfo::CStampAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 13:
|
||||
case EAnnotType::Caret:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pCaretPr);
|
||||
m_pCaretPr = new CAnnotFieldInfo::CCaretAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 14:
|
||||
case EAnnotType::Ink:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pInkPr);
|
||||
m_pInkPr = new CAnnotFieldInfo::CInkAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
case EAnnotType::Popup:
|
||||
{
|
||||
RELEASEOBJECT(m_pPopupPr);
|
||||
m_pPopupPr = new CAnnotFieldInfo::CPopupAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 26:
|
||||
case 27:
|
||||
case 28:
|
||||
case 29:
|
||||
case 30:
|
||||
case 31:
|
||||
case 32:
|
||||
case 33:
|
||||
case EAnnotType::Widget:
|
||||
case EAnnotType::WidgetPushButton:
|
||||
case EAnnotType::WidgetRadioButton:
|
||||
case EAnnotType::WidgetCheckBox:
|
||||
case EAnnotType::WidgetText:
|
||||
case EAnnotType::WidgetCombobox:
|
||||
case EAnnotType::WidgetListbox:
|
||||
case EAnnotType::WidgetSignature:
|
||||
{
|
||||
RELEASEOBJECT(m_pWidgetPr);
|
||||
m_pWidgetPr = new CAnnotFieldInfo::CWidgetAnnotPr(nType);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
CAnnotFieldInfo::EAnnotType CAnnotFieldInfo::GetType() { return m_nType; }
|
||||
|
||||
void CAnnotFieldInfo::GetBounds(double& dX1, double& dY1, double& dX2, double& dY2)
|
||||
{
|
||||
@ -224,6 +214,7 @@ int CAnnotFieldInfo::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::GetID() const { return m_nID; }
|
||||
int CAnnotFieldInfo::GetAnnotFlag() const { return m_nAnnotFlag; }
|
||||
int CAnnotFieldInfo::GetPage() const { return m_nPage; }
|
||||
int CAnnotFieldInfo::GetCopyAP() const { return m_nCopyAP; }
|
||||
void CAnnotFieldInfo::GetBE(BYTE& nS, double& dI) { nS = m_pBE.first; dI = m_pBE.second; }
|
||||
BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
|
||||
{
|
||||
@ -343,6 +334,7 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
if (nFlags & (1 << 3))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -353,6 +345,7 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
if (m_oBorder.nType == 2)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_oBorder.arrDash.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_oBorder.arrDash.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -367,6 +360,8 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
}
|
||||
if (nFlags & (1 << 7))
|
||||
m_wsOUserID = pReader->ReadString();
|
||||
if (nFlags & (1 << 8))
|
||||
m_nCopyAP = pReader->ReadInt();
|
||||
|
||||
if (IsMarkup())
|
||||
{
|
||||
@ -428,6 +423,7 @@ void CAnnotFieldInfo::CMarkupAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
if (nFlags & (1 << 3))
|
||||
{
|
||||
int nFont = pReader->ReadInt();
|
||||
m_arrRC.reserve(nFont);
|
||||
for (int i = 0; i < nFont; ++i)
|
||||
{
|
||||
CFontData* pFont = new CFontData();
|
||||
@ -480,6 +476,7 @@ void CAnnotFieldInfo::CInkAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* p
|
||||
{
|
||||
std::vector<double> arrLine;
|
||||
int m = pReader->ReadInt();
|
||||
arrLine.reserve(m);
|
||||
for (int j = 0; j < m; ++j)
|
||||
arrLine.push_back(pReader->ReadDouble());
|
||||
if (!arrLine.empty())
|
||||
@ -512,6 +509,7 @@ void CAnnotFieldInfo::CLineAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader*
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrIC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrIC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -539,6 +537,7 @@ void CAnnotFieldInfo::CTextMarkupAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferRe
|
||||
{
|
||||
m_nSubtype = nType;
|
||||
int n = pReader->ReadInt();
|
||||
m_arrQuadPoints.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -559,6 +558,7 @@ void CAnnotFieldInfo::CSquareCircleAnnotPr::Read(NSOnlineOfficeBinToPdf::CBuffer
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrIC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrIC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -572,6 +572,7 @@ const std::vector<double>& CAnnotFieldInfo::CPolygonLineAnnotPr::GetVertices() {
|
||||
void CAnnotFieldInfo::CPolygonLineAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, BYTE nType, int nFlags)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrVertices.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrVertices.push_back(pReader->ReadDouble());
|
||||
|
||||
@ -584,6 +585,7 @@ void CAnnotFieldInfo::CPolygonLineAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferR
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrIC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrIC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -613,6 +615,7 @@ void CAnnotFieldInfo::CFreeTextAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferRead
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrCL.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrCL.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -625,6 +628,7 @@ void CAnnotFieldInfo::CFreeTextAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferRead
|
||||
if (nFlags & (1 << 21))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrIC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrIC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -685,6 +689,7 @@ const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetDV() { return m_wsDV; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetT() { return m_wsT; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetFontName() { return m_wsFN; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetFontKey() { return m_wsFK; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetOMetadata() { return m_wsOMetadata; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetTC() { return m_arrTC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetBC() { return m_arrBC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetBG() { return m_arrBG; }
|
||||
@ -814,6 +819,7 @@ CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* ReadAction(NSOnlineOfficeBinToPd
|
||||
{
|
||||
pRes->nKind = pReader->ReadByte();
|
||||
int n = pReader->ReadInt();
|
||||
pRes->arrStr.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pRes->arrStr.push_back(pReader->ReadString());
|
||||
break;
|
||||
@ -822,6 +828,7 @@ CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* ReadAction(NSOnlineOfficeBinToPd
|
||||
{
|
||||
pRes->nInt1 = pReader->ReadInt();
|
||||
int n = pReader->ReadInt();
|
||||
pRes->arrStr.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pRes->arrStr.push_back(pReader->ReadString());
|
||||
break;
|
||||
@ -841,6 +848,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
m_nFontStyle = pReader->ReadInt();
|
||||
|
||||
int n = pReader->ReadInt();
|
||||
m_arrTC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrTC.push_back(pReader->ReadDouble());
|
||||
|
||||
@ -863,6 +871,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
if (nFlags & (1 << 5))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrBC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrBC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -871,6 +880,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
if (nFlags & (1 << 7))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrBG.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrBG.push_back(pReader->ReadDouble());
|
||||
}
|
||||
@ -880,6 +890,8 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
m_nParentID = pReader->ReadInt();
|
||||
if (nFlags & (1 << 18))
|
||||
m_wsT = pReader->ReadString();
|
||||
if (nFlags & (1 << 20))
|
||||
m_wsOMetadata = pReader->ReadString();
|
||||
|
||||
// Action
|
||||
int nAction = pReader->ReadInt();
|
||||
@ -976,7 +988,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::Read(NSOnlineOfficeBinToPdf
|
||||
m_wsV = pReader->ReadString();
|
||||
if (nFlags & (1 << 10))
|
||||
m_nMaxLen = pReader->ReadInt();
|
||||
if (nWidgetFlag & (1 << 25))
|
||||
if (nFlags & (1 << 11))
|
||||
m_wsRV = pReader->ReadString();
|
||||
if (nFlags & (1 << 12))
|
||||
m_wsAPV = pReader->ReadString();
|
||||
@ -1006,6 +1018,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::Read(NSOnlineOfficeBinToP
|
||||
if (nFlags & (1 << 10))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrOpt.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::wstring s1 = pReader->ReadString();
|
||||
@ -1020,12 +1033,14 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::Read(NSOnlineOfficeBinToP
|
||||
if (nFlags & (1 << 13))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrV.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrV.push_back(pReader->ReadString());
|
||||
}
|
||||
if (nFlags & (1 << 14))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrI.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrI.push_back(pReader->ReadInt());
|
||||
}
|
||||
@ -1052,16 +1067,24 @@ CWidgetsInfo::~CWidgetsInfo()
|
||||
for (int i = 0; i < m_arrParents.size(); ++i)
|
||||
RELEASEOBJECT(m_arrParents[i]);
|
||||
}
|
||||
const std::vector<int>& CWidgetsInfo::GetCO() { return m_arrCO; }
|
||||
const std::vector< std::pair<int, int> >& CWidgetsInfo::GetCO() { return m_arrCO; }
|
||||
const std::vector<std::wstring>& CWidgetsInfo::GetButtonImg() { return m_arrButtonImg; }
|
||||
const std::vector<CWidgetsInfo::CParent*>& CWidgetsInfo::GetParents() { return m_arrParents; }
|
||||
void CWidgetsInfo::ChangeCO(int i, int nNum, int nGen)
|
||||
{
|
||||
if (i < 0 || i > m_arrCO.size() - 1)
|
||||
return;
|
||||
m_arrCO[i] = std::make_pair(nNum, nGen);
|
||||
}
|
||||
bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrCO.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrCO.push_back(pReader->ReadInt());
|
||||
m_arrCO.push_back(std::make_pair(pReader->ReadInt(), -1));
|
||||
|
||||
n = pReader->ReadInt();
|
||||
m_arrParents.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
CParent* pParent = new CParent();
|
||||
@ -1077,6 +1100,7 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
if (nFlags & (1 << 3))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
pParent->arrI.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pParent->arrI.push_back(pReader->ReadInt());
|
||||
}
|
||||
@ -1085,13 +1109,45 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
if (nFlags & (1 << 5))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
pParent->arrV.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pParent->arrV.push_back(pReader->ReadString());
|
||||
}
|
||||
if (nFlags & (1 << 6))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
pParent->arrOpt.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::wstring s1 = pReader->ReadString();
|
||||
std::wstring s2 = pReader->ReadString();
|
||||
pParent->arrOpt.push_back(std::make_pair(s1, s2));
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 7))
|
||||
pParent->nFieldFlag = pReader->ReadInt();
|
||||
if (nFlags & (1 << 8))
|
||||
{
|
||||
// Action
|
||||
int nAction = pReader->ReadInt();
|
||||
for (int i = 0; i < nAction; ++i)
|
||||
{
|
||||
std::wstring wsType = pReader->ReadString();
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* pA = ReadAction(pReader);
|
||||
if (pA)
|
||||
{
|
||||
pA->wsType = wsType;
|
||||
pParent->arrAction.push_back(pA);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 9))
|
||||
pParent->nMaxLen = pReader->ReadInt();
|
||||
m_arrParents.push_back(pParent);
|
||||
}
|
||||
|
||||
n = pReader->ReadInt();
|
||||
m_arrButtonImg.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::string sImagePath = pReader->ReadStringA();
|
||||
|
||||
@ -39,6 +39,36 @@ class IMetafileToRenderter;
|
||||
class GRAPHICS_DECL CAnnotFieldInfo : public IAdvancedCommand
|
||||
{
|
||||
public:
|
||||
enum EAnnotType
|
||||
{
|
||||
Unknown = -1,
|
||||
Text = 0,
|
||||
Link = 1,
|
||||
FreeText = 2,
|
||||
Line = 3,
|
||||
Square = 4,
|
||||
Circle = 5,
|
||||
PolygonLine = 6,
|
||||
PolyLine = 7,
|
||||
Highlight = 8,
|
||||
Underline = 9,
|
||||
Squiggly = 10,
|
||||
Strikeout = 11,
|
||||
Stamp = 12,
|
||||
Caret = 13,
|
||||
Ink = 14,
|
||||
Popup = 15,
|
||||
FileAttachment = 16,
|
||||
Widget = 26,
|
||||
WidgetPushButton = 27,
|
||||
WidgetRadioButton = 28,
|
||||
WidgetCheckBox = 29,
|
||||
WidgetText = 30,
|
||||
WidgetCombobox = 31,
|
||||
WidgetListbox = 32,
|
||||
WidgetSignature = 33
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CWidgetAnnotPr
|
||||
{
|
||||
public:
|
||||
@ -164,6 +194,7 @@ public:
|
||||
const std::wstring& GetT();
|
||||
const std::wstring& GetFontName();
|
||||
const std::wstring& GetFontKey();
|
||||
const std::wstring& GetOMetadata();
|
||||
const std::vector<double>& GetTC();
|
||||
const std::vector<double>& GetBC();
|
||||
const std::vector<double>& GetBG();
|
||||
@ -193,6 +224,7 @@ public:
|
||||
std::wstring m_wsT;
|
||||
std::wstring m_wsFN;
|
||||
std::wstring m_wsFK;
|
||||
std::wstring m_wsOMetadata;
|
||||
std::vector<double> m_arrTC;
|
||||
std::vector<double> m_arrBC;
|
||||
std::vector<double> m_arrBG;
|
||||
@ -423,7 +455,9 @@ public:
|
||||
CAnnotFieldInfo();
|
||||
virtual ~CAnnotFieldInfo();
|
||||
|
||||
void CreateMarkup();
|
||||
void SetType(int nType);
|
||||
EAnnotType GetType();
|
||||
|
||||
void GetBounds(double& dX1, double& dY1, double& dX2, double& dY2);
|
||||
void GetBorder(BYTE& nType, double& dWidth, std::vector<double>& arrDash);
|
||||
@ -431,6 +465,7 @@ public:
|
||||
int GetID() const;
|
||||
int GetAnnotFlag() const;
|
||||
int GetPage() const;
|
||||
int GetCopyAP() const;
|
||||
void GetBE(BYTE& nS, double& dI);
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
const std::wstring& GetNM();
|
||||
@ -479,7 +514,7 @@ private:
|
||||
std::vector<double> arrDash;
|
||||
};
|
||||
|
||||
int m_nType;
|
||||
EAnnotType m_nType;
|
||||
double m_dX1;
|
||||
double m_dY1;
|
||||
double m_dX2;
|
||||
@ -488,6 +523,7 @@ private:
|
||||
int m_nID;
|
||||
int m_nAnnotFlag;
|
||||
int m_nPage;
|
||||
int m_nCopyAP;
|
||||
std::wstring m_wsNM;
|
||||
std::wstring m_wsLM;
|
||||
std::wstring m_wsOUserID;
|
||||
@ -533,25 +569,31 @@ public:
|
||||
{
|
||||
int nID;
|
||||
int nFlags;
|
||||
int nMaxLen;
|
||||
int nParentID;
|
||||
int nFieldFlag;
|
||||
std::wstring sName;
|
||||
std::wstring sV;
|
||||
std::wstring sDV;
|
||||
std::vector<int> arrI;
|
||||
std::vector<std::wstring> arrV;
|
||||
std::vector<CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget*> arrAction;
|
||||
std::vector< std::pair<std::wstring, std::wstring> > arrOpt;
|
||||
};
|
||||
|
||||
CWidgetsInfo();
|
||||
virtual ~CWidgetsInfo();
|
||||
|
||||
const std::vector<int>& GetCO();
|
||||
const std::vector< std::pair<int, int> >& GetCO();
|
||||
const std::vector<std::wstring>& GetButtonImg();
|
||||
const std::vector<CParent*>& GetParents();
|
||||
|
||||
void ChangeCO(int i, int nNum, int nGen);
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
|
||||
private:
|
||||
std::vector<int> m_arrCO;
|
||||
std::vector< std::pair<int, int> > m_arrCO;
|
||||
std::vector<std::wstring> m_arrButtonImg;
|
||||
std::vector<CParent*> m_arrParents;
|
||||
};
|
||||
|
||||
@ -51,6 +51,9 @@
|
||||
"_IsNeedCMap",
|
||||
"_SetCMapData",
|
||||
"_ScanPage",
|
||||
"_SplitPages",
|
||||
"_MergePages",
|
||||
"_UnmergePages",
|
||||
"_GetImageBase64",
|
||||
"_GetImageBase64Len",
|
||||
"_GetImageBase64Ptr",
|
||||
@ -86,7 +89,7 @@
|
||||
"NO_CONSOLE_IO", "USE_EXTERNAL_JPEG2000", "USE_JPIP", "OPJ_STATIC", "FONT_ENGINE_DISABLE_FILESYSTEM",
|
||||
"IMAGE_CHECKER_DISABLE_XML",
|
||||
"USE_OPENSSL_HASH",
|
||||
"DISABLE_FULL_DOCUMENT_CREATION", "DISABLE_FILESYSTEM"
|
||||
"DISABLE_FULL_DOCUMENT_CREATION", "DISABLE_FILESYSTEM", "CRYPTOPP_DISABLE_ASM", "DISABLE_TYPE_MISMATCH"
|
||||
],
|
||||
"compile_files_array": [
|
||||
{
|
||||
@ -135,7 +138,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "./wasm/src/",
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "pdfwriter.cpp", "HTMLRendererText.cpp"]
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "HTMLRendererText.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "freetype-2.10.4/src/",
|
||||
@ -143,7 +146,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../",
|
||||
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "BooleanOperations.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp"]
|
||||
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "BooleanOperations.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp", "MetafileToRenderer.cpp", "MetafileToRendererReader.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../fontengine/",
|
||||
@ -155,12 +158,16 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../common/",
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp"]
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp", "SystemUtils.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/icu/icu/source/common/",
|
||||
"files": ["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"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/cryptopp/",
|
||||
"files": ["cryptlib.cpp", "cpu.cpp", "integer.cpp", "3way.cpp", "adler32.cpp", "algebra.cpp", "algparam.cpp", "allocate.cpp", "arc4.cpp", "aria.cpp", "aria_simd.cpp", "ariatab.cpp", "asn.cpp", "authenc.cpp", "base32.cpp", "base64.cpp", "basecode.cpp", "bfinit.cpp", "blake2.cpp", "blake2s_simd.cpp", "blake2b_simd.cpp", "blowfish.cpp", "blumshub.cpp", "camellia.cpp", "cast.cpp", "casts.cpp", "cbcmac.cpp", "ccm.cpp", "chacha.cpp", "chacha_simd.cpp", "chacha_avx.cpp", "chachapoly.cpp", "cham.cpp", "cham_simd.cpp", "channels.cpp", "cmac.cpp", "crc.cpp", "crc_simd.cpp", "darn.cpp", "default.cpp", "des.cpp", "dessp.cpp", "dh.cpp", "dh2.cpp", "dll.cpp", "donna_32.cpp", "donna_64.cpp", "donna_sse.cpp", "dsa.cpp", "eax.cpp", "ec2n.cpp", "ecp.cpp", "eccrypto.cpp", "eprecomp.cpp", "elgamal.cpp", "emsa2.cpp", "eprecomp.cpp", "esign.cpp", "files.cpp", "filters.cpp", "fips140.cpp", "gcm.cpp", "gcm_simd.cpp", "gf256.cpp", "gf2_32.cpp", "gf2n.cpp", "gf2n_simd.cpp", "gfpcrypt.cpp", "gost.cpp", "gzip.cpp", "hc128.cpp", "hc256.cpp", "hex.cpp", "hight.cpp", "hmac.cpp", "hrtimer.cpp", "ida.cpp", "idea.cpp", "iterhash.cpp", "kalyna.cpp", "md5.cpp", "randpool.cpp", "osrng.cpp", "rijndael.cpp", "modes.cpp", "misc.cpp", "rdtables.cpp", "sha.cpp", "mqueue.cpp", "queue.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../OfficeUtils/src/",
|
||||
"files": ["OfficeUtils.cpp", "ZipBuffer.cpp", "ZipUtilsCP.cpp", "zlib_addon.c"]
|
||||
@ -179,7 +186,23 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/",
|
||||
"files": ["SrcReader/Adaptors.cpp", "SrcReader/GfxClip.cpp", "SrcReader/RendererOutputDev.cpp", "SrcReader/JPXStream2.cpp", "SrcReader/PdfAnnot.cpp", "Resources/BaseFonts.cpp", "Resources/CMapMemory/cmap_memory.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", "PdfFile.cpp", "PdfReader.cpp"]
|
||||
"files": ["PdfFile.cpp", "PdfReader.cpp", "PdfWriter.cpp", "PdfEditor.cpp", "OnlineOfficeBinToPdf.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcReader/",
|
||||
"files": ["Adaptors.cpp", "GfxClip.cpp", "RendererOutputDev.cpp", "JPXStream2.cpp", "PdfAnnot.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcWriter/",
|
||||
"files": ["AcroForm.cpp", "Annotation.cpp", "Catalog.cpp", "Destination.cpp", "Document.cpp", "Encrypt.cpp", "EncryptDictionary.cpp", "Field.cpp", "Font.cpp", "Font14.cpp", "FontCidTT.cpp", "FontTT.cpp", "FontTTWriter.cpp", "GState.cpp", "Image.cpp", "Info.cpp", "Metadata.cpp", "Objects.cpp", "Outline.cpp", "Pages.cpp", "Pattern.cpp", "ResourcesDictionary.cpp", "Shading.cpp", "States.cpp", "Streams.cpp", "Utils.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/Resources/",
|
||||
"files": ["BaseFonts.cpp", "CMapMemory/cmap_memory.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/lib/",
|
||||
"files": ["fofi/FofiBase.cc", "fofi/FofiEncodings.cc", "fofi/FofiIdentifier.cc", "fofi/FofiTrueType.cc", "fofi/FofiType1.cc", "fofi/FofiType1C.cc", "goo/FixedPoint.cc", "goo/gfile.cc", "goo/GHash.cc", "goo/GList.cc", "goo/gmem.cc", "goo/gmempp.cc", "goo/GString.cc", "goo/parseargs.c", "goo/Trace.cc", "splash/Splash.cc", "splash/SplashBitmap.cc", "splash/SplashClip.cc", "splash/SplashFont.cc", "splash/SplashFontEngine.cc", "splash/SplashFontFile.cc", "splash/SplashFontFileID.cc", "splash/SplashFTFont.cc", "splash/SplashFTFontEngine.cc", "splash/SplashFTFontFile.cc", "splash/SplashPath.cc", "splash/SplashPattern.cc", "splash/SplashScreen.cc", "splash/SplashState.cc", "splash/SplashXPath.cc", "splash/SplashXPathScanner.cc", "xpdf/AcroForm.cc", "xpdf/Annot.cc", "xpdf/Array.cc", "xpdf/BuiltinFont.cc", "xpdf/BuiltinFontTables.cc", "xpdf/Catalog.cc", "xpdf/CharCodeToUnicode.cc", "xpdf/CMap.cc", "xpdf/Decrypt.cc", "xpdf/Dict.cc", "xpdf/DisplayState.cc", "xpdf/Error.cc", "xpdf/FontEncodingTables.cc", "xpdf/Function.cc", "xpdf/Gfx.cc", "xpdf/GfxFont.cc", "xpdf/GfxState.cc", "xpdf/GlobalParams.cc", "xpdf/ImageOutputDev.cc", "xpdf/JArithmeticDecoder.cc", "xpdf/JBIG2Stream.cc", "xpdf/JPXStream.cc", "xpdf/Lexer.cc", "xpdf/Link.cc", "xpdf/NameToCharCode.cc", "xpdf/Object.cc", "xpdf/OptionalContent.cc", "xpdf/Outline.cc", "xpdf/OutputDev.cc", "xpdf/Page.cc", "xpdf/Parser.cc", "xpdf/PDF417Barcode.cc", "xpdf/PDFCore.cc", "xpdf/PDFDoc.cc", "xpdf/PDFDocEncoding.cc", "xpdf/PreScanOutputDev.cc", "xpdf/PSOutputDev.cc", "xpdf/PSTokenizer.cc", "xpdf/SecurityHandler.cc", "xpdf/ShadingImage.cc", "xpdf/SplashOutputDev.cc", "xpdf/Stream.cc", "xpdf/TextOutputDev.cc", "xpdf/TextString.cc", "xpdf/TileCache.cc", "xpdf/TileCompositor.cc", "xpdf/TileMap.cc", "xpdf/UnicodeMap.cc", "xpdf/UnicodeRemapping.cc", "xpdf/UnicodeTypeTable.cc", "xpdf/UTF8.cc", "xpdf/WebFont.cc", "xpdf/XFAScanner.cc", "xpdf/XRef.cc", "xpdf/Zoox.cc"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../raster/Jp2/openjpeg/openjpeg-2.4.0/src/lib/openjp2/",
|
||||
|
||||
@ -619,10 +619,7 @@ INCLUDEPATH += \
|
||||
$$PDF_ROOT_DIR/lib/splash \
|
||||
$$PDF_ROOT_DIR/lib
|
||||
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/lib/aconf.h \
|
||||
$$$files($$PDF_ROOT_DIR/lib/*.h)
|
||||
|
||||
HEADERS += $$files($$PDF_ROOT_DIR/lib/*.h, true)
|
||||
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.c, true)
|
||||
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.cc, true)
|
||||
|
||||
@ -644,9 +641,7 @@ SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.cpp \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/BaseFonts.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp \
|
||||
$$PDF_ROOT_DIR/PdfReader.cpp \
|
||||
$$PDF_ROOT_DIR/PdfFile.cpp
|
||||
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp
|
||||
|
||||
HEADERS +=\
|
||||
$$PDF_ROOT_DIR/Resources/Fontd050000l.h \
|
||||
@ -670,9 +665,87 @@ HEADERS +=\
|
||||
$$PDF_ROOT_DIR/SrcReader/MemoryUtils.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/FontsWasm.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.h
|
||||
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
|
||||
|
||||
# PdfWriter
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/AcroForm.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Annotation.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Catalog.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Consts.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Destination.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Document.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encodings.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encrypt.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/EncryptDictionary.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Field.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font14.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontCidTT.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTT.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTTWriter.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/GState.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Image.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Info.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Objects.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Outline.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pages.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pattern.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ResourcesDictionary.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Shading.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Streams.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Types.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ICCProfile.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.h
|
||||
|
||||
SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/AcroForm.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Annotation.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Catalog.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Destination.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Document.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encrypt.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/EncryptDictionary.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Field.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font14.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontCidTT.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTT.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTTWriter.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/GState.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Image.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Info.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Objects.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Outline.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pages.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pattern.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ResourcesDictionary.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Shading.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Streams.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.cpp
|
||||
|
||||
# PdfFile
|
||||
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/PdfFile.h \
|
||||
$$PDF_ROOT_DIR/PdfWriter.h \
|
||||
$$PDF_ROOT_DIR/PdfReader.h \
|
||||
$$PDF_ROOT_DIR/PdfFile.h
|
||||
$$PDF_ROOT_DIR/PdfEditor.h \
|
||||
$$PDF_ROOT_DIR/OnlineOfficeBinToPdf.h
|
||||
|
||||
SOURCES += \
|
||||
$$PDF_ROOT_DIR/PdfFile.cpp \
|
||||
$$PDF_ROOT_DIR/PdfWriter.cpp \
|
||||
$$PDF_ROOT_DIR/PdfReader.cpp \
|
||||
$$PDF_ROOT_DIR/PdfEditor.cpp \
|
||||
$$PDF_ROOT_DIR/OnlineOfficeBinToPdf.cpp
|
||||
|
||||
# DocxRenderer
|
||||
DOCX_RENDERER_ROOT_DIR = $$CORE_ROOT_DIR/DocxRenderer
|
||||
@ -682,6 +755,7 @@ HEADERS += \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/DropCap.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Table.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/ExternalImageStorage.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontStyleManager.h \
|
||||
@ -706,6 +780,7 @@ SOURCES += \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/ContText.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Table.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontManager.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontStyleManager.cpp \
|
||||
@ -727,7 +802,6 @@ HEADERS += \
|
||||
../wasm/src/Text.h
|
||||
|
||||
SOURCES += \
|
||||
../wasm/src/pdfwriter.cpp \
|
||||
../wasm/src/HTMLRendererText.cpp \
|
||||
../wasm/src/drawingfile.cpp \
|
||||
../wasm/src/drawingfile_test.cpp
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -94,6 +94,11 @@ CFile.prototype._getError = function()
|
||||
return g_native_drawing_file["GetErrorCode"]();
|
||||
};
|
||||
|
||||
CFile.prototype._addPDF = function(buffer, password)
|
||||
{
|
||||
return g_native_drawing_file["AddPDF"]();
|
||||
}
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -86,8 +86,9 @@ CFile.prototype._openFile = function(buffer, password)
|
||||
{
|
||||
let data = new Uint8Array(buffer);
|
||||
this.stream_size = data.length;
|
||||
this.stream = Module["_malloc"](this.stream_size);
|
||||
Module["HEAP8"].set(data, this.stream);
|
||||
let stream = Module["_malloc"](this.stream_size);
|
||||
Module["HEAP8"].set(data, stream);
|
||||
this.stream.push(stream);
|
||||
}
|
||||
|
||||
let passwordPtr = 0;
|
||||
@ -98,7 +99,7 @@ CFile.prototype._openFile = function(buffer, password)
|
||||
Module["HEAP8"].set(passwordBuf, passwordPtr);
|
||||
}
|
||||
|
||||
this.nativeFile = Module["_Open"](this.stream, this.stream_size, passwordPtr);
|
||||
this.nativeFile = Module["_Open"](this.stream[0], this.stream_size, passwordPtr);
|
||||
|
||||
if (passwordPtr)
|
||||
Module["_free"](passwordPtr);
|
||||
@ -112,7 +113,7 @@ CFile.prototype._closeFile = function()
|
||||
|
||||
CFile.prototype._getType = function()
|
||||
{
|
||||
return Module["_GetType"](this.stream, this.stream_size);
|
||||
return Module["_GetType"](this.stream[0], this.stream_size);
|
||||
};
|
||||
|
||||
CFile.prototype._getError = function()
|
||||
@ -120,6 +121,70 @@ CFile.prototype._getError = function()
|
||||
return Module["_GetErrorCode"](this.nativeFile);
|
||||
};
|
||||
|
||||
CFile.prototype._SplitPages = function(memoryBuffer, arrayBufferChanges)
|
||||
{
|
||||
let changesPtr = 0;
|
||||
let changesLen = 0;
|
||||
if (arrayBufferChanges)
|
||||
{
|
||||
let changes = new Uint8Array(arrayBufferChanges);
|
||||
changesLen = changes.length;
|
||||
changesPtr = Module["_malloc"](changesLen);
|
||||
Module["HEAP8"].set(changes, changesPtr);
|
||||
}
|
||||
|
||||
let pointer = Module["_malloc"](memoryBuffer.length * 4);
|
||||
Module["HEAP32"].set(memoryBuffer, pointer >> 2);
|
||||
let ptr = Module["_SplitPages"](this.nativeFile, pointer, memoryBuffer.length, changesPtr, changesLen);
|
||||
Module["_free"](pointer);
|
||||
if (changesPtr)
|
||||
Module["_free"](changesPtr);
|
||||
return ptr;
|
||||
};
|
||||
|
||||
CFile.prototype._MergePages = function(buffer, maxID, prefixForm)
|
||||
{
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
let data = (undefined !== buffer.byteLength) ? new Uint8Array(buffer) : buffer;
|
||||
let stream2 = Module["_malloc"](data.length);
|
||||
Module["HEAP8"].set(data, stream2);
|
||||
|
||||
if (!maxID)
|
||||
maxID = 0;
|
||||
|
||||
let prefixPtr = 0;
|
||||
if (prefixForm)
|
||||
{
|
||||
let prefixBuf = prefixForm.toUtf8();
|
||||
prefixPtr = Module["_malloc"](prefixBuf.length);
|
||||
Module["HEAP8"].set(prefixBuf, prefixPtr);
|
||||
}
|
||||
|
||||
let bRes = Module["_MergePages"](this.nativeFile, stream2, data.length, maxID, prefixPtr);
|
||||
if (bRes == 1)
|
||||
this.stream.push(stream2);
|
||||
else
|
||||
Module["_free"](stream2);
|
||||
|
||||
if (prefixPtr)
|
||||
Module["_free"](prefixPtr);
|
||||
|
||||
return bRes == 1;
|
||||
};
|
||||
|
||||
CFile.prototype._UndoMergePages = function()
|
||||
{
|
||||
let bRes = Module["_UnmergePages"](this.nativeFile);
|
||||
if (bRes == 1)
|
||||
{
|
||||
let str = this.stream.pop();
|
||||
Module["_free"](str);
|
||||
}
|
||||
return bRes == 1;
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -42,6 +42,12 @@ CBinaryReader.prototype.readByte = function()
|
||||
this.pos += 1;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readShort = function()
|
||||
{
|
||||
let val = this.data[this.pos] | this.data[this.pos + 1] << 8;
|
||||
this.pos += 2;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readInt = function()
|
||||
{
|
||||
let val = this.data[this.pos] | this.data[this.pos + 1] << 8 | this.data[this.pos + 2] << 16 | this.data[this.pos + 3] << 24;
|
||||
@ -56,6 +62,10 @@ CBinaryReader.prototype.readDouble2 = function()
|
||||
{
|
||||
return this.readInt() / 10000;
|
||||
};
|
||||
CBinaryReader.prototype.readDouble3 = function()
|
||||
{
|
||||
return this.readInt() / 100000;
|
||||
};
|
||||
CBinaryReader.prototype.readString = function()
|
||||
{
|
||||
let len = this.readInt();
|
||||
@ -63,9 +73,20 @@ CBinaryReader.prototype.readString = function()
|
||||
this.pos += len;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readString2 = function()
|
||||
{
|
||||
let len = this.readShort();
|
||||
let val = "";
|
||||
for (let i = 0; i < len; ++i)
|
||||
{
|
||||
let c = this.readShort();
|
||||
val += String.fromCharCode(c);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readData = function()
|
||||
{
|
||||
let len = this.readInt();
|
||||
let len = this.readInt() - 4;
|
||||
let val = this.data.slice(this.pos, this.pos + len);
|
||||
this.pos += len;
|
||||
return val;
|
||||
|
||||
@ -125,7 +125,7 @@ WASM_EXPORT BYTE* GetGlyphs(CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pFile->GetGlyphs(nPageIndex);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetLinks (CDrawingFile* pFile, int nPageIndex)
|
||||
WASM_EXPORT BYTE* GetLinks(CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pFile->GetLinks(nPageIndex);
|
||||
}
|
||||
@ -177,6 +177,18 @@ WASM_EXPORT BYTE* ScanPage(CDrawingFile* pFile, int nPageIndex, int mode)
|
||||
{
|
||||
return pFile->ScanPage(nPageIndex, mode);
|
||||
}
|
||||
WASM_EXPORT BYTE* SplitPages(CDrawingFile* pFile, int* arrPageIndex, int nLength, BYTE* data, LONG size)
|
||||
{
|
||||
return pFile->SplitPages(arrPageIndex, nLength, data, size);
|
||||
}
|
||||
WASM_EXPORT int MergePages(CDrawingFile* pFile, BYTE* data, LONG size, int nMaxID, const char* sPrefixForm)
|
||||
{
|
||||
return pFile->MergePages(data, size, nMaxID, sPrefixForm) ? 1 : 0;
|
||||
}
|
||||
WASM_EXPORT int UnmergePages(CDrawingFile* pFile)
|
||||
{
|
||||
return pFile->UnmergePages() ? 1 : 0;
|
||||
}
|
||||
|
||||
WASM_EXPORT void* GetImageBase64(CDrawingFile* pFile, int rId)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -40,6 +40,7 @@ enum OfficeDrawingFileType
|
||||
odftPDF = 0,
|
||||
odftXPS = 1,
|
||||
odftDJVU = 2,
|
||||
odftOFD = 3,
|
||||
odftUndefined = 255
|
||||
};
|
||||
|
||||
|
||||
@ -19,6 +19,10 @@ core_linux {
|
||||
QMAKE_CXXFLAGS += -Wno-narrowing
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
QMAKE_CFLAGS += -Wno-incompatible-function-pointer-types
|
||||
}
|
||||
|
||||
core_mac {
|
||||
DEFINES += HAVE_UNISTD_H HAVE_FCNTL_H
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ CImageFileFormatChecker::CImageFileFormatChecker()
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
}
|
||||
CImageFileFormatChecker::CImageFileFormatChecker(std::wstring sFileName)
|
||||
CImageFileFormatChecker::CImageFileFormatChecker(const std::wstring& sFileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
isImageFile(sFileName);
|
||||
@ -433,7 +433,7 @@ bool CImageFileFormatChecker::isPicFile(BYTE *pBuffer, DWORD dwBytes)
|
||||
return false;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool CImageFileFormatChecker::isImageFile(std::wstring& fileName)
|
||||
bool CImageFileFormatChecker::isImageFile(const std::wstring& fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -673,7 +673,7 @@ bool CImageFileFormatChecker::isImageFile(BYTE* buffer, DWORD sizeRead)
|
||||
if (eFileType) return true;
|
||||
return false;
|
||||
}
|
||||
bool CImageFileFormatChecker::isSvmFile(std::wstring & fileName)
|
||||
bool CImageFileFormatChecker::isSvmFile(const std::wstring & fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -703,7 +703,7 @@ bool CImageFileFormatChecker::isSvmFile(std::wstring & fileName)
|
||||
if (eFileType)return true;
|
||||
else return false;
|
||||
}
|
||||
bool CImageFileFormatChecker::isPngFile(std::wstring & fileName)
|
||||
bool CImageFileFormatChecker::isPngFile(const std::wstring & fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_UNKNOWN;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -735,7 +735,7 @@ bool CImageFileFormatChecker::isPngFile(std::wstring & fileName)
|
||||
|
||||
}
|
||||
|
||||
bool CImageFileFormatChecker::isRawFile(std::wstring& fileName)
|
||||
bool CImageFileFormatChecker::isRawFile(const std::wstring& fileName)
|
||||
{
|
||||
// TODO:
|
||||
return false;
|
||||
@ -745,7 +745,7 @@ bool CImageFileFormatChecker::isRawFile(BYTE* pBuffer, DWORD dwBytes)
|
||||
// TODO:
|
||||
return false;
|
||||
}
|
||||
bool CImageFileFormatChecker::isSvgFile(std::wstring& fileName)
|
||||
bool CImageFileFormatChecker::isSvgFile(const std::wstring& fileName)
|
||||
{
|
||||
#ifndef IMAGE_CHECKER_DISABLE_XML
|
||||
XmlUtils::CXmlLiteReader oReader;
|
||||
|
||||
@ -71,17 +71,17 @@ public:
|
||||
__ENUM_CXIMAGE_FORMATS eFileType;
|
||||
|
||||
CImageFileFormatChecker();
|
||||
CImageFileFormatChecker(std::wstring sFileName);
|
||||
CImageFileFormatChecker(const std::wstring& sFileName);
|
||||
CImageFileFormatChecker(BYTE* pBuffer, DWORD dwBytes);
|
||||
|
||||
bool isImageFileInZip(std::wstring& fileName);
|
||||
bool isImageFileInZip(const std::wstring& fileName);
|
||||
|
||||
bool isImageFile(std::wstring& fileName);
|
||||
bool isPngFile(std::wstring& fileName);
|
||||
bool isSvmFile(std::wstring& fileName);
|
||||
bool isImageFile(const std::wstring& fileName);
|
||||
bool isPngFile(const std::wstring& fileName);
|
||||
bool isSvmFile(const std::wstring& fileName);
|
||||
|
||||
bool isRawFile(std::wstring& fileName);
|
||||
bool isSvgFile(std::wstring& fileName);
|
||||
bool isRawFile(const std::wstring& fileName);
|
||||
bool isSvgFile(const std::wstring& fileName);
|
||||
|
||||
bool isImageFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isBmpFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
|
||||
@ -100,8 +100,6 @@ namespace MetaFile
|
||||
m_bStartedPath = false;
|
||||
m_bUpdatedClip = true;
|
||||
|
||||
m_pRenderer->CommandLong(c_nPenWidth0As1px, 1);
|
||||
|
||||
//int alpha = 0xff;
|
||||
//m_pRenderer->put_BrushAlpha1(alpha);
|
||||
//m_pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
@ -1218,7 +1216,41 @@ namespace MetaFile
|
||||
else if (PS_JOIN_MITER == ulPenJoin)
|
||||
nJoinStyle = Aggplus::LineJoinMiter;
|
||||
|
||||
const double dWidth = pPen->GetWidth() * m_dScaleX;
|
||||
double dWidth = pPen->GetWidth();
|
||||
|
||||
// Повторение кода из Graphics для вычисления минимальной ширины пера
|
||||
double dM11, dM12, dM21, dM22, dDx, dDy;
|
||||
m_pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
|
||||
|
||||
Aggplus::CMatrix oMatrix;
|
||||
|
||||
oMatrix.SetElements(dM11, dM12, dM21, dM22, dDx, dDy);
|
||||
oMatrix.Scale(1. / m_dScaleX, 1. / m_dScaleY);
|
||||
|
||||
// Вычисление минимально возможной ширины пера
|
||||
// # Код явялется дублированным из Graphics
|
||||
const double dSqrtDet = sqrt(abs(oMatrix.Determinant()));
|
||||
const double dWidthMinSize = (dSqrtDet != 0) ? (1.0 / dSqrtDet) : dWidth;
|
||||
|
||||
if (0 == pPen->GetWidth())
|
||||
{
|
||||
double dX = 0.72, dY = 0.72;
|
||||
|
||||
oMatrix.Invert();
|
||||
oMatrix.TransformPoint(dX, dY);
|
||||
dX -= oMatrix.OffsetX();
|
||||
dY -= oMatrix.OffsetY();
|
||||
dWidth = std::min(abs(dX), abs(dY));
|
||||
}
|
||||
//------------------------
|
||||
else
|
||||
{
|
||||
dWidth *= m_dScaleX;
|
||||
|
||||
if (dWidth < dWidthMinSize)
|
||||
dWidth = dWidthMinSize;
|
||||
}
|
||||
|
||||
const double dMiterLimit = (0 != pPen->GetMiterLimit()) ? pPen->GetMiterLimit() : m_pFile->GetMiterLimit() * m_dScaleX;
|
||||
|
||||
BYTE nDashStyle = Aggplus::DashStyleSolid;
|
||||
@ -1228,79 +1260,83 @@ namespace MetaFile
|
||||
|
||||
pPen->GetDashData(pDataDash, unSizeDash);
|
||||
|
||||
if (NULL != pDataDash && 0 != unSizeDash)
|
||||
if ((NULL != pDataDash && 0 != unSizeDash) || PS_SOLID != ulPenStyle)
|
||||
{
|
||||
m_pRenderer->put_PenDashOffset(pPen->GetDashOffset());
|
||||
// Дублированный код из Graphics
|
||||
// Без этого используется оригинальный код в Graphics, который отрисовывает уже неверно
|
||||
double dDashWidth{dWidth};
|
||||
|
||||
double dM11, dTemp;
|
||||
m_pRenderer->GetTransform(&dM11, &dTemp, &dTemp, &dTemp, &dTemp, &dTemp);
|
||||
double dDpi;
|
||||
m_pRenderer->get_DpiX(&dDpi);
|
||||
const double dNewWidth{dWidth * dM11 * dDpi / 25.4};
|
||||
|
||||
std::vector<double> arDashes(unSizeDash);
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex)
|
||||
arDashes[unIndex] = pDataDash[unIndex] * dNewWidth;
|
||||
|
||||
m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash);
|
||||
|
||||
nDashStyle = Aggplus::DashStyleCustom;
|
||||
}
|
||||
else if (PS_SOLID != ulPenStyle)
|
||||
{
|
||||
std::vector<double> arDashPattern;
|
||||
|
||||
double dM11, dTemp;
|
||||
m_pRenderer->GetTransform(&dM11, &dTemp, &dTemp, &dTemp, &dTemp, &dTemp);
|
||||
double dDpi;
|
||||
m_pRenderer->get_DpiX(&dDpi);
|
||||
const double dNewWidth{dWidth * dM11 * dDpi / 25.4};
|
||||
|
||||
switch (ulPenStyle)
|
||||
if (!Equals(dWidthMinSize, dWidth))
|
||||
{
|
||||
case PS_DASH:
|
||||
{
|
||||
arDashPattern.push_back(9 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
double dDet = oMatrix.Determinant();
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DOT:
|
||||
{
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOTDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
arDashPattern.push_back(3 * dNewWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
if (fabs(dDet) < 0.0001)
|
||||
dDashWidth *= dSqrtDet;
|
||||
}
|
||||
// -----------------------------
|
||||
|
||||
if (!arDashPattern.empty())
|
||||
if (NULL != pDataDash && 0 != unSizeDash)
|
||||
{
|
||||
m_pRenderer->PenDashPattern(arDashPattern.data(), arDashPattern.size());
|
||||
m_pRenderer->put_PenDashOffset(pPen->GetDashOffset());
|
||||
|
||||
std::vector<double> arDashes(unSizeDash);
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex)
|
||||
arDashes[unIndex] = pDataDash[unIndex] * dDashWidth;
|
||||
|
||||
m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash);
|
||||
|
||||
nDashStyle = Aggplus::DashStyleCustom;
|
||||
nStartCapStyle = nEndCapStyle = Aggplus::LineCapFlat;
|
||||
nJoinStyle = Aggplus::LineJoinMiter;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<double> arDashPattern;
|
||||
|
||||
switch (ulPenStyle)
|
||||
{
|
||||
case PS_DASH:
|
||||
{
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DOT:
|
||||
{
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOTDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!arDashPattern.empty())
|
||||
{
|
||||
m_pRenderer->PenDashPattern(arDashPattern.data(), arDashPattern.size());
|
||||
nDashStyle = Aggplus::DashStyleCustom;
|
||||
nStartCapStyle = nEndCapStyle = Aggplus::LineCapFlat;
|
||||
nJoinStyle = Aggplus::LineJoinMiter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,8 @@ namespace MetaFile
|
||||
: r(_r), g(_g), b(_b), a(_a)
|
||||
{}
|
||||
|
||||
TRGBA::TRGBA(int nValue) : r((nValue >> 0) & 0xFF), g((nValue >> 8) & 0xFF), b((nValue >> 16) & 0xFF), a((nValue >> 24) & 0xFF)
|
||||
TRGBA::TRGBA(int nValue)
|
||||
: r((nValue >> 0) & 0xFF), g((nValue >> 8) & 0xFF), b((nValue >> 16) & 0xFF), a((nValue >> 24) & 0xFF)
|
||||
{}
|
||||
|
||||
void TRGBA::Set(unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a)
|
||||
@ -94,7 +95,18 @@ namespace MetaFile
|
||||
return a;
|
||||
}
|
||||
|
||||
TXForm::TXForm() : M11(1), M12(0), M21(0), M22(1), Dx(0), Dy(0)
|
||||
TRGBA& TRGBA::operator=(const TRGBA& oRGBA)
|
||||
{
|
||||
r = oRGBA.r;
|
||||
g = oRGBA.g;
|
||||
b = oRGBA.b;
|
||||
a = oRGBA.a;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TXForm::TXForm()
|
||||
: M11(1), M12(0), M21(0), M22(1), Dx(0), Dy(0)
|
||||
{}
|
||||
|
||||
TXForm::TXForm(const TXForm &oXForm)
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
#include "../../../common/StringExt.h"
|
||||
|
||||
#ifndef BYTE
|
||||
@ -558,6 +559,8 @@ namespace MetaFile
|
||||
unsigned char GetGreen() const;
|
||||
unsigned char GetBlue() const;
|
||||
unsigned char GetAlpha() const;
|
||||
|
||||
TRGBA& operator=(const TRGBA& oRGBA);
|
||||
};
|
||||
|
||||
struct TXForm
|
||||
|
||||
@ -237,7 +237,9 @@ namespace MetaFile
|
||||
}
|
||||
for (int nAddIndex = 0; nAddIndex < nAdditBytes; nAddIndex++)
|
||||
{
|
||||
int nByte = *pBuffer; pBuffer++; lBufLen--;
|
||||
// int nByte = *pBuffer;
|
||||
++pBuffer;
|
||||
--lBufLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -271,7 +273,9 @@ namespace MetaFile
|
||||
}
|
||||
for (int nAddIndex = 0; nAddIndex < nAdditBytes; nAddIndex++)
|
||||
{
|
||||
int nByte = *pBuffer; pBuffer++; lBufLen--;
|
||||
// int nByte = *pBuffer;
|
||||
++pBuffer;
|
||||
--lBufLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -490,7 +494,12 @@ namespace MetaFile
|
||||
}
|
||||
|
||||
if (lBufLen < (nWidth + nAdd) * abs(nHeight))
|
||||
{
|
||||
if (pUncompressedBuffer)
|
||||
delete[] pUncompressedBuffer;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
pBgraBuffer = new BYTE[nWidth * abs(nHeight) * 4 * sizeof(BYTE)];
|
||||
if (NULL == pBgraBuffer)
|
||||
@ -643,7 +652,7 @@ namespace MetaFile
|
||||
*pulWidth = ulWidth;
|
||||
*pulHeight = ulHeight;
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
else if (BI_BITCOUNT_5 == ushBitCount)
|
||||
{
|
||||
@ -990,29 +999,6 @@ namespace MetaFile
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring ascii_to_unicode(const char *src)
|
||||
{
|
||||
size_t nSize = mbstowcs(0, src, 0);
|
||||
wchar_t* pBuffer = new wchar_t[nSize];
|
||||
nSize = mbstowcs(pBuffer, src, nSize);
|
||||
std::wstring sRes;
|
||||
if (nSize != (size_t)-1)
|
||||
sRes = std::wstring(pBuffer, nSize);
|
||||
delete[] pBuffer;
|
||||
return sRes;
|
||||
}
|
||||
std::string unicode_to_ascii(const wchar_t *src)
|
||||
{
|
||||
size_t nSize = wcstombs(0, src, 0);
|
||||
char* pBuffer = new char[nSize];
|
||||
nSize = wcstombs(pBuffer, src, nSize);
|
||||
std::string sRes;
|
||||
if (nSize != (size_t)-1)
|
||||
sRes = std::string(pBuffer, nSize);
|
||||
delete[] pBuffer;
|
||||
return sRes;
|
||||
}
|
||||
|
||||
std::wstring GetTempFilename(const std::wstring& sFolder)
|
||||
{
|
||||
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(sFolder.empty() ? NSFile::CFileBinary::GetTempPath() : sFolder, L"wmf");
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
*
|
||||
*/
|
||||
#include "../../../raster/ImageFileFormatChecker.h"
|
||||
#include "../../../graphics/Image.h"
|
||||
|
||||
#include "../Common/MetaFileUtils.h"
|
||||
|
||||
|
||||
@ -593,6 +593,8 @@ namespace MetaFile
|
||||
|
||||
if (!BanEMFProcesses())
|
||||
HANDLE_EMR_CREATEBRUSHINDIRECT(ulBrushIndex, pBrush);
|
||||
else
|
||||
delete pBrush;
|
||||
}
|
||||
|
||||
void CEmfParser::Read_EMR_SETTEXTCOLOR()
|
||||
@ -630,6 +632,8 @@ namespace MetaFile
|
||||
|
||||
if (!BanEMFProcesses())
|
||||
HANDLE_EMR_EXTCREATEFONTINDIRECTW(ulIndex, pFont);
|
||||
else
|
||||
delete pFont;
|
||||
}
|
||||
|
||||
void CEmfParser::Read_EMR_SETTEXTALIGN()
|
||||
@ -722,6 +726,8 @@ namespace MetaFile
|
||||
|
||||
if (!BanEMFProcesses())
|
||||
HANDLE_EMR_EXTCREATEPEN(ulPenIndex, pPen, arUnused);
|
||||
else
|
||||
delete pPen;
|
||||
}
|
||||
|
||||
void CEmfParser::Read_EMR_CREATEPEN()
|
||||
@ -744,6 +750,8 @@ namespace MetaFile
|
||||
|
||||
if (!BanEMFProcesses())
|
||||
HANDLE_EMR_CREATEPEN(ulPenIndex, widthX, pPen);
|
||||
else
|
||||
delete pPen;
|
||||
}
|
||||
|
||||
void CEmfParser::Read_EMR_SETPOLYFILLMODE()
|
||||
@ -1011,6 +1019,8 @@ namespace MetaFile
|
||||
|
||||
if (!BanEMFProcesses())
|
||||
HANDLE_EMR_CREATEPALETTE(ulPaletteIndex, pPalette);
|
||||
else
|
||||
delete pPalette;
|
||||
}
|
||||
|
||||
void CEmfParser::Read_EMR_SELECTPALETTE()
|
||||
|
||||
@ -763,7 +763,7 @@ namespace MetaFile
|
||||
if (InterpretatorType::Svg == oInterpretatorType)
|
||||
{
|
||||
CEmfInterpretatorSvg *pEmfInterpretatorSvg = new CEmfInterpretatorSvg(this, dWidth, dHeight);
|
||||
pEmfInterpretatorSvg->SetShapeRendering(EShapeRendering::CrispEdges);
|
||||
pEmfInterpretatorSvg->SetShapeRendering(EShapeRendering::OptimizeSpeed);
|
||||
m_pInterpretator = pEmfInterpretatorSvg;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
#ifndef CEMFPARSERBASE_H
|
||||
#define CEMFPARSERBASE_H
|
||||
|
||||
//#include "../EmfTypes.h"
|
||||
//#include "../EmfObjects.h"
|
||||
//#include "../../Common/MetaFileUtils.h"
|
||||
|
||||
#include "../EmfPlayer.h"
|
||||
|
||||
#include "../../Common/MetaFile.h"
|
||||
|
||||
@ -67,15 +67,11 @@
|
||||
#define EMFPLUS_TRANSLATEWORLDTRANSFORM 0x402D
|
||||
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
#include "CEmfParser.h"
|
||||
#include "../../Wmf/WmfFile.h"
|
||||
#include "../../Wmf/WmfInterpretator/CWmfInterpretatorSvg.h"
|
||||
|
||||
#include "../EmfInterpretator/CEmfInterpretator.h"
|
||||
#include "../EmfInterpretator/CEmfInterpretatorSvg.h"
|
||||
#include "../EmfInterpretator/CEmfInterpretatorArray.h"
|
||||
#include "../EmfInterpretator/CEmfInterpretatorRender.h"
|
||||
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF_XML
|
||||
@ -649,6 +645,9 @@ namespace MetaFile
|
||||
//TODO::реализовать при встрече
|
||||
}
|
||||
|
||||
if (BrushDataTransform & unBrushDataFlags)
|
||||
m_oStream.Skip(24);
|
||||
|
||||
if (BrushDataPresetColors & unBrushDataFlags)
|
||||
{
|
||||
unsigned int unPositionCount;
|
||||
@ -665,8 +664,8 @@ namespace MetaFile
|
||||
for (unsigned int unIndex = 0; unIndex < unPositionCount; ++unIndex)
|
||||
m_oStream >> pEmfPlusBrush->arGradientColors[unIndex].first;
|
||||
|
||||
pEmfPlusBrush->oColor = pEmfPlusBrush->arGradientColors[unPositionCount - 1].first;
|
||||
pEmfPlusBrush->oColorBack = pEmfPlusBrush->arGradientColors[0].first;
|
||||
pEmfPlusBrush->oColor = pEmfPlusBrush->arGradientColors.back() .first;
|
||||
pEmfPlusBrush->oColorBack = pEmfPlusBrush->arGradientColors.front().first;
|
||||
}
|
||||
}
|
||||
|
||||
@ -775,7 +774,7 @@ namespace MetaFile
|
||||
|
||||
switch (nEndCap)
|
||||
{
|
||||
case 0: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_FLAT; break;
|
||||
case 0: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_FLAT; break;
|
||||
case 1: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_SQUARE; break;
|
||||
case 2: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_ROUND; break;
|
||||
}
|
||||
@ -788,7 +787,7 @@ namespace MetaFile
|
||||
|
||||
switch (nJoin)
|
||||
{
|
||||
case 0: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_MITER; break;
|
||||
case 0: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_MITER; break;
|
||||
case 1: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_BEVEL; break;
|
||||
case 2: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_ENDCAP_ROUND; break;
|
||||
}
|
||||
@ -874,7 +873,7 @@ namespace MetaFile
|
||||
m_oStream >> *pLineCapData;
|
||||
|
||||
if (CustomLineCapDataFillPath == pLineCapData->unCustomLineCapDataFlags ||
|
||||
CustomLineCapDataLinePath == pLineCapData->unCustomLineCapDataFlags)
|
||||
CustomLineCapDataLinePath == pLineCapData->unCustomLineCapDataFlags)
|
||||
{
|
||||
m_oStream.Skip(4); // FillPathLength or LinePathLength
|
||||
pLineCapData->pPath = ReadPath();
|
||||
@ -1346,7 +1345,7 @@ namespace MetaFile
|
||||
if (oImageAttributes.eWrapMode == WrapModeClamp)
|
||||
{
|
||||
if (oRectangle.dX < 0 || oRectangle.dX < 0 ||
|
||||
oRectangle.dX >= oRectangle.dWidth || oRectangle.dY >= oRectangle.dHeight)
|
||||
oRectangle.dX >= oRectangle.dWidth || oRectangle.dY >= oRectangle.dHeight)
|
||||
return oImageAttributes.oClampColor;
|
||||
|
||||
}
|
||||
@ -1544,14 +1543,10 @@ namespace MetaFile
|
||||
case MetafileDataTypeEmf:
|
||||
case MetafileDataTypeEmfPlusOnly:
|
||||
case MetafileDataTypeEmfPlusDual:
|
||||
{
|
||||
return DrawMetafile<CEmfParser>(pBuffer, unSizeBuffer, oSrcRect, arPoints);
|
||||
}
|
||||
case MetafileDataTypeWmf:
|
||||
case MetafileDataTypeWmfPlaceable:
|
||||
{
|
||||
return DrawMetafile<CWmfParser>(pBuffer, unSizeBuffer, oSrcRect, arPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1664,7 +1659,7 @@ namespace MetaFile
|
||||
BYTE* pNewBuffer = GetClipedImage(pPixels, nWidth, nHeight, oClipRect, nW, nH);
|
||||
|
||||
m_pInterpretator->DrawBitmap(arPoints[0].X, arPoints[0].Y, arPoints[1].X - arPoints[0].X - m_pDC->GetPixelWidth(), arPoints[2].Y - arPoints[0].Y - m_pDC->GetPixelHeight(),
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pPixels, nW, nH);
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pPixels, nW, nH);
|
||||
|
||||
RELEASEINTERFACE(pGrRenderer);
|
||||
RELEASEARRAYOBJECTS(pNewBuffer);
|
||||
@ -1743,7 +1738,7 @@ namespace MetaFile
|
||||
BYTE* pNewBuffer = GetClipedImage(pBytes, unWidth, unHeight, oClipRect, nW, nH);
|
||||
|
||||
m_pInterpretator->DrawBitmap(arPoints[0].X, arPoints[0].Y, arPoints[1].X - arPoints[0].X, arPoints[2].Y - arPoints[0].Y,
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pBytes, nW, nH);
|
||||
(NULL != pNewBuffer) ? pNewBuffer : pBytes, nW, nH);
|
||||
|
||||
if (!bExternalBuffer)
|
||||
RELEASEARRAYOBJECTS(pBytes);
|
||||
@ -1806,17 +1801,15 @@ namespace MetaFile
|
||||
m_pDC->SetPen(pPen);
|
||||
|
||||
if (AD_COUNTERCLOCKWISE != m_pDC->GetArcDirection())
|
||||
{
|
||||
dSweepAngle = dSweepAngle - 360;
|
||||
}
|
||||
|
||||
TEmfPlusRectF oConvertedRect = GetConvertedRectangle(oRect);
|
||||
|
||||
MoveTo(oConvertedRect.dX, oConvertedRect.dY);
|
||||
ArcTo(oConvertedRect.dX, oConvertedRect.dY,
|
||||
oConvertedRect.dX + oConvertedRect.dWidth,
|
||||
oConvertedRect.dY + oConvertedRect.dHeight,
|
||||
dStartAngle, dSweepAngle);
|
||||
oConvertedRect.dX + oConvertedRect.dWidth,
|
||||
oConvertedRect.dY + oConvertedRect.dHeight,
|
||||
dStartAngle, dSweepAngle);
|
||||
DrawPath(true, false);
|
||||
|
||||
if (NULL != m_pInterpretator)
|
||||
@ -2293,13 +2286,13 @@ namespace MetaFile
|
||||
|
||||
if (NULL != m_pInterpretator)
|
||||
{
|
||||
CPathConverter oPathConverter;
|
||||
CPath oNewPath, oLineCapPath;
|
||||
|
||||
oPathConverter.GetUpdatedPath(oNewPath, oLineCapPath, *pPath, *pEmfPlusPen);
|
||||
|
||||
if (InterpretatorType::Render == m_pInterpretator->GetType())
|
||||
{
|
||||
CPathConverter oPathConverter;
|
||||
CPath oNewPath, oLineCapPath;
|
||||
|
||||
oPathConverter.GetUpdatedPath(oNewPath, oLineCapPath, *pPath, *pEmfPlusPen);
|
||||
|
||||
oNewPath.DrawOn(m_pInterpretator, true, false);
|
||||
oLineCapPath.DrawOn(m_pInterpretator, false, true);
|
||||
}
|
||||
@ -2836,7 +2829,7 @@ namespace MetaFile
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_FILLREGION(unsigned short unShFlags)
|
||||
{
|
||||
short shOgjectIndex = ExpressValue(unShFlags, 0, 7);
|
||||
// short shOgjectIndex = ExpressValue(unShFlags, 0, 7);
|
||||
unsigned int unBrushId;
|
||||
|
||||
m_oStream >> unBrushId;
|
||||
@ -2995,34 +2988,34 @@ namespace MetaFile
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETANTIALIASMODE(unsigned short unShFlags)
|
||||
{
|
||||
short shSmoothingMode = ExpressValue(unShFlags, 1, 7);
|
||||
// short shSmoothingMode = ExpressValue(unShFlags, 1, 7);
|
||||
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETCOMPOSITINGMODE(unsigned short unShFlags)
|
||||
{
|
||||
short shCompositingMode = ExpressValue(unShFlags, 0, 7);
|
||||
// short shCompositingMode = ExpressValue(unShFlags, 0, 7);
|
||||
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETCOMPOSITINGQUALITY(unsigned short unShFlags)
|
||||
{
|
||||
short shCompositingQuality = ExpressValue(unShFlags, 0, 7);
|
||||
// short shCompositingQuality = ExpressValue(unShFlags, 0, 7);
|
||||
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETINTERPOLATIONMODE(unsigned short unShFlags)
|
||||
{
|
||||
short shInterpolationMode = ExpressValue(unShFlags, 0, 7);
|
||||
// short shInterpolationMode = ExpressValue(unShFlags, 0, 7);
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETPIXELOFFSETMODE(unsigned short unShFlags)
|
||||
{
|
||||
short shPixelOffsetMode = ExpressValue(unShFlags, 0, 7);
|
||||
// short shPixelOffsetMode = ExpressValue(unShFlags, 0, 7);
|
||||
|
||||
//TODO: реализовать
|
||||
}
|
||||
@ -3039,20 +3032,20 @@ namespace MetaFile
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETTEXTCONTRAST(unsigned short unShFlags)
|
||||
{
|
||||
short shTextContrast = ExpressValue(unShFlags, 0, 11);
|
||||
// short shTextContrast = ExpressValue(unShFlags, 0, 11);
|
||||
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMRPLUS_SETTEXTRENDERINGHINT(unsigned short unShFlags)
|
||||
{
|
||||
short shTextRenderingHint = ExpressValue(unShFlags, 0, 7);
|
||||
// short shTextRenderingHint = ExpressValue(unShFlags, 0, 7);
|
||||
//TODO: реализовать
|
||||
}
|
||||
|
||||
void CEmfPlusParser::Read_EMFPLUS_BEGINCONTAINER(unsigned short unShFlags)
|
||||
{
|
||||
short shPageUnit = ExpressValue(unShFlags, 8, 15);
|
||||
// short shPageUnit = ExpressValue(unShFlags, 8, 15);
|
||||
TEmfPlusRectF oDestRect, oSrcRect;
|
||||
unsigned int unStackIndex;
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
#ifndef CEMFPLUSPARSER_H
|
||||
#define CEMFPLUSPARSER_H
|
||||
|
||||
//#include "../../Common/MetaFileUtils.h"
|
||||
//#include "../../Common/MetaFile.h"
|
||||
#include "../EmfPlusObjects.h"
|
||||
#include "CEmfParserBase.h"
|
||||
#include "../EmfPlusTypes.h"
|
||||
|
||||
@ -106,6 +106,16 @@ namespace MetaFile
|
||||
chRed = oARGB.chRed;
|
||||
chAlpha = oARGB.chAlpha;
|
||||
}
|
||||
|
||||
TEmfPlusARGB& operator=(const TEmfPlusARGB& oARGB)
|
||||
{
|
||||
chBlue = oARGB.chBlue;
|
||||
chGreen = oARGB.chGreen;
|
||||
chRed = oARGB.chRed;
|
||||
chAlpha = oARGB.chAlpha;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct TGUID
|
||||
|
||||
@ -611,6 +611,9 @@ namespace MetaFile
|
||||
|
||||
void CMetaFile::ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight)
|
||||
{
|
||||
if (nWidth == 0 || nHeight == 0)
|
||||
return;
|
||||
|
||||
NSGraphics::IGraphicsRenderer* pGrRenderer = NSGraphics::Create();
|
||||
|
||||
NSFonts::IFontManager* pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
|
||||
@ -266,6 +266,7 @@ void CSvmFile::Read_META_LINE()
|
||||
{
|
||||
case LINE_SOLID: last_pen->PenStyle = PS_SOLID ; break;
|
||||
case LINE_DASH: last_pen->PenStyle = PS_DASH ; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,6 +324,7 @@ void CSvmFile::Read_META_POLYLINE()
|
||||
{
|
||||
case LINE_SOLID: last_pen->PenStyle = PS_SOLID ; break;
|
||||
case LINE_DASH: last_pen->PenStyle = PS_DASH ; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (last_pen->Width < 1)
|
||||
|
||||
@ -153,7 +153,13 @@ namespace MetaFile
|
||||
|
||||
const std::wstring wsText{ConvertToUnicode(pString, (long)shStringLength, (NULL != pFont) ? pFont->GetCharSet() : DEFAULT_CHARSET)};
|
||||
|
||||
TPointD oScale((m_pParser->IsWindowFlippedX()) ? -1 : 1, (m_pParser->IsWindowFlippedY()) ? -1 : 1);
|
||||
TPointD oScale(1, 1);
|
||||
|
||||
if (NULL != m_pParser)
|
||||
{
|
||||
oScale.X = m_pParser->IsWindowFlippedX() ? -1 : 1;
|
||||
oScale.Y = m_pParser->IsWindowFlippedY() ? -1 : 1;
|
||||
}
|
||||
|
||||
std::vector<double> arDx(0);
|
||||
|
||||
|
||||
@ -298,7 +298,7 @@ namespace MetaFile
|
||||
m_oStream >> oBitmap;
|
||||
|
||||
unsigned int unRecordSizeDWORD = m_unRecordSize >> 1;
|
||||
unsigned int unValue = (META_STRETCHBLT >> 8) + 3;
|
||||
// unsigned int unValue = (META_STRETCHBLT >> 8) + 3;
|
||||
|
||||
if (unRecordSizeDWORD == ((META_STRETCHBLT >> 8) + 3))
|
||||
{
|
||||
|
||||
@ -196,7 +196,7 @@ namespace MetaFile
|
||||
if (InterpretatorType::Svg == oInterpretatorType)
|
||||
{
|
||||
CWmfInterpretatorSvg *pWmfInterpretatorSvg = new CWmfInterpretatorSvg(this, unWidth, unHeight);
|
||||
pWmfInterpretatorSvg->SetShapeRendering(EShapeRendering::CrispEdges);
|
||||
pWmfInterpretatorSvg->SetShapeRendering(EShapeRendering::OptimizeSpeed);
|
||||
m_pInterpretator = pWmfInterpretatorSvg;
|
||||
}
|
||||
}
|
||||
@ -241,10 +241,10 @@ namespace MetaFile
|
||||
{
|
||||
const double dKoef = 96. / (double)m_oPlaceable.ushInch;
|
||||
|
||||
m_oDCRect.Left = std::round(m_oDCRect.Left * dKoef);
|
||||
m_oDCRect.Top = std::round(m_oDCRect.Top * dKoef);
|
||||
m_oDCRect.Right = std::round(m_oDCRect.Right * dKoef);
|
||||
m_oDCRect.Bottom = std::round(m_oDCRect.Bottom * dKoef);
|
||||
m_oDCRect.Left = static_cast<int>(std::round(m_oDCRect.Left * dKoef));
|
||||
m_oDCRect.Top = static_cast<int>(std::round(m_oDCRect.Top * dKoef));
|
||||
m_oDCRect.Right = static_cast<int>(std::round(m_oDCRect.Right * dKoef));
|
||||
m_oDCRect.Bottom = static_cast<int>(std::round(m_oDCRect.Bottom * dKoef));
|
||||
}
|
||||
|
||||
// Иногда m_oPlaceable.BoundingBox задается нулевой ширины и высоты
|
||||
@ -292,6 +292,16 @@ namespace MetaFile
|
||||
m_pDC->SetCurPos(shX, shY);
|
||||
}
|
||||
|
||||
void CWmfParserBase::MoveToD(double dX, double dY)
|
||||
{
|
||||
if (NULL != m_pInterpretator)
|
||||
m_pInterpretator->MoveTo(dX, dY);
|
||||
else
|
||||
RegisterPoint(static_cast<short>(dX), static_cast<short>(dY));
|
||||
|
||||
m_pDC->SetCurPos(static_cast<short>(dX), static_cast<short>(dY));
|
||||
}
|
||||
|
||||
void CWmfParserBase::LineTo(short shX, short shY)
|
||||
{
|
||||
if (NULL != m_pInterpretator)
|
||||
@ -396,7 +406,7 @@ namespace MetaFile
|
||||
NSFonts::IFontManager* pFontManager = GetFontManager();
|
||||
if (pFontManager)
|
||||
{
|
||||
int lLogicalFontHeight = pFont->GetHeight();
|
||||
int lLogicalFontHeight = static_cast<int>(pFont->GetHeight());
|
||||
if (lLogicalFontHeight < 0)
|
||||
lLogicalFontHeight = -lLogicalFontHeight;
|
||||
if (lLogicalFontHeight < 0.01)
|
||||
@ -444,8 +454,8 @@ namespace MetaFile
|
||||
{
|
||||
pFontManager->LoadString1(wsText, 0, 0);
|
||||
TBBox oBox = pFontManager->MeasureString2();
|
||||
fL = (float)(oBox.fMinX);
|
||||
fW = (float)(oBox.fMaxX - oBox.fMinX);
|
||||
fL = static_cast<float>(oBox.fMinX);
|
||||
fW = static_cast<float>(oBox.fMaxX - oBox.fMinX);
|
||||
}
|
||||
|
||||
pFontManager->LoadString1(wsText, 0, 0);
|
||||
@ -520,7 +530,7 @@ namespace MetaFile
|
||||
}
|
||||
else
|
||||
{
|
||||
int lLogicalFontHeight = pFont->GetHeight();
|
||||
int lLogicalFontHeight = static_cast<int>(pFont->GetHeight());
|
||||
if (lLogicalFontHeight < 0)
|
||||
lLogicalFontHeight = -lLogicalFontHeight;
|
||||
if (lLogicalFontHeight < 0.01)
|
||||
@ -548,7 +558,7 @@ namespace MetaFile
|
||||
fW = (float)(dFontHeight * wsText.length());
|
||||
}
|
||||
|
||||
fH = dFontHeight * 1.2;
|
||||
fH = (float)dFontHeight * 1.2f;
|
||||
|
||||
double dTheta = -((((double)pFont->GetEscapement()) / 10) * 3.14159265358979323846 / 180);
|
||||
double dCosTheta = (float)cos(dTheta);
|
||||
@ -724,17 +734,17 @@ namespace MetaFile
|
||||
oNewRect.Top < 0 || oNewRect.Bottom < 0)
|
||||
return NULL;
|
||||
|
||||
if (unHeight < (oNewRect.Bottom - oNewRect.Top))
|
||||
oNewRect.Bottom = oNewRect.Top + unWidth;
|
||||
if (unHeight < static_cast<unsigned int>(std::abs(oNewRect.Bottom - oNewRect.Top)))
|
||||
oNewRect.Bottom = oNewRect.Top + unHeight;
|
||||
|
||||
if (unWidth < (oNewRect.Right - oNewRect.Left))
|
||||
if (unWidth < static_cast<unsigned int>(std::abs(oNewRect.Right - oNewRect.Left)))
|
||||
oNewRect.Right = oNewRect.Left + unWidth;
|
||||
|
||||
if (unHeight == (oNewRect.Bottom - oNewRect.Top) &&
|
||||
unWidth == (oNewRect.Right - oNewRect.Left))
|
||||
return NULL;
|
||||
|
||||
int nBeginX, nBeginY, nEndX, nEndY;
|
||||
ULONG nBeginX, nBeginY, nEndX, nEndY;
|
||||
|
||||
nBeginX = (std::min)(oNewRect.Left, oNewRect.Right);
|
||||
nBeginY = (std::min)(oNewRect.Top, oNewRect.Bottom);
|
||||
@ -924,7 +934,7 @@ namespace MetaFile
|
||||
|
||||
double dSweepAngle = GetSweepAngle(dStartAngle, dEndAngle);
|
||||
|
||||
MoveTo(dX1, dY1);
|
||||
MoveToD(dX1, dY1);
|
||||
ArcTo(shLeft, shTop, shRight, shBottom, dStartAngle, dSweepAngle);
|
||||
DrawPath(true, false);
|
||||
}
|
||||
|
||||
@ -188,6 +188,7 @@ namespace MetaFile
|
||||
inline double GetSweepAngle(const double& dStartAngle, const double& dEndAngle) const;
|
||||
|
||||
void MoveTo(short shX, short shY);
|
||||
void MoveToD(double dX, double dY);
|
||||
void LineTo(short shX, short shY);
|
||||
void ArcTo(short shL, short shT, short shR, short shB, double dStart, double dSweep);
|
||||
void ClosePath();
|
||||
|
||||
@ -85,6 +85,7 @@ namespace XmlUtils
|
||||
bool FromString (const wchar_t* sXml);
|
||||
bool FromString (const std::wstring& sXml);
|
||||
bool FromStringA(const std::string& sXml);
|
||||
bool FromStringA(const char* sXml, int size);
|
||||
|
||||
bool MoveToStart();
|
||||
|
||||
|
||||
@ -111,6 +111,10 @@ namespace XmlUtils
|
||||
{
|
||||
return m_pInternal->FromStringA(sXml);
|
||||
}
|
||||
bool CXmlLiteReader::FromStringA(const char* sXml, int size)
|
||||
{
|
||||
return m_pInternal->FromStringA(sXml, size);
|
||||
}
|
||||
bool CXmlLiteReader::MoveToStart()
|
||||
{
|
||||
return m_pInternal->MoveToStart();
|
||||
|
||||
@ -214,7 +214,15 @@ namespace XmlUtils
|
||||
|
||||
return true;
|
||||
}
|
||||
inline bool FromStringA(const char* sXml, int size)
|
||||
{
|
||||
m_lStreamLen = size;
|
||||
m_pStream = new BYTE[m_lStreamLen];
|
||||
memcpy(m_pStream, sXml, m_lStreamLen);
|
||||
reader = xmlReaderForMemory((char*)m_pStream, m_lStreamLen, NULL, NULL, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
inline bool MoveToStart()
|
||||
{
|
||||
if (NULL != reader)
|
||||
|
||||
@ -121,3 +121,15 @@ BYTE* CDjVuFile::GetLinks (int nPageIndex)
|
||||
return m_pImplementation->GetPageLinks(nPageIndex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned char* CDjVuFile::ConvertToPixels(
|
||||
int nPageIndex,
|
||||
int nRasterW, int nRasterH, bool bIsFlip,
|
||||
NSFonts::IFontManager* pFonts,
|
||||
int nBackgroundColor, bool bIsDarkMode,
|
||||
int nBackgroundOpacity)
|
||||
{
|
||||
if (m_pImplementation)
|
||||
return m_pImplementation->ConvertToPixels(nPageIndex, nRasterW, nRasterH, !bIsFlip);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -76,4 +76,11 @@ public:
|
||||
|
||||
virtual BYTE* GetStructure();
|
||||
virtual BYTE* GetLinks (int nPageIndex);
|
||||
|
||||
virtual unsigned char* ConvertToPixels(
|
||||
int nPageIndex,
|
||||
int nRasterW, int nRasterH, bool bIsFlip = false,
|
||||
NSFonts::IFontManager* pFonts = NULL,
|
||||
int nBackgroundColor = 0xFFFFFF, bool bIsDarkMode = false,
|
||||
int nBackgroundOpacity = 0xFF);
|
||||
};
|
||||
|
||||
@ -247,18 +247,11 @@ void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRenderer, int nPag
|
||||
long lRendererType = c_nUnknownRenderer;
|
||||
pRenderer->get_Type(&lRendererType);
|
||||
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
if (c_nPDFWriter == lRendererType)
|
||||
{
|
||||
XmlUtils::CXmlNode oText = ParseText(pPage);
|
||||
CreatePdfFrame(pRenderer, pPage, nPageIndex, oText);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
XmlUtils::CXmlNode oText = ParseText(pPage);
|
||||
CreateFrame(pRenderer, pPage, nPageIndex, oText);
|
||||
}
|
||||
XmlUtils::CXmlNode text;
|
||||
if (c_nPDFWriter == lRendererType || c_nHtmlRendrererText == lRendererType)
|
||||
text = ParseText(pPage);
|
||||
|
||||
CreateFrame(pRenderer, pPage, nPageIndex, text);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -463,9 +456,14 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
}
|
||||
|
||||
int nDpi = pPage->get_dpi();
|
||||
|
||||
double dPixToMM = 25.4;
|
||||
|
||||
if (c_nHtmlRendrererText == lRendererType && text.IsValid())
|
||||
{
|
||||
TextToRenderer(pRenderer, text, dPixToMM / nDpi);
|
||||
return;
|
||||
}
|
||||
|
||||
double dRendDpiX = 0;
|
||||
double dRendDpiY = 0;
|
||||
|
||||
@ -491,150 +489,22 @@ void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& p
|
||||
LONG lImageWidth = (LONG)(dRendDpiX * dRendWidth / dPixToMM);
|
||||
LONG lImageHeight = (LONG)(dRendDpiY * dRendHeight / dPixToMM);
|
||||
|
||||
BYTE* pBufferDst = new BYTE[4 * lImageHeight * lImageWidth];
|
||||
BYTE* pBufferDst = this->ConvertToPixels(pPage, lImageWidth, lImageHeight, false);
|
||||
|
||||
if (!pBufferDst)
|
||||
return;
|
||||
|
||||
bool bIsInit = false;
|
||||
|
||||
Aggplus::CImage oImage;
|
||||
oImage.Create(pBufferDst, lImageWidth, lImageHeight, 4 * lImageWidth);
|
||||
if (pPage->is_legal_photo() || pPage->is_legal_compound())
|
||||
{
|
||||
bIsInit = true;
|
||||
GRect oRectAll(0, 0, lImageWidth, lImageHeight);
|
||||
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
|
||||
|
||||
BYTE* pBuffer = pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
GPixel* pLine = pImage->operator [](j);
|
||||
|
||||
for (int i = 0; i < lImageWidth; ++i, pBuffer += 4, ++pLine)
|
||||
{
|
||||
pBuffer[0] = pLine->b;
|
||||
pBuffer[1] = pLine->g;
|
||||
pBuffer[2] = pLine->r;
|
||||
pBuffer[3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pPage->is_legal_bilevel())
|
||||
{
|
||||
bIsInit = true;
|
||||
GRect oRectAll(0, 0, lImageWidth, lImageHeight);
|
||||
GP<GBitmap> pBitmap = pPage->get_bitmap(oRectAll, oRectAll, 4);
|
||||
int nPaletteEntries = pBitmap->get_grays();
|
||||
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
|
||||
// Create palette for the bitmap
|
||||
int color = 0xff0000;
|
||||
int decrement = color / (nPaletteEntries - 1);
|
||||
for (int i = 0; i < nPaletteEntries; ++i)
|
||||
{
|
||||
BYTE level = (BYTE)(color >> 16);
|
||||
palette[i] = (0xFF000000 | level << 16 | level << 8 | level);
|
||||
color -= decrement;
|
||||
}
|
||||
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
BYTE* pLine = pBitmap->operator [](j);
|
||||
|
||||
for (int i = 0; i < lImageWidth; ++i, ++pBuffer, ++pLine)
|
||||
{
|
||||
if (*pLine < nPaletteEntries)
|
||||
{
|
||||
*pBuffer = palette[*pLine];
|
||||
}
|
||||
else
|
||||
{
|
||||
*pBuffer = palette[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(palette);
|
||||
}
|
||||
else
|
||||
{
|
||||
// белый фрейм??
|
||||
//memset(pBufferDst, 0xFF, 4 * lImageWidth * lImageHeight);
|
||||
GRect oRectAll(0, 0, lImageWidth, lImageHeight);
|
||||
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
|
||||
|
||||
if (NULL != pImage)
|
||||
{
|
||||
bIsInit = true;
|
||||
BYTE* pBuffer = pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
GPixel* pLine = pImage->operator [](j);
|
||||
|
||||
for (int i = 0; i < lImageWidth; ++i, pBuffer += 4, ++pLine)
|
||||
{
|
||||
pBuffer[0] = pLine->b;
|
||||
pBuffer[1] = pLine->g;
|
||||
pBuffer[2] = pLine->r;
|
||||
pBuffer[3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GP<GBitmap> pBitmap = pPage->get_bitmap(oRectAll, oRectAll, 4);
|
||||
|
||||
if (NULL != pBitmap)
|
||||
{
|
||||
bIsInit = true;
|
||||
int nPaletteEntries = pBitmap->get_grays();
|
||||
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
|
||||
// Create palette for the bitmap
|
||||
int color = 0xff0000;
|
||||
int decrement = color / (nPaletteEntries - 1);
|
||||
for (int i = 0; i < nPaletteEntries; ++i)
|
||||
{
|
||||
BYTE level = (BYTE)(color >> 16);
|
||||
palette[i] = (0xFF000000 | level << 16 | level << 8 | level);
|
||||
color -= decrement;
|
||||
}
|
||||
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
for (int j = lImageHeight - 1; j >= 0; --j)
|
||||
{
|
||||
BYTE* pLine = pBitmap->operator [](j);
|
||||
|
||||
for (int i = 0; i < lImageWidth; ++i, ++pBuffer, ++pLine)
|
||||
{
|
||||
if (*pLine < nPaletteEntries)
|
||||
{
|
||||
*pBuffer = palette[*pLine];
|
||||
}
|
||||
else
|
||||
{
|
||||
*pBuffer = palette[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(palette);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pRenderer->BeginCommand(c_nPageType);
|
||||
|
||||
if (c_nGrRenderer != lRendererType && c_nHtmlRendrerer != lRendererType && c_nHtmlRendrerer2 != lRendererType)
|
||||
if (text.IsValid())
|
||||
{
|
||||
TextToRenderer(pRenderer, text, dPixToMM / nDpi);
|
||||
}
|
||||
|
||||
if (bIsInit)
|
||||
pRenderer->DrawImage((IGrObject*)&oImage, 0, 0, dRendWidth, dRendHeight);
|
||||
pRenderer->DrawImage((IGrObject*)&oImage, 0, 0, dRendWidth, dRendHeight);
|
||||
pRenderer->EndCommand(c_nPageType);
|
||||
}
|
||||
void CDjVuFileImplementation::CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>& pPage, int nPageIndex, XmlUtils::CXmlNode& oText)
|
||||
@ -849,6 +719,104 @@ void CDjVuFileImplementation::CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>
|
||||
pRenderer->EndCommand(c_nPageType);
|
||||
}
|
||||
|
||||
unsigned char* CDjVuFileImplementation::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip)
|
||||
{
|
||||
try
|
||||
{
|
||||
GP<DjVuImage> pPage = m_pDoc->get_page(nPageIndex);
|
||||
//pPage->wait_for_complete_decode();
|
||||
pPage->set_rotate(0);
|
||||
return ConvertToPixels(pPage, nRasterW, nRasterH, bIsFlip);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned char* CDjVuFileImplementation::ConvertToPixels(GP<DjVuImage>& pPage, int nImageW, int nImageH, bool bFlip)
|
||||
{
|
||||
BYTE* pBufferDst = NULL;
|
||||
|
||||
auto processPixmap = [&](GP<GPixmap> pImage, bool bFlip = false)
|
||||
{
|
||||
pBufferDst = new BYTE[4 * nImageW * nImageH];
|
||||
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
for (int j = 0; j < nImageH; ++j)
|
||||
{
|
||||
int nRow = bFlip ? j : (nImageH - 1 - j);
|
||||
GPixel* pLine = pImage->operator[](nRow);
|
||||
for (int i = 0; i < nImageW; ++i)
|
||||
{
|
||||
*pBuffer++ = 0xFF000000 | pLine->r << 16 | pLine->g << 8 | pLine->b;
|
||||
++pLine;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto processBitmap = [&](GP<GBitmap> pBitmap, bool bFlip = false)
|
||||
{
|
||||
pBufferDst = new BYTE[4 * nImageW * nImageH];
|
||||
|
||||
int nPaletteEntries = pBitmap->get_grays();
|
||||
unsigned int* palette = new unsigned int[nPaletteEntries];
|
||||
int color = 0xFF0000;
|
||||
int decrement = color / (nPaletteEntries - 1);
|
||||
for (int i = 0; i < nPaletteEntries; ++i)
|
||||
{
|
||||
BYTE level = (BYTE)(color >> 16);
|
||||
palette[i] = (0xFF000000 | level << 16 | level << 8 | level);
|
||||
color -= decrement;
|
||||
}
|
||||
|
||||
unsigned int* pBuffer = (unsigned int*)pBufferDst;
|
||||
for (int j = 0; j < nImageH; ++j)
|
||||
{
|
||||
int nRow = bFlip ? j : (nImageH - 1 - j);
|
||||
BYTE* pLine = pBitmap->operator[](nRow);
|
||||
for (int i = 0; i < nImageW; ++i)
|
||||
{
|
||||
*pBuffer++ = palette[*pLine < nPaletteEntries ? *pLine : 0];
|
||||
++pLine;
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(palette);
|
||||
};
|
||||
|
||||
GRect oRectAll(0, 0, nImageW, nImageH);
|
||||
|
||||
if (pPage->is_legal_photo() || pPage->is_legal_compound())
|
||||
{
|
||||
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
|
||||
processPixmap(pImage, bFlip);
|
||||
}
|
||||
else if (pPage->is_legal_bilevel())
|
||||
{
|
||||
GP<GBitmap> pBitmap = pPage->get_bitmap(oRectAll, oRectAll, 4);
|
||||
processBitmap(pBitmap, bFlip);
|
||||
}
|
||||
else
|
||||
{
|
||||
GP<GPixmap> pImage = pPage->get_pixmap(oRectAll, oRectAll);
|
||||
if (pImage)
|
||||
{
|
||||
processPixmap(pImage, bFlip);
|
||||
}
|
||||
else
|
||||
{
|
||||
GP<GBitmap> pBitmap = pPage->get_bitmap(oRectAll, oRectAll, 4);
|
||||
if (pBitmap)
|
||||
{
|
||||
processBitmap(pBitmap, bFlip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pBufferDst;
|
||||
}
|
||||
|
||||
XmlUtils::CXmlNode CDjVuFileImplementation::ParseText(GP<DjVuImage> pPage)
|
||||
{
|
||||
XmlUtils::CXmlNode paragraph;
|
||||
|
||||
@ -79,8 +79,12 @@ public:
|
||||
BYTE* GetPageGlyphs(int nPageIndex);
|
||||
BYTE* GetPageLinks (int nPageIndex);
|
||||
|
||||
unsigned char* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip = false);
|
||||
|
||||
private:
|
||||
|
||||
unsigned char* ConvertToPixels(GP<DjVuImage>& pPage, int nRasterW, int nRasterH, bool bIsFlip = false);
|
||||
|
||||
void CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, int nPage, XmlUtils::CXmlNode& oText);
|
||||
void CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, int nPage, XmlUtils::CXmlNode& oText);
|
||||
XmlUtils::CXmlNode ParseText(GP<DjVuImage> pPage);
|
||||
|
||||
@ -1943,15 +1943,15 @@ void DjVuDocument::ReadPageInfo(int nPage, int& width, int& height, int& nDpi)
|
||||
bHasIW44 = true;
|
||||
|
||||
// Get image dimensions and resolution from bitmap chunk
|
||||
UINT serial = chunk_stream->read8();
|
||||
UINT slices = chunk_stream->read8();
|
||||
UINT major = chunk_stream->read8();
|
||||
UINT minor = chunk_stream->read8();
|
||||
unsigned int serial = chunk_stream->read8();
|
||||
unsigned int slices = chunk_stream->read8();
|
||||
unsigned int major = chunk_stream->read8();
|
||||
unsigned int minor = chunk_stream->read8();
|
||||
|
||||
UINT xhi = chunk_stream->read8();
|
||||
UINT xlo = chunk_stream->read8();
|
||||
UINT yhi = chunk_stream->read8();
|
||||
UINT ylo = chunk_stream->read8();
|
||||
unsigned int xhi = chunk_stream->read8();
|
||||
unsigned int xlo = chunk_stream->read8();
|
||||
unsigned int yhi = chunk_stream->read8();
|
||||
unsigned int ylo = chunk_stream->read8();
|
||||
|
||||
width = (xhi << 8) | xlo;
|
||||
height = (yhi << 8) | ylo;
|
||||
|
||||
@ -16,7 +16,9 @@ LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
|
||||
|
||||
ADD_DEPENDENCY(kernel, UnicodeConverter, graphics)
|
||||
|
||||
DEFINES += HWPFILE_USE_DYNAMIC_LIBRARY
|
||||
DEFINES += HWPFILE_USE_DYNAMIC_LIBRARY \
|
||||
CRYPTOPP_DISABLE_ASM
|
||||
|
||||
|
||||
SOURCES += \
|
||||
HWPFile.cpp \
|
||||
|
||||
@ -19,6 +19,7 @@ public:
|
||||
};
|
||||
|
||||
int ConvertWidthToHWP(const std::wstring& wsValue);
|
||||
int ConvertHexToInt(const std::string& wsValue, const int& _default = 0x00000000);
|
||||
}
|
||||
|
||||
#endif // XMLNODEH_H
|
||||
|
||||
@ -17,20 +17,7 @@ bool CXMLNode::GetAttributeBool(const std::wstring& wsName)
|
||||
|
||||
int CXMLNode::GetAttributeColor(const std::wstring& wsName, const int& _default)
|
||||
{
|
||||
std::wstring sColor = XmlUtils::CXmlNode::GetAttribute(wsName);
|
||||
|
||||
if (L"none" != sColor)
|
||||
{
|
||||
if (L'#' == sColor.front())
|
||||
sColor.erase(0, 1);
|
||||
|
||||
if (sColor.length() < 6)
|
||||
return _default;
|
||||
|
||||
return std::stoi(sColor.substr(0, 6), nullptr, 16);
|
||||
}
|
||||
|
||||
return _default;
|
||||
return ConvertHexToInt(XmlUtils::CXmlNode::GetAttributeA(wsName), _default);
|
||||
}
|
||||
|
||||
CXMLNode CXMLNode::GetChild(const std::wstring& wsName)
|
||||
@ -98,4 +85,36 @@ int ConvertWidthToHWP(const std::wstring& wsValue)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ConvertHexToInt(const std::string& wsValue, const int& _default)
|
||||
{
|
||||
if (wsValue.empty() || "none" == wsValue)
|
||||
return _default;
|
||||
|
||||
std::string::const_iterator itStart = wsValue.cbegin();
|
||||
|
||||
if ('#' == *itStart)
|
||||
++itStart;
|
||||
|
||||
if (wsValue.cend() - itStart < 6)
|
||||
return _default;
|
||||
|
||||
itStart = wsValue.cend() - 6;
|
||||
|
||||
int nResult = 0;
|
||||
|
||||
while (itStart != wsValue.cend())
|
||||
{
|
||||
if ('0' <= *itStart && *itStart <= '9')
|
||||
nResult = (nResult << 4) | (*itStart++ - '0');
|
||||
else if ('A' <= *itStart && *itStart <= 'F')
|
||||
nResult = (nResult << 4) | (*itStart++ - 'A' + 10);
|
||||
else if ('a' <= *itStart && *itStart <= 'f')
|
||||
nResult = (nResult << 4) | (*itStart++ - 'a' + 10);
|
||||
else
|
||||
return _default;
|
||||
}
|
||||
|
||||
return nResult;
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,12 +62,7 @@ EColorFillPattern GetColorFillPattern(int nPattern)
|
||||
void TBorder::ReadFromNode(CXMLNode& oNode)
|
||||
{
|
||||
m_eStyle = GetLineStyle2(oNode.GetAttribute(L"type"));
|
||||
|
||||
HWP_STRING sColor = std::regex_replace(oNode.GetAttribute(L"color"), std::wregex(L"^#([0-9A-Fa-f]+)$"), L"$1");
|
||||
|
||||
if (L"none" != sColor)
|
||||
m_nColor = std::stoi(sColor, 0, 16);
|
||||
|
||||
m_nColor = oNode.GetAttributeColor(L"color");
|
||||
m_chWidth = (HWP_BYTE)ConvertWidthToHWP(oNode.GetAttribute(L"width"));
|
||||
}
|
||||
|
||||
@ -199,7 +194,7 @@ void CFill::ReadGradation(CXMLNode& oNode)
|
||||
m_arColors.resize(arChilds.size());
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < arChilds.size(); ++unIndex)
|
||||
m_arColors[unIndex] = std::stoi(std::regex_replace(arChilds[unIndex].GetText(), std::wregex(L"\\D"), L""), 0, 16);
|
||||
m_arColors[unIndex] = ConvertHexToInt(arChilds[unIndex].GetTextA());
|
||||
}
|
||||
|
||||
void CFill::ReadImgBrush(CXMLNode& oNode)
|
||||
|
||||
@ -48,8 +48,16 @@ CHWPRecordBullet::CHWPRecordBullet(CHWPDocInfo& oDocInfo, int nTagNum, int nLeve
|
||||
CHWPRecordBullet::CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_BULLET, 0, 0), m_pParent(&oDocInfo)
|
||||
{
|
||||
m_chBulletChar = oNode.GetAttribute(L"char").at(0);
|
||||
m_chCheckBulletChar = oNode.GetAttribute(L"checkedChar").at(0);
|
||||
std::wstring wsAttributeValue = oNode.GetAttribute(L"char");
|
||||
|
||||
if (!wsAttributeValue.empty())
|
||||
m_chBulletChar = wsAttributeValue.at(0);
|
||||
|
||||
wsAttributeValue = oNode.GetAttribute(L"checkedChar");
|
||||
|
||||
if (!wsAttributeValue.empty())
|
||||
m_chCheckBulletChar = wsAttributeValue.at(0);
|
||||
|
||||
m_nBulletImage = oNode.GetAttributeInt(L"useImage");
|
||||
|
||||
for (CXMLNode& oChild : oNode.GetChilds())
|
||||
|
||||
@ -619,6 +619,7 @@ namespace PPT
|
||||
|
||||
WriteSlides();
|
||||
WriteNotes();
|
||||
m_pShapeWriter->SetRelsGenerator(NULL);
|
||||
}
|
||||
|
||||
// todo reforming and refactoring!
|
||||
@ -1544,6 +1545,8 @@ namespace PPT
|
||||
|
||||
oRels.StartSlide(nLayout, pSlide->m_lNotesID);
|
||||
}
|
||||
|
||||
m_pShapeWriter->SetRelsGenerator(&oRels);
|
||||
|
||||
oWriter.WriteString(std::wstring(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"));
|
||||
oWriter.WriteString(std::wstring(L"<p:sld \
|
||||
@ -1637,10 +1640,12 @@ xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\""));
|
||||
{
|
||||
CStringWriter oWriter;
|
||||
CRelsGenerator oRels(&m_oManager);
|
||||
|
||||
|
||||
CSlide* pNotes = m_pDocument->m_arNotes[nIndexNotes];
|
||||
|
||||
oRels.StartNotes(pNotes->m_lSlideID, m_pDocument->m_pNotesMaster != NULL);
|
||||
|
||||
m_pShapeWriter->SetRelsGenerator(&oRels);
|
||||
|
||||
oWriter.WriteString(std::wstring(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"));
|
||||
oWriter.WriteString(std::wstring(L"<p:notes xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\""));
|
||||
|
||||
@ -371,9 +371,9 @@ const std::wstring wchar_t2hex_str(const wchar_t val)
|
||||
}
|
||||
|
||||
|
||||
static boost::wregex match_hex(L"^_x[0-9A-F]{4}_");
|
||||
const std::wstring escape_ST_Xstring(const std::wstring& wstr)
|
||||
{
|
||||
static boost::wregex match_hex(L"^_x[0-9A-F]{4}_");
|
||||
std::wstring ret_val = L"";
|
||||
|
||||
for (size_t i = 0; i < wstr.length(); i++)
|
||||
@ -399,6 +399,7 @@ const std::wstring escape_ST_Xstring(const std::wstring& wstr)
|
||||
|
||||
const std::wstring unescape_ST_Xstring(const std::wstring& wstr)
|
||||
{
|
||||
static boost::wregex match_hex(L"^_x[0-9A-F]{4}_");
|
||||
std::wstring::const_iterator x_pos_noncopied = wstr.begin();
|
||||
std::wstring::const_iterator x_pos_next;// = wstr.begin();
|
||||
std::wstring::const_iterator wstr_end = wstr.end();
|
||||
@ -779,20 +780,5 @@ bool isColumn(const std::wstring& columnName, _UINT32 listIndex, _UINT16& indexC
|
||||
}
|
||||
return false;
|
||||
}
|
||||
unsigned int getColumnsCount(_UINT32 listIndex)
|
||||
{
|
||||
auto arrColumn = XLS::GlobalWorkbookInfo::mapTableColumnNames_static.find(listIndex);
|
||||
if(arrColumn != XLS::GlobalWorkbookInfo::mapTableColumnNames_static.end())
|
||||
{
|
||||
auto counter = 0;
|
||||
for(auto i:arrColumn->second)
|
||||
{
|
||||
if(!i.empty())
|
||||
counter++;
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} //namespace XMLSTUFF
|
||||
|
||||
|
||||
@ -87,15 +87,13 @@ namespace STR
|
||||
};
|
||||
|
||||
namespace XMLSTUFF
|
||||
{;
|
||||
|
||||
{
|
||||
const std::wstring name2sheet_name(std::wstring name, const std::wstring prefix);
|
||||
const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabLast, std::vector<std::wstring>& names, const std::wstring prefix = L"");
|
||||
unsigned short sheetsnames2ixti(std::wstring name);
|
||||
unsigned int definenames2index(std::wstring name);
|
||||
bool isTableFmla(const std::wstring& tableName, _UINT32& listIndex);
|
||||
bool isColumn(const std::wstring& columnName, _UINT32 listIndex, _UINT16& indexColumn);
|
||||
unsigned int getColumnsCount(_UINT32 listIndex);
|
||||
unsigned short AddMultysheetXti(const std::wstring& name, const _INT32& firstIxti, const _INT32& secondIxti);
|
||||
unsigned int AddDefinedName(const std::wstring& name);
|
||||
}
|
||||
|
||||
@ -53,11 +53,11 @@ public:
|
||||
static const ElementType type = typeDVal;
|
||||
|
||||
//-----------------------------
|
||||
bool fWnClosed;
|
||||
_UINT32 xLeft;
|
||||
_UINT32 yTop;
|
||||
_INT32 idObj;
|
||||
_UINT32 idvMac;
|
||||
bool fWnClosed = 0;
|
||||
_UINT32 xLeft = 0;
|
||||
_UINT32 yTop = 0;
|
||||
_INT32 idObj = 0;
|
||||
_UINT32 idvMac = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ public:
|
||||
static const ElementType type = typeFileSharing;
|
||||
|
||||
Boolean<unsigned short> fReadOnlyRec;
|
||||
unsigned short wResPassNum;
|
||||
unsigned short wResPassNum = 0;
|
||||
std::wstring wResPass;
|
||||
_UINT16 iNoResPass;
|
||||
XLUnicodeString stUNUsername;
|
||||
|
||||
@ -61,12 +61,12 @@ namespace XLS
|
||||
|
||||
static const ElementType type = typeXF;
|
||||
|
||||
_UINT16 font_index;
|
||||
_UINT16 font_index = 0;
|
||||
|
||||
_UINT16 ifmt; //used
|
||||
std::wstring format_code;
|
||||
_UINT16 ifmt = 0; //used
|
||||
std::wstring format_code = L"";
|
||||
|
||||
_UINT16 ixfParent;
|
||||
_UINT16 ixfParent = 0;
|
||||
|
||||
bool fLocked = false;
|
||||
bool fHidden = false;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2021
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
@ -71,10 +71,9 @@ namespace XLSB
|
||||
|
||||
void FRTSqref::save(XLS::CFRecord& record)
|
||||
{
|
||||
_UINT32 flags = 0;
|
||||
_UINT32 flags = 2;
|
||||
|
||||
SETBIT(flags, 0, fAdjDelete)
|
||||
SETBIT(flags, 1, fDoAdjust)
|
||||
SETBIT(flags, 2, fAdjChange)
|
||||
SETBIT(flags, 3, fEdit)
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2021
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
@ -52,7 +52,7 @@ namespace XLSB
|
||||
void load(XLS::CFRecord& record) override;
|
||||
void save(XLS::CFRecord& record) override;
|
||||
|
||||
_INT32 crfx;
|
||||
_INT32 crfx = 0;
|
||||
std::vector<UncheckedRfX> rgrfx;
|
||||
|
||||
const XLS::CellRef getLocationFirstCell() const;
|
||||
|
||||
@ -64,10 +64,10 @@ public:
|
||||
const bool getRowRelative() const;
|
||||
const bool getColumnRelative() const;
|
||||
|
||||
int row;
|
||||
int column;
|
||||
bool rowRelative;
|
||||
bool colRelative;
|
||||
int row = 0;
|
||||
int column = 0;
|
||||
bool rowRelative = false;
|
||||
bool colRelative = false;
|
||||
protected:
|
||||
bool fQuoted;
|
||||
mutable std::wstring to_string_cache;
|
||||
|
||||
@ -531,8 +531,8 @@ Ftab_Cetab::ValuesDetermination::ValuesDetermination()
|
||||
params_fixed.insert(ParamsFixed(0x01E0, 2, L"IFERROR"));
|
||||
params_fixed.insert(ParamsFixed(0x01E1, -1, L"COUNTIFS"));
|
||||
params_fixed.insert(ParamsFixed(0x01E2, 3, L"SUMIFS"));
|
||||
params_fixed.insert(ParamsFixed(0x01E3, 2, L"AVERAGEIF"));
|
||||
params_fixed.insert(ParamsFixed(0x01E4, 3, L"AVERAGEIFS"));
|
||||
params_fixed.insert(ParamsFixed(0x01E3, -1, L"AVERAGEIF"));
|
||||
params_fixed.insert(ParamsFixed(0x01E4, -1, L"AVERAGEIFS"));
|
||||
|
||||
// Cetab values
|
||||
params_fixed.insert(ParamsFixed(0x8000, -1, L"BEEP"));
|
||||
|
||||
@ -82,6 +82,7 @@ OfficeArtRecordPtr OfficeArtContainer::CreateOfficeArt(unsigned short type)
|
||||
case FSP:
|
||||
art_record = OfficeArtRecordPtr(new OfficeArtFSP); break;
|
||||
case FOPT:
|
||||
case SecondaryFOPT:
|
||||
art_record = OfficeArtRecordPtr(new OfficeArtFOPT); break;
|
||||
case ChildAnchor:
|
||||
art_record = OfficeArtRecordPtr(new OfficeArtChildAnchor); break;
|
||||
@ -116,8 +117,6 @@ OfficeArtRecordPtr OfficeArtContainer::CreateOfficeArt(unsigned short type)
|
||||
art_record = OfficeArtRecordPtr(new OfficeArtBStoreContainer); break;
|
||||
case TertiaryFOPT:
|
||||
art_record = OfficeArtRecordPtr(new OfficeArtTertiaryFOPT); break;
|
||||
case SecondaryFOPT:
|
||||
|
||||
case FPSPL:
|
||||
case FDGSL:
|
||||
case FBSE:
|
||||
|
||||
@ -138,7 +138,7 @@ void PtgExtraArray::save(CFRecord& record)
|
||||
const std::wstring PtgExtraArray::toString() const
|
||||
{
|
||||
std::wstring ret_val;
|
||||
unsigned char col_cnt = cols;
|
||||
unsigned char col_cnt = cols + 1;
|
||||
|
||||
if (array_.empty()) return L"";
|
||||
|
||||
@ -152,7 +152,7 @@ const std::wstring PtgExtraArray::toString() const
|
||||
else
|
||||
{
|
||||
ret_val += L';';
|
||||
col_cnt = cols;
|
||||
col_cnt = cols + 1;
|
||||
}
|
||||
}
|
||||
ret_val += array_.back()->toString();
|
||||
|
||||
@ -317,9 +317,6 @@ const bool StringPtgParser::parseToPtgs(const std::wstring& assembled_formula, R
|
||||
[&](XLS::GlobalWorkbookInfo::_xti i) {
|
||||
return i.iSup == ixti;
|
||||
});
|
||||
if(pos->itabFirst == pos->itabLast)
|
||||
rgce.addPtg(found_operand = OperandPtgPtr(new PtgRef3d(ixti, operand_str, OperandPtg::ptg_VALUE, rgce.getLocation())));
|
||||
else
|
||||
rgce.addPtg(found_operand = OperandPtgPtr(new PtgRef3d(ixti, operand_str, OperandPtg::ptg_REFERENCE, rgce.getLocation())));
|
||||
}
|
||||
else if(SyntaxPtg::extract_PtgRefErr(it, itEnd))
|
||||
|
||||
@ -617,21 +617,11 @@ const bool SyntaxPtg::extract_PtgList(std::wstring::const_iterator& first, std::
|
||||
}
|
||||
else if (boost::regex_search(first, last, results_1, reg_inside_table6))
|
||||
{
|
||||
auto colCount = XMLSTUFF::getColumnsCount(indexTable);
|
||||
if(colCount>1)
|
||||
{
|
||||
ptgList.columns = 0x02;
|
||||
ptgList.colFirst = 0;
|
||||
ptgList.colLast = colCount-1;
|
||||
first = results_1[0].second;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptgList.columns = 0x01;
|
||||
ptgList.colFirst = 0;
|
||||
ptgList.colLast = 0;
|
||||
first = results_1[0].second;
|
||||
}
|
||||
ptgList.columns = 0;
|
||||
ptgList.colFirst = 0;
|
||||
ptgList.colLast = 0;
|
||||
ptgList.rowType = 0x00;
|
||||
first = results_1[0].second;
|
||||
return true;
|
||||
}
|
||||
else if(boost::regex_search(first, last, results_1, reg_inside_table4))
|
||||
|
||||
147
OFDFile/OFDFile.cpp
Normal file
147
OFDFile/OFDFile.cpp
Normal file
@ -0,0 +1,147 @@
|
||||
#include "OFDFile.h"
|
||||
#include "src/OFDFile_Private.h"
|
||||
|
||||
#ifndef DISABLE_PDF_CONVERTATION
|
||||
#include "../PdfFile/PdfFile.h"
|
||||
#endif
|
||||
|
||||
COFDFile::COFDFile(NSFonts::IApplicationFonts* pFonts)
|
||||
: m_pInternal(new COFDFile_Private(pFonts))
|
||||
{}
|
||||
|
||||
COFDFile::~COFDFile()
|
||||
{
|
||||
COFDFile::Close();
|
||||
|
||||
if (nullptr != m_pInternal)
|
||||
delete m_pInternal;
|
||||
}
|
||||
|
||||
bool COFDFile::LoadFromFile(const std::wstring& file, const std::wstring& options, const std::wstring& owner_password, const std::wstring& user_password)
|
||||
{
|
||||
if (nullptr == m_pInternal)
|
||||
return false;
|
||||
|
||||
Close();
|
||||
|
||||
return m_pInternal->LoadFromFile(file);
|
||||
}
|
||||
|
||||
bool COFDFile::LoadFromMemory(unsigned char* data, unsigned long length, const std::wstring& options, const std::wstring& owner_password, const std::wstring& user_password)
|
||||
{
|
||||
if (nullptr == m_pInternal)
|
||||
return false;
|
||||
|
||||
Close();
|
||||
|
||||
return m_pInternal->LoadFromMemory(data, length);
|
||||
}
|
||||
|
||||
void COFDFile::Close()
|
||||
{
|
||||
if (nullptr != m_pInternal)
|
||||
m_pInternal->Close();
|
||||
}
|
||||
|
||||
NSFonts::IApplicationFonts* COFDFile::GetFonts()
|
||||
{
|
||||
return (nullptr != m_pInternal) ? m_pInternal->GetFonts() : nullptr;
|
||||
}
|
||||
|
||||
OfficeDrawingFileType COFDFile::GetType()
|
||||
{
|
||||
return odftOFD;
|
||||
}
|
||||
|
||||
std::wstring COFDFile::GetTempDirectory()
|
||||
{
|
||||
if (nullptr != m_pInternal)
|
||||
return m_pInternal->GetTempDir();
|
||||
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
void COFDFile::SetTempDirectory(const std::wstring& directory)
|
||||
{
|
||||
if (nullptr != m_pInternal)
|
||||
m_pInternal->SetTempDir(directory);
|
||||
}
|
||||
|
||||
int COFDFile::GetPagesCount()
|
||||
{
|
||||
if (nullptr != m_pInternal)
|
||||
return m_pInternal->GetPageCount();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void COFDFile::GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY)
|
||||
{
|
||||
if (nullptr == m_pInternal)
|
||||
return;
|
||||
|
||||
m_pInternal->GetPageSize(nPageIndex, *pdWidth, *pdHeight);
|
||||
|
||||
*pdDpiX = 25.4;
|
||||
*pdDpiY = 25.4;
|
||||
}
|
||||
|
||||
void COFDFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak, COfficeDrawingPageParams* pParams)
|
||||
{
|
||||
if (nullptr == pRenderer || nullptr == m_pInternal)
|
||||
return;
|
||||
|
||||
m_pInternal->DrawPage(pRenderer, nPageIndex);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_PDF_CONVERTATION
|
||||
void COFDFile::ConvertToPdf(const std::wstring& wsDstPath)
|
||||
{
|
||||
CPdfFile oPdf(GetFonts());
|
||||
oPdf.CreatePdf();
|
||||
bool bBreak = false;
|
||||
|
||||
int nPagesCount = GetPagesCount();
|
||||
for (int nPageIndex = 0; nPageIndex < nPagesCount; nPageIndex++)
|
||||
{
|
||||
oPdf.NewPage();
|
||||
oPdf.BeginCommand(c_nPageType);
|
||||
|
||||
double dPageDpiX = 96., dPageDpiY = 96.;
|
||||
double dWidth = 0., dHeight = 0.;
|
||||
|
||||
GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
||||
|
||||
dWidth *= 25.4 / dPageDpiX;
|
||||
dHeight *= 25.4 / dPageDpiY;
|
||||
|
||||
oPdf.put_Width(dWidth);
|
||||
oPdf.put_Height(dHeight);
|
||||
|
||||
DrawPageOnRenderer(&oPdf, nPageIndex, &bBreak);
|
||||
|
||||
oPdf.EndCommand(c_nPageType);
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf("page %d / %d\n", nPageIndex + 1, nPagesCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
oPdf.SaveToFile(wsDstPath);
|
||||
}
|
||||
|
||||
std::wstring COFDFile::GetInfo()
|
||||
{
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
unsigned char* COFDFile::GetStructure()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned char* COFDFile::GetLinks(int nPageIndex)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user