mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-17 21:12:19 +08:00
Compare commits
957 Commits
v99.99.99.
...
feature/so
| Author | SHA1 | Date | |
|---|---|---|---|
| c725eed37d | |||
| 573b85932f | |||
| 52f8640b10 | |||
| 8a1a45f403 | |||
| 2b46e0251f | |||
| 078a58772c | |||
| 3c707ebbf4 | |||
| d54f0326cd | |||
| 269dd9b8bc | |||
| 9da0b82ead | |||
| e3334cbea5 | |||
| 01c928c724 | |||
| e5c1dc4bc3 | |||
| 2c5cd93ac5 | |||
| 1ff1334746 | |||
| de096d4229 | |||
| 6c9d795167 | |||
| 8116322018 | |||
| 5428c28874 | |||
| e389b4d799 | |||
| 8c607a429a | |||
| 00e80b68f6 | |||
| 377317892d | |||
| ef77688ea2 | |||
| eb756fab5c | |||
| 2d2bb7cee7 | |||
| 1abe5b2dcc | |||
| 2b4bdfdc05 | |||
| 007c70bcc0 | |||
| 017b43dd66 | |||
| 88a6760086 | |||
| 98a0551123 | |||
| 49cb1cdbca | |||
| 73e00a5096 | |||
| 462eeda60c | |||
| e1f81b6830 | |||
| d63a6e2ba4 | |||
| b9cf1bd204 | |||
| 81ec569f59 | |||
| 236913f902 | |||
| 2a6d9faaf8 | |||
| 7a78e1bbc6 | |||
| f2db0df9f5 | |||
| c2dfac0d27 | |||
| 902497b299 | |||
| 35aa329619 | |||
| 6ace9b1cc5 | |||
| f6bc46c551 | |||
| 790049d14a | |||
| ccc9f8f91f | |||
| f2eace2b53 | |||
| dfe7a64e1a | |||
| 65f89c1e4b | |||
| ea7ff62816 | |||
| 4ac45f41cb | |||
| 947e5a1f5d | |||
| 3e724e6164 | |||
| 8ef0713adc | |||
| 2f74b3b69b | |||
| 7ce71b6f5d | |||
| 9b5847e653 | |||
| d81e26eff7 | |||
| 67e987e389 | |||
| bc91106ea4 | |||
| d91a19cbc2 | |||
| 970720575a | |||
| f11045c87f | |||
| 70e819c56b | |||
| 5a662b3567 | |||
| 0f920531ac | |||
| 84d3ea7a21 | |||
| 4893ff96fd | |||
| 6a7791ae0a | |||
| 78ac7bb427 | |||
| 8180a20cb8 | |||
| eb51861f39 | |||
| e4cc737c38 | |||
| 6c89a66b3d | |||
| b127bd3ac1 | |||
| 0cca75b662 | |||
| 08dc0c99cf | |||
| d2af89a2f6 | |||
| 836787f151 | |||
| eb78332705 | |||
| f232d0ca51 | |||
| 24d436fb9c | |||
| 1d362cf69a | |||
| 6c0326d660 | |||
| 4400c9d4f4 | |||
| 71c7d25c9e | |||
| ab1dd7a48b | |||
| 6e3d625420 | |||
| ebb0eb8136 | |||
| 10f34fb67d | |||
| 98d2f62f9e | |||
| 096df8fc31 | |||
| a7886c5cd6 | |||
| ee6ea683d1 | |||
| 9343f73818 | |||
| 61aeb6f386 | |||
| 06e8d136bf | |||
| c1d649b506 | |||
| 4386e9c794 | |||
| 4900305b4a | |||
| e1f923c593 | |||
| 07ef2269ac | |||
| cf44441645 | |||
| 7157d209d7 | |||
| 64a560679c | |||
| 2682e49090 | |||
| 7fd4219ff4 | |||
| 4f9c229f77 | |||
| 6d8454c39d | |||
| 58deecba88 | |||
| 1940bc53f7 | |||
| a6ac765676 | |||
| 08624e8334 | |||
| 1f078c8c49 | |||
| e6036b37be | |||
| 04f1c30036 | |||
| 86f84f89de | |||
| 17b80ac96e | |||
| 710bfef301 | |||
| aa75825a73 | |||
| f74caacbd0 | |||
| 4d903b58b8 | |||
| 6434965f09 | |||
| f60f957d00 | |||
| bad5b172d5 | |||
| 7b6f29a5f0 | |||
| b5e1cf9d06 | |||
| 0f73b2aa8b | |||
| e3b5d72ec8 | |||
| 8f8a9ad29b | |||
| 1417b4bbd4 | |||
| 87c9f66c58 | |||
| d0a9d2cfe2 | |||
| 627d5913e6 | |||
| 5ca60f6bcd | |||
| 72f679b649 | |||
| c84c35933e | |||
| 63f160641d | |||
| 7a8ccfdfa0 | |||
| 6091a7b5cd | |||
| 95b4461961 | |||
| ec5afc1f17 | |||
| 9dd13a2f74 | |||
| b850450c25 | |||
| 098d40d44f | |||
| 82769d3c0e | |||
| 5121f74851 | |||
| 6fa8b51541 | |||
| 3b32ba4d14 | |||
| e23acc8881 | |||
| c266ffa85f | |||
| bd2af5f455 | |||
| ec8c0182c3 | |||
| 04ad9d4e47 | |||
| 3261ba0d0c | |||
| 2189934a50 | |||
| e3842c796a | |||
| 7507b6c71f | |||
| 8a406c9612 | |||
| 3a004e8495 | |||
| 404748ec5a | |||
| d4f7767c45 | |||
| f91cc79e7d | |||
| b14e7fd3a2 | |||
| fce8173ce4 | |||
| 8f5bfef6b2 | |||
| f6bf73dfab | |||
| 3b10e1a0f3 | |||
| f7555af6b3 | |||
| 3e09e5ad48 | |||
| 655bc0698f | |||
| e16b85f671 | |||
| 981b8b16a3 | |||
| 70aa8c7e64 | |||
| 4144723822 | |||
| 2663e412ef | |||
| 9a91e8192c | |||
| bff86db600 | |||
| 668804035a | |||
| cb97ee9fdc | |||
| 56b8e41875 | |||
| 565b2ec494 | |||
| a243e60e5a | |||
| 96ce3c22f1 | |||
| 6b58358186 | |||
| 6c95810f63 | |||
| d9260e5eee | |||
| 63510a1fe9 | |||
| 1e05ab9acb | |||
| c1236815a3 | |||
| c822a995c1 | |||
| e612306d75 | |||
| 2d6382e61a | |||
| 2f34fd917e | |||
| 024a5e0192 | |||
| a6183fa4cd | |||
| 13912c93ef | |||
| adcdbc164f | |||
| a48a78c1c5 | |||
| da57bd115c | |||
| 71b21ea79d | |||
| 5fbb998524 | |||
| ea47a90763 | |||
| daefd8744a | |||
| 647327a0c5 | |||
| 58b221f4fa | |||
| 22eaf8241b | |||
| 64c7b7a3fd | |||
| 858c2e14c8 | |||
| 2024302fbe | |||
| 00f4752dda | |||
| 90b329e06c | |||
| d286b8459b | |||
| ff93f1e8b3 | |||
| 65a4fa90a5 | |||
| 4471940b92 | |||
| c4daa0acd4 | |||
| 6df0cf26f3 | |||
| 720d66ad74 | |||
| e6522c6ce4 | |||
| 9b3c2291d8 | |||
| e7cfb67962 | |||
| 8725be55f0 | |||
| 37ae77d0d2 | |||
| 4c6ded76a1 | |||
| 2d8701cd4f | |||
| d5c321d47d | |||
| bddfadabb2 | |||
| 324f7b3933 | |||
| edef6a83c8 | |||
| e7c21fb2cd | |||
| be8ba62c3f | |||
| fda8c8e445 | |||
| d9ebae1724 | |||
| 92ec3d854e | |||
| f4867bd9f9 | |||
| 9b9da90dcc | |||
| cba4bc8085 | |||
| 325c2d3000 | |||
| 3187913c8e | |||
| 8958d13b56 | |||
| 9d13526724 | |||
| 93f70176bc | |||
| e2ad965d7c | |||
| d535aa64ef | |||
| c155a4c53a | |||
| 97cbd8dcc7 | |||
| 5e58298d1e | |||
| d38576085c | |||
| 46dd9efa2e | |||
| 6af52920a2 | |||
| f13baca136 | |||
| 28a91a1519 | |||
| 0e48e65ef1 | |||
| ad1709d4af | |||
| e2c6ecec9b | |||
| ef55594f90 | |||
| 223bbe3347 | |||
| eca0cdb318 | |||
| 4a52368c30 | |||
| 73f4e20c56 | |||
| d53768969b | |||
| 324d6ec0bd | |||
| 767b652ef2 | |||
| 68f2f0760d | |||
| 694282a013 | |||
| e64eeb26af | |||
| 873b2b9351 | |||
| d5ecb00472 | |||
| 2ac6801afa | |||
| 213c65fe54 | |||
| 8269c14207 | |||
| f438a17779 | |||
| 9c8b739d0e | |||
| a9dc790f92 | |||
| 7f0720bb95 | |||
| 846b212882 | |||
| 344a096e24 | |||
| 15eb4793f5 | |||
| 3ce4b4bfe8 | |||
| b8fab6f4df | |||
| 14bb45d2fe | |||
| 347c1f82a9 | |||
| 7ebf12c1e4 | |||
| 1813e09e1f | |||
| e32b48524e | |||
| d2a986c480 | |||
| 73880f6207 | |||
| 24ad4adf6f | |||
| e4ea19ed81 | |||
| 575e379c4b | |||
| 86d8c7bfa3 | |||
| a3e1efb75b | |||
| e1f7feb5c1 | |||
| 2a3f565b44 | |||
| 13008c60e5 | |||
| df69099689 | |||
| 4e6f6e44bd | |||
| 67b54dc371 | |||
| b0c3172ae5 | |||
| 91d21a80ac | |||
| e820a9c936 | |||
| b38b12dfaf | |||
| 39b9e89e77 | |||
| 0b6ea2a399 | |||
| eee3161833 | |||
| fc422bb2e7 | |||
| f359f180bb | |||
| b0338919fe | |||
| 41358e3308 | |||
| 1a29fb1389 | |||
| 2fa048303f | |||
| 79f8e14d07 | |||
| e837479426 | |||
| e8f68e3a40 | |||
| 702987e00c | |||
| 83745da5f3 | |||
| 6b73faac12 | |||
| cab91648ce | |||
| 57b51a8854 | |||
| 4a84b8887f | |||
| 23027e4c2c | |||
| 52c61219dc | |||
| 2c37dac18c | |||
| aa7f104e60 | |||
| 83ea144c16 | |||
| ea6fdc8872 | |||
| b64b31a972 | |||
| 59fb6e4838 | |||
| d38ce5b836 | |||
| bb4ceb14e5 | |||
| ef9f25aa4d | |||
| 0c2a5eac1b | |||
| 0f85422315 | |||
| 38fa7436c0 | |||
| e2ce58a055 | |||
| cadba798b0 | |||
| 3941d5ced2 | |||
| c529cc6d5c | |||
| 31f274fbc4 | |||
| 58fe8ae679 | |||
| e3f77e11e0 | |||
| 6e696daa15 | |||
| 21dd930d30 | |||
| c4708222c6 | |||
| 34aae89432 | |||
| 273454a391 | |||
| ae4edab75e | |||
| e61aa447f2 | |||
| 6609e84bd1 | |||
| 402fe2c796 | |||
| e2aab8a241 | |||
| 555a251211 | |||
| 4a605d2424 | |||
| e49c4bc7fe | |||
| f5a4e570bb | |||
| af5a87327b | |||
| 11c637deeb | |||
| b3a7e20b35 | |||
| 915576a819 | |||
| 38a07b3c4d | |||
| ead20d7bfe | |||
| 90dc792fae | |||
| 0561ed2182 | |||
| 116ec89cd2 | |||
| f44de11437 | |||
| f5395b8b5f | |||
| 614222ee44 | |||
| 1b5d71a14c | |||
| 2ff12c06a4 | |||
| a3b6295058 | |||
| efd9e3a29e | |||
| 0fa13f3659 | |||
| 8133e3f7b7 | |||
| 7eabfd0838 | |||
| 3081d02c9c | |||
| fd2710e46e | |||
| bc076fb5b6 | |||
| 33fa3fa38b | |||
| 9bc03ffdef | |||
| 91afd3d340 | |||
| 6018add7a5 | |||
| b616ce6fd7 | |||
| 570482b60d | |||
| 201cae0e6f | |||
| 1cca5e3c12 | |||
| 048eebc613 | |||
| 7d06219664 | |||
| 760b4f9079 | |||
| 578118380e | |||
| 59f376908c | |||
| 38ceb61e4a | |||
| b3a76d5678 | |||
| c2d1bf113b | |||
| bde1115962 | |||
| d8dc82ea35 | |||
| 0ef0518f1a | |||
| f2da15defa | |||
| e3272a5e91 | |||
| d29dae37cb | |||
| d82c96dc0f | |||
| 69948ba383 | |||
| d04f9cb8cf | |||
| 5d6caf8a93 | |||
| f6ede7a53f | |||
| 3839ab4c15 | |||
| e936b0e4e7 | |||
| 6283a68841 | |||
| 75477e8c03 | |||
| 527cc5f89f | |||
| f4cb421b49 | |||
| 83d8a073a7 | |||
| 55ba36f4d2 | |||
| f760d03281 | |||
| 50ae7db2f0 | |||
| 0e02919540 | |||
| 1237991ffb | |||
| 5e5293b77b | |||
| 8250b59558 | |||
| 646c29166e | |||
| a2fc927b39 | |||
| b6f024b73f | |||
| 3aca7bec15 | |||
| 078ec02efd | |||
| dd17cb7243 | |||
| deff23eaac | |||
| b3988b002f | |||
| db2a9e88a1 | |||
| a8fe05fb6a | |||
| bb3091b6f1 | |||
| d908cb668e | |||
| d595d3ea86 | |||
| dde96288ed | |||
| 41d79b0df6 | |||
| 2330f1dae8 | |||
| 8f108582b9 | |||
| 6c6d575908 | |||
| 14dd41a2a2 | |||
| b000343b86 | |||
| c7e1250287 | |||
| dc6ca55b57 | |||
| 707aab41f3 | |||
| fba3767e36 | |||
| 7b8eae26c1 | |||
| c445c0444d | |||
| 94edfff846 | |||
| 482810712e | |||
| 43ba8fca21 | |||
| f38759d071 | |||
| 52e47745de | |||
| 554d3d0dfd | |||
| c9100737e0 | |||
| a22f0bfb60 | |||
| d21b44a0b8 | |||
| 0da5ad2f48 | |||
| 8611c5f781 | |||
| ea338db68a | |||
| 5089a76b43 | |||
| a8678c5d10 | |||
| ac5c7d6d76 | |||
| 080ae0d924 | |||
| 77c9bd8c6d | |||
| 8144f98bb8 | |||
| aec1220bff | |||
| 76f3afc6c0 | |||
| 3e78043cdd | |||
| 0319918827 | |||
| 80d8f4b12e | |||
| c52cfd0886 | |||
| 4c9a24bf71 | |||
| 9ece4889a1 | |||
| 00c24f9d68 | |||
| 0223b1beab | |||
| 5c15b76598 | |||
| 72315df901 | |||
| cb0e361490 | |||
| db279bd725 | |||
| 40c4c922c1 | |||
| 67f287f30f | |||
| 964a44ed93 | |||
| 57984ca8a2 | |||
| a30f7dfdf4 | |||
| b369c32e9e | |||
| 40a4fa1a92 | |||
| 3870d23511 | |||
| 9c12c0b30a | |||
| 2779542061 | |||
| e232fc779d | |||
| 3209c8e42e | |||
| 037057ea7a | |||
| d373a8cc4c | |||
| 13e2efe724 | |||
| b09d441987 | |||
| 9e835d5cc1 | |||
| f75df05824 | |||
| 0d6d273573 | |||
| d7a1642a62 | |||
| d74899a116 | |||
| 981df3fce7 | |||
| d0dfd6737c | |||
| 05d7d88481 | |||
| cec10b7058 | |||
| c3b3a1b5ef | |||
| 47258d9c30 | |||
| 10ab7009a1 | |||
| 3623b0970b | |||
| 7ecab52601 | |||
| 9fedabc0e2 | |||
| 85d98daedd | |||
| fa46455e74 | |||
| 0c87e66785 | |||
| 9dacd4a548 | |||
| e815f39905 | |||
| fb8a72cd6b | |||
| ad6113cf21 | |||
| 11914f8dc2 | |||
| 50b2656c44 | |||
| 39235f7fd6 | |||
| d2527e5707 | |||
| 3484834b9d | |||
| 81b4ba3493 | |||
| 44e217cf7c | |||
| 61311457be | |||
| e15391ea35 | |||
| fefeb483e5 | |||
| e31e02d993 | |||
| 5c7ef5a6eb | |||
| bcdcfa8bf7 | |||
| fc110a004d | |||
| 12d33fad53 | |||
| 2534d2b5c9 | |||
| 7019b192bd | |||
| ac97a5680b | |||
| bebb39a619 | |||
| 1ee8baa672 | |||
| d014383a6d | |||
| 6422ce7f78 | |||
| 31f7136f70 | |||
| f2023f626b | |||
| 6ea64599bd | |||
| d1d94f481d | |||
| 82eb921f05 | |||
| 84847f1e74 | |||
| 3730827cd8 | |||
| eab6d5530b | |||
| dd00be6dce | |||
| 8391667147 | |||
| b8748e40d5 | |||
| 39da47bc21 | |||
| 3a201b8b28 | |||
| bbfbe4a149 | |||
| 0c1c57ccb3 | |||
| fa532edad6 | |||
| df82306306 | |||
| 7a3464b985 | |||
| 49924e23ac | |||
| b5f0b39258 | |||
| 3f6a800dd8 | |||
| 1c8ad7a5c4 | |||
| 8464d3aeb7 | |||
| ed939ebd1d | |||
| fe6c5614d4 | |||
| 1eaac39e48 | |||
| 7624e24027 | |||
| 44ffa4b72e | |||
| 10bdf2703a | |||
| c488384dbc | |||
| cd80bca553 | |||
| 6e49670513 | |||
| b1b3e1fb7c | |||
| d78487e0f5 | |||
| 5069b68247 | |||
| 31433e20de | |||
| 86d0d2113e | |||
| 8f2b4e4153 | |||
| 0be867c47d | |||
| 78aae7e9d0 | |||
| 10e63543dc | |||
| 900cf01902 | |||
| f6a52876ce | |||
| 45ad566eb1 | |||
| 5bbea51848 | |||
| 28a1828000 | |||
| 816430e0e2 | |||
| 29a29cc818 | |||
| bf66c1d9c0 | |||
| 2a3982a884 | |||
| 9f94166f82 | |||
| f11beb659f | |||
| 9a9182a1e9 | |||
| c7cce459bc | |||
| b5fb8a34dc | |||
| 11f0c937f4 | |||
| 5e435d322f | |||
| 05660e8c31 | |||
| b9ff6ba943 | |||
| d603e4f5dd | |||
| 207dd32a5d | |||
| f2d0d7ac4c | |||
| 842d17f79e | |||
| d48a28fe1d | |||
| 2a22c5e1f3 | |||
| 629a35213e | |||
| 7b995bb45f | |||
| 08502f0b24 | |||
| aeca319710 | |||
| 7425d53eb3 | |||
| a056b2e4a9 | |||
| 2dd35a7d81 | |||
| 080d89c8a0 | |||
| 1809f7f4c2 | |||
| 4bfd4f0a08 | |||
| 3ef5651dfd | |||
| 8231809ef0 | |||
| 7f3d073d63 | |||
| 5f09e91944 | |||
| f4359e0b7f | |||
| ca9cf4ee61 | |||
| f52538f66a | |||
| bd76b2add0 | |||
| 0436e39722 | |||
| 15359be125 | |||
| 07be806ae3 | |||
| fc2a12c6f2 | |||
| 42030372fe | |||
| bbf6c2d8e9 | |||
| cb15cc18eb | |||
| 389bf976a9 | |||
| 4d1b516cc9 | |||
| 600a59c966 | |||
| 94f06bf997 | |||
| 230316aefa | |||
| 66b2f3c828 | |||
| 64e077da19 | |||
| 499fe52b8c | |||
| 6f9c376040 | |||
| f0b266793f | |||
| 490281dda0 | |||
| b98b808cda | |||
| 6c77718f17 | |||
| 1e18352e77 | |||
| c3f4f32702 | |||
| 50c7e106fb | |||
| 6b5ee390a2 | |||
| 6df7a7e01e | |||
| 6167f23a08 | |||
| 7c544729bc | |||
| 74a2b3b06f | |||
| 8f3e19a5db | |||
| d60c102dbb | |||
| 9049e2e6a8 | |||
| 67c6707072 | |||
| 0c29a5d436 | |||
| d709598563 | |||
| 0019f589bc | |||
| 02d492ff90 | |||
| a7026ccb8d | |||
| 200c17ee40 | |||
| 4543bfa6cd | |||
| 16e78d87a4 | |||
| 051597a78a | |||
| 7afad1fe49 | |||
| aa53d6302f | |||
| 13e03328af | |||
| 04ccd4fe27 | |||
| ae8fb19147 | |||
| 12083905dc | |||
| e653442b8c | |||
| 511cfb6158 | |||
| 7f665b96a5 | |||
| 6b80b39d4d | |||
| 8926c15908 | |||
| 033c45b7a0 | |||
| cbf138b1eb | |||
| 897f8fa9f2 | |||
| 8feb44225d | |||
| 517e337049 | |||
| c05231cf58 | |||
| 66b1007ab4 | |||
| 16d75fe498 | |||
| 62413b8df5 | |||
| fe2e1568fa | |||
| f93c259977 | |||
| 7e057bab6e | |||
| 910ff6a6dd | |||
| 22e5bcbde3 | |||
| 4bf8308bff | |||
| a77cbf903b | |||
| 9b4416952f | |||
| a320b5bd5a | |||
| 34a1f117c9 | |||
| ec4700ac38 | |||
| 6af3f2fe35 | |||
| b61d8df484 | |||
| fc3748e516 | |||
| 468dcd7ba4 | |||
| 85047874b7 | |||
| 52bf1a6988 | |||
| 27746f5c2b | |||
| d3710a755e | |||
| 5c8dcd7ed2 | |||
| 5c0b3744ee | |||
| 7048f132c6 | |||
| 1f3467d75f | |||
| 238cdc8084 | |||
| a1d8597b4f | |||
| 15dc718211 | |||
| 1db12e66c6 | |||
| 580283ef45 | |||
| 5de19652f2 | |||
| fd648a7dd3 | |||
| 76b5bd594d | |||
| 61b55c9230 | |||
| 22aecb56ec | |||
| 4d4f3be717 | |||
| 6e481f6a34 | |||
| 2059e4bb95 | |||
| 3586a010a8 | |||
| 146fc90746 | |||
| 4452d7bf3d | |||
| 673678e80a | |||
| b51960e925 | |||
| 6a5186c411 | |||
| b5ea9d68e2 | |||
| 71e96930c9 | |||
| d9be0df8fb | |||
| 0477002e85 | |||
| 68f1c6f97d | |||
| 6f85ce7116 | |||
| d920492afe | |||
| d69a54de38 | |||
| 919d117a1f | |||
| d4b289d0ca | |||
| cbb1df1522 | |||
| 3b0e98fc4a | |||
| a29eb52e1a | |||
| 270e8e41dd | |||
| 16eb1b51e7 | |||
| 751b82dc51 | |||
| 320e30c857 | |||
| e4c84e2972 | |||
| 527ff672d9 | |||
| aa24268a2e | |||
| 39e4c3a09c | |||
| a6898c8235 | |||
| 8158ace0eb | |||
| 463ca05404 | |||
| f38ce7b61b | |||
| 95a1b39fb1 | |||
| f58be7754a | |||
| a31c3ee00a | |||
| b1a36d546b | |||
| 278cac8a61 | |||
| 07fd1e87d7 | |||
| d93bd27896 | |||
| be56209baf | |||
| 6a573d0da7 | |||
| ca2504edb6 | |||
| e936e330d9 | |||
| 07bedd847e | |||
| bda95fc03d | |||
| ae2680c419 | |||
| 7777048790 | |||
| 1bdff9e7fe | |||
| 8fab1802df | |||
| 6cf6ade6e3 | |||
| 2399ba41e4 | |||
| fe2fb0c08d | |||
| bfffcda0c5 | |||
| e96ceab1e3 | |||
| 4bc78e7bb4 | |||
| 8203492999 | |||
| 910f453ce8 | |||
| 76b7099a37 | |||
| 85f428fda6 | |||
| 41fb12d58b | |||
| 984807d611 | |||
| 250c85c077 | |||
| dbd92bfdfa | |||
| 954d86ed0f | |||
| 4b335fc796 | |||
| 5e177412e2 | |||
| 1dd5eb3368 | |||
| 5a491aea3e | |||
| 2d7c5ec2df | |||
| dec13334db | |||
| 38079e8692 | |||
| ac75675367 | |||
| a0fc634f5f | |||
| 2ebade4413 | |||
| da1bc5d2d6 | |||
| 9d5388a7bf | |||
| 2cdb04656d | |||
| 3934c28eb8 | |||
| f6337bb12c | |||
| 1d88830b38 | |||
| 9737038776 | |||
| 915c3497e4 | |||
| 53c4f320f6 | |||
| 1aec69965d | |||
| afdac778b0 | |||
| fbc42a514f | |||
| 686b719bff | |||
| f05fa7c0ee | |||
| 0d646a32c4 | |||
| 917c33e76d | |||
| 1937895a56 | |||
| 01fbf07c9e | |||
| d208215814 | |||
| 5c5a18de0d | |||
| 9f24bda011 | |||
| fdb9eaa2a5 | |||
| 3e9b0ffbda | |||
| eb2ba042ef | |||
| 1111f421d9 | |||
| e2bda52737 | |||
| 6c9c2cf538 | |||
| 62d826d8c6 | |||
| dfbdb869d7 | |||
| 526a21da57 | |||
| fb6bda209b | |||
| 4b0f79a1ab | |||
| e5946892c9 | |||
| d399027127 | |||
| 2e732ce62f | |||
| c8ebcfac87 | |||
| 44e6774c5a | |||
| 2931c4b53e | |||
| 460abc0d55 | |||
| 01b2aaedb2 | |||
| 580c896b72 | |||
| 03a1d9fa4c | |||
| 61d199a0c1 | |||
| 54a0c7f231 | |||
| a4d60a1ae1 | |||
| b7b3e0dd65 | |||
| c28a6bf1ea | |||
| 9f24254cc7 | |||
| e105eca426 | |||
| 02a923afb4 | |||
| c7a0996a6c | |||
| 6d27231e15 | |||
| a2a5ef8fcd | |||
| 1c877ebe59 | |||
| f03248ca86 | |||
| a4005412a7 | |||
| e50016259a | |||
| d5a6c935e5 | |||
| aa3d4cb3ce | |||
| 130de28e4b | |||
| 122a54f510 | |||
| b425405744 | |||
| 28ffd27fca | |||
| 9bc9d86dd6 | |||
| a1891b597f | |||
| bf9ce4f535 | |||
| 508d8f25db | |||
| efbfcaed37 | |||
| deb90037d5 | |||
| d1fc31ac28 | |||
| b8efe6c554 | |||
| 13410f8467 | |||
| 3a389147dd | |||
| ba203f734d | |||
| 758454747d | |||
| bf175e92a3 | |||
| 0c9b5821e7 | |||
| 98dae842ae | |||
| ff53c1b474 | |||
| 334f9602b4 | |||
| fed94358fe | |||
| 89b669e319 | |||
| db213d3ae4 | |||
| 79df81301f | |||
| 197bbf7027 | |||
| a466592bc2 | |||
| 4bce73d81d | |||
| ed13e54d26 | |||
| e371f7ccf1 | |||
| 14a0e4713c | |||
| 74b9a426c2 | |||
| 43c7e2c9a8 | |||
| 39b9c28607 | |||
| 6e57d7e4e7 | |||
| f831d9a22d | |||
| 930165a993 | |||
| 7f54430813 | |||
| ea42899b9e | |||
| b420fd731f | |||
| dbbf4d04f9 | |||
| fe2b631c87 | |||
| 62132c27bd | |||
| e4449d7aa9 | |||
| cb304293b7 | |||
| ffb62243a9 | |||
| 63a80580cc | |||
| fed142690b | |||
| 8d368ca91c | |||
| 2cc2434982 | |||
| f5989b979a | |||
| 62955d5f6e | |||
| cb68e4389e | |||
| 9fc3fcabcb | |||
| 6af0b89c1d | |||
| c34b9e00e5 | |||
| e715da8680 | |||
| 7a26c345c5 | |||
| 2a6e76a2bc | |||
| adfc79938d | |||
| c3ce1d2756 | |||
| cf5208d6a5 | |||
| 56e6a0a3b8 | |||
| 0a7ad2f560 | |||
| fede5921e1 | |||
| 897ea781b7 | |||
| f95014f46f | |||
| 92fae52a6d | |||
| afb0f44af2 | |||
| af20b1f63d | |||
| c779654a58 | |||
| d1c99891c6 | |||
| ffc94bf455 | |||
| 680c83853a | |||
| 33e698242c | |||
| e8ad643a0e | |||
| 609e3bc158 | |||
| 7e51dd143a | |||
| 31d65dea7c | |||
| 89172a9047 | |||
| 0103717241 | |||
| c012662402 | |||
| 0f1cb37153 | |||
| 95bad7b071 | |||
| 00c3085a90 | |||
| f1fa861c8a | |||
| c37f96da2d | |||
| 89473c5ba0 | |||
| 07afc6e4c3 | |||
| 05404c1bad | |||
| b0e810013d | |||
| 34c34018a0 | |||
| 05dd636a1c | |||
| e6158043b9 | |||
| cfd1dcc3ee | |||
| 7a2944ce58 | |||
| 8a11fa5aac | |||
| aa2127b55f | |||
| 86a2d66d83 | |||
| 9b3b6caef9 | |||
| 2aeec01f1e | |||
| 70412f5f8e | |||
| b1885e5b91 | |||
| 8e2d1e2c16 |
@ -6,12 +6,13 @@ import os
|
||||
if not base.is_dir("glm"):
|
||||
base.cmd("git", ["clone", "https://github.com/g-truc/glm.git"])
|
||||
base.cmd_in_dir("glm", "git", ["checkout", "33b4a621a697a305bc3a7610d290677b96beb181", "--quiet"])
|
||||
base.replaceInFile("./glm/glm/detail/func_common.inl", "vec<L, T, Q> v;", "vec<L, T, Q> v{};")
|
||||
|
||||
if not base.is_dir("mdds"):
|
||||
base.cmd("git", ["clone", "https://github.com/kohei-us/mdds.git"])
|
||||
base.cmd_in_dir("mdds", "git", ["checkout", "0783158939c6ce4b0b1b89e345ab983ccb0f0ad0"], "--quiet")
|
||||
|
||||
fix_cpp_version = "#if __cplusplus < 201402L\n"
|
||||
fix_cpp_version = "#if __cplusplus < 201703L\n"
|
||||
fix_cpp_version += "#ifndef _MSC_VER\n"
|
||||
fix_cpp_version += "namespace std {\n"
|
||||
fix_cpp_version += " template<bool __v>\n"
|
||||
|
||||
@ -3,6 +3,8 @@ DEPENDPATH += $$PWD
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri)
|
||||
|
||||
css_calculator_without_xhtml {
|
||||
HEADERS += \
|
||||
$$PWD/src/CCssCalculator_Private.h \
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
|
||||
#include <iostream>
|
||||
#include "../../../../../DesktopEditor/common/File.h"
|
||||
#include "StaticFunctions.h"
|
||||
#include "ConstValues.h"
|
||||
@ -18,14 +17,16 @@ namespace NSCSS
|
||||
{
|
||||
typedef std::map<std::wstring, std::wstring>::const_iterator styles_iterator;
|
||||
|
||||
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Point), m_dCoreFontSize(DEFAULT_FONT_SIZE)
|
||||
CCompiledStyle::CCompiledStyle()
|
||||
: m_nDpi(96), m_UnitMeasure(Point), m_dCoreFontSize(DEFAULT_FONT_SIZE)
|
||||
{}
|
||||
|
||||
CCompiledStyle::CCompiledStyle(const CCompiledStyle& oStyle) :
|
||||
m_arParentsStyles(oStyle.m_arParentsStyles), m_sId(oStyle.m_sId),
|
||||
m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure), m_dCoreFontSize(oStyle.m_dCoreFontSize),
|
||||
m_oFont(oStyle.m_oFont), m_oMargin(oStyle.m_oMargin), m_oPadding(oStyle.m_oPadding), m_oBackground(oStyle.m_oBackground),
|
||||
m_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay), m_oTransform(oStyle.m_oTransform){}
|
||||
m_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay), m_oTransform(oStyle.m_oTransform)
|
||||
{}
|
||||
|
||||
CCompiledStyle::~CCompiledStyle()
|
||||
{
|
||||
@ -34,6 +35,8 @@ namespace NSCSS
|
||||
|
||||
CCompiledStyle& CCompiledStyle::operator+= (const CCompiledStyle &oElement)
|
||||
{
|
||||
m_arParentsStyles.insert(oElement.m_arParentsStyles.begin(), oElement.m_arParentsStyles.end());
|
||||
|
||||
if (oElement.Empty())
|
||||
return *this;
|
||||
|
||||
@ -49,8 +52,6 @@ namespace NSCSS
|
||||
if (!oElement.m_sId.empty())
|
||||
m_sId += L'+' + oElement.m_sId;
|
||||
|
||||
m_arParentsStyles.insert(oElement.m_arParentsStyles.begin(), oElement.m_arParentsStyles.end());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@ -15,29 +15,33 @@ inline static std::wstring StringifyValueList(const KatanaArray* oValues);
|
||||
inline static std::wstring StringifyValue(const KatanaValue* oValue);
|
||||
inline static bool IsTableElement(const std::wstring& wsNameTag);
|
||||
|
||||
bool operator<(const std::vector<NSCSS::CNode> &arLeftSelectors, const std::vector<NSCSS::CNode> &arRightSelectors)
|
||||
{
|
||||
const size_t& sizeLeftSelectors = arLeftSelectors.size();
|
||||
const size_t& sizeRightSelectors = arRightSelectors.size();
|
||||
|
||||
if (sizeLeftSelectors < sizeRightSelectors)
|
||||
return true;
|
||||
else if (sizeLeftSelectors > sizeRightSelectors)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < arLeftSelectors.size(); ++i)
|
||||
{
|
||||
if (arLeftSelectors[i] < arRightSelectors[i])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
bool operator<(const std::vector<NSCSS::CNode> &arLeftSelectors, const std::vector<NSCSS::CNode> &arRightSelectors)
|
||||
{
|
||||
if (arLeftSelectors.size() < arRightSelectors.size())
|
||||
return true;
|
||||
else if (arLeftSelectors.size() > arRightSelectors.size())
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < arLeftSelectors.size(); ++i)
|
||||
{
|
||||
if (arLeftSelectors[i] == arRightSelectors[i])
|
||||
continue;
|
||||
|
||||
if (arLeftSelectors[i] < arRightSelectors[i])
|
||||
return true;
|
||||
else if (arRightSelectors[i] < arLeftSelectors[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CStyleStorage::CStyleStorage()
|
||||
{}
|
||||
{
|
||||
InitDefaultStyles();
|
||||
}
|
||||
|
||||
CStyleStorage::~CStyleStorage()
|
||||
{
|
||||
@ -62,6 +66,7 @@ namespace NSCSS
|
||||
m_arEmptyStyleFiles.clear();
|
||||
|
||||
ClearEmbeddedStyles();
|
||||
ClearDefaultStyles();
|
||||
ClearAllowedStyleFiles();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
@ -208,6 +213,16 @@ namespace NSCSS
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const CElement* CStyleStorage::FindDefaultElement(const std::wstring& wsSelector) const
|
||||
{
|
||||
if (wsSelector.empty())
|
||||
return nullptr;
|
||||
|
||||
const CElement* pFoundElement = FindSelectorFromStyleData(wsSelector, m_mDefaultStyleData);
|
||||
|
||||
return (nullptr != pFoundElement) ? pFoundElement : nullptr;
|
||||
}
|
||||
|
||||
void CStyleStorage::AddStyles(const std::string& sStyle, std::map<std::wstring, CElement*>& mStyleData)
|
||||
{
|
||||
if (sStyle.empty())
|
||||
@ -227,6 +242,15 @@ namespace NSCSS
|
||||
m_mEmbeddedStyleData.clear();
|
||||
}
|
||||
|
||||
void CStyleStorage::ClearDefaultStyles()
|
||||
{
|
||||
for (std::map<std::wstring, CElement*>::iterator oIter = m_mDefaultStyleData.begin(); oIter != m_mDefaultStyleData.end(); ++oIter)
|
||||
if (oIter->second != nullptr)
|
||||
delete oIter->second;
|
||||
|
||||
m_mDefaultStyleData.clear();
|
||||
}
|
||||
|
||||
void CStyleStorage::ClearAllowedStyleFiles()
|
||||
{
|
||||
m_arAllowedStyleFiles.clear();
|
||||
@ -480,7 +504,33 @@ namespace NSCSS
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_sEncoding(L"UTF-8"){}
|
||||
void CStyleStorage::InitDefaultStyles()
|
||||
{
|
||||
m_mDefaultStyleData[L"b"] = new CElement(L"b", {{L"font-weight", L"bold"}});
|
||||
m_mDefaultStyleData[L"center"] = new CElement(L"center", {{L"text-align", L"center"}});
|
||||
m_mDefaultStyleData[L"i"] = new CElement(L"i", {{L"font-style", L"italic"}});
|
||||
m_mDefaultStyleData[L"code"] = new CElement(L"code", {{L"font-family", L"Courier New"}});
|
||||
m_mDefaultStyleData[L"kbd"] = new CElement(L"kbd", {{L"font-family", L"Courier New"},
|
||||
{L"font_weight", L"bold"}});
|
||||
m_mDefaultStyleData[L"s"] = new CElement(L"s", {{L"text-decoration", L"line-through"}});
|
||||
m_mDefaultStyleData[L"u"] = new CElement(L"u", {{L"text-decoration", L"underline"}});
|
||||
m_mDefaultStyleData[L"mark"] = new CElement(L"mark", {{L"background-color", L"yellow"}});
|
||||
m_mDefaultStyleData[L"sup"] = new CElement(L"sup", {{L"vertical-align", L"top"}});
|
||||
m_mDefaultStyleData[L"sub"] = new CElement(L"sub", {{L"vertical-align", L"bottom"}});
|
||||
m_mDefaultStyleData[L"dd"] = new CElement(L"dd", {{L"margin-left", L"720tw"}});
|
||||
m_mDefaultStyleData[L"pre"] = new CElement(L"pre", {{L"font-family", L"Courier New"},
|
||||
{L"margin-top", L"0"},
|
||||
{L"margin-bottom", L"0"}});
|
||||
m_mDefaultStyleData[L"blockquote"] = new CElement(L"blockquote", {{L"margin", L"0px"}});
|
||||
m_mDefaultStyleData[L"ul"] = new CElement(L"ul", {{L"margin-top", L"100tw"},
|
||||
{L"margin-bottom", L"100tw"}});
|
||||
m_mDefaultStyleData[L"textarea"] = new CElement(L"textarea", {{L"border", L"1px solid black"}});
|
||||
}
|
||||
|
||||
CCssCalculator_Private::CCssCalculator_Private()
|
||||
: m_nDpi(96), m_nCountNodes(0), m_sEncoding(L"UTF-8")
|
||||
{
|
||||
}
|
||||
|
||||
CCssCalculator_Private::~CCssCalculator_Private()
|
||||
{}
|
||||
@ -503,17 +553,25 @@ namespace NSCSS
|
||||
arSelectors.back().m_pCompiledStyle->m_oBorder.Clear();
|
||||
}
|
||||
|
||||
if (arSelectors.size() > 1)
|
||||
arSelectors.back().m_pCompiledStyle->AddParent(arSelectors[arSelectors.size() - 2].m_wsName);
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetID(L"text-" + std::to_wstring(++m_nCountNodes));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::const_iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
if (oItem != m_mUsedStyles.cend() && (arSelectors.back().m_wsId.empty() || !HaveStylesById(arSelectors.back().m_wsId)))
|
||||
{
|
||||
arSelectors.back().SetCompiledStyle(new CCompiledStyle(oItem->second));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!arSelectors.back().m_pCompiledStyle->Empty())
|
||||
return true;
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetDpi(m_nDpi);
|
||||
unsigned int unStart = 0;
|
||||
|
||||
@ -522,7 +580,7 @@ namespace NSCSS
|
||||
if (itFound != arSelectors.crend())
|
||||
unStart = itFound.base() - arSelectors.cbegin();
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors, unStart);
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors, unStart, arSelectors.size());
|
||||
std::vector<std::wstring> arPrevNodes = CalculateAllNodes(arSelectors, 0, unStart);
|
||||
bool bInTable = false;
|
||||
|
||||
@ -539,7 +597,8 @@ namespace NSCSS
|
||||
if (0 != i)
|
||||
*arSelectors[i].m_pCompiledStyle += *arSelectors[i - 1].m_pCompiledStyle;
|
||||
|
||||
arSelectors[i].m_pCompiledStyle->AddParent(arSelectors[i].m_wsName);
|
||||
if (i != arSelectors.size() - 1)
|
||||
arSelectors[i].m_pCompiledStyle->AddParent(arSelectors[i].m_wsName);
|
||||
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
@ -548,6 +607,7 @@ namespace NSCSS
|
||||
{
|
||||
arSelectors[i].m_pCompiledStyle->m_oBackground.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oBorder.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oDisplay.Clear();
|
||||
}
|
||||
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
@ -594,7 +654,7 @@ namespace NSCSS
|
||||
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors, unsigned int unStart, unsigned int unEnd)
|
||||
{
|
||||
if (0 != unEnd && (unEnd < unStart || unEnd > arSelectors.size()))
|
||||
if ((0 != unEnd && (unEnd < unStart || unEnd > arSelectors.size())) || (unStart == unEnd))
|
||||
return std::vector<std::wstring>();
|
||||
|
||||
std::vector<std::wstring> arNodes;
|
||||
@ -611,8 +671,8 @@ namespace NSCSS
|
||||
std::vector<std::wstring> arClasses = NS_STATIC_FUNCTIONS::GetWordsW(oNode->m_wsClass, false, L" ");
|
||||
|
||||
arNodes.push_back(std::accumulate(arClasses.begin(), arClasses.end(), std::wstring(),
|
||||
[](std::wstring sRes, const std::wstring& sClass)
|
||||
{return sRes += L'.' + sClass + L' ';}));
|
||||
[](std::wstring sRes, const std::wstring& sClass)
|
||||
{return sRes += L'.' + sClass + L' ';}));
|
||||
}
|
||||
else
|
||||
arNodes.push_back(L'.' + oNode->m_wsClass);
|
||||
@ -630,7 +690,7 @@ namespace NSCSS
|
||||
if (arNextNodes.empty())
|
||||
return;
|
||||
|
||||
const std::vector<CElement*> arTempPrev = pElement->GetPrevElements(arNextNodes.crbegin() + 1, arNextNodes.crend());
|
||||
const std::vector<CElement*> arTempPrev = pElement->GetPrevElements(arNextNodes.cbegin(), arNextNodes.cend());
|
||||
const std::vector<CElement*> arTempKins = pElement->GetNextOfKin(wsName, arClasses);
|
||||
|
||||
if (!arTempPrev.empty())
|
||||
@ -640,6 +700,36 @@ namespace NSCSS
|
||||
arFindedElements.insert(arFindedElements.end(), arTempKins.begin(), arTempKins.end());
|
||||
}
|
||||
|
||||
inline std::wstring GetAlternativeDefaultNodeName(const std::wstring& wsNodeName)
|
||||
{
|
||||
if (L"strong" == wsNodeName)
|
||||
return L"b";
|
||||
|
||||
if (L"cite" == wsNodeName || L"dfn" == wsNodeName || L"em" == wsNodeName ||
|
||||
L"var" == wsNodeName || L"adress" == wsNodeName)
|
||||
return L"i";
|
||||
|
||||
if (L"tt" == wsNodeName || L"samp" == wsNodeName)
|
||||
return L"code";
|
||||
|
||||
if (L"strike" == wsNodeName || L"del" == wsNodeName)
|
||||
return L"s";
|
||||
|
||||
if (L"ins" == wsNodeName)
|
||||
return L"u";
|
||||
|
||||
if (L"xmp" == wsNodeName || L"nobr" == wsNodeName)
|
||||
return L"pre";
|
||||
|
||||
if (L"ol" == wsNodeName)
|
||||
return L"ul";
|
||||
|
||||
if (L"fieldset" == wsNodeName)
|
||||
return L"textarea";
|
||||
|
||||
return wsNodeName;
|
||||
}
|
||||
|
||||
std::vector<const CElement*> CCssCalculator_Private::FindElements(std::vector<std::wstring> &arNodes, std::vector<std::wstring> &arNextNodes)
|
||||
{
|
||||
if (arNodes.empty())
|
||||
@ -647,20 +737,19 @@ namespace NSCSS
|
||||
|
||||
std::vector<const CElement*> arFindedElements;
|
||||
|
||||
std::wstring wsName, wsId;
|
||||
std::wstring wsName, wsClasses, wsId;
|
||||
std::vector<std::wstring> arClasses;
|
||||
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'#')
|
||||
{
|
||||
wsId = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsId);
|
||||
}
|
||||
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'.')
|
||||
{
|
||||
arClasses = NS_STATIC_FUNCTIONS::GetWordsW(arNodes.back(), false, L" ");
|
||||
arNextNodes.push_back(arNodes.back());
|
||||
wsClasses = arNodes.back();
|
||||
arClasses = NS_STATIC_FUNCTIONS::GetWordsW(wsClasses, false, L" ");
|
||||
arNodes.pop_back();
|
||||
}
|
||||
|
||||
@ -668,7 +757,6 @@ namespace NSCSS
|
||||
{
|
||||
wsName = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsName);
|
||||
}
|
||||
|
||||
if (!wsId.empty())
|
||||
@ -700,6 +788,11 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
const CElement* pFoundDefault = m_oStyleStorage.FindDefaultElement(GetAlternativeDefaultNodeName(wsName));
|
||||
|
||||
if (nullptr != pFoundDefault)
|
||||
arFindedElements.push_back(pFoundDefault);
|
||||
|
||||
const CElement* pFoundName = m_oStyleStorage.FindElement(wsName);
|
||||
|
||||
if (nullptr != pFoundName)
|
||||
@ -727,6 +820,14 @@ namespace NSCSS
|
||||
{ return oFirstElement->GetWeight() > oSecondElement->GetWeight(); });
|
||||
}
|
||||
|
||||
if (!wsId.empty())
|
||||
arNextNodes.push_back(wsId);
|
||||
|
||||
if (!wsClasses.empty())
|
||||
arNextNodes.push_back(wsClasses);
|
||||
|
||||
arNextNodes.push_back(wsName);
|
||||
|
||||
return arFindedElements;
|
||||
}
|
||||
|
||||
@ -741,7 +842,7 @@ namespace NSCSS
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors);
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors, 0, arSelectors.size());
|
||||
std::vector<std::wstring> arNextNodes;
|
||||
|
||||
for (size_t i = 0; i < arSelectors.size(); ++i)
|
||||
|
||||
@ -27,6 +27,7 @@ namespace NSCSS
|
||||
void AddStylesFromFile(const std::wstring& wsFileName);
|
||||
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearDefaultStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
void ClearStylesFromFile(const std::wstring& wsFileName);
|
||||
|
||||
@ -38,6 +39,7 @@ namespace NSCSS
|
||||
#endif
|
||||
|
||||
const CElement* FindElement(const std::wstring& wsSelector) const;
|
||||
const CElement* FindDefaultElement(const std::wstring& wsSelector) const;
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
@ -49,6 +51,7 @@ namespace NSCSS
|
||||
std::set<std::wstring> m_arAllowedStyleFiles;
|
||||
std::vector<TStyleFileData*> m_arStyleFiles;
|
||||
std::map<std::wstring, CElement*> m_mEmbeddedStyleData;
|
||||
std::map<std::wstring, CElement*> m_mDefaultStyleData;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
typedef struct
|
||||
@ -78,6 +81,8 @@ 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;
|
||||
|
||||
void InitDefaultStyles();
|
||||
};
|
||||
|
||||
class CCssCalculator_Private
|
||||
@ -110,7 +115,7 @@ namespace NSCSS
|
||||
void ClearPageData();
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors, unsigned int unStart = 0, unsigned int unEnd = 0);
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors, unsigned int unStart, unsigned int unEnd);
|
||||
std::vector<const CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes);
|
||||
|
||||
void AddStyles(const std::string& sStyle);
|
||||
|
||||
@ -9,6 +9,13 @@ namespace NSCSS
|
||||
CElement::CElement()
|
||||
{
|
||||
}
|
||||
|
||||
CElement::CElement(const std::wstring& wsSelector, std::map<std::wstring, std::wstring> mStyle)
|
||||
: m_mStyle(mStyle), m_sSelector(wsSelector), m_sFullSelector(wsSelector)
|
||||
{
|
||||
UpdateWeight();
|
||||
}
|
||||
|
||||
CElement::~CElement()
|
||||
{
|
||||
for (CElement* oElement : m_arPrevElements)
|
||||
@ -18,7 +25,6 @@ namespace NSCSS
|
||||
continue;
|
||||
|
||||
m_mStyle.clear();
|
||||
|
||||
}
|
||||
|
||||
std::wstring CElement::GetSelector() const
|
||||
@ -176,14 +182,14 @@ namespace NSCSS
|
||||
return arElements;
|
||||
}
|
||||
|
||||
std::vector<CElement *> CElement::GetPrevElements(const std::vector<std::wstring>::const_reverse_iterator& oNodesRBegin, const std::vector<std::wstring>::const_reverse_iterator& oNodesREnd) const
|
||||
std::vector<CElement *> CElement::GetPrevElements(const std::vector<std::wstring>::const_iterator& oNodesBegin, const std::vector<std::wstring>::const_iterator& oNodesEnd) const
|
||||
{
|
||||
if (oNodesRBegin >= oNodesREnd || m_arPrevElements.empty())
|
||||
if (oNodesBegin >= oNodesEnd || m_arPrevElements.empty())
|
||||
return std::vector<CElement*>();
|
||||
|
||||
std::vector<CElement*> arElements;
|
||||
|
||||
for (std::vector<std::wstring>::const_reverse_iterator iWord = oNodesRBegin; iWord != oNodesREnd; ++iWord)
|
||||
for (std::vector<std::wstring>::const_iterator iWord = oNodesBegin; iWord != oNodesEnd; ++iWord)
|
||||
{
|
||||
if ((*iWord)[0] == L'.' && ((*iWord).find(L" ") != std::wstring::npos))
|
||||
{
|
||||
@ -195,7 +201,7 @@ namespace NSCSS
|
||||
if (oPrevElement->m_sSelector == wsClass)
|
||||
{
|
||||
arElements.push_back(oPrevElement);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesREnd);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesEnd);
|
||||
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
|
||||
}
|
||||
}
|
||||
@ -208,9 +214,8 @@ namespace NSCSS
|
||||
if (oPrevElement->m_sSelector == *iWord)
|
||||
{
|
||||
arElements.push_back(oPrevElement);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesREnd);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesEnd);
|
||||
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
|
||||
// return arElements;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ namespace NSCSS
|
||||
|
||||
public:
|
||||
CElement();
|
||||
CElement(const std::wstring& wsSelector, std::map<std::wstring, std::wstring> mStyle);
|
||||
~CElement();
|
||||
|
||||
std::wstring GetSelector() const;
|
||||
@ -39,7 +40,7 @@ namespace NSCSS
|
||||
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<CNode>& arSelectors) const;
|
||||
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<std::wstring>& arNodes) const;
|
||||
std::vector<CElement *> GetNextOfKin(const std::wstring& sName, const std::vector<std::wstring>& arClasses = {}) const;
|
||||
std::vector<CElement *> GetPrevElements(const std::vector<std::wstring>::const_reverse_iterator& oNodesRBegin, const std::vector<std::wstring>::const_reverse_iterator& oNodesREnd) const;
|
||||
std::vector<CElement *> GetPrevElements(const std::vector<std::wstring>::const_iterator& oNodesBegin, const std::vector<std::wstring>::const_iterator& oNodesEnd) const;
|
||||
std::map<std::wstring, std::wstring> GetConvertStyle(const std::vector<CNode>& arNodes) const;
|
||||
|
||||
CElement *FindPrevElement(const std::wstring& sSelector) const;
|
||||
|
||||
@ -17,8 +17,7 @@ namespace NSCSS
|
||||
m_wsStyle(oNode.m_wsStyle), m_mAttributes(oNode.m_mAttributes)
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
m_pCompiledStyle = new CCompiledStyle();
|
||||
*m_pCompiledStyle = *oNode.m_pCompiledStyle;
|
||||
m_pCompiledStyle = new CCompiledStyle(*oNode.m_pCompiledStyle);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -42,6 +41,23 @@ namespace NSCSS
|
||||
return m_wsName.empty() && m_wsClass.empty() && m_wsId.empty() && m_wsStyle.empty();
|
||||
}
|
||||
|
||||
bool CNode::GetAttributeValue(const std::wstring& wsAttributeName, std::wstring& wsAttributeValue) const
|
||||
{
|
||||
const std::map<std::wstring, std::wstring>::const_iterator itFound{m_mAttributes.find(wsAttributeName)};
|
||||
|
||||
if (m_mAttributes.cend() == itFound)
|
||||
return false;
|
||||
|
||||
wsAttributeValue = itFound->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring CNode::GetAttributeValue(const std::wstring& wsAttributeName) const
|
||||
{
|
||||
const std::map<std::wstring, std::wstring>::const_iterator itFound{m_mAttributes.find(wsAttributeName)};
|
||||
return (m_mAttributes.cend() != itFound) ? itFound->second : std::wstring();
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void CNode::SetCompiledStyle(CCompiledStyle* pCompiledStyle)
|
||||
{
|
||||
@ -86,6 +102,9 @@ namespace NSCSS
|
||||
if(m_wsStyle != oNode.m_wsStyle)
|
||||
return m_wsStyle < oNode.m_wsStyle;
|
||||
|
||||
if (m_mAttributes.size() != oNode.m_mAttributes.size())
|
||||
return m_mAttributes.size() < oNode.m_mAttributes.size();
|
||||
|
||||
if (m_mAttributes != oNode.m_mAttributes)
|
||||
return m_mAttributes < oNode.m_mAttributes;
|
||||
|
||||
@ -94,10 +113,9 @@ namespace NSCSS
|
||||
|
||||
bool CNode::operator==(const CNode& oNode) const
|
||||
{
|
||||
return((m_wsId == oNode.m_wsId) &&
|
||||
(m_wsName == oNode.m_wsName) &&
|
||||
(m_wsClass == oNode.m_wsClass) &&
|
||||
(m_wsStyle == oNode.m_wsStyle) &&
|
||||
(m_mAttributes == oNode.m_mAttributes));
|
||||
return((m_wsName == oNode.m_wsName) &&
|
||||
(m_wsClass == oNode.m_wsClass) &&
|
||||
(m_wsStyle == oNode.m_wsStyle) &&
|
||||
(m_mAttributes == oNode.m_mAttributes));
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,9 @@ namespace NSCSS
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
bool GetAttributeValue(const std::wstring& wsAttributeName, std::wstring& wsAttributeValue) const;
|
||||
std::wstring GetAttributeValue(const std::wstring& wsAttributeName) const;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void SetCompiledStyle(CCompiledStyle* pCompiledStyle);
|
||||
#endif
|
||||
|
||||
@ -149,7 +149,7 @@ namespace NSCSS
|
||||
case NSCSS::Millimeter:
|
||||
return dValue * 0.01764;
|
||||
case NSCSS::Inch:
|
||||
return dValue * 1440.;
|
||||
return dValue / 1440.;
|
||||
case NSCSS::Peak:
|
||||
return dValue * 0.004167; // 0.004167 = 6 / 1440
|
||||
default:
|
||||
|
||||
@ -69,7 +69,10 @@ namespace NSCSS
|
||||
R_Highlight,
|
||||
R_Shd,
|
||||
R_SmallCaps,
|
||||
R_Kern
|
||||
R_Kern,
|
||||
R_Vanish,
|
||||
R_Strike,
|
||||
R_VertAlign
|
||||
} RunnerProperties;
|
||||
|
||||
typedef enum
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -4,11 +4,14 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include "../../../../DesktopEditor/graphics/Matrix.h"
|
||||
#include "CUnitMeasureConverter.h"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include "boost/blank.hpp"
|
||||
#include <boost/variant2/variant.hpp>
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
namespace NSProperties
|
||||
@ -16,33 +19,34 @@ namespace NSCSS
|
||||
#define NEXT_LEVEL UINT_MAX, true
|
||||
|
||||
template<typename T>
|
||||
class CValue
|
||||
class CValueBase
|
||||
{
|
||||
friend class CString;
|
||||
friend class CMatrix;
|
||||
friend class CDigit;
|
||||
friend class CColor;
|
||||
friend class CEnum;
|
||||
friend class CURL;
|
||||
protected:
|
||||
CValueBase()
|
||||
: m_unLevel(0), m_bImportant(false)
|
||||
{}
|
||||
CValueBase(const CValueBase& oValue)
|
||||
: m_oValue(oValue.m_oValue), m_unLevel(oValue.m_unLevel), m_bImportant(oValue.m_bImportant)
|
||||
{}
|
||||
|
||||
CValueBase(const T& oValue, unsigned int unLevel, bool bImportant)
|
||||
: m_oValue(oValue), m_unLevel(unLevel), m_bImportant(bImportant)
|
||||
{}
|
||||
|
||||
T m_oValue;
|
||||
unsigned int m_unLevel;
|
||||
bool m_bImportant;
|
||||
public:
|
||||
CValue(const T& oValue, unsigned int unLevel, bool bImportant) :
|
||||
m_oValue(oValue), m_unLevel(unLevel), m_bImportant(bImportant)
|
||||
{
|
||||
}
|
||||
virtual bool Empty() const = 0;
|
||||
virtual void Clear() = 0;
|
||||
|
||||
virtual bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) = 0;
|
||||
|
||||
virtual bool Empty() const = 0;
|
||||
virtual void Clear() = 0;
|
||||
virtual int ToInt() const = 0;
|
||||
virtual double ToDouble() const = 0;
|
||||
virtual std::wstring ToWString() const = 0;
|
||||
|
||||
static void Equation(CValue &oFirstValue, CValue &oSecondValue)
|
||||
static void Equation(CValueBase &oFirstValue, CValueBase &oSecondValue)
|
||||
{
|
||||
if (oFirstValue.m_bImportant && !oSecondValue.m_bImportant && oFirstValue.Empty())
|
||||
oSecondValue.Clear();
|
||||
@ -57,18 +61,39 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
static bool LevelIsSame(const CValue& oFirstValue, const CValue& oSecondValue)
|
||||
static bool LevelIsSame(const CValueBase& oFirstValue, const CValueBase& oSecondValue)
|
||||
{
|
||||
return oFirstValue.m_unLevel == oSecondValue.m_unLevel;
|
||||
}
|
||||
|
||||
bool operator==(const T& oValue) const { return m_oValue == oValue; }
|
||||
bool operator>=(const T& oValue) const { return m_oValue >= oValue; }
|
||||
bool operator<=(const T& oValue) const { return m_oValue <= oValue; }
|
||||
bool operator> (const T& oValue) const { return m_oValue > oValue; }
|
||||
bool operator< (const T& oValue) const { return m_oValue < oValue; }
|
||||
friend bool operator==(const CValueBase& oLeftValue, const CValueBase& oRightValue)
|
||||
{
|
||||
if (oLeftValue.Empty() && oRightValue.Empty())
|
||||
return true;
|
||||
|
||||
virtual CValue& operator =(const CValue& oValue)
|
||||
if (( oLeftValue.Empty() && !oRightValue.Empty()) ||
|
||||
(!oLeftValue.Empty() && oRightValue.Empty()))
|
||||
return false;
|
||||
|
||||
return oLeftValue.m_oValue == oRightValue.m_oValue;
|
||||
}
|
||||
|
||||
friend bool operator!=(const CValueBase& oLeftValue, const CValueBase& oRightValue)
|
||||
{
|
||||
return !(oLeftValue == oRightValue);
|
||||
}
|
||||
|
||||
bool operator==(const T& oValue) const
|
||||
{
|
||||
return m_oValue == oValue;
|
||||
}
|
||||
|
||||
bool operator!=(const T& oValue) const
|
||||
{
|
||||
return m_oValue != oValue;
|
||||
}
|
||||
|
||||
virtual CValueBase& operator =(const CValueBase& oValue)
|
||||
{
|
||||
m_oValue = oValue.m_oValue;
|
||||
m_unLevel = oValue.m_unLevel;
|
||||
@ -77,70 +102,93 @@ namespace NSCSS
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual CValue& operator =(const T& oValue)
|
||||
virtual CValueBase& operator =(const T& oValue)
|
||||
{
|
||||
//m_oValue = oValue.m_oValue;
|
||||
m_oValue = oValue;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual CValue& operator+=(const CValue& oValue)
|
||||
virtual CValueBase& operator+=(const CValueBase& oValue)
|
||||
{
|
||||
if (m_unLevel > oValue.m_unLevel || (m_bImportant && !oValue.m_bImportant) || oValue.Empty())
|
||||
return *this;
|
||||
|
||||
m_oValue = oValue.m_oValue;
|
||||
m_unLevel = oValue.m_unLevel;
|
||||
m_bImportant = oValue.m_bImportant;
|
||||
*this = oValue;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
virtual bool operator==(const CValue& oValue) const
|
||||
template<typename T>
|
||||
class CValueOptional : public CValueBase<boost::optional<T>>
|
||||
{
|
||||
protected:
|
||||
CValueOptional() = default;
|
||||
|
||||
CValueOptional(const T& oValue, unsigned int unLevel = 0, bool bImportant = false)
|
||||
: CValueBase<boost::optional<T>>(oValue, unLevel, bImportant)
|
||||
{}
|
||||
public:
|
||||
virtual bool Empty() const override
|
||||
{
|
||||
return m_oValue == oValue.m_oValue;
|
||||
return !this->m_oValue.has_value();
|
||||
}
|
||||
void Clear() override
|
||||
{
|
||||
this->m_oValue.reset();
|
||||
this->m_unLevel = 0;
|
||||
this->m_bImportant = false;
|
||||
}
|
||||
|
||||
virtual bool operator!=(const CValue& oValue) const
|
||||
bool operator==(const T& oValue) const
|
||||
{
|
||||
return m_oValue != oValue.m_oValue;
|
||||
if (!this->m_oValue.has_value())
|
||||
return false;
|
||||
|
||||
return this->m_oValue.value() == oValue;
|
||||
}
|
||||
|
||||
virtual CValueOptional& operator=(const T& oValue)
|
||||
{
|
||||
this->m_oValue = oValue;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class CString : public CValue<std::wstring>
|
||||
class CString : public CValueOptional<std::wstring>
|
||||
{
|
||||
public:
|
||||
CString();
|
||||
CString(const std::wstring& wsValue, unsigned int unLevel, bool bImportant = false);
|
||||
CString() = default;
|
||||
CString(const std::wstring& wsValue, unsigned int unLevel = 0, bool bImportant = false);
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
|
||||
bool SetValue(const std::wstring& wsValue, const std::vector<std::wstring>& arValiableValues, unsigned int unLevel, bool bHardMode);
|
||||
bool SetValue(const std::wstring& wsValue, const std::map<std::wstring, std::wstring>& arValiableValues, unsigned int unLevel, bool bHardMode);
|
||||
|
||||
bool Empty() const override;
|
||||
void Clear() override;
|
||||
|
||||
int ToInt() const override;
|
||||
double ToDouble() const override;
|
||||
std::wstring ToWString() const override;
|
||||
|
||||
CString& operator+=(const CString& oString);
|
||||
bool operator==(const wchar_t* pValue) const;
|
||||
bool operator!=(const wchar_t* pValue) const;
|
||||
|
||||
using CValueOptional<std::wstring>::operator=;
|
||||
};
|
||||
|
||||
class CDigit : public CValue<double>
|
||||
class CDigit : public CValueOptional<double>
|
||||
{
|
||||
UnitMeasure m_enUnitMeasure;
|
||||
|
||||
double ConvertValue(double dPrevValue, UnitMeasure enUnitMeasure) const;
|
||||
public:
|
||||
CDigit();
|
||||
CDigit(double dValue);
|
||||
CDigit(double dValue, unsigned int unLevel, bool bImportant = false);
|
||||
CDigit(const double& dValue, unsigned int unLevel = 0, bool bImportant = false);
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
|
||||
bool SetValue(const CDigit& oValue);
|
||||
bool SetValue(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel = 0, bool bHardMode = true);
|
||||
|
||||
bool Empty() const override;
|
||||
bool Zero() const;
|
||||
void Clear() override;
|
||||
|
||||
@ -156,7 +204,7 @@ namespace NSCSS
|
||||
|
||||
UnitMeasure GetUnitMeasure() const;
|
||||
|
||||
bool operator==(const double& oValue) const;
|
||||
bool operator==(const double& dValue) const;
|
||||
bool operator==(const CDigit& oDigit) const;
|
||||
|
||||
bool operator!=(const double& oValue) const;
|
||||
@ -171,11 +219,19 @@ namespace NSCSS
|
||||
|
||||
CDigit& operator+=(const CDigit& oDigit);
|
||||
CDigit& operator-=(const CDigit& oDigit);
|
||||
CDigit& operator+=(double dValue);
|
||||
CDigit& operator-=(double dValue);
|
||||
CDigit& operator*=(double dValue);
|
||||
CDigit& operator/=(double dValue);
|
||||
CDigit& operator =(double dValue);
|
||||
CDigit& operator+=(const double& dValue);
|
||||
CDigit& operator-=(const double& dValue);
|
||||
CDigit& operator*=(const double& dValue);
|
||||
CDigit& operator/=(const double& dValue);
|
||||
|
||||
using CValueOptional<double>::operator=;
|
||||
private:
|
||||
UnitMeasure m_enUnitMeasure;
|
||||
|
||||
double ConvertValue(double dPrevValue, UnitMeasure enUnitMeasure) const;
|
||||
|
||||
template <typename Operation>
|
||||
CDigit ApplyOperation(const CDigit& oDigit, Operation operation) const;
|
||||
};
|
||||
|
||||
struct TRGB
|
||||
@ -186,6 +242,8 @@ namespace NSCSS
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
int ToInt() const;
|
||||
|
||||
bool operator==(const TRGB& oRGB) const;
|
||||
bool operator!=(const TRGB& oRGB) const;
|
||||
};
|
||||
@ -211,31 +269,58 @@ namespace NSCSS
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ColorEmpty,
|
||||
ColorNone,
|
||||
ColorRGB,
|
||||
ColorHEX,
|
||||
ColorUrl,
|
||||
ColorContextStroke,
|
||||
ColorContextFill
|
||||
} ColorType;
|
||||
} EColorType;
|
||||
|
||||
class CColor : public CValue<void*>
|
||||
class CColorValue
|
||||
{
|
||||
using color_value = boost::variant2::variant<boost::blank, std::wstring, TRGB, CURL>;
|
||||
protected:
|
||||
EColorType m_eType;
|
||||
public:
|
||||
CColorValue();
|
||||
CColorValue(const CColorValue& oValue);
|
||||
CColorValue(const std::wstring& wsValue);
|
||||
CColorValue(const TRGB& oValue);
|
||||
CColorValue(const CURL& oValue);
|
||||
|
||||
EColorType GetType() const;
|
||||
|
||||
bool operator==(const CColorValue& oValue) const;
|
||||
|
||||
color_value m_oValue;
|
||||
};
|
||||
|
||||
class CColorValueContextStroke : public CColorValue
|
||||
{
|
||||
public:
|
||||
CColorValueContextStroke();
|
||||
};
|
||||
|
||||
class CColorValueContextFill : public CColorValue
|
||||
{
|
||||
public:
|
||||
CColorValueContextFill();
|
||||
};
|
||||
|
||||
class CColor : public CValueOptional<CColorValue>
|
||||
{
|
||||
public:
|
||||
CColor();
|
||||
CColor(const CColor& oColor);
|
||||
~CColor();
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
|
||||
bool SetOpacity(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true);
|
||||
|
||||
bool Empty() const override;
|
||||
bool None() const;
|
||||
bool Url() const;
|
||||
void Clear() override;
|
||||
|
||||
ColorType GetType() const;
|
||||
EColorType GetType() const;
|
||||
|
||||
double GetOpacity() const;
|
||||
|
||||
@ -249,21 +334,15 @@ namespace NSCSS
|
||||
static TRGB ConvertHEXtoRGB(const std::wstring& wsValue);
|
||||
static std::wstring ConvertRGBtoHEX(const TRGB& oValue);
|
||||
|
||||
bool operator==(const CColor& oColor) const;
|
||||
bool operator!=(const CColor& oColor) const;
|
||||
|
||||
CColor& operator =(const CColor& oColor);
|
||||
CColor& operator+=(const CColor& oColor);
|
||||
using CValueOptional<CColorValue>::operator=;
|
||||
private:
|
||||
CDigit m_oOpacity;
|
||||
ColorType m_enType;
|
||||
CDigit m_oOpacity;
|
||||
|
||||
void SetEmpty(unsigned int unLevel = 0);
|
||||
void SetRGB(unsigned char uchR, unsigned char uchG, unsigned char uchB);
|
||||
void SetRGB(const TRGB& oRGB);
|
||||
void SetHEX(const std::wstring& wsValue);
|
||||
void SetUrl(const std::wstring& wsValue);
|
||||
void SetNone();
|
||||
bool SetUrl(const std::wstring& wsValue);
|
||||
};
|
||||
|
||||
typedef enum
|
||||
@ -279,7 +358,7 @@ namespace NSCSS
|
||||
|
||||
typedef std::vector<std::pair<std::vector<double>, TransformType>> MatrixValues;
|
||||
|
||||
class CMatrix : public CValue<MatrixValues>
|
||||
class CMatrix : public CValueBase<MatrixValues>
|
||||
{
|
||||
std::vector<std::wstring> CutTransforms(const std::wstring& wsValue) const;
|
||||
public:
|
||||
@ -304,29 +383,27 @@ namespace NSCSS
|
||||
bool operator==(const CMatrix& oMatrix) const;
|
||||
CMatrix& operator+=(const CMatrix& oMatrix);
|
||||
CMatrix& operator-=(const CMatrix& oMatrix);
|
||||
|
||||
using CValueBase<MatrixValues>::operator=;
|
||||
};
|
||||
|
||||
class CEnum : public CValue<int>
|
||||
class CEnum : public CValueOptional<int>
|
||||
{
|
||||
std::map<std::wstring, int> m_mMap;
|
||||
public:
|
||||
CEnum();
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
|
||||
void SetMapping(const std::map<std::wstring, int>& mMap, int nDefaulvalue = -1);
|
||||
|
||||
bool Empty() const override;
|
||||
void Clear() override;
|
||||
|
||||
CEnum &operator =(int nValue);
|
||||
|
||||
bool operator==(int nValue) const;
|
||||
bool operator!=(int nValue) const;
|
||||
|
||||
int ToInt() const override;
|
||||
|
||||
using CValueOptional<int>::operator=;
|
||||
private:
|
||||
double ToDouble() const override;
|
||||
std::wstring ToWString() const override;
|
||||
|
||||
int m_nDefaultValue;
|
||||
std::map<std::wstring, int> m_mMap;
|
||||
};
|
||||
|
||||
// PROPERTIES
|
||||
@ -373,6 +450,7 @@ namespace NSCSS
|
||||
const CEnum& GetWhiteSpace() const;
|
||||
|
||||
bool Empty() const;
|
||||
void Clear();
|
||||
|
||||
CDisplay& operator+=(const CDisplay& oDisplay);
|
||||
bool operator==(const CDisplay& oDisplay) const;
|
||||
@ -618,6 +696,30 @@ namespace NSCSS
|
||||
bool operator==(const TTextDecoration& oTextDecoration) const;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Baseline,
|
||||
Sub,
|
||||
Super,
|
||||
Percentage,
|
||||
Length
|
||||
} EBaselineShift;
|
||||
|
||||
class CBaselineShift
|
||||
{
|
||||
CEnum m_eType;
|
||||
CDigit m_oValue;
|
||||
public:
|
||||
CBaselineShift();
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
EBaselineShift GetType() const;
|
||||
double GetValue() const;
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
};
|
||||
|
||||
class CText
|
||||
{
|
||||
public:
|
||||
@ -625,11 +727,12 @@ namespace NSCSS
|
||||
|
||||
static void Equation(CText &oFirstText, CText &oSecondText);
|
||||
|
||||
bool SetIndent (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetDecoration(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetHighlight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetIndent (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetDecoration (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetHighlight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetBaselineShift (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
const CDigit& GetIndent() const;
|
||||
const CString& GetAlign() const;
|
||||
@ -637,6 +740,9 @@ namespace NSCSS
|
||||
const CColor& GetColor() const;
|
||||
const CColor& GetHighlight() const;
|
||||
|
||||
EBaselineShift GetBaselineShiftType() const;
|
||||
double GetBaselineShiftValue() const;
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
bool Underline() const;
|
||||
@ -646,6 +752,7 @@ namespace NSCSS
|
||||
CText& operator+=(const CText& oText);
|
||||
bool operator==(const CText& oText) const;
|
||||
private:
|
||||
CBaselineShift m_oBaselineShift;
|
||||
TTextDecoration m_oDecoration;
|
||||
CDigit m_oIndent;
|
||||
CString m_oAlign;
|
||||
|
||||
@ -22,6 +22,11 @@ namespace NSCSS
|
||||
: m_oStyle(oStyle), m_bIsPStyle(bIsPStyle)
|
||||
{}
|
||||
|
||||
void CStyleUsed::SetFinalId(const std::wstring& wsFinalId)
|
||||
{
|
||||
m_wsFinalId = wsFinalId;
|
||||
}
|
||||
|
||||
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
|
||||
{
|
||||
std::unordered_set<std::wstring> arInitialSet(arInitial.begin(), arInitial.end());
|
||||
@ -57,19 +62,14 @@ namespace NSCSS
|
||||
m_oStyle == oUsedStyle.m_oStyle;
|
||||
}
|
||||
|
||||
std::wstring CStyleUsed::getId()
|
||||
std::wstring CStyleUsed::GetId() const
|
||||
{
|
||||
if (m_bIsPStyle)
|
||||
return m_oStyle.GetId();
|
||||
|
||||
return m_oStyle.GetId() + L"-c";
|
||||
return m_wsFinalId;
|
||||
}
|
||||
|
||||
CDocumentStyle::CDocumentStyle() : m_arStandardStyles(Names_Standard_Styles)
|
||||
{
|
||||
for (const std::wstring& oNameStandardStyle : Names_Standard_Styles)
|
||||
m_arStandardStyles.push_back(oNameStandardStyle + L"-c");
|
||||
}
|
||||
CDocumentStyle::CDocumentStyle()
|
||||
: m_arStandardStyles(Names_Standard_Styles)
|
||||
{}
|
||||
|
||||
CDocumentStyle::~CDocumentStyle()
|
||||
{
|
||||
@ -85,7 +85,7 @@ namespace NSCSS
|
||||
|
||||
std::wstring CDocumentStyle::GetIdAndClear()
|
||||
{
|
||||
std::wstring sId = m_sId;
|
||||
const std::wstring sId = m_sId;
|
||||
Clear();
|
||||
return sId;
|
||||
}
|
||||
@ -110,10 +110,10 @@ namespace NSCSS
|
||||
m_sId = sId;
|
||||
}
|
||||
|
||||
void CDocumentStyle::CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement)
|
||||
bool CDocumentStyle::CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement)
|
||||
{
|
||||
if (arStandartedStyles.empty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
std::vector<std::wstring> arStyles;
|
||||
for (const std::wstring& sStyleName : arStandartedStyles)
|
||||
@ -123,7 +123,7 @@ namespace NSCSS
|
||||
}
|
||||
|
||||
if (arStyles.empty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
std::wstring sId;
|
||||
for (std::vector<std::wstring>::const_reverse_iterator iStyleName = arStyles.rbegin(); iStyleName != arStyles.rend(); ++iStyleName)
|
||||
@ -142,18 +142,25 @@ namespace NSCSS
|
||||
|
||||
oElement.AddBasicProperties(BProperties::B_Name, sId);
|
||||
oElement.AddBasicProperties(BProperties::B_StyleId, sId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDocumentStyle::CreateStandardStyle(const std::wstring& sNameStyle, CXmlElement& oElement)
|
||||
bool CDocumentStyle::CreateStandardStyle(const std::wstring& sNameStyle, CXmlElement& oElement)
|
||||
{
|
||||
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sNameStyle) != m_arStandardStyles.end())
|
||||
{
|
||||
oElement.CreateDefaultElement(sNameStyle);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CDocumentStyle::ConvertStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle)
|
||||
bool CDocumentStyle::ConvertStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle)
|
||||
{
|
||||
if (oStyle.GetId().empty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
std::wstring sName = oStyle.GetId();
|
||||
const size_t posPoint = sName.find(L'.');
|
||||
@ -183,25 +190,25 @@ namespace NSCSS
|
||||
for (std::wstring& sParentName : arParentsName)
|
||||
sParentName += L"-c";
|
||||
|
||||
bool bResult{false};
|
||||
|
||||
if (!arParentsName.empty())
|
||||
{
|
||||
CombineStandardStyles(arParentsName, oParentStyle);
|
||||
bResult = CombineStandardStyles(arParentsName, oParentStyle);
|
||||
|
||||
if (!oParentStyle.Empty())
|
||||
{
|
||||
oParentStyle.AddBasicProperties(BProperties::B_BasedOn, L"normal");
|
||||
oParentStyle.AddBasicProperties(BProperties::B_StyleId, L"(" + oParentStyle.GetStyleId() + L")");
|
||||
oParentStyle.AddBasicProperties(BProperties::B_StyleId, oParentStyle.GetStyleId());
|
||||
if (!bIsPStyle)
|
||||
{
|
||||
oParentStyle.AddBasicProperties(BProperties::B_StyleId, oParentStyle.GetStyleId() + L"-c");
|
||||
oParentStyle.AddBasicProperties(BProperties::B_Type, L"character");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CXmlElement oStandardXmlElement;
|
||||
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sName) != m_arStandardStyles.end())
|
||||
CreateStandardStyle(sName, oStandardXmlElement);
|
||||
if (CreateStandardStyle(sName, oStandardXmlElement))
|
||||
bResult = true;
|
||||
|
||||
if (oStandardXmlElement.Empty() && !oParentStyle.Empty())
|
||||
{
|
||||
@ -221,7 +228,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sParentsStyleID;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, sParentsStyleID);
|
||||
@ -234,7 +241,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sStandPlusParent;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, sStandPlusParent);
|
||||
}
|
||||
@ -258,7 +265,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sStandPlusParent;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, oTempElement.GetStyleId());
|
||||
}
|
||||
@ -281,7 +288,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sStandartStyleID;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, sStandartStyleID);
|
||||
}
|
||||
@ -289,7 +296,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty() && oElement.Empty())
|
||||
{
|
||||
m_sId = L"normal";
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_sId = oStyle.GetId();
|
||||
@ -302,15 +309,19 @@ namespace NSCSS
|
||||
oElement.AddBasicProperties(BProperties::B_Name, m_sId);
|
||||
oElement.AddBasicProperties(BProperties::B_Type, bIsPStyle ? L"paragraph" : L"character");
|
||||
oElement.AddBasicProperties(BProperties::B_CustomStyle, L"1");
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
void CDocumentStyle::SetPStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
bool CDocumentStyle::SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
{
|
||||
bool bResult{false};
|
||||
|
||||
if (!bIsLite)
|
||||
ConvertStyle(oStyle, oXmlElement, true);
|
||||
bResult = ConvertStyle(oStyle, oXmlElement, true);
|
||||
|
||||
if (oStyle.Empty())
|
||||
return;
|
||||
return bResult;
|
||||
|
||||
const bool bInTable{oStyle.HaveThisParent(L"table")};
|
||||
|
||||
@ -390,6 +401,8 @@ namespace NSCSS
|
||||
SetBorderStyle(oStyle, oXmlElement, PProperties::P_LeftBorder);
|
||||
}
|
||||
}
|
||||
|
||||
return bResult || !oXmlElement.Empty();
|
||||
}
|
||||
|
||||
void CDocumentStyle::SetBorderStyle(const CCompiledStyle &oStyle, CXmlElement &oXmlElement, const PProperties &enBorderProperty)
|
||||
@ -473,13 +486,15 @@ namespace NSCSS
|
||||
return L"w:val=\"" + wsStyle + L"\" w:sz=\"" + std::to_wstring(nWidth) + + L"\" w:space=\"" + std::to_wstring(nSpace) + L"\" w:color=\"" + wsColor + L"\"";
|
||||
}
|
||||
|
||||
void CDocumentStyle::SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
bool CDocumentStyle::SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
{
|
||||
bool bResult{false};
|
||||
|
||||
if (!bIsLite)
|
||||
ConvertStyle(oStyle, oXmlElement, false);
|
||||
bResult = ConvertStyle(oStyle, oXmlElement, false);
|
||||
|
||||
if (oStyle.Empty() && oXmlElement.Empty())
|
||||
return;
|
||||
return bResult;
|
||||
|
||||
if (!oStyle.m_oFont.GetSize().Empty())
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Sz, std::to_wstring(static_cast<int>(oStyle.m_oFont.GetSize().ToDouble(NSCSS::Point) * 2. * oStyle.m_oTransform.GetMatrix().GetFinalValue().sy() + 0.5))); // Значения шрифта увеличивает на 2
|
||||
@ -509,10 +524,25 @@ namespace NSCSS
|
||||
else if (L"serif" == wsFontFamily)
|
||||
wsFontFamily = L"Times New Roman";
|
||||
|
||||
if (oStyle.m_oDisplay.GetDisplay() == L"none")
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Vanish, L"true");
|
||||
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_RFonts, oStyle.m_oFont.GetFamily().ToWString());
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_I, oStyle.m_oFont.GetStyle().ToWString());
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_B, oStyle.m_oFont.GetWeight().ToWString());
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_SmallCaps, oStyle.m_oFont.GetVariant().ToWString());
|
||||
|
||||
if (oStyle.m_oText.LineThrough())
|
||||
{
|
||||
if (L"double" == oStyle.m_oText.GetDecoration().m_oStyle.ToWString())
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Strike, L"dstrike");
|
||||
else
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Strike, L"strike");
|
||||
}
|
||||
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_VertAlign, oStyle.m_oDisplay.GetVAlign().ToWString());
|
||||
|
||||
return bResult || !oXmlElement.Empty();
|
||||
}
|
||||
|
||||
bool CDocumentStyle::WriteRStyle(const NSCSS::CCompiledStyle& oStyle)
|
||||
@ -528,16 +558,16 @@ namespace NSCSS
|
||||
|
||||
if (oItem != m_arStyleUsed.end())
|
||||
{
|
||||
m_sId = (*oItem).getId();
|
||||
m_sId = (*oItem).GetId();
|
||||
return true;
|
||||
}
|
||||
|
||||
CXmlElement oXmlElement;
|
||||
SetRStyle(oStyle, oXmlElement);
|
||||
|
||||
if (oXmlElement.Empty())
|
||||
if (!SetRStyle(oStyle, oXmlElement))
|
||||
return false;
|
||||
|
||||
structStyle.SetFinalId(m_sId);
|
||||
m_arStyleUsed.push_back(structStyle);
|
||||
m_sStyle += oXmlElement.GetRStyle();
|
||||
|
||||
@ -590,16 +620,16 @@ namespace NSCSS
|
||||
|
||||
if (oItem != m_arStyleUsed.end())
|
||||
{
|
||||
m_sId = (*oItem).getId();
|
||||
m_sId = (*oItem).GetId();
|
||||
return true;
|
||||
}
|
||||
|
||||
CXmlElement oXmlElement;
|
||||
SetPStyle(oStyle, oXmlElement);
|
||||
|
||||
if (oXmlElement.Empty())
|
||||
if (!SetPStyle(oStyle, oXmlElement))
|
||||
return false;
|
||||
|
||||
structStyle.SetFinalId(m_sId);
|
||||
m_arStyleUsed.push_back(structStyle);
|
||||
m_sStyle += oXmlElement.GetPStyle();
|
||||
|
||||
|
||||
@ -12,16 +12,19 @@ namespace NSCSS
|
||||
{
|
||||
CCompiledStyle m_oStyle;
|
||||
bool m_bIsPStyle;
|
||||
std::wstring m_wsFinalId;
|
||||
|
||||
public:
|
||||
CStyleUsed(const CCompiledStyle& oStyle, bool bIsPStyle);
|
||||
|
||||
void SetFinalId(const std::wstring& wsFinalId);
|
||||
|
||||
bool operator==(const CStyleUsed& oUsedStyle) const;
|
||||
|
||||
std::wstring getId();
|
||||
std::wstring GetId() const;
|
||||
};
|
||||
|
||||
static const std::vector<std::wstring> Names_Standard_Styles = {L"a", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6",L"p", L"div"};
|
||||
static const std::vector<std::wstring> Names_Standard_Styles = {L"a", L"a-c", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6", L"h1-c", L"h2-c", L"h3-c", L"h4-c", L"h5-c", L"h6-c"};
|
||||
|
||||
class CSSCALCULATOR_EXPORT CDocumentStyle
|
||||
{
|
||||
@ -36,12 +39,12 @@ namespace NSCSS
|
||||
std::wstring m_sStyle;
|
||||
std::wstring m_sId;
|
||||
|
||||
void CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement);
|
||||
void CreateStandardStyle (const std::wstring& sNameStyle, CXmlElement& oElement);
|
||||
void ConvertStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle);
|
||||
bool CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement);
|
||||
bool CreateStandardStyle (const std::wstring& sNameStyle, CXmlElement& oElement);
|
||||
bool ConvertStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle);
|
||||
|
||||
void SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
void SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
bool SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
bool SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
|
||||
void SetBorderStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, const PProperties& enBorderProperty);
|
||||
public:
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
#include <cwctype>
|
||||
#include <functional>
|
||||
|
||||
#include <iostream>
|
||||
#include "../ConstValues.h"
|
||||
|
||||
#define DEFAULTFONTNAME L"Times New Roman"
|
||||
@ -67,7 +66,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h1-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"0");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h2")
|
||||
{
|
||||
@ -78,7 +77,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h2-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"1");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h3")
|
||||
{
|
||||
@ -89,7 +88,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h3-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"2");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h4")
|
||||
{
|
||||
@ -100,7 +99,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h4-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"3");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h5")
|
||||
{
|
||||
@ -111,7 +110,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h5-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"4");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
|
||||
}
|
||||
else if (sNameDefaultElement == L"h6")
|
||||
@ -123,13 +122,13 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h6-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"5");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h1-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h1-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 1 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 1 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h1");
|
||||
@ -142,7 +141,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h2-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 2 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 2 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
@ -155,7 +154,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h3-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 3 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 3 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
@ -168,7 +167,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h4-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 4 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 4 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
@ -181,7 +180,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h5-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 5 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 5 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
@ -194,7 +193,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h6-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 6 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 6 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
@ -473,6 +472,25 @@ std::wstring CXmlElement::ConvertRStyle(bool bIsLite) const
|
||||
sRStyle += L"<w:kern w:val=\"" + oItem.second + L"\"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_Vanish:
|
||||
{
|
||||
if (oItem.second == L"true")
|
||||
sRStyle += L"<w:vanish/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_Strike:
|
||||
{
|
||||
sRStyle += L"<w:" + oItem.second + L"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_VertAlign:
|
||||
{
|
||||
if (L"top" == oItem.second)
|
||||
sRStyle += L"<w:vertAlign w:val=\"superscript\"/>";
|
||||
else if (L"bottom" == oItem.second)
|
||||
sRStyle += L"<w:vertAlign w:val=\"subscript\"/>";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -7,4 +7,5 @@ core_windows:INCLUDEPATH += $$PWD/gumbo-parser/visualc/include
|
||||
HEADERS += $$files($$PWD/gumbo-parser/src/*.h, true) \
|
||||
$$PWD/htmltoxhtml.h
|
||||
|
||||
SOURCES += $$files($$PWD/gumbo-parser/src/*.c, true)
|
||||
SOURCES += $$files($$PWD/gumbo-parser/src/*.c, true) \
|
||||
$$PWD/htmltoxhtml.cpp
|
||||
|
||||
657
Common/3dParty/html/htmltoxhtml.cpp
Normal file
657
Common/3dParty/html/htmltoxhtml.cpp
Normal file
@ -0,0 +1,657 @@
|
||||
#include "htmltoxhtml.h"
|
||||
|
||||
#include <map>
|
||||
#include <cctype>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "gumbo-parser/src/gumbo.h"
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
#include "../../../DesktopEditor/common/Directory.h"
|
||||
#include "../../../DesktopEditor/common/StringBuilder.h"
|
||||
#include "../../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "../../../HtmlFile2/src/StringFinder.h"
|
||||
|
||||
namespace HTML
|
||||
{
|
||||
#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|";
|
||||
static std::string special_handling = "|html|body|";
|
||||
static std::string treat_like_inline = "|p|";
|
||||
|
||||
static std::vector<std::string> html_tags = {"div","span","a","img","p","h1","h2","h3","h4","h5","h6",
|
||||
"ul", "ol", "li","td","tr","table","thead","tbody","tfoot","th",
|
||||
"br","form","input","button","section","nav","header","footer",
|
||||
"main","figure","figcaption","strong","em","i", "b", "u","pre",
|
||||
"code","blockquote","hr","script","link","meta","style","title",
|
||||
"head","body","html","legend","optgroup","option","select","dl",
|
||||
"dt","dd","time","data","abbr","address","area","base","bdi",
|
||||
"bdo","cite","col","iframe","video","source","track","textarea",
|
||||
"label","fieldset","colgroup","del","ins","details","summary",
|
||||
"dialog","embed","kbd","map","mark","menu","meter","object",
|
||||
"output","param","progress","q","samp","small","sub","sup","var",
|
||||
"wbr","acronym","applet","article","aside","audio","basefont",
|
||||
"bgsound","big","blink","canvas","caption","center","command",
|
||||
"comment","datalist","dfn","dir","font","frame","frameset",
|
||||
"hgroup","isindex","keygen","marquee","nobr","noembed","noframes",
|
||||
"noscript","plaintext","rp","rt","ruby","s","strike","tt","xmp"};
|
||||
|
||||
static std::vector<std::string> unchecked_nodes_new = {"svg"};
|
||||
|
||||
static void replace_all(std::string& s, const std::string& s1, const std::string& s2)
|
||||
{
|
||||
size_t pos = s.find(s1);
|
||||
while(pos != std::string::npos)
|
||||
{
|
||||
s.replace(pos, s1.length(), s2);
|
||||
pos = s.find(s1, pos + s2.length());
|
||||
}
|
||||
}
|
||||
|
||||
static bool NodeIsUnprocessed(const std::string& sTagName)
|
||||
{
|
||||
return "xml" == sTagName;
|
||||
}
|
||||
|
||||
static bool IsUnckeckedNodes(const std::string& sValue)
|
||||
{
|
||||
return unchecked_nodes_new.end() != std::find(unchecked_nodes_new.begin(), unchecked_nodes_new.end(), sValue);
|
||||
}
|
||||
|
||||
static std::string Base64ToString(const std::string& sContent, const std::string& sCharset)
|
||||
{
|
||||
std::string sRes;
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
{
|
||||
std::wstring sConvert;
|
||||
if(!sCharset.empty() && NSStringFinder::Equals<std::string>("utf-8", sCharset))
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sConvert = oConverter.toUnicode(reinterpret_cast<char *>(pData), (unsigned)nDecodeLen, sCharset.data());
|
||||
}
|
||||
sRes = sConvert.empty() ? std::string(reinterpret_cast<char *>(pData), nDecodeLen) : U_TO_UTF8(sConvert);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return sRes;
|
||||
}
|
||||
|
||||
static std::string QuotedPrintableDecode(const std::string& sContent, std::string& sCharset)
|
||||
{
|
||||
NSStringUtils::CStringBuilderA sRes;
|
||||
size_t ip = 0;
|
||||
size_t i = sContent.find('=');
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
size_t nIgnore = 12;
|
||||
std::string charset = sContent.substr(0, nIgnore);
|
||||
if(charset == "=00=00=FE=FF")
|
||||
sCharset = "UTF-32BE";
|
||||
else if(charset == "=FF=FE=00=00")
|
||||
sCharset = "UTF-32LE";
|
||||
else if(charset == "=2B=2F=76=38" || charset == "=2B=2F=76=39" ||
|
||||
charset == "=2B=2F=76=2B" || charset == "=2B=2F=76=2F")
|
||||
sCharset = "UTF-7";
|
||||
else if(charset == "=DD=73=66=73")
|
||||
sCharset = "UTF-EBCDIC";
|
||||
else if(charset == "=84=31=95=33")
|
||||
sCharset = "GB-18030";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=EF=BB=BF")
|
||||
sCharset = "UTF-8";
|
||||
else if(charset == "=F7=64=4C")
|
||||
sCharset = "UTF-1";
|
||||
else if(charset == "=0E=FE=FF")
|
||||
sCharset = "SCSU";
|
||||
else if(charset == "=FB=EE=28")
|
||||
sCharset = "BOCU-1";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=FE=FF")
|
||||
sCharset = "UTF-16BE";
|
||||
else if(charset == "=FF=FE")
|
||||
sCharset = "UTF-16LE";
|
||||
else
|
||||
nIgnore -= 6;
|
||||
}
|
||||
}
|
||||
|
||||
ip = nIgnore;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
|
||||
while(i != std::string::npos && i + 2 < sContent.length())
|
||||
{
|
||||
sRes.WriteString(sContent.c_str() + ip, i - ip);
|
||||
std::string str = sContent.substr(i + 1, 2);
|
||||
if(str.front() == '\n' || str.front() == '\r')
|
||||
{
|
||||
char ch = str[1];
|
||||
if(ch != '\n' && ch != '\r')
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* err;
|
||||
char ch = (int)strtol(str.data(), &err, 16);
|
||||
if(*err)
|
||||
sRes.WriteString('=' + str);
|
||||
else
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
ip = i + 3;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
if(ip != std::string::npos)
|
||||
sRes.WriteString(sContent.c_str() + ip);
|
||||
return sRes.GetData();
|
||||
}
|
||||
|
||||
static std::string mhtTohtml(const std::string& sFileContent);
|
||||
|
||||
static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::string>& sRes, NSStringUtils::CStringBuilderA& oRes)
|
||||
{
|
||||
size_t unContentPosition = 0, unCharsetBegin = 0, unCharsetEnd = std::string::npos;
|
||||
|
||||
NSStringFinder::TFoundedData<char> oData;
|
||||
|
||||
// Content-Type
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentType{oData.m_sValue};
|
||||
|
||||
if (sContentType.empty())
|
||||
return;
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
|
||||
{
|
||||
oRes.WriteString(mhtTohtml(sMhtContent.substr(oData.m_unEndPosition, sMhtContent.length() - oData.m_unEndPosition)));
|
||||
return;
|
||||
}
|
||||
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetBegin = oData.m_unEndPosition;
|
||||
|
||||
// name
|
||||
// std::string sName = NSStringFinder::FindProperty(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
|
||||
// Content-Location
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentLocation{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
|
||||
// Content-ID
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentID{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
NSStringFinder::CutInside<std::string>(sContentID, "<", ">");
|
||||
}
|
||||
|
||||
if (sContentLocation.empty() && !sContentID.empty())
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
|
||||
// Content-Transfer-Encoding
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentEncoding{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
}
|
||||
|
||||
// charset
|
||||
std::string sCharset = "utf-8";
|
||||
|
||||
if (std::string::npos != unCharsetEnd && unCharsetBegin < unCharsetEnd)
|
||||
{
|
||||
sCharset = NSStringFinder::FindProperty(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "\"");
|
||||
}
|
||||
|
||||
// Content
|
||||
std::string sContent = sMhtContent.substr(unContentPosition, sMhtContent.length() - unContentPosition);
|
||||
|
||||
// std::wstring sExtention = NSFile::GetFileExtention(UTF8_TO_U(sName));
|
||||
// std::transform(sExtention.begin(), sExtention.end(), sExtention.begin(), tolower);
|
||||
// Основной документ
|
||||
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
|
||||
oRes.WriteString(mhtTohtml(sContent));
|
||||
else if ((NSStringFinder::Find(sContentType, "text") /*&& (sExtention.empty() || NSStringFinder::EqualOf(sExtention, {L"htm", L"html", L"xhtml", L"css"}))*/)
|
||||
|| (NSStringFinder::Equals(sContentType, "application/octet-stream") && NSStringFinder::Find(sContentLocation, "css")))
|
||||
{
|
||||
// Стили заключаются в тэг <style>
|
||||
const bool bAddTagStyle = NSStringFinder::Equals(sContentType, "text/css") /*|| NSStringFinder::Equals(sExtention, L"css")*/ || NSStringFinder::Find(sContentLocation, "css");
|
||||
|
||||
if (bAddTagStyle)
|
||||
oRes.WriteString("<style>");
|
||||
|
||||
if (NSStringFinder::Equals(sContentEncoding, "base64"))
|
||||
sContent = Base64ToString(sContent, sCharset);
|
||||
else if (NSStringFinder::EqualOf(sContentEncoding, {"8bit", "7bit"}) || sContentEncoding.empty())
|
||||
{
|
||||
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
}
|
||||
else if (NSStringFinder::Equals(sContentEncoding, "quoted-printable"))
|
||||
{
|
||||
sContent = QuotedPrintableDecode(sContent, sCharset);
|
||||
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
}
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "text/html"))
|
||||
sContent = U_TO_UTF8(htmlToXhtml(sContent, false));
|
||||
|
||||
oRes.WriteString(sContent);
|
||||
|
||||
if(bAddTagStyle)
|
||||
oRes.WriteString("</style>");
|
||||
}
|
||||
// Картинки
|
||||
else if ((NSStringFinder::Find(sContentType, "image") /*|| NSStringFinder::Equals(sExtention, L"gif")*/ || NSStringFinder::Equals(sContentType, "application/octet-stream")) &&
|
||||
NSStringFinder::Equals(sContentEncoding, "base64"))
|
||||
{
|
||||
// if (NSStringFinder::Equals(sExtention, L"ico") || NSStringFinder::Find(sContentType, "ico"))
|
||||
// sContentType = "image/jpg";
|
||||
// else if(NSStringFinder::Equals(sExtention, L"gif"))
|
||||
// sContentType = "image/gif";
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
sRes.insert(std::make_pair(sContentLocation, "data:" + sContentType + ";base64," + sContent));
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
}
|
||||
}
|
||||
|
||||
static std::string mhtTohtml(const std::string& sFileContent)
|
||||
{
|
||||
std::map<std::string, std::string> sRes;
|
||||
NSStringUtils::CStringBuilderA oRes;
|
||||
|
||||
// Поиск boundary
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindProperty(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
|
||||
size_t nFound{oData.m_unEndPosition};
|
||||
std::string sBoundary{oData.m_sValue};
|
||||
|
||||
if (sBoundary.empty())
|
||||
{
|
||||
size_t nFoundEnd = sFileContent.length();
|
||||
nFound = 0;
|
||||
ReadMht(sFileContent.substr(nFound, nFoundEnd), sRes, oRes);
|
||||
return oRes.GetData();
|
||||
}
|
||||
|
||||
NSStringFinder::CutInside<std::string>(sBoundary, "\"");
|
||||
|
||||
size_t nFoundEnd{nFound};
|
||||
|
||||
sBoundary = "--" + sBoundary;
|
||||
size_t nBoundaryLength = sBoundary.length();
|
||||
|
||||
nFound = sFileContent.find(sBoundary, nFound) + nBoundaryLength;
|
||||
|
||||
// Цикл по boundary
|
||||
while(nFound != std::string::npos)
|
||||
{
|
||||
nFoundEnd = sFileContent.find(sBoundary, nFound + nBoundaryLength);
|
||||
if(nFoundEnd == std::string::npos)
|
||||
break;
|
||||
|
||||
ReadMht(sFileContent.substr(nFound, nFoundEnd - nFound), sRes, oRes);
|
||||
|
||||
nFound = sFileContent.find(sBoundary, nFoundEnd);
|
||||
}
|
||||
|
||||
std::string sFile = oRes.GetData();
|
||||
for(const std::pair<std::string, std::string>& item : sRes)
|
||||
{
|
||||
std::string sName = item.first;
|
||||
size_t found = sFile.find(sName);
|
||||
size_t sfound = sName.rfind('/');
|
||||
if(found == std::string::npos && sfound != std::string::npos)
|
||||
found = sFile.find(sName.erase(0, sfound + 1));
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
size_t fq = sFile.find_last_of("\"\'>=", found);
|
||||
|
||||
if (std::string::npos == fq)
|
||||
break;
|
||||
|
||||
char ch = sFile[fq];
|
||||
if(ch != '\"' && ch != '\'')
|
||||
fq++;
|
||||
size_t tq = sFile.find_first_of("\"\'<> ", found) + 1;
|
||||
|
||||
if (std::string::npos == tq)
|
||||
break;
|
||||
|
||||
if(sFile[tq] != '\"' && sFile[tq] != '\'')
|
||||
tq--;
|
||||
if(ch != '>')
|
||||
{
|
||||
std::string is = '\"' + item.second + '\"';
|
||||
sFile.replace(fq, tq - fq, is);
|
||||
found = sFile.find(sName, fq + is.length());
|
||||
}
|
||||
else
|
||||
found = sFile.find(sName, tq);
|
||||
}
|
||||
}
|
||||
|
||||
return sFile;
|
||||
}
|
||||
|
||||
// Заменяет сущности &,<,> в text
|
||||
static void substitute_xml_entities_into_text(std::string& text)
|
||||
{
|
||||
// replacing & must come first
|
||||
replace_all(text, "&", "&");
|
||||
replace_all(text, "<", "<");
|
||||
replace_all(text, ">", ">");
|
||||
}
|
||||
|
||||
// After running through Gumbo, the values of type "" are replaced with the corresponding code '0x01'
|
||||
// Since the attribute value does not use control characters (value <= 0x09),
|
||||
// then just delete them, otherwise XmlUtils::CXmlLiteReader crashes on them.
|
||||
// bug#73486
|
||||
static void remove_control_symbols(std::string& text)
|
||||
{
|
||||
std::string::iterator itFound = std::find_if(text.begin(), text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
|
||||
while (itFound != text.end())
|
||||
{
|
||||
itFound = text.erase(itFound);
|
||||
itFound = std::find_if(itFound, text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
}
|
||||
}
|
||||
|
||||
// Заменяет сущности " в text
|
||||
static void substitute_xml_entities_into_attributes(std::string& text)
|
||||
{
|
||||
remove_control_symbols(text);
|
||||
substitute_xml_entities_into_text(text);
|
||||
replace_all(text, "\"", """);
|
||||
}
|
||||
|
||||
static std::string handle_unknown_tag(GumboStringPiece* text)
|
||||
{
|
||||
if (text->data == NULL)
|
||||
return "";
|
||||
GumboStringPiece gsp = *text;
|
||||
gumbo_tag_from_original_text(&gsp);
|
||||
std::string sAtr = std::string(gsp.data, gsp.length);
|
||||
size_t found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
sAtr.erase(found, 1);
|
||||
found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}", found);
|
||||
}
|
||||
return sAtr;
|
||||
}
|
||||
|
||||
static std::string get_tag_name(GumboNode* node)
|
||||
{
|
||||
std::string tagname = (node->type == GUMBO_NODE_DOCUMENT ? "document" : gumbo_normalized_tagname(node->v.element.tag));
|
||||
if (tagname.empty())
|
||||
tagname = handle_unknown_tag(&node->v.element.original_tag);
|
||||
return tagname;
|
||||
}
|
||||
|
||||
static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder)
|
||||
{
|
||||
if (node->v.document.has_doctype)
|
||||
{
|
||||
oBuilder.WriteString("<!DOCTYPE ");
|
||||
oBuilder.WriteString(node->v.document.name);
|
||||
std::string pi(node->v.document.public_identifier);
|
||||
remove_control_symbols(pi);
|
||||
if ((node->v.document.public_identifier != NULL) && !pi.empty())
|
||||
{
|
||||
oBuilder.WriteString(" PUBLIC \"");
|
||||
oBuilder.WriteString(pi);
|
||||
oBuilder.WriteString("\" \"");
|
||||
oBuilder.WriteString(node->v.document.system_identifier);
|
||||
oBuilder.WriteString("\"");
|
||||
}
|
||||
oBuilder.WriteString(">");
|
||||
}
|
||||
}
|
||||
|
||||
static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringBuilderA& atts)
|
||||
{
|
||||
std::vector<std::string> arrRepeat;
|
||||
for (size_t i = 0; i < attribs->length; ++i)
|
||||
{
|
||||
GumboAttribute* at = static_cast<GumboAttribute*>(attribs->data[i]);
|
||||
std::string sVal(at->value);
|
||||
std::string sName(at->name);
|
||||
|
||||
remove_control_symbols(sVal);
|
||||
remove_control_symbols(sName);
|
||||
|
||||
atts.WriteString(" ");
|
||||
|
||||
bool bCheck = false;
|
||||
size_t nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}");
|
||||
while(nBad != std::string::npos)
|
||||
{
|
||||
sName.erase(nBad, 1);
|
||||
nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}", nBad);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(sName.empty())
|
||||
continue;
|
||||
while(sName.front() >= '0' && sName.front() <= '9')
|
||||
{
|
||||
sName.erase(0, 1);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(bCheck)
|
||||
{
|
||||
GumboAttribute* check = gumbo_get_attribute(attribs, sName.c_str());
|
||||
if(check || std::find(arrRepeat.begin(), arrRepeat.end(), sName) != arrRepeat.end())
|
||||
continue;
|
||||
else
|
||||
arrRepeat.push_back(sName);
|
||||
}
|
||||
|
||||
if(sName.empty())
|
||||
continue;
|
||||
atts.WriteString(sName);
|
||||
|
||||
// determine original quote character used if it exists
|
||||
std::string qs ="\"";
|
||||
atts.WriteString("=");
|
||||
atts.WriteString(qs);
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
atts.WriteString(sVal);
|
||||
atts.WriteString(qs);
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode = true);
|
||||
|
||||
static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA& contents, bool bCheckValidNode)
|
||||
{
|
||||
std::string key = "|" + get_tag_name(node) + "|";
|
||||
bool keep_whitespace = preserve_whitespace.find(key) != std::string::npos;
|
||||
bool is_inline = nonbreaking_inline.find(key) != std::string::npos;
|
||||
bool is_like_inline = treat_like_inline.find(key) != std::string::npos;
|
||||
|
||||
GumboVector* children = &node->v.element.children;
|
||||
|
||||
for (size_t i = 0; i < children->length; i++)
|
||||
{
|
||||
GumboNode* child = static_cast<GumboNode*> (children->data[i]);
|
||||
|
||||
if (child->type == GUMBO_NODE_TEXT)
|
||||
{
|
||||
std::string val(child->v.text.text);
|
||||
remove_control_symbols(val);
|
||||
substitute_xml_entities_into_text(val);
|
||||
|
||||
// Избавление от FF
|
||||
size_t found = val.find_first_of("\014");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
val.erase(found, 1);
|
||||
found = val.find_first_of("\014", found);
|
||||
}
|
||||
|
||||
contents.WriteString(val);
|
||||
}
|
||||
else if ((child->type == GUMBO_NODE_ELEMENT) || (child->type == GUMBO_NODE_TEMPLATE))
|
||||
prettyprint(child, contents, bCheckValidNode);
|
||||
else if (child->type == GUMBO_NODE_WHITESPACE)
|
||||
{
|
||||
if (keep_whitespace || is_inline || is_like_inline)
|
||||
contents.WriteString(child->v.text.text);
|
||||
}
|
||||
else if (child->type != GUMBO_NODE_COMMENT)
|
||||
{
|
||||
// Сообщение об ошибке
|
||||
// Does this actually exist: (child->type == GUMBO_NODE_CDATA)
|
||||
// fprintf(stderr, "unknown element of type: %d\n", child->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode)
|
||||
{
|
||||
// special case the document node
|
||||
if (node->type == GUMBO_NODE_DOCUMENT)
|
||||
{
|
||||
build_doctype(node, oBuilder);
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
remove_control_symbols(tagname);
|
||||
|
||||
if (NodeIsUnprocessed(tagname))
|
||||
return;
|
||||
|
||||
if (bCheckValidNode)
|
||||
bCheckValidNode = !IsUnckeckedNodes(tagname);
|
||||
|
||||
if (bCheckValidNode && html_tags.end() == std::find(html_tags.begin(), html_tags.end(), tagname))
|
||||
{
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string close = "";
|
||||
std::string closeTag = "";
|
||||
std::string key = "|" + tagname + "|";
|
||||
bool is_empty_tag = empty_tags.find(key) != std::string::npos;
|
||||
|
||||
// determine closing tag type
|
||||
if (is_empty_tag)
|
||||
close = "/";
|
||||
else
|
||||
closeTag = "</" + tagname + ">";
|
||||
|
||||
// build results
|
||||
oBuilder.WriteString("<" + tagname);
|
||||
|
||||
// build attr string
|
||||
const GumboVector* attribs = &node->v.element.attributes;
|
||||
build_attributes(attribs, oBuilder);
|
||||
oBuilder.WriteString(close + ">");
|
||||
|
||||
// prettyprint your contents
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
oBuilder.WriteString(closeTag);
|
||||
}
|
||||
|
||||
std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\"", "'"}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindProperty(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
if (!sEncoding.empty() && !NSStringFinder::Equals("utf-8", sEncoding))
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sFileContent = U_TO_UTF8(oConverter.toUnicode(sFileContent, sEncoding.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
// Избавляемся от лишних символов до <...
|
||||
boost::regex oRegex("<[a-zA-Z]");
|
||||
boost::match_results<typename std::string::const_iterator> oResult;
|
||||
|
||||
if (boost::regex_search(sFileContent, oResult, oRegex))
|
||||
sFileContent.erase(0, oResult.position());
|
||||
|
||||
//Избавление от <a ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "a"));
|
||||
//Избавление от <title ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "title"));
|
||||
//Избавление от <script ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "script"));
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
|
||||
std::wstring mhtToXhtml(std::string& sFileContent)
|
||||
{
|
||||
sFileContent = mhtTohtml(sFileContent);
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
}
|
||||
@ -2,658 +2,11 @@
|
||||
#define HTMLTOXHTML_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <cctype>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "gumbo-parser/src/gumbo.h"
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
#include "../../../DesktopEditor/common/Directory.h"
|
||||
#include "../../../DesktopEditor/common/StringBuilder.h"
|
||||
#include "../../../DesktopEditor/xml/include/xmlutils.h"
|
||||
#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|";
|
||||
static std::string special_handling = "|html|body|";
|
||||
static std::string treat_like_inline = "|p|";
|
||||
|
||||
static std::vector<std::string> html_tags = {"div","span","a","img","p","h1","h2","h3","h4","h5","h6",
|
||||
"ul", "ol", "li","td","tr","table","thead","tbody","tfoot","th",
|
||||
"br","form","input","button","section","nav","header","footer",
|
||||
"main","figure","figcaption","strong","em","i", "b", "u","pre",
|
||||
"code","blockquote","hr","script","link","meta","style","title",
|
||||
"head","body","html","legend","optgroup","option","select","dl",
|
||||
"dt","dd","time","data","abbr","address","area","base","bdi",
|
||||
"bdo","cite","col","iframe","video","source","track","textarea",
|
||||
"label","fieldset","colgroup","del","ins","details","summary",
|
||||
"dialog","embed","kbd","map","mark","menu","meter","object",
|
||||
"output","param","progress","q","samp","small","sub","sup","var",
|
||||
"wbr","acronym","applet","article","aside","audio","basefont",
|
||||
"bgsound","big","blink","canvas","caption","center","command",
|
||||
"comment","datalist","dfn","dir","font","frame","frameset",
|
||||
"hgroup","isindex","keygen","marquee","nobr","noembed","noframes",
|
||||
"noscript","plaintext","rp","rt","ruby","s","strike","tt","xmp"};
|
||||
|
||||
static std::vector<std::string> unchecked_nodes_new = {"svg"};
|
||||
|
||||
static void prettyprint(GumboNode*, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode = true);
|
||||
static std::string mhtTohtml(const std::string &sFileContent);
|
||||
|
||||
// Заменяет в строке s все символы s1 на s2
|
||||
static void replace_all(std::string& s, const std::string& s1, const std::string& s2)
|
||||
namespace HTML
|
||||
{
|
||||
size_t pos = s.find(s1);
|
||||
while(pos != std::string::npos)
|
||||
{
|
||||
s.replace(pos, s1.length(), s2);
|
||||
pos = s.find(s1, pos + s2.length());
|
||||
}
|
||||
}
|
||||
|
||||
static bool NodeIsUnprocessed(const std::string& wsTagName)
|
||||
{
|
||||
return "xml" == wsTagName;
|
||||
}
|
||||
|
||||
static bool IsUnckeckedNodes(const std::string& sValue)
|
||||
{
|
||||
return unchecked_nodes_new.end() != std::find(unchecked_nodes_new.begin(), unchecked_nodes_new.end(), sValue);
|
||||
}
|
||||
|
||||
static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\"", "'"}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindProperty(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
if (!sEncoding.empty() && !NSStringFinder::Equals("utf-8", sEncoding))
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sFileContent = U_TO_UTF8(oConverter.toUnicode(sFileContent, sEncoding.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
// Избавляемся от лишних символов до <...
|
||||
boost::regex oRegex("<[a-zA-Z]");
|
||||
boost::match_results<typename std::string::const_iterator> oResult;
|
||||
|
||||
if (boost::regex_search(sFileContent, oResult, oRegex))
|
||||
sFileContent.erase(0, oResult.position());
|
||||
|
||||
//Избавление от <a ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "a"));
|
||||
//Избавление от <title ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "title"));
|
||||
//Избавление от <script ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "script"));
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
|
||||
static std::string Base64ToString(const std::string& sContent, const std::string& sCharset)
|
||||
{
|
||||
std::string sRes;
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
{
|
||||
std::wstring sConvert;
|
||||
if(!sCharset.empty() && NSStringFinder::Equals<std::string>("utf-8", sCharset))
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sConvert = oConverter.toUnicode(reinterpret_cast<char *>(pData), (unsigned)nDecodeLen, sCharset.data());
|
||||
}
|
||||
sRes = sConvert.empty() ? std::string(reinterpret_cast<char *>(pData), nDecodeLen) : U_TO_UTF8(sConvert);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return sRes;
|
||||
}
|
||||
|
||||
static std::string QuotedPrintableDecode(const std::string& sContent, std::string& sCharset)
|
||||
{
|
||||
NSStringUtils::CStringBuilderA sRes;
|
||||
size_t ip = 0;
|
||||
size_t i = sContent.find('=');
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
size_t nIgnore = 12;
|
||||
std::string charset = sContent.substr(0, nIgnore);
|
||||
if(charset == "=00=00=FE=FF")
|
||||
sCharset = "UTF-32BE";
|
||||
else if(charset == "=FF=FE=00=00")
|
||||
sCharset = "UTF-32LE";
|
||||
else if(charset == "=2B=2F=76=38" || charset == "=2B=2F=76=39" ||
|
||||
charset == "=2B=2F=76=2B" || charset == "=2B=2F=76=2F")
|
||||
sCharset = "UTF-7";
|
||||
else if(charset == "=DD=73=66=73")
|
||||
sCharset = "UTF-EBCDIC";
|
||||
else if(charset == "=84=31=95=33")
|
||||
sCharset = "GB-18030";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=EF=BB=BF")
|
||||
sCharset = "UTF-8";
|
||||
else if(charset == "=F7=64=4C")
|
||||
sCharset = "UTF-1";
|
||||
else if(charset == "=0E=FE=FF")
|
||||
sCharset = "SCSU";
|
||||
else if(charset == "=FB=EE=28")
|
||||
sCharset = "BOCU-1";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=FE=FF")
|
||||
sCharset = "UTF-16BE";
|
||||
else if(charset == "=FF=FE")
|
||||
sCharset = "UTF-16LE";
|
||||
else
|
||||
nIgnore -= 6;
|
||||
}
|
||||
}
|
||||
|
||||
ip = nIgnore;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
|
||||
while(i != std::string::npos && i + 2 < sContent.length())
|
||||
{
|
||||
sRes.WriteString(sContent.c_str() + ip, i - ip);
|
||||
std::string str = sContent.substr(i + 1, 2);
|
||||
if(str.front() == '\n' || str.front() == '\r')
|
||||
{
|
||||
char ch = str[1];
|
||||
if(ch != '\n' && ch != '\r')
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* err;
|
||||
char ch = (int)strtol(str.data(), &err, 16);
|
||||
if(*err)
|
||||
sRes.WriteString('=' + str);
|
||||
else
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
ip = i + 3;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
if(ip != std::string::npos)
|
||||
sRes.WriteString(sContent.c_str() + ip);
|
||||
return sRes.GetData();
|
||||
}
|
||||
|
||||
static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::string>& sRes, NSStringUtils::CStringBuilderA& oRes)
|
||||
{
|
||||
size_t unContentPosition = 0, unCharsetBegin = 0, unCharsetEnd = std::string::npos;
|
||||
|
||||
NSStringFinder::TFoundedData<char> oData;
|
||||
|
||||
// Content-Type
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentType{oData.m_sValue};
|
||||
|
||||
if (sContentType.empty())
|
||||
return;
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
|
||||
{
|
||||
oRes.WriteString(mhtTohtml(sMhtContent.substr(oData.m_unEndPosition, sMhtContent.length() - oData.m_unEndPosition)));
|
||||
return;
|
||||
}
|
||||
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetBegin = oData.m_unEndPosition;
|
||||
|
||||
// name
|
||||
// std::string sName = NSStringFinder::FindProperty(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
|
||||
// Content-Location
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentLocation{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
|
||||
// Content-ID
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentID{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
NSStringFinder::CutInside<std::string>(sContentID, "<", ">");
|
||||
}
|
||||
|
||||
if (sContentLocation.empty() && !sContentID.empty())
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
|
||||
// Content-Transfer-Encoding
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentEncoding{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
}
|
||||
|
||||
// charset
|
||||
std::string sCharset = "utf-8";
|
||||
|
||||
if (std::string::npos != unCharsetEnd && unCharsetBegin < unCharsetEnd)
|
||||
{
|
||||
sCharset = NSStringFinder::FindProperty(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "\"");
|
||||
}
|
||||
|
||||
// Content
|
||||
std::string sContent = sMhtContent.substr(unContentPosition, sMhtContent.length() - unContentPosition);
|
||||
|
||||
// std::wstring sExtention = NSFile::GetFileExtention(UTF8_TO_U(sName));
|
||||
// std::transform(sExtention.begin(), sExtention.end(), sExtention.begin(), tolower);
|
||||
// Основной документ
|
||||
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
|
||||
oRes.WriteString(mhtTohtml(sContent));
|
||||
else if ((NSStringFinder::Find(sContentType, "text") /*&& (sExtention.empty() || NSStringFinder::EqualOf(sExtention, {L"htm", L"html", L"xhtml", L"css"}))*/)
|
||||
|| (NSStringFinder::Equals(sContentType, "application/octet-stream") && NSStringFinder::Find(sContentLocation, "css")))
|
||||
{
|
||||
// Стили заключаются в тэг <style>
|
||||
const bool bAddTagStyle = NSStringFinder::Equals(sContentType, "text/css") /*|| NSStringFinder::Equals(sExtention, L"css")*/ || NSStringFinder::Find(sContentLocation, "css");
|
||||
|
||||
if (bAddTagStyle)
|
||||
oRes.WriteString("<style>");
|
||||
|
||||
if (NSStringFinder::Equals(sContentEncoding, "base64"))
|
||||
sContent = Base64ToString(sContent, sCharset);
|
||||
else if (NSStringFinder::EqualOf(sContentEncoding, {"8bit", "7bit"}) || sContentEncoding.empty())
|
||||
{
|
||||
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
}
|
||||
else if (NSStringFinder::Equals(sContentEncoding, "quoted-printable"))
|
||||
{
|
||||
sContent = QuotedPrintableDecode(sContent, sCharset);
|
||||
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
}
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "text/html"))
|
||||
sContent = U_TO_UTF8(htmlToXhtml(sContent, false));
|
||||
|
||||
oRes.WriteString(sContent);
|
||||
|
||||
if(bAddTagStyle)
|
||||
oRes.WriteString("</style>");
|
||||
}
|
||||
// Картинки
|
||||
else if ((NSStringFinder::Find(sContentType, "image") /*|| NSStringFinder::Equals(sExtention, L"gif")*/ || NSStringFinder::Equals(sContentType, "application/octet-stream")) &&
|
||||
NSStringFinder::Equals(sContentEncoding, "base64"))
|
||||
{
|
||||
// if (NSStringFinder::Equals(sExtention, L"ico") || NSStringFinder::Find(sContentType, "ico"))
|
||||
// sContentType = "image/jpg";
|
||||
// else if(NSStringFinder::Equals(sExtention, L"gif"))
|
||||
// sContentType = "image/gif";
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
sRes.insert(std::make_pair(sContentLocation, "data:" + sContentType + ";base64," + sContent));
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
}
|
||||
}
|
||||
|
||||
static std::string mhtTohtml(const std::string& sFileContent)
|
||||
{
|
||||
std::map<std::string, std::string> sRes;
|
||||
NSStringUtils::CStringBuilderA oRes;
|
||||
|
||||
// Поиск boundary
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindProperty(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
|
||||
size_t nFound{oData.m_unEndPosition};
|
||||
std::string sBoundary{oData.m_sValue};
|
||||
|
||||
if (sBoundary.empty())
|
||||
{
|
||||
size_t nFoundEnd = sFileContent.length();
|
||||
nFound = 0;
|
||||
ReadMht(sFileContent.substr(nFound, nFoundEnd), sRes, oRes);
|
||||
return oRes.GetData();
|
||||
}
|
||||
|
||||
NSStringFinder::CutInside<std::string>(sBoundary, "\"");
|
||||
|
||||
size_t nFoundEnd{nFound};
|
||||
|
||||
sBoundary = "--" + sBoundary;
|
||||
size_t nBoundaryLength = sBoundary.length();
|
||||
|
||||
nFound = sFileContent.find(sBoundary, nFound) + nBoundaryLength;
|
||||
|
||||
// Цикл по boundary
|
||||
while(nFound != std::string::npos)
|
||||
{
|
||||
nFoundEnd = sFileContent.find(sBoundary, nFound + nBoundaryLength);
|
||||
if(nFoundEnd == std::string::npos)
|
||||
break;
|
||||
|
||||
ReadMht(sFileContent.substr(nFound, nFoundEnd - nFound), sRes, oRes);
|
||||
|
||||
nFound = sFileContent.find(sBoundary, nFoundEnd);
|
||||
}
|
||||
|
||||
std::string sFile = oRes.GetData();
|
||||
for(const std::pair<std::string, std::string>& item : sRes)
|
||||
{
|
||||
std::string sName = item.first;
|
||||
size_t found = sFile.find(sName);
|
||||
size_t sfound = sName.rfind('/');
|
||||
if(found == std::string::npos && sfound != std::string::npos)
|
||||
found = sFile.find(sName.erase(0, sfound + 1));
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
size_t fq = sFile.find_last_of("\"\'>=", found);
|
||||
|
||||
if (std::string::npos == fq)
|
||||
break;
|
||||
|
||||
char ch = sFile[fq];
|
||||
if(ch != '\"' && ch != '\'')
|
||||
fq++;
|
||||
size_t tq = sFile.find_first_of("\"\'<> ", found) + 1;
|
||||
|
||||
if (std::string::npos == tq)
|
||||
break;
|
||||
|
||||
if(sFile[tq] != '\"' && sFile[tq] != '\'')
|
||||
tq--;
|
||||
if(ch != '>')
|
||||
{
|
||||
std::string is = '\"' + item.second + '\"';
|
||||
sFile.replace(fq, tq - fq, is);
|
||||
found = sFile.find(sName, fq + is.length());
|
||||
}
|
||||
else
|
||||
found = sFile.find(sName, tq);
|
||||
}
|
||||
}
|
||||
|
||||
return sFile;
|
||||
}
|
||||
|
||||
static std::wstring mhtToXhtml(std::string& sFileContent)
|
||||
{
|
||||
sFileContent = mhtTohtml(sFileContent);
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
|
||||
// Заменяет сущности &,<,> в text
|
||||
static void substitute_xml_entities_into_text(std::string& text)
|
||||
{
|
||||
// replacing & must come first
|
||||
replace_all(text, "&", "&");
|
||||
replace_all(text, "<", "<");
|
||||
replace_all(text, ">", ">");
|
||||
}
|
||||
|
||||
// After running through Gumbo, the values of type "" are replaced with the corresponding code '0x01'
|
||||
// Since the attribute value does not use control characters (value <= 0x09),
|
||||
// then just delete them, otherwise XmlUtils::CXmlLiteReader crashes on them.
|
||||
// bug#73486
|
||||
static void remove_control_symbols(std::string& text)
|
||||
{
|
||||
std::string::iterator itFound = std::find_if(text.begin(), text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
|
||||
while (itFound != text.end())
|
||||
{
|
||||
itFound = text.erase(itFound);
|
||||
itFound = std::find_if(itFound, text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
}
|
||||
}
|
||||
|
||||
// Заменяет сущности " в text
|
||||
static void substitute_xml_entities_into_attributes(std::string& text)
|
||||
{
|
||||
remove_control_symbols(text);
|
||||
substitute_xml_entities_into_text(text);
|
||||
replace_all(text, "\"", """);
|
||||
}
|
||||
|
||||
static std::string handle_unknown_tag(GumboStringPiece* text)
|
||||
{
|
||||
if (text->data == NULL)
|
||||
return "";
|
||||
GumboStringPiece gsp = *text;
|
||||
gumbo_tag_from_original_text(&gsp);
|
||||
std::string sAtr = std::string(gsp.data, gsp.length);
|
||||
size_t found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
sAtr.erase(found, 1);
|
||||
found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}", found);
|
||||
}
|
||||
return sAtr;
|
||||
}
|
||||
|
||||
static std::string get_tag_name(GumboNode* node)
|
||||
{
|
||||
std::string tagname = (node->type == GUMBO_NODE_DOCUMENT ? "document" : gumbo_normalized_tagname(node->v.element.tag));
|
||||
if (tagname.empty())
|
||||
tagname = handle_unknown_tag(&node->v.element.original_tag);
|
||||
return tagname;
|
||||
}
|
||||
|
||||
static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder)
|
||||
{
|
||||
if (node->v.document.has_doctype)
|
||||
{
|
||||
oBuilder.WriteString("<!DOCTYPE ");
|
||||
oBuilder.WriteString(node->v.document.name);
|
||||
std::string pi(node->v.document.public_identifier);
|
||||
remove_control_symbols(pi);
|
||||
if ((node->v.document.public_identifier != NULL) && !pi.empty())
|
||||
{
|
||||
oBuilder.WriteString(" PUBLIC \"");
|
||||
oBuilder.WriteString(pi);
|
||||
oBuilder.WriteString("\" \"");
|
||||
oBuilder.WriteString(node->v.document.system_identifier);
|
||||
oBuilder.WriteString("\"");
|
||||
}
|
||||
oBuilder.WriteString(">");
|
||||
}
|
||||
}
|
||||
|
||||
static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringBuilderA& atts)
|
||||
{
|
||||
std::vector<std::string> arrRepeat;
|
||||
for (size_t i = 0; i < attribs->length; ++i)
|
||||
{
|
||||
GumboAttribute* at = static_cast<GumboAttribute*>(attribs->data[i]);
|
||||
std::string sVal(at->value);
|
||||
std::string sName(at->name);
|
||||
|
||||
remove_control_symbols(sVal);
|
||||
remove_control_symbols(sName);
|
||||
|
||||
atts.WriteString(" ");
|
||||
|
||||
bool bCheck = false;
|
||||
size_t nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}");
|
||||
while(nBad != std::string::npos)
|
||||
{
|
||||
sName.erase(nBad, 1);
|
||||
nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}", nBad);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(sName.empty())
|
||||
continue;
|
||||
while(sName.front() >= '0' && sName.front() <= '9')
|
||||
{
|
||||
sName.erase(0, 1);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(bCheck)
|
||||
{
|
||||
GumboAttribute* check = gumbo_get_attribute(attribs, sName.c_str());
|
||||
if(check || std::find(arrRepeat.begin(), arrRepeat.end(), sName) != arrRepeat.end())
|
||||
continue;
|
||||
else
|
||||
arrRepeat.push_back(sName);
|
||||
}
|
||||
|
||||
if(sName.empty())
|
||||
continue;
|
||||
atts.WriteString(sName);
|
||||
|
||||
// determine original quote character used if it exists
|
||||
std::string qs ="\"";
|
||||
atts.WriteString("=");
|
||||
atts.WriteString(qs);
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
atts.WriteString(sVal);
|
||||
atts.WriteString(qs);
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA& contents, bool bCheckValidNode)
|
||||
{
|
||||
std::string key = "|" + get_tag_name(node) + "|";
|
||||
bool keep_whitespace = preserve_whitespace.find(key) != std::string::npos;
|
||||
bool is_inline = nonbreaking_inline.find(key) != std::string::npos;
|
||||
bool is_like_inline = treat_like_inline.find(key) != std::string::npos;
|
||||
|
||||
GumboVector* children = &node->v.element.children;
|
||||
|
||||
for (size_t i = 0; i < children->length; i++)
|
||||
{
|
||||
GumboNode* child = static_cast<GumboNode*> (children->data[i]);
|
||||
|
||||
if (child->type == GUMBO_NODE_TEXT)
|
||||
{
|
||||
std::string val(child->v.text.text);
|
||||
remove_control_symbols(val);
|
||||
substitute_xml_entities_into_text(val);
|
||||
|
||||
// Избавление от FF
|
||||
size_t found = val.find_first_of("\014");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
val.erase(found, 1);
|
||||
found = val.find_first_of("\014", found);
|
||||
}
|
||||
|
||||
contents.WriteString(val);
|
||||
}
|
||||
else if ((child->type == GUMBO_NODE_ELEMENT) || (child->type == GUMBO_NODE_TEMPLATE))
|
||||
prettyprint(child, contents, bCheckValidNode);
|
||||
else if (child->type == GUMBO_NODE_WHITESPACE)
|
||||
{
|
||||
if (keep_whitespace || is_inline || is_like_inline)
|
||||
contents.WriteString(child->v.text.text);
|
||||
}
|
||||
else if (child->type != GUMBO_NODE_COMMENT)
|
||||
{
|
||||
// Сообщение об ошибке
|
||||
// Does this actually exist: (child->type == GUMBO_NODE_CDATA)
|
||||
// fprintf(stderr, "unknown element of type: %d\n", child->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode)
|
||||
{
|
||||
// special case the document node
|
||||
if (node->type == GUMBO_NODE_DOCUMENT)
|
||||
{
|
||||
build_doctype(node, oBuilder);
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
remove_control_symbols(tagname);
|
||||
|
||||
if (NodeIsUnprocessed(tagname))
|
||||
return;
|
||||
|
||||
if (bCheckValidNode)
|
||||
bCheckValidNode = !IsUnckeckedNodes(tagname);
|
||||
|
||||
if (bCheckValidNode && html_tags.end() == std::find(html_tags.begin(), html_tags.end(), tagname))
|
||||
{
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string close = "";
|
||||
std::string closeTag = "";
|
||||
std::string key = "|" + tagname + "|";
|
||||
bool is_empty_tag = empty_tags.find(key) != std::string::npos;
|
||||
|
||||
// determine closing tag type
|
||||
if (is_empty_tag)
|
||||
close = "/";
|
||||
else
|
||||
closeTag = "</" + tagname + ">";
|
||||
|
||||
// build results
|
||||
oBuilder.WriteString("<" + tagname);
|
||||
|
||||
// build attr string
|
||||
const GumboVector* attribs = &node->v.element.attributes;
|
||||
build_attributes(attribs, oBuilder);
|
||||
oBuilder.WriteString(close + ">");
|
||||
|
||||
// prettyprint your contents
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
oBuilder.WriteString(closeTag);
|
||||
std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert);
|
||||
std::wstring mhtToXhtml(std::string& sFileContent);
|
||||
}
|
||||
|
||||
#endif // HTMLTOXHTML_H
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -5,6 +5,9 @@
|
||||
|
||||
namespace Md
|
||||
{
|
||||
#define MD_PARSER_FLAGS MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM | MD_FLAG_HARD_SOFT_BREAKS | MD_HTML_FLAG_XHTML | MD_FLAG_LATEXMATHSPANS
|
||||
#define MD_RENDERER_FLAGS MD_HTML_FLAG_XHTML
|
||||
|
||||
void ToHtml(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)
|
||||
{
|
||||
if (NULL != pData)
|
||||
@ -14,7 +17,7 @@ void ToHtml(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)
|
||||
std::string ConvertMdStringToHtml(const std::string& sMdString)
|
||||
{
|
||||
std::string sData;
|
||||
md_html(sMdString.c_str(), sMdString.length(), ToHtml, &sData, 0, 0);
|
||||
md_html(sMdString.c_str(), sMdString.length(), ToHtml, &sData, MD_PARSER_FLAGS, MD_RENDERER_FLAGS);
|
||||
return sData;
|
||||
}
|
||||
|
||||
@ -36,14 +39,13 @@ void WriteBaseHtmlStyles(NSFile::CFileBinary& oFile)
|
||||
oFile.WriteStringUTF8(L"img { vertical-align: middle; }");
|
||||
|
||||
// Styles for tables
|
||||
oFile.WriteStringUTF8(L"table { margin-bottom: 20px; width: 100%; max-width: 100%; border-spacing:0; border-collapse: collapse; border-color: gray;}");
|
||||
oFile.WriteStringUTF8(L"thead { display: table-header-group; vertical-align: middle; }");
|
||||
oFile.WriteStringUTF8(L"table { margin-bottom: 20px; width: 100%; max-width: 100%; border-spacing:0; border-collapse: collapse; border-color: gray; vertical-align:middle;}");
|
||||
oFile.WriteStringUTF8(L"thead { display: table-header-group;}");
|
||||
oFile.WriteStringUTF8(L"tr { display: table-row; }");
|
||||
oFile.WriteStringUTF8(L"th { text-align: left; display: table-cell; font-weight: bold; }");
|
||||
oFile.WriteStringUTF8(L"th { text-align: center; display: table-cell; font-weight: bold; }");
|
||||
|
||||
oFile.WriteStringUTF8(L"table thead tr th { vertical-align: bottom; border-bottom: 2px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table thead tr th, table tbody tr th, table thead tr td, table tbody tr td { padding 8px; line-height: 1.4; vertical-align: top; border-top: 1px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table > caption + thead > tr > th, table > colgroup + thead > tr > th, table > thead > tr > th, table > caption + thead > tr > td, table > colgroup + thead > tr > td, table > thead > tr > td { border-top: 0; }");
|
||||
oFile.WriteStringUTF8(L"table thead tr th, table thead tr td { border-bottom: 2px solid #ddd; border-top: none; }");
|
||||
oFile.WriteStringUTF8(L"table tbody tr th, table tbody tr td { padding 8px; line-height: 1.4; border-top: 1px solid #ddd; }");
|
||||
|
||||
// Styles for blockquote
|
||||
oFile.WriteStringUTF8(L"blockquote { border-left: 3px solid #e9e9e9; margin: 1.5em 0; padding: 0.5em 10px 0.5em 24px; font-size: 1.25rem; display: block; margin-top: 8pt; font-style: italic; color: #404040; }");
|
||||
@ -87,9 +89,7 @@ bool ConvertMdFileToHtml(const std::wstring& wsPathToMdFile, const std::wstring&
|
||||
|
||||
bool bResult = true;
|
||||
|
||||
if (0 != md_html(sMdData.c_str(), sMdData.length(), ToHtmlFile, &oFile,
|
||||
MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM,
|
||||
0))
|
||||
if (0 != md_html(sMdData.c_str(), sMdData.length(), ToHtmlFile, &oFile, MD_PARSER_FLAGS, MD_RENDERER_FLAGS))
|
||||
bResult = false;
|
||||
|
||||
oFile.WriteStringUTF8(L"</body></html>");
|
||||
|
||||
@ -90,7 +90,7 @@ static std::wstring convertUtf16ToWString(const UTF16 * Data, int nLength)
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
std::wstring wstr ((wchar_t *) pStrUtf32);
|
||||
std::wstring wstr ((wchar_t *) pStrUtf32, nLength);
|
||||
|
||||
delete [] pStrUtf32;
|
||||
return wstr;
|
||||
|
||||
@ -72,6 +72,10 @@ extern NSString *const SRHTTPResponseErrorKey;
|
||||
// Optional array of cookies (NSHTTPCookie objects) to apply to the connections
|
||||
@property (nonatomic, readwrite) NSArray * requestCookies;
|
||||
|
||||
// Optional proxy configuration dictionary (kCFStreamPropertyHTTPProxy format).
|
||||
// Set before calling -open. Example: Proxyman at 127.0.0.1:9090.
|
||||
@property (nonatomic, strong) NSDictionary *proxyDictionary;
|
||||
|
||||
// This returns the negotiated protocol.
|
||||
// It will be nil until after the handshake completes.
|
||||
@property (nonatomic, readonly, copy) NSString *protocol;
|
||||
|
||||
@ -619,7 +619,16 @@ static __strong NSData *CRLFCRLF;
|
||||
|
||||
_inputStream.delegate = self;
|
||||
_outputStream.delegate = self;
|
||||
|
||||
|
||||
if (self.proxyDictionary) {
|
||||
CFReadStreamSetProperty((__bridge CFReadStreamRef)_inputStream,
|
||||
kCFStreamPropertyHTTPProxy,
|
||||
(__bridge CFDictionaryRef)self.proxyDictionary);
|
||||
CFWriteStreamSetProperty((__bridge CFWriteStreamRef)_outputStream,
|
||||
kCFStreamPropertyHTTPProxy,
|
||||
(__bridge CFDictionaryRef)self.proxyDictionary);
|
||||
}
|
||||
|
||||
[self setupNetworkServiceType:_urlRequest.networkServiceType];
|
||||
}
|
||||
|
||||
|
||||
4
Common/3dParty/v8_89/.gitignore
vendored
4
Common/3dParty/v8_89/.gitignore
vendored
@ -1,6 +1,6 @@
|
||||
.cipd
|
||||
.gclient
|
||||
.gclient_entries
|
||||
.gclient*
|
||||
.gcs*
|
||||
v8
|
||||
depot_tools
|
||||
v8.data
|
||||
|
||||
@ -188,7 +188,7 @@ namespace NSNetwork
|
||||
else
|
||||
{
|
||||
NSURL* url = [NSURL URLWithString:escapedURL];
|
||||
NSData* urlData = [NSData dataWithContentsOfURL:url];
|
||||
NSData* urlData = [[NSData alloc] initWithContentsOfURL:url];
|
||||
if ( urlData )
|
||||
{
|
||||
NSString* filePath = StringWToNSString(m_sDownloadFilePath);
|
||||
|
||||
@ -38,6 +38,8 @@
|
||||
#include <memory>
|
||||
#include "../../../../../DesktopEditor/graphics/BaseThread.h"
|
||||
|
||||
#define _LOGGER_SOCKETS
|
||||
|
||||
namespace NSNetwork
|
||||
{
|
||||
namespace NSWebSocket
|
||||
@ -124,6 +126,10 @@ namespace NSNetwork
|
||||
}
|
||||
|
||||
//webSocket.connect(url, queryDst, sio::string_message::create(sAuth));
|
||||
#ifdef _LOGGER_SOCKETS
|
||||
m_socket->set_proxy_basic_auth("http://127.0.0.1:9090", "", "");
|
||||
#endif
|
||||
|
||||
m_connecting_in_process = true;
|
||||
m_socket->connect(m_base->url, queryDst, objAuth);
|
||||
|
||||
|
||||
@ -42,6 +42,8 @@
|
||||
#include <memory>
|
||||
#include "../../../../../DesktopEditor/graphics/BaseThread.h"
|
||||
|
||||
#define _LOGGER_SOCKETS
|
||||
|
||||
namespace NSNetwork
|
||||
{
|
||||
namespace NSWebSocket
|
||||
@ -113,6 +115,10 @@ namespace NSNetwork
|
||||
}
|
||||
|
||||
//webSocket.connect(url, queryDst, sio_no_tls::string_message::create(sAuth));
|
||||
#ifdef _LOGGER_SOCKETS
|
||||
m_socket->set_proxy_basic_auth("http://127.0.0.1:9090", "", "");
|
||||
#endif
|
||||
|
||||
m_connecting_in_process = true;
|
||||
m_socket->connect(m_base->url, queryDst, objAuth);
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
}
|
||||
|
||||
- (void)open
|
||||
{
|
||||
{
|
||||
if (m_url && m_url.length)
|
||||
{
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:m_url]];
|
||||
@ -58,6 +58,19 @@
|
||||
protocols:nil
|
||||
allowsUntrustedSSLCertificates:YES];
|
||||
self.socket.delegate = self;
|
||||
|
||||
#ifdef _LOGGER_SOCKETS
|
||||
self.socket.proxyDictionary = @{
|
||||
(NSString *)kCFNetworkProxiesHTTPEnable: @YES,
|
||||
(NSString *)kCFNetworkProxiesHTTPProxy: @"127.0.0.1",
|
||||
(NSString *)kCFNetworkProxiesHTTPPort: @9090,
|
||||
(NSString *)kCFNetworkProxiesHTTPSEnable: @YES,
|
||||
(NSString *)kCFNetworkProxiesHTTPSProxy: @"127.0.0.1",
|
||||
(NSString *)kCFNetworkProxiesHTTPSPort: @9090
|
||||
};
|
||||
NSLog(@"[SocketRocket] Proxyman proxy enabled: 127.0.0.1:9090");
|
||||
#endif
|
||||
|
||||
[self.socket open];
|
||||
}
|
||||
}
|
||||
@ -65,7 +78,7 @@
|
||||
|
||||
- (void)send:(NSString*)message
|
||||
{
|
||||
#if _LOGGER_SOCKETS
|
||||
#ifdef _LOGGER_SOCKETS
|
||||
|
||||
NSLog(@"------------------- SEND TO SOCKET -------------------");
|
||||
NSLog(@"%@", message);
|
||||
@ -101,7 +114,7 @@
|
||||
|
||||
- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message
|
||||
{
|
||||
#if _LOGGER_SOCKETS
|
||||
#ifdef _LOGGER_SOCKETS
|
||||
|
||||
NSLog(@"------------------- SOCKET RECEIVE MESSAGE -------------------");
|
||||
NSLog(@"%@", message);
|
||||
@ -119,7 +132,7 @@
|
||||
{
|
||||
m_listener->onOpen();
|
||||
|
||||
#if _LOGGER_SOCKETS
|
||||
#ifdef _LOGGER_SOCKETS
|
||||
|
||||
NSLog(@"------------------- SOCKET OPEN -------------------");
|
||||
NSLog(@"URL : %@", webSocket.url);
|
||||
@ -134,7 +147,7 @@
|
||||
{
|
||||
m_listener->onError(error.localizedDescription.stdstring);
|
||||
|
||||
#if _LOGGER_SOCKETS
|
||||
#ifdef _LOGGER_SOCKETS
|
||||
|
||||
NSLog(@"---------------------------------------------------------");
|
||||
NSLog(@"------------------- SOCKET ERROR : %@ ------------", error);
|
||||
@ -147,7 +160,7 @@
|
||||
{
|
||||
m_listener->onClose(code, reason.stdstring);
|
||||
|
||||
#if _LOGGER_SOCKETS
|
||||
#ifdef _LOGGER_SOCKETS
|
||||
|
||||
NSLog(@"---------------------------------------------------------");
|
||||
NSLog(@"------------------- SOCKET CLOSE : %@ -----------", reason);
|
||||
@ -158,7 +171,7 @@
|
||||
|
||||
- (void)webSocket:(SRWebSocket *)webSocket didReceivePong:(NSData *)pongPayload
|
||||
{
|
||||
#if _LOGGER_SOCKETS
|
||||
#ifdef _LOGGER_SOCKETS
|
||||
|
||||
NSString *str = [[NSString alloc] initWithData:pongPayload encoding:NSUTF8StringEncoding];
|
||||
|
||||
|
||||
@ -967,7 +967,12 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT;
|
||||
else if (0 == sExt.compare(L".md"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
|
||||
else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".xls") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xlsb"))
|
||||
else if (0 == sExt.compare(L".tsv"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV;
|
||||
else if (0 == sExt.compare(L".scsv"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV;
|
||||
else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".tsv") || 0 == sExt.compare(L".dsv") || 0 == sExt.compare(L".cssv")
|
||||
|| 0 == sExt.compare(L".xls") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xlsb"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
else if (0 == sExt.compare(L".html") || 0 == sExt.compare(L".htm"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML;
|
||||
@ -1799,6 +1804,10 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".ods";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV:
|
||||
return L".csv";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV:
|
||||
return L".tsv";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV:
|
||||
return L".scsv";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT:
|
||||
return L".fods";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS:
|
||||
@ -1988,7 +1997,11 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSB;
|
||||
if (L".xls" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS;
|
||||
if (L".csv" == ext)
|
||||
if (L".tsv" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV;
|
||||
if (L".scsv" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV;
|
||||
if (L".csv" == ext || L".dsv" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
if (L".fods" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT;
|
||||
|
||||
@ -87,13 +87,14 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0005
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0006
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0007
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSB AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0008
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0009
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000a
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000b
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_PACKAGE AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000c
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000d
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0014
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0024
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM 0x0200
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0001
|
||||
|
||||
214
Common/base.pri
214
Common/base.pri
@ -33,8 +33,7 @@ OO_BUILD_BRANDING = $$(OO_BRANDING)
|
||||
OO_DESTDIR_BUILD_OVERRIDE = $$(DESTDIR_BUILD_OVERRIDE)
|
||||
|
||||
win32 {
|
||||
CURRENT_YEAR = $$system(wmic PATH Win32_LocalTime GET ^Year /FORMAT:VALUE | find \"=\")
|
||||
CURRENT_YEAR = $$replace(CURRENT_YEAR, "Year=", "")
|
||||
CURRENT_YEAR = $$system(powershell -NoLogo -NoProfile -Command "(Get-Date).Year")
|
||||
CURRENT_YEAR = $$replace(CURRENT_YEAR, "\r", "")
|
||||
CURRENT_YEAR = $$replace(CURRENT_YEAR, "\n", "")
|
||||
CURRENT_YEAR = $$replace(CURRENT_YEAR, "\t", "")
|
||||
@ -119,13 +118,13 @@ win32:contains(QMAKE_TARGET.arch, arm64): {
|
||||
}
|
||||
|
||||
linux-clang-libc++ {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang-libc++")
|
||||
}
|
||||
linux-clang-libc++-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang-libc++")
|
||||
@ -181,9 +180,9 @@ mac {
|
||||
!core_ios {
|
||||
CONFIG += core_mac
|
||||
CONFIG += core_mac_64
|
||||
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
}
|
||||
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
}
|
||||
|
||||
# DEFINES
|
||||
@ -200,32 +199,58 @@ core_win_64 {
|
||||
DEFINES += WIN64 _WIN64
|
||||
}
|
||||
|
||||
defineTest(startsWith) {
|
||||
tmp = $$2
|
||||
tmp ~= s,^$$re_escape($$1),,
|
||||
!equals(tmp, $$2): return(true)
|
||||
return(false)
|
||||
}
|
||||
|
||||
core_linux {
|
||||
DEFINES += LINUX _LINUX
|
||||
|
||||
QMAKE_CUSTOM_SYSROOT = $$(QMAKE_CUSTOM_SYSROOT)
|
||||
QMAKE_CUSTOM_SYSROOT_BIN = $$(QMAKE_CUSTOM_SYSROOT)/usr/bin/
|
||||
QMAKE_CUSTOM_SYSROOT = $$(QMAKE_CUSTOM_SYSROOT)
|
||||
!isEmpty(QMAKE_CUSTOM_SYSROOT) {
|
||||
CONFIG += core_linix_use_sysroot
|
||||
message("using custom sysroot $$QMAKE_CUSTOM_SYSROOT")
|
||||
|
||||
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_CFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_CXXFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_LFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
}
|
||||
QMAKE_CUSTOM_SYSROOT_BIN = $$(QMAKE_CUSTOM_SYSROOT_BIN)
|
||||
isEmpty(QMAKE_CUSTOM_SYSROOT_BIN) {
|
||||
QMAKE_CUSTOM_SYSROOT_BIN = $$QMAKE_CUSTOM_SYSROOT/usr/bin
|
||||
}
|
||||
QMAKE_CUSTOM_SYSROOT_BIN = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , /)
|
||||
|
||||
startsWith($$QMAKE_CUSTOM_SYSROOT, $$QMAKE_CUSTOM_SYSROOT_BIN) {
|
||||
message("Using compilers from same 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_AR = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "ar") cqs
|
||||
QMAKE_RANLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "ranlib")
|
||||
QMAKE_STRIP = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "strip")
|
||||
} else {
|
||||
message("Using cross-compilers from host sysroot")
|
||||
QMAKE_CC = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-gcc")
|
||||
QMAKE_CXX = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-g++")
|
||||
QMAKE_LINK = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-g++")
|
||||
QMAKE_LINK_SHLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-g++")
|
||||
QMAKE_AR = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-ar") cqs
|
||||
QMAKE_RANLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-ranlib")
|
||||
QMAKE_STRIP = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-strip")
|
||||
QMAKE_OBJCOPY = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-objcopy")
|
||||
}
|
||||
|
||||
QMAKE_CFLAGS += --sysroot=$$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_CXXFLAGS += --sysroot=$$QMAKE_CUSTOM_SYSROOT -std=gnu++1y
|
||||
|
||||
QMAKE_LFLAGS += --sysroot=$$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_INCDIR += $$QMAKE_CUSTOM_SYSROOT/usr/include
|
||||
}
|
||||
}
|
||||
|
||||
gcc {
|
||||
COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion")
|
||||
COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion")
|
||||
COMPILER_MAJOR_VERSION_ARRAY = $$split(COMPILER_VERSION, ".")
|
||||
COMPILER_MAJOR_VERSION = $$member(COMPILER_MAJOR_VERSION_ARRAY, 0)
|
||||
lessThan(COMPILER_MAJOR_VERSION, 5): CONFIG += build_gcc_less_5
|
||||
@ -255,6 +280,11 @@ core_mac {
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
|
||||
!apple_silicon:QMAKE_APPLE_DEVICE_ARCHS = x86_64
|
||||
}
|
||||
|
||||
!core_debug {
|
||||
equals(TEMPLATE, app):QMAKE_POST_LINK += strip $(TARGET)
|
||||
# TODO: plugin!
|
||||
}
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
@ -313,6 +343,10 @@ core_linux {
|
||||
core_linux {
|
||||
equals(TEMPLATE, app):CONFIG += core_static_link_libstd
|
||||
plugin:CONFIG += core_static_link_libstd
|
||||
|
||||
|
||||
equals(TEMPLATE, app):QMAKE_LFLAGS_RELEASE += -Wl,-s
|
||||
plugin:QMAKE_LFLAGS_RELEASE += -Wl,-s
|
||||
}
|
||||
|
||||
core_win_32 {
|
||||
@ -322,7 +356,7 @@ core_win_64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_64
|
||||
}
|
||||
core_win_arm64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_arm64
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_arm64
|
||||
}
|
||||
core_linux_32 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = linux_32
|
||||
@ -344,27 +378,6 @@ core_linux_arm {
|
||||
linux_arm64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = linux_arm64
|
||||
DEFINES += _ARM_ALIGN_
|
||||
|
||||
ARM64_TOOLCHAIN_BIN = $$(ARM64_TOOLCHAIN_BIN)
|
||||
ARM64_TOOLCHAIN_BIN_PREFIX = $$(ARM64_TOOLCHAIN_BIN_PREFIX)
|
||||
|
||||
!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++")
|
||||
QMAKE_LINK = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "g++")
|
||||
QMAKE_LINK_SHLIB = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "g++")
|
||||
|
||||
QMAKE_AR = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "ar cqs")
|
||||
QMAKE_OBJCOPY = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "objcopy")
|
||||
QMAKE_NM = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "nm -P")
|
||||
QMAKE_STRIP = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "strip")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
core_ios {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = ios
|
||||
@ -465,6 +478,15 @@ core_android {
|
||||
!core_android_no_unistd {
|
||||
DEFINES += HAVE_UNISTD_H HAVE_FCNTL_H
|
||||
}
|
||||
|
||||
core_release {
|
||||
QMAKE_CFLAGS += -g0
|
||||
QMAKE_CXXFLAGS += -g0
|
||||
QMAKE_LFLAGS += -Wl,-s
|
||||
|
||||
QMAKE_CFLAGS -= -fno-limit-debug-info
|
||||
QMAKE_CXXFLAGS -= -fno-limit-debug-info
|
||||
}
|
||||
}
|
||||
|
||||
core_debug {
|
||||
@ -691,3 +713,105 @@ ADD_INC_PATH = $$(ADDITIONAL_INCLUDE_PATH)
|
||||
!disable_precompiled_header {
|
||||
CONFIG += precompile_header
|
||||
}
|
||||
|
||||
SWIFT_SOURCES=
|
||||
defineTest(UseSwift) {
|
||||
isEmpty(SWIFT_SOURCES): return(false)
|
||||
# work only on ios and mac
|
||||
!core_ios:!core_mac {
|
||||
return(false)
|
||||
}
|
||||
|
||||
# path to the bridging header that exposes Objective-C code to Swift
|
||||
BRIDGING_HEADER = $$1
|
||||
# sdk and toolchain (set from environment variables)
|
||||
SDK_PATH = $$(SDK_PATH)
|
||||
XCODE_TOOLCHAIN_PATH = $$(XCODE_TOOLCHAIN_PATH)
|
||||
|
||||
IOS_TARGET_PLATFORM = apple-ios11.0
|
||||
SWIFT_GEN_HEADERS_PATH = $$PWD_ROOT_DIR/core_build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
|
||||
ARCHS = arm64
|
||||
# simulator
|
||||
xcframework_platform_ios_simulator {
|
||||
IOS_TARGET_PLATFORM = $${IOS_TARGET_PLATFORM}-simulator
|
||||
SWIFT_GEN_HEADERS_PATH = $$SWIFT_GEN_HEADERS_PATH/simulator
|
||||
ARCHS += x86_64
|
||||
}
|
||||
|
||||
# add swift compiler for each architecture
|
||||
SWIFT_COMPILERS_OUT =
|
||||
for(ARCH, ARCHS) {
|
||||
COMPILER_NAME = swift_compiler_$${ARCH}
|
||||
COMPILER_OUTPUT = $$SWIFT_GEN_HEADERS_PATH/swift_module_$${ARCH}.o
|
||||
SWIFT_COMPILERS_OUT += $$COMPILER_OUTPUT
|
||||
|
||||
$${COMPILER_NAME}.name = SwiftCompiler_$${ARCH}
|
||||
$${COMPILER_NAME}.input = SWIFT_SOURCES
|
||||
$${COMPILER_NAME}.output = $$COMPILER_OUTPUT
|
||||
SWIFT_CMD = swiftc -c $$SWIFT_SOURCES \
|
||||
-module-name SwiftModule \
|
||||
-whole-module-optimization \
|
||||
-emit-objc-header \
|
||||
-emit-objc-header-path $$SWIFT_GEN_HEADERS_PATH/SwiftModule-Swift.h \
|
||||
-emit-object \
|
||||
-sdk $$SDK_PATH \
|
||||
-target $${ARCH}-$${IOS_TARGET_PLATFORM} \
|
||||
-o $$COMPILER_OUTPUT \
|
||||
-framework UIKit
|
||||
|
||||
!isEmpty(BRIDGING_HEADER) {
|
||||
SWIFT_CMD += -import-objc-header $$BRIDGING_HEADER
|
||||
}
|
||||
|
||||
$${COMPILER_NAME}.commands = $$SWIFT_CMD
|
||||
$${COMPILER_NAME}.CONFIG = combine target_predeps no_link
|
||||
|
||||
export($${COMPILER_NAME}.name)
|
||||
export($${COMPILER_NAME}.input)
|
||||
export($${COMPILER_NAME}.output)
|
||||
export($${COMPILER_NAME}.commands)
|
||||
export($${COMPILER_NAME}.CONFIG)
|
||||
QMAKE_EXTRA_COMPILERS += $${COMPILER_NAME}
|
||||
}
|
||||
|
||||
# add lipo tool execution to form universal binary
|
||||
LIPO_OUT = $$SWIFT_GEN_HEADERS_PATH/swift_module.o
|
||||
lipo_tool.name = LipoTool
|
||||
# as input for lipo_tool we set SWIFT_SOURCES (not SWIFT_COMPILERS_OUT as it won't be executed otherwise!)
|
||||
lipo_tool.input = SWIFT_SOURCES
|
||||
# compiled swift sources go into depends
|
||||
lipo_tool.depends = $$SWIFT_COMPILERS_OUT
|
||||
lipo_tool.output = $$LIPO_OUT
|
||||
lipo_tool.commands = lipo -create $$SWIFT_COMPILERS_OUT -output $$LIPO_OUT
|
||||
lipo_tool.CONFIG = combine target_predeps no_link
|
||||
lipo_tool.variable_out = OBJECTS
|
||||
|
||||
export(lipo_tool.name)
|
||||
export(lipo_tool.input)
|
||||
export(lipo_tool.depends)
|
||||
export(lipo_tool.output)
|
||||
export(lipo_tool.commands)
|
||||
export(lipo_tool.CONFIG)
|
||||
export(lipo_tool.variable_out)
|
||||
QMAKE_EXTRA_COMPILERS += lipo_tool
|
||||
|
||||
export(QMAKE_EXTRA_COMPILERS)
|
||||
|
||||
INCLUDEPATH += $$SWIFT_GEN_HEADERS_PATH
|
||||
export(INCLUDEPATH)
|
||||
|
||||
# link with libs from toolchain
|
||||
SWIFT_LIB_PATH = $$XCODE_TOOLCHAIN_PATH/usr/lib/swift/iphoneos
|
||||
xcframework_platform_ios_simulator {
|
||||
SWIFT_LIB_PATH = $$XCODE_TOOLCHAIN_PATH/usr/lib/swift/iphonesimulator
|
||||
}
|
||||
LIBS += -L$$SWIFT_LIB_PATH
|
||||
LIBS += -lswiftCore -lswiftFoundation -lswiftObjectiveC
|
||||
|
||||
export(LIBS)
|
||||
|
||||
OTHER_FILES += $$SWIFT_SOURCES
|
||||
export(OTHER_FILES)
|
||||
return(true)
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,10 @@
|
||||
#undef DeleteFile
|
||||
#endif
|
||||
|
||||
#if defined(GetSystemDirectory)
|
||||
#undef GetSystemDirectory
|
||||
#endif
|
||||
|
||||
#ifndef _BUILD_FILE_CROSSPLATFORM_H_
|
||||
#define _BUILD_FILE_CROSSPLATFORM_H_
|
||||
|
||||
|
||||
@ -246,6 +246,11 @@ namespace NSSystemPath
|
||||
|
||||
wsNewPath.pop_back();
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
if (L'/' == strPath[0] || L'\\' == strPath[0])
|
||||
return L'/' + wsNewPath;
|
||||
#endif
|
||||
|
||||
return wsNewPath;
|
||||
}
|
||||
|
||||
|
||||
@ -195,6 +195,16 @@ namespace NSStringUtils
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = m_lSize;
|
||||
}
|
||||
|
||||
CStringBuilder::CStringBuilder(size_t nSize)
|
||||
{
|
||||
m_lSize = nSize;
|
||||
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
|
||||
|
||||
m_lSizeCur = 0;
|
||||
m_pDataCur = m_pData;
|
||||
return;
|
||||
}
|
||||
CStringBuilder::~CStringBuilder()
|
||||
{
|
||||
if (NULL != m_pData)
|
||||
|
||||
@ -86,6 +86,7 @@ namespace NSStringUtils
|
||||
|
||||
public:
|
||||
CStringBuilder();
|
||||
CStringBuilder(size_t nSize);
|
||||
virtual ~CStringBuilder();
|
||||
|
||||
virtual void AddSize(size_t nSize);
|
||||
|
||||
@ -60,6 +60,7 @@ namespace NSSystemUtils
|
||||
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_EnvSigningKeystorePassphrase = L"SIGNING_KEYSTORE_PASSPHRASE";
|
||||
|
||||
KERNEL_DECL std::string GetEnvVariableA(const std::wstring& strName);
|
||||
KERNEL_DECL std::wstring GetEnvVariable(const std::wstring& strName);
|
||||
|
||||
@ -26,7 +26,7 @@ def _loadLibrary(path):
|
||||
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'
|
||||
path = path + '/docbuilder.c.framework/Versions/A'
|
||||
library_name = 'docbuilder.c'
|
||||
|
||||
_lib = ctypes.CDLL(path + '/' + library_name)
|
||||
|
||||
@ -347,11 +347,11 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
}
|
||||
|
||||
if (!bIsBreak)
|
||||
bIsBreak = !this->ExecuteCommand(L"Api.asc_nativeInitBuilder();");
|
||||
bIsBreak = !this->ExecuteCommand(L"Asc.editor.asc_nativeInitBuilder();");
|
||||
if (!bIsBreak)
|
||||
bIsBreak = !this->ExecuteCommand(L"Api.asc_SetSilentMode(true);");
|
||||
bIsBreak = !this->ExecuteCommand(L"Asc.editor.asc_SetSilentMode(true);");
|
||||
if (!bIsBreak)
|
||||
bIsBreak = !this->ExecuteCommand(L"Api.asc_showComments();");
|
||||
bIsBreak = !this->ExecuteCommand(L"Asc.editor.asc_showComments();");
|
||||
|
||||
LOGGER_SPEED_LAP("open");
|
||||
|
||||
@ -425,7 +425,7 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
bIsSilentMode = true;
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);", NULL, isEnterContext);
|
||||
this->ExecuteCommand(L"Asc.editor.asc_SetSilentMode(false);", NULL, isEnterContext);
|
||||
|
||||
std::wstring strError;
|
||||
bool bIsError = Doct_renderer_SaveFile_ForBuilder(_formatDst,
|
||||
@ -437,7 +437,7 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
sJsonParams);
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);", NULL, isEnterContext);
|
||||
this->ExecuteCommand(L"Asc.editor.asc_SetSilentMode(true);", NULL, isEnterContext);
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
@ -1507,7 +1507,7 @@ namespace NSDoctRenderer
|
||||
if (m_pInternal->m_oParams.m_bSaveWithDoctrendererMode)
|
||||
{
|
||||
// перед сохранением в такой схеме нужно скинуть изменения
|
||||
this->ExecuteCommand(L"Api.asc_Save();");
|
||||
this->ExecuteCommand(L"Asc.editor.asc_Save();");
|
||||
}
|
||||
|
||||
const wchar_t* sParams = NULL;
|
||||
|
||||
@ -287,7 +287,10 @@ namespace NSDoctRenderer
|
||||
|
||||
JSSmart<CJSObject> js_objectApi = api_js_maybe_null;
|
||||
if (!js_objectApi.IsInit() || js_objectApi->isUndefined())
|
||||
js_objectApi = global_js->get("Api")->toObject();
|
||||
{
|
||||
JSSmart<CJSObject> js_objectAsc = global_js->get("Asc")->toObject();
|
||||
js_objectApi = js_objectAsc->get("editor")->toObject();
|
||||
}
|
||||
|
||||
bool bIsBreak = false;
|
||||
if (js_objectApi->isUndefined() || !js_objectApi->isObject())
|
||||
@ -687,7 +690,8 @@ namespace NSDoctRenderer
|
||||
bIsBreak = true;
|
||||
}
|
||||
|
||||
js_objectApi = global_js->get("Api")->toObject();
|
||||
JSSmart<CJSObject> js_objectAsc = global_js->get("Asc")->toObject();
|
||||
js_objectApi = js_objectAsc->get("editor")->toObject();
|
||||
if (try_catch->Check())
|
||||
{
|
||||
strError = L"code=\"open\"";
|
||||
|
||||
@ -120,7 +120,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
bool OpenFile(const std::wstring& sFile, const std::wstring& sPassword)
|
||||
bool OpenFile(const std::wstring& sFile, const wchar_t* sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
@ -171,7 +171,7 @@ public:
|
||||
|
||||
return m_pFile ? true : false;
|
||||
}
|
||||
bool OpenFile(BYTE* data, LONG size, const std::wstring& sPassword)
|
||||
bool OpenFile(BYTE* data, LONG size, const wchar_t* sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
@ -245,7 +245,18 @@ public:
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CheckOwnerPassword(const wchar_t* sPassword)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->CheckOwnerPassword(sPassword);
|
||||
return true;
|
||||
}
|
||||
bool CheckPerm(int nPerm)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->CheckPerm(nPerm);
|
||||
return true;
|
||||
}
|
||||
BYTE* GetInfo()
|
||||
{
|
||||
NSWasm::CData oRes;
|
||||
@ -443,6 +454,20 @@ public:
|
||||
if (m_nType == 0)
|
||||
((CPdfFile*)m_pFile)->SetCMapMemory(data, size);
|
||||
}
|
||||
void SetScanPageFonts(int nPageIndex)
|
||||
{
|
||||
if (NULL == m_pImageStorage)
|
||||
m_pImageStorage = NSDocxRenderer::CreateWasmImageStorage();
|
||||
|
||||
CDocxRenderer oRenderer(m_pApplicationFonts);
|
||||
oRenderer.SetExternalImageStorage(m_pImageStorage);
|
||||
oRenderer.SetTextAssociationType(NSDocxRenderer::TextAssociationType::tatParagraphToShape);
|
||||
|
||||
oRenderer.ScanPageBin(m_pFile, nPageIndex);
|
||||
|
||||
if (m_nType == 0)
|
||||
((CPdfFile*)m_pFile)->SetPageFonts(nPageIndex);
|
||||
}
|
||||
BYTE* ScanPage(int nPageIndex, int mode)
|
||||
{
|
||||
if (NULL == m_pImageStorage)
|
||||
@ -479,6 +504,9 @@ public:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (m_nType == 0)
|
||||
((CPdfFile*)m_pFile)->SetPageFonts(nPageIndex);
|
||||
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return res;
|
||||
@ -567,6 +595,19 @@ public:
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
BYTE* GetGIDByUnicode(const std::string& sPathA)
|
||||
{
|
||||
if (m_nType != 0)
|
||||
return NULL;
|
||||
std::wstring sFontName = UTF8_TO_U(sPathA);
|
||||
return ((CPdfFile*)m_pFile)->GetGIDByUnicode(sFontName);
|
||||
}
|
||||
BYTE* GetGIDByUnicode(const std::wstring& wsPathA)
|
||||
{
|
||||
if (m_nType != 0)
|
||||
return NULL;
|
||||
return ((CPdfFile*)m_pFile)->GetGIDByUnicode(wsPathA);
|
||||
}
|
||||
|
||||
std::wstring GetFontBinaryNative(const std::wstring& sName)
|
||||
{
|
||||
|
||||
@ -26,7 +26,8 @@ CDrawingFileEmbed::~CDrawingFileEmbed()
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::OpenFile(JSSmart<CJSValue> sFile, JSSmart<CJSValue> sPassword)
|
||||
{
|
||||
bool bResult = m_pFile->OpenFile(sFile->toStringW(), sPassword->isString() ? sPassword->toStringW() : L"");
|
||||
std::wstring wsPassword = sPassword->isString() ? sPassword->toStringW() : L"";
|
||||
bool bResult = m_pFile->OpenFile(sFile->toStringW(), sPassword->isString() ? wsPassword.c_str() : NULL);
|
||||
return CJSContext::createBool(bResult);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::CloseFile()
|
||||
@ -136,6 +137,10 @@ JSSmart<CJSValue> CDrawingFileEmbed::DestroyTextInfo()
|
||||
m_pFile->DestroyTextInfo();
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetGIDByUnicode(JSSmart<CJSValue> sId)
|
||||
{
|
||||
return WasmMemoryToJS(m_pFile->GetGIDByUnicode(sId->toStringW()));
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::IsNeedCMap()
|
||||
{
|
||||
return CJSContext::createBool(false);
|
||||
@ -144,6 +149,11 @@ JSSmart<CJSValue> CDrawingFileEmbed::ScanPage(JSSmart<CJSValue> nPageIndex, JSSm
|
||||
{
|
||||
return WasmMemoryToJS(m_pFile->ScanPage(nPageIndex->toInt32(), mode->toInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::SetScanPageFonts(JSSmart<CJSValue> nPageIndex)
|
||||
{
|
||||
m_pFile->SetScanPageFonts(nPageIndex->toInt32());
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetImageBase64(JSSmart<CJSValue> rId)
|
||||
{
|
||||
@ -242,6 +252,17 @@ JSSmart<CJSValue> CDrawingFileEmbed::UndoRedact()
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::CheckOwnerPassword(JSSmart<CJSValue> sPassword)
|
||||
{
|
||||
std::wstring wsPassword = sPassword->isString() ? sPassword->toStringW() : L"";
|
||||
bool bResult = m_pFile->CheckOwnerPassword(sPassword->isString() ? wsPassword.c_str() : NULL);
|
||||
return CJSContext::createBool(bResult);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::CheckPerm(JSSmart<CJSValue> nPerm)
|
||||
{
|
||||
return CJSContext::createBool(m_pFile->CheckPerm(nPerm->toInt32()));
|
||||
}
|
||||
|
||||
bool EmbedDrawingFile(JSSmart<NSJSBase::CJSContext>& context, IOfficeDrawingFile* pFile)
|
||||
{
|
||||
CJSContext::Embed<CDrawingFileEmbed>(false);
|
||||
|
||||
@ -43,9 +43,11 @@ public:
|
||||
JSSmart<CJSValue> GetFontBinary(JSSmart<CJSValue> Id);
|
||||
JSSmart<CJSValue> GetGlyphs(JSSmart<CJSValue> nPageIndex);
|
||||
JSSmart<CJSValue> DestroyTextInfo();
|
||||
JSSmart<CJSValue> GetGIDByUnicode(JSSmart<CJSValue> sId);
|
||||
|
||||
JSSmart<CJSValue> IsNeedCMap();
|
||||
JSSmart<CJSValue> ScanPage(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> mode);
|
||||
JSSmart<CJSValue> SetScanPageFonts(JSSmart<CJSValue> nPageIndex);
|
||||
|
||||
JSSmart<CJSValue> GetImageBase64(JSSmart<CJSValue> rId);
|
||||
|
||||
@ -57,6 +59,9 @@ public:
|
||||
JSSmart<CJSValue> RedactPage(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> arrRedactBox, JSSmart<CJSValue> dataFiller);
|
||||
JSSmart<CJSValue> UndoRedact();
|
||||
|
||||
JSSmart<CJSValue> CheckOwnerPassword(JSSmart<CJSValue> sPassword);
|
||||
JSSmart<CJSValue> CheckPerm(JSSmart<CJSValue> nPerm);
|
||||
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
|
||||
@ -194,6 +194,9 @@ JSSmart<CJSValue> CNativeControlEmbed::ZipOpenBase64(JSSmart<CJSValue> name)
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::ZipFileAsString(JSSmart<CJSValue> name)
|
||||
{
|
||||
if (m_pInternal->m_oZipWorker.m_sTmpFolder.empty())
|
||||
return CJSContext::createUndefined();
|
||||
|
||||
BYTE* pData = NULL;
|
||||
DWORD len = 0;
|
||||
m_pInternal->m_oZipWorker.GetFileData(name->toStringW(), pData, len);
|
||||
@ -202,6 +205,9 @@ JSSmart<CJSValue> CNativeControlEmbed::ZipFileAsString(JSSmart<CJSValue> name)
|
||||
|
||||
JSSmart<CJSValue> CNativeControlEmbed::ZipFileAsBinary(JSSmart<CJSValue> name)
|
||||
{
|
||||
if (m_pInternal->m_oZipWorker.m_sTmpFolder.empty())
|
||||
return CJSContext::createUndefined();
|
||||
|
||||
return CJSContext::createUint8Array(m_pInternal->m_oZipWorker.m_sTmpFolder + L"/" + name->toStringW());
|
||||
}
|
||||
|
||||
|
||||
@ -23,13 +23,19 @@
|
||||
-(JSValue*) GetFontBinary : (JSValue*)Id;
|
||||
-(JSValue*) GetGlyphs : (JSValue*)nPageIndex;
|
||||
-(JSValue*) DestroyTextInfo;
|
||||
-(JSValue*) GetGIDByUnicode : (JSValue*)sId;
|
||||
-(JSValue*) IsNeedCMap;
|
||||
-(JSValue*) ScanPage : (JSValue*)nPageIndex : (JSValue*)mode;
|
||||
-(JSValue*) SetScanPageFonts : (JSValue*)nPageIndex;
|
||||
-(JSValue*) GetImageBase64 : (JSValue*)rId;
|
||||
-(JSValue*) FreeWasmData : (JSValue*)typedArray;
|
||||
-(JSValue*) SplitPages : (JSValue*)arrPageIndexes : (JSValue*)data;
|
||||
-(JSValue*) MergePages : (JSValue*)data : (JSValue*)nMaxID : (JSValue*)sPrefixForm;
|
||||
-(JSValue*) UnmergePages;
|
||||
-(JSValue*) RedactPage : (JSValue*)nPageIndex : (JSValue*)arrRedactBox : (JSValue*)dataFiller;
|
||||
-(JSValue*) UndoRedact;
|
||||
-(JSValue*) CheckOwnerPassword : (JSValue*)sPassword;
|
||||
-(JSValue*) CheckPerm : (JSValue*)nPerm;
|
||||
@end
|
||||
|
||||
@interface CJSCDrawingFileEmbed : NSObject<IJSCDrawingFileEmbed, JSEmbedObjectProtocol>
|
||||
@ -60,13 +66,19 @@ FUNCTION_WRAPPER_JS_6(GetAnnotationsAP, GetAnnotationsAP)
|
||||
FUNCTION_WRAPPER_JS_1(GetFontBinary, GetFontBinary)
|
||||
FUNCTION_WRAPPER_JS_1(GetGlyphs, GetGlyphs)
|
||||
FUNCTION_WRAPPER_JS_0(DestroyTextInfo, DestroyTextInfo)
|
||||
FUNCTION_WRAPPER_JS_1(GetGIDByUnicode, GetGIDByUnicode)
|
||||
FUNCTION_WRAPPER_JS_0(IsNeedCMap, IsNeedCMap)
|
||||
FUNCTION_WRAPPER_JS_2(ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_JS_1(SetScanPageFonts, SetScanPageFonts)
|
||||
FUNCTION_WRAPPER_JS_1(GetImageBase64, GetImageBase64)
|
||||
FUNCTION_WRAPPER_JS_1(FreeWasmData, FreeWasmData)
|
||||
FUNCTION_WRAPPER_JS_2(SplitPages, SplitPages)
|
||||
FUNCTION_WRAPPER_JS_3(MergePages, MergePages)
|
||||
FUNCTION_WRAPPER_JS_0(UnmergePages, UnmergePages)
|
||||
FUNCTION_WRAPPER_JS_3(RedactPage, RedactPage)
|
||||
FUNCTION_WRAPPER_JS_0(UndoRedact, UndoRedact)
|
||||
FUNCTION_WRAPPER_JS_1(CheckOwnerPassword, CheckOwnerPassword)
|
||||
FUNCTION_WRAPPER_JS_1(CheckPerm, CheckPerm)
|
||||
@end
|
||||
|
||||
class CDrawingFileEmbedAdapter : public CJSEmbedObjectAdapterJSC
|
||||
|
||||
@ -26,8 +26,10 @@ namespace NSDrawingFileEmbed
|
||||
FUNCTION_WRAPPER_V8_1(_GetFontBinary, GetFontBinary)
|
||||
FUNCTION_WRAPPER_V8_1(_GetGlyphs, GetGlyphs)
|
||||
FUNCTION_WRAPPER_V8_0(_DestroyTextInfo, DestroyTextInfo)
|
||||
FUNCTION_WRAPPER_V8_1(_GetGIDByUnicode, GetGIDByUnicode)
|
||||
FUNCTION_WRAPPER_V8_0(_IsNeedCMap, IsNeedCMap)
|
||||
FUNCTION_WRAPPER_V8_2(_ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_V8_1(_SetScanPageFonts, SetScanPageFonts)
|
||||
FUNCTION_WRAPPER_V8_1(_GetImageBase64, GetImageBase64)
|
||||
FUNCTION_WRAPPER_V8_1(_FreeWasmData, FreeWasmData)
|
||||
FUNCTION_WRAPPER_V8_2(_SplitPages, SplitPages)
|
||||
@ -35,6 +37,8 @@ namespace NSDrawingFileEmbed
|
||||
FUNCTION_WRAPPER_V8_0(_UnmergePages, UnmergePages)
|
||||
FUNCTION_WRAPPER_V8_3(_RedactPage, RedactPage)
|
||||
FUNCTION_WRAPPER_V8_0(_UndoRedact, UndoRedact)
|
||||
FUNCTION_WRAPPER_V8_1(_CheckOwnerPassword, CheckOwnerPassword)
|
||||
FUNCTION_WRAPPER_V8_1(_CheckPerm, CheckPerm)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
@ -60,15 +64,19 @@ namespace NSDrawingFileEmbed
|
||||
NSV8Objects::Template_Set(result, "GetFontBinary", _GetFontBinary);
|
||||
NSV8Objects::Template_Set(result, "GetGlyphs", _GetGlyphs);
|
||||
NSV8Objects::Template_Set(result, "DestroyTextInfo", _DestroyTextInfo);
|
||||
NSV8Objects::Template_Set(result, "GetGIDByUnicode", _GetGIDByUnicode);
|
||||
NSV8Objects::Template_Set(result, "IsNeedCMap", _IsNeedCMap);
|
||||
NSV8Objects::Template_Set(result, "ScanPage", _ScanPage);
|
||||
NSV8Objects::Template_Set(result, "SetScanPageFonts", _SetScanPageFonts);
|
||||
NSV8Objects::Template_Set(result, "GetImageBase64", _GetImageBase64);
|
||||
NSV8Objects::Template_Set(result, "FreeWasmData", _FreeWasmData);
|
||||
NSV8Objects::Template_Set(result, "SplitPages", _SplitPages);
|
||||
NSV8Objects::Template_Set(result, "MergePages", _MergePages);
|
||||
NSV8Objects::Template_Set(result, "UnmergePages", _UnmergePages);
|
||||
NSV8Objects::Template_Set(result, "RedactPage", _RedactPage);
|
||||
NSV8Objects::Template_Set(result, "RedactPage", _RedactPage);
|
||||
NSV8Objects::Template_Set(result, "UndoRedact", _UndoRedact);
|
||||
NSV8Objects::Template_Set(result, "CheckOwnerPassword", _CheckOwnerPassword);
|
||||
NSV8Objects::Template_Set(result, "CheckPerm", _CheckPerm);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
@ -461,6 +461,8 @@ namespace NSJSBase
|
||||
v8::SnapshotCreator snapshotCreator;
|
||||
v8::Isolate* isolate = snapshotCreator.GetIsolate();
|
||||
{
|
||||
CV8TryCatch try_catch(isolate);
|
||||
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
// Create a new context
|
||||
v8::Local<v8::Context> context = v8::Context::New(isolate);
|
||||
@ -472,11 +474,12 @@ namespace NSJSBase
|
||||
global->Set(context, v8::String::NewFromUtf8Literal(isolate, "self"), global).Check();
|
||||
global->Set(context, v8::String::NewFromUtf8Literal(isolate, "native"), v8::Undefined(isolate)).Check();
|
||||
|
||||
// Compile and run
|
||||
// Compile
|
||||
v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, script.c_str()).ToLocalChecked();
|
||||
v8::Local<v8::Script> script = v8::Script::Compile(context, source).ToLocalChecked();
|
||||
|
||||
// Run
|
||||
script->Run(context).IsEmpty();
|
||||
|
||||
snapshotCreator.SetDefaultContext(context);
|
||||
}
|
||||
v8::StartupData data = snapshotCreator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep);
|
||||
|
||||
@ -62,7 +62,13 @@ v8::Local<v8::String> CreateV8String(v8::Isolate* i, const std::string& str);
|
||||
#include <android/log.h>
|
||||
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, "js", __VA_ARGS__)
|
||||
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "js", __VA_ARGS__)
|
||||
#endif
|
||||
#ifdef _DEBUG
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "js", __VA_ARGS__)
|
||||
#else
|
||||
// should be disabled for release builds
|
||||
#define LOGD(...)
|
||||
#endif // _DEBUG
|
||||
#endif // ANDROID_LOGS
|
||||
|
||||
#endif
|
||||
|
||||
@ -799,6 +805,9 @@ namespace NSJSBase
|
||||
CV8TryCatch() : CJSTryCatch(), try_catch(V8IsolateOneArg)
|
||||
{
|
||||
}
|
||||
CV8TryCatch(v8::Isolate* isolate) : CJSTryCatch(), try_catch(isolate)
|
||||
{
|
||||
}
|
||||
virtual ~CV8TryCatch()
|
||||
{
|
||||
}
|
||||
|
||||
@ -837,53 +837,63 @@ public:
|
||||
CSymbolSimpleChecker2 oAllChecker(arSymbolsAll, nMaxSymbol);
|
||||
|
||||
std::map<std::wstring, int> mapFontsPriorityStandard;
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"ASCW3", 1));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Arial", 2));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Times New Roman", 3));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Tahoma", 4));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Cambria", 5));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Calibri", 6));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Verdana", 7));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Georgia", 8));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Open Sans", 9));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Liberation Sans", 10));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Helvetica", 11));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Nimbus Sans L", 12));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"DejaVu Sans", 13));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Liberation Serif", 14));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Trebuchet MS", 15));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Courier New", 16));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Carlito", 17));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Segoe UI", 18));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"SimSun", 19));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"MS Gothic", 20));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Nirmala UI", 21));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Batang", 22));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"MS Mincho", 23));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Wingdings", 24));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Microsoft JhengHei", 25));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Microsoft JhengHei UI", 26));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Microsoft YaHei", 27));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"PMingLiU", 28));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"MingLiU", 29));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"DFKai-SB", 30));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"FangSong", 31));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"KaiTi", 32));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"SimKai", 33));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"SimHei", 34));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Meiryo", 35));
|
||||
int nCurrentPriority = 1;
|
||||
|
||||
#define SET_FONT_PRIORITY(fontName) mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(fontName, nCurrentPriority++))
|
||||
|
||||
SET_FONT_PRIORITY(L"ASCW3");
|
||||
SET_FONT_PRIORITY(L"Arial");
|
||||
SET_FONT_PRIORITY(L"Times New Roman");
|
||||
SET_FONT_PRIORITY(L"Tahoma");
|
||||
SET_FONT_PRIORITY(L"Cambria");
|
||||
SET_FONT_PRIORITY(L"Calibri");
|
||||
SET_FONT_PRIORITY(L"Verdana");
|
||||
SET_FONT_PRIORITY(L"Georgia");
|
||||
SET_FONT_PRIORITY(L"Open Sans");
|
||||
SET_FONT_PRIORITY(L"Liberation Sans");
|
||||
SET_FONT_PRIORITY(L"Helvetica");
|
||||
SET_FONT_PRIORITY(L"Nimbus Sans L");
|
||||
SET_FONT_PRIORITY(L"DejaVu Sans");
|
||||
SET_FONT_PRIORITY(L"Liberation Serif");
|
||||
SET_FONT_PRIORITY(L"Trebuchet MS");
|
||||
SET_FONT_PRIORITY(L"Courier New");
|
||||
SET_FONT_PRIORITY(L"Carlito");
|
||||
SET_FONT_PRIORITY(L"Segoe UI");
|
||||
SET_FONT_PRIORITY(L"SimSun");
|
||||
SET_FONT_PRIORITY(L"MS Gothic");
|
||||
SET_FONT_PRIORITY(L"Nirmala UI");
|
||||
SET_FONT_PRIORITY(L"Batang");
|
||||
SET_FONT_PRIORITY(L"MS Mincho");
|
||||
SET_FONT_PRIORITY(L"Wingdings");
|
||||
SET_FONT_PRIORITY(L"Microsoft JhengHei");
|
||||
SET_FONT_PRIORITY(L"Microsoft JhengHei UI");
|
||||
SET_FONT_PRIORITY(L"Microsoft YaHei");
|
||||
SET_FONT_PRIORITY(L"PMingLiU");
|
||||
SET_FONT_PRIORITY(L"MingLiU");
|
||||
SET_FONT_PRIORITY(L"DFKai-SB");
|
||||
SET_FONT_PRIORITY(L"FangSong");
|
||||
SET_FONT_PRIORITY(L"KaiTi");
|
||||
SET_FONT_PRIORITY(L"SimKai");
|
||||
SET_FONT_PRIORITY(L"SimHei");
|
||||
SET_FONT_PRIORITY(L"Meiryo");
|
||||
|
||||
#ifdef _MAC
|
||||
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));
|
||||
SET_FONT_PRIORITY(L"PingFang SC");
|
||||
SET_FONT_PRIORITY(L"PingFang TC");
|
||||
SET_FONT_PRIORITY(L"PingFang HK");
|
||||
|
||||
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));
|
||||
SET_FONT_PRIORITY(L"Heiti SC");
|
||||
SET_FONT_PRIORITY(L"Heiti TC");
|
||||
SET_FONT_PRIORITY(L"Songti SC");
|
||||
SET_FONT_PRIORITY(L"Songti TC");
|
||||
#endif
|
||||
|
||||
SET_FONT_PRIORITY(L"Malgun Gothic");
|
||||
SET_FONT_PRIORITY(L"Nanum Gothic");
|
||||
SET_FONT_PRIORITY(L"NanumGothic");
|
||||
SET_FONT_PRIORITY(L"Noto Sans KR");
|
||||
SET_FONT_PRIORITY(L"TakaoGothic");
|
||||
|
||||
NSFonts::CApplicationFontsSymbols oApplicationChecker;
|
||||
|
||||
// приоритеты шрифтов. по имени (все стили)
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
#include <vector>
|
||||
#include "../graphics/pro/Fonts.h"
|
||||
|
||||
#define ONLYOFFICE_FONTS_VERSION 14
|
||||
#define ONLYOFFICE_FONTS_VERSION 15
|
||||
#define ONLYOFFICE_ALL_FONTS_VERSION 2
|
||||
|
||||
class CApplicationFontsWorkerBreaker
|
||||
|
||||
@ -731,10 +731,10 @@ void CFontFile::CheckHintsSupport()
|
||||
int CFontFile::SetCMapForCharCode(long lUnicode, int *pnCMapIndex)
|
||||
{
|
||||
*pnCMapIndex = -1;
|
||||
if (!m_pFace)
|
||||
if (!m_pFace || !m_pFace->num_charmaps)
|
||||
return 0;
|
||||
|
||||
if ( m_bStringGID || 0 == m_pFace->num_charmaps )
|
||||
if ( m_bStringGID )
|
||||
return lUnicode;
|
||||
|
||||
int nCharIndex = 0;
|
||||
|
||||
@ -117,7 +117,7 @@ WASM_EXPORT unsigned int ASC_FT_SetCMapForCharCode(FT_Face face, unsigned int un
|
||||
return 0;
|
||||
|
||||
if ( 0 == face->num_charmaps )
|
||||
return unicode;
|
||||
return 0;
|
||||
|
||||
unsigned int nCharIndex = 0;
|
||||
|
||||
|
||||
@ -265,15 +265,15 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../",
|
||||
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp", "graphics/Matrix.cpp"]
|
||||
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp", "graphics/Matrix.cpp", "graphics/GraphicsPath.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../agg-2.4/src/",
|
||||
"files": ["agg_trans_affine.cpp"]
|
||||
"files": ["agg_trans_affine.cpp", "agg_bezier_arc.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../raster/",
|
||||
"files": ["PICT/PICFile.cpp", "PICT/pic.cpp"]
|
||||
"files": ["PICT/PICFile.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../graphics/pro/js/qt/raster",
|
||||
|
||||
@ -85,6 +85,13 @@ bool Segment::IsEmpty() const noexcept
|
||||
return Id == 0 && Index == -1 && P.IsZero() && HI.IsZero() && HO.IsZero();
|
||||
}
|
||||
|
||||
bool Segment::Equals(const Segment& other) const noexcept
|
||||
{
|
||||
return isZero(P.X - other.P.X) && isZero(P.Y - other.P.Y) &&
|
||||
isZero(HI.X - other.HI.X) && isZero(HI.Y - other.HI.Y) &&
|
||||
isZero(HO.X - other.HO.X) && isZero(HO.Y - other.HO.Y);
|
||||
}
|
||||
|
||||
bool Segment::operator==(const Segment& other) const noexcept
|
||||
{
|
||||
return (Index == other.Index) && (Id == other.Id);
|
||||
@ -690,6 +697,12 @@ bool Curve::IsStraight() const noexcept
|
||||
return !Segment2.IsCurve;
|
||||
}
|
||||
|
||||
bool Curve::Equals(const Curve& other) const noexcept
|
||||
{
|
||||
return Segment1.Equals(other.Segment1) &&
|
||||
Segment2.Equals(other.Segment2);
|
||||
}
|
||||
|
||||
bool Curve::operator==(const Curve& other) const noexcept
|
||||
{
|
||||
return Segment1 == other.Segment1 &&
|
||||
@ -737,11 +750,13 @@ CBooleanOperations::CBooleanOperations(const CGraphicsPath& path1,
|
||||
const CGraphicsPath& path2,
|
||||
BooleanOpType op,
|
||||
long fillType,
|
||||
bool isLuminosity) :
|
||||
bool isLuminosity,
|
||||
bool isSelf) :
|
||||
Op(op),
|
||||
Close1(path1.Is_poly_closed()),
|
||||
Close2(path2.Is_poly_closed()),
|
||||
IsLuminosity(isLuminosity),
|
||||
IsSelf(isSelf),
|
||||
FillType(fillType),
|
||||
Path1(path1),
|
||||
Path2(path2)
|
||||
@ -784,10 +799,9 @@ bool CBooleanOperations::IsSelfInters(const CGraphicsPath& p)
|
||||
void CBooleanOperations::TraceBoolean()
|
||||
{
|
||||
bool reverse = false;
|
||||
bool self = Path1 == Path2;
|
||||
if (((Op == Subtraction || Op == Exclusion) ^
|
||||
Path1.IsClockwise() ^
|
||||
Path2.IsClockwise()) && !self)
|
||||
Path2.IsClockwise()) && !IsSelf)
|
||||
reverse = true;
|
||||
|
||||
PreparePath(Path1, 1, Segments1, Curves1);
|
||||
@ -798,7 +812,7 @@ void CBooleanOperations::TraceBoolean()
|
||||
|
||||
GetIntersection();
|
||||
|
||||
if (self)
|
||||
if (IsSelf)
|
||||
{
|
||||
if (Op == Subtraction)
|
||||
return;
|
||||
@ -823,8 +837,13 @@ void CBooleanOperations::TraceBoolean()
|
||||
CreateNewPath(adj_matr);
|
||||
return;
|
||||
}
|
||||
else if (Path1 == Path2)
|
||||
{
|
||||
Result = std::move(Path1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Locations.empty())
|
||||
if (!Locations.empty() && !IsOnlyEnds())
|
||||
{
|
||||
int length = static_cast<int>(Locations.size());
|
||||
for (int i = 0; i < length; i++)
|
||||
@ -1839,7 +1858,7 @@ void CBooleanOperations::GetCurveIntersection(const Curve& curve1, const Curve&
|
||||
AddCurveIntersection(flip ? curve2 : curve1, flip ? curve1 : curve2,
|
||||
flip ? curve2 : curve1, flip ? curve1 : curve2, flip);
|
||||
|
||||
if (Locations.size() == before && (!straight || Locations.empty()))
|
||||
if (Locations.size() == before && (!straight /*|| Locations.empty()*/))
|
||||
{
|
||||
double t = curve2.GetTimeOf(curve1.Segment1.P);
|
||||
if (t != -1.0)
|
||||
@ -2052,17 +2071,27 @@ bool CBooleanOperations::IsInside(const Segment& segment) const
|
||||
|
||||
void CBooleanOperations::SetWinding()
|
||||
{
|
||||
if (Locations.empty() || (Locations.size() == 2 && Locations[0]->Ends))
|
||||
if (Locations.empty() || (Locations.size() == 2 && Locations[0]->Ends) || IsOnlyEnds())
|
||||
{
|
||||
Segment s1, s2;
|
||||
Segment s1 = Segments1[0], s2 = Segments2[0];
|
||||
|
||||
for (const auto& s : Segments1)
|
||||
if (!s.Inters)
|
||||
{
|
||||
bool skip = false;
|
||||
for (const auto& ss : Segments2)
|
||||
skip = skip || !s.Equals(ss);
|
||||
if (!s.Inters && !skip)
|
||||
s1 = s;
|
||||
}
|
||||
|
||||
for (const auto& s : Segments2)
|
||||
if (!s.Inters)
|
||||
{
|
||||
bool skip = false;
|
||||
for (const auto& ss : Segments1)
|
||||
skip = skip || !s.Equals(ss);
|
||||
if (!s.Inters && !skip)
|
||||
s2 = s;
|
||||
}
|
||||
|
||||
bool winding = IsInside(s1);
|
||||
|
||||
@ -2279,8 +2308,8 @@ bool CBooleanOperations::IsOneCurvePath(int pathIndex) const noexcept
|
||||
void CBooleanOperations::AddLocation(Curve curve1, Curve curve2, double t1,
|
||||
double t2, bool overlap, bool filter, bool ends)
|
||||
{
|
||||
bool excludeStart = !overlap && GetPreviousCurve(curve1) == curve2,
|
||||
excludeEnd = !overlap && curve1 != curve2 && GetNextCurve(curve1) == curve2;
|
||||
bool excludeStart = !overlap && GetPreviousCurve(curve1).Equals(curve2),
|
||||
excludeEnd = !overlap && curve1 != curve2 && GetNextCurve(curve1).Equals(curve2);
|
||||
double tMin = CURVETIME_EPSILON,
|
||||
tMax = 1 - tMin;
|
||||
|
||||
@ -2339,6 +2368,18 @@ bool CBooleanOperations::CheckLocation(std::shared_ptr<Location> loc, bool start
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBooleanOperations::IsOnlyEnds() const noexcept
|
||||
{
|
||||
bool onlyEnds1 = true;
|
||||
bool onlyEnds2 = true;
|
||||
for (const auto& l : Locations)
|
||||
{
|
||||
onlyEnds1 = onlyEnds1 && l->Ends;
|
||||
onlyEnds2 = onlyEnds2 && l->Inters->Ends;
|
||||
}
|
||||
return onlyEnds1 || onlyEnds2;
|
||||
}
|
||||
|
||||
CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
const CGraphicsPath& path2,
|
||||
BooleanOpType op,
|
||||
@ -2355,7 +2396,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
CBooleanOperations o;
|
||||
if (i > skip_end2 && o.IsSelfInters(paths2[i]))
|
||||
{
|
||||
CBooleanOperations operation(paths2[i], paths2[i], Intersection, fillType, isLuminosity);
|
||||
CBooleanOperations operation(paths2[i], paths2[i], Intersection, fillType, isLuminosity, true);
|
||||
CGraphicsPath p = std::move(operation.GetResult());
|
||||
|
||||
std::vector<CGraphicsPath> tmp_paths = p.GetSubPaths();
|
||||
@ -2370,7 +2411,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
CBooleanOperations o2;
|
||||
if (j > skip_end1 && o2.IsSelfInters(paths1[j]))
|
||||
{
|
||||
CBooleanOperations operation(paths1[j], paths1[j], Intersection, fillType, isLuminosity);
|
||||
CBooleanOperations operation(paths1[j], paths1[j], Intersection, fillType, isLuminosity, true);
|
||||
CGraphicsPath p = std::move(operation.GetResult());
|
||||
|
||||
std::vector<CGraphicsPath> tmp_paths = p.GetSubPaths();
|
||||
@ -2380,7 +2421,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
paths1.insert(paths1.begin() + i + k, tmp_paths[k]);
|
||||
}
|
||||
|
||||
CBooleanOperations operation(paths1[j], paths2[i], op, fillType, isLuminosity);
|
||||
CBooleanOperations operation(paths1[j], paths2[i], op, fillType, isLuminosity, false);
|
||||
paths.push_back(operation.GetResult());
|
||||
}
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ namespace Aggplus
|
||||
|
||||
bool IsValid(const BooleanOpType& op) const noexcept;
|
||||
bool IsEmpty() const noexcept;
|
||||
bool Equals(const Segment& other) const noexcept;
|
||||
bool operator==(const Segment& other) const noexcept;
|
||||
bool operator!=(const Segment& other) const noexcept;
|
||||
};
|
||||
@ -82,6 +83,7 @@ namespace Aggplus
|
||||
void Flip() noexcept;
|
||||
|
||||
bool IsStraight() const noexcept;
|
||||
bool Equals(const Curve& other) const noexcept;
|
||||
bool operator==(const Curve& other) const noexcept;
|
||||
bool operator!=(const Curve& other) const noexcept;
|
||||
};
|
||||
@ -108,7 +110,7 @@ namespace Aggplus
|
||||
{
|
||||
public:
|
||||
CBooleanOperations() {};
|
||||
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType, bool isLuminosity);
|
||||
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType, bool isLuminosity, bool isSelf);
|
||||
~CBooleanOperations();
|
||||
CGraphicsPath&& GetResult();
|
||||
bool IsSelfInters(const CGraphicsPath& p);
|
||||
@ -159,6 +161,7 @@ namespace Aggplus
|
||||
bool IsOneCurvePath(int pathIndex) const noexcept;
|
||||
void AddOffsets(std::vector<double>& offsets, const Curve& curve, bool end);
|
||||
bool CheckLocation(std::shared_ptr<Location> loc, bool start) const noexcept;
|
||||
bool IsOnlyEnds() const noexcept;
|
||||
|
||||
private:
|
||||
BooleanOpType Op = Intersection;
|
||||
@ -166,6 +169,7 @@ namespace Aggplus
|
||||
bool Close1 = true;
|
||||
bool Close2 = true;
|
||||
bool IsLuminosity = false;
|
||||
bool IsSelf = false;
|
||||
|
||||
// c_nStroke, c_nWindingFillMode, c_nEvenOddFillMode
|
||||
long FillType = c_nWindingFillMode;
|
||||
|
||||
@ -419,6 +419,7 @@ namespace Aggplus
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const std::wstring& strName, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
@ -427,6 +428,7 @@ namespace Aggplus
|
||||
m_bReleaseImage = TRUE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CImage *pImage, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
@ -435,6 +437,7 @@ namespace Aggplus
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::~CBrushTexture()
|
||||
|
||||
@ -205,6 +205,10 @@ public:
|
||||
bool m_bUseBounds;
|
||||
CDoubleRect m_oBounds;
|
||||
|
||||
bool m_bIsScale;
|
||||
double m_dScaleX;
|
||||
double m_dScaleY;
|
||||
|
||||
BYTE Alpha;
|
||||
};
|
||||
}
|
||||
|
||||
@ -847,6 +847,8 @@ namespace Aggplus
|
||||
double dScaleY = m_dDpiY / m_dDpiTile;
|
||||
|
||||
brushMatrix.Scale(dScaleX, dScaleY, Aggplus::MatrixOrderAppend);
|
||||
if (ptxBrush->m_bIsScale)
|
||||
brushMatrix.Scale(ptxBrush->m_dScaleX, ptxBrush->m_dScaleY, Aggplus::MatrixOrderAppend);
|
||||
}
|
||||
|
||||
brushMatrix.Translate(x, y, Aggplus::MatrixOrderAppend);
|
||||
@ -2142,7 +2144,12 @@ namespace Aggplus
|
||||
agg::trans_affine* full_trans = &m_oFullTransform.m_internal->m_agg_mtx;
|
||||
double dDet = full_trans->determinant();
|
||||
|
||||
if (fabs(dDet) < 0.0001)
|
||||
double sx = sqrt(full_trans->sx * full_trans->sx + full_trans->shx * full_trans->shx);
|
||||
double sy = sqrt(full_trans->shy * full_trans->shy + full_trans->sy * full_trans->sy);
|
||||
double scale = std::max(sx, sy);
|
||||
double adaptive_threshold = 1.0 / (scale * scale * 10000.0);
|
||||
|
||||
if (fabs(dDet) < std::max(0.0001, adaptive_threshold))
|
||||
{
|
||||
path_copy.transform_all_paths(m_oFullTransform.m_internal->m_agg_mtx);
|
||||
dWidth *= sqrt(fabs(dDet));
|
||||
@ -2240,6 +2247,8 @@ namespace Aggplus
|
||||
LONG lCount2 = lCount / 2;
|
||||
|
||||
double dKoef = 1.0;
|
||||
if (bIsUseIdentity)
|
||||
dKoef = sqrt(fabs(m_oFullTransform.m_internal->m_agg_mtx.determinant()));
|
||||
|
||||
for (LONG i = 0; i < lCount2; ++i)
|
||||
{
|
||||
|
||||
@ -886,17 +886,17 @@ namespace Aggplus
|
||||
if (isCurve)
|
||||
{
|
||||
std::vector<PointD> points = GetPoints(idx, 4);
|
||||
area = (points[3].Y - points[0].Y) * (points[1].X + points[2].X)
|
||||
- (points[3].X - points[0].X) * (points[1].Y + points[2].Y)
|
||||
+ points[1].Y * (points[0].X - points[2].X)
|
||||
- points[1].X * (points[0].Y - points[2].Y)
|
||||
+ points[3].Y * (points[2].X + points[0].X / 3.0)
|
||||
- points[3].X * (points[2].Y + points[0].Y / 3.0);
|
||||
area = 3.0 * ((points[3].Y - points[0].Y) * (points[1].X + points[2].X)
|
||||
- (points[3].X - points[0].X) * (points[1].Y + points[2].Y)
|
||||
+ points[1].Y * (points[0].X - points[2].X)
|
||||
- points[1].X * (points[0].Y - points[2].Y)
|
||||
+ points[3].Y * (points[2].X + points[0].X / 3.0)
|
||||
- points[3].X * (points[2].Y + points[0].Y / 3.0)) / 20.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<PointD> points = GetPoints(idx, 2);
|
||||
area = 4.0 * (points[1].Y * points[0].X - points[1].X * points[0].Y) / 3.0;
|
||||
area = (points[1].Y * points[0].X - points[1].X * points[0].Y) / 2.0;
|
||||
}
|
||||
|
||||
return area;
|
||||
@ -1007,16 +1007,18 @@ namespace Aggplus
|
||||
bool CGraphicsPath::operator==(const CGraphicsPath& other) noexcept
|
||||
{
|
||||
unsigned pointsCount = GetPointCount(),
|
||||
otherPointsCount = other.GetPointCount();
|
||||
otherPointsCount = other.GetPointCount();
|
||||
|
||||
if (pointsCount != otherPointsCount)
|
||||
return false;
|
||||
|
||||
std::vector<PointD> points = GetPoints(0, pointsCount),
|
||||
otherPoints = other.GetPoints(0, otherPointsCount);
|
||||
otherPoints = other.GetPoints(0, otherPointsCount);
|
||||
|
||||
bool reverse = IsClockwise() ^ other.IsClockwise();
|
||||
|
||||
for (unsigned i = 0; i < pointsCount; i++)
|
||||
if (!points[i].Equals(otherPoints[i]))
|
||||
if (!points[i].Equals(otherPoints[reverse ? pointsCount - i - 1 : i]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -1549,3 +1551,31 @@ namespace Aggplus
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT IRenderer::AddPath(const Aggplus::CGraphicsPath& path)
|
||||
{
|
||||
if (path.GetPointCount() == 0)
|
||||
return S_FALSE;
|
||||
|
||||
size_t length = path.GetPointCount() + path.GetCloseCount();
|
||||
std::vector<Aggplus::PointD> points = path.GetPoints(0, length);
|
||||
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
if (path.IsCurvePoint(i))
|
||||
{
|
||||
PathCommandCurveTo(points[i].X, points[i].Y,
|
||||
points[i + 1].X, points[i + 1].Y,
|
||||
points[i + 2].X, points[i + 2].Y);
|
||||
i += 2;
|
||||
}
|
||||
else if (path.IsMovePoint(i))
|
||||
PathCommandMoveTo(points[i].X, points[i].Y);
|
||||
else if (path.IsLinePoint(i))
|
||||
PathCommandLineTo(points[i].X, points[i].Y);
|
||||
else
|
||||
PathCommandClose();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -613,6 +613,32 @@ HRESULT CGraphicsRenderer::put_BrushTransform(const Aggplus::CMatrix& oMatrix)
|
||||
m_oBrush.Transform = oMatrix;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::get_BrushOffset(double& offsetX, double& offsetY) const
|
||||
{
|
||||
offsetX = m_oBrush.OffsetX;
|
||||
offsetY = m_oBrush.OffsetY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::put_BrushOffset(const double& offsetX, const double& offsetY)
|
||||
{
|
||||
m_oBrush.OffsetX = offsetX;
|
||||
m_oBrush.OffsetY = offsetY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const
|
||||
{
|
||||
isScale = m_oBrush.IsScale;
|
||||
scaleX = m_oBrush.ScaleX;
|
||||
scaleY = m_oBrush.ScaleY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::put_BrushScale(bool isScale, const double& scaleX, const double& scaleY)
|
||||
{
|
||||
m_oBrush.IsScale = isScale;
|
||||
m_oBrush.ScaleX = scaleX;
|
||||
m_oBrush.ScaleY = scaleY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height)
|
||||
{
|
||||
m_oBrush.Rectable = val;
|
||||
@ -946,11 +972,18 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
switch (m_oBrush.TextureMode)
|
||||
{
|
||||
case c_BrushTextureModeTile:
|
||||
oMode = Aggplus::WrapModeTile;
|
||||
break;
|
||||
case c_BrushTextureModeTileCenter:
|
||||
oMode = Aggplus::WrapModeTile;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipX:
|
||||
oMode = Aggplus::WrapModeTileFlipX;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipY:
|
||||
oMode = Aggplus::WrapModeTileFlipY;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipXY:
|
||||
oMode = Aggplus::WrapModeTileFlipXY;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1023,11 +1056,18 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
if (m_oBrush.Rectable == 1)
|
||||
{
|
||||
pTextureBrush->m_bUseBounds = true;
|
||||
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X;
|
||||
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y;
|
||||
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X + m_oBrush.OffsetX;
|
||||
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y + m_oBrush.OffsetY;
|
||||
pTextureBrush->m_oBounds.right = pTextureBrush->m_oBounds.left + m_oBrush.Rect.Width;
|
||||
pTextureBrush->m_oBounds.bottom = pTextureBrush->m_oBounds.top + m_oBrush.Rect.Height;
|
||||
}
|
||||
|
||||
if (m_oBrush.IsScale == 1)
|
||||
{
|
||||
pTextureBrush->m_bIsScale = true;
|
||||
pTextureBrush->m_dScaleX = m_oBrush.ScaleX;
|
||||
pTextureBrush->m_dScaleY = m_oBrush.ScaleY;
|
||||
}
|
||||
}
|
||||
|
||||
pBrush = pTextureBrush;
|
||||
|
||||
@ -189,6 +189,10 @@ public:
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle);
|
||||
virtual HRESULT get_BrushTransform(Aggplus::CMatrix& oMatrix);
|
||||
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix);
|
||||
virtual HRESULT get_BrushOffset(double& offsetX, double& offsetY) const;
|
||||
virtual HRESULT put_BrushOffset(const double& offsetX, const double& offsetY);
|
||||
virtual HRESULT get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const;
|
||||
virtual HRESULT put_BrushScale(bool isScale, const double& scaleX, const double& scaleY);
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height);
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height);
|
||||
virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount);
|
||||
|
||||
@ -117,6 +117,7 @@ const long c_nDarkMode = 0x0008;
|
||||
const long c_nUseDictionaryFonts = 0x0010;
|
||||
const long c_nPenWidth0As1px = 0x0020;
|
||||
const long c_nSupportPathTextAsText = 0x0040;
|
||||
const long c_nFontSubstitution = 0x0080;
|
||||
|
||||
// типы рендерера
|
||||
const long c_nUnknownRenderer = 0x0000;
|
||||
@ -168,7 +169,10 @@ public:
|
||||
AdvancedCommandType GetCommandType() { return m_nCommandType; }
|
||||
};
|
||||
|
||||
namespace Aggplus { class CImage; }
|
||||
namespace Aggplus {
|
||||
class CImage;
|
||||
class CGraphicsPath;
|
||||
}
|
||||
|
||||
// IRenderer
|
||||
class IRenderer : public IGrObject
|
||||
@ -240,6 +244,32 @@ public:
|
||||
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix) = 0;
|
||||
virtual HRESULT get_BrushLinearAngle(double* dAngle) = 0;
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle) = 0;
|
||||
virtual HRESULT get_BrushOffset(double& offsetX, double& offsetY) const
|
||||
{
|
||||
UNUSED_VARIABLE(offsetX);
|
||||
UNUSED_VARIABLE(offsetY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT put_BrushOffset(const double& offsetX, const double& offsetY)
|
||||
{
|
||||
UNUSED_VARIABLE(offsetX);
|
||||
UNUSED_VARIABLE(offsetY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const
|
||||
{
|
||||
UNUSED_VARIABLE(isScale);
|
||||
UNUSED_VARIABLE(scaleX);
|
||||
UNUSED_VARIABLE(scaleY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT put_BrushScale(bool isScale, const double& scaleX, const double& scaleY)
|
||||
{
|
||||
UNUSED_VARIABLE(isScale);
|
||||
UNUSED_VARIABLE(scaleX);
|
||||
UNUSED_VARIABLE(scaleY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
|
||||
@ -299,6 +329,8 @@ public:
|
||||
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
|
||||
HRESULT AddPath(const Aggplus::CGraphicsPath& path);
|
||||
|
||||
//-------- Функции для вывода изображений ---------------------------------------------------
|
||||
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255) = 0;
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include "../fontengine/FontManager.h"
|
||||
#include "../raster/BgraFrame.h"
|
||||
#include "../common/StringExt.h"
|
||||
#include "GraphicsPath.h"
|
||||
|
||||
// этот класс нужно переписать. должно работать как и в js
|
||||
// а не просто на каждом символе переключаться, если нужно
|
||||
@ -351,7 +352,13 @@ namespace NSOnlineOfficeBinToPdf
|
||||
bool bIsPathOpened = false;
|
||||
bool bIsEnableBrushRect = false;
|
||||
|
||||
double old_t1, old_t2, old_t3, old_t4, old_t5, old_t6;
|
||||
|
||||
CBufferReader oReader(pBuffer, lBufferLen);
|
||||
Aggplus::CGraphicsPath path;
|
||||
Aggplus::CMatrix transMatrRot;
|
||||
Aggplus::RectF_T<double> clipRect;
|
||||
bool isResetRot = false;
|
||||
while (oReader.Check())
|
||||
{
|
||||
eCommand = (CommandType)(oReader.ReadByte());
|
||||
@ -382,6 +389,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
if (bIsPathOpened)
|
||||
{
|
||||
pRenderer->PathCommandEnd();
|
||||
if (path.GetPointCount())
|
||||
path.Reset();
|
||||
pRenderer->EndCommand(c_nPathType);
|
||||
}
|
||||
bIsPathOpened = false;
|
||||
@ -471,6 +480,17 @@ namespace NSOnlineOfficeBinToPdf
|
||||
double m2 = oReader.ReadDouble();
|
||||
double m3 = oReader.ReadDouble();
|
||||
double m4 = oReader.ReadDouble();
|
||||
|
||||
clipRect = Aggplus::RectF_T<double>(m1, m2, m3, m4);
|
||||
|
||||
long type;
|
||||
pRenderer->get_BrushTextureMode(&type);
|
||||
if (type != c_BrushTextureModeStretch)
|
||||
{
|
||||
m1 = 0.0;
|
||||
m2 = 0.0;
|
||||
}
|
||||
|
||||
pRenderer->BrushRect(bIsEnableBrushRect ? 1 : 0, m1, m2, m3, m4);
|
||||
break;
|
||||
}
|
||||
@ -479,7 +499,10 @@ namespace NSOnlineOfficeBinToPdf
|
||||
bIsEnableBrushRect = oReader.ReadBool();
|
||||
|
||||
if (!bIsEnableBrushRect)
|
||||
{
|
||||
pRenderer->BrushRect(bIsEnableBrushRect ? 1 : 0, 0, 0, 1, 1);
|
||||
clipRect = Aggplus::RectF_T<double>();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ctBrushTexturePathOld:
|
||||
@ -590,6 +613,16 @@ namespace NSOnlineOfficeBinToPdf
|
||||
pRenderer->put_BrushTextureAlpha(lAlpha);
|
||||
break;
|
||||
}
|
||||
case ctBrushResetRotation:
|
||||
{
|
||||
pRenderer->GetTransform(&old_t1, &old_t2, &old_t3, &old_t4, &old_t5, &old_t6);
|
||||
|
||||
Aggplus::CMatrix mtr(old_t1, old_t2, old_t3, old_t4, old_t5, old_t6);
|
||||
double rot = mtr.rotation();
|
||||
transMatrRot.Rotate(agg::rad2deg(rot));
|
||||
isResetRot = true;
|
||||
break;
|
||||
}
|
||||
case ctSetTransform:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
@ -606,11 +639,15 @@ namespace NSOnlineOfficeBinToPdf
|
||||
if (bIsPathOpened)
|
||||
{
|
||||
pRenderer->PathCommandEnd();
|
||||
if (path.GetPointCount())
|
||||
path.Reset();
|
||||
pRenderer->EndCommand(c_nPathType);
|
||||
}
|
||||
|
||||
pRenderer->BeginCommand(c_nPathType);
|
||||
pRenderer->PathCommandStart();
|
||||
path.Reset();
|
||||
path.StartFigure();
|
||||
|
||||
bIsPathOpened = true;
|
||||
break;
|
||||
@ -619,14 +656,14 @@ namespace NSOnlineOfficeBinToPdf
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
pRenderer->PathCommandMoveTo(m1, m2);
|
||||
path.MoveTo(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandLineTo:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
pRenderer->PathCommandLineTo(m1, m2);
|
||||
path.LineTo(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandCurveTo:
|
||||
@ -637,12 +674,12 @@ namespace NSOnlineOfficeBinToPdf
|
||||
double m4 = oReader.ReadDouble();
|
||||
double m5 = oReader.ReadDouble();
|
||||
double m6 = oReader.ReadDouble();
|
||||
pRenderer->PathCommandCurveTo(m1, m2, m3, m4, m5, m6);
|
||||
path.CurveTo(m1, m2, m3, m4, m5, m6);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandClose:
|
||||
{
|
||||
pRenderer->PathCommandClose();
|
||||
path.CloseFigure();
|
||||
break;
|
||||
}
|
||||
case ctPathCommandEnd:
|
||||
@ -650,14 +687,107 @@ namespace NSOnlineOfficeBinToPdf
|
||||
if (bIsPathOpened)
|
||||
{
|
||||
pRenderer->PathCommandEnd();
|
||||
if (path.GetPointCount())
|
||||
path.Reset();
|
||||
pRenderer->EndCommand(c_nPathType);
|
||||
bIsPathOpened = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ctPathCommandOffset:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
|
||||
pRenderer->put_BrushOffset(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandScale:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
|
||||
pRenderer->put_BrushScale(true, m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctDrawPath:
|
||||
{
|
||||
pRenderer->DrawPath(oReader.ReadInt());
|
||||
long fill = oReader.ReadInt();
|
||||
long type;
|
||||
pRenderer->get_BrushType(&type);
|
||||
|
||||
if (fill != c_nStroke && type == c_BrushTypeTexture)
|
||||
{
|
||||
Aggplus::CGraphicsPath clipPath;
|
||||
Aggplus::CGraphicsPath drawPath(path);
|
||||
|
||||
if (isResetRot)
|
||||
{
|
||||
pRenderer->get_BrushTextureMode(&type);
|
||||
bool isStretch = type == c_BrushTextureModeStretch;
|
||||
|
||||
double left, top, width, height;
|
||||
drawPath.GetBounds(left, top, width, height);
|
||||
|
||||
double rot = transMatrRot.rotation();
|
||||
double cX = left + width / 2.0;
|
||||
double cY = top + height / 2.0;
|
||||
|
||||
bool isZeroPt = clipRect.X < 0.1 && clipRect.X > -0.1 && clipRect.Y < 0.1 && clipRect.Y > -0.1;
|
||||
bool isZeroRot = rot < 1e-6 && rot > -1e-6;
|
||||
|
||||
transMatrRot.Reset();
|
||||
transMatrRot.RotateAt(agg::rad2deg(rot), cX, cY, Aggplus::MatrixOrderAppend);
|
||||
|
||||
double offX = old_t5 - transMatrRot.tx();
|
||||
double offY = old_t6 - transMatrRot.ty();
|
||||
|
||||
drawPath.Transform(&transMatrRot);
|
||||
pRenderer->SetTransform(1.0, 0.0, 0.0, 1.0, offX, offY);
|
||||
|
||||
if (isZeroPt && !isZeroRot && isStretch)
|
||||
drawPath.GetBounds(left, top, width, height);
|
||||
else
|
||||
{
|
||||
Aggplus::CGraphicsPath tmpPath;
|
||||
tmpPath.AddRectangle(left, top, width, height);
|
||||
tmpPath.Transform(&transMatrRot);
|
||||
tmpPath.GetBounds(left, top, width, height);
|
||||
}
|
||||
|
||||
if (isZeroPt || !isStretch)
|
||||
clipRect = Aggplus::RectF_T<double>(left, top, width, height);
|
||||
|
||||
if (isStretch)
|
||||
{
|
||||
if (!isZeroPt)
|
||||
clipRect.Offset(-offX, -offY);
|
||||
pRenderer->BrushRect(true, clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
double tileOffX, tileOffY;
|
||||
pRenderer->get_BrushOffset(tileOffX, tileOffY);
|
||||
pRenderer->put_BrushOffset(tileOffX - offX, tileOffY - offY);
|
||||
}
|
||||
}
|
||||
|
||||
clipPath.AddRectangle(clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height);
|
||||
path = Aggplus::CalcBooleanOperation(drawPath, clipPath, Aggplus::Intersection);
|
||||
}
|
||||
|
||||
pRenderer->AddPath(path);
|
||||
pRenderer->DrawPath(fill);
|
||||
|
||||
if (isResetRot)
|
||||
{
|
||||
pRenderer->SetTransform(old_t1, old_t2, old_t3, old_t4, old_t5, old_t6);
|
||||
transMatrRot.Reset();
|
||||
isResetRot = false;
|
||||
}
|
||||
|
||||
pRenderer->put_BrushScale(false, 1.0, 1.0);
|
||||
pRenderer->put_BrushOffset(0.0, 0.0);
|
||||
break;
|
||||
}
|
||||
case ctDrawImageFromFile:
|
||||
@ -734,6 +864,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
if (bIsPathOpened)
|
||||
{
|
||||
pRenderer->PathCommandEnd();
|
||||
if (path.GetPointCount())
|
||||
path.Reset();
|
||||
pRenderer->EndCommand(4);
|
||||
bIsPathOpened = false;
|
||||
}
|
||||
@ -747,8 +879,13 @@ namespace NSOnlineOfficeBinToPdf
|
||||
pRenderer->EndCommand(4);
|
||||
bIsPathOpened = false;
|
||||
}
|
||||
pRenderer->EndCommand((DWORD)(oReader.ReadInt()));
|
||||
int nCommand = oReader.ReadInt();
|
||||
if (path.GetPointCount() && nCommand == c_nClipType)
|
||||
pRenderer->AddPath(path);
|
||||
pRenderer->EndCommand((DWORD)nCommand);
|
||||
pRenderer->PathCommandEnd();
|
||||
if (path.GetPointCount())
|
||||
path.Reset();
|
||||
break;
|
||||
}
|
||||
case ctGradientFill:
|
||||
@ -1132,6 +1269,10 @@ namespace NSOnlineOfficeBinToPdf
|
||||
oReader.Skip(1);
|
||||
break;
|
||||
}
|
||||
case ctBrushResetRotation:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ctSetTransform:
|
||||
{
|
||||
oReader.SkipInt(6);
|
||||
@ -1164,6 +1305,16 @@ namespace NSOnlineOfficeBinToPdf
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ctPathCommandOffset:
|
||||
{
|
||||
oReader.SkipInt(2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandScale:
|
||||
{
|
||||
oReader.SkipInt(2);
|
||||
break;
|
||||
}
|
||||
case ctDrawPath:
|
||||
{
|
||||
oReader.SkipInt();
|
||||
|
||||
@ -108,6 +108,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
ctBrushRectableEnabled = 30,
|
||||
ctBrushGradient = 31,
|
||||
ctBrushTexturePath = 32,
|
||||
ctBrushResetRotation = 33,
|
||||
|
||||
// font
|
||||
ctFontXML = 40,
|
||||
@ -153,6 +154,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
ctPathCommandGetCurrentPoint = 101,
|
||||
ctPathCommandText = 102,
|
||||
ctPathCommandTextEx = 103,
|
||||
ctPathCommandOffset = 104,
|
||||
ctPathCommandScale = 105,
|
||||
|
||||
// image
|
||||
ctDrawImage = 110,
|
||||
|
||||
@ -214,6 +214,18 @@ public:
|
||||
|
||||
inline bool IsPositive() { return Width > 0 && Height > 0; }
|
||||
|
||||
RectF_T& operator=(const RectF_T& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
X = other.X;
|
||||
Y = other.Y;
|
||||
Width = other.Width;
|
||||
Height = other.Height;
|
||||
|
||||
return *this;
|
||||
};
|
||||
public:
|
||||
T X, Y, Width, Height;
|
||||
};
|
||||
|
||||
@ -46,6 +46,92 @@
|
||||
// void Set(const std::wstring& ws) { m_ws = ws; }
|
||||
// const std::wstring& Get() { return m_ws; }
|
||||
|
||||
CAnnotFieldInfo::CActionFieldPr* ReadAction(NSOnlineOfficeBinToPdf::CBufferReader* pReader)
|
||||
{
|
||||
CAnnotFieldInfo::CActionFieldPr* pRes = new CAnnotFieldInfo::CActionFieldPr();
|
||||
|
||||
pRes->nActionType = pReader->ReadByte();
|
||||
switch (pRes->nActionType)
|
||||
{
|
||||
case 14: // JavaScript
|
||||
{
|
||||
pRes->wsStr1 = pReader->ReadString();
|
||||
break;
|
||||
}
|
||||
case 1: // GoTo
|
||||
{
|
||||
pRes->nInt1 = pReader->ReadInt();
|
||||
pRes->nKind = pReader->ReadByte();
|
||||
switch (pRes->nKind)
|
||||
{
|
||||
case 0:
|
||||
case 2:
|
||||
case 3:
|
||||
case 6:
|
||||
case 7:
|
||||
{
|
||||
pRes->nFlags = pReader->ReadInt();
|
||||
if (pRes->nFlags & (1 << 0))
|
||||
pRes->dD[0] = pReader->ReadDouble();
|
||||
if (pRes->nFlags & (1 << 1))
|
||||
pRes->dD[1] = pReader->ReadDouble();
|
||||
if (pRes->nFlags & (1 << 2))
|
||||
pRes->dD[2] = pReader->ReadDouble();
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
pRes->dD[0] = pReader->ReadDouble();
|
||||
pRes->dD[1] = pReader->ReadDouble();
|
||||
pRes->dD[2] = pReader->ReadDouble();
|
||||
pRes->dD[3] = pReader->ReadDouble();
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 5:
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 10: // Named
|
||||
{
|
||||
pRes->wsStr1 = pReader->ReadString();
|
||||
break;
|
||||
}
|
||||
case 6: // URI
|
||||
{
|
||||
pRes->wsStr1 = pReader->ReadString();
|
||||
break;
|
||||
}
|
||||
case 9: // Hide
|
||||
{
|
||||
pRes->nKind = pReader->ReadByte();
|
||||
int n = pReader->ReadInt();
|
||||
pRes->arrStr.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pRes->arrStr.push_back(pReader->ReadString());
|
||||
break;
|
||||
}
|
||||
case 12: // ResetForm
|
||||
{
|
||||
pRes->nInt1 = pReader->ReadInt();
|
||||
int n = pReader->ReadInt();
|
||||
pRes->arrStr.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pRes->arrStr.push_back(pReader->ReadString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pReader->ReadByte())
|
||||
pRes->pNext = ReadAction(pReader);
|
||||
|
||||
return pRes;
|
||||
}
|
||||
|
||||
CAnnotFieldInfo::CAnnotFieldInfo() : IAdvancedCommand(AdvancedCommandType::Annotaion)
|
||||
{
|
||||
m_nType = EAnnotType::Unknown;
|
||||
@ -77,6 +163,7 @@ CAnnotFieldInfo::CAnnotFieldInfo() : IAdvancedCommand(AdvancedCommandType::Annot
|
||||
m_pCaretPr = NULL;
|
||||
m_pStampPr = NULL;
|
||||
m_pRedactPr = NULL;
|
||||
m_pLinkPr = NULL;
|
||||
m_pWidgetPr = NULL;
|
||||
}
|
||||
CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
@ -93,6 +180,7 @@ CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
RELEASEOBJECT(m_pCaretPr);
|
||||
RELEASEOBJECT(m_pStampPr);
|
||||
RELEASEOBJECT(m_pRedactPr);
|
||||
RELEASEOBJECT(m_pLinkPr);
|
||||
RELEASEOBJECT(m_pWidgetPr);
|
||||
}
|
||||
|
||||
@ -113,6 +201,12 @@ void CAnnotFieldInfo::SetType(int nType)
|
||||
m_pTextPr = new CAnnotFieldInfo::CTextAnnotPr();
|
||||
break;
|
||||
}
|
||||
case EAnnotType::Link:
|
||||
{
|
||||
RELEASEOBJECT(m_pLinkPr);
|
||||
m_pLinkPr = new CAnnotFieldInfo::CLinkAnnotPr();
|
||||
break;
|
||||
}
|
||||
case EAnnotType::FreeText:
|
||||
{
|
||||
CreateMarkup();
|
||||
@ -305,6 +399,10 @@ bool CAnnotFieldInfo::IsRedact() const
|
||||
{
|
||||
return (m_nType == 25);
|
||||
}
|
||||
bool CAnnotFieldInfo::IsLink() const
|
||||
{
|
||||
return (m_nType == 1);
|
||||
}
|
||||
|
||||
CAnnotFieldInfo::CMarkupAnnotPr* CAnnotFieldInfo::GetMarkupAnnotPr() { return m_pMarkupPr; }
|
||||
CAnnotFieldInfo::CTextAnnotPr* CAnnotFieldInfo::GetTextAnnotPr() { return m_pTextPr; }
|
||||
@ -318,6 +416,7 @@ CAnnotFieldInfo::CFreeTextAnnotPr* CAnnotFieldInfo::GetFreeTextAnnotPr()
|
||||
CAnnotFieldInfo::CCaretAnnotPr* CAnnotFieldInfo::GetCaretAnnotPr() { return m_pCaretPr; }
|
||||
CAnnotFieldInfo::CStampAnnotPr* CAnnotFieldInfo::GetStampAnnotPr() { return m_pStampPr; }
|
||||
CAnnotFieldInfo::CRedactAnnotPr* CAnnotFieldInfo::GetRedactAnnotPr() { return m_pRedactPr; }
|
||||
CAnnotFieldInfo::CLinkAnnotPr* CAnnotFieldInfo::GetLinkAnnotPr() { return m_pLinkPr; }
|
||||
CAnnotFieldInfo::CWidgetAnnotPr* CAnnotFieldInfo::GetWidgetAnnotPr() { return m_pWidgetPr; }
|
||||
|
||||
bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
@ -412,6 +511,8 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
m_pPopupPr->Read(pReader);
|
||||
else if (IsWidget())
|
||||
m_pWidgetPr->Read(pReader, nType);
|
||||
else if (IsLink())
|
||||
m_pLinkPr->Read(pReader);
|
||||
|
||||
return m_nType != -1;
|
||||
}
|
||||
@ -721,6 +822,45 @@ void CAnnotFieldInfo::CRedactAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
}
|
||||
}
|
||||
|
||||
CAnnotFieldInfo::CLinkAnnotPr::CLinkAnnotPr()
|
||||
{
|
||||
m_pAction = NULL;
|
||||
m_pPA = NULL;
|
||||
}
|
||||
CAnnotFieldInfo::CLinkAnnotPr::~CLinkAnnotPr()
|
||||
{
|
||||
RELEASEOBJECT(m_pAction);
|
||||
RELEASEOBJECT(m_pPA);
|
||||
}
|
||||
BYTE CAnnotFieldInfo::CLinkAnnotPr::GetH() const { return m_nH; }
|
||||
int CAnnotFieldInfo::CLinkAnnotPr::GetFlags() const { return m_nFlags; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CLinkAnnotPr::GetQuadPoints() { return m_arrQuadPoints; }
|
||||
CAnnotFieldInfo::CActionFieldPr* CAnnotFieldInfo::CLinkAnnotPr::GetA() { return m_pAction; }
|
||||
CAnnotFieldInfo::CActionFieldPr* CAnnotFieldInfo::CLinkAnnotPr::GetPA() { return m_pPA; }
|
||||
void CAnnotFieldInfo::CLinkAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader)
|
||||
{
|
||||
m_nFlags = pReader->ReadInt();
|
||||
if (m_nFlags & (1 << 0))
|
||||
{
|
||||
pReader->ReadString();
|
||||
m_pAction = ReadAction(pReader);
|
||||
}
|
||||
if (m_nFlags & (1 << 1))
|
||||
{
|
||||
pReader->ReadString();
|
||||
m_pPA = ReadAction(pReader);
|
||||
}
|
||||
if (m_nFlags & (1 << 2))
|
||||
m_nH = pReader->ReadByte();
|
||||
if (m_nFlags & (1 << 3))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrQuadPoints.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
}
|
||||
}
|
||||
|
||||
bool CAnnotFieldInfo::CPopupAnnotPr::IsOpen() const { return m_bOpen; }
|
||||
int CAnnotFieldInfo::CPopupAnnotPr::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::CPopupAnnotPr::GetParentID() const { return m_nParentID; }
|
||||
@ -752,7 +892,7 @@ const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetFontKey() { return m_w
|
||||
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; }
|
||||
const std::vector<CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget*>& CAnnotFieldInfo::CWidgetAnnotPr::GetActions() { return m_arrAction; }
|
||||
const std::vector<CAnnotFieldInfo::CActionFieldPr*>& CAnnotFieldInfo::CWidgetAnnotPr::GetActions() { return m_arrAction; }
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr* CAnnotFieldInfo::CWidgetAnnotPr::GetButtonWidgetPr() { return m_pButtonPr; }
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr* CAnnotFieldInfo::CWidgetAnnotPr::GetTextWidgetPr() { return m_pTextPr; }
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr* CAnnotFieldInfo::CWidgetAnnotPr::GetChoiceWidgetPr() { return m_pChoicePr; }
|
||||
@ -812,93 +952,8 @@ CAnnotFieldInfo::CWidgetAnnotPr::~CWidgetAnnotPr()
|
||||
RELEASEOBJECT(m_arrAction[i]);
|
||||
}
|
||||
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget::CActionWidget() : pNext(NULL) {}
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget::~CActionWidget() { RELEASEOBJECT(pNext); }
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* ReadAction(NSOnlineOfficeBinToPdf::CBufferReader* pReader)
|
||||
{
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* pRes = new CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget();
|
||||
|
||||
pRes->nActionType = pReader->ReadByte();
|
||||
switch (pRes->nActionType)
|
||||
{
|
||||
case 14: // JavaScript
|
||||
{
|
||||
pRes->wsStr1 = pReader->ReadString();
|
||||
break;
|
||||
}
|
||||
case 1: // GoTo
|
||||
{
|
||||
pRes->nInt1 = pReader->ReadInt();
|
||||
pRes->nKind = pReader->ReadByte();
|
||||
switch (pRes->nKind)
|
||||
{
|
||||
case 0:
|
||||
case 2:
|
||||
case 3:
|
||||
case 6:
|
||||
case 7:
|
||||
{
|
||||
pRes->nFlags = pReader->ReadByte();
|
||||
if (pRes->nFlags & (1 << 0))
|
||||
pRes->dD[0] = pReader->ReadDouble();
|
||||
if (pRes->nFlags & (1 << 1))
|
||||
pRes->dD[1] = pReader->ReadDouble();
|
||||
if (pRes->nFlags & (1 << 2))
|
||||
pRes->dD[2] = pReader->ReadDouble();
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
pRes->dD[0] = pReader->ReadDouble();
|
||||
pRes->dD[1] = pReader->ReadDouble();
|
||||
pRes->dD[2] = pReader->ReadDouble();
|
||||
pRes->dD[3] = pReader->ReadDouble();
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 5:
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 10: // Named
|
||||
{
|
||||
pRes->wsStr1 = pReader->ReadString();
|
||||
break;
|
||||
}
|
||||
case 6: // URI
|
||||
{
|
||||
pRes->wsStr1 = pReader->ReadString();
|
||||
break;
|
||||
}
|
||||
case 9: // Hide
|
||||
{
|
||||
pRes->nKind = pReader->ReadByte();
|
||||
int n = pReader->ReadInt();
|
||||
pRes->arrStr.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pRes->arrStr.push_back(pReader->ReadString());
|
||||
break;
|
||||
}
|
||||
case 12: // ResetForm
|
||||
{
|
||||
pRes->nInt1 = pReader->ReadInt();
|
||||
int n = pReader->ReadInt();
|
||||
pRes->arrStr.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
pRes->arrStr.push_back(pReader->ReadString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pReader->ReadByte())
|
||||
pRes->pNext = ReadAction(pReader);
|
||||
|
||||
return pRes;
|
||||
}
|
||||
CAnnotFieldInfo::CActionFieldPr::CActionFieldPr() : pNext(NULL) {}
|
||||
CAnnotFieldInfo::CActionFieldPr::~CActionFieldPr() { RELEASEOBJECT(pNext); }
|
||||
void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, BYTE nType)
|
||||
{
|
||||
m_wsFN = pReader->ReadString();
|
||||
@ -957,7 +1012,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
for (int i = 0; i < nAction; ++i)
|
||||
{
|
||||
std::wstring wsType = pReader->ReadString();
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* pA = ReadAction(pReader);
|
||||
CAnnotFieldInfo::CActionFieldPr* pA = ReadAction(pReader);
|
||||
if (pA)
|
||||
{
|
||||
pA->wsType = wsType;
|
||||
@ -987,6 +1042,7 @@ const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::GetCA() {
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::GetRC() { return m_wsRC; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::GetAC() { return m_wsAC; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::GetAP_N_Yes() { return m_wsAP_N_Yes; }
|
||||
const std::vector< std::pair<std::wstring, std::wstring> >& CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::GetOpt() { return m_arrOpt; }
|
||||
void CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, BYTE nType, int nFlags)
|
||||
{
|
||||
if (nType == 27)
|
||||
@ -1027,6 +1083,17 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::Read(NSOnlineOfficeBinToP
|
||||
if (nFlags & (1 << 9))
|
||||
m_wsV = pReader->ReadString();
|
||||
m_nStyle = pReader->ReadByte();
|
||||
if (nFlags & (1 << 10))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrOpt.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::wstring s1 = pReader->ReadString();
|
||||
std::wstring s2 = pReader->ReadString();
|
||||
m_arrOpt.push_back(std::make_pair(s1, s2));
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 14))
|
||||
m_wsAP_N_Yes = pReader->ReadString();
|
||||
}
|
||||
@ -1192,7 +1259,7 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
for (int i = 0; i < nAction; ++i)
|
||||
{
|
||||
std::wstring wsType = pReader->ReadString();
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* pA = ReadAction(pReader);
|
||||
CAnnotFieldInfo::CActionFieldPr* pA = ReadAction(pReader);
|
||||
if (pA)
|
||||
{
|
||||
pA->wsType = wsType;
|
||||
|
||||
@ -70,6 +70,23 @@ public:
|
||||
WidgetSignature = 33
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CActionFieldPr
|
||||
{
|
||||
public:
|
||||
CActionFieldPr();
|
||||
~CActionFieldPr();
|
||||
|
||||
BYTE nKind;
|
||||
BYTE nFlags;
|
||||
BYTE nActionType;
|
||||
int nInt1;
|
||||
double dD[4]{};
|
||||
std::wstring wsType;
|
||||
std::wstring wsStr1;
|
||||
std::vector<std::wstring> arrStr;
|
||||
CActionFieldPr* pNext;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CWidgetAnnotPr
|
||||
{
|
||||
public:
|
||||
@ -90,6 +107,7 @@ public:
|
||||
const std::wstring& GetRC();
|
||||
const std::wstring& GetAC();
|
||||
const std::wstring& GetAP_N_Yes();
|
||||
const std::vector< std::pair<std::wstring, std::wstring> >& GetOpt();
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, BYTE nType, int nFlags);
|
||||
|
||||
@ -108,6 +126,7 @@ public:
|
||||
std::wstring m_wsRC;
|
||||
std::wstring m_wsAC;
|
||||
std::wstring m_wsAP_N_Yes;
|
||||
std::vector< std::pair<std::wstring, std::wstring> > m_arrOpt;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CTextWidgetPr
|
||||
@ -159,23 +178,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CActionWidget
|
||||
{
|
||||
public:
|
||||
CActionWidget();
|
||||
~CActionWidget();
|
||||
|
||||
BYTE nKind;
|
||||
BYTE nFlags;
|
||||
BYTE nActionType;
|
||||
int nInt1;
|
||||
double dD[4]{};
|
||||
std::wstring wsType;
|
||||
std::wstring wsStr1;
|
||||
std::vector<std::wstring> arrStr;
|
||||
CActionWidget* pNext;
|
||||
};
|
||||
|
||||
CWidgetAnnotPr(BYTE nType);
|
||||
~CWidgetAnnotPr();
|
||||
|
||||
@ -199,7 +201,7 @@ public:
|
||||
const std::vector<double>& GetTC();
|
||||
const std::vector<double>& GetBC();
|
||||
const std::vector<double>& GetBG();
|
||||
const std::vector<CActionWidget*>& GetActions();
|
||||
const std::vector<CActionFieldPr*>& GetActions();
|
||||
|
||||
CButtonWidgetPr* GetButtonWidgetPr();
|
||||
CTextWidgetPr* GetTextWidgetPr();
|
||||
@ -229,7 +231,7 @@ public:
|
||||
std::vector<double> m_arrTC;
|
||||
std::vector<double> m_arrBC;
|
||||
std::vector<double> m_arrBG;
|
||||
std::vector<CActionWidget*> m_arrAction;
|
||||
std::vector<CActionFieldPr*> m_arrAction;
|
||||
|
||||
CButtonWidgetPr* m_pButtonPr;
|
||||
CTextWidgetPr* m_pTextPr;
|
||||
@ -389,7 +391,7 @@ public:
|
||||
{
|
||||
public:
|
||||
bool IsOpen() const;
|
||||
int GetFlag() const;
|
||||
int GetFlag() const;
|
||||
int GetParentID() const;
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader);
|
||||
@ -478,6 +480,28 @@ public:
|
||||
std::vector<double> m_arrQuadPoints;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CLinkAnnotPr
|
||||
{
|
||||
public:
|
||||
CLinkAnnotPr();
|
||||
~CLinkAnnotPr();
|
||||
|
||||
BYTE GetH() const;
|
||||
int GetFlags() const;
|
||||
const std::vector<double>& GetQuadPoints();
|
||||
CActionFieldPr* GetA();
|
||||
CActionFieldPr* GetPA();
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader);
|
||||
|
||||
private:
|
||||
BYTE m_nH;
|
||||
int m_nFlags;
|
||||
std::vector<double> m_arrQuadPoints;
|
||||
CActionFieldPr* m_pAction;
|
||||
CActionFieldPr* m_pPA;
|
||||
};
|
||||
|
||||
CAnnotFieldInfo();
|
||||
virtual ~CAnnotFieldInfo();
|
||||
|
||||
@ -518,6 +542,7 @@ public:
|
||||
bool IsCaret() const;
|
||||
bool IsStamp() const;
|
||||
bool IsRedact() const;
|
||||
bool IsLink() const;
|
||||
|
||||
CMarkupAnnotPr* GetMarkupAnnotPr();
|
||||
CTextAnnotPr* GetTextAnnotPr();
|
||||
@ -531,6 +556,7 @@ public:
|
||||
CCaretAnnotPr* GetCaretAnnotPr();
|
||||
CStampAnnotPr* GetStampAnnotPr();
|
||||
CRedactAnnotPr* GetRedactAnnotPr();
|
||||
CLinkAnnotPr* GetLinkAnnotPr();
|
||||
CWidgetAnnotPr* GetWidgetAnnotPr();
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
@ -576,6 +602,7 @@ private:
|
||||
CCaretAnnotPr* m_pCaretPr;
|
||||
CStampAnnotPr* m_pStampPr;
|
||||
CRedactAnnotPr* m_pRedactPr;
|
||||
CLinkAnnotPr* m_pLinkPr;
|
||||
CWidgetAnnotPr* m_pWidgetPr;
|
||||
};
|
||||
|
||||
@ -610,7 +637,7 @@ public:
|
||||
std::wstring sTU;
|
||||
std::vector<int> arrI;
|
||||
std::vector<std::wstring> arrV;
|
||||
std::vector<CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget*> arrAction;
|
||||
std::vector<CAnnotFieldInfo::CActionFieldPr*> arrAction;
|
||||
std::vector< std::pair<std::wstring, std::wstring> > arrOpt;
|
||||
};
|
||||
|
||||
|
||||
@ -179,7 +179,6 @@ CHeadings::CHeading::CHeading()
|
||||
nPage = 0;
|
||||
dX = 0.0;
|
||||
dY = 0.0;
|
||||
pParent = NULL;
|
||||
}
|
||||
CHeadings::CHeading::~CHeading()
|
||||
{
|
||||
@ -196,35 +195,26 @@ CHeadings::~CHeadings()
|
||||
const std::vector<CHeadings::CHeading*>& CHeadings::GetHeading() { return m_arrHeading; }
|
||||
bool CHeadings::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
int nPredLevel = 0, nHeaderLevel = 0;
|
||||
std::vector<CHeading*>* arrHeading = &m_arrHeading;
|
||||
CHeading* pParent = NULL;
|
||||
std::vector<CHeading*> arrParentStack;
|
||||
int nHeadings = pReader->ReadInt();
|
||||
for (int i = 0; i < nHeadings; ++i)
|
||||
{
|
||||
int nLevel = pReader->ReadInt();
|
||||
if (nLevel > nPredLevel && i > 0)
|
||||
{
|
||||
nHeaderLevel = nPredLevel;
|
||||
pParent = arrHeading->back();
|
||||
arrHeading = &pParent->arrHeading;
|
||||
}
|
||||
else if (nLevel < nPredLevel && nLevel <= nHeaderLevel)
|
||||
{
|
||||
nHeaderLevel = nLevel;
|
||||
pParent = pParent ? pParent->pParent : NULL;
|
||||
arrHeading = pParent ? &pParent->arrHeading : &m_arrHeading;
|
||||
}
|
||||
nPredLevel = nLevel;
|
||||
|
||||
CHeading* pHeading = new CHeading();
|
||||
pHeading->nPage = pReader->ReadInt();
|
||||
pHeading->dX = pReader->ReadDouble();
|
||||
pHeading->dY = pReader->ReadDouble();
|
||||
pHeading->wsTitle = pReader->ReadString();
|
||||
pHeading->pParent = pParent;
|
||||
|
||||
arrHeading->push_back(pHeading);
|
||||
while (arrParentStack.size() > nLevel)
|
||||
arrParentStack.pop_back();
|
||||
|
||||
if (arrParentStack.empty())
|
||||
m_arrHeading.push_back(pHeading);
|
||||
else
|
||||
arrParentStack.back()->arrHeading.push_back(pHeading);
|
||||
|
||||
arrParentStack.push_back(pHeading);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -181,7 +181,6 @@ public:
|
||||
int nPage;
|
||||
double dX;
|
||||
double dY;
|
||||
CHeading* pParent;
|
||||
std::vector<CHeading*> arrHeading;
|
||||
|
||||
CHeading();
|
||||
|
||||
@ -46,16 +46,20 @@
|
||||
"_InitializeFontsRanges",
|
||||
"_SetFontBinary",
|
||||
"_GetFontBinary",
|
||||
"_GetGIDByUnicode",
|
||||
"_IsFontBinaryExist",
|
||||
"_DestroyTextInfo",
|
||||
"_IsNeedCMap",
|
||||
"_SetCMapData",
|
||||
"_SetScanPageFonts",
|
||||
"_ScanPage",
|
||||
"_SplitPages",
|
||||
"_MergePages",
|
||||
"_UnmergePages",
|
||||
"_RedactPage",
|
||||
"_UndoRedact",
|
||||
"_CheckOwnerPassword",
|
||||
"_CheckPerm",
|
||||
"_GetImageBase64",
|
||||
"_GetImageBase64Len",
|
||||
"_GetImageBase64Ptr",
|
||||
@ -193,7 +197,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcReader/",
|
||||
"files": ["Adaptors.cpp", "GfxClip.cpp", "RendererOutputDev.cpp", "JPXStream2.cpp", "PdfAnnot.cpp"]
|
||||
"files": ["Adaptors.cpp", "GfxClip.cpp", "RendererOutputDev.cpp", "JPXStream2.cpp", "PdfAnnot.cpp", "PdfFont.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcWriter/",
|
||||
|
||||
@ -639,6 +639,7 @@ SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcReader/Adaptors.cpp \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.cpp \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.cpp \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfFont.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/BaseFonts.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp
|
||||
|
||||
@ -664,6 +665,7 @@ HEADERS +=\
|
||||
$$PDF_ROOT_DIR/SrcReader/MemoryUtils.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/FontsWasm.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfFont.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.h
|
||||
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM
|
||||
|
||||
@ -145,6 +145,14 @@ CFile.prototype["isNeedPassword"] = function()
|
||||
{
|
||||
return this._isNeedPassword;
|
||||
};
|
||||
CFile.prototype["CheckOwnerPassword"] = function(password)
|
||||
{
|
||||
return this._CheckOwnerPassword(password);
|
||||
};
|
||||
CFile.prototype["CheckPerm"] = function(perm)
|
||||
{
|
||||
return this._CheckPerm(perm);
|
||||
};
|
||||
CFile.prototype["SplitPages"] = function(arrOriginIndex, arrayBufferChanges)
|
||||
{
|
||||
let ptr = this._SplitPages(arrOriginIndex, arrayBufferChanges);
|
||||
@ -354,6 +362,26 @@ CFile.prototype["getFontByID"] = function(ID)
|
||||
return this._getFontByID(ID);
|
||||
};
|
||||
|
||||
CFile.prototype["getGIDByUnicode"] = function(ID)
|
||||
{
|
||||
let ptr = this._getGIDByUnicode(ID);
|
||||
let reader = ptr.getReader();
|
||||
if (!reader)
|
||||
return {};
|
||||
|
||||
let res = {};
|
||||
let nFontLength = reader.readInt();
|
||||
for (let i = 0; i < nFontLength; i++)
|
||||
{
|
||||
let np1 = reader.readInt();
|
||||
let np2 = reader.readInt();
|
||||
res[np2] = np1;
|
||||
}
|
||||
|
||||
ptr.free();
|
||||
return res;
|
||||
};
|
||||
|
||||
CFile.prototype["setCMap"] = function(memoryBuffer)
|
||||
{
|
||||
if (!this.nativeFile)
|
||||
@ -401,7 +429,7 @@ function readAction(reader, rec, readDoubleFunc, readStringFunc)
|
||||
case 6:
|
||||
case 7:
|
||||
{
|
||||
let nFlag = reader.readByte();
|
||||
let nFlag = reader.readInt();
|
||||
if (nFlag & (1 << 0))
|
||||
rec["left"] = readDoubleFunc.call(reader);
|
||||
if (nFlag & (1 << 1))
|
||||
@ -413,9 +441,9 @@ function readAction(reader, rec, readDoubleFunc, readStringFunc)
|
||||
case 4:
|
||||
{
|
||||
rec["left"] = readDoubleFunc.call(reader);
|
||||
rec["bottom"] = readDoubleFunc.call(reader);
|
||||
rec["top"] = readDoubleFunc.call(reader);
|
||||
rec["right"] = readDoubleFunc.call(reader);
|
||||
rec["top"] = readDoubleFunc.call(reader);
|
||||
rec["bottom"] = readDoubleFunc.call(reader);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
@ -1027,6 +1055,37 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
rec["font"]["style"] = reader.readInt();
|
||||
}
|
||||
}
|
||||
// Link
|
||||
else if (rec["type"] == 1)
|
||||
{
|
||||
flags = reader.readInt();
|
||||
if (flags & (1 << 0))
|
||||
{
|
||||
rec["A"] = {};
|
||||
if (isRead)
|
||||
readStringFunc.call(reader);
|
||||
readAction(reader, rec["A"], readDoubleFunc, readStringFunc);
|
||||
}
|
||||
if (flags & (1 << 1))
|
||||
{
|
||||
rec["PA"] = {};
|
||||
if (isRead)
|
||||
readStringFunc.call(reader);
|
||||
readAction(reader, rec["PA"], readDoubleFunc, readStringFunc);
|
||||
}
|
||||
// Selection mode - H
|
||||
// 0 - none, 1 - invert, 2 - push, 3 - outline
|
||||
if (flags & (1 << 2))
|
||||
rec["highlight"] = reader.readByte();
|
||||
// QuadPoints
|
||||
if (flags & (1 << 3))
|
||||
{
|
||||
let n = reader.readInt();
|
||||
rec["QuadPoints"] = [];
|
||||
for (let i = 0; i < n; ++i)
|
||||
rec["QuadPoints"].push(readDoubleFunc.call(reader));
|
||||
}
|
||||
}
|
||||
}
|
||||
function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readStringFunc, isRead = false)
|
||||
{
|
||||
@ -1171,6 +1230,20 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString
|
||||
rec["value"] = readStringFunc.call(reader);
|
||||
// 0 - check, 1 - cross, 2 - diamond, 3 - circle, 4 - star, 5 - square
|
||||
rec["style"] = reader.readByte();
|
||||
if (flags & (1 << 10))
|
||||
{
|
||||
let n = reader.readInt();
|
||||
rec["opt"] = [];
|
||||
for (let i = 0; i < n; ++i)
|
||||
{
|
||||
let opt1 = readStringFunc.call(reader);
|
||||
let opt2 = readStringFunc.call(reader);
|
||||
if (opt1 == "")
|
||||
rec["opt"].push(opt2);
|
||||
else
|
||||
rec["opt"].push([opt2, opt1]);
|
||||
}
|
||||
}
|
||||
if (flags & (1 << 14))
|
||||
rec["ExportValue"] = readStringFunc.call(reader);
|
||||
// 12.7.4.2.1
|
||||
@ -1648,6 +1721,11 @@ CFile.prototype["readAnnotationsInfoFromBinary"] = function(AnnotInfo)
|
||||
};
|
||||
|
||||
// SCAN PAGES
|
||||
CFile.prototype["scanPageFonts"] = function(page)
|
||||
{
|
||||
this._setScanPageFonts(page);
|
||||
};
|
||||
|
||||
CFile.prototype["scanPage"] = function(page, mode)
|
||||
{
|
||||
let ptr = this._scanPage(page, mode);
|
||||
|
||||
@ -146,6 +146,16 @@ CFile.prototype._UndoRedact = function()
|
||||
return g_native_drawing_file["UndoRedact"]();
|
||||
};
|
||||
|
||||
CFile.prototype._CheckOwnerPassword = function(password)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
CFile.prototype._CheckPerm = function(perm)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
@ -162,6 +172,12 @@ CFile.prototype._getFontByID = function(ID)
|
||||
return g_native_drawing_file["GetFontBinary"](ID);
|
||||
};
|
||||
|
||||
CFile.prototype._getGIDByUnicode = function(ID)
|
||||
{
|
||||
g_module_pointer.ptr = g_native_drawing_file["GetGIDByUnicode"](ID);
|
||||
return g_module_pointer;
|
||||
}
|
||||
|
||||
CFile.prototype._getInteractiveFormsFonts = function(type)
|
||||
{
|
||||
g_module_pointer.ptr = g_native_drawing_file["GetInteractiveFormsFonts"](type);
|
||||
@ -236,6 +252,11 @@ CFile.prototype._getInteractiveFormsAP = function(width, height, backgroundColor
|
||||
};
|
||||
|
||||
// SCAN PAGES
|
||||
CFile.prototype._setScanPageFonts = function(page)
|
||||
{
|
||||
g_native_drawing_file["SetScanPageFonts"](page);
|
||||
};
|
||||
|
||||
CFile.prototype._scanPage = function(page, mode)
|
||||
{
|
||||
g_module_pointer.ptr = g_native_drawing_file["ScanPage"](page, (mode === undefined) ? 0 : mode);
|
||||
|
||||
@ -106,7 +106,7 @@ CFile.prototype._openFile = function(buffer, password)
|
||||
}
|
||||
|
||||
let passwordPtr = 0;
|
||||
if (password)
|
||||
if (password !== undefined)
|
||||
{
|
||||
let passwordBuf = password.toUtf8();
|
||||
passwordPtr = Module["_malloc"](passwordBuf.length);
|
||||
@ -224,6 +224,29 @@ CFile.prototype._UndoRedact = function()
|
||||
return Module["_UndoRedact"](this.nativeFile) == 1;
|
||||
};
|
||||
|
||||
CFile.prototype._CheckOwnerPassword = function(password)
|
||||
{
|
||||
let passwordPtr = 0;
|
||||
if (password !== undefined)
|
||||
{
|
||||
let passwordBuf = password.toUtf8();
|
||||
passwordPtr = Module["_malloc"](passwordBuf.length);
|
||||
Module["HEAP8"].set(passwordBuf, passwordPtr);
|
||||
}
|
||||
|
||||
let bRes = Module["_CheckOwnerPassword"](this.nativeFile, passwordPtr);
|
||||
|
||||
if (passwordPtr)
|
||||
Module["_free"](passwordPtr);
|
||||
|
||||
return bRes == 1;
|
||||
}
|
||||
|
||||
CFile.prototype._CheckPerm = function(perm)
|
||||
{
|
||||
return Module["_CheckPerm"](this.nativeFile, perm) == 1;
|
||||
}
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
@ -263,6 +286,19 @@ CFile.prototype._getFontByID = function(ID)
|
||||
return res;
|
||||
};
|
||||
|
||||
CFile.prototype._getGIDByUnicode = function(ID)
|
||||
{
|
||||
if (ID === undefined)
|
||||
return null;
|
||||
|
||||
let idBuffer = ID.toUtf8();
|
||||
let idPointer = Module["_malloc"](idBuffer.length);
|
||||
Module["HEAP8"].set(idBuffer, idPointer);
|
||||
g_module_pointer.ptr = Module["_GetGIDByUnicode"](this.nativeFile, idPointer);
|
||||
Module["_free"](idPointer);
|
||||
return g_module_pointer;
|
||||
}
|
||||
|
||||
CFile.prototype._getInteractiveFormsFonts = function(type)
|
||||
{
|
||||
g_module_pointer.ptr = Module["_GetInteractiveFormsFonts"](this.nativeFile, type);
|
||||
@ -337,6 +373,11 @@ CFile.prototype._getInteractiveFormsAP = function(width, height, backgroundColor
|
||||
};
|
||||
|
||||
// SCAN PAGES
|
||||
CFile.prototype._setScanPageFonts = function(page)
|
||||
{
|
||||
Module["_SetScanPageFonts"](this.nativeFile, page);
|
||||
};
|
||||
|
||||
CFile.prototype._scanPage = function(page, mode)
|
||||
{
|
||||
g_module_pointer.ptr = Module["_ScanPage"](this.nativeFile, page, (mode === undefined) ? 0 : mode);
|
||||
|
||||
@ -80,7 +80,7 @@ WASM_EXPORT CDrawingFile* Open(BYTE* data, LONG size, const char* password)
|
||||
std::wstring sPassword = L"";
|
||||
if (NULL != password)
|
||||
sPassword = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)password, strlen(password));
|
||||
pFile->OpenFile(data, size, sPassword);
|
||||
pFile->OpenFile(data, size, password ? sPassword.c_str() : NULL);
|
||||
return pFile;
|
||||
}
|
||||
WASM_EXPORT int GetType(CDrawingFile* pFile)
|
||||
@ -150,6 +150,10 @@ WASM_EXPORT BYTE* GetFontBinary(CDrawingFile* pFile, char* path)
|
||||
{
|
||||
return pFile->GetFontBinary(std::string(path));
|
||||
}
|
||||
WASM_EXPORT BYTE* GetGIDByUnicode(CDrawingFile* pFile, char* path)
|
||||
{
|
||||
return pFile->GetGIDByUnicode(std::string(path));
|
||||
}
|
||||
WASM_EXPORT void DestroyTextInfo(CDrawingFile* pFile)
|
||||
{
|
||||
return pFile->DestroyTextInfo();
|
||||
@ -162,6 +166,10 @@ WASM_EXPORT void SetCMapData(CDrawingFile* pFile, BYTE* data, int size)
|
||||
{
|
||||
pFile->SetCMapData(data, size);
|
||||
}
|
||||
WASM_EXPORT void SetScanPageFonts(CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pFile->SetScanPageFonts(nPageIndex);
|
||||
}
|
||||
WASM_EXPORT BYTE* ScanPage(CDrawingFile* pFile, int nPageIndex, int mode)
|
||||
{
|
||||
return pFile->ScanPage(nPageIndex, mode);
|
||||
@ -191,6 +199,17 @@ WASM_EXPORT int UndoRedact(CDrawingFile* pFile)
|
||||
{
|
||||
return pFile->UndoRedact() ? 1 : 0;
|
||||
}
|
||||
WASM_EXPORT int CheckOwnerPassword(CDrawingFile* pFile, const char* password)
|
||||
{
|
||||
std::wstring sPassword = L"";
|
||||
if (NULL != password)
|
||||
sPassword = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)password, strlen(password));
|
||||
return pFile->CheckOwnerPassword(password ? sPassword.c_str() : NULL) ? 1 : 0;
|
||||
}
|
||||
WASM_EXPORT int CheckPerm(CDrawingFile* pFile, int nPermFlag)
|
||||
{
|
||||
return pFile->CheckPerm(nPermFlag) ? 1 : 0;
|
||||
}
|
||||
|
||||
WASM_EXPORT void* GetImageBase64(CDrawingFile* pFile, int rId)
|
||||
{
|
||||
|
||||
@ -704,6 +704,23 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i)
|
||||
i += 1;
|
||||
std::cout << "Style " << arrStyle[nPathLength] << ", ";
|
||||
|
||||
if (nFlags & (1 << 10))
|
||||
{
|
||||
int nOptLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
for (int j = 0; j < nOptLength; ++j)
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << std::to_string(j) << " Opt1 " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
i += 4;
|
||||
std::cout << std::to_string(j) << " Opt2 " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
|
||||
i += nPathLength;
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 14))
|
||||
{
|
||||
nPathLength = READ_INT(pWidgets + i);
|
||||
@ -938,6 +955,36 @@ void ReadInteractiveFormsFonts(CDrawingFile* pGrFile, int nType)
|
||||
std::cout << "font" << j << ".txt";
|
||||
}
|
||||
|
||||
if (pFont)
|
||||
free(pFont);
|
||||
|
||||
if (true)
|
||||
continue;
|
||||
|
||||
pFont = GetGIDByUnicode(pGrFile, (char*)sFontName.c_str());
|
||||
nLength2 = READ_INT(pFont);
|
||||
i2 = 4;
|
||||
nLength2 -= 4;
|
||||
|
||||
while (i2 < nLength2)
|
||||
{
|
||||
int nFontLength = READ_INT(pFont + i2);
|
||||
i2 += 4;
|
||||
|
||||
std::cout << std::endl << "GIDtoUnicode" << std::endl;
|
||||
|
||||
for (int j = 0; j < nFontLength; ++j)
|
||||
{
|
||||
unsigned int code = READ_INT(pFont + i2);
|
||||
i2 += 4;
|
||||
unsigned int unicode = READ_INT(pFont + i2);
|
||||
i2 += 4;
|
||||
std::cout << "gid\t" << code << "\tunicode\t" << unicode << std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
if (pFont)
|
||||
free(pFont);
|
||||
}
|
||||
@ -1025,7 +1072,7 @@ int main(int argc, char* argv[])
|
||||
if (!NSFile::CFileBinary::ReadAllBytes(sFilePath, &pFileData, nFileDataLen))
|
||||
return 1;
|
||||
|
||||
CDrawingFile* pGrFile = Open(pFileData, (LONG)nFileDataLen, "");
|
||||
CDrawingFile* pGrFile = Open(pFileData, (LONG)nFileDataLen, NULL);
|
||||
int nError = GetErrorCode(pGrFile);
|
||||
|
||||
if (nError != 0)
|
||||
@ -1033,7 +1080,7 @@ int main(int argc, char* argv[])
|
||||
Close(pGrFile);
|
||||
if (nError == 4)
|
||||
{
|
||||
std::string sPassword = "123456";
|
||||
std::string sPassword = "";
|
||||
pGrFile = Open(pFileData, nFileDataLen, sPassword.c_str());
|
||||
}
|
||||
else
|
||||
@ -1053,7 +1100,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (true && GetFromBase64(NSFile::GetProcessDirectory() + L"/split.txt", &pBuffer, &nBufferLen))
|
||||
{
|
||||
std::vector<int> arrPages = { 2 };
|
||||
std::vector<int> arrPages = { 0 };
|
||||
BYTE* pSplitPages = SplitPages(pGrFile, arrPages.data(), arrPages.size(), pBuffer, nBufferLen);
|
||||
int nLength = READ_INT(pSplitPages);
|
||||
|
||||
@ -1125,26 +1172,38 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
BYTE* pColor = new BYTE[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
// OWNER PASSWORD
|
||||
if (false)
|
||||
{
|
||||
std::string sPassword = "";
|
||||
std::cout << "CheckPerm 4 Edit " << CheckPerm(pGrFile, 4) << std::endl;
|
||||
std::cout << "CheckPerm 4 Print " << CheckPerm(pGrFile, 3) << std::endl;
|
||||
|
||||
std::cout << "CheckOwnerPassword " << CheckOwnerPassword(pGrFile, sPassword.c_str()) << std::endl;
|
||||
std::cout << "CheckPerm 4 Edit " << CheckPerm(pGrFile, 4) << std::endl;
|
||||
std::cout << "CheckPerm 4 Print " << CheckPerm(pGrFile, 3) << std::endl;
|
||||
}
|
||||
|
||||
// REDACT
|
||||
if (false)
|
||||
{
|
||||
BYTE* pColor = new BYTE[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
int pRect[8] = { 307499, 217499, 307499, 1124999, 1799999, 1124999, 1799999, 217499 };
|
||||
if (!RedactPage(pGrFile, nTestPage, pRect, 1, pColor, 12))
|
||||
std::cout << "Redact false" << std::endl;
|
||||
}
|
||||
|
||||
int i = nTestPage;
|
||||
//for (int i = 0; i < nPagesCount; ++i)
|
||||
// RASTER
|
||||
if (false)
|
||||
{
|
||||
// RASTER
|
||||
if (true)
|
||||
int i = nTestPage;
|
||||
//for (int i = 0; i < nPagesCount; ++i)
|
||||
{
|
||||
nWidth = READ_INT(pInfo + i * 16 + 12);
|
||||
nHeight = READ_INT(pInfo + i * 16 + 16);
|
||||
|
||||
//nWidth *= 3;
|
||||
//nHeight *= 3;
|
||||
//nWidth *= 2;
|
||||
//nHeight *= 2;
|
||||
|
||||
BYTE* res = NULL;
|
||||
res = GetPixmap(pGrFile, i, nWidth, nHeight, 0xFFFFFF);
|
||||
@ -1164,7 +1223,7 @@ int main(int argc, char* argv[])
|
||||
free(pInfo);
|
||||
|
||||
// LINKS
|
||||
if (true && nPagesCount > 0)
|
||||
if (false && nPagesCount > 0)
|
||||
{
|
||||
BYTE* pLinks = GetLinks(pGrFile, nTestPage);
|
||||
nLength = READ_INT(pLinks);
|
||||
@ -1200,7 +1259,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// STRUCTURE
|
||||
if (true)
|
||||
if (false)
|
||||
{
|
||||
BYTE* pStructure = GetStructure(pGrFile);
|
||||
nLength = READ_INT(pStructure);
|
||||
@ -2132,6 +2191,44 @@ int main(int argc, char* argv[])
|
||||
std::cout << nPathLength << ", ";
|
||||
}
|
||||
}
|
||||
else if (sType == "Link")
|
||||
{
|
||||
nFlags = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
if (nFlags & (1 << 0))
|
||||
{
|
||||
std::cout << std::endl << "A ";
|
||||
ReadAction(pAnnots, i);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
if (nFlags & (1 << 1))
|
||||
{
|
||||
std::cout << std::endl << "PA ";
|
||||
ReadAction(pAnnots, i);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
if (nFlags & (1 << 2))
|
||||
{
|
||||
std::string arrHighlighting[] = {"none", "invert", "push", "outline"};
|
||||
nPathLength = READ_BYTE(pAnnots + i);
|
||||
i += 1;
|
||||
std::cout << "Highlight " << arrHighlighting[nPathLength] << ", ";
|
||||
}
|
||||
if (nFlags & (1 << 3))
|
||||
{
|
||||
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 << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << std::endl << "]" << std::endl;
|
||||
}
|
||||
@ -2154,12 +2251,13 @@ int main(int argc, char* argv[])
|
||||
free(pAnnotAP);
|
||||
}
|
||||
|
||||
// SCAN PAGE
|
||||
// SCAN PAGE Fonts
|
||||
if (false)
|
||||
{
|
||||
BYTE* pScan = ScanPage(pGrFile, nTestPage, 1);
|
||||
if (pScan)
|
||||
free(pScan);
|
||||
SetScanPageFonts(pGrFile, nTestPage);
|
||||
|
||||
ReadInteractiveFormsFonts(pGrFile, 1);
|
||||
ReadInteractiveFormsFonts(pGrFile, 2);
|
||||
}
|
||||
|
||||
Close(pGrFile);
|
||||
|
||||
@ -63,9 +63,9 @@ public:
|
||||
|
||||
// Open
|
||||
virtual bool LoadFromFile(const std::wstring& file, const std::wstring& options = L"",
|
||||
const std::wstring& owner_password = L"", const std::wstring& user_password = L"") = 0;
|
||||
const wchar_t* owner_password = NULL, const wchar_t* user_password = NULL) = 0;
|
||||
virtual bool LoadFromMemory(unsigned char* data, unsigned long length, const std::wstring& options = L"",
|
||||
const std::wstring& owner_password = L"", const std::wstring& user_password = L"") = 0;
|
||||
const wchar_t* owner_password = NULL, const wchar_t* user_password = NULL) = 0;
|
||||
|
||||
// Close
|
||||
virtual void Close() = 0;
|
||||
|
||||
@ -113,7 +113,10 @@ const long c_BrushTypeTensorCurveGradient = 6007;
|
||||
|
||||
const long c_BrushTextureModeStretch = 0;
|
||||
const long c_BrushTextureModeTile = 1;
|
||||
const long c_BrushTextureModeTileCenter = 2;
|
||||
const long c_BrushTextureModeTileFlipX = 2;
|
||||
const long c_BrushTextureModeTileFlipY = 3;
|
||||
const long c_BrushTextureModeTileFlipXY = 4;
|
||||
const long c_BrushTextureModeTileCenter = 5;
|
||||
// --------------------------------------------------------------
|
||||
|
||||
namespace Aggplus { class CImage; }
|
||||
@ -284,6 +287,13 @@ namespace NSStructures
|
||||
Aggplus::RectF Rect;
|
||||
Aggplus::CDoubleRect Bounds;
|
||||
|
||||
int IsScale;
|
||||
double ScaleX;
|
||||
double ScaleY;
|
||||
|
||||
double OffsetX;
|
||||
double OffsetY;
|
||||
|
||||
double LinearAngle;
|
||||
std::vector<TSubColor> m_arrSubColors;
|
||||
NSStructures::GradientInfo m_oGradientInfo;
|
||||
@ -415,6 +425,13 @@ namespace NSStructures
|
||||
Rect.Width = 0.0F;
|
||||
Rect.Height = 0.0F;
|
||||
|
||||
IsScale = FALSE;
|
||||
ScaleX = 1.0;
|
||||
ScaleY = 1.0;
|
||||
|
||||
OffsetX = 0.0;
|
||||
OffsetY = 0.0;
|
||||
|
||||
Bounds.left = 0;
|
||||
Bounds.top = 0;
|
||||
Bounds.right = 0;
|
||||
@ -454,6 +471,10 @@ namespace NSStructures
|
||||
Rect = other.Rect;
|
||||
Bounds = other.Bounds;
|
||||
|
||||
IsScale = other.IsScale;
|
||||
ScaleX = other.ScaleX;
|
||||
ScaleY = other.ScaleY;
|
||||
|
||||
LinearAngle = other.LinearAngle;
|
||||
m_arrSubColors = other.m_arrSubColors;
|
||||
m_oGradientInfo = other.m_oGradientInfo;
|
||||
|
||||
@ -349,7 +349,7 @@ bool CImageFileFormatChecker::isSvgFile(BYTE* pBuffer,DWORD dwBytes)
|
||||
{
|
||||
if (eFileType)return false;
|
||||
|
||||
if ( (6 <= dwBytes) &&(0x3C == pBuffer[0] && 0x3F == pBuffer[1] && 0x78 == pBuffer[2] && 0x6D == pBuffer[3]
|
||||
if ( (6 <= dwBytes) && (0x3C == pBuffer[0] && 0x3F == pBuffer[1] && 0x78 == pBuffer[2] && 0x6D == pBuffer[3]
|
||||
&& 0x6C == pBuffer[4] && 0x20 == pBuffer[5]))
|
||||
{
|
||||
std::string sXml_part = std::string((char*)pBuffer, dwBytes);
|
||||
@ -358,6 +358,11 @@ bool CImageFileFormatChecker::isSvgFile(BYTE* pBuffer,DWORD dwBytes)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ( (6 <= dwBytes) && (0x3C == pBuffer[0] && 's' == pBuffer[1] && 'v' == pBuffer[2] && 'g' == pBuffer[3]
|
||||
&& 0x20 == pBuffer[4]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ namespace MetaFile
|
||||
virtual void EndClipPath(unsigned int unMode) = 0;
|
||||
|
||||
virtual void UpdateDC() = 0;
|
||||
virtual void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) = 0;
|
||||
virtual void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) = 0;
|
||||
virtual void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -914,7 +914,7 @@ namespace MetaFile
|
||||
|
||||
m_bStartedPath = false;
|
||||
}
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY)
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY)
|
||||
{
|
||||
double dKoefX = m_dScaleX;
|
||||
double dKoefY = m_dScaleY;
|
||||
@ -1237,7 +1237,7 @@ namespace MetaFile
|
||||
|
||||
// Вычисление минимально возможной ширины пера
|
||||
// # Код явялется дублированным из Graphics
|
||||
const double dSqrtDet = sqrt(abs(oMatrix.Determinant()));
|
||||
const double dSqrtDet = sqrt(fabs(oMatrix.Determinant()));
|
||||
const double dWidthMinSize = (dSqrtDet != 0) ? (1.0 / dSqrtDet) : dWidth;
|
||||
|
||||
if (0 == pPen->GetWidth())
|
||||
@ -1270,19 +1270,6 @@ namespace MetaFile
|
||||
|
||||
if ((NULL != pDataDash && 0 != unSizeDash) || PS_SOLID != ulPenStyle)
|
||||
{
|
||||
// Дублированный код из Graphics
|
||||
// Без этого используется оригинальный код в Graphics, который отрисовывает уже неверно
|
||||
double dDashWidth{dWidth};
|
||||
|
||||
if (!Equals(dWidthMinSize, dWidth))
|
||||
{
|
||||
double dDet = oMatrix.Determinant();
|
||||
|
||||
if (fabs(dDet) < 0.0001)
|
||||
dDashWidth *= dSqrtDet;
|
||||
}
|
||||
// -----------------------------
|
||||
|
||||
if (NULL != pDataDash && 0 != unSizeDash)
|
||||
{
|
||||
m_pRenderer->put_PenDashOffset(pPen->GetDashOffset());
|
||||
@ -1290,7 +1277,7 @@ namespace MetaFile
|
||||
std::vector<double> arDashes(unSizeDash);
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex)
|
||||
arDashes[unIndex] = pDataDash[unIndex] * dDashWidth;
|
||||
arDashes[unIndex] = pDataDash[unIndex] * dWidth;
|
||||
|
||||
m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash);
|
||||
|
||||
@ -1304,35 +1291,35 @@ namespace MetaFile
|
||||
{
|
||||
case PS_DASH:
|
||||
{
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(9 * dWidth);
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DOT:
|
||||
{
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(9 * dWidth);
|
||||
arDashPattern.push_back(6 * dWidth);
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
arDashPattern.push_back(6 * dWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOTDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(9 * dWidth);
|
||||
arDashPattern.push_back(6 * dWidth);
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
arDashPattern.push_back(6 * dWidth);
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
arDashPattern.push_back(6 * dWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override {};
|
||||
|
||||
void UpdateDC() override {};
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override {};
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override {};
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override {};
|
||||
};
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ namespace MetaFile
|
||||
pInterpretator->UpdateDC();
|
||||
}
|
||||
|
||||
void CEmfInterpretatorArray::SetTransform(double &dM11, double &dM12, double &dM21, double &dM22, double &dX, double &dY)
|
||||
void CEmfInterpretatorArray::SetTransform(const double &dM11, const double &dM12, const double &dM21, const double &dM22, const double &dX, const double &dY)
|
||||
{
|
||||
for (CEmfInterpretatorBase* pInterpretator : m_arInterpretators)
|
||||
pInterpretator->SetTransform(dM11, dM12, dM21, dM22, dX, dY);
|
||||
|
||||
@ -57,7 +57,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override;
|
||||
|
||||
void UpdateDC() override;
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override;
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override;
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override;
|
||||
|
||||
void HANDLE_EMR_HEADER(const TEmfHeader& oTEmfHeader) override;
|
||||
|
||||
@ -18,8 +18,8 @@ namespace MetaFile
|
||||
|
||||
void CEmfInterpretatorRender::ChangeConditional()
|
||||
{
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->ChangeConditional();
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->ChangeConditional();
|
||||
}
|
||||
|
||||
void CEmfInterpretatorRender::Begin()
|
||||
@ -143,7 +143,7 @@ namespace MetaFile
|
||||
m_pMetaFileRenderer->UpdateDC();
|
||||
}
|
||||
|
||||
void CEmfInterpretatorRender::SetTransform(double &dM11, double &dM12, double &dM21, double &dM22, double &dX, double &dY)
|
||||
void CEmfInterpretatorRender::SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY)
|
||||
{
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->SetTransform(dM11, dM12, dM21, dM22, dX, dY);
|
||||
|
||||
@ -43,7 +43,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override;
|
||||
|
||||
void UpdateDC() override;
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override;
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override;
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override;
|
||||
|
||||
CMetaFileRenderer* GetRenderer() const;
|
||||
|
||||
@ -223,7 +223,7 @@ namespace MetaFile
|
||||
void EndPath() override {};
|
||||
|
||||
void UpdateDC() override {};
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override {};
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override {};
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override {};
|
||||
|
||||
void SwapClips(CSvgClip& oFirstClip, CSvgClip& oSecondClip);
|
||||
|
||||
@ -237,7 +237,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override {};
|
||||
|
||||
void UpdateDC() override {};
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override {};
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override {};
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override {};
|
||||
};
|
||||
}
|
||||
|
||||
@ -1264,7 +1264,11 @@ namespace MetaFile
|
||||
|
||||
if (NULL != m_pPath)
|
||||
{
|
||||
m_pDC->GetClip()->SetPath(*m_pPath, unRegionMode, m_pDC->GetFinalTransform(GM_ADVANCED));
|
||||
TEmfXForm oTransform{m_pDC->GetFinalTransform(GM_ADVANCED)};
|
||||
oTransform.Dx -= GetDCBounds().Left;
|
||||
oTransform.Dy -= GetDCBounds().Top;
|
||||
|
||||
m_pDC->GetClip()->SetPath(*m_pPath, unRegionMode, oTransform);
|
||||
RELEASEOBJECT(m_pPath);
|
||||
UpdateOutputDC();
|
||||
}
|
||||
|
||||
@ -3284,6 +3284,10 @@ namespace MetaFile
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETCLIPRECT(unsigned short unShFlags)
|
||||
{
|
||||
short shCM = ExpressValue(unShFlags, 8, 11);
|
||||
|
||||
if (0 == shCM)
|
||||
shCM = RGN_COPY;
|
||||
|
||||
TEmfPlusRectF oRect;
|
||||
|
||||
m_oStream >> oRect;
|
||||
|
||||
@ -68,6 +68,10 @@ namespace MetaFile
|
||||
#ifdef METAFILE_SUPPORT_SVM
|
||||
m_oSvmFile.SetFontManager(m_pFontManager);
|
||||
#endif
|
||||
|
||||
#ifdef METAFILE_SUPPORT_SVG
|
||||
m_oSvgFile.SetFontManager(m_pFontManager);
|
||||
#endif
|
||||
m_lType = 0;
|
||||
}
|
||||
|
||||
@ -84,7 +88,6 @@ namespace MetaFile
|
||||
|
||||
std::wstring CMetaFile::ConvertToSvg(unsigned int unWidth, unsigned int unHeight)
|
||||
{
|
||||
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
if (c_lMetaWmf == m_lType)
|
||||
{
|
||||
|
||||
@ -627,15 +627,13 @@ namespace MetaFile
|
||||
|
||||
void CInterpretatorSvgBase::PathClip(const CPath &oPath, int nClipMode, TXForm *pTransform)
|
||||
{
|
||||
std::wstring wsPath = CreatePath(oPath, pTransform);
|
||||
const std::wstring wsPath = CreatePath(oPath, pTransform);
|
||||
|
||||
if (wsPath.empty())
|
||||
return;
|
||||
|
||||
const std::wstring wsClipId = L"PATHCLIP_" + ConvertToWString(++m_unNumberDefs, 0);
|
||||
const std::wstring wsValue = L"<path d=\"" + wsPath + L"\"/>";
|
||||
|
||||
m_oClip.AddClipValue(wsClipId, wsValue, nClipMode);
|
||||
m_oClip.AddClipValue(L"PATHCLIP_" + ConvertToWString(++m_unNumberDefs, 0),
|
||||
L"<path d=\"" + wsPath + L"\"/>", nClipMode);
|
||||
}
|
||||
|
||||
void CInterpretatorSvgBase::AddStroke(NodeAttributes &arAttributes) const
|
||||
|
||||
@ -131,7 +131,7 @@ namespace MetaFile
|
||||
m_pMetaFileRenderer->UpdateDC();
|
||||
}
|
||||
|
||||
void CWmfInterpretatorRender::SetTransform(double &dM11, double &dM12, double &dM21, double &dM22, double &dX, double &dY)
|
||||
void CWmfInterpretatorRender::SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY)
|
||||
{
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->SetTransform(dM11, dM12, dM21, dM22, dX, dY);
|
||||
|
||||
@ -40,7 +40,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override;
|
||||
|
||||
void UpdateDC() override;
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override;
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override;
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override;
|
||||
|
||||
CMetaFileRenderer* GetRenderer() const;
|
||||
|
||||
@ -130,7 +130,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override {};
|
||||
|
||||
void UpdateDC() override {};
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override {};
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override {};
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override {};
|
||||
};
|
||||
|
||||
|
||||
@ -1740,8 +1740,8 @@ namespace MetaFile
|
||||
const TRectL& oEmfRect{oEmfParser.GetDCBounds()};
|
||||
const TRectL& oCurentRect{GetDCBounds()};
|
||||
|
||||
const double dScaleX = std::abs((oCurentRect.Right - oCurentRect.Left) / (oEmfRect.Right - oEmfRect.Left));
|
||||
const double dScaleY = std::abs((oCurentRect.Bottom - oCurentRect.Top) / (oEmfRect.Bottom - oEmfRect.Top));
|
||||
const double dScaleX = std::abs((double)(oCurentRect.Right - oCurentRect.Left) / (double)(oEmfRect.Right - oEmfRect.Left));
|
||||
const double dScaleY = std::abs((double)(oCurentRect.Bottom - oCurentRect.Top) / (double)(oEmfRect.Bottom - oEmfRect.Top));
|
||||
|
||||
const bool bAddGElement = !Equals(1., dScaleX) || !Equals(1., dScaleY);
|
||||
|
||||
|
||||
@ -68,7 +68,13 @@ bool CSvgFile::MarkObject(SVG::CObject *pObject)
|
||||
if (NULL == pObject || pObject->GetId().empty())
|
||||
return false;
|
||||
|
||||
pObject->AddRef();
|
||||
pObject->Mark();
|
||||
|
||||
const MarkedMap::const_iterator itFound = m_mMarkedObjects.find(pObject->GetId());
|
||||
|
||||
if (m_mMarkedObjects.cend() != itFound)
|
||||
RELEASEINTERFACE(m_mMarkedObjects[pObject->GetId()])
|
||||
|
||||
m_mMarkedObjects[pObject->GetId()] = pObject;
|
||||
|
||||
return true;
|
||||
@ -153,8 +159,7 @@ bool CSvgFile::Draw(IRenderer *pRenderer, double dX, double dY, double dWidth, d
|
||||
dTranslateY -= oViewBox.m_oY.ToDouble(NSCSS::Pixel) * dScaleY * dM22;
|
||||
}
|
||||
|
||||
const double dMinScale = std::min(dScaleX, dScaleY);
|
||||
pRenderer->SetTransform(dM11 * dMinScale, 0, 0, dM22 * dMinScale, dTranslateX, dTranslateY);
|
||||
pRenderer->SetTransform(dM11 * dScaleX, 0, 0, dM22 * dScaleY, dTranslateX, dTranslateY);
|
||||
|
||||
bool bResult = m_pContainer->Draw(pRenderer, this);
|
||||
|
||||
@ -165,7 +170,7 @@ bool CSvgFile::Draw(IRenderer *pRenderer, double dX, double dY, double dWidth, d
|
||||
|
||||
void CSvgFile::Clear()
|
||||
{
|
||||
RELEASEOBJECT(m_pContainer);
|
||||
RELEASEINTERFACE(m_pContainer);
|
||||
m_oSvgCalculator.Clear();
|
||||
|
||||
for (MarkedMap::reference oIter : m_mMarkedObjects)
|
||||
|
||||
@ -117,7 +117,7 @@ namespace SVG
|
||||
ScanStyles(oReader, pFile);
|
||||
oReader.MoveToStart();
|
||||
|
||||
RELEASEOBJECT(pContainer);
|
||||
RELEASEINTERFACE(pContainer);
|
||||
|
||||
pContainer = CObject::Create<CGraphicsContainer>(oReader, pFile);
|
||||
|
||||
@ -224,7 +224,7 @@ namespace SVG
|
||||
pObject = CObject::Create<CGraphicsContainer>(oReader, pFile, pParent);
|
||||
if (!ReadChildrens(oReader, (CGraphicsContainer*)pObject, pFile, (CGraphicsContainer*)pObject))
|
||||
{
|
||||
RELEASEOBJECT(pObject);
|
||||
RELEASEINTERFACE(pObject);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -290,21 +290,21 @@ namespace SVG
|
||||
if (ReadChildrens(oReader, (CSymbol*)pObject, pFile))
|
||||
return true;
|
||||
else
|
||||
RELEASEOBJECT(pObject);
|
||||
RELEASEINTERFACE(pObject);
|
||||
}
|
||||
else if ("font" == sElementName)
|
||||
{
|
||||
pObject = CObject::Create<CFont>(oReader, pFile);
|
||||
pObject = CObject::Create<CFont>(oReader, pFile, pFile);
|
||||
}
|
||||
|
||||
if (NULL == pObject)
|
||||
return false;
|
||||
|
||||
if ((RendererObject == pObject->GetType() && AddObject((ObjectType*)pObject, pContainer)) ||
|
||||
if ((RendererObject == pObject->GetType() && (AddObject((ObjectType*)pObject, pContainer) || pObject->Marked())) ||
|
||||
AppliedObject == pObject->GetType())
|
||||
return true;
|
||||
|
||||
RELEASEOBJECT(pObject);
|
||||
RELEASEINTERFACE(pObject);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -2,22 +2,23 @@
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CGlyph::CGlyph(CSvgReader& oReader)
|
||||
CGlyph::CGlyph(CSvgReader& oReader, CSvgFile* pFile)
|
||||
: CPath(oReader)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("unicode" == sAttributeName)
|
||||
{
|
||||
const std::wstring wsUnicode{oReader.GetText()};
|
||||
{}
|
||||
|
||||
if (!wsUnicode.empty())
|
||||
m_wchUnicode = wsUnicode[0];
|
||||
}
|
||||
else if ("horiz-adv-x" == sAttributeName)
|
||||
m_oHorizAdvX.SetValue(oReader.GetText());
|
||||
void CGlyph::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
{
|
||||
if ("unicode" == sName)
|
||||
{
|
||||
const std::wstring wsUnicode{oReader.GetText()};
|
||||
|
||||
if (!wsUnicode.empty())
|
||||
m_wchUnicode = wsUnicode[0];
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
else if ("horiz-adv-x" == sName)
|
||||
m_oHorizAdvX.SetValue(oReader.GetText());
|
||||
else
|
||||
CPath::SetAttribute(sName, oReader);
|
||||
}
|
||||
|
||||
wchar_t CGlyph::GetUnicode() const
|
||||
@ -28,10 +29,10 @@ namespace SVG
|
||||
CFontFace::CFontFace(CSvgReader& oReader)
|
||||
{}
|
||||
|
||||
CFont::CFont(CSvgReader& oReader)
|
||||
CFont::CFont(CSvgReader& oReader, CSvgFile* pFile)
|
||||
: CAppliedObject(oReader), m_pMissingGlyph(NULL)
|
||||
{
|
||||
ParseGlyphs(oReader);
|
||||
ParseGlyphs(oReader, pFile);
|
||||
}
|
||||
|
||||
CFont::~CFont()
|
||||
@ -95,7 +96,7 @@ namespace SVG
|
||||
{ \
|
||||
oMatrix.Scale(1. / dGlyphScale, -1. / dGlyphScale); \
|
||||
pRenderer->SetTransform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty()); \
|
||||
} \
|
||||
}
|
||||
|
||||
for (wchar_t wchGlyph : wsText)
|
||||
{
|
||||
@ -128,13 +129,13 @@ namespace SVG
|
||||
return true;
|
||||
}
|
||||
|
||||
void CFont::ParseGlyphs(CSvgReader& oReader)
|
||||
void CFont::ParseGlyphs(CSvgReader& oReader, CSvgFile* pFile)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if ("glyph" == sNodeName)
|
||||
{
|
||||
CGlyph *pGlyph = new CGlyph(oReader);
|
||||
CGlyph *pGlyph = CObject::Create<CGlyph>(oReader, pFile, pFile);
|
||||
|
||||
if (NULL == pGlyph)
|
||||
continue;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user