mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-31 10:21:37 +08:00
Compare commits
628 Commits
v9.0.0.131
...
fix/bug597
| Author | SHA1 | Date | |
|---|---|---|---|
| 950482095c | |||
| 8ca89ca9b7 | |||
| da705edfb8 | |||
| 2ed318df0f | |||
| 771ee80ec5 | |||
| 4ddf4521c4 | |||
| 1491bd8802 | |||
| e7de9af0e0 | |||
| 703ec47e67 | |||
| 708e37d0a5 | |||
| e11b946d62 | |||
| 331401ea86 | |||
| 40809ea3c2 | |||
| b79001a9fd | |||
| 49d4b5c1d2 | |||
| fa513eb83f | |||
| e84e0a6ce8 | |||
| 13158b2956 | |||
| 9e8beb5651 | |||
| 711e80e62c | |||
| 3404aab782 | |||
| 9c3ba26fab | |||
| 02f4c10cd6 | |||
| 0d912533bf | |||
| 066793921b | |||
| 9b2b7263c2 | |||
| 31c28903d6 | |||
| 518a38e178 | |||
| 631c2d4490 | |||
| 0d0003ad5a | |||
| eb3bedd840 | |||
| 0e9db67173 | |||
| 1a65242d46 | |||
| 30da4b631f | |||
| a988e6741c | |||
| 29c2239df2 | |||
| 0d7ddfb580 | |||
| a7b5866bc6 | |||
| 8bbb21263d | |||
| a652bd6591 | |||
| 78532c27cf | |||
| 63d3999072 | |||
| d055522aa0 | |||
| c5e63a8d26 | |||
| e56da8e641 | |||
| ba63cfc622 | |||
| 7486182be7 | |||
| 6f171bd5d7 | |||
| dad2fdd3e0 | |||
| 48bc54311c | |||
| a71b7ec6e7 | |||
| 292e6b0431 | |||
| 5649de0877 | |||
| 7aa2056785 | |||
| b1c8969ede | |||
| d3805e81d7 | |||
| 8171939be6 | |||
| 5178de4254 | |||
| f3ee3c8c91 | |||
| e108591a7e | |||
| 29f1dc454b | |||
| b534907bc9 | |||
| b957d3aeea | |||
| 520c345f00 | |||
| 08ce05e5d3 | |||
| a8125114de | |||
| 13a4986eb7 | |||
| 62003d97bb | |||
| 3e0a88a487 | |||
| 1969229659 | |||
| 98af93c631 | |||
| a4ebe56f28 | |||
| 247b90ce1a | |||
| aef05de075 | |||
| 5b12d7fff3 | |||
| 4223f9c265 | |||
| 9e60a7e3ab | |||
| 5de9bd7e67 | |||
| dacde4c593 | |||
| 97385c3f37 | |||
| edd17cd7c3 | |||
| e373adf717 | |||
| 2ad1771333 | |||
| 73f40edc7e | |||
| 182a3cea90 | |||
| 72f0b0403e | |||
| 3d5d871911 | |||
| 1fbffa673c | |||
| 06c47b07ec | |||
| e2bcf62cc4 | |||
| f5a91c33b5 | |||
| 79ab0bc04b | |||
| 242aa2c9d6 | |||
| e01517714c | |||
| 3f7edeec4f | |||
| 9cef29c201 | |||
| 688632c373 | |||
| c86387c015 | |||
| e8f7720387 | |||
| 4ea504f688 | |||
| c3dd5c8fc9 | |||
| 6e1357f276 | |||
| fee71647a9 | |||
| 6c516b7ce2 | |||
| 53d5f4517b | |||
| 03e21d19f1 | |||
| cd05b830b1 | |||
| bf05a63db0 | |||
| bc96c82ff9 | |||
| 4187522006 | |||
| a82cf375b7 | |||
| 81f057ba78 | |||
| c2a733f465 | |||
| fcd7818675 | |||
| baf8321c61 | |||
| 826bd168ad | |||
| b1dff84b1b | |||
| c65460e49b | |||
| f5fa14a230 | |||
| db744e6fdc | |||
| a15156fcb3 | |||
| dbc54e5879 | |||
| 2a09e2ef67 | |||
| 17534abdda | |||
| e4a7cf63c9 | |||
| 0eadce28da | |||
| 29c53f751b | |||
| 6500e65edc | |||
| e8ecb2cdfb | |||
| 3046b1557f | |||
| fbf4ef22d8 | |||
| 628908e96c | |||
| 78df0b3780 | |||
| d8c0e9b68d | |||
| df8f8636b6 | |||
| 5722599351 | |||
| f4489a3926 | |||
| 91f27bf771 | |||
| eb3daff8d6 | |||
| 6d707ebae2 | |||
| bab8da0475 | |||
| 66501ab353 | |||
| a865901405 | |||
| c1987b196e | |||
| 8899966508 | |||
| 41dc23ce53 | |||
| 3a555aa223 | |||
| 2168216009 | |||
| 13b42d71e2 | |||
| 58cd88a93f | |||
| 4dc1d88bc9 | |||
| ef2d554265 | |||
| 2d08404f72 | |||
| cd6c4c56c3 | |||
| 96f7de8534 | |||
| dba4be73dd | |||
| f3101fd2ec | |||
| 08716fc4ce | |||
| 986125a3e6 | |||
| b655a4e109 | |||
| 7ce6602951 | |||
| f45b3ba0da | |||
| 5ec24525b8 | |||
| 0c601c1c82 | |||
| c7d3e5df14 | |||
| 2351b1f052 | |||
| b93ea3bb41 | |||
| 697f604fc4 | |||
| a817cd54d5 | |||
| 1fc61459b8 | |||
| e1b3474a06 | |||
| 041325b440 | |||
| 064a04a600 | |||
| df4e1445f6 | |||
| cc6132cd77 | |||
| c7a209048f | |||
| a359060684 | |||
| 08fafaa655 | |||
| 57923e4266 | |||
| b488623e81 | |||
| 2462074f63 | |||
| 5e121188d8 | |||
| 114f9a0da3 | |||
| 7c4b85600d | |||
| 48e2defbcd | |||
| 07bd804009 | |||
| 348fc71e1c | |||
| d123b0f610 | |||
| 13e30bf918 | |||
| e74a96884c | |||
| c67d87b1f0 | |||
| 1e73aed4a5 | |||
| 63da89d846 | |||
| 9f223deee7 | |||
| d49789ea19 | |||
| 738583d0d4 | |||
| 47a1e26ff5 | |||
| ecca7a5cdd | |||
| 407993cd40 | |||
| 7e5d3bb3eb | |||
| 381daebcb9 | |||
| 7e6d6b407c | |||
| 5e9f0d762a | |||
| f5ddf8c6ce | |||
| 4f95713790 | |||
| 337847f606 | |||
| a84491cf74 | |||
| 689eaddd5b | |||
| 2cc56a9f9f | |||
| 33c6640ce0 | |||
| e6e93549c9 | |||
| 00e5c8bd2e | |||
| ae063b3d41 | |||
| 01d6a7d090 | |||
| 98c998b3ee | |||
| f6c8356684 | |||
| 880951a611 | |||
| 2895f829e3 | |||
| 671b88d8bc | |||
| c0ba4267d2 | |||
| 29355d337b | |||
| 6f7a414888 | |||
| 031fc7517b | |||
| a040e89ae5 | |||
| e025ae2779 | |||
| 21ca48c6f6 | |||
| ec906774dd | |||
| e17b99554d | |||
| 09ac9f8609 | |||
| 97178ae328 | |||
| 1dc8990c9d | |||
| f68825c6d3 | |||
| 4770a2b22b | |||
| dda00c3b18 | |||
| 156578ca82 | |||
| 2ec63f2cb7 | |||
| 62d2deaefb | |||
| fbed837a47 | |||
| 0715c0c5a5 | |||
| 103c8dd575 | |||
| 5dc5a200b8 | |||
| 23008b3737 | |||
| 03f490047d | |||
| 36454f4c6e | |||
| 34e1dabefb | |||
| 3d39d5837f | |||
| a6efd8a374 | |||
| 3bfa3643e6 | |||
| 453e17ac0e | |||
| 88620dc8cd | |||
| cc9b00329e | |||
| 88c84ad577 | |||
| ee22e8e8b4 | |||
| 1756d58c6d | |||
| ecab418202 | |||
| d3430ace10 | |||
| 10a6f6e617 | |||
| 8c6a26895b | |||
| 5142536e17 | |||
| fd05f3b16d | |||
| e0840e73d2 | |||
| ae2918ec71 | |||
| 17369e8bee | |||
| 3047a9fb47 | |||
| 1495581b00 | |||
| 6c2fce16a8 | |||
| 58be006bb9 | |||
| 6c2a8205ec | |||
| 29cee43448 | |||
| 0154543b01 | |||
| 3e2dee5719 | |||
| 8b4fe95291 | |||
| c25f8cc204 | |||
| 010d1ce4c9 | |||
| 6ac9349ccb | |||
| c3bf7ad49b | |||
| b5d56d1d6d | |||
| d3aae6dfcb | |||
| fb07c0c468 | |||
| 327d00bacf | |||
| fe0d95009c | |||
| bcc5f67ec8 | |||
| 9200c29d42 | |||
| c13027c9d1 | |||
| 6acb9855a1 | |||
| 1619e421f2 | |||
| 2b1e5faef9 | |||
| ea214f942f | |||
| ccbff8d8da | |||
| 1cd72ab988 | |||
| 63937e706e | |||
| 54a903d2e7 | |||
| e48fab418d | |||
| 537304ad24 | |||
| fa9e3cb48e | |||
| d362999e2a | |||
| 6e73b593ba | |||
| 46fbf81b4d | |||
| 519a93ecaf | |||
| 90ded6788f | |||
| 1f4a420d35 | |||
| 087146ce77 | |||
| b4ac2a9515 | |||
| d11e0492f2 | |||
| 4b3c4242f6 | |||
| 482a821974 | |||
| 2e1538b3dc | |||
| 48ec45c1dd | |||
| 809ed63ca0 | |||
| 91badde27d | |||
| 618b1a9ca8 | |||
| 95d523370d | |||
| a2768af989 | |||
| 85e8d253a9 | |||
| d4e623f277 | |||
| 827dc4c1b9 | |||
| 5d033bef69 | |||
| 18e22f0f05 | |||
| 426cd08d57 | |||
| d1a64d29c0 | |||
| b8053ae388 | |||
| c56cfaf71f | |||
| 2680fd7073 | |||
| cfdeca436b | |||
| db3769eb13 | |||
| e5fcbcf5f3 | |||
| 6d4ff364b3 | |||
| 8a9277d1d8 | |||
| f3d3755a31 | |||
| ffab501ce9 | |||
| 74b21f5b4c | |||
| 3e9d3bed35 | |||
| 8ddb6e7f05 | |||
| db9fd85f22 | |||
| e54e8d7a8a | |||
| 8e0e1203c6 | |||
| 9a74609366 | |||
| d9f24ca635 | |||
| ebddab233c | |||
| 0bdd7f098d | |||
| efadc23a50 | |||
| 36db67cba3 | |||
| c9e5320ea3 | |||
| 58f12dbbee | |||
| 1656d0dd6d | |||
| 39090a2423 | |||
| 8241d85596 | |||
| 8ebc312dc7 | |||
| aaf744353f | |||
| 4cff6dfe57 | |||
| 15ee6ecf91 | |||
| 67a5b7f087 | |||
| c6e2ad0fef | |||
| 5b9141ce1d | |||
| 502312fe20 | |||
| a10b8ee6fb | |||
| 7c6cd1107d | |||
| 05be4876e8 | |||
| d9806dfbc8 | |||
| 00e9d050ae | |||
| 405a2c1f59 | |||
| d287fc016e | |||
| 383a616c97 | |||
| 4e272d8ecf | |||
| f6900b5d11 | |||
| 0a7a3c3a99 | |||
| 556ea0dce4 | |||
| 62dde72acc | |||
| 5e45f5fb09 | |||
| 750b28d866 | |||
| 33b246b9da | |||
| 6c8e053bb2 | |||
| db7ebc5765 | |||
| 84462ab1da | |||
| 7cb08f3a87 | |||
| 16b28e60a4 | |||
| 8ac1c4d158 | |||
| 5f78402f2a | |||
| fa80e4913f | |||
| aa5012928c | |||
| c0f5336a5a | |||
| 646f2ca6b1 | |||
| 18f92b56ba | |||
| bc34a76127 | |||
| ad5670cde7 | |||
| b09fc50b62 | |||
| b04f9bda4a | |||
| 046b39478a | |||
| 4e59cac4cd | |||
| 0d79f941b9 | |||
| d69d71ec07 | |||
| 0ebc0da7b2 | |||
| 3db0662c14 | |||
| 49477554a4 | |||
| 55e758e3f8 | |||
| c11171fbf2 | |||
| 8c4fc0d94c | |||
| e6570a6ccc | |||
| ecda52ae5c | |||
| 5df1ec97c3 | |||
| 78577f70e5 | |||
| 78e20f5358 | |||
| dba3b263e6 | |||
| 40ce56d7f8 | |||
| 33864a1a1e | |||
| 602879432a | |||
| cbc36b0b0a | |||
| dfc4048630 | |||
| adc2930f0b | |||
| 599566c5e2 | |||
| 17c1e0a2bb | |||
| 462523cfa5 | |||
| fcdbdff42f | |||
| e7b231feed | |||
| 3264e0764e | |||
| 5f4cfa5bdf | |||
| b159b76018 | |||
| a006479964 | |||
| 2012fef748 | |||
| c8288b8b7b | |||
| 7f31f40843 | |||
| 414b376f04 | |||
| 10427d151d | |||
| 8e9198f307 | |||
| a3399b3119 | |||
| 646bbd405f | |||
| 04663e7653 | |||
| 240b78b0a6 | |||
| 9a147d9817 | |||
| e20231dc88 | |||
| 9c7d4e6d90 | |||
| c936c4419c | |||
| 622617d16d | |||
| 1daaaad842 | |||
| 4d9744190e | |||
| 575e45a0b2 | |||
| e9e88f616b | |||
| ee67e5dbc5 | |||
| c53f6fe09f | |||
| 624e5477ae | |||
| 5938d38219 | |||
| 6cc0b5e215 | |||
| 3d9045e0d4 | |||
| 01e1cb14bf | |||
| 011e2a8592 | |||
| b3e297bb08 | |||
| 68e10572f1 | |||
| ae1266d506 | |||
| b86dfb8d90 | |||
| fd9d46fc3c | |||
| c53009ee3d | |||
| 02a845d451 | |||
| b380692fe5 | |||
| 8123c0e409 | |||
| cae981891b | |||
| 49fad86617 | |||
| feb3c7af90 | |||
| 0f169b1491 | |||
| 22e89be7a3 | |||
| ced5bb6c71 | |||
| 26cb45ceaa | |||
| 9091f12828 | |||
| 500cf8fca3 | |||
| b17b3dec40 | |||
| 57b854355e | |||
| 2d758b155d | |||
| 29c81f7653 | |||
| d86afbe693 | |||
| b9120f5c29 | |||
| 49841da755 | |||
| 76bed5ae36 | |||
| 4451768f4e | |||
| 102fdb83bc | |||
| a5f5a2921f | |||
| 353f8ddbac | |||
| 916f293c89 | |||
| f6e214b0c3 | |||
| 4f63982e2f | |||
| f570c88d29 | |||
| 10e6664313 | |||
| 00a82a7693 | |||
| 0dfe7c8dcc | |||
| 56b09897d7 | |||
| 3886951671 | |||
| 326fe32013 | |||
| 777eb2697d | |||
| a824e9c25d | |||
| 6402c0cb73 | |||
| 29c01ac9c9 | |||
| 03463ee0e4 | |||
| daf8fb9dd7 | |||
| ae71fefd92 | |||
| c4eb6ef445 | |||
| f285120de5 | |||
| 5f56a0d2d7 | |||
| 79bb238b5f | |||
| 8c6baa9c0b | |||
| 5c2171db93 | |||
| e73b1e2db2 | |||
| 3b8b1cff55 | |||
| a96d51bad2 | |||
| 1eb681992e | |||
| c140c6ef6a | |||
| 8c5a8fd7bc | |||
| 9395c14324 | |||
| 3bd151445d | |||
| 90b0b667ce | |||
| 0b79502804 | |||
| ab893e371c | |||
| 5174ea0ce6 | |||
| 44bb82919f | |||
| 3ac479ccdc | |||
| 5942b88c8d | |||
| 942480d895 | |||
| 931b66e038 | |||
| cb9dce54a7 | |||
| 5892c2fa1b | |||
| d50ee7467e | |||
| f51fb711b4 | |||
| d15ac8b84f | |||
| 00176a0425 | |||
| 14f0a757ac | |||
| 7b51ade6f5 | |||
| 49bd1657ab | |||
| d50f2b3ccc | |||
| 8ff979c2e9 | |||
| e4a69da400 | |||
| 9b24261b2b | |||
| 211f151346 | |||
| 6c8cbec6ba | |||
| 9507e3b3f2 | |||
| 755a357e3d | |||
| 2a7256eb48 | |||
| 0e8c37c293 | |||
| 284d54f456 | |||
| bf00185275 | |||
| 6ed57dae6c | |||
| 8e64dcc5a4 | |||
| 1e2b91e77f | |||
| eb472e27b4 | |||
| 51aed7ae53 | |||
| ecf59a75a7 | |||
| 9039ff53db | |||
| b53b2859de | |||
| fe1372882e | |||
| 34e0b7e69a | |||
| 856ae09f69 | |||
| 28f2e14bce | |||
| e74199b3d2 | |||
| b8d9ba3b1d | |||
| 5fe6dd8730 | |||
| ab573cf9ba | |||
| 92902724a0 | |||
| 7e116dbd41 | |||
| c964ed7d58 | |||
| 88db7ec840 | |||
| b456a094ee | |||
| a19dc86ea9 | |||
| 62ba3fa029 | |||
| 58c2fa783e | |||
| 678101f7e4 | |||
| 17fb69ee8a | |||
| 0833c97c99 | |||
| 5d64c7c6e7 | |||
| 0f3ef78362 | |||
| fa65a546da | |||
| 1a54c8f8b9 | |||
| 9aa6bceddf | |||
| 6d6f87cae6 | |||
| 3d9a783d46 | |||
| 21028c2ca5 | |||
| 8c16766e9f | |||
| c8ca725523 | |||
| 3c2fd33c7a | |||
| f9062d7d38 | |||
| 25fa05b701 | |||
| 6f66b0c533 | |||
| bf89efd471 | |||
| 8f14a0f30b | |||
| 494b7b52cb | |||
| e5d6f5df47 | |||
| 6f1ffaad40 | |||
| e76398db01 | |||
| 7c9ae624e9 | |||
| cafdb1d2a5 | |||
| 06bfb07f0d | |||
| e3c60a6b05 | |||
| 4a03b8cc4a | |||
| 5a0d23f6af | |||
| 652940657c | |||
| 421f5bb0f2 | |||
| 61640a9a06 | |||
| 87f0835010 | |||
| eb71d95944 | |||
| cab887c161 | |||
| b1b4c0e5ff | |||
| c5cd520bfe | |||
| f0dbf92bde | |||
| 1d27cc61f4 | |||
| f535cef848 | |||
| 7ad49a5650 | |||
| 71201f4446 | |||
| 3ad2fff67b | |||
| 66b56360da | |||
| e8f88ab20d | |||
| 7857106d76 | |||
| 64c74192c7 | |||
| 3ec47d195e | |||
| daf6dd5af2 | |||
| 9b8f01b293 | |||
| 3c60ee114c | |||
| 8165c6ffde | |||
| 7dc753a868 | |||
| ea475e2828 | |||
| 5cb7ad11e4 | |||
| ec01f4a77e | |||
| ef1fc051d5 | |||
| daa90eee79 | |||
| f253eb5448 | |||
| a7457fd058 | |||
| 6791799fcb | |||
| a03e397234 | |||
| dcf8f0fb01 | |||
| d04146db5b | |||
| 5a7d3de597 | |||
| 6cb6631d1a | |||
| 1a3ce88654 | |||
| 037879ca65 |
1
Common/.gitignore
vendored
Normal file
1
Common/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
**/module.version
|
||||
@ -26,14 +26,21 @@ bundle_xcframeworks {
|
||||
}
|
||||
}
|
||||
|
||||
core_win_arm64 {
|
||||
DEFINES += MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS=0
|
||||
}
|
||||
|
||||
core_windows {
|
||||
VS_VERSION=140
|
||||
VS_DEBUG=
|
||||
VS_ARCH=x64
|
||||
core_debug:VS_DEBUG=gd-
|
||||
core_win_32:VS_ARCH=x32
|
||||
core_win_arm64:VS_ARCH=a64
|
||||
vs2019:VS_VERSION=142
|
||||
|
||||
DEFINES += BOOST_USE_WINDOWS_H BOOST_WINAPI_NO_REDECLARATIONS
|
||||
|
||||
BOOST_POSTFIX = -vc$${VS_VERSION}-mt-$${VS_DEBUG}$${VS_ARCH}-1_72
|
||||
|
||||
core_boost_libs:LIBS += -L$$CORE_BOOST_LIBS -llibboost_system$$BOOST_POSTFIX -llibboost_filesystem$$BOOST_POSTFIX
|
||||
|
||||
2
Common/3dParty/brotli/.gitignore
vendored
Normal file
2
Common/3dParty/brotli/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
brotli/
|
||||
module.version
|
||||
9
Common/3dParty/brotli/brotli.pri
Normal file
9
Common/3dParty/brotli/brotli.pri
Normal file
@ -0,0 +1,9 @@
|
||||
SRC_DIR = $$PWD/brotli/c
|
||||
DEFINES += FT_CONFIG_OPTION_USE_BROTLI
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$SRC_DIR/include
|
||||
|
||||
SOURCES += $$files($$SRC_DIR/common/*.c)
|
||||
SOURCES += $$files($$SRC_DIR/dec/*.c)
|
||||
#SOURCES += $$files($$SRC_DIR/enc/*.c)
|
||||
20
Common/3dParty/brotli/make.py
Executable file
20
Common/3dParty/brotli/make.py
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append("../../../../build_tools/scripts")
|
||||
import base
|
||||
|
||||
def clear_module():
|
||||
if base.is_dir("brotli"):
|
||||
base.delete_dir_with_access_error("brotli")
|
||||
return
|
||||
|
||||
base.check_module_version("1", clear_module)
|
||||
|
||||
# fetch harfbuzz
|
||||
if not base.is_dir("brotli"):
|
||||
base.cmd("git", ["clone", "https://github.com/google/brotli.git"])
|
||||
os.chdir("brotli")
|
||||
base.cmd("git", ["checkout", "a47d7475063eb223c87632eed806c0070e70da29"])
|
||||
os.chdir("../")
|
||||
4
Common/3dParty/heif/.gitignore
vendored
Normal file
4
Common/3dParty/heif/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
x265_git
|
||||
libde265
|
||||
libheif
|
||||
ios-cmake
|
||||
42
Common/3dParty/heif/heif.pri
Normal file
42
Common/3dParty/heif/heif.pri
Normal file
@ -0,0 +1,42 @@
|
||||
DEFINES += LIBHEIF_STATIC_BUILD
|
||||
|
||||
HEIF_BUILDS_PLATFORM_PREFIX = $$CORE_BUILDS_PLATFORM_PREFIX
|
||||
core_ios : xcframework_platform_ios_simulator {
|
||||
HEIF_BUILDS_PLATFORM_PREFIX = ios_simulator
|
||||
}
|
||||
|
||||
HEIF_BUILD_PATH = $$PWD/libheif/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PWD/libheif/libheif/api \
|
||||
$$HEIF_BUILD_PATH # for heif_version.h
|
||||
|
||||
core_windows {
|
||||
core_debug {
|
||||
BUILD_TYPE = Debug
|
||||
} else {
|
||||
BUILD_TYPE = Release
|
||||
}
|
||||
|
||||
LIBS += \
|
||||
-L$$PWD/x265_git/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/$$BUILD_TYPE -lx265-static \
|
||||
-L$$PWD/libde265/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/libde265/$$BUILD_TYPE -llibde265 \
|
||||
-L$$HEIF_BUILD_PATH/libheif/$$BUILD_TYPE -lheif
|
||||
}
|
||||
|
||||
core_linux | core_android {
|
||||
# we need to wrap x265 and de265 libraries in `whole-archive` flags to avoid "undefined symbol" errors when later linking with graphics.so
|
||||
LIBS += \
|
||||
-Wl,--whole-archive \
|
||||
-L$$PWD/x265_git/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX -lx265 \
|
||||
-L$$PWD/libde265/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/libde265 -lde265 \
|
||||
-Wl,--no-whole-archive \
|
||||
-L$$HEIF_BUILD_PATH/libheif -lheif
|
||||
}
|
||||
|
||||
core_mac | core_ios {
|
||||
LIBS += \
|
||||
-L$$PWD/x265_git/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX -lx265 \
|
||||
-L$$PWD/libde265/build/$$HEIF_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX/libde265 -lde265 \
|
||||
-L$$HEIF_BUILD_PATH/libheif -lheif
|
||||
}
|
||||
@ -12,7 +12,7 @@
|
||||
#include "StaticFunctions.h"
|
||||
#include "ConstValues.h"
|
||||
|
||||
#define DEFAULT_FONT_SIZE 14
|
||||
#define DEFAULT_FONT_SIZE 12
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
@ -444,6 +444,11 @@ namespace NSCSS
|
||||
m_oDisplay.SetVAlign(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
CASE(L"white-space"):
|
||||
{
|
||||
m_oDisplay.SetWhiteSpace(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
//TRANSFORM
|
||||
CASE(L"transform"):
|
||||
{
|
||||
|
||||
@ -58,6 +58,11 @@ namespace NSCSS
|
||||
return m_pInternal->GetDpi();
|
||||
}
|
||||
|
||||
bool CCssCalculator::HaveStylesById(const std::wstring& wsId) const
|
||||
{
|
||||
return m_pInternal->HaveStylesById(wsId);
|
||||
}
|
||||
|
||||
void CCssCalculator::ClearPageData()
|
||||
{
|
||||
m_pInternal->ClearPageData();
|
||||
|
||||
@ -32,6 +32,8 @@ namespace NSCSS
|
||||
std::wstring GetEncoding() const;
|
||||
unsigned short int GetDpi() const;
|
||||
|
||||
bool HaveStylesById(const std::wstring& wsId) const;
|
||||
|
||||
void ClearPageData();
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
|
||||
@ -184,7 +184,7 @@ namespace NSCSS
|
||||
}
|
||||
#endif
|
||||
|
||||
const CElement* CStyleStorage::FindElement(const std::wstring& wsSelector)
|
||||
const CElement* CStyleStorage::FindElement(const std::wstring& wsSelector) const
|
||||
{
|
||||
if (wsSelector.empty())
|
||||
return nullptr;
|
||||
@ -470,7 +470,7 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
const CElement* CStyleStorage::FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData)
|
||||
const CElement* CStyleStorage::FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData) const
|
||||
{
|
||||
std::map<std::wstring, CElement*>::const_iterator itFound = mStyleData.find(wsSelector);
|
||||
|
||||
@ -491,6 +491,21 @@ namespace NSCSS
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
if (L"#text" == arSelectors.back().m_wsName)
|
||||
{
|
||||
if (arSelectors.size() > 1 && arSelectors.back().m_pCompiledStyle->Empty())
|
||||
*arSelectors.back().m_pCompiledStyle += *(arSelectors.end() - 2)->m_pCompiledStyle;
|
||||
|
||||
if(arSelectors.crend() != std::find_if(arSelectors.crbegin(), arSelectors.crend(),
|
||||
[](const CNode& oNode){ return IsTableElement(oNode.m_wsName); }))
|
||||
{
|
||||
arSelectors.back().m_pCompiledStyle->m_oBackground.Clear();
|
||||
arSelectors.back().m_pCompiledStyle->m_oBorder.Clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
@ -692,6 +707,16 @@ namespace NSCSS
|
||||
FindPrevAndKindElements(pFoundName, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
|
||||
const CElement* pFoundAll = m_oStyleStorage.FindElement(L"*");
|
||||
|
||||
if (nullptr != pFoundAll)
|
||||
{
|
||||
if (!pFoundAll->Empty())
|
||||
arFindedElements.push_back(pFoundAll);
|
||||
|
||||
FindPrevAndKindElements(pFoundAll, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
|
||||
if (arFindedElements.size() > 1)
|
||||
{
|
||||
std::sort(arFindedElements.rbegin(), arFindedElements.rend(),
|
||||
@ -765,6 +790,11 @@ namespace NSCSS
|
||||
return m_nDpi;
|
||||
}
|
||||
|
||||
bool CCssCalculator_Private::HaveStylesById(const std::wstring& wsId) const
|
||||
{
|
||||
return nullptr != m_oStyleStorage.FindElement(L'#' + wsId);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::ClearEmbeddedStyles()
|
||||
{
|
||||
m_oStyleStorage.ClearEmbeddedStyles();
|
||||
|
||||
@ -37,7 +37,7 @@ namespace NSCSS
|
||||
void ClearPageData();
|
||||
#endif
|
||||
|
||||
const CElement* FindElement(const std::wstring& wsSelector);
|
||||
const CElement* FindElement(const std::wstring& wsSelector) const;
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
@ -77,7 +77,7 @@ namespace NSCSS
|
||||
|
||||
void GetOutputData(KatanaOutput* oOutput, std::map<std::wstring, CElement*>& mStyleData);
|
||||
|
||||
const CElement* FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData);
|
||||
const CElement* FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData) const;
|
||||
};
|
||||
|
||||
class CCssCalculator_Private
|
||||
@ -122,6 +122,8 @@ namespace NSCSS
|
||||
std::wstring GetEncoding() const;
|
||||
unsigned short int GetDpi() const;
|
||||
|
||||
bool HaveStylesById(const std::wstring& wsId) const;
|
||||
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
void ClearStylesFromFile(const std::wstring& wsFilePath);
|
||||
|
||||
@ -1328,7 +1328,14 @@ namespace NSCSS
|
||||
|
||||
// DISPLAY
|
||||
CDisplay::CDisplay()
|
||||
{}
|
||||
{
|
||||
m_eWhiteSpace.SetMapping({{L"normal", EWhiteSpace::Normal },
|
||||
{L"nowrap", EWhiteSpace::Nowrap },
|
||||
{L"pre", EWhiteSpace::Pre },
|
||||
{L"pre-line", EWhiteSpace::Pre_Line},
|
||||
{L"pre-wrap", EWhiteSpace::Pre_Wrap}},
|
||||
EWhiteSpace::Normal);
|
||||
}
|
||||
|
||||
void CDisplay::Equation(CDisplay &oFirstDisplay, CDisplay &oSecondDisplay)
|
||||
{
|
||||
@ -1341,6 +1348,8 @@ namespace NSCSS
|
||||
CString::Equation(oFirstDisplay.m_oHAlign, oSecondDisplay.m_oHAlign);
|
||||
|
||||
CString::Equation(oFirstDisplay.m_oDisplay, oSecondDisplay.m_oDisplay);
|
||||
|
||||
CEnum::Equation(oFirstDisplay.m_eWhiteSpace, oSecondDisplay.m_eWhiteSpace);
|
||||
}
|
||||
|
||||
bool CDisplay::SetX(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
@ -1404,6 +1413,11 @@ namespace NSCSS
|
||||
return m_oDisplay.SetValue(wsValue, NSConstValues::DISPLAY_VALUES, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CDisplay::SetWhiteSpace(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_eWhiteSpace.SetValue(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
const CDigit& CDisplay::GetX() const
|
||||
{
|
||||
return m_oX;
|
||||
@ -1439,34 +1453,42 @@ namespace NSCSS
|
||||
return m_oDisplay;
|
||||
}
|
||||
|
||||
const CEnum& CDisplay::GetWhiteSpace() const
|
||||
{
|
||||
return m_eWhiteSpace;
|
||||
}
|
||||
|
||||
bool CDisplay::Empty() const
|
||||
{
|
||||
return m_oX.Empty() && m_oY.Empty() && m_oWidth.Empty() && m_oHeight.Empty() &&
|
||||
m_oHeight.Empty() && m_oVAlign.Empty() && m_oDisplay.Empty();
|
||||
m_oHeight.Empty() && m_oVAlign.Empty() && m_oDisplay.Empty() &&
|
||||
(m_eWhiteSpace.Empty() || m_eWhiteSpace == EWhiteSpace::Normal);
|
||||
}
|
||||
|
||||
CDisplay &CDisplay::operator+=(const CDisplay &oDisplay)
|
||||
{
|
||||
m_oX += oDisplay.m_oX;
|
||||
m_oY += oDisplay.m_oY;
|
||||
m_oWidth = oDisplay.m_oWidth;
|
||||
m_oHeight = oDisplay.m_oHeight;
|
||||
m_oHAlign += oDisplay.m_oHAlign;
|
||||
m_oVAlign += oDisplay.m_oVAlign;
|
||||
m_oDisplay += oDisplay.m_oDisplay;
|
||||
m_oX += oDisplay.m_oX;
|
||||
m_oY += oDisplay.m_oY;
|
||||
m_oWidth = oDisplay.m_oWidth;
|
||||
m_oHeight = oDisplay.m_oHeight;
|
||||
m_oHAlign += oDisplay.m_oHAlign;
|
||||
m_oVAlign += oDisplay.m_oVAlign;
|
||||
m_oDisplay += oDisplay.m_oDisplay;
|
||||
m_eWhiteSpace += oDisplay.m_eWhiteSpace;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CDisplay::operator==(const CDisplay &oDisplay) const
|
||||
{
|
||||
return m_oX == oDisplay.m_oX &&
|
||||
m_oY == oDisplay.m_oY &&
|
||||
m_oWidth == oDisplay.m_oWidth &&
|
||||
m_oHeight == oDisplay.m_oHeight &&
|
||||
m_oHAlign == oDisplay.m_oHAlign &&
|
||||
m_oVAlign == oDisplay.m_oVAlign &&
|
||||
m_oDisplay == oDisplay.m_oDisplay;
|
||||
return m_oX == oDisplay.m_oX &&
|
||||
m_oY == oDisplay.m_oY &&
|
||||
m_oWidth == oDisplay.m_oWidth &&
|
||||
m_oHeight == oDisplay.m_oHeight &&
|
||||
m_oHAlign == oDisplay.m_oHAlign &&
|
||||
m_oVAlign == oDisplay.m_oVAlign &&
|
||||
m_oDisplay == oDisplay.m_oDisplay &&
|
||||
m_eWhiteSpace == oDisplay.m_eWhiteSpace.ToInt();
|
||||
}
|
||||
|
||||
// STROKE
|
||||
|
||||
@ -328,6 +328,15 @@ namespace NSCSS
|
||||
};
|
||||
|
||||
// PROPERTIES
|
||||
typedef enum
|
||||
{
|
||||
Normal,
|
||||
Nowrap,
|
||||
Pre,
|
||||
Pre_Line,
|
||||
Pre_Wrap
|
||||
} EWhiteSpace;
|
||||
|
||||
class CDisplay
|
||||
{
|
||||
public:
|
||||
@ -347,6 +356,8 @@ namespace NSCSS
|
||||
|
||||
bool SetDisplay(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
bool SetWhiteSpace(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
const CDigit& GetX() const;
|
||||
const CDigit& GetY() const;
|
||||
const CDigit& GetWidth() const;
|
||||
@ -357,6 +368,8 @@ namespace NSCSS
|
||||
|
||||
const CString& GetDisplay() const;
|
||||
|
||||
const CEnum& GetWhiteSpace() const;
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
CDisplay& operator+=(const CDisplay& oDisplay);
|
||||
@ -371,6 +384,8 @@ namespace NSCSS
|
||||
CString m_oVAlign;
|
||||
|
||||
CString m_oDisplay;
|
||||
|
||||
CEnum m_eWhiteSpace;
|
||||
};
|
||||
|
||||
class CStroke
|
||||
|
||||
@ -15,6 +15,10 @@
|
||||
#include "../../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "../../../HtmlFile2/src/StringFinder.h"
|
||||
|
||||
#if defined(CreateDirectory)
|
||||
#undef CreateDirectory
|
||||
#endif
|
||||
|
||||
static std::string nonbreaking_inline = "|a|abbr|acronym|b|bdo|big|cite|code|dfn|em|font|i|img|kbd|nobr|s|small|span|strike|strong|sub|sup|tt|";
|
||||
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|";
|
||||
@ -68,7 +72,7 @@ static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""}).m_sValue;
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\"", "'"}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindProperty(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
ICU_MAJOR_VER = 58
|
||||
ICU_MAJOR_VER = 74
|
||||
|
||||
core_windows {
|
||||
exists($$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/icu) {
|
||||
@ -20,8 +20,15 @@ core_linux {
|
||||
core_mac {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/include
|
||||
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.$${ICU_MAJOR_VER}.dylib
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.$${ICU_MAJOR_VER}.dylib
|
||||
ICU_LIBS_PATH_MAC = $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build
|
||||
bundle_dylibs {
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicudata.a
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicui18n.a
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicuuc.a
|
||||
} else {
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicuuc.$${ICU_MAJOR_VER}.dylib
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicudata.$${ICU_MAJOR_VER}.dylib
|
||||
}
|
||||
}
|
||||
|
||||
core_ios {
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
ICU_VERSION="58"
|
||||
|
||||
ICU_DIR="$PWD/icu"
|
||||
|
||||
ICU_SOURCE="${ICU_DIR}/source"
|
||||
@ -47,8 +45,6 @@ defines_utypes=(
|
||||
|
||||
function prebuild() {
|
||||
|
||||
svn export http://source.icu-project.org/repos/icu/tags/release-${ICU_VERSION}/icu4c/ ${ICU_DIR} --native-eol LF
|
||||
|
||||
echo "===== REMOVING data from bundle ====="
|
||||
|
||||
#Data bundle reduction
|
||||
|
||||
@ -29,7 +29,7 @@ void WriteBaseHtmlStyles(NSFile::CFileBinary& oFile)
|
||||
oFile.WriteStringUTF8(L"<style>");
|
||||
|
||||
// Main styles
|
||||
oFile.WriteStringUTF8(L"* { font-family: Arial; }");
|
||||
oFile.WriteStringUTF8(L"* { font-family: Arial; color:black; white-space:pre; }");
|
||||
oFile.WriteStringUTF8(L"p { margin: 0 0 10px; display: block; }");
|
||||
oFile.WriteStringUTF8(L"a { color: #0553c1; text-decoration: underline; } a:visited { color: #954f72; text-decoration: underline; }");
|
||||
oFile.WriteStringUTF8(L"ul { margin-top: 0; margin-bottom: 10px; }");
|
||||
@ -50,11 +50,10 @@ void WriteBaseHtmlStyles(NSFile::CFileBinary& oFile)
|
||||
|
||||
// Styles for code
|
||||
oFile.WriteStringUTF8(L"code { padding: 2px 4px; font-size: 90%; color: #c7254e; background-color: #f9f2f4; border-radius: 4px; }");
|
||||
oFile.WriteStringUTF8(L"pre code { padding: 0px; white-space: pre-wrap; background-color: transparent; border-radius: 0; color: inherit; }");
|
||||
oFile.WriteStringUTF8(L"pre code { padding: 0px; white-space: pre-wrap; border-radius: 0; background-color: #f5f5f5; color:black; }");
|
||||
oFile.WriteStringUTF8(L"pre { display: block; padding: 9.5px; margin: 0 0 10px; line-height: 1.4; word-break: break-all; word-wrap: break-word; background-color: #f5f5f5; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; }");
|
||||
oFile.WriteStringUTF8(L"code, pre { font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; }");
|
||||
|
||||
|
||||
// Styles for headings
|
||||
oFile.WriteStringUTF8(L"h1 { font-size: 20pt; color: #0f4761; margin-top: 18pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h2 { font-size: 16pt; color: #0f4761; margin-top: 8pt; margin-bottom: 4pt; }");
|
||||
@ -81,12 +80,16 @@ bool ConvertMdFileToHtml(const std::wstring& wsPathToMdFile, const std::wstring&
|
||||
oFile.WriteStringUTF8(L"<html><body>");
|
||||
|
||||
oFile.WriteStringUTF8(L"<head>");
|
||||
//oFile.WriteStringUTF8(L"<meta charset=\"UTF-8\">");
|
||||
oFile.WriteStringUTF8(L"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
|
||||
WriteBaseHtmlStyles(oFile);
|
||||
oFile.WriteStringUTF8(L"</head>");
|
||||
|
||||
bool bResult = true;
|
||||
|
||||
if (0 != md_html(sMdData.c_str(), sMdData.length(), ToHtmlFile, &oFile, MD_DIALECT_GITHUB, 0))
|
||||
if (0 != md_html(sMdData.c_str(), sMdData.length(), ToHtmlFile, &oFile,
|
||||
MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM,
|
||||
0))
|
||||
bResult = false;
|
||||
|
||||
oFile.WriteStringUTF8(L"</body></html>");
|
||||
|
||||
@ -34,6 +34,8 @@
|
||||
#include "../../../../DesktopEditor/common/StringExt.h"
|
||||
|
||||
#include <wininet.h>
|
||||
#include <objbase.h>
|
||||
#include <urlmon.h>
|
||||
#pragma comment(lib, "Wininet")
|
||||
#pragma comment(lib, "Ole32.lib")
|
||||
|
||||
|
||||
@ -240,7 +240,7 @@ bool COfficeFileFormatChecker::isPdfFormatFile(unsigned char *pBuffer, int dwByt
|
||||
|
||||
documentID.clear();
|
||||
|
||||
if (dwBytes < 1)
|
||||
if (dwBytes < 5 || (pBuffer[0] == 'P' && pBuffer[1] == 'K'))
|
||||
return false;
|
||||
|
||||
pBuffer[dwBytes - 1] = '\0';
|
||||
@ -1601,12 +1601,15 @@ bool COfficeFileFormatChecker::isOOXFlatFormatFile(unsigned char *pBuffer, int d
|
||||
const char *xlsxPackage = "progid=\"Excel.Sheet\"";
|
||||
const char *pptxPackage = "progid=\"PowerPoint.Show\"";
|
||||
const char *packageFormatLine = "xmlns:pkg=\"http://schemas.microsoft.com/office/2006/xmlPackage\"";
|
||||
const char* workbookFormatLine = "<Workbook";
|
||||
const char* htmlFormatLine = "<html";
|
||||
|
||||
if (std::string::npos != xml_string.find(docxFormatLine))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_FLAT;
|
||||
}
|
||||
else if (std::string::npos != xml_string.find(xlsxFormatLine))
|
||||
else if (std::string::npos != xml_string.find(xlsxFormatLine) && ( std::string::npos != xml_string.find(workbookFormatLine) ||
|
||||
std::string::npos == xml_string.find(htmlFormatLine)))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT;
|
||||
}
|
||||
|
||||
105
Common/base.pri
105
Common/base.pri
@ -47,7 +47,7 @@ win32 {
|
||||
DEFINES += COPYRIGHT_YEAR=$${CURRENT_YEAR}
|
||||
|
||||
QMAKE_TARGET_COMPANY = $$PUBLISHER_NAME
|
||||
QMAKE_TARGET_COPYRIGHT = Copyright (C) $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved
|
||||
QMAKE_TARGET_COPYRIGHT = © $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved.
|
||||
|
||||
# CONFIGURATION
|
||||
CONFIG(debug, debug|release) {
|
||||
@ -91,6 +91,10 @@ isEqual(QT_MAJOR_VERSION, 5) {
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||
DEFINES += QT_VERSION_6
|
||||
|
||||
core_windows {
|
||||
QMAKE_CXXFLAGS += /permissive-
|
||||
}
|
||||
}
|
||||
|
||||
ios {
|
||||
@ -108,6 +112,10 @@ win32:contains(QMAKE_TARGET.arch, x86_64): {
|
||||
win32:!contains(QMAKE_TARGET.arch, x86_64): {
|
||||
CONFIG += core_win_32
|
||||
}
|
||||
win32:contains(QMAKE_TARGET.arch, arm64): {
|
||||
CONFIG -= core_win_32
|
||||
CONFIG += core_win_arm64
|
||||
}
|
||||
|
||||
linux-clang-libc++ {
|
||||
CONFIG += core_linux
|
||||
@ -190,6 +198,8 @@ core_windows {
|
||||
DEFINES += WIN32 _WIN32
|
||||
DEFINES += NOMINMAX
|
||||
|
||||
#DEFINES += WIN32_LEAN_AND_MEAN
|
||||
|
||||
# use default _ITERATOR_DEBUG_LEVEL value
|
||||
#core_debug:DEFINES += "_ITERATOR_DEBUG_LEVEL=0"
|
||||
}
|
||||
@ -199,6 +209,25 @@ core_win_64 {
|
||||
|
||||
core_linux {
|
||||
DEFINES += LINUX _LINUX
|
||||
|
||||
QMAKE_CUSTOM_SYSROOT = $$(QMAKE_CUSTOM_SYSROOT)
|
||||
QMAKE_CUSTOM_SYSROOT_BIN = $$(QMAKE_CUSTOM_SYSROOT)/usr/bin/
|
||||
|
||||
core_linux_64 {
|
||||
!linux_arm64 { # x86_64
|
||||
QMAKE_CUSTOM_SYSROOT_LIB = $$(QMAKE_CUSTOM_SYSROOT)/usr/lib/x86_64-linux-gnu
|
||||
!isEmpty(QMAKE_CUSTOM_SYSROOT) {
|
||||
message("using custom sysroot $$QMAKE_CUSTOM_SYSROOT")
|
||||
QMAKE_CC = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "gcc")
|
||||
QMAKE_CXX = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
QMAKE_LINK = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
QMAKE_LINK_SHLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
|
||||
QMAKE_CXXFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_LFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
core_linux_host_arm64 {
|
||||
message("build on arm64")
|
||||
@ -211,7 +240,11 @@ core_mac {
|
||||
QMAKE_LFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH
|
||||
|
||||
# xcode15 add new linker
|
||||
QMAKE_LFLAGS += -Wl,-ld_classic
|
||||
greaterThan(QMAKE_XCODE_VERSION, 1499) {
|
||||
QMAKE_LFLAGS += -Wl,-ld_classic
|
||||
} else {
|
||||
CONFIG += c++14
|
||||
}
|
||||
|
||||
QMAKE_CFLAGS += "-Wno-implicit-function-declaration"
|
||||
|
||||
@ -228,8 +261,8 @@ core_linux_clang {
|
||||
# PREFIXES
|
||||
core_windows {
|
||||
CONFIG -= debug_and_release debug_and_release_target
|
||||
QMAKE_CXXFLAGS_RELEASE -= -Zc:strictStrings
|
||||
QMAKE_CXXFLAGS -= -Zc:strictStrings
|
||||
QMAKE_CXXFLAGS_RELEASE += /Zc:strictStrings-
|
||||
QMAKE_CXXFLAGS += /Zc:strictStrings-
|
||||
QMAKE_CXXFLAGS += /MP
|
||||
|
||||
MSVC_VERSION_DETECT = $$(VisualStudioVersion)
|
||||
@ -285,6 +318,9 @@ core_win_32 {
|
||||
core_win_64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_64
|
||||
}
|
||||
core_win_arm64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_arm64
|
||||
}
|
||||
core_linux_32 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = linux_32
|
||||
}
|
||||
@ -311,8 +347,8 @@ linux_arm64 {
|
||||
|
||||
!isEmpty(ARM64_TOOLCHAIN_BIN){
|
||||
!isEmpty(ARM64_TOOLCHAIN_BIN_PREFIX){
|
||||
|
||||
ARM64_TOOLCHAIN_BIN_FULL = $$ARM64_TOOLCHAIN_BIN/$$ARM64_TOOLCHAIN_BIN_PREFIX
|
||||
message("using arm64 toolchain $$ARM64_TOOLCHAIN_BIN")
|
||||
|
||||
QMAKE_CC = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "gcc")
|
||||
QMAKE_CXX = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "g++")
|
||||
@ -572,42 +608,45 @@ core_windows {
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM
|
||||
}
|
||||
|
||||
core_ios:CONFIG+=support_bundle_dylibs
|
||||
core_ios|core_mac {
|
||||
CONFIG += support_bundle_dylibs
|
||||
}
|
||||
|
||||
!support_bundle_dylibs:CONFIG-=bundle_dylibs
|
||||
|
||||
core_ios {
|
||||
bundle_dylibs {
|
||||
plugin {
|
||||
CONFIG -= plugin
|
||||
CONFIG += lib_bundle
|
||||
bundle_dylibs {
|
||||
plugin {
|
||||
CONFIG -= plugin
|
||||
CONFIG += lib_bundle
|
||||
|
||||
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @executable_path/Frameworks
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @loader_path/Frameworks
|
||||
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @executable_path/Frameworks
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @loader_path/Frameworks
|
||||
|
||||
# correct version to < 256
|
||||
VERSIONS = $$split(VERSION, ".")
|
||||
VERSION_1 = $$member(VERSIONS, 0)
|
||||
VERSION_2 = $$member(VERSIONS, 1)
|
||||
VERSION_3 = $$member(VERSIONS, 2)
|
||||
VERSION_4 = $$member(VERSIONS, 3)
|
||||
# correct version to < 256
|
||||
VERSIONS = $$split(VERSION, ".")
|
||||
VERSION_1 = $$member(VERSIONS, 0)
|
||||
VERSION_2 = $$member(VERSIONS, 1)
|
||||
VERSION_3 = $$member(VERSIONS, 2)
|
||||
VERSION_4 = $$member(VERSIONS, 3)
|
||||
|
||||
greaterThan(VERSION_1, 255): VERSION_1 = 255
|
||||
greaterThan(VERSION_2, 255): VERSION_2 = 255
|
||||
greaterThan(VERSION_3, 255): VERSION_3 = 255
|
||||
greaterThan(VERSION_4, 255): VERSION_4 = 255
|
||||
greaterThan(VERSION_1, 255): VERSION_1 = 255
|
||||
greaterThan(VERSION_2, 255): VERSION_2 = 255
|
||||
greaterThan(VERSION_3, 255): VERSION_3 = 255
|
||||
greaterThan(VERSION_4, 255): VERSION_4 = 255
|
||||
|
||||
VERSION_CORRECT = $$VERSION_1
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_2)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_3)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_4)
|
||||
VERSION_CORRECT = $$VERSION_1
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_2)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_3)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_4)
|
||||
|
||||
VERSION = $$VERSION_CORRECT
|
||||
}
|
||||
VERSION = $$VERSION_CORRECT
|
||||
MAJOR_VERSION = $$VERSION_1
|
||||
# set framework version as A
|
||||
QMAKE_FRAMEWORK_VERSION = A
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
Common/js/.gitignore
vendored
1
Common/js/.gitignore
vendored
@ -1 +1,2 @@
|
||||
emsdk
|
||||
__pycache__
|
||||
|
||||
@ -506,7 +506,7 @@ namespace NSDirectory
|
||||
rmdir((char*)pUtf8);
|
||||
delete [] pUtf8;
|
||||
|
||||
if (deleteRoot = false)CreateDirectory(strDirectory);
|
||||
if (deleteRoot == false)CreateDirectory(strDirectory);
|
||||
#elif MAC
|
||||
BYTE* pUtf8 = NULL;
|
||||
LONG lLen = 0;
|
||||
@ -514,7 +514,7 @@ namespace NSDirectory
|
||||
rmdir((char*)pUtf8);
|
||||
delete [] pUtf8;
|
||||
|
||||
if (deleteRoot = false)CreateDirectory(strDirectory);
|
||||
if (deleteRoot == false)CreateDirectory(strDirectory);
|
||||
#endif
|
||||
}
|
||||
std::wstring GetFolderPath(const std::wstring& wsFolderPath)
|
||||
|
||||
@ -1868,7 +1868,7 @@ namespace NSFile
|
||||
|
||||
namespace NSFile
|
||||
{
|
||||
bool CBase64Converter::Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags)
|
||||
bool CBase64Converter::Encode(const BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags)
|
||||
{
|
||||
if (!pDataSrc || nLenSrc < 1)
|
||||
return false;
|
||||
|
||||
@ -212,7 +212,7 @@ namespace NSFile
|
||||
class KERNEL_DECL CBase64Converter
|
||||
{
|
||||
public:
|
||||
static bool Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
|
||||
static bool Encode(const BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
|
||||
static bool Decode(const char* pDataSrc, int nLenSrc, BYTE*& pDataDst, int& nLenDst);
|
||||
};
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ namespace NSProcessEnv
|
||||
static const char* gc_proxy = "proxy";
|
||||
static const char* gc_proxyUser = "proxyUser";
|
||||
static const char* gc_proxyHeader = "proxyHeader";
|
||||
static const char* gc_oformAsPdf = "oformAsPdf";
|
||||
}
|
||||
|
||||
// serialize
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
@ -59,7 +59,7 @@ namespace NSSystemUtils
|
||||
static const wchar_t* gc_EnvLastModifiedBy = L"LAST_MODIFIED_BY";
|
||||
static const wchar_t* gc_EnvModified = L"MODIFIED";
|
||||
static const wchar_t* gc_EnvMemoryLimit = L"X2T_MEMORY_LIMIT";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"4GiB";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"3GiB";
|
||||
|
||||
KERNEL_DECL std::string GetEnvVariableA(const std::wstring& strName);
|
||||
KERNEL_DECL std::wstring GetEnvVariable(const std::wstring& strName);
|
||||
|
||||
@ -46,8 +46,10 @@
|
||||
#define CXIMAGE_SUPPORT_PSD 1
|
||||
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
#define CXIMAGE_SUPPORT_HEIF 1
|
||||
#define CXIMAGE_SUPPORT_RAW 1
|
||||
#else
|
||||
#define CXIMAGE_SUPPORT_HEIF 0
|
||||
#define CXIMAGE_SUPPORT_RAW 0
|
||||
#endif
|
||||
|
||||
|
||||
@ -133,13 +133,17 @@ CXIMAGE_FORMAT_PSD = 20,
|
||||
#if CXIMAGE_SUPPORT_PIC
|
||||
CXIMAGE_FORMAR_PIC = 25,
|
||||
#endif
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
CXIMAGE_FORMAT_HEIF = 26,
|
||||
#endif
|
||||
CMAX_IMAGE_FORMATS = CXIMAGE_SUPPORT_BMP + CXIMAGE_SUPPORT_GIF + CXIMAGE_SUPPORT_JPG +
|
||||
CXIMAGE_SUPPORT_PNG + CXIMAGE_SUPPORT_MNG + CXIMAGE_SUPPORT_ICO +
|
||||
CXIMAGE_SUPPORT_TIF + CXIMAGE_SUPPORT_TGA + CXIMAGE_SUPPORT_PCX +
|
||||
CXIMAGE_SUPPORT_WBMP+ CXIMAGE_SUPPORT_WMF + CXIMAGE_SUPPORT_PIC +
|
||||
CXIMAGE_SUPPORT_JBG + CXIMAGE_SUPPORT_JP2 + CXIMAGE_SUPPORT_JPC +
|
||||
CXIMAGE_SUPPORT_PGX + CXIMAGE_SUPPORT_PNM + CXIMAGE_SUPPORT_RAS +
|
||||
CXIMAGE_SUPPORT_SKA + CXIMAGE_SUPPORT_RAW + CXIMAGE_SUPPORT_PSD + 1
|
||||
CXIMAGE_SUPPORT_SKA + CXIMAGE_SUPPORT_RAW + CXIMAGE_SUPPORT_PSD +
|
||||
CXIMAGE_SUPPORT_HEIF + 1
|
||||
};
|
||||
|
||||
#if CXIMAGE_SUPPORT_EXIF
|
||||
|
||||
@ -23,14 +23,14 @@
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma warning (disable : 4550)
|
||||
|
||||
#pragma warning (disable : 4550)
|
||||
|
||||
/*
|
||||
* TIFF Library
|
||||
*
|
||||
* Read and return a packed RGBA image.
|
||||
*/
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
#include <stdio.h>
|
||||
|
||||
@ -828,11 +828,12 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
nrowsub = nrow;
|
||||
if ((nrowsub%subsamplingver)!=0)
|
||||
nrowsub+=subsamplingver-nrowsub%subsamplingver;
|
||||
|
||||
if (TIFFReadEncodedStrip(tif,
|
||||
TIFFComputeStrip(tif,row+img->row_offset, 0),
|
||||
buf,
|
||||
((row + img->row_offset)%rowsperstrip + nrowsub) * scanline) < 0
|
||||
&& img->stoponerr)
|
||||
((row + img->row_offset)%rowsperstrip + nrowsub) * scanline) < 0
|
||||
&& img->stoponerr)
|
||||
{
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
@ -23,6 +23,30 @@ public class NativeLibraryLoader {
|
||||
}
|
||||
}
|
||||
|
||||
private static String libPrefix;
|
||||
private static String libExtension;
|
||||
|
||||
private static boolean loadIfExist(String libPath) {
|
||||
File libFile = new File(libPath);
|
||||
if (libFile.exists()) {
|
||||
System.load(libPath);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void load(Path libDirPath, String libName) {
|
||||
String libPath = libDirPath.resolve(libPrefix + libName + libExtension).toString();
|
||||
if (OSChecker.isMac()) {
|
||||
if (!loadIfExist(libPath)) {
|
||||
// if dylib does not exist, load framework library
|
||||
System.load(libDirPath.resolve(libName + ".framework/" + libName).toString());
|
||||
}
|
||||
} else {
|
||||
System.load(libPath);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
Path libDirPath = getLibPath();
|
||||
@ -31,8 +55,8 @@ public class NativeLibraryLoader {
|
||||
System.load(libDirPath.resolve("icudt58.dll").toString());
|
||||
System.load(libDirPath.resolve("icuuc58.dll").toString());
|
||||
} else if (OSChecker.isMac()) {
|
||||
System.load(libDirPath.resolve("libicudata.58.dylib").toString());
|
||||
System.load(libDirPath.resolve("libicuuc.58.dylib").toString());
|
||||
loadIfExist(libDirPath.resolve("libicudata.58.dylib").toString());
|
||||
loadIfExist(libDirPath.resolve("libicuuc.58.dylib").toString());
|
||||
} else if (OSChecker.isLinux()) {
|
||||
System.load(libDirPath.resolve("libicudata.so.58").toString());
|
||||
System.load(libDirPath.resolve("libicuuc.so.58").toString());
|
||||
@ -42,24 +66,25 @@ public class NativeLibraryLoader {
|
||||
|
||||
String[] libs = {"UnicodeConverter", "kernel", "kernel_network", "graphics", "PdfFile", "XpsFile", "DjVuFile", "DocxRenderer", "doctrenderer", "docbuilder.jni"};
|
||||
|
||||
String prefix = "";
|
||||
libPrefix = "";
|
||||
if (OSChecker.isMac() || OSChecker.isLinux()) {
|
||||
prefix = "lib";
|
||||
libPrefix = "lib";
|
||||
}
|
||||
|
||||
String extension = "";
|
||||
libExtension = "";
|
||||
if (OSChecker.isWindows()) {
|
||||
extension = ".dll";
|
||||
libExtension = ".dll";
|
||||
} else if (OSChecker.isMac()) {
|
||||
extension = ".dylib";
|
||||
libExtension = ".dylib";
|
||||
} else {
|
||||
extension = ".so";
|
||||
libExtension = ".so";
|
||||
}
|
||||
|
||||
for (String lib : libs) {
|
||||
System.load(libDirPath.resolve(prefix + lib + extension).toString());
|
||||
load(libDirPath, lib);
|
||||
}
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
throw new RuntimeException("Cannot load dynamic libraries. Check if JAR file is in the same directory as all docbuilder libraries.");
|
||||
}
|
||||
}
|
||||
|
||||
1
DesktopEditor/doctrenderer/docbuilder.net/.gitignore
vendored
Normal file
1
DesktopEditor/doctrenderer/docbuilder.net/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
deploy/
|
||||
@ -24,6 +24,10 @@ def _loadLibrary(path):
|
||||
library_name = 'libdocbuilder.c.so'
|
||||
elif 'darwin' == os_name:
|
||||
library_name = 'libdocbuilder.c.dylib'
|
||||
# if there is no dylib file, get library from framework
|
||||
if not os.path.exists(path + '/' + library_name):
|
||||
path = path + '/docbuilder.c.framework'
|
||||
library_name = 'docbuilder.c'
|
||||
|
||||
_lib = ctypes.CDLL(path + '/' + library_name)
|
||||
|
||||
@ -437,7 +441,7 @@ 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")
|
||||
|
||||
@ -74,6 +74,7 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder, cons
|
||||
global->set("native", oNativeCtrl);
|
||||
|
||||
CBuilderEmbed* pBuilderJSNative = static_cast<CBuilderEmbed*>(oBuilderJS->getNative());
|
||||
pBuilderJSNative->SetExternalize(true);
|
||||
pBuilderJSNative->m_pBuilder = pBuilder;
|
||||
}
|
||||
CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
@ -1272,7 +1273,7 @@ namespace NSDoctRenderer
|
||||
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
m_pInternal->m_bIsOpenedFromSimpleJS = false;
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_pInternal->m_nFileType = -1;
|
||||
@ -1513,7 +1514,8 @@ namespace NSDoctRenderer
|
||||
if (nCountParameters > 2)
|
||||
sParams = _builder_params[2].c_str();
|
||||
|
||||
this->SaveFile(nFormat, _builder_params[1].c_str(), sParams);
|
||||
int nSaveError = this->SaveFile(nFormat, _builder_params[1].c_str(), sParams);
|
||||
bIsNoError = (0 == nSaveError);
|
||||
}
|
||||
else if ("WriteData" == sFuncNum)
|
||||
{
|
||||
|
||||
@ -547,6 +547,7 @@ namespace NSDoctRenderer
|
||||
CApplicationFontsWorker oWorker;
|
||||
oWorker.m_bIsUseSystemFonts = m_oParams.m_bIsSystemFonts;
|
||||
oWorker.m_arAdditionalFolders = m_oParams.m_arFontDirs;
|
||||
oWorker.m_arAdditionalFolders.push_back(NSFile::GetProcessDirectory() + L"/fonts");
|
||||
oWorker.m_bIsNeedThumbnails = false;
|
||||
oWorker.m_sDirectory = sDirectory;
|
||||
// это не рабочая папка, где только шрифты
|
||||
@ -927,7 +928,7 @@ namespace NSDoctRenderer
|
||||
|
||||
COfficeFileFormatChecker oChecker;
|
||||
if (!oChecker.isOfficeFile(sFileCopy))
|
||||
return false;
|
||||
return 1;
|
||||
|
||||
if (oChecker.nFileType & AVS_OFFICESTUDIO_FILE_DOCUMENT)
|
||||
m_nFileType = 0;
|
||||
|
||||
@ -289,10 +289,20 @@ public:
|
||||
return ((CPdfFile*)m_pFile)->SplitPages(arrPageIndex, nLength, data, size);
|
||||
return NULL;
|
||||
}
|
||||
bool MergePages(BYTE* data, LONG size, int nMaxID, const std::string& sPrefixForm)
|
||||
bool MergePages(BYTE* data, LONG size, int nMaxID, const std::string& sPrefixForm, bool bCopy = false)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
{
|
||||
// Память из CDrawingFileEmbed освобождается сразу после вызова функции, поэтому копируем
|
||||
if (bCopy)
|
||||
{
|
||||
BYTE* pCopy = (BYTE*)malloc(size);
|
||||
memcpy(pCopy, data, size);
|
||||
data = pCopy;
|
||||
}
|
||||
// Захватывает полученную память, будет освобождена либо в деструкторе MemStream, либо free в случае неудачи
|
||||
return ((CPdfFile*)m_pFile)->MergePages(data, size, nMaxID, sPrefixForm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool UnmergePages()
|
||||
@ -420,22 +430,32 @@ public:
|
||||
oRenderer.SetExternalImageStorage(m_pImageStorage);
|
||||
oRenderer.SetTextAssociationType(NSDocxRenderer::TextAssociationType::tatParagraphToShape);
|
||||
|
||||
std::vector<std::wstring> arShapes;
|
||||
if (0 == mode)
|
||||
arShapes = oRenderer.ScanPage(m_pFile, nPageIndex);
|
||||
else
|
||||
arShapes = oRenderer.ScanPagePptx(m_pFile, nPageIndex);
|
||||
|
||||
int nLen = (int)arShapes.size();
|
||||
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
oRes.AddInt(nLen);
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
std::vector<std::wstring> arShapes = (0 == mode) ? oRenderer.ScanPage(m_pFile, nPageIndex) : oRenderer.ScanPagePptx(m_pFile, nPageIndex);
|
||||
int nLen = (int)arShapes.size();
|
||||
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
oRes.WriteString(arShapes[i]);
|
||||
oRes.SkipLen();
|
||||
oRes.AddInt(nLen);
|
||||
|
||||
oRes.WriteLen();
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
oRes.WriteString(arShapes[i]);
|
||||
|
||||
oRes.WriteLen();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
oRes = oRenderer.ScanPageBin(m_pFile, nPageIndex);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
|
||||
@ -195,7 +195,7 @@ JSSmart<CJSValue> CDrawingFileEmbed::MergePages(JSSmart<CJSValue> data, JSSmart<
|
||||
int maxID = nMaxID->toInt32();
|
||||
std::string prefix = sPrefixForm->toStringA();
|
||||
CJSDataBuffer buffer = dataPtr->getData();
|
||||
result = m_pFile->MergePages(buffer.Data, (LONG)buffer.Len, maxID, prefix);
|
||||
result = m_pFile->MergePages(buffer.Data, (LONG)buffer.Len, maxID, prefix, true);
|
||||
if (buffer.IsExternalize)
|
||||
buffer.Free();
|
||||
}
|
||||
|
||||
@ -196,7 +196,9 @@ JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSVa
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::Destroy()
|
||||
{
|
||||
// For save image bits, if needed.
|
||||
m_pInternal->Destroy();
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::EndDraw()
|
||||
|
||||
@ -45,7 +45,7 @@ public:
|
||||
|
||||
public:
|
||||
CBuilderDocumentEmbed() : m_pBuilder(NULL), m_bIsValid(false) {}
|
||||
~CBuilderDocumentEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
~CBuilderDocumentEmbed() { if(m_pBuilder && !m_isExternalize) RELEASEOBJECT(m_pBuilder); }
|
||||
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
NSDoctRenderer::CDocBuilder_Private* GetPrivate(NSDoctRenderer::CDocBuilder* pBuilder) { return pBuilder->GetPrivate(); }
|
||||
|
||||
@ -88,6 +88,7 @@ JSSmart<CJSValue> CBuilderEmbed::OpenTmpFile(JSSmart<CJSValue> path, JSSmart<CJS
|
||||
JSSmart<CJSObject> oBuilderTmpDoc = CJSContext::createEmbedObject("CBuilderDocumentEmbed");
|
||||
CBuilderDocumentEmbed* pBuilderTmpDocNative = static_cast<CBuilderDocumentEmbed*>(oBuilderTmpDoc->getNative());
|
||||
pBuilderTmpDocNative->m_pBuilder = m_pBuilder;
|
||||
pBuilderTmpDocNative->SetExternalize(true);
|
||||
pBuilderTmpDocNative->_OpenFile(sPath, sParams);
|
||||
return oBuilderTmpDoc->toValue();
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
NSDoctRenderer::CDocBuilder* m_pBuilder;
|
||||
|
||||
CBuilderEmbed() : m_pBuilder(NULL) {}
|
||||
~CBuilderEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
~CBuilderEmbed() { if(m_pBuilder && !m_isExternalize) RELEASEOBJECT(m_pBuilder); }
|
||||
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
NSDoctRenderer::CDocBuilder_Private* GetPrivate() { return m_pBuilder->GetPrivate(); }
|
||||
|
||||
@ -42,6 +42,7 @@ namespace NSGraphics
|
||||
|
||||
m_pRenderer = NSGraphics::Create();
|
||||
m_pRenderer->SetFontManager(pManager);
|
||||
RELEASEINTERFACE(pManager);
|
||||
|
||||
int nRasterW = (int)width_px;
|
||||
int nRasterH = (int)height_px;
|
||||
|
||||
@ -115,17 +115,16 @@ namespace NSGraphics
|
||||
class CGraphics
|
||||
{
|
||||
public:
|
||||
CGraphicsAppImage* m_pAppImage;
|
||||
CGraphicsAppImage* m_pAppImage = nullptr;
|
||||
CBgraFrame m_oFrame;
|
||||
|
||||
private:
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer;
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer = nullptr;
|
||||
CGrState m_oGrState;
|
||||
|
||||
public:
|
||||
CGraphics()
|
||||
{
|
||||
m_pAppImage = NULL;
|
||||
}
|
||||
~CGraphics()
|
||||
{
|
||||
|
||||
@ -31,6 +31,7 @@ namespace NSJSBase {
|
||||
{
|
||||
embed_native_internal = nullptr;
|
||||
m_pAdapter = nullptr;
|
||||
m_isExternalize = false;
|
||||
}
|
||||
|
||||
CJSEmbedObject::~CJSEmbedObject()
|
||||
@ -44,6 +45,16 @@ namespace NSJSBase {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CJSEmbedObject::SetExternalize(const bool& isExternalize)
|
||||
{
|
||||
m_isExternalize = isExternalize;
|
||||
}
|
||||
|
||||
bool CJSEmbedObject::GetExternalize()
|
||||
{
|
||||
return m_isExternalize;
|
||||
}
|
||||
|
||||
CJSEmbedObjectAdapterBase* CJSEmbedObject::getAdapter()
|
||||
{
|
||||
return nullptr;
|
||||
|
||||
@ -194,10 +194,18 @@ namespace NSJSBase
|
||||
*/
|
||||
virtual CJSEmbedObjectAdapterBase* getAdapter();
|
||||
|
||||
/**
|
||||
* Use the externalize flag if you are monitoring the object's destruction yourself.
|
||||
*/
|
||||
virtual void SetExternalize(const bool& isExternalize = true);
|
||||
virtual bool GetExternalize();
|
||||
|
||||
protected:
|
||||
CJSEmbedObjectPrivateBase* embed_native_internal;
|
||||
CJSEmbedObjectAdapterBase* m_pAdapter;
|
||||
|
||||
bool m_isExternalize;
|
||||
|
||||
friend class CJSEmbedObjectPrivateBase;
|
||||
friend class CJSEmbedObjectPrivate;
|
||||
};
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
@protocol JSEmbedObjectProtocol
|
||||
-(void*) getNative;
|
||||
-(void) freeNative;
|
||||
@end
|
||||
|
||||
#if __has_feature(objc_arc)
|
||||
@ -41,6 +42,10 @@
|
||||
-(void*) getNative \
|
||||
{ \
|
||||
return m_internal; \
|
||||
} \
|
||||
-(void) freeNative \
|
||||
{ \
|
||||
RELEASEOBJECT(m_internal); \
|
||||
}
|
||||
|
||||
namespace NSJSBase
|
||||
|
||||
@ -34,6 +34,7 @@ namespace NSJSBase
|
||||
|
||||
// embed
|
||||
id CreateEmbedNativeObject(NSString* name);
|
||||
void FreeNativeObject(id embedded_object);
|
||||
}
|
||||
|
||||
namespace NSJSBase
|
||||
|
||||
@ -232,10 +232,14 @@ namespace NSJSBase
|
||||
{
|
||||
[m_internal->context evaluateScript:@"function jsc_toBase64(r){for(var o=[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\",\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\",\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"+\",\"/\"],a=r.length,f=4*(a/3>>0),n=f/76>>0,t=19,v=0,e=[],i=\"\",s=0;s<=n;s++){s==n&&(t=f%76/4>>0);for(var u=0;u<t;u++){for(var c=0,h=0;h<3;h++)c|=r[0+v++],c<<=8;i=\"\";for(var A=0;A<4;A++){i+=o[c>>>26&255],c<<=6,c&=4294967295}e.push(i)}}if(n=a%3!=0?a%3+1:0){for(c=0,h=0;h<3;h++)h<a%3&&(c|=r[0+v++]),c<<=8;i=\"\";for(A=0;A<n;A++){i+=o[c>>>26&255],c<<=6}t=0!=n?4-n:0;for(u=0;u<t;u++)i+=\"=\";e.push(i)}return e.join(\"\")}function jsc_fromBase64(r,o){for(var a,f=r.length,n=0,t=new Array(void 0===o?f:o),v=t,e=0,i=0;e<f;){for(var s=0,u=0,c=0;c<4&&!(f<=e);c++){var h=65<=(a=r.charCodeAt(e++))&&a<=90?a-65:97<=a&&a<=122?a-71:48<=a&&a<=57?a+4:43==a?62:47==a?63:-1;-1!=h?(s<<=6,s|=h,u+=6):c--}for(s<<=24-u,i=u>>>3,c=0;c<i;c++)v[n++]=(16711680&s)>>>16,s<<=8}return t}\n"];
|
||||
}
|
||||
// insert CreateEmbedObject() function to global object of this context
|
||||
// insert embed functions to global object of this context
|
||||
m_internal->context[@"CreateEmbedObject"] = ^(NSString* name) {
|
||||
return CreateEmbedNativeObject(name);
|
||||
};
|
||||
m_internal->context[@"FreeEmbedObject"] = ^(id embedded_object) {
|
||||
FreeNativeObject(embedded_object);
|
||||
};
|
||||
|
||||
|
||||
JSValue* global_js = [m_internal->context globalObject];
|
||||
[global_js setValue:global_js forProperty:[[NSString alloc] initWithUTF8String:"window"]];
|
||||
@ -246,6 +250,8 @@ namespace NSJSBase
|
||||
{
|
||||
CGlobalContext::GetInstance().UnregisterContextForId(*i);
|
||||
}
|
||||
// remove any exceptions pending to not prevent any JSValue deallocations
|
||||
m_internal->context.exception = nil;
|
||||
m_internal->context = nil;
|
||||
}
|
||||
|
||||
@ -503,6 +509,15 @@ namespace NSJSBase
|
||||
return pEmbedObj;
|
||||
}
|
||||
|
||||
void FreeNativeObject(id embedded_object)
|
||||
{
|
||||
// check if the object was actually embedded and do nothing if it wasn't
|
||||
if ([embedded_object conformsToProtocol:@protocol(JSEmbedObjectProtocol)])
|
||||
{
|
||||
[embedded_object freeNative];
|
||||
}
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CJSEmbedObjectAdapterJSC::Native2Value(JSValue* value)
|
||||
{
|
||||
return js_value(value);
|
||||
|
||||
@ -214,12 +214,41 @@ namespace NSJSBase
|
||||
m_internal->m_contextPersistent.Reset(isolate, v8::Context::New(isolate));
|
||||
// create temporary local handle to context
|
||||
m_internal->m_context = v8::Local<v8::Context>::New(isolate, m_internal->m_contextPersistent);
|
||||
// insert CreateEmbedObject() function to global object of this context
|
||||
// insert embed functions to global object of this context
|
||||
m_internal->InsertToGlobal("CreateEmbedObject", CreateEmbedNativeObject);
|
||||
m_internal->InsertToGlobal("FreeEmbedObject", FreeNativeObject);
|
||||
// clear temporary local handle
|
||||
m_internal->m_context.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
class WeakHandleVisitor : public v8::PersistentHandleVisitor
|
||||
{
|
||||
private:
|
||||
WeakHandleVisitor() = default;
|
||||
|
||||
public:
|
||||
void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_t class_id) override
|
||||
{
|
||||
if (class_id == CJSEmbedObjectPrivate::kWeakHandleId)
|
||||
{
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
v8::Local<v8::Object> handle = value->Get(isolate).As<v8::Object>();
|
||||
v8::Local<v8::External> field = v8::Local<v8::External>::Cast(handle->GetInternalField(0));
|
||||
CJSEmbedObject* native = static_cast<CJSEmbedObject*>(field->Value());
|
||||
delete native;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
static WeakHandleVisitor* getInstance()
|
||||
{
|
||||
static WeakHandleVisitor visitor;
|
||||
return &visitor;
|
||||
}
|
||||
};
|
||||
|
||||
void CJSContext::Dispose()
|
||||
{
|
||||
#ifdef V8_INSPECTOR
|
||||
@ -228,7 +257,13 @@ namespace NSJSBase
|
||||
#endif
|
||||
|
||||
m_internal->m_contextPersistent.Reset();
|
||||
m_internal->m_isolate->Dispose();
|
||||
// destroy native object in the weak handles before isolate disposal
|
||||
v8::Isolate* isolate = m_internal->m_isolate;
|
||||
{
|
||||
v8::Isolate::Scope scope(isolate);
|
||||
isolate->VisitHandlesWithClassIds(WeakHandleVisitor::getInstance());
|
||||
}
|
||||
isolate->Dispose();
|
||||
m_internal->m_isolate = NULL;
|
||||
}
|
||||
|
||||
@ -655,4 +690,22 @@ namespace NSJSBase
|
||||
NSJSBase::CJSEmbedObjectPrivate::CreateWeaker(obj);
|
||||
args.GetReturnValue().Set(obj);
|
||||
}
|
||||
|
||||
void FreeNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
if (args.Length() != 1)
|
||||
{
|
||||
args.GetReturnValue().Set(v8::Undefined(isolate));
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> obj = args[0].As<v8::Object>();
|
||||
v8::Local<v8::External> field = v8::Local<v8::External>::Cast(obj->GetInternalField(0));
|
||||
CJSEmbedObject* native = static_cast<CJSEmbedObject*>(field->Value());
|
||||
delete native;
|
||||
// weak persistent handle will be cleared and removed in CJSEmbedObjectPrivate destructor
|
||||
}
|
||||
}
|
||||
|
||||
@ -883,6 +883,7 @@ namespace NSJSBase
|
||||
|
||||
// embed
|
||||
void CreateEmbedNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
void FreeNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
class CJSEmbedObjectAdapterV8Template : public CJSEmbedObjectAdapterBase
|
||||
{
|
||||
@ -900,6 +901,8 @@ namespace NSJSBase
|
||||
{
|
||||
public:
|
||||
v8::Persistent<v8::Object> handle;
|
||||
// contstant id for all weak native handles
|
||||
static const uint16_t kWeakHandleId = 1;
|
||||
|
||||
CJSEmbedObjectPrivate(v8::Local<v8::Object> obj)
|
||||
{
|
||||
@ -918,6 +921,8 @@ namespace NSJSBase
|
||||
|
||||
handle.Reset(CV8Worker::GetCurrent(), obj);
|
||||
handle.SetWeak(pEmbedObject, EmbedObjectWeakCallback, v8::WeakCallbackType::kParameter);
|
||||
// set class_id for being able to iterate over all these handles to destroy them on isolate disposal
|
||||
handle.SetWrapperClassId(kWeakHandleId);
|
||||
|
||||
pEmbedObject->embed_native_internal = this;
|
||||
}
|
||||
@ -931,8 +936,6 @@ namespace NSJSBase
|
||||
|
||||
static void EmbedObjectWeakCallback(const v8::WeakCallbackInfo<CJSEmbedObject>& data)
|
||||
{
|
||||
v8::Isolate* isolate = data.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
CJSEmbedObject* wrap = data.GetParameter();
|
||||
((CJSEmbedObjectPrivate*)wrap->embed_native_internal)->handle.Reset();
|
||||
delete wrap;
|
||||
|
||||
@ -1,4 +1,15 @@
|
||||
#include "Embed.h"
|
||||
#include <iostream>
|
||||
|
||||
CTestEmbed::CTestEmbed()
|
||||
{
|
||||
std::cout << "debug: CTestEmbed constructed" << std::endl;
|
||||
}
|
||||
|
||||
CTestEmbed::~CTestEmbed()
|
||||
{
|
||||
std::cout << "debug: CTestEmbed destroyed" << std::endl;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SUM_DEL
|
||||
JSSmart<CJSValue> CTestEmbed::FunctionSum(JSSmart<CJSValue> param1, JSSmart<CJSValue> param2)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef _BUILD_NATIVE_HASH_EMBED_H_
|
||||
#define _BUILD_NATIVE_HASH_EMBED_H_
|
||||
#ifndef CTESTEMBED_H_
|
||||
#define CTESTEMBED_H_
|
||||
|
||||
#include "js_internal/js_base.h"
|
||||
|
||||
@ -10,13 +10,8 @@ using namespace NSJSBase;
|
||||
class CTestEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
CTestEmbed()
|
||||
{
|
||||
}
|
||||
|
||||
~CTestEmbed()
|
||||
{
|
||||
}
|
||||
CTestEmbed();
|
||||
~CTestEmbed();
|
||||
|
||||
virtual void* getObject() override { return NULL; }
|
||||
|
||||
@ -33,4 +28,4 @@ public:
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
#endif // _BUILD_NATIVE_HASH_EMBED_H_
|
||||
#endif // CTESTEMBED_H_
|
||||
|
||||
@ -1,278 +1,14 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "test_functions.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "embed/Default.h"
|
||||
#include "js_internal/js_base.h"
|
||||
#include "Embed.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
int main(int argc, char *argv[])
|
||||
int main()
|
||||
{
|
||||
#if 0
|
||||
// Primitives example
|
||||
// TODO: test
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext(false);
|
||||
oContext1->Initialize();
|
||||
|
||||
JSSmart<CJSContext> oContext2 = new CJSContext;
|
||||
// oContext2->Initialize();
|
||||
|
||||
// Work with first context
|
||||
oContext1->Enter();
|
||||
|
||||
{
|
||||
CJSContextScope scope(oContext1);
|
||||
CJSLocalScope local_scope;
|
||||
JSSmart<CJSValue> oResLocal = oContext1->runScript("function f() { return 'Local scope test'; }; f();");
|
||||
std::cout << oResLocal->toStringA() << std::endl;
|
||||
}
|
||||
JSSmart<CJSObject> oGlobal1 = oContext1->GetGlobal();
|
||||
JSSmart<CJSValue> oVar2 = oContext1->createString("Hel");
|
||||
oGlobal1->set("v1", oVar2.GetPointer());
|
||||
oContext1->runScript("var res = v1 + 'lo'");
|
||||
|
||||
oContext1->Exit();
|
||||
|
||||
// Work with second context with CJSContextScope usage
|
||||
{
|
||||
CJSContextScope scope(oContext2);
|
||||
|
||||
JSSmart<CJSObject> oGlobal2 = oContext2->GetGlobal();
|
||||
JSSmart<CJSValue> oVar4 = oContext2->createString("Wor");
|
||||
oGlobal2->set("v1", oVar4.GetPointer());
|
||||
oContext2->runScript("var res = v1 + 'ld!'");
|
||||
}
|
||||
|
||||
// Print result from first context
|
||||
oContext1->Enter();
|
||||
|
||||
JSSmart<CJSValue> oRes1 = oContext1->runScript("function f() { return res; }; f();");
|
||||
std::string strRes1 = oRes1->toStringA();
|
||||
std::cout << strRes1 << std::endl;
|
||||
|
||||
// Print second variable
|
||||
oContext2->Enter();
|
||||
|
||||
JSSmart<CJSValue> oRes2 = oContext1->runScript("function f() { return res; }; f();");
|
||||
std::string strRes2 = oRes2->toStringA();
|
||||
std::cout << strRes2 << std::endl;
|
||||
|
||||
oContext2->Exit();
|
||||
oContext1->Exit();
|
||||
|
||||
// oContext1->Dispose();
|
||||
oContext2->Dispose();
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// External embed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
|
||||
// Embedding
|
||||
CJSContextScope scope(oContext1);
|
||||
CJSContext::Embed<CTestEmbed>();
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed1 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSum(10, 5); })();");
|
||||
std::cout << "FunctionSum(10, 5) = " << oResTestEmbed1->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed2 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSquare(4); })();");
|
||||
std::cout << "FunctionSquare(4) = " << oResTestEmbed2->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed3 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionDel(30, 3); })();");
|
||||
std::cout << "FunctionDel(30, 3) = " << oResTestEmbed3->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed4 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionGet(); })();");
|
||||
std::cout << "FunctionGet() = " << oResTestEmbed4->toInt32() << std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// CZipEmbed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
JSSmart<CJSContext> oContext2 = new CJSContext();
|
||||
|
||||
// Work with first context
|
||||
oContext1->Enter();
|
||||
CreateDefaults();
|
||||
JSSmart<CJSValue> oRes1 = oContext1->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();");
|
||||
oContext1->Exit();
|
||||
|
||||
// Work with second context
|
||||
{
|
||||
CJSContextScope scope(oContext2);
|
||||
// CreateDefaults();
|
||||
JSSmart<CJSValue> oRes2 = oContext2->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "/../embed');\n"
|
||||
"oZip.close();");
|
||||
}
|
||||
|
||||
// Print first result
|
||||
oContext1->Enter();
|
||||
JSSmart<CJSObject> oGlobal1 = oContext1->GetGlobal();
|
||||
JSSmart<CJSArray> oFiles1 = oGlobal1->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 1:\n";
|
||||
for (int i = 0; i < oFiles1->getCount(); i++)
|
||||
{
|
||||
std::cout << oFiles1->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
// Print second result
|
||||
oContext2->Enter();
|
||||
JSSmart<CJSObject> oGlobal2 = oContext2->GetGlobal();
|
||||
JSSmart<CJSArray> oFiles2 = oGlobal2->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 2:\n";
|
||||
for (int i = 0; i < oFiles2->getCount(); i++)
|
||||
{
|
||||
std::cout << oFiles2->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
oContext2->Exit();
|
||||
oContext1->Exit();
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// CHashEmbed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
|
||||
// Call hash() on first context
|
||||
CJSContextScope scope(oContext1);
|
||||
CreateDefaults();
|
||||
JSSmart<CJSValue> oRes1 = oContext1->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);");
|
||||
|
||||
// Print first result
|
||||
JSSmart<CJSObject> oGlobal1 = oContext1->GetGlobal();
|
||||
JSSmart<CJSTypedArray> oHash = oGlobal1->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < oHash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(oHash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// Call hash2() on first context
|
||||
JSSmart<CJSValue> oRes2 = oContext1->runScript(
|
||||
"var str2 = 'test';\n"
|
||||
"var hash2 = oHash.hash2(str2, 'yrGivlyCImiWnryRee1OJw==', 100000, 7);");
|
||||
|
||||
// Print first result
|
||||
JSSmart<CJSTypedArray> oHash2 = oGlobal1->get("hash2")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH2:\n";
|
||||
for (int i = 0; i < oHash2->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(oHash2->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
// Mixed embed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
|
||||
// External CTestEmbed
|
||||
CJSContextScope scope(oContext1);
|
||||
CJSContext::Embed<CTestEmbed>(false);
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed1 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSum(10, 5); })();");
|
||||
if (oResTestEmbed1->isNumber())
|
||||
std::cout << "FunctionSum(10, 5) = " << oResTestEmbed1->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSObject> oTestEmbed = CJSContext::createEmbedObject("CTestEmbed");
|
||||
|
||||
// JSSmart<CJSValue> oResTestEmbed2 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSquare(4); })();");
|
||||
JSSmart<CJSValue> args2[1];
|
||||
args2[0] = CJSContext::createInt(4);
|
||||
JSSmart<CJSValue> oResTestEmbed2 = oTestEmbed->call_func("FunctionSquare", 1, args2);
|
||||
if (oResTestEmbed2->isNumber())
|
||||
std::cout << "FunctionSquare(4) = " << oResTestEmbed2->toInt32() << std::endl;
|
||||
|
||||
// JSSmart<CJSValue> oResTestEmbed3 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionDel(30, 3); })();");
|
||||
JSSmart<CJSValue> args3[2];
|
||||
args3[0] = CJSContext::createInt(30);
|
||||
args3[1] = CJSContext::createInt(3);
|
||||
JSSmart<CJSValue> oResTestEmbed3 = oTestEmbed->call_func("FunctionDel", 2, args3);
|
||||
if (oResTestEmbed3->isNumber())
|
||||
std::cout << "FunctionDel(30, 3) = " << oResTestEmbed3->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed4 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionGet(); })();");
|
||||
if (oResTestEmbed4->isNumber())
|
||||
std::cout << "FunctionGet() = " << oResTestEmbed4->toInt32() << std::endl;
|
||||
|
||||
// Internal CHashEmbed
|
||||
CreateDefaults();
|
||||
oContext1->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);");
|
||||
|
||||
// Print hash
|
||||
JSSmart<CJSObject> oGlobal = oContext1->GetGlobal();
|
||||
JSSmart<CJSTypedArray> oHash = oGlobal->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < oHash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(oHash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// Internal CZipEmbed
|
||||
oContext1->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();");
|
||||
|
||||
// Print files
|
||||
JSSmart<CJSArray> oFiles1 = oGlobal->get("files")->toArray();
|
||||
std::cout << "\nFILES IN CURRENT DIRECTORY:\n";
|
||||
for (int i = 0; i < oFiles1->getCount(); i++)
|
||||
{
|
||||
std::cout << oFiles1->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
#endif
|
||||
// testMultipleContexts();
|
||||
testEmbedExternal();
|
||||
// testEmbedInternal();
|
||||
// testHashEmbed();
|
||||
// testEmbedMixed();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
14
DesktopEditor/doctrenderer/test/embed/external/main.mm
vendored
Normal file
14
DesktopEditor/doctrenderer/test/embed/external/main.mm
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
#include "test_functions.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// all test functions should be called inside the `@autoreleasepool` block!
|
||||
@autoreleasepool
|
||||
{
|
||||
testEmbedExternal();
|
||||
// testHashEmbed();
|
||||
// testEmbedMixed();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -29,10 +29,18 @@ core_linux {
|
||||
LIBS += -ldl
|
||||
}
|
||||
|
||||
SOURCES += main.cpp \
|
||||
Embed.cpp
|
||||
|
||||
HEADERS += \
|
||||
Embed.h
|
||||
Embed.h \
|
||||
test_functions.h
|
||||
|
||||
SOURCES += \
|
||||
Embed.cpp \
|
||||
test_functions.cpp
|
||||
|
||||
use_javascript_core {
|
||||
OBJECTIVE_SOURCES += main.mm
|
||||
} else {
|
||||
SOURCES += main.cpp
|
||||
}
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(Embed.h)
|
||||
|
||||
286
DesktopEditor/doctrenderer/test/embed/external/test_functions.cpp
vendored
Normal file
286
DesktopEditor/doctrenderer/test/embed/external/test_functions.cpp
vendored
Normal file
@ -0,0 +1,286 @@
|
||||
#include "test_functions.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "embed/Default.h"
|
||||
#include "js_internal/js_base.h"
|
||||
#include "Embed.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
|
||||
void testMultipleContexts()
|
||||
{
|
||||
// passing `false` when creating CJSContext means that we need to initialize it manually
|
||||
JSSmart<CJSContext> context1 = new CJSContext(false);
|
||||
context1->Initialize();
|
||||
|
||||
// while creating CJSContext without any arguments will create initialized CJSContext
|
||||
JSSmart<CJSContext> context2 = new CJSContext;
|
||||
// we don't need it:
|
||||
// oContext2->Initialize();
|
||||
|
||||
// entering the first context
|
||||
context1->Enter();
|
||||
{
|
||||
// entering the first context the second time in scope creation - it's allowed and the scopes stack correctly
|
||||
CJSContextScope scope(context1);
|
||||
// allocate new local variables inside a custom local scope instead of
|
||||
// the one that is provided by CJSContextScope by default
|
||||
CJSLocalScope local_scope;
|
||||
JSSmart<CJSValue> res_local = context1->runScript("(function() { return 'Local scope test'; })();");
|
||||
std::cout << res_local->toStringA() << std::endl;
|
||||
// the first context is going to be exited at the end of the scope
|
||||
}
|
||||
// at this moment we are still inside the first context, since we have entered it twices
|
||||
JSSmart<CJSObject> global1 = context1->GetGlobal();
|
||||
JSSmart<CJSValue> var = context1->createString("Hel");
|
||||
global1->set("v1", var);
|
||||
// here `res` is set to be "Hello"
|
||||
context1->runScript("var res = v1 + 'lo'");
|
||||
// exit from the first context
|
||||
context1->Exit();
|
||||
|
||||
// now we are going to work with the second context
|
||||
{
|
||||
// enter the second context via context scope
|
||||
CJSContextScope scope(context2);
|
||||
|
||||
JSSmart<CJSObject> global2 = context2->GetGlobal();
|
||||
JSSmart<CJSValue> var = context2->createString("Wor");
|
||||
global2->set("v1", var);
|
||||
// `res` is "World!"
|
||||
context2->runScript("var res = v1 + 'ld!'");
|
||||
// the second context is going to be exited at the end of the scope
|
||||
}
|
||||
|
||||
// enter the first context
|
||||
context1->Enter();
|
||||
// print `res` variable from the first context
|
||||
JSSmart<CJSValue> res1 = context1->runScript("(function() { return res; })();");
|
||||
std::string str_res1 = res1->toStringA();
|
||||
std::cout << str_res1 << ", ";
|
||||
// make new variable `v2` in first context
|
||||
// important to note, that accessing previous `global1` object is undefined behaviour and can lead to crashes!
|
||||
// that is because when we exited from the first context, every local handle inside CJSValue and CJSObject was invalidated
|
||||
global1 = context1->GetGlobal();
|
||||
global1->set("v2", CJSContext::createInt(42));
|
||||
|
||||
// enter from the second context (notice, we haven't exited the first context before)
|
||||
context2->Enter();
|
||||
// print `res` variable from the second context
|
||||
JSSmart<CJSValue> res2 = context1->runScript("(function() { return res; })();");
|
||||
std::string str_res2 = res2->toStringA();
|
||||
std::cout << str_res2 << std::endl;
|
||||
|
||||
// exit from the second context
|
||||
context2->Exit();
|
||||
|
||||
// at this moment we are still in the first context
|
||||
// we can validate that accessing `v2` variable, which exists only in the first context
|
||||
global1 = context1->GetGlobal();
|
||||
std::cout << global1->get("v2")->toInt32() << std::endl;
|
||||
// exit from the first context
|
||||
context1->Exit();
|
||||
|
||||
// manual disposing is not necessary, since it's going to be called in CJSContext's destructor anyway
|
||||
// so we don't need to explicitly write:
|
||||
// oContext1->Dispose();
|
||||
|
||||
// but still nothing wrong will happen if we do:
|
||||
context2->Dispose();
|
||||
}
|
||||
|
||||
void testEmbedExternal()
|
||||
{
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
|
||||
// Embedding
|
||||
CJSContextScope scope(context);
|
||||
CJSContext::Embed<CTestEmbed>();
|
||||
|
||||
JSSmart<CJSValue> res1 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionSum(10, 5); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionSum(10, 5) = " << res1->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> res2 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionSquare(4); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionSquare(4) = " << res2->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> res3 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionDel(30, 3); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionDel(30, 3) = " << res3->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> res4 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionGet(); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionGet() = " << res4->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
void testEmbedInternal()
|
||||
{
|
||||
// create both contexts
|
||||
JSSmart<CJSContext> context1 = new CJSContext();
|
||||
JSSmart<CJSContext> context2 = new CJSContext();
|
||||
|
||||
// work with the first context
|
||||
context1->Enter();
|
||||
// create embedding info for internally embedded objects (CZipEmbed is the one of them)
|
||||
CreateDefaults();
|
||||
context1->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();"
|
||||
);
|
||||
context1->Exit();
|
||||
|
||||
// work with the second context via context scope
|
||||
{
|
||||
CJSContextScope scope(context2);
|
||||
// function CJSContext::Embed() is context-independent, so we don't actually need to call it in another context
|
||||
// CreateDefaults();
|
||||
context2->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "/../../../embed');\n"
|
||||
"oZip.close();"
|
||||
);
|
||||
}
|
||||
|
||||
// print the files from the first context
|
||||
context1->Enter();
|
||||
JSSmart<CJSObject> global1 = context1->GetGlobal();
|
||||
JSSmart<CJSArray> file_list1 = global1->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 1:\n";
|
||||
for (int i = 0; i < file_list1->getCount(); i++)
|
||||
{
|
||||
std::cout << file_list1->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
// print the files from the second result (note, we haven't exited the first context before)
|
||||
context2->Enter();
|
||||
JSSmart<CJSObject> global2 = context2->GetGlobal();
|
||||
JSSmart<CJSArray> file_list2 = global2->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 2:\n";
|
||||
for (int i = 0; i < file_list2->getCount(); i++)
|
||||
{
|
||||
std::cout << file_list2->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
// exit the contexts in reverse order
|
||||
context2->Exit();
|
||||
context1->Exit();
|
||||
}
|
||||
|
||||
void testHashEmbed()
|
||||
{
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
|
||||
// test hash()
|
||||
CJSContextScope scope(context);
|
||||
CreateDefaults();
|
||||
context->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);"
|
||||
);
|
||||
|
||||
JSSmart<CJSObject> global = context->GetGlobal();
|
||||
JSSmart<CJSTypedArray> res_hash = global->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < res_hash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(res_hash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// test hash2()
|
||||
context->runScript(
|
||||
"var str2 = 'test';\n"
|
||||
"var hash2 = oHash.hash2(str2, 'yrGivlyCImiWnryRee1OJw==', 100000, 7);"
|
||||
);
|
||||
|
||||
JSSmart<CJSTypedArray> res_hash2 = global->get("hash2")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH2:\n";
|
||||
for (int i = 0; i < res_hash2->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(res_hash2->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void testEmbedMixed()
|
||||
{
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
CJSContextScope scope(context);
|
||||
|
||||
|
||||
// --- test external embedding with CTestEmbed ---
|
||||
// embed with `false` - means we are not able to create the object directly from JavaScript.
|
||||
CJSContext::Embed<CTestEmbed>(false);
|
||||
|
||||
// example of incorrect usage:
|
||||
JSSmart<CJSValue> res1 = context->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSum(10, 5); })();");
|
||||
if (res1->isNumber())
|
||||
{
|
||||
// this wouldn't print anything, since `res1` not a number - embedded object was not created in JS and exception was thrown.
|
||||
std::cout << "FunctionSum(10, 5) = " << res1->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
// example of correct usage:
|
||||
JSSmart<CJSObject> embedded_object = CJSContext::createEmbedObject("CTestEmbed");
|
||||
JSSmart<CJSValue> args2[1];
|
||||
args2[0] = CJSContext::createInt(4);
|
||||
JSSmart<CJSValue> res2 = embedded_object->call_func("FunctionSquare", 1, args2);
|
||||
if (res2->isNumber())
|
||||
{
|
||||
// should print: "FunctionSquare(4) = 16"
|
||||
std::cout << "FunctionSquare(4) = " << res2->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
// another example of correct usage:
|
||||
JSSmart<CJSValue> args3[2];
|
||||
args3[0] = CJSContext::createInt(30);
|
||||
args3[1] = CJSContext::createInt(3);
|
||||
JSSmart<CJSValue> oResTestEmbed3 = embedded_object->call_func("FunctionDel", 2, args3);
|
||||
if (oResTestEmbed3->isNumber())
|
||||
{
|
||||
// should print: "FunctionDel(30, 3) = 10"
|
||||
std::cout << "FunctionDel(30, 3) = " << oResTestEmbed3->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
// another example of incorrect usage:
|
||||
JSSmart<CJSValue> oResTestEmbed4 = context->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionGet(); })();");
|
||||
if (oResTestEmbed4->isNumber())
|
||||
{
|
||||
// again, this won't be executed and nothing will be printed
|
||||
std::cout << "FunctionGet() = " << oResTestEmbed4->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
// --- test internal embedding with CHashEmbed ---
|
||||
CreateDefaults();
|
||||
context->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);"
|
||||
);
|
||||
// print hash
|
||||
JSSmart<CJSObject> global = context->GetGlobal();
|
||||
JSSmart<CJSTypedArray> hash = global->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < hash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(hash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
|
||||
// --- test internal embedding with CZipEmbed ---
|
||||
context->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();"
|
||||
);
|
||||
|
||||
// print files
|
||||
JSSmart<CJSArray> file_list = global->get("files")->toArray();
|
||||
std::cout << "\nFILES IN CURRENT DIRECTORY:\n";
|
||||
for (int i = 0; i < file_list->getCount(); i++)
|
||||
{
|
||||
std::cout << file_list->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
}
|
||||
34
DesktopEditor/doctrenderer/test/embed/external/test_functions.h
vendored
Normal file
34
DesktopEditor/doctrenderer/test/embed/external/test_functions.h
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef TEST_FUNCTIONS_H_
|
||||
#define TEST_FUNCTIONS_H_
|
||||
|
||||
|
||||
/**
|
||||
* NOTE: V8 ONLY!
|
||||
* The function tests the work of two CJSContexts in one thread.
|
||||
* Current working context is managed with Enter() and Exit() functions, or with CJSContextScope.
|
||||
*/
|
||||
void testMultipleContexts();
|
||||
|
||||
/**
|
||||
* The function tests external embedding functionality by embedding CTestEmbed class.
|
||||
*/
|
||||
void testEmbedExternal();
|
||||
|
||||
/**
|
||||
* NOTE: V8 ONLY!
|
||||
* The function tests internal embedding functionality by using CZipEmbed class.
|
||||
* It also shows how embedding works for two CJSContext in the same thread (similar to testMultipleContexts()).
|
||||
*/
|
||||
void testEmbedInternal();
|
||||
|
||||
/**
|
||||
* The function tests CHashEmbed class that is embedded internally.
|
||||
*/
|
||||
void testHashEmbed();
|
||||
|
||||
/**
|
||||
* The function tests both internal and external embedding in a more complicated way.
|
||||
*/
|
||||
void testEmbedMixed();
|
||||
|
||||
#endif // TEST_FUNCTIONS_H_
|
||||
@ -1853,6 +1853,16 @@ std::vector<std::wstring> CApplicationFonts::GetSetupFontFiles(const bool& bIsUs
|
||||
#if defined(_MAC) && !defined(_IOS)
|
||||
std::vector<std::wstring> _array = NSDirectory::GetFiles(L"/Library/Fonts", true);
|
||||
NSDirectory::GetFiles2(L"/System/Library/Fonts", _array, true);
|
||||
|
||||
std::set<std::wstring> installedList = GetInstalledFontsMac();
|
||||
for (const auto& sysPath : installedList) {
|
||||
if (0 == sysPath.find(L"/System/Library/Fonts/"))
|
||||
continue;
|
||||
if (0 == sysPath.find(L"/Library/Fonts/"))
|
||||
continue;
|
||||
_array.push_back(sysPath);
|
||||
}
|
||||
|
||||
return _array;
|
||||
#endif
|
||||
|
||||
@ -1958,6 +1968,10 @@ namespace NSFonts
|
||||
if (FT_Open_Face(m_internal->m_library, &oOpenArgs, nFaceIndex, &pFace))
|
||||
return;
|
||||
|
||||
bool bIsASC = false;
|
||||
if (pFace->family_name && (0 == strcmp(pFace->family_name, "ASCW3")))
|
||||
bIsASC = true;
|
||||
|
||||
for (int nCharMap = 0; nCharMap < pFace->num_charmaps; nCharMap++)
|
||||
{
|
||||
FT_Set_Charmap(pFace, pFace->charmaps[nCharMap]);
|
||||
@ -1967,7 +1981,8 @@ namespace NSFonts
|
||||
|
||||
while (indexG)
|
||||
{
|
||||
pChecker->Check((int)character, indexG);
|
||||
if (!bIsASC || (character < 35 || character > 255))
|
||||
pChecker->Check((int)character, indexG);
|
||||
character = FT_Get_Next_Char(pFace, character, &indexG);
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "FontManager.h"
|
||||
#include <set>
|
||||
|
||||
namespace NSFonts
|
||||
{
|
||||
@ -354,6 +355,10 @@ public:
|
||||
void InitFromReg();
|
||||
#endif
|
||||
|
||||
#if defined(_MAC) && !defined(_IOS)
|
||||
std::set<std::wstring> GetInstalledFontsMac();
|
||||
#endif
|
||||
|
||||
NSFonts::IFontManager* GenerateFontManager();
|
||||
|
||||
std::wstring GetFontBySymbol(int symbol);
|
||||
|
||||
@ -877,6 +877,11 @@ public:
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"PingFang SC", 36));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"PingFang TC", 37));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"PingFang HK", 38));
|
||||
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Heiti SC", 39));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Heiti TC", 40));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Songti SC", 41));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Songti TC", 42));
|
||||
#endif
|
||||
|
||||
NSFonts::CApplicationFontsSymbols oApplicationChecker;
|
||||
@ -1604,6 +1609,14 @@ NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
|
||||
if (m_sDirectory.empty())
|
||||
return NULL;
|
||||
|
||||
for (std::vector<std::wstring>::iterator i = m_arAdditionalFolders.begin(); i != m_arAdditionalFolders.end(); i++)
|
||||
{
|
||||
if (0 == i->find(L"./"))
|
||||
*i = NSFile::GetProcessDirectory() + L"/" + i->substr(2);
|
||||
else if (0 == i->find(L"../"))
|
||||
*i = NSFile::GetProcessDirectory() + L"/" + *i;
|
||||
}
|
||||
|
||||
std::wstring strAllFontsJSPath = m_sDirectory + L"/AllFonts.js";
|
||||
std::wstring strFontsSelectionBin = m_sDirectory + L"/font_selection.bin";
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
#include <vector>
|
||||
#include "../graphics/pro/Fonts.h"
|
||||
|
||||
#define ONLYOFFICE_FONTS_VERSION 12
|
||||
#define ONLYOFFICE_FONTS_VERSION 14
|
||||
#define ONLYOFFICE_ALL_FONTS_VERSION 2
|
||||
|
||||
class CApplicationFontsWorkerBreaker
|
||||
|
||||
@ -29,37 +29,36 @@
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include "ApplicationFonts.h"
|
||||
#include "../common/File.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreText/CoreText.h>
|
||||
|
||||
#include "./../WrapperWritingElement.h"
|
||||
#include "./../Limit/FrameShape.h"
|
||||
#include "./../Limit/AlbumLayout.h"
|
||||
|
||||
namespace PPTX
|
||||
std::set<std::wstring> CApplicationFonts::GetInstalledFontsMac()
|
||||
{
|
||||
namespace nsPresentation
|
||||
std::set<std::wstring> paths;
|
||||
|
||||
CFArrayRef fontURLs = CTFontManagerCopyAvailableFontURLs();
|
||||
if (!fontURLs)
|
||||
return paths;
|
||||
|
||||
NSStringEncoding encode = CFStringConvertEncodingToNSStringEncoding (kCFStringEncodingUTF32LE);
|
||||
|
||||
CFIndex count = CFArrayGetCount(fontURLs);
|
||||
for (CFIndex i = 0; i < count; ++i)
|
||||
{
|
||||
class PhotoAlbum : public WrapperWritingElement
|
||||
{
|
||||
public:
|
||||
PPTX_LOGIC_BASE(PhotoAlbum)
|
||||
CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(fontURLs, i);
|
||||
if (!url)
|
||||
continue;
|
||||
|
||||
public:
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node);
|
||||
virtual std::wstring toXML() const;
|
||||
NSString* nsPath = [(__bridge NSURL *)url path];
|
||||
if (!nsPath)
|
||||
continue;
|
||||
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
|
||||
nullable_bool bw;
|
||||
nullable_limit<Limit::FrameShape> frame;
|
||||
nullable_limit<Limit::AlbumLayout> layout;
|
||||
nullable_bool showCaptions;
|
||||
|
||||
protected:
|
||||
virtual void FillParentPointersForChilds();
|
||||
};
|
||||
} // namespace nsPresentation
|
||||
} // namespace PPTX
|
||||
NSData* pSData = [nsPath dataUsingEncoding: encode];
|
||||
paths.emplace(std::wstring((wchar_t*)[pSData bytes], [pSData length] / sizeof (wchar_t)));
|
||||
}
|
||||
|
||||
CFRelease(fontURLs);
|
||||
return paths;
|
||||
}
|
||||
@ -83,6 +83,7 @@
|
||||
"./../../graphics/pro/js/wasm/src/lib",
|
||||
|
||||
"./../../../Common/3dParty/harfbuzz/harfbuzz/src",
|
||||
"./../../../Common/3dParty/brotli/brotli/c/include",
|
||||
|
||||
"./../../../OfficeUtils/src",
|
||||
"./../../../OfficeUtils/src/zlib-1.2.11",
|
||||
@ -113,6 +114,8 @@
|
||||
"BUILD_ZLIB_AS_SOURCES",
|
||||
"IMAGE_CHECKER_DISABLE_XML",
|
||||
|
||||
"FT_CONFIG_OPTION_USE_BROTLI",
|
||||
|
||||
"BUILDING_WASM_MODULE"
|
||||
],
|
||||
"compile_files_array": [
|
||||
@ -349,6 +352,26 @@
|
||||
{
|
||||
"folder": "./../../../Common/3dParty/hyphen/js/src",
|
||||
"files": ["hyphen.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "./../../../Common/3dParty/brotli/brotli/c/common",
|
||||
"files": [
|
||||
"constants.c",
|
||||
"context.c",
|
||||
"dictionary.c",
|
||||
"platform.c",
|
||||
"shared_dictionary.c",
|
||||
"transform.c"
|
||||
]
|
||||
},
|
||||
{
|
||||
"folder": "./../../../Common/3dParty/brotli/brotli/c/dec",
|
||||
"files": [
|
||||
"bit_reader.c",
|
||||
"decode.c",
|
||||
"huffman.c",
|
||||
"state.c"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -917,15 +917,15 @@ function onLoadFontsModule(window, undefined)
|
||||
this._mapToNames = AscCommon.spellcheckGetLanguages();
|
||||
|
||||
let _langKey = "" + lang;
|
||||
let _langName = this._mapToNames[_langKey];
|
||||
if (_langName === undefined)
|
||||
let _langObj = this._mapToNames[_langKey];
|
||||
if (!_langObj || !_langObj["hyphen"] || !_langObj["name"])
|
||||
{
|
||||
this._dictionaries[_langKey] = false;
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
this._loadDictionaryAttemt(_langKey, _langName, callback);
|
||||
this._loadDictionaryAttemt(_langKey, _langObj["name"], callback);
|
||||
};
|
||||
|
||||
this._loadDictionaryAttemt = function(langKey, langName, callback, currentAttempt)
|
||||
|
||||
@ -214,7 +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; }
|
||||
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)
|
||||
{
|
||||
@ -224,6 +224,7 @@ BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
|
||||
const std::wstring& CAnnotFieldInfo::GetNM() { return m_wsNM; }
|
||||
const std::wstring& CAnnotFieldInfo::GetLM() { return m_wsLM; }
|
||||
const std::wstring& CAnnotFieldInfo::GetOUserID() { return m_wsOUserID; }
|
||||
const std::wstring& CAnnotFieldInfo::GetOMetadata() { return m_wsOMetadata; }
|
||||
const std::wstring& CAnnotFieldInfo::GetContents() { return m_wsContents; }
|
||||
const std::vector<double>& CAnnotFieldInfo::GetC() { return m_arrC; }
|
||||
|
||||
@ -362,6 +363,8 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
m_wsOUserID = pReader->ReadString();
|
||||
if (nFlags & (1 << 8))
|
||||
m_nCopyAP = pReader->ReadInt();
|
||||
if (nFlags & (1 << 9))
|
||||
m_wsOMetadata = pReader->ReadString();
|
||||
|
||||
if (IsMarkup())
|
||||
{
|
||||
@ -680,6 +683,7 @@ int CAnnotFieldInfo::CWidgetAnnotPr::GetR() const { return m_nR; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetFlags() const { return m_nFlags; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetParentID() const { return m_nParentID; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetMEOptions() const { return m_nMEOptions; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetFontStyle() const { return m_nFontStyle; }
|
||||
double CAnnotFieldInfo::CWidgetAnnotPr::GetFontSize() const { return m_dFS; }
|
||||
double CAnnotFieldInfo::CWidgetAnnotPr::GetFontSizeAP() const { return m_dFSAP; }
|
||||
@ -689,7 +693,6 @@ 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; }
|
||||
@ -890,8 +893,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();
|
||||
if (nFlags & (1 << 21))
|
||||
m_nMEOptions = pReader->ReadInt();
|
||||
|
||||
// Action
|
||||
int nAction = pReader->ReadInt();
|
||||
@ -1143,6 +1146,10 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
}
|
||||
if (nFlags & (1 << 9))
|
||||
pParent->nMaxLen = pReader->ReadInt();
|
||||
if (nFlags & (1 << 10))
|
||||
pParent->sTU = pReader->ReadString();
|
||||
if (nFlags & (1 << 11))
|
||||
pParent->nMEOptions = pReader->ReadInt();
|
||||
m_arrParents.push_back(pParent);
|
||||
}
|
||||
|
||||
@ -1151,7 +1158,10 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::string sImagePath = pReader->ReadStringA();
|
||||
m_arrButtonImg.push_back(pCorrector->GetImagePath(UTF8_TO_U(sImagePath)));
|
||||
std::wstring sImage = UTF8_TO_U(sImagePath);
|
||||
if (sImagePath.find("data:") != 0 && !sImagePath.empty())
|
||||
sImage = pCorrector->GetImagePath(sImage);
|
||||
m_arrButtonImg.push_back(sImage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -185,6 +185,7 @@ public:
|
||||
int GetFlag() const;
|
||||
int GetFlags() const;
|
||||
int GetParentID() const;
|
||||
int GetMEOptions() const;
|
||||
int GetFontStyle() const;
|
||||
double GetFontSize() const;
|
||||
double GetFontSizeAP() const;
|
||||
@ -194,7 +195,6 @@ 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();
|
||||
@ -215,6 +215,7 @@ public:
|
||||
int m_nFlag;
|
||||
int m_nFlags;
|
||||
int m_nParentID;
|
||||
int m_nMEOptions;
|
||||
int m_nFontStyle;
|
||||
double m_dFS;
|
||||
double m_dFSAP;
|
||||
@ -224,7 +225,6 @@ 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;
|
||||
@ -471,6 +471,7 @@ public:
|
||||
const std::wstring& GetNM();
|
||||
const std::wstring& GetLM();
|
||||
const std::wstring& GetOUserID();
|
||||
const std::wstring& GetOMetadata();
|
||||
const std::wstring& GetContents();
|
||||
const std::vector<double>& GetC();
|
||||
|
||||
@ -527,6 +528,7 @@ private:
|
||||
std::wstring m_wsNM;
|
||||
std::wstring m_wsLM;
|
||||
std::wstring m_wsOUserID;
|
||||
std::wstring m_wsOMetadata;
|
||||
std::wstring m_wsContents;
|
||||
std::pair<BYTE, double> m_pBE;
|
||||
std::vector<double> m_arrC;
|
||||
@ -571,10 +573,12 @@ public:
|
||||
int nFlags;
|
||||
int nMaxLen;
|
||||
int nParentID;
|
||||
int nMEOptions;
|
||||
int nFieldFlag;
|
||||
std::wstring sName;
|
||||
std::wstring sV;
|
||||
std::wstring sDV;
|
||||
std::wstring sTU;
|
||||
std::vector<int> arrI;
|
||||
std::vector<std::wstring> arrV;
|
||||
std::vector<CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget*> arrAction;
|
||||
|
||||
@ -18,6 +18,12 @@ SOURCES += \
|
||||
$$FONT_ENGINE_PATH/FontPath.cpp \
|
||||
$$FONT_ENGINE_PATH/GlyphString.cpp
|
||||
|
||||
core_mac {
|
||||
OBJECTIVE_SOURCES += $$FONT_ENGINE_PATH/ApplicationFonts_mac.mm
|
||||
LIBS += -framework Foundation
|
||||
LIBS += -framework CoreText
|
||||
}
|
||||
|
||||
# Application fonts worker
|
||||
HEADERS += $$FONT_ENGINE_PATH/ApplicationFontsWorker.h
|
||||
SOURCES += $$FONT_ENGINE_PATH/ApplicationFontsWorker.cpp
|
||||
@ -38,6 +44,10 @@ enable_support_shaper {
|
||||
}
|
||||
# -------------------------------------------------
|
||||
|
||||
# ------------------- brotli ----------------------
|
||||
include($$PWD/../../../Common/3dParty/brotli/brotli.pri)
|
||||
# -------------------------------------------------
|
||||
|
||||
# ------------------- hyphen ----------------------
|
||||
HEADERS += $$FONT_ENGINE_PATH/languages.h
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@
|
||||
},
|
||||
{
|
||||
"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"]
|
||||
"files": ["ustr_wcs.cpp", "ustrtrns.cpp", "udata.cpp", "ucnv_io.cpp", "ustring.cpp", "umutex.cpp", "putil.cpp", "ustr_cnv.cpp", "ucnvmbcs.cpp", "ucln_cmn.cpp", "ucnv2022.cpp", "ucnvbocu.cpp", "stringpiece.cpp", "charstr.cpp", "ucnv_ext.cpp", "uobject.cpp", "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", "ustrcase.cpp", "bytestrie.cpp", "utf_impl.cpp", "cmemory.cpp", "uhash.cpp", "udatamem.cpp", "umapfile.cpp", "uinvchar.cpp", "uchar.cpp", "ubidi_props.cpp", "characterproperties.cpp", "ucptrie.cpp", "edits.cpp", "umutablecptrie.cpp", "bytesinkutil.cpp", "emojiprops.cpp", "cstring.cpp", "ucmndata.cpp", "ucnv.cpp", "ucnv_u7.cpp", "ucnv_u8.cpp", "ucnv_u16.cpp", "ucnv_u32.cpp", "ucnv_err.cpp", "ucnv_cnv.cpp", "ucnv_lmb.cpp", "ucnv_cb.cpp", "ucnv_ct.cpp", "ucharstrieiterator.cpp", "ucnvlat1.cpp", "uvectr32.cpp", "ucnvhz.cpp", "ucnvscsu.cpp", "ucnv_bld.cpp", "ucnvisci.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/cryptopp/",
|
||||
@ -195,7 +195,7 @@
|
||||
},
|
||||
{
|
||||
"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"]
|
||||
"files": ["AcroForm.cpp", "Annotation.cpp", "Catalog.cpp", "Destination.cpp", "Document.cpp", "Encrypt.cpp", "EncryptDictionary.cpp", "Field.cpp", "Font.cpp", "Font14.cpp", "FontCidTT.cpp", "FontOTWriter.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/",
|
||||
|
||||
@ -717,6 +717,7 @@ SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontCidTT.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTT.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTTWriter.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontOTWriter.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/GState.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Image.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Info.cpp \
|
||||
|
||||
@ -40,7 +40,7 @@ var UpdateFontsSource = {
|
||||
function CFile()
|
||||
{
|
||||
this.nativeFile = 0;
|
||||
this.stream = [];
|
||||
this.stream = -1;
|
||||
this.stream_size = 0;
|
||||
this.type = -1;
|
||||
this.pages = [];
|
||||
@ -128,17 +128,17 @@ CFile.prototype["close"] = function()
|
||||
this.pages = [];
|
||||
this.info = null;
|
||||
this.StartID = null;
|
||||
for (let i = 0; i < this.stream.length; i++)
|
||||
this._free(this.stream[i]);
|
||||
this.stream = [];
|
||||
if (this.stream > 0)
|
||||
this._free(this.stream);
|
||||
this.stream = -1;
|
||||
self.drawingFile = null;
|
||||
};
|
||||
|
||||
CFile.prototype["getFileBinary"] = function()
|
||||
{
|
||||
if (this.stream.length == 0)
|
||||
if (0 >= this.stream)
|
||||
return "";
|
||||
return new Uint8Array(Module["HEAP8"].buffer, this.stream[0], this.stream_size);
|
||||
return new Uint8Array(Module["HEAP8"].buffer, this.stream, this.stream_size);
|
||||
};
|
||||
|
||||
CFile.prototype["isNeedPassword"] = function()
|
||||
@ -543,9 +543,10 @@ function readAnnot(reader, rec, readDoubleFunc, readDouble2Func, readStringFunc,
|
||||
// User ID
|
||||
if (flags & (1 << 7))
|
||||
rec["OUserID"] = readStringFunc.call(reader);
|
||||
// User ID
|
||||
if (flags & (1 << 8))
|
||||
rec["AP"]["Copy"] = reader.readInt();
|
||||
// if (flags & (1 << 8))
|
||||
// reader.readInt();
|
||||
if (flags & (1 << 9))
|
||||
rec["meta"] = readStringFunc.call(reader);
|
||||
}
|
||||
function readAnnotAP(reader, AP)
|
||||
{
|
||||
@ -581,7 +582,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
{
|
||||
// Markup
|
||||
let flags = 0;
|
||||
if ((rec["Type"] < 18 && rec["Type"] != 1 && rec["Type"] != 15) || rec["Type"] == 25)
|
||||
if ((rec["type"] < 18 && rec["type"] != 1 && rec["type"] != 15) || rec["type"] == 25)
|
||||
{
|
||||
flags = reader.readInt();
|
||||
if (flags & (1 << 0))
|
||||
@ -636,7 +637,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
rec["Subj"] = readStringFunc.call(reader);
|
||||
}
|
||||
// Text
|
||||
if (rec["Type"] == 0)
|
||||
if (rec["type"] == 0)
|
||||
{
|
||||
// Background color - C->IC
|
||||
if (rec["C"])
|
||||
@ -660,7 +661,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
|
||||
}
|
||||
// Line
|
||||
else if (rec["Type"] == 3)
|
||||
else if (rec["type"] == 3)
|
||||
{
|
||||
// L
|
||||
rec["L"] = [];
|
||||
@ -710,7 +711,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
}
|
||||
}
|
||||
// Ink
|
||||
else if (rec["Type"] == 14)
|
||||
else if (rec["type"] == 14)
|
||||
{
|
||||
// offsets like getStructure and viewer.navigate
|
||||
let n = reader.readInt();
|
||||
@ -724,7 +725,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
}
|
||||
}
|
||||
// Highlight, Underline, Squiggly, Strikeout
|
||||
else if (rec["Type"] > 7 && rec["Type"] < 12)
|
||||
else if (rec["type"] > 7 && rec["type"] < 12)
|
||||
{
|
||||
// QuadPoints
|
||||
let n = reader.readInt();
|
||||
@ -733,7 +734,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
rec["QuadPoints"].push(readDoubleFunc.call(reader));
|
||||
}
|
||||
// Square, Circle
|
||||
else if (rec["Type"] == 4 || rec["Type"] == 5)
|
||||
else if (rec["type"] == 4 || rec["type"] == 5)
|
||||
{
|
||||
// Rect and RD differences
|
||||
if (flags & (1 << 15))
|
||||
@ -752,7 +753,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
}
|
||||
}
|
||||
// Polygon, PolyLine
|
||||
else if (rec["Type"] == 6 || rec["Type"] == 7)
|
||||
else if (rec["type"] == 6 || rec["type"] == 7)
|
||||
{
|
||||
let nVertices = reader.readInt();
|
||||
rec["Vertices"] = [];
|
||||
@ -780,8 +781,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
rec["IT"] = reader.readByte();
|
||||
}
|
||||
// Popup
|
||||
/*
|
||||
else if (rec["Type"] == 15)
|
||||
else if (rec["type"] == 15)
|
||||
{
|
||||
flags = reader.readInt();
|
||||
rec["Open"] = (flags >> 0) & 1;
|
||||
@ -789,9 +789,8 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
if (flags & (1 << 1))
|
||||
rec["PopupParent"] = reader.readInt();
|
||||
}
|
||||
*/
|
||||
// FreeText
|
||||
else if (rec["Type"] == 2)
|
||||
else if (rec["type"] == 2)
|
||||
{
|
||||
// Background color - C->IC
|
||||
if (!isRead && rec["C"])
|
||||
@ -847,7 +846,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
}
|
||||
}
|
||||
// Caret
|
||||
else if (rec["Type"] == 13)
|
||||
else if (rec["type"] == 13)
|
||||
{
|
||||
// Rect and RD differenses
|
||||
if (flags & (1 << 15))
|
||||
@ -862,7 +861,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
rec["Sy"] = reader.readByte();
|
||||
}
|
||||
// FileAttachment
|
||||
else if (rec["Type"] == 16)
|
||||
else if (rec["type"] == 16)
|
||||
{
|
||||
if (flags & (1 << 15))
|
||||
rec["Icon"] = readStringFunc.call(reader);
|
||||
@ -961,7 +960,7 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
rec["Desc"] = readStringFunc.call(reader);
|
||||
}
|
||||
// Stamp
|
||||
else if (rec["Type"] == 12)
|
||||
else if (rec["type"] == 12)
|
||||
{
|
||||
rec["Icon"] = readStringFunc.call(reader);
|
||||
rec["Rotate"] = readDouble2Func.call(reader);
|
||||
@ -969,6 +968,55 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
for (let i = 0; i < 8; ++i)
|
||||
rec["InRect"].push(readDouble2Func.call(reader));
|
||||
}
|
||||
// Redact
|
||||
else if (rec["type"] == 25)
|
||||
{
|
||||
// QuadPoints
|
||||
if (flags & (1 << 15))
|
||||
{
|
||||
let n = reader.readInt();
|
||||
rec["QuadPoints"] = [];
|
||||
for (let i = 0; i < n; ++i)
|
||||
rec["QuadPoints"].push(readDoubleFunc.call(reader));
|
||||
}
|
||||
// IC
|
||||
if (flags & (1 << 16))
|
||||
{
|
||||
let n = reader.readInt();
|
||||
rec["IC"] = [];
|
||||
for (let i = 0; i < n; ++i)
|
||||
rec["IC"].push(readDouble2Func.call(reader));
|
||||
}
|
||||
// OverlayText
|
||||
if (flags & (1 << 17))
|
||||
rec["OverlayText"] = readStringFunc.call(reader);
|
||||
// Repeat
|
||||
rec["Repeat"] = (flags >> 18) & 1;
|
||||
// Q - alignment
|
||||
if (flags & (1 << 19))
|
||||
{
|
||||
// 0 - left-justified, 1 - centered, 2 - right-justified
|
||||
rec["alignment"] = reader.readByte();
|
||||
}
|
||||
// Font from DA
|
||||
if (flags & (1 << 20))
|
||||
{
|
||||
rec["font"] = {};
|
||||
let n = reader.readInt();
|
||||
rec["font"]["color"] = [];
|
||||
for (let i = 0; i < n; ++i)
|
||||
rec["font"]["color"].push(readDouble2Func.call(reader));
|
||||
rec["font"]["size"] = readDoubleFunc.call(reader);
|
||||
rec["font"]["name"] = readStringFunc.call(reader);
|
||||
if (!isRead)
|
||||
{
|
||||
let fontActual = readStringFunc.call(reader);
|
||||
if (fontActual != "")
|
||||
rec["font"]["actual"] = fontActual;
|
||||
}
|
||||
rec["font"]["style"] = reader.readInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readStringFunc, isRead = false)
|
||||
{
|
||||
@ -987,7 +1035,7 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString
|
||||
rec["font"]["color"].push(readDouble2Func.call(reader));
|
||||
}
|
||||
// 0 - left-justified, 1 - centered, 2 - right-justified
|
||||
if (!isRead || (rec["Type"] != 29 && rec["Type"] != 28 && rec["Type"] != 27))
|
||||
if (!isRead || (rec["type"] != 29 && rec["type"] != 28 && rec["type"] != 27))
|
||||
rec["alignment"] = reader.readByte();
|
||||
rec["flag"] = reader.readInt();
|
||||
// 12.7.3.1
|
||||
@ -1000,7 +1048,7 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString
|
||||
let flags = reader.readInt();
|
||||
// Alternative field name, used in tooltip and error messages - TU
|
||||
if (flags & (1 << 0))
|
||||
rec["userName"] = readStringFunc.call(reader);
|
||||
rec["tooltip"] = readStringFunc.call(reader);
|
||||
// Default style string (CSS2 format) - DS
|
||||
if (flags & (1 << 1))
|
||||
rec["defaultStyle"] = readStringFunc.call(reader);
|
||||
@ -1044,8 +1092,10 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString
|
||||
rec["name"] = readStringFunc.call(reader);
|
||||
if (flags & (1 << 19))
|
||||
rec["font"]["AP"] = readStringFunc.call(reader);
|
||||
if (flags & (1 << 20))
|
||||
rec["meta"] = readStringFunc.call(reader);
|
||||
// if (flags & (1 << 20))
|
||||
// readStringFunc.call(reader);
|
||||
if (flags & (1 << 21))
|
||||
rec["MEOptions"] = reader.readInt();
|
||||
// Action
|
||||
let nAction = reader.readInt();
|
||||
if (nAction > 0)
|
||||
@ -1317,6 +1367,10 @@ CFile.prototype["getInteractiveFormsInfo"] = function()
|
||||
}
|
||||
if (flags & (1 << 9))
|
||||
rec["maxLen"] = reader.readInt();
|
||||
if (flags & (1 << 10))
|
||||
rec["tooltip"] = reader.readString();
|
||||
if (flags & (1 << 11))
|
||||
rec["MEOptions"] = reader.readInt();
|
||||
res["Parents"].push(rec);
|
||||
}
|
||||
|
||||
@ -1471,7 +1525,7 @@ CFile.prototype["getAnnotationsInfo"] = function(pageIndex)
|
||||
// 11 - Strikeout, 12 - Stamp, 13 - Caret, 14 - Ink, 15 - Popup, 16 - FileAttachment,
|
||||
// 17 - Sound, 18 - Movie, 19 - Widget, 20 - Screen, 21 - PrinterMark,
|
||||
// 22 - TrapNet, 23 - Watermark, 24 - 3D, 25 - Redact
|
||||
rec["Type"] = reader.readByte();
|
||||
rec["type"] = reader.readByte();
|
||||
// Annot
|
||||
readAnnot(reader, rec, reader.readDouble, reader.readDouble2, reader.readString);
|
||||
// Annot type
|
||||
@ -1528,35 +1582,50 @@ CFile.prototype["readAnnotationsInfoFromBinary"] = function(AnnotInfo)
|
||||
let reader = new CBinaryReader(AnnotInfo, 0, AnnotInfo.length);
|
||||
if (!reader) return [];
|
||||
|
||||
let res = [];
|
||||
let res = { annots:[], imgs:[] };
|
||||
while (reader.isValid())
|
||||
{
|
||||
let nCommand = reader.readByte();
|
||||
let nPos = reader.pos;
|
||||
let nSize = reader.readInt();
|
||||
if (nCommand != 164) // ctAnnotField
|
||||
if (nCommand == 164) // ctAnnotField
|
||||
{
|
||||
let rec = {};
|
||||
// Annotation type
|
||||
// 0 - Text, 1 - Link, 2 - FreeText, 3 - Line, 4 - Square, 5 - Circle,
|
||||
// 6 - Polygon, 7 - PolyLine, 8 - Highlight, 9 - Underline, 10 - Squiggly,
|
||||
// 11 - Strikeout, 12 - Stamp, 13 - Caret, 14 - Ink, 15 - Popup, 16 - FileAttachment,
|
||||
// 17 - Sound, 18 - Movie, 19 - Widget, 20 - Screen, 21 - PrinterMark,
|
||||
// 22 - TrapNet, 23 - Watermark, 24 - 3D, 25 - Redact
|
||||
rec["type"] = reader.readByte();
|
||||
// Annot
|
||||
readAnnot(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
// Annot type
|
||||
readAnnotType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
if (rec["type"] >= 26 && rec["type"] <= 33)
|
||||
{
|
||||
// Widget type
|
||||
readWidgetType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
}
|
||||
res.annots.push(rec);
|
||||
}
|
||||
else if (nCommand == 166) // ctWidgetsInfo
|
||||
{
|
||||
reader.readInt(); // CO must be 0
|
||||
reader.readInt(); // Parents must be 0
|
||||
// ButtonImg
|
||||
let n = reader.readInt();
|
||||
for (let i = 0; i < n; ++i)
|
||||
{
|
||||
let data = reader.readString();
|
||||
res.imgs.push(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.pos = nPos + nSize;
|
||||
continue;
|
||||
}
|
||||
let rec = {};
|
||||
// Annotation type
|
||||
// 0 - Text, 1 - Link, 2 - FreeText, 3 - Line, 4 - Square, 5 - Circle,
|
||||
// 6 - Polygon, 7 - PolyLine, 8 - Highlight, 9 - Underline, 10 - Squiggly,
|
||||
// 11 - Strikeout, 12 - Stamp, 13 - Caret, 14 - Ink, 15 - Popup, 16 - FileAttachment,
|
||||
// 17 - Sound, 18 - Movie, 19 - Widget, 20 - Screen, 21 - PrinterMark,
|
||||
// 22 - TrapNet, 23 - Watermark, 24 - 3D, 25 - Redact
|
||||
rec["Type"] = reader.readByte();
|
||||
// Annot
|
||||
readAnnot(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
// Annot type
|
||||
readAnnotType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
if (rec["Type"] >= 26 && rec["Type"] <= 33)
|
||||
{
|
||||
// Widget type
|
||||
readWidgetType(reader, rec, reader.readDouble3, reader.readDouble3, reader.readString2, true);
|
||||
}
|
||||
res.push(rec);
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -1566,8 +1635,13 @@ CFile.prototype["readAnnotationsInfoFromBinary"] = function(AnnotInfo)
|
||||
CFile.prototype["scanPage"] = function(page, mode)
|
||||
{
|
||||
let ptr = this._scanPage(page, mode);
|
||||
let reader = ptr.getReader();
|
||||
if (mode == 2) {
|
||||
data = ptr.getMemory(true);
|
||||
ptr.free();
|
||||
return data;
|
||||
}
|
||||
|
||||
let reader = ptr.getReader();
|
||||
if (!reader) return [];
|
||||
|
||||
let shapesCount = reader.readInt();
|
||||
|
||||
@ -101,9 +101,8 @@ CFile.prototype._openFile = function(buffer, password)
|
||||
{
|
||||
let data = new Uint8Array(buffer);
|
||||
this.stream_size = data.length;
|
||||
let stream = Module["_malloc"](this.stream_size);
|
||||
Module["HEAP8"].set(data, stream);
|
||||
this.stream.push(stream);
|
||||
this.stream = Module["_malloc"](this.stream_size);
|
||||
Module["HEAP8"].set(data, this.stream);
|
||||
}
|
||||
|
||||
let passwordPtr = 0;
|
||||
@ -114,7 +113,7 @@ CFile.prototype._openFile = function(buffer, password)
|
||||
Module["HEAP8"].set(passwordBuf, passwordPtr);
|
||||
}
|
||||
|
||||
this.nativeFile = Module["_Open"](this.stream[0], this.stream_size, passwordPtr);
|
||||
this.nativeFile = Module["_Open"](this.stream, this.stream_size, passwordPtr);
|
||||
|
||||
if (passwordPtr)
|
||||
Module["_free"](passwordPtr);
|
||||
@ -128,7 +127,7 @@ CFile.prototype._closeFile = function()
|
||||
|
||||
CFile.prototype._getType = function()
|
||||
{
|
||||
return Module["_GetType"](this.stream[0], this.stream_size);
|
||||
return Module["_GetType"](this.nativeFile);
|
||||
};
|
||||
|
||||
CFile.prototype._getError = function()
|
||||
@ -180,10 +179,7 @@ CFile.prototype._MergePages = function(buffer, maxID, prefixForm)
|
||||
}
|
||||
|
||||
let bRes = Module["_MergePages"](this.nativeFile, stream2, data.length, maxID, prefixPtr);
|
||||
if (bRes == 1)
|
||||
this.stream.push(stream2);
|
||||
else
|
||||
Module["_free"](stream2);
|
||||
stream2 = 0; // Success or not, stream2 is either taken or freed
|
||||
|
||||
if (prefixPtr)
|
||||
Module["_free"](prefixPtr);
|
||||
@ -193,13 +189,7 @@ CFile.prototype._MergePages = function(buffer, maxID, prefixForm)
|
||||
|
||||
CFile.prototype._UndoMergePages = function()
|
||||
{
|
||||
let bRes = Module["_UnmergePages"](this.nativeFile);
|
||||
if (bRes == 1)
|
||||
{
|
||||
let str = this.stream.pop();
|
||||
Module["_free"](str);
|
||||
}
|
||||
return bRes == 1;
|
||||
return Module["_UnmergePages"](this.nativeFile) == 1;
|
||||
};
|
||||
|
||||
// FONTS
|
||||
|
||||
@ -68,25 +68,6 @@ WASM_EXPORT int IsFontBinaryExist(char* path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
WASM_EXPORT int GetType(BYTE* data, LONG size)
|
||||
{
|
||||
// 0 - PDF
|
||||
// 1 - DJVU
|
||||
// 2 - XPS
|
||||
LONG nHeaderSearchSize = 1024;
|
||||
LONG nSize = size < nHeaderSearchSize ? size : nHeaderSearchSize;
|
||||
char* pData = (char*)data;
|
||||
for (int i = 0; i < nSize - 5; ++i)
|
||||
{
|
||||
int nPDF = strncmp(&pData[i], "%PDF-", 5);
|
||||
if (!nPDF)
|
||||
return 0;
|
||||
}
|
||||
if ( (8 <= size) && (0x41 == data[0] && 0x54 == data[1] && 0x26 == data[2] && 0x54 == data[3] &&
|
||||
0x46 == data[4] && 0x4f == data[5] && 0x52 == data[6] && 0x4d == data[7]))
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
WASM_EXPORT CDrawingFile* Open(BYTE* data, LONG size, const char* password)
|
||||
{
|
||||
if (!g_applicationFonts)
|
||||
@ -102,6 +83,13 @@ WASM_EXPORT CDrawingFile* Open(BYTE* data, LONG size, const char* password)
|
||||
pFile->OpenFile(data, size, sPassword);
|
||||
return pFile;
|
||||
}
|
||||
WASM_EXPORT int GetType(CDrawingFile* pFile)
|
||||
{
|
||||
// 0 - PDF
|
||||
// 1 - DJVU
|
||||
// 2 - XPS
|
||||
return pFile->GetType();
|
||||
}
|
||||
WASM_EXPORT int GetErrorCode(CDrawingFile* pFile)
|
||||
{
|
||||
if (!pFile)
|
||||
@ -111,6 +99,7 @@ WASM_EXPORT int GetErrorCode(CDrawingFile* pFile)
|
||||
WASM_EXPORT void Close(CDrawingFile* pFile)
|
||||
{
|
||||
delete pFile;
|
||||
g_applicationFonts->GetStreams()->Clear();
|
||||
NSFonts::NSApplicationFontStream::SetGlobalMemoryStorage(NULL);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetInfo(CDrawingFile* pFile)
|
||||
|
||||
@ -278,6 +278,13 @@ void ReadAnnot(BYTE* pWidgets, int& i)
|
||||
std::cout << "User ID " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
if (nFlags & (1 << 9))
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << "OMetadata " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
}
|
||||
|
||||
void ReadInteractiveForms(BYTE* pWidgets, int& i)
|
||||
@ -415,6 +422,19 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i)
|
||||
i += 4;
|
||||
std::cout << "MaxLen " << nPathLength << ", ";
|
||||
}
|
||||
if (nFlags & (1 << 10))
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << "TU " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
if (nFlags & (1 << 11))
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << "MEOptions " << nPathLength << ", ";
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
@ -574,12 +594,11 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i)
|
||||
std::cout << "Font button " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
if (nFlags & (1 << 20))
|
||||
if (nFlags & (1 << 21))
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << "OMetadata " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
std::cout << "MEOptions " << nPathLength << ", ";
|
||||
}
|
||||
|
||||
//Action
|
||||
@ -1022,9 +1041,9 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(pFileData);
|
||||
|
||||
// SPLIT & MERGE
|
||||
BYTE* pSplitPages = NULL;
|
||||
BYTE* pFileMerge = NULL;
|
||||
if (false)
|
||||
{
|
||||
int nBufferLen = NULL;
|
||||
@ -1036,12 +1055,19 @@ int main(int argc, char* argv[])
|
||||
BYTE* pSplitPages = SplitPages(pGrFile, arrPages.data(), arrPages.size(), pBuffer, nBufferLen);
|
||||
int nLength = READ_INT(pSplitPages);
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/split1.pdf"))
|
||||
oFile.WriteFile(pSplitPages + 4, nLength - 4);
|
||||
oFile.CloseFile();
|
||||
if (nLength > 4)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/split1.pdf"))
|
||||
oFile.WriteFile(pSplitPages + 4, nLength - 4);
|
||||
oFile.CloseFile();
|
||||
|
||||
MergePages(pGrFile, pSplitPages + 4, nLength - 4, 0, "merge1");
|
||||
BYTE* pMallocData = (BYTE*)malloc(nLength - 4);
|
||||
memcpy(pMallocData, pSplitPages + 4, nLength - 4);
|
||||
|
||||
MergePages(pGrFile, pMallocData, nLength - 4, 0, "merge1");
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pSplitPages);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
|
||||
@ -1051,12 +1077,19 @@ int main(int argc, char* argv[])
|
||||
BYTE* pSplitPages = SplitPages(pGrFile, arrPages.data(), arrPages.size(), pBuffer, nBufferLen);
|
||||
int nLength = READ_INT(pSplitPages);
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/split2.pdf"))
|
||||
oFile.WriteFile(pSplitPages + 4, nLength - 4);
|
||||
oFile.CloseFile();
|
||||
if (nLength > 4)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/split2.pdf"))
|
||||
oFile.WriteFile(pSplitPages + 4, nLength - 4);
|
||||
oFile.CloseFile();
|
||||
|
||||
MergePages(pGrFile, pSplitPages + 4, nLength - 4, 0, "merge2");
|
||||
BYTE* pMallocData = (BYTE*)malloc(nLength - 4);
|
||||
memcpy(pMallocData, pSplitPages + 4, nLength - 4);
|
||||
|
||||
MergePages(pGrFile, pMallocData, nLength - 4, 0, "merge2");
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pSplitPages);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
}
|
||||
@ -2022,6 +2055,83 @@ int main(int argc, char* argv[])
|
||||
i += 4;
|
||||
std::cout << "Y4 " << (double)nPathLength / 10000.0 << ", ";
|
||||
}
|
||||
else if (sType == "Redact")
|
||||
{
|
||||
if (nFlags & (1 << 15))
|
||||
{
|
||||
std::cout << "QuadPoints";
|
||||
int nQuadPointsLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
|
||||
for (int j = 0; j < nQuadPointsLength; ++j)
|
||||
{
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << " " << (double)nPathLength / 100.0;
|
||||
}
|
||||
std::cout << ", ";
|
||||
}
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int nICLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << "IC ";
|
||||
|
||||
for (int j = 0; j < nICLength; ++j)
|
||||
{
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << (double)nPathLength / 10000.0 << " ";
|
||||
}
|
||||
std::cout << ", ";
|
||||
}
|
||||
if (nFlags & (1 << 17))
|
||||
{
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << "OverlayText " << std::string((char*)(pAnnots + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
if (nFlags & (1 << 18))
|
||||
std::cout << "Repeat true, ";
|
||||
else
|
||||
std::cout << "Repeat false, ";
|
||||
if (nFlags & (1 << 19))
|
||||
{
|
||||
std::string arrQ[] = {"left-justified", "centered", "right-justified"};
|
||||
nPathLength = READ_BYTE(pAnnots + i);
|
||||
i += 1;
|
||||
std::cout << "Q " << arrQ[nPathLength] << ", ";
|
||||
}
|
||||
if (nFlags & (1 << 20))
|
||||
{
|
||||
int nICLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << "DA color ";
|
||||
|
||||
for (int j = 0; j < nICLength; ++j)
|
||||
{
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << (double)nPathLength / 10000.0 << " ";
|
||||
}
|
||||
std::cout << ", size ";
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << (double)nPathLength / 100.0 << ", font ";
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << std::string((char*)(pAnnots + i), nPathLength) << " actual ";
|
||||
i += nPathLength;
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << std::string((char*)(pAnnots + i), nPathLength) << ", style ";
|
||||
i += nPathLength;
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << nPathLength << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << std::endl << "]" << std::endl;
|
||||
}
|
||||
@ -2053,10 +2163,6 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
Close(pGrFile);
|
||||
RELEASEARRAYOBJECTS(pFileData);
|
||||
RELEASEARRAYOBJECTS(pSplitPages);
|
||||
RELEASEARRAYOBJECTS(pFileMerge);
|
||||
RELEASEARRAYOBJECTS(pCMapData);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2,8 +2,11 @@
|
||||
#define _WASM_SERIALIZE_H
|
||||
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
#include "../../../../../common/File.h"
|
||||
|
||||
#define CLEAR_STACK(stack) while (!(stack).empty()) (stack).pop()
|
||||
|
||||
namespace NSWasm
|
||||
{
|
||||
class CData
|
||||
@ -15,6 +18,8 @@ namespace NSWasm
|
||||
BYTE* m_pDataCur;
|
||||
size_t m_lSizeCur;
|
||||
|
||||
std::stack<size_t> m_lStack;
|
||||
|
||||
public:
|
||||
CData()
|
||||
{
|
||||
@ -24,10 +29,70 @@ namespace NSWasm
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = m_lSize;
|
||||
}
|
||||
CData(const CData& other)
|
||||
{
|
||||
m_lSize = other.m_lSize;
|
||||
m_lSizeCur = other.m_lSizeCur;
|
||||
|
||||
m_pData = (BYTE*)malloc(m_lSize * sizeof(BYTE));
|
||||
memcpy(m_pData, other.m_pData, other.m_lSizeCur * sizeof(BYTE));
|
||||
m_pDataCur = m_pData + m_lSizeCur;
|
||||
|
||||
m_lStack = other.m_lStack;
|
||||
}
|
||||
CData(CData&& other)
|
||||
{
|
||||
m_lSize = other.m_lSize;
|
||||
m_lSizeCur = other.m_lSizeCur;
|
||||
|
||||
m_pData = other.m_pData;
|
||||
m_pDataCur = other.m_pDataCur;
|
||||
|
||||
m_lStack = std::move(other.m_lStack);
|
||||
|
||||
other.ClearWithoutAttack();
|
||||
}
|
||||
virtual ~CData()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
CData& operator= (const CData& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
Clear();
|
||||
|
||||
m_lSize = other.m_lSize;
|
||||
m_lSizeCur = other.m_lSizeCur;
|
||||
|
||||
m_pData = (BYTE*)malloc(m_lSize * sizeof(BYTE));
|
||||
memcpy(m_pData, other.m_pData, other.m_lSizeCur * sizeof(BYTE));
|
||||
m_pDataCur = m_pData + m_lSizeCur;
|
||||
|
||||
m_lStack = other.m_lStack;
|
||||
|
||||
return *this;
|
||||
}
|
||||
CData& operator= (CData&& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
Clear();
|
||||
|
||||
m_lSize = other.m_lSize;
|
||||
m_lSizeCur = other.m_lSizeCur;
|
||||
|
||||
m_pData = other.m_pData;
|
||||
m_pDataCur = other.m_pDataCur;
|
||||
|
||||
other.ClearWithoutAttack();
|
||||
|
||||
m_lStack = std::move(other.m_lStack);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void AddSize(size_t nSize)
|
||||
{
|
||||
@ -68,6 +133,20 @@ namespace NSWasm
|
||||
}
|
||||
|
||||
public:
|
||||
void StartRecord(BYTE type)
|
||||
{
|
||||
AddSize(5); // sizeof (BYTE + unsigned int)
|
||||
WriteBYTE(type);
|
||||
AddInt(0);
|
||||
m_lStack.push(m_lSizeCur);
|
||||
}
|
||||
void EndRecord()
|
||||
{
|
||||
size_t start = m_lStack.top();
|
||||
unsigned int len = m_lSizeCur - start;
|
||||
memcpy(m_pData + start - 4, &len, sizeof(unsigned int));
|
||||
m_lStack.pop();
|
||||
}
|
||||
void AddInt(unsigned int value)
|
||||
{
|
||||
AddSize(4);
|
||||
@ -75,6 +154,13 @@ namespace NSWasm
|
||||
m_pDataCur += 4;
|
||||
m_lSizeCur += 4;
|
||||
}
|
||||
void AddSInt(int value)
|
||||
{
|
||||
AddSize(4);
|
||||
memcpy(m_pDataCur, &value, sizeof(int));
|
||||
m_pDataCur += 4;
|
||||
m_lSizeCur += 4;
|
||||
}
|
||||
void AddInt(unsigned int value, size_t pos)
|
||||
{
|
||||
if (pos < m_lSizeCur)
|
||||
@ -93,6 +179,10 @@ namespace NSWasm
|
||||
m_pDataCur += sizeof(BYTE);
|
||||
m_lSizeCur += sizeof(BYTE);
|
||||
}
|
||||
void WriteBool(bool value)
|
||||
{
|
||||
WriteBYTE(value ? 1 : 0);
|
||||
}
|
||||
void WriteDouble(double value)
|
||||
{
|
||||
int nV = value * 10000;
|
||||
@ -151,6 +241,37 @@ namespace NSWasm
|
||||
WriteString(pDataUtf8, (unsigned int)lDataUtf8);
|
||||
RELEASEARRAYOBJECTS(pDataUtf8);
|
||||
}
|
||||
void WriteStringUtf16(const std::wstring& sStr, const bool& isBytes = false)
|
||||
{
|
||||
unsigned int size = static_cast<unsigned int>(sStr.length());
|
||||
|
||||
int len = 0;
|
||||
size_t posLen = m_lSizeCur;
|
||||
|
||||
// len reserve
|
||||
AddInt(0);
|
||||
|
||||
if (sizeof(wchar_t) == 4)
|
||||
{
|
||||
AddSize(4 * size + 2/*'\0'*/);
|
||||
NSFile::CUtf8Converter::GetUtf16StringFromUnicode_4bytes(sStr.c_str(), (LONG)size, m_pDataCur, len, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t bufferLen = 2 * size;
|
||||
AddSize(bufferLen);
|
||||
len = (int)(bufferLen);
|
||||
memcpy(m_pDataCur, sStr.c_str(), bufferLen);
|
||||
}
|
||||
|
||||
m_pDataCur += static_cast<unsigned int>(len);
|
||||
m_lSizeCur += static_cast<unsigned int>(len);
|
||||
|
||||
if (!isBytes)
|
||||
len /= 2;
|
||||
|
||||
AddInt((unsigned int)len, posLen);
|
||||
}
|
||||
void Write(BYTE* value, unsigned int len)
|
||||
{
|
||||
if (!value || len == 0)
|
||||
@ -165,6 +286,13 @@ namespace NSWasm
|
||||
return m_pData;
|
||||
}
|
||||
|
||||
BYTE* MoveBuffer()
|
||||
{
|
||||
BYTE* pData = m_pData;
|
||||
ClearWithoutAttack();
|
||||
return pData;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
if (m_pData)
|
||||
@ -175,6 +303,8 @@ namespace NSWasm
|
||||
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = 0;
|
||||
|
||||
CLEAR_STACK(m_lStack);
|
||||
}
|
||||
void ClearWithoutAttack()
|
||||
{
|
||||
@ -183,11 +313,15 @@ namespace NSWasm
|
||||
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = 0;
|
||||
|
||||
CLEAR_STACK(m_lStack);
|
||||
}
|
||||
void ClearNoAttack()
|
||||
{
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = 0;
|
||||
|
||||
CLEAR_STACK(m_lStack);
|
||||
}
|
||||
unsigned int GetSize()
|
||||
{
|
||||
|
||||
@ -14,13 +14,15 @@ DEFINES += \
|
||||
MNG_STORE_CHUNKS\
|
||||
MNG_ERROR_TELLTALE
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/heif/heif.pri)
|
||||
|
||||
core_linux {
|
||||
DEFINES += HAVE_UNISTD_H HAVE_FCNTL_H
|
||||
QMAKE_CXXFLAGS += -Wno-narrowing
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
QMAKE_CFLAGS += -Wno-incompatible-function-pointer-types
|
||||
QMAKE_CFLAGS += -Wno-incompatible-function-pointer-types
|
||||
}
|
||||
|
||||
core_mac {
|
||||
@ -285,6 +287,9 @@ SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/PICFile.cpp \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/pic.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/heif/heif.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/jasper/base/jas_cm.c \
|
||||
$$LIB_GRAPHICS_PRI_PATH/cximage/jasper/base/jas_debug.c \
|
||||
|
||||
9
DesktopEditor/graphics/tests/testHeic/main.cpp
Normal file
9
DesktopEditor/graphics/tests/testHeic/main.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "../../pro/Graphics.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Aggplus::CImage img(L"C:\\Users\\KProkhorov\\Work\\core\\DesktopEditor\\graphics\\tests\\testHeic\\image1.heic");
|
||||
img.SaveFile(L"C:\\Users\\KProkhorov\\Work\\core\\DesktopEditor\\graphics\\tests\\testHeic\\image1.bmp", 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
24
DesktopEditor/graphics/tests/testHeic/testHeic.pro
Normal file
24
DesktopEditor/graphics/tests/testHeic/testHeic.pro
Normal file
@ -0,0 +1,24 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter)
|
||||
|
||||
GRAPHICS_AGG_PATH = $$PWD/../../../agg-2.4
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$GRAPHICS_AGG_PATH/include
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
DESTDIR = $$PWD_ROOT_DIR/build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
|
||||
@ -44,6 +44,10 @@
|
||||
#include "PICT/PICFile.h"
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
#include "heif/heif.h"
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#define BGRA_FRAME_CXIMAGE_MAX_MEMORY 67108864 // 256Mb (*4 channel)
|
||||
|
||||
@ -444,11 +448,18 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileTyp
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_PIC
|
||||
if (CXIMAGE_FORMAR_PIC == m_nFileType)
|
||||
{
|
||||
PICT::CPictFile PIC;
|
||||
return PIC.Open(this, strFileName, !m_bIsRGBA);
|
||||
}
|
||||
if (CXIMAGE_FORMAR_PIC == m_nFileType)
|
||||
{
|
||||
PICT::CPictFile PIC;
|
||||
return PIC.Open(this, strFileName, !m_bIsRGBA);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
if (CXIMAGE_FORMAT_HEIF == m_nFileType)
|
||||
{
|
||||
return NSHeif::CHeifFile::Open(this, strFileName);
|
||||
}
|
||||
#endif
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
@ -534,6 +545,13 @@ bool CBgraFrame::Decode(BYTE* pBuffer, int nSize, unsigned int nFileType)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
if (CXIMAGE_FORMAT_HEIF == m_nFileType)
|
||||
{
|
||||
return NSHeif::CHeifFile::Open(this, pBuffer, nSize);
|
||||
}
|
||||
#endif
|
||||
|
||||
CxImage img;
|
||||
|
||||
if (!img.Decode(pBuffer, nSize, m_nFileType))
|
||||
@ -562,28 +580,32 @@ bool CBgraFrame::SaveFile(const std::wstring& strFileName, unsigned int nFileTyp
|
||||
|
||||
return res;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
if (CXIMAGE_FORMAT_HEIF == nFileType)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (!oFile.CreateFileW(strFileName))
|
||||
return false;
|
||||
|
||||
CxImage img;
|
||||
|
||||
if (!img.CreateFromArray(m_pData, m_lWidth, m_lHeight, lBitsPerPixel * 8, lStride, (m_lStride >= 0) ? true : false, !m_bIsRGBA))
|
||||
return false;
|
||||
|
||||
if (m_pPalette)
|
||||
{
|
||||
img.SetPalette((RGBQUAD*)m_pPalette, m_lPaletteColors);
|
||||
}
|
||||
|
||||
if (!img.Encode(oFile.GetFileNative(), nFileType))
|
||||
return false;
|
||||
|
||||
oFile.CloseFile();
|
||||
return NSHeif::CHeifFile::Save(m_pData, m_lWidth, m_lHeight, m_lStride, strFileName);
|
||||
}
|
||||
#endif
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
if (!oFile.CreateFileW(strFileName))
|
||||
return false;
|
||||
|
||||
CxImage img;
|
||||
|
||||
if (!img.CreateFromArray(m_pData, m_lWidth, m_lHeight, lBitsPerPixel * 8, lStride, (m_lStride >= 0) ? true : false, !m_bIsRGBA))
|
||||
return false;
|
||||
|
||||
if (m_pPalette)
|
||||
{
|
||||
img.SetPalette((RGBQUAD*)m_pPalette, m_lPaletteColors);
|
||||
}
|
||||
|
||||
if (!img.Encode(oFile.GetFileNative(), nFileType))
|
||||
return false;
|
||||
|
||||
oFile.CloseFile();
|
||||
return true;
|
||||
}
|
||||
bool CBgraFrame::Encode(BYTE*& pBuffer, int& nSize, unsigned int nFileType)
|
||||
|
||||
@ -32,6 +32,9 @@
|
||||
#include "ImageFileFormatChecker.h"
|
||||
#include "../common/File.h"
|
||||
#include "../cximage/CxImage/ximacfg.h"
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
#include "heif/heif.h"
|
||||
#endif
|
||||
|
||||
#ifndef IMAGE_CHECKER_DISABLE_XML
|
||||
#include "../xml/include/xmlutils.h"
|
||||
@ -432,6 +435,15 @@ bool CImageFileFormatChecker::isPicFile(BYTE *pBuffer, DWORD dwBytes)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CImageFileFormatChecker::isHeifFile(BYTE* pBuffer, DWORD dwBytes)
|
||||
{
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
return NSHeif::CHeifFile::isHeif(pBuffer, dwBytes);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool CImageFileFormatChecker::isImageFile(const std::wstring& fileName)
|
||||
{
|
||||
@ -554,6 +566,10 @@ bool CImageFileFormatChecker::isImageFile(const std::wstring& fileName)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_PIC;
|
||||
}
|
||||
else if (isHeifFile(fileName))
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_HEIF;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
delete [] buffer;
|
||||
|
||||
@ -669,6 +685,10 @@ bool CImageFileFormatChecker::isImageFile(BYTE* buffer, DWORD sizeRead)
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_PIC;
|
||||
}
|
||||
if (isHeifFile(buffer, sizeRead))
|
||||
{
|
||||
eFileType = _CXIMAGE_FORMAT_HEIF;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
if (eFileType) return true;
|
||||
return false;
|
||||
@ -786,6 +806,14 @@ bool CImageFileFormatChecker::isSvgFile(const std::wstring& fileName)
|
||||
return bFind;
|
||||
#endif
|
||||
}
|
||||
bool CImageFileFormatChecker::isHeifFile(const std::wstring& fileName)
|
||||
{
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
return NSHeif::CHeifFile::isHeif(fileName);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::wstring CImageFileFormatChecker::DetectFormatByData(BYTE *Data, int DataSize)
|
||||
{
|
||||
|
||||
@ -63,6 +63,7 @@ enum __ENUM_CXIMAGE_FORMATS
|
||||
_CXIMAGE_FORMAT_SVM = 23,
|
||||
_CXIMAGE_FORMAT_SVG = 24,
|
||||
_CXIMAGE_FORMAT_PIC = 25,
|
||||
_CXIMAGE_FORMAT_HEIF = 26,
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CImageFileFormatChecker
|
||||
@ -82,6 +83,7 @@ public:
|
||||
|
||||
bool isRawFile(const std::wstring& fileName);
|
||||
bool isSvgFile(const std::wstring& fileName);
|
||||
bool isHeifFile(const std::wstring& fileName);
|
||||
|
||||
bool isImageFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isBmpFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
@ -111,6 +113,7 @@ public:
|
||||
bool isSvgFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isRawFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isPicFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isHeifFile(BYTE* pBuffer, DWORD dwBytes);
|
||||
|
||||
std::wstring DetectFormatByData(BYTE *Data, int DataSize);
|
||||
|
||||
|
||||
@ -79,9 +79,9 @@ bool CSvgFile::GetBounds(double &dX, double &dY, double &dWidth, double &dHeight
|
||||
else
|
||||
dHeight = m_oContainer.GetViewBox().m_oHeight.ToDouble(NSCSS::Pixel);
|
||||
|
||||
if (0. == dWidth)
|
||||
if (DBL_EPSILON > dWidth)
|
||||
dWidth = SVG_FILE_WIDTH;
|
||||
if (0. == dHeight)
|
||||
if (DBL_EPSILON > dHeight)
|
||||
dHeight = SVG_FILE_HEIGHT;
|
||||
|
||||
return true;
|
||||
|
||||
@ -260,6 +260,8 @@ namespace SVG
|
||||
{
|
||||
oSecondPoint = Point{arValues[arValues.size() - 2], arValues[arValues.size() - 1]};
|
||||
|
||||
arValues.erase(arValues.end() - 2, arValues.end());
|
||||
|
||||
return new CLineElement(oSecondPoint + oTranslatePoint);
|
||||
}
|
||||
|
||||
|
||||
@ -697,12 +697,18 @@ int AquirePixelsMemory(ImagePICT* image)
|
||||
return 0;
|
||||
}
|
||||
|
||||
image->m_nPixelsSize = image->m_nHeight * image->m_nWidth * image->number_channels;
|
||||
int nPixelsSize_new = image->m_nHeight * image->m_nWidth * image->number_channels;
|
||||
|
||||
if (image->ppixels == NULL)
|
||||
image->ppixels = (unsigned char*) malloc(image->m_nPixelsSize);
|
||||
else
|
||||
image->ppixels = (unsigned char*) realloc(image->ppixels, image->m_nPixelsSize);
|
||||
{
|
||||
image->ppixels = (unsigned char*)malloc(nPixelsSize_new);
|
||||
memset(image->ppixels, 0xff, nPixelsSize_new);
|
||||
}
|
||||
else if (nPixelsSize_new != image->m_nPixelsSize)
|
||||
{
|
||||
image->ppixels = (unsigned char*)realloc(image->ppixels, nPixelsSize_new);
|
||||
}
|
||||
image->m_nPixelsSize = nPixelsSize_new;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
154
DesktopEditor/raster/heif/heif.cpp
Normal file
154
DesktopEditor/raster/heif/heif.cpp
Normal file
@ -0,0 +1,154 @@
|
||||
#include "heif.h"
|
||||
#include "../../common/File.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
#define CONCAT_IMPL(x, y) x##y
|
||||
#define CONCAT(x, y) CONCAT_IMPL(x, y)
|
||||
#define defer(code) Defer CONCAT(_defer_, __COUNTER__)([&](){code;})
|
||||
|
||||
class Defer {
|
||||
std::function<void()> func;
|
||||
public:
|
||||
explicit Defer(std::function<void()> func) : func(func) {}
|
||||
~Defer() { func(); }
|
||||
};
|
||||
|
||||
namespace NSHeif {
|
||||
NSUnicodeConverter::CUnicodeConverter CHeifFile::m_oConverter{};
|
||||
|
||||
bool CHeifFile::isHeif(const std::wstring& fileName)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
return !IsError(heif_context_read_from_file(ctx, m_oConverter.fromUnicode(fileName, "UTF-8").c_str(), nullptr));
|
||||
}
|
||||
|
||||
bool CHeifFile::isHeif(BYTE* buffer, DWORD size)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
return !IsError(heif_context_read_from_memory_without_copy(ctx, buffer, size, nullptr));
|
||||
}
|
||||
|
||||
bool CHeifFile::Open(CBgraFrame *frame, const std::wstring& fileName)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
if (IsError(heif_context_read_from_file(ctx, m_oConverter.fromUnicode(fileName, "UTF-8").c_str(), nullptr)))
|
||||
return false;
|
||||
return Decode(ctx, frame);
|
||||
}
|
||||
|
||||
bool CHeifFile::Open(CBgraFrame *frame, BYTE* buffer, DWORD size)
|
||||
{
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
if (IsError(heif_context_read_from_memory_without_copy(ctx, buffer, size, nullptr)))
|
||||
return false;
|
||||
return Decode(ctx, frame);
|
||||
}
|
||||
|
||||
bool CHeifFile::Save(const BYTE* source, int width, int height, int sourceStride, const std::wstring& dstPath)
|
||||
{
|
||||
if (!source)
|
||||
return false;
|
||||
|
||||
heif_image* img;
|
||||
defer(heif_image_release(img););
|
||||
|
||||
if (IsError(heif_image_create(width, height, heif_colorspace_RGB, heif_chroma_interleaved_RGB, &img)))
|
||||
return false;
|
||||
|
||||
if (IsError(heif_image_add_plane(img, heif_channel_interleaved, width, height, 24)))
|
||||
return false;
|
||||
|
||||
int stride;
|
||||
BYTE* data = heif_image_get_plane(img, heif_channel_interleaved, &stride);
|
||||
|
||||
if (!data || stride == 0)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < height; ++i)
|
||||
{
|
||||
const BYTE* row = source + (height - i - 1) * (sourceStride < 0 ? -sourceStride : sourceStride);
|
||||
for (size_t j = 0; j < width; ++j)
|
||||
{
|
||||
data[(i * width + j) * 3 + 0] = row[(width - j - 1) * 4 + 2];
|
||||
data[(i * width + j) * 3 + 1] = row[(width - j - 1) * 4 + 1];
|
||||
data[(i * width + j) * 3 + 2] = row[(width - j - 1) * 4 + 0];
|
||||
}
|
||||
}
|
||||
|
||||
heif_context* ctx = heif_context_alloc();
|
||||
defer(heif_context_free(ctx););
|
||||
|
||||
heif_encoder* encoder;
|
||||
defer(heif_encoder_release(encoder););
|
||||
|
||||
if (IsError(heif_context_get_encoder_for_format(ctx, heif_compression_HEVC, &encoder)))
|
||||
return false;
|
||||
|
||||
if (IsError(heif_context_encode_image(ctx, img, encoder, nullptr, nullptr)))
|
||||
return false;
|
||||
|
||||
if (IsError(heif_context_write_to_file(ctx, m_oConverter.fromUnicode(dstPath, "UTF-8").c_str())))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool CHeifFile::IsError(heif_error err)
|
||||
{
|
||||
return err.code != heif_error_Ok;
|
||||
}
|
||||
|
||||
inline bool CHeifFile::Decode(heif_context* ctx, CBgraFrame* frame)
|
||||
{
|
||||
heif_image_handle* handle;
|
||||
defer(heif_image_handle_release(handle););
|
||||
|
||||
if (IsError(heif_context_get_primary_image_handle(ctx, &handle)))
|
||||
return false;
|
||||
|
||||
heif_image* img;
|
||||
defer(heif_image_release(img););
|
||||
|
||||
if (IsError(heif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_444, nullptr)))
|
||||
return false;
|
||||
|
||||
int width = heif_image_get_primary_width(img);
|
||||
int height = heif_image_get_primary_height(img);
|
||||
|
||||
int stride_R, stride_G, stride_B;
|
||||
const BYTE* source_R = heif_image_get_plane_readonly(img, heif_channel_R, &stride_R);
|
||||
const BYTE* source_G = heif_image_get_plane_readonly(img, heif_channel_G, &stride_G);
|
||||
const BYTE* source_B = heif_image_get_plane_readonly(img, heif_channel_B, &stride_B);
|
||||
|
||||
if (stride_R == 0 || !source_R)
|
||||
return false;
|
||||
|
||||
BYTE* data = new BYTE[4 * width * height];
|
||||
|
||||
frame->put_Width(width);
|
||||
frame->put_Height(height);
|
||||
frame->put_Stride(4 * width);
|
||||
frame->put_Data(data);
|
||||
|
||||
for (size_t i = 0; i < height; ++i)
|
||||
{
|
||||
const BYTE* row_R = source_R + i * stride_R;
|
||||
const BYTE* row_G = source_G + i * stride_G;
|
||||
const BYTE* row_B = source_B + i * stride_B;
|
||||
for (size_t j = 0; j < width; ++j)
|
||||
{
|
||||
data[(i * width + j) * 4 + 0] = row_B[j];
|
||||
data[(i * width + j) * 4 + 1] = row_G[j];
|
||||
data[(i * width + j) * 4 + 2] = row_R[j];
|
||||
data[(i * width + j) * 4 + 3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
DesktopEditor/raster/heif/heif.h
Normal file
22
DesktopEditor/raster/heif/heif.h
Normal file
@ -0,0 +1,22 @@
|
||||
#include "../BgraFrame.h"
|
||||
#include "../../Common/3dParty/heif/libheif/libheif/api/libheif/heif.h"
|
||||
#include "../../UnicodeConverter/UnicodeConverter.h"
|
||||
|
||||
namespace NSHeif {
|
||||
class GRAPHICS_DECL CHeifFile {
|
||||
private:
|
||||
CHeifFile() = delete;
|
||||
public:
|
||||
static bool isHeif(const std::wstring& fileName);
|
||||
static bool isHeif(BYTE* buffer, DWORD size);
|
||||
|
||||
static bool Open(CBgraFrame* frame, const std::wstring& fileName);
|
||||
static bool Open(CBgraFrame* frame, BYTE* buffer, DWORD size);
|
||||
static bool Save(const BYTE* source, int width, int height, int sourceStride, const std::wstring& dstPath);
|
||||
|
||||
private:
|
||||
static bool IsError(heif_error err);
|
||||
static bool Decode(heif_context* ctx, CBgraFrame* frame);
|
||||
static NSUnicodeConverter::CUnicodeConverter m_oConverter;
|
||||
};
|
||||
}
|
||||
@ -37,12 +37,19 @@
|
||||
#include "../DesktopEditor/graphics/commands/DocInfo.h"
|
||||
#include <algorithm>
|
||||
|
||||
enum class ShapeSerializeType
|
||||
{
|
||||
sstBinary,
|
||||
sstXml
|
||||
};
|
||||
|
||||
class CDocxRenderer_Private
|
||||
{
|
||||
public:
|
||||
NSDocxRenderer::CDocument m_oDocument;
|
||||
std::wstring m_sTempDirectory;
|
||||
bool m_bIsSupportShapeCommands = false;
|
||||
ShapeSerializeType m_eShapeSerializeType = ShapeSerializeType::sstBinary;
|
||||
|
||||
public:
|
||||
CDocxRenderer_Private(NSFonts::IApplicationFonts* pFonts, IRenderer* pRenderer) : m_oDocument(pRenderer, pFonts)
|
||||
@ -139,12 +146,28 @@ std::vector<std::wstring> CDocxRenderer::ScanPagePptx(IOfficeDrawingFile* pFile,
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
|
||||
m_pInternal->m_bIsSupportShapeCommands = true;
|
||||
|
||||
m_pInternal->m_eShapeSerializeType = ShapeSerializeType::sstXml;
|
||||
DrawPage(pFile, nPage);
|
||||
m_pInternal->m_eShapeSerializeType = ShapeSerializeType::sstBinary;
|
||||
|
||||
auto xml_shapes = m_pInternal->m_oDocument.m_oCurrentPage.GetXmlShapesPptx();
|
||||
m_pInternal->m_oDocument.Clear();
|
||||
return xml_shapes;
|
||||
}
|
||||
NSWasm::CData CDocxRenderer::ScanPageBin(IOfficeDrawingFile* pFile, size_t nPage)
|
||||
{
|
||||
m_pInternal->m_oDocument.Clear();
|
||||
m_pInternal->m_oDocument.Init(false);
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = true;
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
|
||||
m_pInternal->m_bIsSupportShapeCommands = true;
|
||||
|
||||
DrawPage(pFile, nPage);
|
||||
|
||||
auto bin_shapes = m_pInternal->m_oDocument.m_oCurrentPage.GetShapesBin();
|
||||
m_pInternal->m_oDocument.Clear();
|
||||
return bin_shapes;
|
||||
}
|
||||
|
||||
void CDocxRenderer::SetExternalImageStorage(NSDocxRenderer::IImageStorage* pStorage)
|
||||
{
|
||||
@ -194,6 +217,7 @@ HRESULT CDocxRenderer::IsSupportAdvancedCommand(const IAdvancedCommand::Advanced
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT CDocxRenderer::AdvancedCommand(IAdvancedCommand* command)
|
||||
{
|
||||
if (NULL == command)
|
||||
@ -205,14 +229,69 @@ HRESULT CDocxRenderer::AdvancedCommand(IAdvancedCommand* command)
|
||||
{
|
||||
CShapeStart* pShape = (CShapeStart*)command;
|
||||
std::string& sUtf8Shape = pShape->GetShapeXML();
|
||||
UINT nImageId = 0xFFFFFFFF;
|
||||
|
||||
Aggplus::CImage* pImage = pShape->GetShapeImage();
|
||||
if (pImage)
|
||||
{
|
||||
std::shared_ptr<NSDocxRenderer::CImageInfo> pInfo = m_pInternal->m_oDocument.m_oImageManager.GenerateImageID(pImage);
|
||||
std::string sNewId = "r:embed=\"rId" + std::to_string(pInfo->m_nId + c_iStartingIdForImages) + "\"";
|
||||
NSStringUtils::string_replaceA(sUtf8Shape, "r:embed=\"\"", sNewId);
|
||||
nImageId = pInfo->m_nId;
|
||||
}
|
||||
|
||||
if (sUtf8Shape.empty())
|
||||
return S_FALSE;
|
||||
|
||||
if ('<' == sUtf8Shape.at(0))
|
||||
{
|
||||
if (m_pInternal->m_eShapeSerializeType == ShapeSerializeType::sstBinary)
|
||||
return S_FALSE;
|
||||
|
||||
if (0xFFFFFFFF != nImageId)
|
||||
{
|
||||
std::string sNewId = "r:embed=\"rId" + std::to_string(nImageId + c_iStartingIdForImages) + "\"";
|
||||
NSStringUtils::string_replaceA(sUtf8Shape, "r:embed=\"\"", sNewId);
|
||||
}
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.AddCompleteXml(UTF8_TO_U(sUtf8Shape));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_pInternal->m_eShapeSerializeType == ShapeSerializeType::sstXml)
|
||||
return S_FALSE;
|
||||
|
||||
if (0xFFFFFFFF != nImageId)
|
||||
{
|
||||
std::wstring rId_new = L"rId" + std::to_wstring(nImageId + c_iStartingIdForImages);
|
||||
NSWasm::CData rId_record;
|
||||
rId_record.StartRecord(100);
|
||||
rId_record.WriteStringUtf16(rId_new);
|
||||
rId_record.EndRecord();
|
||||
|
||||
int buff_len = NSBase64::Base64DecodeGetRequiredLength(sUtf8Shape.size());
|
||||
BYTE* buff = new BYTE[buff_len + rId_record.GetSize()];
|
||||
|
||||
if (NSBase64::Base64Decode(sUtf8Shape.c_str(), (int)sUtf8Shape.size(), buff, &buff_len))
|
||||
{
|
||||
memcpy(buff + buff_len, rId_record.GetBuffer(), rId_record.GetSize());
|
||||
|
||||
unsigned int curr_len = 0;
|
||||
memcpy(&curr_len, buff + 1, sizeof(unsigned int)); // first byte is "type" byte
|
||||
|
||||
curr_len += rId_record.GetSize();
|
||||
memcpy(buff + 1, &curr_len, sizeof(unsigned int));
|
||||
}
|
||||
|
||||
int buff_len_new = buff_len + rId_record.GetSize();
|
||||
int size_base64 = NSBase64::Base64EncodeGetRequiredLength(buff_len_new);
|
||||
char* data_base64 = new char[size_base64];
|
||||
NSBase64::Base64Encode(buff, buff_len_new, (BYTE*)data_base64, &size_base64, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
|
||||
sUtf8Shape = std::string(data_base64, size_base64);
|
||||
|
||||
delete[] buff;
|
||||
delete[] data_base64;
|
||||
}
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.AddCompleteBinBase64(sUtf8Shape);
|
||||
}
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.AddCompleteXml(UTF8_TO_U(sUtf8Shape));
|
||||
return S_OK;
|
||||
}
|
||||
case IAdvancedCommand::AdvancedCommandType::ShapeEnd:
|
||||
|
||||
@ -45,6 +45,7 @@
|
||||
|
||||
#include "convert_params.h"
|
||||
#include "src/logic/managers/ExternalImageStorage.h"
|
||||
#include "../DesktopEditor/graphics/pro/js/wasm/src/serialize.h"
|
||||
|
||||
class CDocxRenderer_Private;
|
||||
class DOCXRENDERER_DECL_EXPORT CDocxRenderer : public IRenderer
|
||||
@ -178,6 +179,7 @@ public:
|
||||
int Convert(IOfficeDrawingFile* pFile, const std::wstring& sDstFile, bool bIsOutCompress = true);
|
||||
std::vector<std::wstring> ScanPage(IOfficeDrawingFile* pFile, size_t nPage);
|
||||
std::vector<std::wstring> ScanPagePptx(IOfficeDrawingFile* pFile, size_t nPage);
|
||||
NSWasm::CData ScanPageBin(IOfficeDrawingFile* pFile, size_t nPage);
|
||||
|
||||
void SetExternalImageStorage(NSDocxRenderer::IImageStorage* pStorage);
|
||||
private:
|
||||
|
||||
@ -12,10 +12,10 @@
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
CDocument::CDocument(IRenderer* pRenderer, NSFonts::IApplicationFonts* pFonts) :
|
||||
m_pAppFonts(pFonts),
|
||||
m_oFontManager(pFonts),
|
||||
m_oFontSelector(pFonts),
|
||||
m_oCurrentPage(pFonts, {&m_oImageManager, &m_oFontStyleManager, &m_oParagraphStyleManager, &m_oFontManager, &m_oFontSelector})
|
||||
m_pAppFonts(pFonts),
|
||||
m_oFontManager(pFonts),
|
||||
m_oFontSelector(pFonts),
|
||||
m_oCurrentPage(pFonts, {&m_oImageManager, &m_oFontStyleManager, &m_oParagraphStyleManager, &m_oFontManager, &m_oFontSelector})
|
||||
{
|
||||
m_oSimpleGraphicsConverter.SetRenderer(pRenderer);
|
||||
}
|
||||
@ -492,8 +492,8 @@ namespace NSDocxRenderer
|
||||
|
||||
//-------- Функции для вывода текста --------------------------------------------------------
|
||||
HRESULT CDocument::CommandDrawTextPrivate(const int* pUnicodes, const int* pGids, int nCount,
|
||||
const double& dX, const double& dY, const double& dW,
|
||||
const double& dH, const double& dBaseLineOffset)
|
||||
const double& dX, const double& dY, const double& dW,
|
||||
const double& dH, const double& dBaseLineOffset)
|
||||
{
|
||||
double dAngleMatrix = m_oCurrentPage.m_oTransform.z_Rotation();
|
||||
if (fabs(dAngleMatrix) > 1 || m_oCurrentPage.m_oTransform.sx() < 0 || m_oCurrentPage.m_oTransform.sy() < 0)
|
||||
@ -830,44 +830,44 @@ namespace NSDocxRenderer
|
||||
|
||||
oDocumentStream.CreateFileW(m_strTempDirectory + L"/word/document.xml");
|
||||
oDocumentStream.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
|
||||
<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" \
|
||||
xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" \
|
||||
xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" \
|
||||
xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" \
|
||||
xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" \
|
||||
xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" \
|
||||
xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" \
|
||||
xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" \
|
||||
xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" \
|
||||
xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
|
||||
xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" \
|
||||
xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" \
|
||||
xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" \
|
||||
xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" \
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14\">\
|
||||
<w:body>");
|
||||
<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" \
|
||||
xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" \
|
||||
xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" \
|
||||
xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" \
|
||||
xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" \
|
||||
xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" \
|
||||
xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" \
|
||||
xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" \
|
||||
xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" \
|
||||
xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
|
||||
xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" \
|
||||
xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" \
|
||||
xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" \
|
||||
xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" \
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14\">\
|
||||
<w:body>");
|
||||
|
||||
for (size_t i = 0; i < m_mapXmlString.size(); ++i)
|
||||
for (size_t i = 0; i < m_mapXmlString.size(); ++i)
|
||||
{
|
||||
oDocumentStream.WriteStringUTF8(m_mapXmlString[i]->GetData());
|
||||
}
|
||||
@ -883,12 +883,12 @@ namespace NSDocxRenderer
|
||||
NSStringUtils::CStringBuilder oWriter;
|
||||
|
||||
oWriter.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
|
||||
<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\
|
||||
<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\"/>\
|
||||
<Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\" Target=\"settings.xml\"/>\
|
||||
<Relationship Id=\"rId3\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings\" Target=\"webSettings.xml\"/>\
|
||||
<Relationship Id=\"rId4\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\" Target=\"fontTable.xml\"/>\
|
||||
<Relationship Id=\"rId5\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\" Target=\"theme/theme.xml\"/>");
|
||||
<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\
|
||||
<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\"/>\
|
||||
<Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\" Target=\"settings.xml\"/>\
|
||||
<Relationship Id=\"rId3\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings\" Target=\"webSettings.xml\"/>\
|
||||
<Relationship Id=\"rId4\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\" Target=\"fontTable.xml\"/>\
|
||||
<Relationship Id=\"rId5\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\" Target=\"theme/theme.xml\"/>");
|
||||
|
||||
for (const auto& pImage : m_oImageManager.m_mapImageData)
|
||||
{
|
||||
@ -912,17 +912,17 @@ namespace NSDocxRenderer
|
||||
NSStringUtils::CStringBuilder oWriter;
|
||||
// сохраним fontTable
|
||||
oWriter.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
|
||||
<w:fonts xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" \
|
||||
xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" \
|
||||
xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" \
|
||||
xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" \
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh\">");
|
||||
<w:fonts xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" \
|
||||
xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" \
|
||||
xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" \
|
||||
xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" \
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh\">");
|
||||
|
||||
const auto& cache = m_oFontSelector.GetCache();
|
||||
std::list<CFontSelector::CFontSelectInfo> font_table;
|
||||
@ -994,17 +994,17 @@ namespace NSDocxRenderer
|
||||
|
||||
// сохраним styles
|
||||
oWriter.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
|
||||
<w:styles xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" \
|
||||
xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" \
|
||||
xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" \
|
||||
xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" \
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh\">");
|
||||
<w:styles xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" \
|
||||
xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" \
|
||||
xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" \
|
||||
xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" \
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh\">");
|
||||
|
||||
oWriter.WriteString(L"<w:docDefaults>");
|
||||
oWriter.WriteString(L"<w:rPrDefault><w:rPr>");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -68,50 +68,65 @@ namespace NSDocxRenderer
|
||||
void DrawPath(LONG lType, const std::shared_ptr<CImageInfo> pInfo);
|
||||
|
||||
void AddText(
|
||||
const PUINT pUnicodes,
|
||||
const PUINT pGids,
|
||||
const UINT& nCount,
|
||||
const double& fX,
|
||||
const double& fY,
|
||||
const double& fWidth,
|
||||
const double& fHeight,
|
||||
const double& fBaseLineOffset);
|
||||
const PUINT pUnicodes,
|
||||
const PUINT pGids,
|
||||
const UINT& nCount,
|
||||
const double& fX,
|
||||
const double& fY,
|
||||
const double& fWidth,
|
||||
const double& fHeight,
|
||||
const double& fBaseLineOffset);
|
||||
|
||||
void Analyze();
|
||||
void Record(NSStringUtils::CStringBuilder& oWriter, bool bIsLastPage);
|
||||
|
||||
std::vector<std::wstring> GetXmlShapes();
|
||||
std::vector<std::wstring> GetXmlShapesPptx();
|
||||
void AddCompleteXml(const std::wstring oXml);
|
||||
NSWasm::CData GetShapesBin();
|
||||
|
||||
void AddCompleteXml(const std::wstring& oXml);
|
||||
void AddCompleteBinBase64(const std::string& oBase64);
|
||||
|
||||
private:
|
||||
using shape_ptr_t = std::shared_ptr<CShape>;
|
||||
using cont_ptr_t = std::shared_ptr<CContText>;
|
||||
using line_ptr_t = std::shared_ptr<CTextLine>;
|
||||
using item_ptr_t = std::shared_ptr<CBaseItem>;
|
||||
using text_line_ptr_t = std::shared_ptr<CTextLine>;
|
||||
using base_item_ptr_t = std::shared_ptr<CBaseItem>;
|
||||
using ooxml_item_ptr_t = std::shared_ptr<IOoxmlItem>;
|
||||
using paragraph_ptr_t = std::shared_ptr<CParagraph>;
|
||||
using table_ptr_t = std::shared_ptr<CTable>;
|
||||
|
||||
using graphical_cell_ptr_t = std::shared_ptr<CGraphicalCell>;
|
||||
using text_cell_ptr_t = std::shared_ptr<CTextCell>;
|
||||
using cell_ptr_t = std::shared_ptr<CTable::CCell>;
|
||||
|
||||
using text_line_group_ptr_t = std::shared_ptr<CBaseItemGroup<CTextLine>>;
|
||||
using text_cell_group_ptr_t = std::shared_ptr<CBaseItemGroup<CTextCell>>;
|
||||
using cell_group_ptr_t = std::shared_ptr<CBaseItemGroup<CTable::CCell>>;
|
||||
|
||||
// returns std::vector of conts with diac. symbols and remove it from m_arConts
|
||||
std::vector<cont_ptr_t> MoveDiacriticalSymbols();
|
||||
|
||||
// returns std::vector of text lines builded from m_arConts
|
||||
std::vector<line_ptr_t> BuildTextLines();
|
||||
std::vector<text_line_ptr_t> BuildTextLines(const std::vector<cont_ptr_t>& arConts);
|
||||
|
||||
// build text line groups
|
||||
std::vector<text_line_group_ptr_t> BuildTextLineGroups();
|
||||
|
||||
// returns std::vector of paragraphs builded from m_arTextLines
|
||||
std::vector<paragraph_ptr_t> BuildParagraphs();
|
||||
std::vector<paragraph_ptr_t> BuildParagraphs(const std::vector<text_line_group_ptr_t>& arTextLineGroups);
|
||||
|
||||
// return groups of text cells
|
||||
std::vector<text_cell_group_ptr_t> BuildTextCellGroups(const std::vector<text_line_group_ptr_t>& arTextLineGroups);
|
||||
|
||||
// returns std::vector of tables builded from shapes and paragraphes
|
||||
std::vector<table_ptr_t> BuildTables();
|
||||
std::vector<table_ptr_t> BuildTables(const std::vector<text_line_group_ptr_t>& arTextLineGroups);
|
||||
|
||||
// returns std::vector of cells for tables
|
||||
std::vector<CTable::cell_ptr_t> BuildCells();
|
||||
|
||||
// returns std::vector of rows for tables
|
||||
std::vector<CTable::row_ptr_t> BuildRows(std::vector<CTable::cell_ptr_t>& arCells);
|
||||
// return std::vector of graphical cells (from shapes)
|
||||
std::vector<graphical_cell_ptr_t> BuildGraphicalCells();
|
||||
|
||||
// returns std::vector of base items builded from m_arParagraphs
|
||||
std::vector<item_ptr_t> BuildOutputObjects();
|
||||
std::vector<ooxml_item_ptr_t> BuildOutputObjects();
|
||||
|
||||
// analyze shapes (set lines type)
|
||||
void AnalyzeShapes();
|
||||
@ -132,7 +147,7 @@ namespace NSDocxRenderer
|
||||
void AnalyzeEffects();
|
||||
|
||||
// adds diacritical symbols in conts
|
||||
void AddDiacriticalSymbols();
|
||||
void AddDiacriticalSymbols(const std::vector<cont_ptr_t>& arDiac);
|
||||
|
||||
// super-sub scripts line merge
|
||||
void MergeTextLinesByVatType();
|
||||
@ -167,27 +182,24 @@ namespace NSDocxRenderer
|
||||
// for drawingml is no tag behind-doc - so we need to reorder shapes
|
||||
void ReorderShapesForPptx();
|
||||
|
||||
// get lines by groups by X
|
||||
std::vector<std::vector<line_ptr_t>> GetLinesByGroups();
|
||||
|
||||
bool IsLineCrossingText(shape_ptr_t pShape, cont_ptr_t pCont) const noexcept;
|
||||
bool IsLineBelowText(shape_ptr_t pShape, cont_ptr_t pCont) const noexcept;
|
||||
bool IsHighlight(shape_ptr_t pShape, cont_ptr_t pCont) const noexcept;
|
||||
bool IsOutline(shape_ptr_t pShape, cont_ptr_t pCont) const noexcept;
|
||||
|
||||
bool IsVerticalLineBetween(item_ptr_t pFirst, item_ptr_t pSecond) const noexcept;
|
||||
bool IsHorizontalLineBetween(item_ptr_t pFirst, item_ptr_t pSecond) const noexcept;
|
||||
bool IsVerticalLineBetween(base_item_ptr_t pFirst, base_item_ptr_t pSecond) const noexcept;
|
||||
bool IsHorizontalLineBetween(base_item_ptr_t pFirst, base_item_ptr_t pSecond) const noexcept;
|
||||
|
||||
bool IsVerticalLineBetween(line_ptr_t pFirst, line_ptr_t pSecond) const noexcept;
|
||||
bool IsHorizontalLineBetween(line_ptr_t pFirst, line_ptr_t pSecond) const noexcept;
|
||||
bool IsVerticalLineBetween(text_line_ptr_t pFirst, text_line_ptr_t pSecond) const noexcept;
|
||||
bool IsHorizontalLineBetween(text_line_ptr_t pFirst, text_line_ptr_t pSecond) const noexcept;
|
||||
|
||||
bool IsVerticalLineTrough(item_ptr_t pFirst) const noexcept;
|
||||
bool IsHorizontalLineTrough(item_ptr_t pFirst) const noexcept;
|
||||
bool IsVerticalLineTrough(base_item_ptr_t pFirst) const noexcept;
|
||||
bool IsHorizontalLineTrough(base_item_ptr_t pFirst) const noexcept;
|
||||
|
||||
void ToXml(NSStringUtils::CStringBuilder& oWriter) const noexcept;
|
||||
void WriteSectionToFile(bool bLastPage, NSStringUtils::CStringBuilder& oWriter) const noexcept;
|
||||
|
||||
static shape_ptr_t CreateSingleLineShape(line_ptr_t& pLine);
|
||||
static shape_ptr_t CreateSingleLineShape(text_line_ptr_t& pLine);
|
||||
static shape_ptr_t CreateSingleParagraphShape(paragraph_ptr_t& pParagraph);
|
||||
|
||||
void DrawImage(shape_ptr_t pShape, std::shared_ptr<CImageInfo> oImg, CVectorGraphics& imageVector);
|
||||
@ -204,15 +216,14 @@ namespace NSDocxRenderer
|
||||
CContTextBuilder m_oContBuilder;
|
||||
CHorVerLinesCollector m_oHorVerLinesCollector;
|
||||
|
||||
std::vector<cont_ptr_t> m_arConts;
|
||||
std::vector<line_ptr_t> m_arTextLines;
|
||||
std::vector<cont_ptr_t> m_arDiacriticalSymbols;
|
||||
std::vector<shape_ptr_t> m_arShapes;
|
||||
std::vector<paragraph_ptr_t> m_arParagraphs;
|
||||
std::vector<table_ptr_t> m_arTables;
|
||||
std::vector<shape_ptr_t> m_arShapes;
|
||||
std::vector<text_line_ptr_t> m_arTextLines;
|
||||
std::vector<paragraph_ptr_t> m_arParagraphs;
|
||||
std::vector<table_ptr_t> m_arTables;
|
||||
std::vector<ooxml_item_ptr_t> m_arOutputObjects;
|
||||
|
||||
std::vector<item_ptr_t> m_arOutputObjects;
|
||||
std::vector<std::wstring> m_arCompleteObjectsXml;
|
||||
std::vector<std::string> m_arCompleteObjectsBinBase64;
|
||||
|
||||
// save the luminosity shapes for later filling
|
||||
std::vector<shape_ptr_t> m_arLuminosityShapes;
|
||||
|
||||
@ -6,76 +6,102 @@
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
CBaseItem& CBaseItem::operator=(const CBaseItem& oSrc)
|
||||
CBaseItem::CBaseItem()
|
||||
{
|
||||
if (this == &oSrc)
|
||||
}
|
||||
CBaseItem::CBaseItem(const CBaseItem& other) :
|
||||
m_dTop(other.m_dTop),
|
||||
m_dBot(other.m_dBot),
|
||||
m_dLeft(other.m_dLeft),
|
||||
m_dRight(other.m_dRight),
|
||||
m_dHeight(other.m_dHeight),
|
||||
m_dWidth(other.m_dWidth)
|
||||
{
|
||||
}
|
||||
|
||||
CBaseItem::CBaseItem(CBaseItem&& other) :
|
||||
m_dTop(other.m_dTop),
|
||||
m_dBot(other.m_dBot),
|
||||
m_dLeft(other.m_dLeft),
|
||||
m_dRight(other.m_dRight),
|
||||
m_dHeight(other.m_dHeight),
|
||||
m_dWidth(other.m_dWidth)
|
||||
{
|
||||
}
|
||||
CBaseItem::~CBaseItem()
|
||||
{
|
||||
}
|
||||
|
||||
CBaseItem& CBaseItem::operator=(const CBaseItem& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_dLeft = oSrc.m_dLeft;
|
||||
m_dTop = oSrc.m_dTop;
|
||||
m_dWidth = oSrc.m_dWidth;
|
||||
m_dHeight = oSrc.m_dHeight;
|
||||
m_dBaselinePos = oSrc.m_dBaselinePos;
|
||||
m_dRight = oSrc.m_dRight;
|
||||
|
||||
m_dTop = other.m_dTop;
|
||||
m_dBot = other.m_dBot;
|
||||
m_dLeft = other.m_dLeft;
|
||||
m_dRight = other.m_dRight;
|
||||
m_dHeight = other.m_dHeight;
|
||||
m_dWidth = other.m_dWidth;
|
||||
return *this;
|
||||
}
|
||||
bool CBaseItem::operator==(const CBaseItem& oSrc)
|
||||
CBaseItem& CBaseItem::operator=(CBaseItem&& other)
|
||||
{
|
||||
if (this == &oSrc)
|
||||
return true;
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
return m_dLeft == oSrc.m_dLeft &&
|
||||
m_dTop == oSrc.m_dTop &&
|
||||
m_dWidth == oSrc.m_dWidth &&
|
||||
m_dHeight == oSrc.m_dHeight &&
|
||||
m_dBaselinePos == oSrc.m_dBaselinePos &&
|
||||
m_dRight == oSrc.m_dRight;
|
||||
m_dTop = other.m_dTop;
|
||||
m_dBot = other.m_dBot;
|
||||
m_dLeft = other.m_dLeft;
|
||||
m_dRight = other.m_dRight;
|
||||
m_dHeight = other.m_dHeight;
|
||||
m_dWidth = other.m_dWidth;
|
||||
return *this;
|
||||
}
|
||||
|
||||
eVerticalCrossingType CBaseItem::GetVerticalCrossingType(const CBaseItem* oSrc) const
|
||||
eVerticalCrossingType CBaseItem::GetVerticalCrossingType(const CBaseItem* pBaseItem) const
|
||||
{
|
||||
if (m_dTop > oSrc->m_dTop && m_dBaselinePos < oSrc->m_dBaselinePos)
|
||||
if (m_dTop > pBaseItem->m_dTop && m_dBot < pBaseItem->m_dBot)
|
||||
{
|
||||
return eVerticalCrossingType::vctCurrentInsideNext;
|
||||
}
|
||||
else if (m_dTop < oSrc->m_dTop && m_dBaselinePos > oSrc->m_dBaselinePos)
|
||||
else if (m_dTop < pBaseItem->m_dTop && m_dBot > pBaseItem->m_dBot)
|
||||
{
|
||||
return eVerticalCrossingType::vctCurrentOutsideNext;
|
||||
}
|
||||
else if (m_dTop < oSrc->m_dTop && m_dBaselinePos < oSrc->m_dBaselinePos &&
|
||||
(m_dBaselinePos >= oSrc->m_dTop || fabs(m_dBaselinePos - oSrc->m_dTop) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
else if (m_dTop < pBaseItem->m_dTop && m_dBot < pBaseItem->m_dBot &&
|
||||
(m_dBot >= pBaseItem->m_dTop || fabs(m_dBot - pBaseItem->m_dTop) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
{
|
||||
return eVerticalCrossingType::vctCurrentAboveNext;
|
||||
}
|
||||
else if (m_dTop > oSrc->m_dTop && m_dBaselinePos > oSrc->m_dBaselinePos &&
|
||||
(m_dTop <= oSrc->m_dBaselinePos || fabs(m_dTop - oSrc->m_dBaselinePos) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
else if (m_dTop > pBaseItem->m_dTop && m_dBot > pBaseItem->m_dBot &&
|
||||
(m_dTop <= pBaseItem->m_dBot || fabs(m_dTop - pBaseItem->m_dBot) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
{
|
||||
return eVerticalCrossingType::vctCurrentBelowNext;
|
||||
}
|
||||
else if (m_dTop == oSrc->m_dTop && m_dBaselinePos == oSrc->m_dBaselinePos &&
|
||||
m_dLeft == oSrc->m_dLeft && m_dRight == oSrc->m_dRight)
|
||||
else if (m_dTop == pBaseItem->m_dTop && m_dBot == pBaseItem->m_dBot &&
|
||||
m_dLeft == pBaseItem->m_dLeft && m_dRight == pBaseItem->m_dRight)
|
||||
{
|
||||
return eVerticalCrossingType::vctDublicate;
|
||||
}
|
||||
else if (fabs(m_dTop - oSrc->m_dTop) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
|
||||
fabs(m_dBaselinePos - oSrc->m_dBaselinePos) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
else if (fabs(m_dTop - pBaseItem->m_dTop) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
|
||||
fabs(m_dBot - pBaseItem->m_dBot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
{
|
||||
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
|
||||
}
|
||||
else if (fabs(m_dTop - oSrc->m_dTop) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
else if (fabs(m_dTop - pBaseItem->m_dTop) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
{
|
||||
return eVerticalCrossingType::vctTopBorderMatch;
|
||||
}
|
||||
else if (fabs(m_dBaselinePos - oSrc->m_dBaselinePos) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
else if (fabs(m_dBot - pBaseItem->m_dBot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
{
|
||||
return eVerticalCrossingType::vctBottomBorderMatch;
|
||||
}
|
||||
else if (m_dBaselinePos < oSrc->m_dTop)
|
||||
else if (m_dBot < pBaseItem->m_dTop)
|
||||
{
|
||||
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
|
||||
}
|
||||
else if (m_dTop > oSrc->m_dBaselinePos)
|
||||
else if (m_dTop > pBaseItem->m_dBot)
|
||||
{
|
||||
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
|
||||
}
|
||||
@ -84,49 +110,49 @@ namespace NSDocxRenderer
|
||||
return eVerticalCrossingType::vctUnknown;
|
||||
}
|
||||
}
|
||||
eHorizontalCrossingType CBaseItem::GetHorizontalCrossingType(const CBaseItem* oSrc) const
|
||||
eHorizontalCrossingType CBaseItem::GetHorizontalCrossingType(const CBaseItem* pBaseItem) const
|
||||
{
|
||||
if (m_dLeft > oSrc->m_dLeft && m_dRight < oSrc->m_dRight)
|
||||
if (m_dLeft > pBaseItem->m_dLeft && m_dRight < pBaseItem->m_dRight)
|
||||
{
|
||||
return eHorizontalCrossingType::hctCurrentInsideNext;
|
||||
}
|
||||
else if (m_dLeft < oSrc->m_dLeft && m_dRight > oSrc->m_dRight)
|
||||
else if (m_dLeft < pBaseItem->m_dLeft && m_dRight > pBaseItem->m_dRight)
|
||||
{
|
||||
return eHorizontalCrossingType::hctCurrentOutsideNext;
|
||||
}
|
||||
else if (m_dLeft < oSrc->m_dLeft && m_dRight < oSrc->m_dRight &&
|
||||
(m_dRight >= oSrc->m_dLeft || fabs(m_dRight - oSrc->m_dLeft) < c_dTHE_SAME_STRING_X_PRECISION_MM))
|
||||
{
|
||||
return eHorizontalCrossingType::hctCurrentLeftOfNext;
|
||||
}
|
||||
else if (m_dLeft > oSrc->m_dLeft && m_dRight > oSrc->m_dRight &&
|
||||
(m_dLeft <= oSrc->m_dRight || fabs(m_dLeft - oSrc->m_dRight) < c_dTHE_SAME_STRING_X_PRECISION_MM))
|
||||
{
|
||||
return eHorizontalCrossingType::hctCurrentRightOfNext;
|
||||
}
|
||||
else if (m_dLeft == oSrc->m_dLeft && m_dRight == oSrc->m_dRight &&
|
||||
m_dTop == oSrc->m_dTop && m_dBaselinePos == oSrc->m_dBaselinePos)
|
||||
{
|
||||
return eHorizontalCrossingType::hctDublicate;
|
||||
}
|
||||
else if (fabs(m_dLeft - oSrc->m_dLeft) < c_dTHE_SAME_STRING_X_PRECISION_MM &&
|
||||
fabs(m_dRight - oSrc->m_dRight) < c_dTHE_SAME_STRING_X_PRECISION_MM)
|
||||
else if (fabs(m_dLeft - pBaseItem->m_dLeft) < c_dTHE_SAME_STRING_X_PRECISION_MM &&
|
||||
fabs(m_dRight - pBaseItem->m_dRight) < c_dTHE_SAME_STRING_X_PRECISION_MM)
|
||||
{
|
||||
return eHorizontalCrossingType::hctLeftAndRightBordersMatch;
|
||||
}
|
||||
else if (fabs(m_dLeft - oSrc->m_dLeft) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
else if (m_dLeft < pBaseItem->m_dLeft && m_dRight < pBaseItem->m_dRight &&
|
||||
(m_dRight >= pBaseItem->m_dLeft || fabs(m_dRight - pBaseItem->m_dLeft) < c_dTHE_SAME_STRING_X_PRECISION_MM))
|
||||
{
|
||||
return eHorizontalCrossingType::hctCurrentLeftOfNext;
|
||||
}
|
||||
else if (m_dLeft > pBaseItem->m_dLeft && m_dRight > pBaseItem->m_dRight &&
|
||||
(m_dLeft <= pBaseItem->m_dRight || fabs(m_dLeft - pBaseItem->m_dRight) < c_dTHE_SAME_STRING_X_PRECISION_MM))
|
||||
{
|
||||
return eHorizontalCrossingType::hctCurrentRightOfNext;
|
||||
}
|
||||
else if (m_dLeft == pBaseItem->m_dLeft && m_dRight == pBaseItem->m_dRight &&
|
||||
m_dTop == pBaseItem->m_dTop && m_dBot == pBaseItem->m_dBot)
|
||||
{
|
||||
return eHorizontalCrossingType::hctDublicate;
|
||||
}
|
||||
else if (fabs(m_dLeft - pBaseItem->m_dLeft) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
{
|
||||
return eHorizontalCrossingType::hctLeftBorderMatch;
|
||||
}
|
||||
else if (fabs(m_dRight - oSrc->m_dRight) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
else if (fabs(m_dRight - pBaseItem->m_dRight) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
{
|
||||
return eHorizontalCrossingType::hctRightBorderMatch;
|
||||
}
|
||||
else if (m_dRight < oSrc->m_dLeft)
|
||||
else if (m_dRight < pBaseItem->m_dLeft)
|
||||
{
|
||||
return eHorizontalCrossingType::hctNoCrossingCurrentLeftOfNext;
|
||||
}
|
||||
else if (m_dLeft > oSrc->m_dRight)
|
||||
else if (m_dLeft > pBaseItem->m_dRight)
|
||||
{
|
||||
return eHorizontalCrossingType::hctNoCrossingCurrentRightOfNext;
|
||||
}
|
||||
@ -136,31 +162,32 @@ namespace NSDocxRenderer
|
||||
}
|
||||
}
|
||||
|
||||
bool CBaseItem::AreObjectsNoCrossingByVertically(const CBaseItem* pObj) const noexcept
|
||||
bool CBaseItem::AreObjectsNoCrossingByVertically(const CBaseItem* pBaseItem) const noexcept
|
||||
{
|
||||
eVerticalCrossingType eVType = GetVerticalCrossingType(pObj);
|
||||
eVerticalCrossingType eVType = GetVerticalCrossingType(pBaseItem);
|
||||
|
||||
return (eVType == eVerticalCrossingType::vctNoCrossingCurrentAboveNext ||
|
||||
eVType == eVerticalCrossingType::vctNoCrossingCurrentBelowNext);
|
||||
eVType == eVerticalCrossingType::vctNoCrossingCurrentBelowNext);
|
||||
}
|
||||
bool CBaseItem::AreObjectsNoCrossingByHorizontally(const CBaseItem* pObj) const noexcept
|
||||
bool CBaseItem::AreObjectsNoCrossingByHorizontally(const CBaseItem* pBaseItem) const noexcept
|
||||
{
|
||||
eHorizontalCrossingType eHType = GetHorizontalCrossingType(pObj);
|
||||
eHorizontalCrossingType eHType = GetHorizontalCrossingType(pBaseItem);
|
||||
|
||||
return (eHType == eHorizontalCrossingType::hctNoCrossingCurrentLeftOfNext ||
|
||||
eHType == eHorizontalCrossingType::hctNoCrossingCurrentRightOfNext);
|
||||
eHType == eHorizontalCrossingType::hctNoCrossingCurrentRightOfNext);
|
||||
}
|
||||
bool CBaseItem::IsEqual(double dTop, double dBaselinePos, double dLeft, double dRight) const noexcept
|
||||
bool CBaseItem::IsEqual(double dTop, double dBot, double dLeft, double dRight) const noexcept
|
||||
{
|
||||
return m_dLeft == dLeft &&
|
||||
m_dTop == dTop &&
|
||||
m_dBaselinePos == dBaselinePos &&
|
||||
m_dRight == dRight;
|
||||
return m_dLeft == dLeft && m_dTop == dTop && m_dBot == dBot && m_dRight == dRight;
|
||||
}
|
||||
bool CBaseItem::operator==(const CBaseItem& other)
|
||||
{
|
||||
return IsEqual(other.m_dTop, other.m_dBot, other.m_dLeft, other.m_dRight);
|
||||
}
|
||||
|
||||
void CBaseItem::RecalcWithNewItem(const CBaseItem* pItem)
|
||||
{
|
||||
m_dBaselinePos = std::max(m_dBaselinePos, pItem->m_dBaselinePos);
|
||||
m_dBot = std::max(m_dBot, pItem->m_dBot);
|
||||
|
||||
if ((pItem->m_dLeft < m_dLeft) || (pItem->m_dLeft > 0 && m_dLeft == 0.0))
|
||||
m_dLeft = pItem->m_dLeft;
|
||||
@ -172,6 +199,6 @@ namespace NSDocxRenderer
|
||||
m_dTop = pItem->m_dTop;
|
||||
|
||||
m_dWidth = m_dRight - m_dLeft;
|
||||
m_dHeight = m_dBaselinePos - m_dTop;
|
||||
m_dHeight = m_dBot - m_dTop;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "../../../../DesktopEditor/common/StringBuilder.h"
|
||||
#include "../../../../DesktopEditor/graphics/pro/js/wasm/src/serialize.h"
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
@ -39,30 +43,112 @@ namespace NSDocxRenderer
|
||||
class CBaseItem
|
||||
{
|
||||
public:
|
||||
double m_dTop {0.0};
|
||||
double m_dBaselinePos {0.0};
|
||||
double m_dTop {0.0};
|
||||
double m_dBot {0.0};
|
||||
double m_dLeft {0.0};
|
||||
double m_dRight {0.0};
|
||||
double m_dHeight {0.0};
|
||||
double m_dWidth {0.0};
|
||||
|
||||
double m_dLeft {0.0};
|
||||
double m_dRight {0.0};
|
||||
double m_dWidth {0.0};
|
||||
CBaseItem();
|
||||
CBaseItem(const CBaseItem& other);
|
||||
CBaseItem(CBaseItem&& other);
|
||||
virtual ~CBaseItem();
|
||||
|
||||
CBaseItem() = default;
|
||||
virtual ~CBaseItem() = default;
|
||||
CBaseItem& operator=(const CBaseItem& other);
|
||||
CBaseItem& operator=(CBaseItem&& other);
|
||||
|
||||
virtual void Clear() = 0;
|
||||
virtual eVerticalCrossingType GetVerticalCrossingType(const CBaseItem* pBaseItem) const;
|
||||
virtual eHorizontalCrossingType GetHorizontalCrossingType(const CBaseItem* pBaseItem) const;
|
||||
virtual void RecalcWithNewItem(const CBaseItem* pBaseItem);
|
||||
|
||||
bool AreObjectsNoCrossingByVertically(const CBaseItem* pBaseItem) const noexcept;
|
||||
bool AreObjectsNoCrossingByHorizontally(const CBaseItem* pBaseItem) const noexcept;
|
||||
bool IsEqual(double dTop, double dBot, double dLeft, double dRight) const noexcept;
|
||||
|
||||
bool operator==(const CBaseItem& other);
|
||||
};
|
||||
|
||||
class IOoxmlItem
|
||||
{
|
||||
public:
|
||||
virtual void ToXml(NSStringUtils::CStringBuilder& oWriter) const = 0;
|
||||
virtual void ToXmlPptx(NSStringUtils::CStringBuilder& oWriter) const = 0;
|
||||
virtual void ToBin(NSWasm::CData& oWriter) const = 0;
|
||||
|
||||
virtual eVerticalCrossingType GetVerticalCrossingType(const CBaseItem* oSrc) const;
|
||||
virtual eHorizontalCrossingType GetHorizontalCrossingType(const CBaseItem* oSrc) const;
|
||||
virtual void RecalcWithNewItem(const CBaseItem* pObj);
|
||||
static const BYTE kBin_g_nodeAttributeStart = 250;
|
||||
static const BYTE kBin_g_nodeAttributeEnd = 251;
|
||||
};
|
||||
|
||||
bool AreObjectsNoCrossingByVertically(const CBaseItem* pObj) const noexcept;
|
||||
bool AreObjectsNoCrossingByHorizontally(const CBaseItem* pObj) const noexcept;
|
||||
bool IsEqual(double dTop, double dBaselinePos, double dLeft, double dRight) const noexcept;
|
||||
// using template to avoid downcasting
|
||||
template <typename T>
|
||||
class CBaseItemGroup : public CBaseItem
|
||||
{
|
||||
public:
|
||||
std::vector<std::shared_ptr<T>> m_arItems;
|
||||
|
||||
CBaseItem& operator=(const CBaseItem& oSrc);
|
||||
bool operator==(const CBaseItem& oSrc);
|
||||
CBaseItemGroup()
|
||||
{
|
||||
static_assert(std::is_base_of<CBaseItem, T>::value, "T should has base of CBaseItem!");
|
||||
}
|
||||
CBaseItemGroup(const CBaseItemGroup<T>& other) : CBaseItemGroup()
|
||||
{
|
||||
for (const auto value : other.m_arItems)
|
||||
m_arItems.push_back(value);
|
||||
}
|
||||
CBaseItemGroup(CBaseItemGroup<T>&& other) : CBaseItemGroup()
|
||||
{
|
||||
m_arItems = std::move(other);
|
||||
}
|
||||
virtual ~CBaseItemGroup() {}
|
||||
|
||||
CBaseItemGroup<T>& operator=(const CBaseItemGroup<T>& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_arItems.clear();
|
||||
for (const auto value : other.m_arItems)
|
||||
m_arItems.push_back(value);
|
||||
|
||||
return *this;
|
||||
}
|
||||
CBaseItemGroup<T>& operator=(CBaseItemGroup<T>&& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_arItems = std::move(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void AddItem(const std::shared_ptr<T>& pItem)
|
||||
{
|
||||
CBaseItem::RecalcWithNewItem(pItem.get());
|
||||
m_arItems.push_back(pItem);
|
||||
}
|
||||
void AddItem(std::shared_ptr<T>&& pItem)
|
||||
{
|
||||
CBaseItem::RecalcWithNewItem(pItem.get());
|
||||
m_arItems.push_back(std::move(pItem));
|
||||
}
|
||||
};
|
||||
|
||||
enum class eBaseItemCmpType
|
||||
{
|
||||
bictVertical,
|
||||
bictHorizontal
|
||||
};
|
||||
|
||||
template <eBaseItemCmpType CmpType>
|
||||
struct CBaseItemCmp
|
||||
{
|
||||
bool operator() (const CBaseItem& item1, const CBaseItem& item2) const
|
||||
{
|
||||
if (CmpType == eBaseItemCmpType::bictVertical)
|
||||
return item1.m_dBot < item2.m_dBot;
|
||||
if (CmpType == eBaseItemCmpType::bictHorizontal)
|
||||
return item1.m_dLeft < item2.m_dLeft;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ namespace NSDocxRenderer
|
||||
m_dBotWithDescent = rCont.m_dBotWithDescent;
|
||||
|
||||
m_oSelectedFont = rCont.m_oSelectedFont;
|
||||
m_bPossibleSplit = rCont.m_bPossibleSplit;
|
||||
m_bPossibleHorSplit = rCont.m_bPossibleHorSplit;
|
||||
m_bWriteStyleRaw = rCont.m_bWriteStyleRaw;
|
||||
|
||||
m_arSymWidths.clear();
|
||||
@ -135,7 +135,7 @@ namespace NSDocxRenderer
|
||||
m_dRight = cont->m_dLeft;
|
||||
m_dWidth = m_dRight - m_dLeft;
|
||||
m_arSymWidths.resize(index + 1);
|
||||
m_bPossibleSplit = false;
|
||||
m_bPossibleHorSplit = false;
|
||||
|
||||
return cont;
|
||||
}
|
||||
@ -181,18 +181,18 @@ namespace NSDocxRenderer
|
||||
return eVerticalCrossingType::vctCurrentOutsideNext;
|
||||
|
||||
else if (this_top < other_top && this_bot < other_bot &&
|
||||
(this_bot >= other_top || fabs(this_bot - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
(this_bot >= other_top || fabs(this_bot - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
return eVerticalCrossingType::vctCurrentAboveNext;
|
||||
|
||||
else if (this_top > other_top && this_bot > other_bot &&
|
||||
(this_top <= other_bot || fabs(this_top - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
(this_top <= other_bot || fabs(this_top - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
return eVerticalCrossingType::vctCurrentBelowNext;
|
||||
|
||||
else if (this_top == other_top && this_bot == other_bot)
|
||||
return eVerticalCrossingType::vctDublicate;
|
||||
|
||||
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
|
||||
fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
|
||||
|
||||
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
@ -475,7 +475,7 @@ namespace NSDocxRenderer
|
||||
oWriter.WriteString(L" x=\"");
|
||||
oWriter.AddDouble(m_dLeft, 4);
|
||||
oWriter.WriteString(L"\" y=\"");
|
||||
oWriter.AddDouble(m_dBaselinePos, 4);
|
||||
oWriter.AddDouble(m_dBot, 4);
|
||||
oWriter.WriteString(L"\" widths=\"");
|
||||
for (auto& w : m_arSymWidths)
|
||||
{
|
||||
@ -490,6 +490,117 @@ namespace NSDocxRenderer
|
||||
oWriter.WriteString(L"\" />");
|
||||
oWriter.WriteString(L"</a:r>");
|
||||
}
|
||||
void CContText::ToBin(NSWasm::CData& oWriter) const
|
||||
{
|
||||
int lCalculatedSpacing = 0;
|
||||
if (!m_oText.empty())
|
||||
{
|
||||
double dSpacing = (m_dWidth - m_oSelectedSizes.dWidth) / (m_oText.length());
|
||||
dSpacing *= c_dMMToPt * 100;
|
||||
lCalculatedSpacing = static_cast<LONG>(dSpacing);
|
||||
}
|
||||
lCalculatedSpacing -= 15;
|
||||
|
||||
const BYTE kPARRUN_TYPE_RUN = 1;
|
||||
oWriter.StartRecord(kPARRUN_TYPE_RUN);
|
||||
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(0); oWriter.WriteStringUtf16(m_oText.ToStdWString());
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
|
||||
// WriteRecord WriteRunProperties
|
||||
[&oWriter, this, lCalculatedSpacing] () {
|
||||
oWriter.StartRecord(0);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
|
||||
oWriter.WriteBYTE(1); oWriter.WriteBool(m_pFontStyle->bBold);
|
||||
oWriter.WriteBYTE(7); oWriter.WriteBool(m_pFontStyle->bItalic);
|
||||
|
||||
BYTE strike = 1;
|
||||
if (m_bIsDoubleStrikeout) strike = 0;
|
||||
else if (m_bIsStrikeoutPresent) strike = 2;
|
||||
oWriter.WriteBYTE(16); oWriter.WriteBYTE(strike);
|
||||
oWriter.WriteBYTE(15); oWriter.AddSInt(lCalculatedSpacing);
|
||||
oWriter.WriteBYTE(18); oWriter.WriteBYTE(m_bIsUnderlinePresent ? 13 : 12);
|
||||
unsigned int font_size = static_cast<unsigned int>(m_pFontStyle->dFontSize) * 100;
|
||||
const unsigned int min_font_size = 100;
|
||||
oWriter.WriteBYTE(17); oWriter.AddInt(std::max(font_size, std::max(font_size, min_font_size)));
|
||||
|
||||
oWriter.WriteBYTE(2);
|
||||
if (m_eVertAlignType == eVertAlignType::vatSubscript)
|
||||
oWriter.AddSInt(-25000);
|
||||
else if (m_eVertAlignType == eVertAlignType::vatSuperscript)
|
||||
oWriter.AddSInt(30000);
|
||||
else
|
||||
oWriter.AddInt(0);
|
||||
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
|
||||
// WriteTextFontTypeface
|
||||
auto WriteTextFontTypeface = [this, &oWriter] (const std::wstring& wsTypeface) {
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(3); oWriter.WriteStringUtf16(wsTypeface);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
};
|
||||
|
||||
// WriteRecord WriteTextFontTypeface
|
||||
oWriter.StartRecord(3); WriteTextFontTypeface(m_pFontStyle->wsFontName); oWriter.EndRecord();
|
||||
oWriter.StartRecord(4); WriteTextFontTypeface(m_pFontStyle->wsFontName); oWriter.EndRecord();
|
||||
oWriter.StartRecord(5); WriteTextFontTypeface(m_pFontStyle->wsFontName); oWriter.EndRecord();
|
||||
|
||||
// WriteUniColor
|
||||
auto WriteUniColor = [&oWriter] (long color, long alpha) {
|
||||
BYTE r = reinterpret_cast<BYTE*>(&color)[0];
|
||||
BYTE g = reinterpret_cast<BYTE*>(&color)[1];
|
||||
BYTE b = reinterpret_cast<BYTE*>(&color)[2];
|
||||
|
||||
oWriter.StartRecord(1); // COLOR_TYPE_SRGB
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(0); oWriter.WriteBYTE(r);
|
||||
oWriter.WriteBYTE(1); oWriter.WriteBYTE(g);
|
||||
oWriter.WriteBYTE(2); oWriter.WriteBYTE(b);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
// WriteMods (alpha)
|
||||
oWriter.StartRecord(0);
|
||||
oWriter.AddInt(1);
|
||||
oWriter.StartRecord(1);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(0); oWriter.WriteStringUtf16(L"alpha");
|
||||
oWriter.WriteBYTE(1); oWriter.AddInt(alpha * 100000 / 255);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
oWriter.EndRecord();
|
||||
oWriter.EndRecord();
|
||||
};
|
||||
|
||||
auto WriteUniFill = [&oWriter, this, &WriteUniColor] () {
|
||||
oWriter.StartRecord(3); // FILL_TYPE_SOLID
|
||||
oWriter.StartRecord(0);
|
||||
WriteUniColor(m_pFontStyle->oBrush.Color1, m_pFontStyle->oBrush.Alpha1);
|
||||
oWriter.EndRecord();
|
||||
oWriter.EndRecord();
|
||||
};
|
||||
|
||||
// WriteRecord WriteUniFill
|
||||
oWriter.StartRecord(1);
|
||||
WriteUniFill();
|
||||
oWriter.EndRecord();
|
||||
|
||||
// WriteRecord WriteHighlightColor
|
||||
if (m_bIsHighlightPresent)
|
||||
{
|
||||
oWriter.StartRecord(12);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.StartRecord(0);
|
||||
WriteUniColor(m_lHighlightColor, 255);
|
||||
oWriter.EndRecord();
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
oWriter.EndRecord();
|
||||
}();
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
|
||||
bool CContText::IsEqual(const CContText *pCont) const noexcept
|
||||
{
|
||||
@ -510,7 +621,7 @@ namespace NSDocxRenderer
|
||||
bool bIf15 = m_eVertAlignType == eVertAlignType::vatBase && pCont->m_eVertAlignType == eVertAlignType::vatUnknown;
|
||||
|
||||
return (bIf1 && bIf2 && bIf3 && bIf4 && bIf5 && bIf6 && bIf7 &&
|
||||
bIf8 && bIf9 && bIf10 && bIf11 && bIf12 && (bIf13 || bIf14 || bIf15));
|
||||
bIf8 && bIf9 && bIf10 && bIf11 && bIf12 && (bIf13 || bIf14 || bIf15));
|
||||
}
|
||||
|
||||
UINT CContText::GetNumberOfFeatures() const noexcept
|
||||
@ -529,10 +640,11 @@ namespace NSDocxRenderer
|
||||
bool CContText::IsDuplicate(CContText* pCont, eVerticalCrossingType eVType, eHorizontalCrossingType eHType) const noexcept
|
||||
{
|
||||
return m_oText == pCont->m_oText &&
|
||||
eVType == eVerticalCrossingType::vctDublicate &&
|
||||
(eHType == eHorizontalCrossingType::hctDublicate ||
|
||||
eHType == eHorizontalCrossingType::hctCurrentLeftOfNext ||
|
||||
eHType == eHorizontalCrossingType::hctCurrentRightOfNext);
|
||||
eVType == eVerticalCrossingType::vctDublicate &&
|
||||
(eHType == eHorizontalCrossingType::hctDublicate ||
|
||||
eHType == eHorizontalCrossingType::hctCurrentLeftOfNext ||
|
||||
eHType == eHorizontalCrossingType::hctCurrentRightOfNext ||
|
||||
eHType == eHorizontalCrossingType::hctLeftAndRightBordersMatch);
|
||||
}
|
||||
|
||||
bool CContText::IsOnlySpaces() const
|
||||
@ -555,7 +667,7 @@ namespace NSDocxRenderer
|
||||
void CContText::AddTextBack(const NSStringUtils::CStringUTF32& oText, const std::vector<double>& arSymWidths)
|
||||
{
|
||||
bool is_space_twice = m_oText.at(m_oText.length() - 1) == c_SPACE_SYM &&
|
||||
oText.at(0) == c_SPACE_SYM;
|
||||
oText.at(0) == c_SPACE_SYM;
|
||||
|
||||
for (size_t i = 0; i < arSymWidths.size(); ++i)
|
||||
{
|
||||
@ -660,10 +772,10 @@ namespace NSDocxRenderer
|
||||
}
|
||||
|
||||
bool CContText::CheckFontEffects
|
||||
(std::shared_ptr<CContText>& pFirstCont,
|
||||
std::shared_ptr<CContText>& pSecondCont,
|
||||
eVerticalCrossingType eVType,
|
||||
eHorizontalCrossingType eHType)
|
||||
(std::shared_ptr<CContText>& pFirstCont,
|
||||
std::shared_ptr<CContText>& pSecondCont,
|
||||
eVerticalCrossingType eVType,
|
||||
eHorizontalCrossingType eHType)
|
||||
{
|
||||
//Условие пересечения по вертикали
|
||||
bool bIf1 = eVType == eVerticalCrossingType::vctCurrentAboveNext; //текущий cont выше
|
||||
@ -743,28 +855,28 @@ namespace NSDocxRenderer
|
||||
}
|
||||
|
||||
bool CContText::CheckVertAlignTypeBetweenConts
|
||||
(std::shared_ptr<CContText> pFirstCont,
|
||||
std::shared_ptr<CContText> pSecondCont,
|
||||
eVerticalCrossingType eVType,
|
||||
eHorizontalCrossingType eHType)
|
||||
(std::shared_ptr<CContText> pFirstCont,
|
||||
std::shared_ptr<CContText> pSecondCont,
|
||||
eVerticalCrossingType eVType,
|
||||
eHorizontalCrossingType eHType)
|
||||
{
|
||||
|
||||
bool bIf1 = eVType == eVerticalCrossingType::vctCurrentAboveNext ||
|
||||
eVType == eVerticalCrossingType::vctCurrentInsideNext;
|
||||
eVType == eVerticalCrossingType::vctCurrentInsideNext;
|
||||
|
||||
bool bIf2 = eVType == eVerticalCrossingType::vctCurrentBelowNext;
|
||||
|
||||
bool bIf3 = (eHType == eHorizontalCrossingType::hctNoCrossingCurrentLeftOfNext ||
|
||||
eHType == eHorizontalCrossingType::hctCurrentLeftOfNext) &&
|
||||
fabs(pFirstCont->m_dRight - pSecondCont->m_dLeft) < c_dTHE_STRING_X_PRECISION_MM * 3;
|
||||
eHType == eHorizontalCrossingType::hctCurrentLeftOfNext) &&
|
||||
fabs(pFirstCont->m_dRight - pSecondCont->m_dLeft) < c_dTHE_STRING_X_PRECISION_MM * 3;
|
||||
|
||||
bool bIf4 = (eHType == eHorizontalCrossingType::hctNoCrossingCurrentRightOfNext ||
|
||||
eHType == eHorizontalCrossingType::hctCurrentRightOfNext) &&
|
||||
fabs(pFirstCont->m_dLeft - pSecondCont->m_dRight) < c_dTHE_STRING_X_PRECISION_MM * 3;
|
||||
eHType == eHorizontalCrossingType::hctCurrentRightOfNext) &&
|
||||
fabs(pFirstCont->m_dLeft - pSecondCont->m_dRight) < c_dTHE_STRING_X_PRECISION_MM * 3;
|
||||
|
||||
//Размеры шрифта должны бать разными
|
||||
bool bIf5 = pFirstCont->m_pFontStyle->dFontSize * 0.7 > pSecondCont->m_pFontStyle->dFontSize;
|
||||
bool bIf6 = pFirstCont->m_pFontStyle->dFontSize < pSecondCont->m_pFontStyle->dFontSize * 0.7;
|
||||
bool bIf5 = pFirstCont->m_pFontStyle->dFontSize * 0.8 > pSecondCont->m_pFontStyle->dFontSize;
|
||||
bool bIf6 = pFirstCont->m_pFontStyle->dFontSize < pSecondCont->m_pFontStyle->dFontSize * 0.8;
|
||||
|
||||
if (bIf3 || bIf4)
|
||||
{
|
||||
@ -774,7 +886,7 @@ namespace NSDocxRenderer
|
||||
pSecondCont->m_pCont = pFirstCont;
|
||||
pFirstCont->m_eVertAlignType = eVertAlignType::vatBase;
|
||||
pFirstCont->m_pCont = pSecondCont;
|
||||
pFirstCont->m_bPossibleSplit = false;
|
||||
pFirstCont->m_bPossibleHorSplit = false;
|
||||
return true;
|
||||
}
|
||||
else if (bIf2 && bIf5)
|
||||
@ -783,7 +895,7 @@ namespace NSDocxRenderer
|
||||
pSecondCont->m_pCont = pFirstCont;
|
||||
pFirstCont->m_eVertAlignType = eVertAlignType::vatBase;
|
||||
pFirstCont->m_pCont = pSecondCont;
|
||||
pFirstCont->m_bPossibleSplit = false;
|
||||
pFirstCont->m_bPossibleHorSplit = false;
|
||||
return true;
|
||||
}
|
||||
else if (bIf1 && bIf6)
|
||||
@ -792,7 +904,7 @@ namespace NSDocxRenderer
|
||||
pFirstCont->m_pCont = pSecondCont;
|
||||
pSecondCont->m_eVertAlignType = eVertAlignType::vatBase;
|
||||
pSecondCont->m_pCont = pFirstCont;
|
||||
pSecondCont->m_bPossibleSplit = false;
|
||||
pSecondCont->m_bPossibleHorSplit = false;
|
||||
return true;
|
||||
}
|
||||
else if (bIf2 && bIf6)
|
||||
@ -801,7 +913,7 @@ namespace NSDocxRenderer
|
||||
pFirstCont->m_pCont = pSecondCont;
|
||||
pSecondCont->m_eVertAlignType = eVertAlignType::vatBase;
|
||||
pSecondCont->m_pCont = pFirstCont;
|
||||
pSecondCont->m_bPossibleSplit = false;
|
||||
pSecondCont->m_bPossibleHorSplit = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -824,15 +936,15 @@ namespace NSDocxRenderer
|
||||
{
|
||||
// more symbols of delims
|
||||
bool is_bullet =
|
||||
(cSym == 0x2022) || (cSym == 0x2023) || (cSym == 0x2043) || (cSym == 0x204C) ||
|
||||
(cSym == 0x204D) || (cSym == 0x2219) || (cSym == 0x25CB) || (cSym == 0x25CF) ||
|
||||
(cSym == 0x25D8) || (cSym == 0x25E6) || (cSym == 0x2619) || (cSym == 0x2765) ||
|
||||
(cSym == 0x2767) || (cSym == 0x29BE) || (cSym == 0x29BF) || (cSym == 0x25C9);
|
||||
(cSym == 0x2022) || (cSym == 0x2023) || (cSym == 0x2043) || (cSym == 0x204C) ||
|
||||
(cSym == 0x204D) || (cSym == 0x2219) || (cSym == 0x25CB) || (cSym == 0x25CF) ||
|
||||
(cSym == 0x25D8) || (cSym == 0x25E6) || (cSym == 0x2619) || (cSym == 0x2765) ||
|
||||
(cSym == 0x2767) || (cSym == 0x29BE) || (cSym == 0x29BF) || (cSym == 0x25C9);
|
||||
|
||||
bool is_another =
|
||||
(cSym == 0xB7) || (cSym == 0xA7) || (cSym == 0xF076) || (cSym == 0x2013) ||
|
||||
(cSym == 0x2713) || (cSym == 0x2714) || (cSym == 0x2756) || (cSym == 0x25C6) ||
|
||||
(cSym == 0x25C7) || (cSym == 0x25C8);
|
||||
(cSym == 0xB7) || (cSym == 0xA7) || (cSym == 0xF076) || (cSym == 0x2013) ||
|
||||
(cSym == 0x2713) || (cSym == 0x2714) || (cSym == 0x2756) || (cSym == 0x25C6) ||
|
||||
(cSym == 0x25C7) || (cSym == 0x25C8);
|
||||
|
||||
return is_bullet || is_another;
|
||||
}
|
||||
@ -852,9 +964,9 @@ namespace NSDocxRenderer
|
||||
bool CContText::IsUnicodeSymbol(uint32_t cSym )
|
||||
{
|
||||
bool is_unicode =
|
||||
(( 0x0009 == cSym) || (0x000A == cSym ) || (0x000D == cSym ) ||
|
||||
(( 0x0020 <= cSym) && (0xD7FF >= cSym )) || ((0xE000 <= cSym) && (cSym <= 0xFFFD )) ||
|
||||
(( 0x10000 <= cSym) && cSym));
|
||||
(( 0x0009 == cSym) || (0x000A == cSym ) || (0x000D == cSym ) ||
|
||||
(( 0x0020 <= cSym) && (0xD7FF >= cSym )) || ((0xE000 <= cSym) && (cSym <= 0xFFFD )) ||
|
||||
(( 0x10000 <= cSym) && cSym));
|
||||
|
||||
return is_unicode;
|
||||
}
|
||||
@ -869,35 +981,42 @@ namespace NSDocxRenderer
|
||||
}
|
||||
|
||||
CContTextBuilder::CContTextBuilder(CFontStyleManager* pFontStyleManager, CFontSelector* pFontSelector) :
|
||||
m_pFontStyleManager(pFontStyleManager), m_pFontSelector(pFontSelector)
|
||||
m_pFontStyleManager(pFontStyleManager), m_pFontSelector(pFontSelector)
|
||||
{}
|
||||
|
||||
std::vector<CContTextBuilder::cont_ptr_t> CContTextBuilder::GetConts()
|
||||
{
|
||||
return std::move(m_arConts);
|
||||
m_pCurrCont = nullptr;
|
||||
}
|
||||
std::vector<CContTextBuilder::cont_ptr_t> CContTextBuilder::GetDiacs()
|
||||
{
|
||||
return std::move(m_arDiacs);
|
||||
m_pCurrCont = nullptr;
|
||||
}
|
||||
|
||||
void CContTextBuilder::AddUnicode(
|
||||
double dTop,
|
||||
double dBot,
|
||||
double dLeft,
|
||||
double dRight,
|
||||
const NSStructures::CFont& oFont,
|
||||
const NSStructures::CBrush& oBrush,
|
||||
CFontManager* pFontManager,
|
||||
const NSStringUtils::CStringUTF32& oText,
|
||||
bool bForcedBold,
|
||||
bool bUseDefaultFont,
|
||||
bool bWriteStyleRaw)
|
||||
double dTop,
|
||||
double dBot,
|
||||
double dLeft,
|
||||
double dRight,
|
||||
const NSStructures::CFont& oFont,
|
||||
const NSStructures::CBrush& oBrush,
|
||||
CFontManager* pFontManager,
|
||||
const NSStringUtils::CStringUTF32& oText,
|
||||
bool bForcedBold,
|
||||
bool bUseDefaultFont,
|
||||
bool bWriteStyleRaw)
|
||||
{
|
||||
double dWidth = dRight - dLeft;
|
||||
double dHeight = dBot - dTop;
|
||||
|
||||
// if new text is close to current cont
|
||||
if (m_pCurrCont != nullptr &&
|
||||
fabs(m_pCurrCont->m_dBaselinePos - dBot) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
|
||||
m_oPrevFont.IsEqual2(&oFont) &&
|
||||
m_oPrevBrush.IsEqual(&oBrush))
|
||||
fabs(m_pCurrCont->m_dBot - dBot) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
|
||||
m_oPrevFont.IsEqual2(&oFont) &&
|
||||
m_oPrevBrush.IsEqual(&oBrush) && !(
|
||||
oText.length() == 1 && CContText::IsUnicodeDiacriticalMark(oText.at(0))))
|
||||
{
|
||||
|
||||
double avg_width = dWidth / oText.length();
|
||||
@ -907,9 +1026,9 @@ namespace NSDocxRenderer
|
||||
|
||||
double avg_space_width = m_pCurrCont->m_pFontStyle->GetAvgSpaceWidth();
|
||||
double space_width =
|
||||
avg_space_width != 0.0 ?
|
||||
avg_space_width * c_dAVERAGE_SPACE_WIDTH_COEF :
|
||||
m_pCurrCont->CalculateSpace() * c_dSPACE_WIDTH_COEF;
|
||||
avg_space_width != 0.0 ?
|
||||
avg_space_width * c_dAVERAGE_SPACE_WIDTH_COEF :
|
||||
m_pCurrCont->CalculateSpace() * c_dSPACE_WIDTH_COEF;
|
||||
|
||||
bool is_added = false;
|
||||
|
||||
@ -940,8 +1059,8 @@ namespace NSDocxRenderer
|
||||
if (is_added)
|
||||
{
|
||||
m_pCurrCont->m_dTop = std::min(m_pCurrCont->m_dTop, dTop);
|
||||
m_pCurrCont->m_dBaselinePos = std::max(m_pCurrCont->m_dBaselinePos, dBot);
|
||||
m_pCurrCont->m_dHeight = m_pCurrCont->m_dBaselinePos - m_pCurrCont->m_dTop;
|
||||
m_pCurrCont->m_dBot = std::max(m_pCurrCont->m_dBot, dBot);
|
||||
m_pCurrCont->m_dHeight = m_pCurrCont->m_dBot - m_pCurrCont->m_dTop;
|
||||
m_pCurrCont->m_dWidth = m_pCurrCont->m_dRight - m_pCurrCont->m_dLeft;
|
||||
return;
|
||||
}
|
||||
@ -952,19 +1071,19 @@ namespace NSDocxRenderer
|
||||
const auto& oMetrics = pFontManager->GetFontMetrics();
|
||||
m_pFontSelector->SelectFont(oParams, oMetrics, oText);
|
||||
|
||||
pCont->m_dBaselinePos = dBot;
|
||||
pCont->m_dTop = dTop;
|
||||
pCont->m_dHeight = dHeight;
|
||||
pCont->m_dLeft = dLeft;
|
||||
pCont->m_dBot = dBot;
|
||||
pCont->m_dTop = dTop;
|
||||
pCont->m_dHeight = dHeight;
|
||||
pCont->m_dLeft = dLeft;
|
||||
|
||||
// первичное получение стиля для текущего символа
|
||||
// при дальнейшем анализе может измениться
|
||||
pCont->m_pFontStyle = m_pFontStyleManager->GetOrAddFontStyle(
|
||||
oBrush,
|
||||
m_pFontSelector->GetSelectedName(),
|
||||
oFont.Size,
|
||||
m_pFontSelector->IsSelectedItalic(),
|
||||
m_pFontSelector->IsSelectedBold() || bForcedBold);
|
||||
oBrush,
|
||||
m_pFontSelector->GetSelectedName(),
|
||||
oFont.Size,
|
||||
m_pFontSelector->IsSelectedItalic(),
|
||||
m_pFontSelector->IsSelectedBold() || bForcedBold);
|
||||
|
||||
// just in case if oText contains more than 1 symbol
|
||||
std::vector<double> ar_widths;
|
||||
@ -985,8 +1104,8 @@ namespace NSDocxRenderer
|
||||
double em_height = oMetrics.dEmHeight;
|
||||
double ratio = font_size / em_height * c_dPtToMM;
|
||||
|
||||
pCont->m_dTopWithAscent = pCont->m_dBaselinePos - (oMetrics.dAscent * ratio) - oMetrics.dBaselineOffset;
|
||||
pCont->m_dBotWithDescent = pCont->m_dBaselinePos + (oMetrics.dDescent * ratio) - oMetrics.dBaselineOffset;
|
||||
pCont->m_dTopWithAscent = pCont->m_dBot - (oMetrics.dAscent * ratio) - oMetrics.dBaselineOffset;
|
||||
pCont->m_dBotWithDescent = pCont->m_dBot + (oMetrics.dDescent * ratio) - oMetrics.dBaselineOffset;
|
||||
pCont->m_dSpaceWidthMM = pFontManager->GetSpaceWidthMM();
|
||||
pCont->m_wsOriginFontName = oFont.Name;
|
||||
|
||||
@ -1005,10 +1124,31 @@ namespace NSDocxRenderer
|
||||
pCont->m_oSelectedFont.Italic = m_pFontSelector->IsSelectedItalic();
|
||||
}
|
||||
pCont->m_bWriteStyleRaw = bWriteStyleRaw;
|
||||
m_arConts.push_back(pCont);
|
||||
|
||||
if (pCont->IsDiacritical())
|
||||
{
|
||||
m_arDiacs.push_back(std::move(pCont));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_arConts.push_back(pCont);
|
||||
}
|
||||
|
||||
m_pCurrCont = pCont;
|
||||
m_oPrevFont = oFont;
|
||||
m_oPrevBrush = oBrush;
|
||||
}
|
||||
|
||||
void CContTextBuilder::NullCurrCont()
|
||||
{
|
||||
m_pCurrCont = nullptr;
|
||||
}
|
||||
void CContTextBuilder::Clear()
|
||||
{
|
||||
m_pCurrCont = nullptr;
|
||||
m_arConts.clear();
|
||||
m_arDiacs.clear();
|
||||
m_oPrevFont.SetDefaultParams();
|
||||
m_oPrevBrush.SetDefaultParams();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,16 +2,15 @@
|
||||
#include "../../../../DesktopEditor/common/StringBuilder.h"
|
||||
|
||||
#include "BaseItem.h"
|
||||
#include "Shape.h"
|
||||
#include "../managers/FontManager.h"
|
||||
#include "../managers//FontStyleManager.h"
|
||||
#include "../managers/FontStyleManager.h"
|
||||
#include "../styles/FontStyle.h"
|
||||
#include "../../resources/Constants.h"
|
||||
#include "../../resources/LinesTable.h"
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
class CShape;
|
||||
|
||||
enum class eVertAlignType
|
||||
{
|
||||
vatUnknown,
|
||||
@ -32,7 +31,7 @@ namespace NSDocxRenderer
|
||||
CSelectedSizes& operator=(const CSelectedSizes& oSelectedSizes);
|
||||
};
|
||||
|
||||
class CContText : public CBaseItem
|
||||
class CContText : public CBaseItem, public IOoxmlItem
|
||||
{
|
||||
public:
|
||||
// utils
|
||||
@ -76,16 +75,17 @@ namespace NSDocxRenderer
|
||||
|
||||
bool m_bIsAddBrEnd{false};
|
||||
bool m_bWriteStyleRaw{false};
|
||||
bool m_bPossibleSplit{false};
|
||||
bool m_bPossibleHorSplit{false};
|
||||
|
||||
CContText() = default;
|
||||
CContText(CFontManager* pManager) : m_pManager(pManager) {}
|
||||
CContText(const CContText& rCont);
|
||||
virtual ~CContText();
|
||||
|
||||
virtual void Clear() override final;
|
||||
virtual void Clear();
|
||||
virtual void ToXml(NSStringUtils::CStringBuilder& oWriter) const override final;
|
||||
virtual void ToXmlPptx(NSStringUtils::CStringBuilder& oWriter) const override final;
|
||||
virtual void ToBin(NSWasm::CData& oWriter) const override final;
|
||||
virtual eVerticalCrossingType GetVerticalCrossingType(const CContText* pItem) const noexcept;
|
||||
|
||||
// calc sizes in selected font (uses m_oSelectedFont & m_pManager)
|
||||
@ -123,16 +123,16 @@ namespace NSDocxRenderer
|
||||
// check font effect and delete not needed cont
|
||||
// return true if was deleted
|
||||
static bool CheckFontEffects
|
||||
(std::shared_ptr<CContText>& pFirstCont,
|
||||
std::shared_ptr<CContText>& pSecondCont,
|
||||
eVerticalCrossingType eVType,
|
||||
eHorizontalCrossingType eHType);
|
||||
(std::shared_ptr<CContText>& pFirstCont,
|
||||
std::shared_ptr<CContText>& pSecondCont,
|
||||
eVerticalCrossingType eVType,
|
||||
eHorizontalCrossingType eHType);
|
||||
|
||||
static bool CheckVertAlignTypeBetweenConts
|
||||
(std::shared_ptr<CContText> pFirstCont,
|
||||
std::shared_ptr<CContText> pSecondCont,
|
||||
eVerticalCrossingType eVType,
|
||||
eHorizontalCrossingType eHType);
|
||||
(std::shared_ptr<CContText> pFirstCont,
|
||||
std::shared_ptr<CContText> pSecondCont,
|
||||
eVerticalCrossingType eVType,
|
||||
eHorizontalCrossingType eHType);
|
||||
|
||||
static bool IsUnicodeRtl(uint32_t cSym);
|
||||
static bool IsUnicodeBullet(uint32_t cSym);
|
||||
@ -157,24 +157,34 @@ namespace NSDocxRenderer
|
||||
CContTextBuilder(CFontStyleManager* pFontStyleManager, CFontSelector* pFontSelector);
|
||||
~CContTextBuilder() = default;
|
||||
|
||||
// after call CContTextBuilder is empty
|
||||
// after call CContTextBuilder conts is empty
|
||||
std::vector<cont_ptr_t> GetConts();
|
||||
|
||||
// after call CContTextBuilder diacs is empty
|
||||
std::vector<cont_ptr_t> GetDiacs();
|
||||
|
||||
void AddUnicode(
|
||||
double dTop,
|
||||
double dBot,
|
||||
double dLeft,
|
||||
double dRight,
|
||||
const NSStructures::CFont& oFont,
|
||||
const NSStructures::CBrush& oBrush,
|
||||
CFontManager* pFontManager,
|
||||
const NSStringUtils::CStringUTF32& oText,
|
||||
bool bForcedBold = false,
|
||||
bool bUseDefaultFont = false,
|
||||
bool bWriteStyleRaw = false);
|
||||
double dTop,
|
||||
double dBot,
|
||||
double dLeft,
|
||||
double dRight,
|
||||
const NSStructures::CFont& oFont,
|
||||
const NSStructures::CBrush& oBrush,
|
||||
CFontManager* pFontManager,
|
||||
const NSStringUtils::CStringUTF32& oText,
|
||||
bool bForcedBold = false,
|
||||
bool bUseDefaultFont = false,
|
||||
bool bWriteStyleRaw = false);
|
||||
|
||||
void NullCurrCont();
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
std::vector<cont_ptr_t> m_arConts;
|
||||
std::vector<cont_ptr_t> m_arDiacs;
|
||||
|
||||
cont_ptr_t m_pCurrCont {nullptr};
|
||||
|
||||
NSStructures::CFont m_oPrevFont;
|
||||
NSStructures::CBrush m_oPrevBrush;
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ namespace NSDocxRenderer
|
||||
|
||||
void CParagraph::Clear()
|
||||
{
|
||||
m_arLines.clear();
|
||||
m_arTextLines.clear();
|
||||
}
|
||||
|
||||
void CParagraph::ToXml(NSStringUtils::CStringBuilder& oWriter) const
|
||||
@ -20,7 +20,7 @@ namespace NSDocxRenderer
|
||||
oWriter.WriteString(L"<w:pPr>");
|
||||
|
||||
// styles
|
||||
if(!m_wsStyleId.empty()) oWriter.WriteString(L"<w:pStyle w:val=\"" + m_wsStyleId + L"\"/>");
|
||||
if (!m_wsStyleId.empty()) oWriter.WriteString(L"<w:pStyle w:val=\"" + m_wsStyleId + L"\"/>");
|
||||
|
||||
oWriter.WriteString(L"<w:spacing");
|
||||
|
||||
@ -105,7 +105,7 @@ namespace NSDocxRenderer
|
||||
}
|
||||
|
||||
oWriter.WriteString(L"</w:pPr>");
|
||||
for(const auto& line : m_arLines)
|
||||
for(const auto& line : m_arTextLines)
|
||||
if(line)
|
||||
line->ToXml(oWriter);
|
||||
oWriter.WriteString(L"</w:p>");
|
||||
@ -135,14 +135,28 @@ namespace NSDocxRenderer
|
||||
break;
|
||||
}
|
||||
|
||||
oWriter.WriteString(L"\"");
|
||||
oWriter.WriteString(L"\" ");
|
||||
|
||||
if (m_bIsNeedFirstLineIndent)
|
||||
{
|
||||
oWriter.WriteString(L" indent=\"");
|
||||
oWriter.WriteString(L" indent=\" ");
|
||||
oWriter.AddInt(static_cast<int>(m_dFirstLine * c_dMMToEMU));
|
||||
oWriter.WriteString(L"\"");
|
||||
}
|
||||
|
||||
if (m_dLeftBorder > 0)
|
||||
{
|
||||
oWriter.WriteString(L" marL=\" ");
|
||||
oWriter.AddInt(static_cast<int>(m_dLeftBorder * c_dMMToEMU));
|
||||
oWriter.WriteString(L"\"");
|
||||
}
|
||||
if (m_dRightBorder > 0)
|
||||
{
|
||||
oWriter.WriteString(L" marR=\"");
|
||||
oWriter.AddInt(static_cast<int>(m_dRightBorder * c_dMMToEMU));
|
||||
oWriter.WriteString(L"\"");
|
||||
}
|
||||
|
||||
oWriter.WriteString(L">");
|
||||
|
||||
oWriter.WriteString(L"<a:spcBef>");
|
||||
@ -151,10 +165,9 @@ namespace NSDocxRenderer
|
||||
oWriter.WriteString(L"\"/>");
|
||||
oWriter.WriteString(L"</a:spcBef>");
|
||||
|
||||
|
||||
oWriter.WriteString(L"<a:spcAft>");
|
||||
oWriter.WriteString(L"<a:spcPts val=\"");
|
||||
oWriter.AddInt(static_cast<int>(m_dSpaceBefore * c_dMMToPt * 100));
|
||||
oWriter.AddInt(static_cast<int>(m_dSpaceAfter * c_dMMToPt * 100));
|
||||
oWriter.WriteString(L"\"/>");
|
||||
oWriter.WriteString(L"</a:spcAft>");
|
||||
|
||||
@ -165,20 +178,113 @@ namespace NSDocxRenderer
|
||||
oWriter.WriteString(L"</a:lnSpc>");
|
||||
|
||||
oWriter.WriteString(L"</a:pPr>");
|
||||
for(const auto& line : m_arLines)
|
||||
for(const auto& line : m_arTextLines)
|
||||
if(line)
|
||||
line->ToXmlPptx(oWriter);
|
||||
oWriter.WriteString(L"</a:p>");
|
||||
}
|
||||
void CParagraph::ToBin(NSWasm::CData& oWriter) const
|
||||
{
|
||||
// WriteRecord WriteTextParagraphPr
|
||||
[this, &oWriter] () {
|
||||
oWriter.StartRecord(0);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(0);
|
||||
switch (m_eTextAlignmentType)
|
||||
{
|
||||
case tatByCenter:
|
||||
oWriter.WriteBYTE(0);
|
||||
break;
|
||||
case tatByRight:
|
||||
oWriter.WriteBYTE(5);
|
||||
break;
|
||||
case tatByWidth:
|
||||
oWriter.WriteBYTE(2);
|
||||
break;
|
||||
case tatByLeft: // fallthrough
|
||||
case tatUnknown: // fallthrough
|
||||
default:
|
||||
oWriter.WriteBYTE(4);
|
||||
break;
|
||||
}
|
||||
|
||||
// marL
|
||||
if (m_dLeftBorder > 0)
|
||||
{
|
||||
oWriter.WriteBYTE(8);
|
||||
oWriter.AddSInt(static_cast<int>(m_dLeftBorder * c_dMMToEMU));
|
||||
}
|
||||
|
||||
// marR
|
||||
if (m_dRightBorder > 0)
|
||||
{
|
||||
oWriter.WriteBYTE(9);
|
||||
oWriter.AddSInt(static_cast<int>(m_dRightBorder * c_dMMToEMU));
|
||||
}
|
||||
|
||||
// indent
|
||||
if (m_bIsNeedFirstLineIndent)
|
||||
{
|
||||
oWriter.WriteBYTE(5);
|
||||
oWriter.AddSInt(static_cast<int>(m_dFirstLine * c_dMMToEMU));
|
||||
}
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
|
||||
const int max_value = 158400;
|
||||
|
||||
// line spacing
|
||||
oWriter.StartRecord(0);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
int height_value = static_cast<int>(m_dLineHeight * c_dMMToPt * 100);
|
||||
if (fabs(height_value) > max_value)
|
||||
height_value > 0 ? height_value = max_value : height_value = -max_value;
|
||||
oWriter.WriteBYTE(1); oWriter.AddSInt(static_cast<int>(height_value));
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
|
||||
// space after
|
||||
oWriter.StartRecord(1);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
int after_value = static_cast<int>(m_dSpaceAfter * c_dMMToPt * 100);
|
||||
if (fabs(after_value) > max_value)
|
||||
after_value > 0 ? after_value = max_value : after_value = -max_value;
|
||||
oWriter.WriteBYTE(1); oWriter.AddSInt(static_cast<int>(after_value));
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
|
||||
// space before
|
||||
oWriter.StartRecord(2);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
int before_value = static_cast<int>(m_dSpaceBefore * c_dMMToPt * 100);
|
||||
if (fabs(before_value) > max_value)
|
||||
before_value > 0 ? before_value = max_value : before_value = -max_value;
|
||||
oWriter.WriteBYTE(1); oWriter.AddSInt(static_cast<int>(before_value));
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
|
||||
oWriter.EndRecord();
|
||||
}();
|
||||
|
||||
oWriter.StartRecord(2);
|
||||
unsigned int count = 0;
|
||||
for (const auto& text_line : m_arTextLines)
|
||||
count += text_line->m_arConts.size();
|
||||
|
||||
oWriter.AddInt(count);
|
||||
for (const auto& text_line : m_arTextLines)
|
||||
text_line->ToBin(oWriter);
|
||||
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
|
||||
void CParagraph::RemoveHighlightColor()
|
||||
{
|
||||
if (!m_bIsShadingPresent)
|
||||
return;
|
||||
|
||||
for(size_t i = 0; i < m_arLines.size(); ++i)
|
||||
for(size_t i = 0; i < m_arTextLines.size(); ++i)
|
||||
{
|
||||
auto& pLine = m_arLines[i];
|
||||
auto& pLine = m_arTextLines[i];
|
||||
if (pLine || pLine->m_pDominantShape)
|
||||
{
|
||||
for (size_t j = 0; j < pLine->m_arConts.size(); ++j)
|
||||
@ -194,9 +300,9 @@ namespace NSDocxRenderer
|
||||
|
||||
void CParagraph::MergeLines()
|
||||
{
|
||||
for(size_t i = 0; i < m_arLines.size() - 1; ++i)
|
||||
for(size_t i = 0; i < m_arTextLines.size() - 1; ++i)
|
||||
{
|
||||
auto pLine = m_arLines[i];
|
||||
auto pLine = m_arTextLines[i];
|
||||
auto pLastCont = pLine->m_arConts.back();
|
||||
size_t iNumConts = pLine->m_arConts.size() - 1;
|
||||
|
||||
@ -206,7 +312,7 @@ namespace NSDocxRenderer
|
||||
auto text = pLastCont->GetText();
|
||||
auto last_sym = text[text.length() - 1];
|
||||
|
||||
if (last_sym != c_SPACE_SYM && m_arLines.size() != 1)
|
||||
if (last_sym != c_SPACE_SYM && m_arTextLines.size() != 1)
|
||||
pLastCont->AddSymBack(c_SPACE_SYM, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
class CParagraph : public CBaseItem
|
||||
class CParagraph : public CBaseItem, public IOoxmlItem
|
||||
{
|
||||
public:
|
||||
enum TextAlignmentType
|
||||
@ -31,15 +31,16 @@ namespace NSDocxRenderer
|
||||
double m_dSpaceAfter {0.0}; // в shape по умолчанию выставляется 8pt, если отсутсвует w:after
|
||||
double m_dLineHeight {0.0};
|
||||
|
||||
std::vector<std::shared_ptr<CTextLine>> m_arLines;
|
||||
std::vector<std::shared_ptr<CTextLine>> m_arTextLines;
|
||||
std::wstring m_wsStyleId;
|
||||
|
||||
public:
|
||||
CParagraph() : CBaseItem() {}
|
||||
virtual ~CParagraph();
|
||||
virtual void Clear() override final;
|
||||
virtual void Clear();
|
||||
virtual void ToXml(NSStringUtils::CStringBuilder& oWriter) const override final;
|
||||
virtual void ToXmlPptx(NSStringUtils::CStringBuilder& oWriter) const override final;
|
||||
virtual void ToBin(NSWasm::CData& oWriter) const override final;
|
||||
|
||||
void RemoveHighlightColor();
|
||||
void MergeLines();
|
||||
|
||||
@ -25,7 +25,7 @@ namespace NSDocxRenderer
|
||||
}
|
||||
|
||||
CShape::CShape(std::shared_ptr<CImageInfo> pInfo, const std::wstring& strDstMedia) :
|
||||
m_strDstMedia(strDstMedia), m_pImageInfo(pInfo)
|
||||
m_strDstMedia(strDstMedia), m_pImageInfo(pInfo)
|
||||
{
|
||||
m_nRelativeHeight = m_gRelativeHeight;
|
||||
m_gRelativeHeight += c_iStandartRelativeHeight;
|
||||
@ -94,7 +94,7 @@ namespace NSDocxRenderer
|
||||
if (m_dHeight < 0.0001)
|
||||
m_dHeight = 0.0001;
|
||||
|
||||
m_dBaselinePos = m_dTop + m_dHeight;
|
||||
m_dBot = m_dTop + m_dHeight;
|
||||
m_dRight = m_dLeft + m_dWidth;
|
||||
}
|
||||
|
||||
@ -110,40 +110,40 @@ namespace NSDocxRenderer
|
||||
double dHorNearby = 30;
|
||||
double dVerNearby = 30;
|
||||
|
||||
if(
|
||||
// только для фигур
|
||||
(pShape->m_eGraphicsType == eGraphicsType::gtComplicatedFigure ||
|
||||
pShape->m_eGraphicsType == eGraphicsType::gtRectangle) &&
|
||||
if (
|
||||
// только для фигур
|
||||
(pShape->m_eGraphicsType == eGraphicsType::gtComplicatedFigure ||
|
||||
pShape->m_eGraphicsType == eGraphicsType::gtRectangle) &&
|
||||
|
||||
(this->m_eGraphicsType == eGraphicsType::gtComplicatedFigure ||
|
||||
this->m_eGraphicsType == eGraphicsType::gtRectangle) &&
|
||||
(this->m_eGraphicsType == eGraphicsType::gtComplicatedFigure ||
|
||||
this->m_eGraphicsType == eGraphicsType::gtRectangle) &&
|
||||
|
||||
// все совпадает
|
||||
pShape->m_eType == this->m_eType &&
|
||||
pShape->m_oPen.IsEqual(&m_oPen) &&
|
||||
pShape->m_oBrush.IsEqual(&m_oBrush) &&
|
||||
pShape->m_bIsNoFill == m_bIsNoFill &&
|
||||
pShape->m_bIsNoStroke == m_bIsNoStroke &&
|
||||
// все совпадает
|
||||
pShape->m_eType == this->m_eType &&
|
||||
pShape->m_oPen.IsEqual(&m_oPen) &&
|
||||
pShape->m_oBrush.IsEqual(&m_oBrush) &&
|
||||
pShape->m_bIsNoFill == m_bIsNoFill &&
|
||||
pShape->m_bIsNoStroke == m_bIsNoStroke &&
|
||||
|
||||
// не картинка
|
||||
pShape->m_pImageInfo == nullptr &&
|
||||
this->m_pImageInfo == nullptr &&
|
||||
// не картинка
|
||||
pShape->m_pImageInfo == nullptr &&
|
||||
this->m_pImageInfo == nullptr &&
|
||||
|
||||
// недалеко друг от друга по горизонтали
|
||||
(fabs(pShape->m_dRight - this->m_dLeft) < dHorNearby ||
|
||||
fabs(pShape->m_dLeft - this->m_dRight) < dHorNearby ||
|
||||
// недалеко друг от друга по горизонтали
|
||||
(fabs(pShape->m_dRight - this->m_dLeft) < dHorNearby ||
|
||||
fabs(pShape->m_dLeft - this->m_dRight) < dHorNearby ||
|
||||
|
||||
// друг в друге тоже учитываем
|
||||
fabs(pShape->m_dRight - this->m_dRight) < dHorNearby ||
|
||||
fabs(pShape->m_dLeft - this->m_dLeft) < dHorNearby) &&
|
||||
// друг в друге тоже учитываем
|
||||
fabs(pShape->m_dRight - this->m_dRight) < dHorNearby ||
|
||||
fabs(pShape->m_dLeft - this->m_dLeft) < dHorNearby) &&
|
||||
|
||||
// недалеко друг от друга по вертикали
|
||||
(fabs(pShape->m_dBaselinePos - this->m_dTop) < dVerNearby ||
|
||||
fabs(pShape->m_dTop - this->m_dBaselinePos) < dVerNearby ||
|
||||
// недалеко друг от друга по вертикали
|
||||
(fabs(pShape->m_dBot - this->m_dTop) < dVerNearby ||
|
||||
fabs(pShape->m_dTop - this->m_dBot) < dVerNearby ||
|
||||
|
||||
// друг в друге
|
||||
fabs(pShape->m_dBaselinePos - this->m_dBaselinePos) < dVerNearby ||
|
||||
fabs(pShape->m_dTop - this->m_dTop) < dVerNearby))
|
||||
// друг в друге
|
||||
fabs(pShape->m_dBot - this->m_dBot) < dVerNearby ||
|
||||
fabs(pShape->m_dTop - this->m_dTop) < dVerNearby))
|
||||
{
|
||||
RecalcWithNewItem(pShape.get());
|
||||
m_oVector.Join(std::move(pShape->m_oVector));
|
||||
@ -327,7 +327,7 @@ namespace NSDocxRenderer
|
||||
return;
|
||||
|
||||
if (!pFirstShape->IsItFitLine() || !pSecondShape->IsItFitLine() || !pFirstShape->IsCorrelated(pSecondShape) ||
|
||||
fabs(pFirstShape->m_dHeight - pSecondShape->m_dHeight) > c_dGRAPHICS_ERROR_IN_LINES_MM)
|
||||
fabs(pFirstShape->m_dHeight - pSecondShape->m_dHeight) > c_dGRAPHICS_ERROR_IN_LINES_MM)
|
||||
{
|
||||
return; // линия должна быть одного размера по высоте
|
||||
}
|
||||
@ -360,8 +360,8 @@ namespace NSDocxRenderer
|
||||
}
|
||||
|
||||
else if (fabs(pFirstShape->m_dTop - pSecondShape->m_dTop) < c_dGRAPHICS_ERROR_IN_LINES_MM * 5 &&
|
||||
fabs(pFirstShape->m_dWidth - pSecondShape->m_dWidth) < c_dGRAPHICS_ERROR_IN_LINES_MM &&
|
||||
fabs(pFirstShape->m_dLeft - pSecondShape->m_dLeft) < c_dGRAPHICS_ERROR_IN_LINES_MM)
|
||||
fabs(pFirstShape->m_dWidth - pSecondShape->m_dWidth) < c_dGRAPHICS_ERROR_IN_LINES_MM &&
|
||||
fabs(pFirstShape->m_dLeft - pSecondShape->m_dLeft) < c_dGRAPHICS_ERROR_IN_LINES_MM)
|
||||
{
|
||||
// условие первого определения
|
||||
if (pFirstShape->m_eSimpleLineType == eSimpleLineType::sltHLongDash && pSecondShape->m_eSimpleLineType == eSimpleLineType::sltHLongDash)
|
||||
@ -450,14 +450,14 @@ namespace NSDocxRenderer
|
||||
if (pSecondShape->m_eSimpleLineType == eSimpleLineType::sltHDot)
|
||||
{
|
||||
if ((pFirstShape->m_eLineType == eLineType::ltUnknown || pFirstShape->m_eLineType == eLineType::ltDotted ||
|
||||
pFirstShape->m_eLineType == eLineType::ltDottedHeavy) && pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
pFirstShape->m_eLineType == eLineType::ltDottedHeavy) && pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
{
|
||||
pFirstShape->m_eLineType = pFirstShape->m_dHeight > 0.3 ? eLineType::ltDottedHeavy : eLineType::ltDotted;
|
||||
passed = true;
|
||||
}
|
||||
else if ((pFirstShape->m_eLineType == eLineType::ltDotDash || pFirstShape->m_eLineType == eLineType::ltDashDotHeavy ||
|
||||
pFirstShape->m_eLineType == eLineType::ltDotDotDash || pFirstShape->m_eLineType == eLineType::ltDashDotDotHeavy) &&
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
pFirstShape->m_eLineType == eLineType::ltDotDotDash || pFirstShape->m_eLineType == eLineType::ltDashDotDotHeavy) &&
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
{
|
||||
pFirstShape->m_eLineType = pFirstShape->m_dHeight > 0.3 ? eLineType::ltDashDotDotHeavy : eLineType::ltDotDotDash;
|
||||
pFirstShape->m_eSimpleLineType = eSimpleLineType::sltHDot;
|
||||
@ -467,13 +467,13 @@ namespace NSDocxRenderer
|
||||
else if (pSecondShape->m_eSimpleLineType == eSimpleLineType::sltHDash)
|
||||
{
|
||||
if ((pFirstShape->m_eLineType == eLineType::ltDotDash || pFirstShape->m_eLineType == eLineType::ltDashDotHeavy) &&
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
{
|
||||
pFirstShape->m_eSimpleLineType = eSimpleLineType::sltHDash;
|
||||
passed = true;
|
||||
}
|
||||
else if ((pFirstShape->m_eLineType == eLineType::ltDotDotDash || pFirstShape->m_eLineType == eLineType::ltDashDotDotHeavy) &&
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
{
|
||||
pFirstShape->m_eSimpleLineType = eSimpleLineType::sltHDash;
|
||||
passed = true;
|
||||
@ -485,13 +485,13 @@ namespace NSDocxRenderer
|
||||
if (pSecondShape->m_eSimpleLineType == eSimpleLineType::sltHDash)
|
||||
{
|
||||
if ((pFirstShape->m_eLineType == eLineType::ltUnknown || pFirstShape->m_eLineType == eLineType::ltDash ||
|
||||
pFirstShape->m_eLineType == eLineType::ltDashedHeavy) && pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
pFirstShape->m_eLineType == eLineType::ltDashedHeavy) && pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
{
|
||||
pFirstShape->m_eLineType = pFirstShape->m_dHeight > 0.3 ? eLineType::ltDashedHeavy : eLineType::ltDash;
|
||||
passed = true;
|
||||
}
|
||||
else if ((pFirstShape->m_eLineType == eLineType::ltDotDash || pFirstShape->m_eLineType == eLineType::ltDashDotHeavy) &&
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
{
|
||||
passed = true;
|
||||
}
|
||||
@ -499,14 +499,14 @@ namespace NSDocxRenderer
|
||||
else if (pSecondShape->m_eSimpleLineType == eSimpleLineType::sltHDot)
|
||||
{
|
||||
if ((pFirstShape->m_eLineType == eLineType::ltUnknown || pFirstShape->m_eLineType == eLineType::ltDotDash ||
|
||||
pFirstShape->m_eLineType == eLineType::ltDashDotHeavy) && pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
pFirstShape->m_eLineType == eLineType::ltDashDotHeavy) && pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
{
|
||||
pFirstShape->m_eLineType = pFirstShape->m_dHeight > 0.3 ? eLineType::ltDashDotHeavy : eLineType::ltDotDash;
|
||||
pFirstShape->m_eSimpleLineType = eSimpleLineType::sltHDot;
|
||||
passed = true;
|
||||
}
|
||||
else if ((pFirstShape->m_eLineType == eLineType::ltDotDotDash || pFirstShape->m_eLineType == eLineType::ltDashDotDotHeavy) &&
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
{
|
||||
pFirstShape->m_eSimpleLineType = eSimpleLineType::sltHDot;
|
||||
passed = true;
|
||||
@ -516,13 +516,13 @@ namespace NSDocxRenderer
|
||||
|
||||
case eSimpleLineType::sltHLongDash:
|
||||
if (fabs(pFirstShape->m_dLeft +pFirstShape->m_dWidth - pSecondShape->m_dLeft) < 0.7 ||
|
||||
pFirstShape->m_eLineType == eLineType::ltThick || pFirstShape->m_eLineType == eLineType::ltSingle)
|
||||
pFirstShape->m_eLineType == eLineType::ltThick || pFirstShape->m_eLineType == eLineType::ltSingle)
|
||||
{
|
||||
pFirstShape->m_eLineType = pFirstShape->m_dHeight > 0.3 ? eLineType::ltThick : eLineType::ltSingle;
|
||||
passed = true;
|
||||
}
|
||||
else if ((pFirstShape->m_eLineType == eLineType::ltUnknown || pFirstShape->m_eLineType == eLineType::ltDashLong ||
|
||||
pFirstShape->m_eLineType == eLineType::ltDashLongHeavy) && pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
pFirstShape->m_eLineType == eLineType::ltDashLongHeavy) && pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
{
|
||||
pFirstShape->m_eLineType = pFirstShape->m_dHeight > 0.3 ? eLineType::ltDashLongHeavy : eLineType::ltDashLong;
|
||||
passed = true;
|
||||
@ -531,8 +531,8 @@ namespace NSDocxRenderer
|
||||
|
||||
case eSimpleLineType::sltHWave:
|
||||
if ((pFirstShape->m_eLineType == eLineType::ltUnknown || pFirstShape->m_eLineType == eLineType::ltWave ||
|
||||
pFirstShape->m_eLineType == eLineType::ltWavyHeavy || pFirstShape->m_eLineType == eLineType::ltWavyDouble) &&
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
pFirstShape->m_eLineType == eLineType::ltWavyHeavy || pFirstShape->m_eLineType == eLineType::ltWavyDouble) &&
|
||||
pSecondShape->m_eLineType == eLineType::ltUnknown)
|
||||
{
|
||||
pFirstShape->m_eLineType = pFirstShape->m_oPen.Size > 0.3 ? eLineType::ltWavyHeavy : eLineType::ltWave;
|
||||
passed = true;
|
||||
@ -585,7 +585,7 @@ namespace NSDocxRenderer
|
||||
double left = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetLeft() : m_dLeft;
|
||||
double right = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetRight() : m_dRight;
|
||||
double top = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetTop() : m_dTop;
|
||||
double bot = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetBottom() : m_dBaselinePos;
|
||||
double bot = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetBottom() : m_dBot;
|
||||
|
||||
double width = right - left;
|
||||
double height = bot - top;
|
||||
@ -707,7 +707,7 @@ namespace NSDocxRenderer
|
||||
double left = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetLeft() : m_dLeft;
|
||||
double right = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetRight() : m_dRight;
|
||||
double top = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetTop() : m_dTop;
|
||||
double bot = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetBottom() : m_dBaselinePos;
|
||||
double bot = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetBottom() : m_dBot;
|
||||
|
||||
double height = bot - top;
|
||||
double width = right - left;
|
||||
@ -908,7 +908,7 @@ namespace NSDocxRenderer
|
||||
double left = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetLeft() : m_dLeft;
|
||||
double right = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetRight() : m_dRight;
|
||||
double top = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetTop() : m_dTop;
|
||||
double bot = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetBottom() : m_dBaselinePos;
|
||||
double bot = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetBottom() : m_dBot;
|
||||
|
||||
double height = bot - top;
|
||||
double width = right - left;
|
||||
@ -1047,4 +1047,344 @@ namespace NSDocxRenderer
|
||||
}
|
||||
oWriter.WriteString(L"</p:sp>");
|
||||
}
|
||||
void CShape::ToBin(NSWasm::CData& oWriter) const
|
||||
{
|
||||
auto& vector = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector : m_oVector;
|
||||
auto& data = vector.GetData();
|
||||
|
||||
double left = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetLeft() : m_dLeft;
|
||||
double right = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetRight() : m_dRight;
|
||||
double top = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetTop() : m_dTop;
|
||||
double bot = fabs(m_dRotation) > c_dMIN_ROTATION ? m_oNoRotVector.GetBottom() : m_dBot;
|
||||
|
||||
double height = bot - top;
|
||||
double width = right - left;
|
||||
|
||||
// WriteUniColor
|
||||
auto WriteUniColor = [&oWriter] (long color, long alpha) {
|
||||
BYTE r = reinterpret_cast<BYTE*>(&color)[0];
|
||||
BYTE g = reinterpret_cast<BYTE*>(&color)[1];
|
||||
BYTE b = reinterpret_cast<BYTE*>(&color)[2];
|
||||
|
||||
oWriter.StartRecord(1); // COLOR_TYPE_SRGB
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(0); oWriter.WriteBYTE(r);
|
||||
oWriter.WriteBYTE(1); oWriter.WriteBYTE(g);
|
||||
oWriter.WriteBYTE(2); oWriter.WriteBYTE(b);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
// WriteMods (alpha)
|
||||
oWriter.StartRecord(0);
|
||||
oWriter.AddInt(1);
|
||||
oWriter.StartRecord(1);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(0); oWriter.WriteStringUtf16(L"alpha");
|
||||
oWriter.WriteBYTE(1); oWriter.AddInt(alpha * 100000 / 255);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
oWriter.EndRecord();
|
||||
oWriter.EndRecord();
|
||||
};
|
||||
|
||||
auto WriteUniFill = [&oWriter, &WriteUniColor] (long color, long alpha) {
|
||||
oWriter.StartRecord(3); // FILL_TYPE_SOLID
|
||||
oWriter.StartRecord(0);
|
||||
WriteUniColor(color, alpha);
|
||||
oWriter.EndRecord();
|
||||
oWriter.EndRecord();
|
||||
};
|
||||
|
||||
auto write_spPr = [this, &oWriter, &vector, &data, &WriteUniFill, &top, &left, &height, &width] () {
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
|
||||
// WriteRecord WriteXfrm
|
||||
oWriter.StartRecord(0);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(0); oWriter.AddSInt(static_cast<int>(left * c_dMMToEMU));
|
||||
oWriter.WriteBYTE(1); oWriter.AddSInt(static_cast<int>(top * c_dMMToEMU));
|
||||
oWriter.WriteBYTE(2); oWriter.AddSInt(static_cast<int>(width * c_dMMToEMU));
|
||||
oWriter.WriteBYTE(3); oWriter.AddSInt(static_cast<int>(height * c_dMMToEMU));
|
||||
|
||||
if (fabs(m_dRotation) > c_dMIN_ROTATION)
|
||||
{
|
||||
int degree = static_cast<int>(m_dRotation * c_dDegreeToAngle);
|
||||
oWriter.WriteBYTE(10); oWriter.AddSInt(degree);
|
||||
}
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
// end of WriteRecord WriteXfrm
|
||||
|
||||
// WriteRecord WriteGeometry
|
||||
oWriter.StartRecord(1);
|
||||
if (vector.IsEmpty())
|
||||
{
|
||||
oWriter.StartRecord(1);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(0); oWriter.WriteStringUtf16(L"rect"); // default rect for text
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
else
|
||||
{
|
||||
oWriter.StartRecord(2);
|
||||
|
||||
// WritePathLst
|
||||
oWriter.StartRecord(4);
|
||||
oWriter.AddInt(1);
|
||||
oWriter.StartRecord(1);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(2); oWriter.AddInt(height * c_dMMToEMU); // pathH
|
||||
oWriter.WriteBYTE(4); oWriter.AddInt(width * c_dMMToEMU); // pathW
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.StartRecord(0);
|
||||
oWriter.AddInt(static_cast<unsigned int>(data.size()));
|
||||
|
||||
auto write_coords = [&oWriter, &left, &top] (const CVectorGraphics::CPathCommand& command) {
|
||||
BYTE byte_count = 0;
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
for (const auto& point : command.points)
|
||||
{
|
||||
int x_coord = static_cast<int>((point.x - left) * c_dMMToEMU);
|
||||
int y_coord = static_cast<int>((point.y - top) * c_dMMToEMU);
|
||||
oWriter.WriteBYTE(byte_count++);
|
||||
oWriter.WriteStringUtf16(std::to_wstring(x_coord));
|
||||
oWriter.WriteBYTE(byte_count++);
|
||||
oWriter.WriteStringUtf16(std::to_wstring(y_coord));
|
||||
}
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
};
|
||||
|
||||
for (const auto& command : data)
|
||||
{
|
||||
oWriter.StartRecord(0);
|
||||
switch (command.type)
|
||||
{
|
||||
case CVectorGraphics::ePathCommandType::pctMove:
|
||||
oWriter.StartRecord(1);
|
||||
write_coords(command);
|
||||
oWriter.EndRecord();
|
||||
break;
|
||||
case CVectorGraphics::ePathCommandType::pctLine:
|
||||
oWriter.StartRecord(2);
|
||||
write_coords(command);
|
||||
oWriter.EndRecord();
|
||||
break;
|
||||
case CVectorGraphics::ePathCommandType::pctCurve:
|
||||
oWriter.StartRecord(4);
|
||||
write_coords(command);
|
||||
oWriter.EndRecord();
|
||||
break;
|
||||
case CVectorGraphics::ePathCommandType::pctClose:
|
||||
oWriter.StartRecord(3);
|
||||
oWriter.EndRecord();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
oWriter.EndRecord();
|
||||
oWriter.EndRecord();
|
||||
oWriter.EndRecord();
|
||||
// end of WritePathLst
|
||||
|
||||
// WriteRecord WriteTextRect
|
||||
oWriter.StartRecord(5);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(0); oWriter.WriteStringUtf16(L"l");
|
||||
oWriter.WriteBYTE(1); oWriter.WriteStringUtf16(L"t");
|
||||
oWriter.WriteBYTE(2); oWriter.WriteStringUtf16(L"r");
|
||||
oWriter.WriteBYTE(3); oWriter.WriteStringUtf16(L"b");
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
// end of WriteRecord WriteTextRect
|
||||
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
oWriter.EndRecord();
|
||||
// end of WriteRecord WriteGeometry
|
||||
|
||||
// WriteRecord WriteUniFill
|
||||
if (!m_bIsNoFill && m_eType != CShape::eShapeType::stVectorTexture)
|
||||
{
|
||||
oWriter.StartRecord(2);
|
||||
WriteUniFill(m_oBrush.Color1, m_oBrush.Alpha1);
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
|
||||
if (!m_bIsNoStroke)
|
||||
{
|
||||
// WriteRecord WriteLn
|
||||
oWriter.StartRecord(3);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(3); oWriter.AddInt(static_cast<unsigned int>(m_oPen.Size * c_dMMToEMU)); // ln w
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
|
||||
oWriter.StartRecord(0);
|
||||
WriteUniFill(m_oPen.Color, m_oPen.Alpha);
|
||||
oWriter.EndRecord();
|
||||
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
};
|
||||
|
||||
if (m_eType == eShapeType::stVectorTexture)
|
||||
{
|
||||
oWriter.StartRecord(2);
|
||||
|
||||
// WriteRecord WriteUniNvPr
|
||||
oWriter.StartRecord(0);
|
||||
|
||||
// WriteRecord Write_cNvPr
|
||||
oWriter.StartRecord(0);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(0); oWriter.AddInt(m_pImageInfo->m_nId);
|
||||
std::wstring name = L"Picture " + std::to_wstring(m_pImageInfo->m_nId);
|
||||
oWriter.WriteBYTE(1); oWriter.WriteStringUtf16(name);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
|
||||
// WriteRecord WritePicCNvPr
|
||||
oWriter.StartRecord(1);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(3); oWriter.WriteBool(true); // noChangeAspect
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
|
||||
oWriter.EndRecord();
|
||||
// end of WriteRecord WriteUniNvPr
|
||||
|
||||
// WriteRecord WriteUniFill (blip)
|
||||
oWriter.StartRecord(1);
|
||||
oWriter.StartRecord(1); // FILL_TYPE_BLIP
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
|
||||
// WriteBlip
|
||||
oWriter.StartRecord(0);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.StartRecord(2);
|
||||
oWriter.AddInt(0); // effects
|
||||
oWriter.EndRecord();
|
||||
|
||||
std::wstring rId = L"rId" + std::to_wstring(c_iStartingIdForImages + m_pImageInfo->m_nId);
|
||||
oWriter.WriteBYTE(10); oWriter.WriteStringUtf16(rId); // embed
|
||||
|
||||
oWriter.EndRecord();
|
||||
// end of WriteBlip
|
||||
|
||||
if (m_oBrush.Image == NULL)
|
||||
{
|
||||
oWriter.StartRecord(1);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
|
||||
// coeff
|
||||
double src_offset_left = 1 - (width / (right - m_dImageLeft));
|
||||
double src_offset_right = 1 - (width / (m_dImageRight - left));
|
||||
double src_offset_top = 1 - (height / (bot - m_dImageTop));
|
||||
double src_offset_bot = 1 - (height / (m_dImageBot - top));
|
||||
|
||||
// percentage
|
||||
src_offset_left *= 100;
|
||||
src_offset_right *= 100;
|
||||
src_offset_top *= 100;
|
||||
src_offset_bot *= 100;
|
||||
|
||||
std::wstring l = std::to_wstring(static_cast<int>(src_offset_left * 1000));
|
||||
std::wstring t = std::to_wstring(static_cast<int>(src_offset_top * 1000));
|
||||
std::wstring r = std::to_wstring(static_cast<int>(src_offset_right * 1000));
|
||||
std::wstring b = std::to_wstring(static_cast<int>(src_offset_bot * 1000));
|
||||
|
||||
oWriter.WriteBYTE(0); oWriter.WriteStringUtf16(l);
|
||||
oWriter.WriteBYTE(1); oWriter.WriteStringUtf16(t);
|
||||
oWriter.WriteBYTE(2); oWriter.WriteStringUtf16(r);
|
||||
oWriter.WriteBYTE(3); oWriter.WriteStringUtf16(b);
|
||||
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
|
||||
oWriter.StartRecord(3);
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
else // tile
|
||||
{
|
||||
oWriter.StartRecord(2);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(0); oWriter.AddInt(100);
|
||||
oWriter.WriteBYTE(1); oWriter.AddInt(100);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
|
||||
oWriter.EndRecord();
|
||||
oWriter.EndRecord();
|
||||
// end of WriteRecord WriteUniFill (blip)
|
||||
|
||||
// WriteRecord WriteSpPr
|
||||
oWriter.StartRecord(2); write_spPr(); oWriter.EndRecord();
|
||||
|
||||
oWriter.EndRecord();
|
||||
return;
|
||||
}
|
||||
|
||||
oWriter.StartRecord(1);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
|
||||
// WriteRecord WriteSpPr
|
||||
oWriter.StartRecord(1); write_spPr(); oWriter.EndRecord();
|
||||
|
||||
if (m_eType == eShapeType::stTextBox && !m_arOutputObjects.empty())
|
||||
{
|
||||
// WriteRecord WriteTxBody
|
||||
oWriter.StartRecord(3);
|
||||
|
||||
// WriteRecord WriteBodyPr
|
||||
oWriter.StartRecord(0);
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
|
||||
oWriter.WriteBYTE(1); oWriter.WriteBYTE(1); // anchor
|
||||
oWriter.WriteBYTE(2); oWriter.WriteBool(false); // anchorCtr
|
||||
oWriter.WriteBYTE(3); oWriter.AddInt(0); // bIns
|
||||
oWriter.WriteBYTE(4); oWriter.WriteBool(true); // compatLnSpc
|
||||
oWriter.WriteBYTE(5); oWriter.WriteBool(false); // forceAA
|
||||
oWriter.WriteBYTE(6); oWriter.WriteBool(false); // fromWordArt
|
||||
oWriter.WriteBYTE(7); oWriter.WriteBYTE(1); // horzOverflow
|
||||
oWriter.WriteBYTE(8); oWriter.AddInt(0); // lIns
|
||||
oWriter.WriteBYTE(9); oWriter.AddInt(1); // numCol
|
||||
oWriter.WriteBYTE(10); oWriter.AddInt(0); // rIns
|
||||
oWriter.WriteBYTE(11); oWriter.AddInt(0); // rot
|
||||
oWriter.WriteBYTE(12); oWriter.WriteBool(false); // rtlCol
|
||||
oWriter.WriteBYTE(13); oWriter.AddInt(0); // spcCol
|
||||
oWriter.WriteBYTE(14); oWriter.WriteBool(false); // spcFirstLastPara
|
||||
oWriter.WriteBYTE(15); oWriter.AddInt(0); // tIns
|
||||
// 16 is upright param
|
||||
oWriter.WriteBYTE(17); oWriter.WriteBYTE(1); // vert
|
||||
oWriter.WriteBYTE(18); oWriter.WriteBYTE(1); // vertOverflow
|
||||
oWriter.WriteBYTE(19); oWriter.WriteBYTE(1); // vert
|
||||
|
||||
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
|
||||
// todo WritePrstTxWarp
|
||||
oWriter.EndRecord();
|
||||
// end of WriteRecord WriteBodyPr
|
||||
|
||||
// WriteRecordArray WriteParagraph
|
||||
oWriter.StartRecord(2);
|
||||
unsigned int len = static_cast<unsigned int>(m_arOutputObjects.size());
|
||||
oWriter.AddInt(len);
|
||||
for (const auto& o : m_arOutputObjects)
|
||||
{
|
||||
oWriter.StartRecord(0);
|
||||
o->ToBin(oWriter);
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
|
||||
oWriter.EndRecord();
|
||||
// end of WriteRecordArray WriteParagraph
|
||||
|
||||
oWriter.EndRecord();
|
||||
// end of WriteRecord WriteTxBody
|
||||
}
|
||||
oWriter.EndRecord();
|
||||
}
|
||||
}; // namespace NSDocxRenderer
|
||||
|
||||
@ -20,7 +20,7 @@ namespace NSDocxRenderer
|
||||
gtNoGraphics,
|
||||
};
|
||||
|
||||
class CShape : public CBaseItem
|
||||
class CShape : public CBaseItem, public IOoxmlItem
|
||||
{
|
||||
public:
|
||||
enum class eShapeType
|
||||
@ -63,15 +63,16 @@ namespace NSDocxRenderer
|
||||
eSimpleLineType m_eSimpleLineType{eSimpleLineType::sltUnknown};
|
||||
eLineType m_eLineType {eLineType::ltUnknown};
|
||||
|
||||
std::vector<std::shared_ptr<CBaseItem>> m_arOutputObjects;
|
||||
std::vector<std::shared_ptr<IOoxmlItem>> m_arOutputObjects;
|
||||
|
||||
public:
|
||||
CShape();
|
||||
CShape(std::shared_ptr<CImageInfo> pInfo, const std::wstring& strDstMedia);
|
||||
virtual ~CShape();
|
||||
virtual void Clear() override final;
|
||||
virtual void Clear();
|
||||
virtual void ToXml(NSStringUtils::CStringBuilder& oWriter) const override final;
|
||||
virtual void ToXmlPptx(NSStringUtils::CStringBuilder& oWriter)const override final;
|
||||
virtual void ToBin(NSWasm::CData& oWriter) const override final;
|
||||
|
||||
void SetVector(CVectorGraphics&& oVector);
|
||||
void CalcNoRotVector();
|
||||
|
||||
@ -5,7 +5,11 @@
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
void CTable::CCell::Clear()
|
||||
CTable::CCell::CCell(const CCell& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
void CTable::CCell::Clear()
|
||||
{
|
||||
m_arParagraphs.clear();
|
||||
}
|
||||
@ -15,17 +19,33 @@ namespace NSDocxRenderer
|
||||
oWriter.WriteString(L"<w:tcPr>");
|
||||
oWriter.WriteString(L"<w:tcW w:w=\"");
|
||||
oWriter.AddUInt(static_cast<unsigned int>(m_dWidth * c_dMMToDx));
|
||||
oWriter.WriteString(L"\"w:type=\"dxa\"/>");
|
||||
oWriter.WriteString(L"\" w:type=\"dxa\"/>");
|
||||
|
||||
oWriter.WriteString(L"<w:gridSpan w:val=\"");
|
||||
oWriter.AddUInt(m_nGridSpan);
|
||||
oWriter.WriteString(L"\"/>");
|
||||
|
||||
oWriter.WriteString(L"<w:vMerge w:val=\"");
|
||||
switch (m_eVMerge) {
|
||||
case eVMerge::vmContinue:
|
||||
oWriter.WriteString(L"continue");
|
||||
break;
|
||||
case eVMerge::vmRestart:
|
||||
oWriter.WriteString(L"restart");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
oWriter.WriteString(L"\"/>");
|
||||
|
||||
oWriter.WriteString(L"<w:tcBorders>");
|
||||
|
||||
auto write_border = [&oWriter] (const CBorder& border, const std::wstring& prefix) {
|
||||
oWriter.WriteString(L"<w:");
|
||||
oWriter.WriteString(prefix);
|
||||
oWriter.WriteString(L" w:val=");
|
||||
oWriter.WriteString(SingletonInstance<LinesTable>().ConvertLineToString(border.lineType));
|
||||
oWriter.WriteString(L" w:sz=\"");
|
||||
oWriter.AddUInt(static_cast<unsigned int>(border.dWidth * c_dMMToPt / 8));
|
||||
oWriter.AddUInt(static_cast<unsigned int>(border.dWidth * c_dMMToPt * 8));
|
||||
oWriter.WriteString(L"\" w:space=\"");
|
||||
oWriter.AddUInt(static_cast<unsigned int>(border.dSpacing * c_dMMToPt));
|
||||
oWriter.WriteString(L"\" w:color=\"");
|
||||
@ -34,7 +54,7 @@ namespace NSDocxRenderer
|
||||
};
|
||||
|
||||
write_border(m_oBorderTop, L"top");
|
||||
write_border(m_oBorderBot, L"bot");
|
||||
write_border(m_oBorderBot, L"bottom");
|
||||
write_border(m_oBorderLeft, L"left");
|
||||
write_border(m_oBorderRight, L"right");
|
||||
|
||||
@ -49,6 +69,28 @@ namespace NSDocxRenderer
|
||||
void CTable::CCell::ToXmlPptx(NSStringUtils::CStringBuilder& oWriter) const
|
||||
{
|
||||
|
||||
}
|
||||
void CTable::CCell::ToBin(NSWasm::CData& oWriter) const
|
||||
{
|
||||
|
||||
}
|
||||
CTable::CCell& CTable::CCell::operator=(const CCell& other)
|
||||
{
|
||||
CBaseItem::operator=(other);
|
||||
|
||||
m_oBorderBot = other.m_oBorderBot;
|
||||
m_oBorderTop = other.m_oBorderTop;
|
||||
m_oBorderLeft = other.m_oBorderLeft;
|
||||
m_oBorderRight = other.m_oBorderRight;
|
||||
|
||||
m_nGridSpan = other.m_nGridSpan;
|
||||
m_eVMerge = other.m_eVMerge;
|
||||
|
||||
m_arParagraphs.clear();
|
||||
for (const auto& p : other.m_arParagraphs)
|
||||
m_arParagraphs.push_back(p);
|
||||
|
||||
return *this;
|
||||
}
|
||||
void CTable::CCell::AddParagraph(const paragraph_ptr_t& pParagraph)
|
||||
{
|
||||
@ -77,6 +119,10 @@ namespace NSDocxRenderer
|
||||
void CTable::CRow::ToXmlPptx(NSStringUtils::CStringBuilder& oWriter) const
|
||||
{
|
||||
|
||||
}
|
||||
void CTable::CRow::ToBin(NSWasm::CData& oWriter) const
|
||||
{
|
||||
|
||||
}
|
||||
void CTable::CRow::AddCell(const cell_ptr_t& pCell)
|
||||
{
|
||||
@ -97,12 +143,26 @@ namespace NSDocxRenderer
|
||||
oWriter.WriteString(L"<w:tbl>");
|
||||
|
||||
oWriter.WriteString(L"<w:tblPr>");
|
||||
oWriter.WriteString(L"<w:tblpPr ");
|
||||
|
||||
oWriter.WriteString(L"w:horzAnchor=\"page\" w:vertAnchor=\"page\" w:tblpX=\"");
|
||||
oWriter.AddInt64(static_cast<long long>(m_dLeft * c_dMMToDx));
|
||||
oWriter.WriteString(L"\" w:tblpY=\"");
|
||||
oWriter.AddInt64(static_cast<long long>(m_dTop * c_dMMToDx));
|
||||
oWriter.WriteString(L"\" />");
|
||||
|
||||
oWriter.WriteString(L"<w:tblW w:w=\"");
|
||||
oWriter.AddUInt(static_cast<unsigned int>(m_dWidth * c_dMMToDx));
|
||||
oWriter.WriteString(L"\"w:type=\"dxa\"/>");
|
||||
oWriter.WriteString(L"\" w:type=\"dxa\"/>");
|
||||
oWriter.WriteString(L"</w:tblPr>");
|
||||
|
||||
oWriter.WriteString(L"<w:tblGrid>");
|
||||
for (const auto& gc : m_arGridCols)
|
||||
{
|
||||
oWriter.WriteString(L"<w:gridCol w:w=\"");
|
||||
oWriter.AddUInt(static_cast<unsigned int>(gc * c_dMMToDx));
|
||||
oWriter.WriteString(L"\" />");
|
||||
}
|
||||
oWriter.WriteString(L"</w:tblGrid>");
|
||||
|
||||
for (const auto& r : m_arRows)
|
||||
@ -113,15 +173,58 @@ namespace NSDocxRenderer
|
||||
void CTable::ToXmlPptx(NSStringUtils::CStringBuilder& oWriter) const
|
||||
{
|
||||
|
||||
}
|
||||
void CTable::ToBin(NSWasm::CData& oWriter) const
|
||||
{
|
||||
|
||||
}
|
||||
void CTable::AddRow(const row_ptr_t& pRow)
|
||||
{
|
||||
CBaseItem::RecalcWithNewItem(pRow.get());
|
||||
m_arRows.push_back(pRow);
|
||||
}
|
||||
void CTable::CalcGridCols()
|
||||
{
|
||||
std::vector<double> cells_left;
|
||||
auto add_if_no_exists = [&cells_left] (double val) {
|
||||
bool exists = false;
|
||||
for (const auto& curr : cells_left)
|
||||
{
|
||||
if (fabs(curr - val) < c_dMAX_TABLE_LINE_WIDTH_MM)
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!exists)
|
||||
cells_left.push_back(val);
|
||||
};
|
||||
|
||||
double right = 0;
|
||||
for (const auto& row : m_arRows)
|
||||
{
|
||||
for (const auto& cell : row->m_arCells)
|
||||
{
|
||||
right = std::max(right, cell->m_dRight);
|
||||
add_if_no_exists(cell->m_dLeft);
|
||||
}
|
||||
}
|
||||
std::sort(cells_left.begin(), cells_left.end(), std::less<double>{});
|
||||
|
||||
for (size_t i = 0; i < cells_left.size() - 1; ++i)
|
||||
m_arGridCols.push_back(cells_left[i + 1] - cells_left[i]);
|
||||
|
||||
m_arGridCols.push_back(right - cells_left.back());
|
||||
}
|
||||
bool CTable::IsEmpty() const
|
||||
{
|
||||
return m_arRows.empty();
|
||||
}
|
||||
|
||||
void CTextCell::AddTextLine(const std::shared_ptr<CTextLine>& pTextLine)
|
||||
{
|
||||
CBaseItem::RecalcWithNewItem(pTextLine.get());
|
||||
m_arTextLines.push_back(pTextLine);
|
||||
}
|
||||
|
||||
} // namespace NSDocxRenderer
|
||||
|
||||
@ -5,12 +5,16 @@
|
||||
|
||||
#include "BaseItem.h"
|
||||
#include "Paragraph.h"
|
||||
#include "Shape.h"
|
||||
|
||||
#include "../../resources/LinesTable.h"
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
class CTable : public CBaseItem
|
||||
class CGraphicalCell;
|
||||
class CTextCell;
|
||||
|
||||
class CTable : public CBaseItem, public IOoxmlItem
|
||||
{
|
||||
public:
|
||||
class CCell;
|
||||
@ -21,22 +25,33 @@ namespace NSDocxRenderer
|
||||
using paragraph_ptr_t = std::shared_ptr<CParagraph>;
|
||||
|
||||
public:
|
||||
class CCell : public CBaseItem
|
||||
class CCell : public CBaseItem, public IOoxmlItem
|
||||
{
|
||||
friend class CTable;
|
||||
public:
|
||||
struct CBorder
|
||||
{
|
||||
double dWidth{};
|
||||
double dSpacing{};
|
||||
long lColor{};
|
||||
eLineType lineType{};
|
||||
eLineType lineType{eLineType::ltNone};
|
||||
};
|
||||
|
||||
enum class eVMerge
|
||||
{
|
||||
vmRestart,
|
||||
vmContinue
|
||||
};
|
||||
|
||||
CCell() = default;
|
||||
CCell(const CCell& other);
|
||||
virtual ~CCell() = default;
|
||||
virtual void Clear() override final;
|
||||
virtual void Clear();
|
||||
virtual void ToXml(NSStringUtils::CStringBuilder& oWriter) const override final;
|
||||
virtual void ToXmlPptx(NSStringUtils::CStringBuilder& oWriter) const override final;
|
||||
virtual void ToBin(NSWasm::CData& oWriter) const override final;
|
||||
|
||||
CCell& operator=(const CCell& other);
|
||||
|
||||
void AddParagraph(const paragraph_ptr_t& pParagraph);
|
||||
|
||||
@ -45,17 +60,21 @@ namespace NSDocxRenderer
|
||||
CBorder m_oBorderLeft;
|
||||
CBorder m_oBorderRight;
|
||||
|
||||
private:
|
||||
unsigned int m_nGridSpan = 1;
|
||||
eVMerge m_eVMerge = CTable::CCell::eVMerge::vmRestart;
|
||||
|
||||
std::vector<paragraph_ptr_t> m_arParagraphs;
|
||||
};
|
||||
class CRow : public CBaseItem
|
||||
class CRow : public CBaseItem, IOoxmlItem
|
||||
{
|
||||
friend class CTable;
|
||||
public:
|
||||
CRow() = default;
|
||||
virtual ~CRow() = default;
|
||||
virtual void Clear() override final;
|
||||
virtual void Clear();
|
||||
virtual void ToXml(NSStringUtils::CStringBuilder& oWriter) const override final;
|
||||
virtual void ToXmlPptx(NSStringUtils::CStringBuilder& oWriter) const override final;
|
||||
virtual void ToBin(NSWasm::CData& oWriter) const override final;
|
||||
|
||||
void AddCell(const cell_ptr_t& pCell);
|
||||
bool IsEmpty() const;
|
||||
@ -66,15 +85,37 @@ namespace NSDocxRenderer
|
||||
|
||||
CTable() = default;
|
||||
virtual ~CTable() = default;
|
||||
virtual void Clear() override final;
|
||||
virtual void Clear();
|
||||
virtual void ToXml(NSStringUtils::CStringBuilder& oWriter) const override final;
|
||||
virtual void ToXmlPptx(NSStringUtils::CStringBuilder& oWriter) const override final;
|
||||
virtual void ToBin(NSWasm::CData& oWriter) const override final;
|
||||
|
||||
void AddRow(const row_ptr_t& pRow);
|
||||
void CalcGridCols();
|
||||
bool IsEmpty() const;
|
||||
|
||||
private:
|
||||
std::vector<row_ptr_t> m_arRows;
|
||||
std::vector<double> m_arGridCols;
|
||||
};
|
||||
|
||||
class CGraphicalCell : public CBaseItem
|
||||
{
|
||||
public:
|
||||
// realization
|
||||
};
|
||||
|
||||
class CTextCell : public CBaseItem
|
||||
{
|
||||
public:
|
||||
void AddTextLine(const std::shared_ptr<CTextLine>& pTextLine);
|
||||
std::vector<std::shared_ptr<CTextLine>> m_arTextLines;
|
||||
|
||||
double m_dMinPossibleTop = std::numeric_limits<double>::lowest();
|
||||
double m_dMinPossibleLeft = std::numeric_limits<double>::lowest();
|
||||
|
||||
double m_dMaxPossibleBot = std::numeric_limits<double>::max();
|
||||
double m_dMaxPossibleRight = std::numeric_limits<double>::max();
|
||||
};
|
||||
} // namespace NSDocxRenderer
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user