mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
850 Commits
v8.2.1.20
...
feature/gr
| Author | SHA1 | Date | |
|---|---|---|---|
| 1fc7ebed19 | |||
| dbf89fcaa3 | |||
| 44c26bc020 | |||
| a3a1c5fc3e | |||
| e3968cec5b | |||
| 20ba78cd7c | |||
| 7043515089 | |||
| 68f070d073 | |||
| b2c6667823 | |||
| 0e563c8461 | |||
| ee47ced36b | |||
| efe6f4408b | |||
| b918f81c2b | |||
| 204bc33610 | |||
| db9fb871a1 | |||
| ccad697cd8 | |||
| dd60367d01 | |||
| 54bbbbc3d7 | |||
| 9b901f7834 | |||
| 4f59af17b8 | |||
| b9258429f6 | |||
| e8f2c55ad4 | |||
| 46f6ba4d0a | |||
| 09b55bd1f1 | |||
| 176053e8d8 | |||
| 01365f938c | |||
| d168e4594f | |||
| cad36a73be | |||
| 27d2e40da7 | |||
| 14b09ce582 | |||
| aeeab690b1 | |||
| 016a0a971b | |||
| afe55a456f | |||
| a430ba92ad | |||
| efc1149235 | |||
| 567cc14bc7 | |||
| 0fc7f2a8b3 | |||
| b14fa1c2a1 | |||
| 2c27cfc720 | |||
| 1d31e5836b | |||
| 6adf65d3a8 | |||
| 093e1348fa | |||
| b78157487a | |||
| 77b30109f0 | |||
| efd047be74 | |||
| 61abfdb272 | |||
| f5088f43d8 | |||
| 6b3c395220 | |||
| 67cb29652d | |||
| d0cb082b33 | |||
| 2eff67efc3 | |||
| 84416ef5b6 | |||
| 447ade207f | |||
| ddd7628bbe | |||
| 1f86b0265a | |||
| e484db496b | |||
| 5bc1c8d860 | |||
| dbdf4bd120 | |||
| a93db0e012 | |||
| f145378002 | |||
| 4e800f6952 | |||
| 8098fec345 | |||
| 7bfcea0fff | |||
| 4b4845c558 | |||
| b26e3e2fee | |||
| 388951670c | |||
| 7d3488abc9 | |||
| fea3910254 | |||
| 2d58b08f0f | |||
| 612142f0ae | |||
| 2a0c84513b | |||
| b7d3464609 | |||
| beb8574dfd | |||
| c22cc89ef0 | |||
| 58255093bf | |||
| 50846677d5 | |||
| 3b450306f1 | |||
| c67ec5f632 | |||
| 62450ee1fb | |||
| ad301b6f50 | |||
| d251682639 | |||
| 896427db83 | |||
| e03f02103b | |||
| 27c7920def | |||
| a1b0421ec1 | |||
| b7972ea391 | |||
| 17840c5ed7 | |||
| ff4726e6ec | |||
| 4e9cd74367 | |||
| b8737d2474 | |||
| 2f4b7442c7 | |||
| d97d2668d2 | |||
| 45da53e9ae | |||
| 618a7ea09e | |||
| a33743cff2 | |||
| a83e19cbdf | |||
| 8a991ae24a | |||
| 6caca87b64 | |||
| 9ab884ae24 | |||
| e493d976e3 | |||
| d75e7342cf | |||
| ddd750be9c | |||
| 79a4434583 | |||
| 44ff2aff3c | |||
| 2f4b3e41b3 | |||
| fe208f5243 | |||
| e41c1d9703 | |||
| 1cb56e532c | |||
| 5c5f98a6e3 | |||
| f9dd82ad47 | |||
| 084c8f4b94 | |||
| bf15325a9e | |||
| 1b50b3a53a | |||
| 70b40c46d2 | |||
| 23798f3c96 | |||
| d91c6ff830 | |||
| b75a577793 | |||
| 1e8d22080d | |||
| 90bcd47fb7 | |||
| c1adf0b30c | |||
| b65ed1ccb4 | |||
| 8e4bbb5e27 | |||
| 81a4d9ccd0 | |||
| a97014c173 | |||
| b3951d083a | |||
| 7d78b37540 | |||
| ff162d451e | |||
| 5dc6402006 | |||
| fae17d9bfc | |||
| 931f4edae4 | |||
| 3609cf1237 | |||
| cc8fa641aa | |||
| 3b9a865d77 | |||
| f3b0a992bd | |||
| 74f3e7f279 | |||
| d195aa4a79 | |||
| 4a384edf08 | |||
| 30f96cbc6c | |||
| 007362d8be | |||
| f4aac048ea | |||
| f815fec8ed | |||
| 4ec217226d | |||
| 3cef41e876 | |||
| 20bff1d6fe | |||
| 8da1a109de | |||
| 704cef604e | |||
| 3c850e2086 | |||
| ab660cb8a3 | |||
| af4343b1d8 | |||
| 7e4fe558f4 | |||
| f942e56361 | |||
| 8b85f6987f | |||
| cbe412d3c7 | |||
| 6913cae8f3 | |||
| d3d9c8df94 | |||
| 01b582c4b9 | |||
| 4568144a22 | |||
| cc4df3726a | |||
| 696610862a | |||
| da6a5e9e98 | |||
| d395e63b80 | |||
| 0350675df6 | |||
| aead2e9fb8 | |||
| d12bad7bd1 | |||
| da2284fff6 | |||
| 1382aa0b3d | |||
| 8ba5df60d9 | |||
| 5299872b17 | |||
| e1757dd5d1 | |||
| 87dcea55b1 | |||
| b5c5a5f1ed | |||
| 6979e17c3d | |||
| c43fb92860 | |||
| c2dc112949 | |||
| 63887c95b6 | |||
| d3d4e86925 | |||
| f6383571eb | |||
| a6f6a67aed | |||
| f9543ef9de | |||
| bb58be4f18 | |||
| 40efe7dabc | |||
| 80b7caaf7a | |||
| 08e3dfb061 | |||
| 3a9d91b291 | |||
| 45b26554b2 | |||
| 09c4df8e05 | |||
| 85533a6553 | |||
| 65898a94ad | |||
| 86009ff6fa | |||
| b91dfb075e | |||
| f057a16bc1 | |||
| bd76adc97f | |||
| 27b5dbf15e | |||
| 58a7c7cd9d | |||
| 18fa4639b0 | |||
| 389e5314df | |||
| 42636a8ab1 | |||
| a3c87e7119 | |||
| 2115371c0c | |||
| bd95478d77 | |||
| 965680de23 | |||
| ad44ddf682 | |||
| 06386d5458 | |||
| ffda83848d | |||
| 55dc0b789f | |||
| 53e3f8c561 | |||
| 731a7addee | |||
| 36b82c1ef9 | |||
| 229a8f9dad | |||
| 5f5d74df92 | |||
| 66ea88bf14 | |||
| 3953044063 | |||
| 9a4a1546cb | |||
| 4085ee5002 | |||
| f6ef582658 | |||
| 7b62295149 | |||
| 421dcd780d | |||
| b9e7a3143c | |||
| c85713d82a | |||
| 6d970d0706 | |||
| 6026841c00 | |||
| 1e6d0a9f25 | |||
| adad3a05ba | |||
| 99fa27e693 | |||
| cf047defac | |||
| 6b66c8fb50 | |||
| 9faa7fb69d | |||
| 84042360ab | |||
| 8a8a6e78eb | |||
| 8bd655dd17 | |||
| 34ecf84835 | |||
| 4cf79c985d | |||
| 18e359c1a6 | |||
| dc777f43d9 | |||
| 8cd7ca9731 | |||
| 8f91c47178 | |||
| fdac954df5 | |||
| 70c98eb9f3 | |||
| aa72db079f | |||
| 024efd2e35 | |||
| da252bfa5e | |||
| c9ce68eab3 | |||
| 3af549a158 | |||
| 34627ff1c5 | |||
| 483ead4243 | |||
| 0c2b49af11 | |||
| 4324ea847c | |||
| df76ff3778 | |||
| 172bb09305 | |||
| aa0ba83d32 | |||
| fb934ef527 | |||
| a2b817bbc2 | |||
| ecd80408e2 | |||
| b78e2cb33c | |||
| ddd92777b4 | |||
| f0c52d2e81 | |||
| 23ac269339 | |||
| 07ab24638e | |||
| 8239d6f51d | |||
| 3adf336384 | |||
| 8e1810697f | |||
| 7c2105b613 | |||
| 2027defafb | |||
| ffe44155e2 | |||
| 2ea586ec6f | |||
| 7c2093a4c7 | |||
| 4f6fa2a15c | |||
| a6940c42ac | |||
| 6ed1cb60d6 | |||
| 2c9e58280b | |||
| f18b50cd4f | |||
| aa2af5d280 | |||
| dde69ba65f | |||
| f51b58c927 | |||
| 43f1ac0596 | |||
| 321e0de9f3 | |||
| ca77113e79 | |||
| 9c70225a9e | |||
| 2098c72a35 | |||
| 06e34fc303 | |||
| 7b56d56c0e | |||
| aa90104b18 | |||
| 98b285ab64 | |||
| cbd7e8ee7b | |||
| b76235d4fc | |||
| b9e1d77038 | |||
| 8f448d3842 | |||
| 89d7242d21 | |||
| 9aaa241523 | |||
| 02bd5c4b0b | |||
| 4003a39ef9 | |||
| a5fed4af70 | |||
| a9d8cbbc57 | |||
| 6c79ab37fa | |||
| 17762b71db | |||
| be2f142fd3 | |||
| fdcb2cf7ba | |||
| b42e3ad01f | |||
| 07bf7a44aa | |||
| 3a40dc1f8b | |||
| a2bfbd8368 | |||
| 25553904df | |||
| 954ef08975 | |||
| aea8b7873c | |||
| 6952bedbc3 | |||
| a7774a6bc3 | |||
| bf299e82bb | |||
| 915790e26e | |||
| e18a26a252 | |||
| 4d15b5c19d | |||
| 73ccefd720 | |||
| 11385b946d | |||
| e230fa1d43 | |||
| 3d30144ebb | |||
| 3365ca15d6 | |||
| c0debdfe39 | |||
| f7d55d48fe | |||
| f2510a9410 | |||
| f2a8a9878b | |||
| 39adc06921 | |||
| 64af642c40 | |||
| ef26ac732e | |||
| 8bbaaf4cef | |||
| de821b73c8 | |||
| a7d5fe3994 | |||
| 7deeefbcf4 | |||
| 3666bdf6fc | |||
| eaa7bb30db | |||
| d4619c5786 | |||
| 0f3852ab1e | |||
| fb5b1c5a6e | |||
| 7598e882b8 | |||
| cef8ac9fd9 | |||
| 45aa5df267 | |||
| e8c94aa103 | |||
| aa5b7e1276 | |||
| dd98d0c11d | |||
| 08971025bd | |||
| 00f6a823d6 | |||
| b4f4da26d6 | |||
| 1c9f7ac597 | |||
| 673139f5a9 | |||
| 4bf0cee034 | |||
| 00abbab370 | |||
| 3125a7a928 | |||
| f20c944c72 | |||
| 6d7dc6517b | |||
| 6fd84c6c8c | |||
| d37f31208c | |||
| c472b19e0d | |||
| 7b03bcde89 | |||
| 51cc45d178 | |||
| 03a7eb0fd4 | |||
| c0a779727e | |||
| 52d3f0bc19 | |||
| c17497e304 | |||
| 6bc4ecbc73 | |||
| 2246077589 | |||
| 91eb74773b | |||
| 5b8d2660aa | |||
| 60ad1c10fd | |||
| 36b0cc524e | |||
| bb33e70b3e | |||
| 9dc3d3ed82 | |||
| 5f2d7b2f5a | |||
| 02aeaa6a64 | |||
| 7696541430 | |||
| 6fe92e1725 | |||
| e512ceedec | |||
| d05a40389e | |||
| ea0494e8c2 | |||
| 614156f575 | |||
| 127680c988 | |||
| cdbd9bdba3 | |||
| 397abd51a5 | |||
| d311090ced | |||
| 1910151224 | |||
| 4a110d68c1 | |||
| cd27981734 | |||
| 505a3c6224 | |||
| 75a21ee162 | |||
| 9509d5e730 | |||
| 440cf968d5 | |||
| 3daa374a51 | |||
| 5d83d912fc | |||
| 695fd3ba1c | |||
| 75f68904f2 | |||
| b99badda9f | |||
| 219733c437 | |||
| 48d86cb7ce | |||
| 9991cc8c03 | |||
| 36a3b693d5 | |||
| dbd6be9520 | |||
| 42ef948fcc | |||
| 69f4ac3ed7 | |||
| 328e379ec2 | |||
| ad4fee9581 | |||
| 2af29de849 | |||
| 7d65d4b11a | |||
| 57ba4355f9 | |||
| 2eea44bc8c | |||
| cb982a1ad4 | |||
| 0aca0a0a5a | |||
| 0c1df859e2 | |||
| 7a153285c8 | |||
| c2d00ee819 | |||
| 3603787df8 | |||
| d58424d089 | |||
| fe2ca8c566 | |||
| 20d2ff7954 | |||
| b125c19d02 | |||
| 2f2d11a5f6 | |||
| de4897fdef | |||
| f9952d0f94 | |||
| 5483a8d36b | |||
| 80ac89f16b | |||
| fcf9830aa6 | |||
| 0c847ce1d8 | |||
| f1905b524b | |||
| d7b435a446 | |||
| f742a0ef10 | |||
| 887d963d8d | |||
| 3547ad9c57 | |||
| 0d2248352b | |||
| bc4c39b7aa | |||
| 012a724069 | |||
| 8d89026d19 | |||
| 4e6e3ce5f0 | |||
| 3d7eced836 | |||
| 2e50a2ede4 | |||
| 78d7d40c0a | |||
| 7130b1be34 | |||
| a5917c389f | |||
| eee80b0f87 | |||
| dac47c3214 | |||
| be3a84dcf7 | |||
| 35dff37820 | |||
| 22a2079c5f | |||
| 2f45a87669 | |||
| fe2bac216f | |||
| 185b3d54eb | |||
| f7f059b6c0 | |||
| 2a9044d066 | |||
| d89e94bb8e | |||
| a95aba3ff4 | |||
| a93f00d0af | |||
| 9a1abe9819 | |||
| f8f9d55ab8 | |||
| a1ebcaea23 | |||
| ab10854dde | |||
| 99b777a5eb | |||
| d1506ec9fa | |||
| 9fc74159ff | |||
| ec14915925 | |||
| f9f4efc383 | |||
| 12ad4e604b | |||
| e0ad062380 | |||
| b72f678c1d | |||
| 7b67dfa57c | |||
| 5153ac069b | |||
| a08b614bce | |||
| 59f41bcdec | |||
| e8aa709d4e | |||
| c4515aca3a | |||
| 3f25120e04 | |||
| 3fde7b3f92 | |||
| b776b7b63f | |||
| d69601c2d2 | |||
| 44d0a0ca23 | |||
| 912482beee | |||
| c0ca4189d3 | |||
| 134a214a0b | |||
| 95f604ec68 | |||
| ecd71dd92a | |||
| d8bd9ef845 | |||
| d3a317ed4b | |||
| 37141b6ba3 | |||
| bd3cabd236 | |||
| ec645c0202 | |||
| 63134aa586 | |||
| c2403aa0b7 | |||
| bdf70dd99e | |||
| 8489127f71 | |||
| 9f18cbce01 | |||
| 05a6f6afaf | |||
| e024463770 | |||
| 7e11af5553 | |||
| 3275182013 | |||
| ca2b6d78aa | |||
| 6a24fd149a | |||
| 168dc1ddb8 | |||
| 8918b7fae0 | |||
| 4501adbc61 | |||
| 0c1864a136 | |||
| 3e2373687c | |||
| 779af49e0d | |||
| cb2f1c5577 | |||
| 446a0f9524 | |||
| 1c839e6c62 | |||
| f7d7dc8c6b | |||
| 6d789e966a | |||
| d20d1af154 | |||
| 925ffa09e2 | |||
| dd0ed96e5a | |||
| 25b30981ce | |||
| ebfee2376f | |||
| fa33af2304 | |||
| 25fa85c218 | |||
| 6e20c656e7 | |||
| 6b9fc964b9 | |||
| 9242ab9743 | |||
| a158529c70 | |||
| 87b5ae8f75 | |||
| e14cc2d5c5 | |||
| 1c163421c7 | |||
| cd73a4d9e3 | |||
| 1b39b9f416 | |||
| 4e57fda1f6 | |||
| f3d65cb04c | |||
| 4ba288978d | |||
| c862d58966 | |||
| c6effb6de2 | |||
| 295dbbbb86 | |||
| 96b34ee008 | |||
| 265db0216b | |||
| 76f2d81655 | |||
| 10ff332f4d | |||
| d5e7ccac2d | |||
| f57179911f | |||
| 863144596c | |||
| a82a8977c3 | |||
| 0109c69e38 | |||
| 92ce5d81ad | |||
| 482da0dab3 | |||
| 32afe4f24e | |||
| 182dd9e072 | |||
| 2ba281a5ee | |||
| b3a30cf2ea | |||
| c321783b44 | |||
| 182cd8d74a | |||
| 98a1988d9a | |||
| acd9219b16 | |||
| 0cbcaa209c | |||
| a53e46be24 | |||
| ab8070aa56 | |||
| 6a930c5aa4 | |||
| 6c0715cc66 | |||
| 925f3614c7 | |||
| ce0f8251d3 | |||
| f019dfbb07 | |||
| fefcef7da4 | |||
| 361bc70fe3 | |||
| 09b4ab5092 | |||
| 6b21323e8c | |||
| e1fcf17b34 | |||
| c83a8a3a54 | |||
| 54f0635500 | |||
| bb48b57af9 | |||
| 8a000efb7f | |||
| 1c362612e3 | |||
| 78404c4ffe | |||
| 3a49869ce0 | |||
| a1a6e6c9a0 | |||
| 4199716550 | |||
| 6d68d7aee5 | |||
| cf346bd535 | |||
| 61e6b54710 | |||
| 536dac5fc9 | |||
| 65ba8ffd3b | |||
| c6467d67c5 | |||
| 5a9812887b | |||
| e637b47d68 | |||
| 0078a2e19b | |||
| d2713d0cfd | |||
| 4bf363f458 | |||
| c1b01029df | |||
| 4b299fedd7 | |||
| dc4074299c | |||
| 2d161f1341 | |||
| fea872d779 | |||
| 6c614051d9 | |||
| 2517316e2b | |||
| c83e50d164 | |||
| 66bc0223cb | |||
| 9ea09f95f8 | |||
| d66d95d4c6 | |||
| 024c288e12 | |||
| caac75fcc1 | |||
| eb88373ec5 | |||
| 4e86a9a08a | |||
| 099ebc3de9 | |||
| 4c3b9411b4 | |||
| 555b91e385 | |||
| 9713138f4f | |||
| 0934c2cda4 | |||
| bb204098a1 | |||
| c65e8d4a04 | |||
| a0cecd357f | |||
| 6a4f30d6fa | |||
| cfde4aa357 | |||
| 2a2f33fd6f | |||
| 8ad76e4e1f | |||
| b0b3d6b280 | |||
| 029e6c6df7 | |||
| e8257896d4 | |||
| 1e9a63083b | |||
| 2f525c1e4f | |||
| 40a1e15033 | |||
| 6c93c8b16c | |||
| 8813f8bb19 | |||
| e979defdee | |||
| cc585185dd | |||
| 9a5240cbba | |||
| 8e498c8299 | |||
| 706a2252fa | |||
| d423549ae4 | |||
| cef0adda0a | |||
| ab2ab7a407 | |||
| 62c401ae5b | |||
| d73d682cbc | |||
| c470363ec0 | |||
| 25be50f058 | |||
| 10931f937a | |||
| 647c8a3cde | |||
| 1d4f9b5c41 | |||
| 3de464a31e | |||
| 3429e8b345 | |||
| b3f5d84a51 | |||
| 23c2ecfe54 | |||
| 485dcb5272 | |||
| 1c9a9f53e3 | |||
| 62ad5bf127 | |||
| ecc1e974ae | |||
| ef61b90242 | |||
| 00bdf67b8a | |||
| ee83f6c826 | |||
| ec50e77695 | |||
| 72fbe98925 | |||
| 4ef62b88cb | |||
| 3e8d5926ba | |||
| 0284c8df70 | |||
| 3d4faa267e | |||
| edc0ae2b8d | |||
| ebaf0eb43a | |||
| eab40d6bb2 | |||
| e7d081aefb | |||
| cc2867e292 | |||
| 8e51f9bdbb | |||
| 92b0f4e654 | |||
| 46d4d76f26 | |||
| 53593c96af | |||
| 21f75547fb | |||
| ac8c99415f | |||
| 0daee49007 | |||
| 5a6a2f800f | |||
| 8e3df35232 | |||
| 521d7c1ee8 | |||
| f1e80adb9c | |||
| 3503eee5b6 | |||
| 1041802214 | |||
| cebc04b852 | |||
| dbfdffd0c5 | |||
| b8d2cba3ae | |||
| b56d62442d | |||
| 5d70f47ebc | |||
| 859351a8d1 | |||
| fbd408ec6d | |||
| c631b62e51 | |||
| 1286dbaaaf | |||
| 1dbeea42b8 | |||
| 0dc65baa25 | |||
| 50fec65617 | |||
| a5ea301e3e | |||
| fb40437d21 | |||
| cf66adea28 | |||
| 42466cf648 | |||
| 2b00698810 | |||
| b00fbeff53 | |||
| 819d1fad17 | |||
| 97f0958f09 | |||
| ce88c4ca95 | |||
| ac7614c4e6 | |||
| a69a992a0d | |||
| b4bb20bea7 | |||
| 949aed7bb4 | |||
| 2ce37e34c4 | |||
| 6ec4191483 | |||
| 3401c2b02e | |||
| 0dd0ad0023 | |||
| 8cf7809359 | |||
| 277dd4a464 | |||
| cb8466de27 | |||
| 1c2501eeb1 | |||
| 0d443743a8 | |||
| 8c7a22b726 | |||
| c8b8462d31 | |||
| a14b3eb8e2 | |||
| 6eaf590844 | |||
| fac279ba81 | |||
| 571a7ee2d1 | |||
| adb6d7bbc2 | |||
| f7fa638591 | |||
| edfa558a38 | |||
| b80ada4b4e | |||
| 492b821472 | |||
| d75a3a5587 | |||
| a8ce7eaad3 | |||
| 8cf78b9e58 | |||
| 28bcfafcc6 | |||
| e527db9515 | |||
| db2660a1a3 | |||
| 77b5ffb56d | |||
| ca70de93a4 | |||
| 04565bbdd4 | |||
| 4266857c6e | |||
| 8e6e510cd6 | |||
| 46588b05b1 | |||
| dc0ea6a7f3 | |||
| a84c8cc471 | |||
| 986d0f0d95 | |||
| cd1bb3b658 | |||
| 6caf517fe5 | |||
| d65d37476e | |||
| ffe85bd64f | |||
| d4c4b804c7 | |||
| 1de2807051 | |||
| b414fb961e | |||
| 0370948e98 | |||
| ccbd9da871 | |||
| cec8402adc | |||
| fd90f73c19 | |||
| 3003c66eba | |||
| cc4c0dd68e | |||
| 5692bee77a | |||
| e25a952279 | |||
| d6864e044a | |||
| 894f78d143 | |||
| eeac44a1ab | |||
| a8e3dd2ef5 | |||
| 20a2aa1ef1 | |||
| 7d10e1e995 | |||
| c3531cb19c | |||
| ba6de346dc | |||
| f2aa34b5ce | |||
| d43a724ee6 | |||
| cba68e2d2a | |||
| f8dd9fb085 | |||
| 39e95e8b49 | |||
| b98922dbfd | |||
| af77bf3f77 | |||
| 83a6e52df2 | |||
| b2e807ec33 | |||
| 1eba4aefa8 | |||
| 956508f994 | |||
| e27415bb84 | |||
| 2afbd3c429 | |||
| 8cadb329b9 | |||
| d21d0caa68 | |||
| af7cb378ac | |||
| 81e075e715 | |||
| f7607e1c92 | |||
| 1022d29fe8 | |||
| d8d540bd02 | |||
| 63bf1797c0 | |||
| 93900a0be8 | |||
| 9ba32e031d | |||
| d69e4ca0ba | |||
| ef2963242a | |||
| cbfc2d5052 | |||
| 1a979fe30a | |||
| ff2146b671 | |||
| d1d5a46896 | |||
| dcc4342483 | |||
| ef5e71e941 | |||
| 5c1b611b88 | |||
| c6e15b7526 | |||
| d9902ba6f9 | |||
| 633af32919 | |||
| 40d3cd1a85 | |||
| 32103b8b9f | |||
| 1244ba5fe5 | |||
| 66231b65c1 | |||
| 7aa2d36d85 | |||
| 982d2d1872 | |||
| 71b1e4fbf3 | |||
| 1a1ec927e2 | |||
| c421936857 | |||
| 3580e84184 | |||
| 1538997b63 | |||
| bdb902128d | |||
| bb41c8b85f | |||
| fbee170e87 | |||
| 115917b9e5 | |||
| c67b78508e | |||
| 3d38fdd005 | |||
| f8ba0c59a6 | |||
| 296dba3a4e | |||
| 38457c0115 | |||
| 40789fbd24 | |||
| 4adc16620b | |||
| 0bfe049e84 | |||
| a6d8deedcd | |||
| 26b69e8612 | |||
| 9fa00c8609 | |||
| 59bb3035bb | |||
| dbb757a954 | |||
| 55a2fb1b00 | |||
| e9c200e455 | |||
| 887898fe58 | |||
| 627d02b006 | |||
| c9fad9a83f | |||
| 9b05fa38ea | |||
| 7062a26561 | |||
| 311d35f332 | |||
| a7fb914f5e | |||
| c068fd2ee0 | |||
| cfbb7d1216 | |||
| abd2421cc1 | |||
| 592fbfccbb | |||
| cf51a10da9 | |||
| 5f2c00a017 | |||
| bb7b63c86e | |||
| 0553db3a69 | |||
| a7ef6ea3be | |||
| 00ccd7f7a0 | |||
| 3604ca9450 | |||
| 01428dc78a | |||
| d72b9b47ed | |||
| 8ae7e577f0 | |||
| d7922089ea | |||
| 3231593049 | |||
| 7e7186f068 | |||
| 2d61e8bbd2 | |||
| 41dcf2eac4 | |||
| c4c350f1aa | |||
| 2f382d21dc | |||
| a968a3a035 | |||
| deb875337d | |||
| 9f62108376 | |||
| 0eedb80d36 | |||
| 8daa8dd509 | |||
| 8b82e48562 | |||
| 2425a40d36 | |||
| 4384ca2274 | |||
| b3590d66f0 | |||
| 1b0791364b | |||
| d939aa7247 | |||
| 14a8a4d8bb | |||
| 7a9549633b | |||
| 8507c8d4d9 |
141
Apple/IWork.cpp
Normal file
141
Apple/IWork.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
#include "IWork.h"
|
||||
#include "../DesktopEditor/common/File.h"
|
||||
#include "../DesktopEditor/common/Directory.h"
|
||||
|
||||
#include <libetonyek/libetonyek.h>
|
||||
#include <libodfgen/OdtGenerator.hxx>
|
||||
#include <libodfgen/OdsGenerator.hxx>
|
||||
#include <libodfgen/OdpGenerator.hxx>
|
||||
#include <libodfgen/test/StringDocumentHandler.hxx>
|
||||
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
|
||||
class CIWorkFile_Private
|
||||
{
|
||||
public:
|
||||
std::wstring m_sTempDirectory;
|
||||
|
||||
public:
|
||||
CIWorkFile_Private()
|
||||
{
|
||||
}
|
||||
~CIWorkFile_Private()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
CIWorkFile::CIWorkFile()
|
||||
{
|
||||
m_internal = new CIWorkFile_Private();
|
||||
}
|
||||
|
||||
CIWorkFile::~CIWorkFile()
|
||||
{
|
||||
delete m_internal;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
#define DATA_TYPE_INPUTFILE std::string
|
||||
#else
|
||||
#define DATA_TYPE_INPUTFILE std::wstring
|
||||
#endif
|
||||
|
||||
bool GetRVNGInputStream(const DATA_TYPE_INPUTFILE& sFile, std::shared_ptr<librevenge::RVNGInputStream>& oRVNGInputStream, libetonyek::EtonyekDocument::Type& oDocumentType)
|
||||
{
|
||||
oRVNGInputStream.reset(new librevenge::RVNGFileStream(sFile.c_str()));
|
||||
|
||||
oDocumentType = libetonyek::EtonyekDocument::TYPE_UNKNOWN;
|
||||
const libetonyek::EtonyekDocument::Confidence confidence = libetonyek::EtonyekDocument::isSupported(oRVNGInputStream.get(), &oDocumentType);
|
||||
|
||||
return libetonyek::EtonyekDocument::CONFIDENCE_NONE != confidence;
|
||||
}
|
||||
|
||||
IWorkFileType CIWorkFile::GetType(const std::wstring& sFile) const
|
||||
{
|
||||
//TODO:: так как на данный момент мы работает только напрямую с файлом, то работа с директорией нам пока не нужна
|
||||
if (NSDirectory::PathIsDirectory(sFile))
|
||||
return IWorkFileType::None;
|
||||
|
||||
std::shared_ptr<librevenge::RVNGInputStream> input;
|
||||
libetonyek::EtonyekDocument::Type oDocumentType;
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
std::string sFileA = U_TO_UTF8(sFile);
|
||||
if (!GetRVNGInputStream(sFileA, input, oDocumentType))
|
||||
return IWorkFileType::None;
|
||||
#else
|
||||
if (!GetRVNGInputStream(sFile, input, oDocumentType))
|
||||
return IWorkFileType::None;
|
||||
#endif
|
||||
|
||||
switch (oDocumentType)
|
||||
{
|
||||
case libetonyek::EtonyekDocument::TYPE_PAGES:
|
||||
return IWorkFileType::Pages;
|
||||
case libetonyek::EtonyekDocument::TYPE_NUMBERS:
|
||||
return IWorkFileType::Numbers;
|
||||
case libetonyek::EtonyekDocument::TYPE_KEYNOTE:
|
||||
return IWorkFileType::Keynote;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return IWorkFileType::None;
|
||||
}
|
||||
|
||||
template<class Generator>
|
||||
int Convert(const std::wstring& wsOutputFile, std::shared_ptr<librevenge::RVNGInputStream>& ptrInput, const std::wstring& wsPassword = L"", const std::wstring& wsTempDirectory = L"")
|
||||
{
|
||||
StringDocumentHandler content;
|
||||
Generator generator;
|
||||
generator.addDocumentHandler(&content, ODF_FLAT_XML);
|
||||
|
||||
bool bRes = libetonyek::EtonyekDocument::parse(ptrInput.get(), &generator);
|
||||
if (!bRes)
|
||||
return 1;
|
||||
|
||||
const std::string sOutputFileA = U_TO_UTF8(wsOutputFile);
|
||||
std::ofstream output(sOutputFileA.c_str());
|
||||
output << content.cstr();
|
||||
|
||||
if (output.bad())
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CIWorkFile::Convert2Odf(const std::wstring& sFile, const std::wstring& sOutputFile) const
|
||||
{
|
||||
//TODO:: так как на данный момент мы работает только напрямую с файлом, то работа с директорией нам пока не нужна
|
||||
if (NSDirectory::PathIsDirectory(sFile))
|
||||
return -1;
|
||||
|
||||
std::shared_ptr<librevenge::RVNGInputStream> input;
|
||||
libetonyek::EtonyekDocument::Type oDocumentType;
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
std::string sFileA = U_TO_UTF8(sFile);
|
||||
if (!GetRVNGInputStream(sFileA, input, oDocumentType))
|
||||
return -1;
|
||||
#else
|
||||
if (!GetRVNGInputStream(sFile, input, oDocumentType))
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
switch (oDocumentType)
|
||||
{
|
||||
case libetonyek::EtonyekDocument::TYPE_PAGES: return Convert<OdtGenerator>(sOutputFile, input);
|
||||
case libetonyek::EtonyekDocument::TYPE_NUMBERS: return Convert<OdsGenerator>(sOutputFile, input);
|
||||
case libetonyek::EtonyekDocument::TYPE_KEYNOTE: return Convert<OdpGenerator>(sOutputFile, input);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CIWorkFile::SetTmpDirectory(const std::wstring& sFolder)
|
||||
{
|
||||
m_internal->m_sTempDirectory = sFolder;
|
||||
}
|
||||
36
Apple/IWork.h
Normal file
36
Apple/IWork.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef _IWORKFILE_IWORKFILE_H
|
||||
#define _IWORKFILE_IWORKFILE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef IWORK_USE_DYNAMIC_LIBRARY
|
||||
#define IWORK_FILE_DECL_EXPORT
|
||||
#else
|
||||
#include "../DesktopEditor/common/base_export.h"
|
||||
#define IWORK_FILE_DECL_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
enum class IWorkFileType
|
||||
{
|
||||
Pages = 0,
|
||||
Numbers = 1,
|
||||
Keynote = 2,
|
||||
|
||||
None = 255
|
||||
};
|
||||
|
||||
class CIWorkFile_Private;
|
||||
class IWORK_FILE_DECL_EXPORT CIWorkFile
|
||||
{
|
||||
private:
|
||||
CIWorkFile_Private* m_internal;
|
||||
public:
|
||||
CIWorkFile();
|
||||
~CIWorkFile();
|
||||
|
||||
IWorkFileType GetType(const std::wstring& sFile) const;
|
||||
int Convert2Odf(const std::wstring& sFile, const std::wstring& sOutputFile) const;
|
||||
void SetTmpDirectory(const std::wstring& sFolder);
|
||||
};
|
||||
|
||||
#endif // _IWORKFILE_IWORKFILE_H
|
||||
46
Apple/IWork.pro
Normal file
46
Apple/IWork.pro
Normal file
@ -0,0 +1,46 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
VERSION = 0.0.0.1
|
||||
TARGET = IWorkFile
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
DEFINES += IWORK_USE_DYNAMIC_LIBRARY
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel, UnicodeConverter)
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PWD
|
||||
|
||||
core_android:DEFINES += NOT_USE_PTHREAD_CANCEL USE_FILE32API
|
||||
|
||||
# BOOST
|
||||
CONFIG += core_boost_regex
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri)
|
||||
|
||||
# ZLIB
|
||||
CONFIG += build_all_zlib build_zlib_as_sources
|
||||
include($$PWD/../OfficeUtils/OfficeUtils.pri)
|
||||
|
||||
# LIBXML
|
||||
CONFIG += core_static_link_xml_full
|
||||
CONFIG += core_only_libxml
|
||||
include($$PWD/../DesktopEditor/xml/build/qt/libxml2.pri)
|
||||
|
||||
#
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/apple/apple.pri)
|
||||
|
||||
# TEST
|
||||
HEADERS += $$ODF_LIB_ROOT/test/StringDocumentHandler.h
|
||||
SOURCES += $$ODF_LIB_ROOT/test/StringDocumentHandler.cxx
|
||||
|
||||
SOURCES += IWork.cpp
|
||||
|
||||
HEADERS += IWork.h
|
||||
0
Apple/test/examples/DO NOT REMOVE
Normal file
0
Apple/test/examples/DO NOT REMOVE
Normal file
45
Apple/test/main.cpp
Normal file
45
Apple/test/main.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../IWork.h"
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
CIWorkFile oFile;
|
||||
|
||||
std::wstring sExamplesDir = NSFile::GetProcessDirectory() + L"/../examples";
|
||||
oFile.Convert2Odf(sExamplesDir + L"/new.pages", sExamplesDir + L"/out_new.odt");
|
||||
oFile.Convert2Odf(sExamplesDir + L"/old.pages", sExamplesDir + L"/out_old.odt");
|
||||
|
||||
return 0;
|
||||
}
|
||||
20
Apple/test/test.pro
Normal file
20
Apple/test/test.pro
Normal file
@ -0,0 +1,20 @@
|
||||
CONFIG -= qt
|
||||
QT -= core gui
|
||||
|
||||
TARGET = test
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
TEMPLATE = app
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel, IWorkFile)
|
||||
|
||||
core_linux:include($$PWD/../../Common/3dParty/icu/icu.pri)
|
||||
core_windows:LIBS += -lgdi32 -ladvapi32 -luser32 -lshell32
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
DESTDIR = $$PWD/build
|
||||
8
Common/3dParty/apple/.gitignore
vendored
Normal file
8
Common/3dParty/apple/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Ignore everything in this directory
|
||||
glm
|
||||
mdds
|
||||
librevenge
|
||||
libodfgen
|
||||
libetonyek
|
||||
# Except this file
|
||||
!.gitignore
|
||||
36
Common/3dParty/apple/apple.pri
Normal file
36
Common/3dParty/apple/apple.pri
Normal file
@ -0,0 +1,36 @@
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
# LIBREVENGE
|
||||
REVENGE_LIB_ROOT = $$PWD/librevenge
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$REVENGE_LIB_ROOT/inc
|
||||
|
||||
HEADERS += $$files($$REVENGE_LIB_ROOT/inc/*.h, true)
|
||||
HEADERS += $$files($$REVENGE_LIB_ROOT/src/lib/*.h, true)
|
||||
SOURCES += $$files($$REVENGE_LIB_ROOT/src/lib/*.cpp, true)
|
||||
|
||||
# LIBODFGEN
|
||||
ODF_LIB_ROOT = $$PWD/libodfgen
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$ODF_LIB_ROOT/inc
|
||||
|
||||
HEADERS += $$files($$ODF_LIB_ROOT/inc/libodfgen/*.hxx, true)
|
||||
HEADERS += $$files($$ODF_LIB_ROOT/src/*.hxx, true)
|
||||
SOURCES += $$files($$ODF_LIB_ROOT/src/*.cxx, true)
|
||||
|
||||
# LIBETONYEK
|
||||
ETONYEK_LIB_ROOT = $$PWD/libetonyek
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$ETONYEK_LIB_ROOT/inc \
|
||||
$$ETONYEK_LIB_ROOT/src/lib \
|
||||
$$ETONYEK_LIB_ROOT/src/lib/contexts \
|
||||
$$PWD/mdds/include \
|
||||
$$PWD/glm
|
||||
|
||||
HEADERS += $$files($$ETONYEK_LIB_ROOT/inc/libetonyek/*.h, true)
|
||||
HEADERS += $$files($$ETONYEK_LIB_ROOT/src/lib/*.h, true)
|
||||
SOURCES += $$files($$ETONYEK_LIB_ROOT/src/lib/*.cpp, true)
|
||||
|
||||
121
Common/3dParty/apple/fetch.py
Normal file
121
Common/3dParty/apple/fetch.py
Normal file
@ -0,0 +1,121 @@
|
||||
import sys
|
||||
sys.path.append('../../../../build_tools/scripts')
|
||||
import base
|
||||
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"])
|
||||
|
||||
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 += "#ifndef _MSC_VER\n"
|
||||
fix_cpp_version += "namespace std {\n"
|
||||
fix_cpp_version += " template<bool __v>\n"
|
||||
fix_cpp_version += " using bool_constant = integral_constant<bool, __v>;\n\n"
|
||||
fix_cpp_version += " template <class... _Types>\n"
|
||||
fix_cpp_version += " using void_t = void;\n"
|
||||
fix_cpp_version += "}\n#endif\n"
|
||||
fix_cpp_version += "#endif\n\n"
|
||||
fix_cpp_version += "namespace mdds {"
|
||||
|
||||
base.replaceInFile("./mdds/include/mdds/global.hpp", "namespace mdds {", fix_cpp_version)
|
||||
|
||||
if not base.is_dir("librevenge"):
|
||||
base.cmd("git", ["clone", "https://github.com/Distrotech/librevenge.git"])
|
||||
base.cmd_in_dir("librevenge", "git", ["checkout", "becd044b519ab83893ad6398e3cbb499a7f0aaf4", "--quiet"])
|
||||
|
||||
stat_windows = ""
|
||||
stat_windows += "#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)\n"
|
||||
stat_windows += "#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)\n"
|
||||
stat_windows += "#endif\n"
|
||||
stat_windows += "#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)\n"
|
||||
stat_windows += "#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)\n"
|
||||
stat_windows += "#endif\n"
|
||||
|
||||
base.replaceInFile("./librevenge/src/lib/RVNGDirectoryStream.cpp", "#include <librevenge-stream/librevenge-stream.h>",
|
||||
"#include <librevenge-stream/librevenge-stream.h>\n\n" + stat_windows)
|
||||
|
||||
fix_RVNG_H = "explicit RVNGFileStream(const char *filename);\n"
|
||||
fix_RVNG_H += " #if defined(_WIN32) || defined(_WIN64)\n"
|
||||
fix_RVNG_H += " explicit RVNGFileStream(const wchar_t *filename);\n"
|
||||
fix_RVNG_H += " #endif\n"
|
||||
|
||||
base.replaceInFile("./librevenge/inc/librevenge-stream/RVNGStreamImplementation.h", "explicit RVNGFileStream(const char *filename);", fix_RVNG_H)
|
||||
|
||||
fix_RVNG_CPP_include = "#if defined(_WIN32) || defined(_WIN64)\n"
|
||||
fix_RVNG_CPP_include += "#include <sys/stat.h>\n\n"
|
||||
fix_RVNG_CPP_include += "static __inline int wstat(wchar_t const* const _FileName, struct stat* const _Stat)\n"
|
||||
fix_RVNG_CPP_include += "{\n"
|
||||
fix_RVNG_CPP_include += " _STATIC_ASSERT(sizeof(struct stat) == sizeof(struct _stat64i32));\n";
|
||||
fix_RVNG_CPP_include += " return _wstat64i32(_FileName, (struct _stat64i32*)_Stat);\n";
|
||||
fix_RVNG_CPP_include += "}\n"
|
||||
fix_RVNG_CPP_include += "#endif\n\n"
|
||||
fix_RVNG_CPP_include += "namespace librevenge"
|
||||
|
||||
base.replaceInFile("./librevenge/src/lib/RVNGStreamImplementation.cpp", "namespace librevenge", fix_RVNG_CPP_include)
|
||||
|
||||
fix_RVNG_CPP = "#if defined(_WIN32) || defined(_WIN64)\n"
|
||||
fix_RVNG_CPP += "RVNGFileStream::RVNGFileStream(const wchar_t *filename) :\n"
|
||||
fix_RVNG_CPP += " RVNGInputStream(),\n"
|
||||
fix_RVNG_CPP += " d(new RVNGFileStreamPrivate())\n"
|
||||
fix_RVNG_CPP += "{\n"
|
||||
fix_RVNG_CPP += " d->file = _wfopen(filename, L\"rb\");\n"
|
||||
fix_RVNG_CPP += " if (!d->file || ferror(d->file))\n"
|
||||
fix_RVNG_CPP += " {\n"
|
||||
fix_RVNG_CPP += " delete d;\n"
|
||||
fix_RVNG_CPP += " d = 0;\n"
|
||||
fix_RVNG_CPP += " return;\n"
|
||||
fix_RVNG_CPP += " }\n\n"
|
||||
fix_RVNG_CPP += " struct stat status;\n"
|
||||
fix_RVNG_CPP += " const int retval = wstat(filename, &status);\n"
|
||||
fix_RVNG_CPP += " if ((0 != retval) || !S_ISREG(status.st_mode))\n"
|
||||
fix_RVNG_CPP += " {\n"
|
||||
fix_RVNG_CPP += " delete d;\n"
|
||||
fix_RVNG_CPP += " d = 0;\n"
|
||||
fix_RVNG_CPP += " return;\n"
|
||||
fix_RVNG_CPP += " }\n\n"
|
||||
fix_RVNG_CPP += " fseek(d->file, 0, SEEK_END);\n\n"
|
||||
fix_RVNG_CPP += " d->streamSize = (unsigned long) ftell(d->file);\n"
|
||||
fix_RVNG_CPP += " if (d->streamSize == (unsigned long)-1)\n"
|
||||
fix_RVNG_CPP += " d->streamSize = 0;\n"
|
||||
fix_RVNG_CPP += " if (d->streamSize > (std::numeric_limits<unsigned long>::max)() / 2)\n"
|
||||
fix_RVNG_CPP += " d->streamSize = (std::numeric_limits<unsigned long>::max)() / 2;\n"
|
||||
fix_RVNG_CPP += " fseek(d->file, 0, SEEK_SET);\n"
|
||||
fix_RVNG_CPP += "}\n"
|
||||
fix_RVNG_CPP += "#endif\n\n"
|
||||
fix_RVNG_CPP += "RVNGFileStream::~RVNGFileStream()"
|
||||
|
||||
base.replaceInFile("./librevenge/src/lib/RVNGStreamImplementation.cpp", "RVNGFileStream::~RVNGFileStream()", fix_RVNG_CPP)
|
||||
|
||||
if not base.is_dir("libodfgen"):
|
||||
base.cmd("git", ["clone", "https://github.com/Distrotech/libodfgen.git"])
|
||||
base.cmd_in_dir("libodfgen", "git", ["checkout", "8ef8c171ebe3c5daebdce80ee422cf7bb96aa3bc", "--quiet"])
|
||||
|
||||
if not base.is_dir("libetonyek"):
|
||||
base.cmd("git", ["clone", "https://github.com/LibreOffice/libetonyek.git"])
|
||||
base.cmd_in_dir("libetonyek", "git", ["checkout", "cb396b4a9453a457469b62a740d8fb933c9442c3", "--quiet"])
|
||||
|
||||
base.replaceInFile("./libetonyek/src/lib/IWORKTable.cpp", "is_tree_valid", "valid_tree")
|
||||
|
||||
cmd_args = sys.argv[1:]
|
||||
use_gperf = False
|
||||
|
||||
for arg in cmd_args:
|
||||
if '--gperf' == arg:
|
||||
use_gperf = True
|
||||
|
||||
if use_gperf:
|
||||
base_gperf_args = ["--compare-strncmp", "--enum", "--null-strings", "--readonly-tables", "--language", "C++"]
|
||||
base_gperf_files = ["IWORKToken.gperf", "KEY1Token.gperf", "KEY2Token.gperf", "NUM1Token.gperf", "PAG1Token.gperf"]
|
||||
|
||||
for file in base_gperf_files:
|
||||
base.cmd_in_dir("./libetonyek/src/lib", "gperf", base_gperf_args + [file, "--output-file", file[0:file.find(".")] + ".inc"])
|
||||
else:
|
||||
base.copy_dir_content("./headers", "./libetonyek/src/lib")
|
||||
|
||||
|
||||
|
||||
2563
Common/3dParty/apple/headers/IWORKToken.inc
Normal file
2563
Common/3dParty/apple/headers/IWORKToken.inc
Normal file
File diff suppressed because it is too large
Load Diff
727
Common/3dParty/apple/headers/KEY1Token.inc
Normal file
727
Common/3dParty/apple/headers/KEY1Token.inc
Normal file
@ -0,0 +1,727 @@
|
||||
/* C++ code produced by gperf version 3.0.1 */
|
||||
/* Command-line: gperf --compare-strncmp --enum --null-strings --readonly-tables --language C++ --output-file KEY1Token.inc KEY1Token.gperf */
|
||||
/* Computed positions: -k'1,3,6,9,14,$' */
|
||||
|
||||
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
||||
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
||||
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
||||
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
||||
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
||||
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
||||
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
||||
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
||||
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
||||
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
||||
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
||||
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
||||
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
||||
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
||||
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
||||
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
||||
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
||||
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
||||
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
||||
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
||||
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
||||
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
|
||||
/* The character set is not based on ISO-646. */
|
||||
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
|
||||
#endif
|
||||
|
||||
#line 10 "KEY1Token.gperf"
|
||||
|
||||
#if defined __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
#endif
|
||||
|
||||
using namespace KEY1Token;
|
||||
#line 18 "KEY1Token.gperf"
|
||||
struct Token
|
||||
{
|
||||
const char *name;
|
||||
int id;
|
||||
};
|
||||
#include <string.h>
|
||||
/* maximum key range = 602, duplicates = 0 */
|
||||
|
||||
class Perfect_Hash
|
||||
{
|
||||
private:
|
||||
static inline unsigned int hash (const char *str, unsigned int len);
|
||||
public:
|
||||
static const struct Token *in_word_set (const char *str, unsigned int len);
|
||||
};
|
||||
|
||||
inline unsigned int
|
||||
Perfect_Hash::hash (register const char *str, register unsigned int len)
|
||||
{
|
||||
static const unsigned short asso_values[] =
|
||||
{
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 220, 612, 0, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 0, 0, 0, 0,
|
||||
0, 0, 10, 612, 612, 612, 0, 612, 30, 15,
|
||||
55, 612, 5, 60, 5, 612, 10, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 0, 612, 20, 165, 115,
|
||||
65, 0, 105, 135, 175, 60, 0, 0, 30, 145,
|
||||
10, 5, 155, 10, 5, 30, 5, 200, 15, 20,
|
||||
0, 190, 0, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612, 612, 612, 612, 612,
|
||||
612, 612, 612, 612, 612, 612
|
||||
};
|
||||
register int hval = len;
|
||||
|
||||
switch (hval)
|
||||
{
|
||||
default:
|
||||
hval += asso_values[(unsigned char)str[13]];
|
||||
/*FALLTHROUGH*/
|
||||
case 13:
|
||||
case 12:
|
||||
case 11:
|
||||
case 10:
|
||||
case 9:
|
||||
hval += asso_values[(unsigned char)str[8]];
|
||||
/*FALLTHROUGH*/
|
||||
case 8:
|
||||
case 7:
|
||||
case 6:
|
||||
hval += asso_values[(unsigned char)str[5]];
|
||||
/*FALLTHROUGH*/
|
||||
case 5:
|
||||
case 4:
|
||||
case 3:
|
||||
hval += asso_values[(unsigned char)str[2]];
|
||||
/*FALLTHROUGH*/
|
||||
case 2:
|
||||
case 1:
|
||||
hval += asso_values[(unsigned char)str[0]];
|
||||
break;
|
||||
}
|
||||
return hval + asso_values[(unsigned char)str[len - 1]];
|
||||
}
|
||||
|
||||
const struct Token *
|
||||
Perfect_Hash::in_word_set (register const char *str, register unsigned int len)
|
||||
{
|
||||
enum
|
||||
{
|
||||
TOTAL_KEYWORDS = 203,
|
||||
MIN_WORD_LENGTH = 1,
|
||||
MAX_WORD_LENGTH = 39,
|
||||
MIN_HASH_VALUE = 10,
|
||||
MAX_HASH_VALUE = 611
|
||||
};
|
||||
|
||||
static const struct Token wordlist[] =
|
||||
{
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 199 "KEY1Token.gperf"
|
||||
{"theme",theme},
|
||||
{(char*)0},
|
||||
#line 211 "KEY1Token.gperf"
|
||||
{"tr",tr},
|
||||
{(char*)0},
|
||||
#line 196 "KEY1Token.gperf"
|
||||
{"text",text},
|
||||
#line 207 "KEY1Token.gperf"
|
||||
{"title",title},
|
||||
{(char*)0},
|
||||
#line 198 "KEY1Token.gperf"
|
||||
{"textbox",textbox},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 65 "KEY1Token.gperf"
|
||||
{"element",element},
|
||||
{(char*)0},
|
||||
#line 132 "KEY1Token.gperf"
|
||||
{"none",none},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0},
|
||||
#line 175 "KEY1Token.gperf"
|
||||
{"size",size},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 209 "KEY1Token.gperf"
|
||||
{"tl",tl},
|
||||
{(char*)0},
|
||||
#line 206 "KEY1Token.gperf"
|
||||
{"tile",tile},
|
||||
#line 168 "KEY1Token.gperf"
|
||||
{"serie",serie},
|
||||
{(char*)0},
|
||||
#line 221 "KEY1Token.gperf"
|
||||
{"version",version},
|
||||
{(char*)0},
|
||||
#line 112 "KEY1Token.gperf"
|
||||
{"line",line},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 174 "KEY1Token.gperf"
|
||||
{"showZero",showZero},
|
||||
{(char*)0},
|
||||
#line 133 "KEY1Token.gperf"
|
||||
{"notes",notes},
|
||||
{(char*)0},
|
||||
#line 188 "KEY1Token.gperf"
|
||||
{"stroke-style",stroke_style},
|
||||
{(char*)0},
|
||||
#line 32 "KEY1Token.gperf"
|
||||
{"axes",axes},
|
||||
#line 172 "KEY1Token.gperf"
|
||||
{"shape",shape},
|
||||
{(char*)0},
|
||||
#line 187 "KEY1Token.gperf"
|
||||
{"stroke-color",stroke_color},
|
||||
#line 166 "KEY1Token.gperf"
|
||||
{"sequence",sequence},
|
||||
{(char*)0},
|
||||
#line 183 "KEY1Token.gperf"
|
||||
{"start",start},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 182 "KEY1Token.gperf"
|
||||
{"span",span},
|
||||
#line 185 "KEY1Token.gperf"
|
||||
{"steps",steps},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 93 "KEY1Token.gperf"
|
||||
{"ident",ident},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 134 "KEY1Token.gperf"
|
||||
{"null",null},
|
||||
#line 197 "KEY1Token.gperf"
|
||||
{"text-attributes",text_attributes},
|
||||
{(char*)0},
|
||||
#line 130 "KEY1Token.gperf"
|
||||
{"natural-size",natural_size},
|
||||
{(char*)0},
|
||||
#line 131 "KEY1Token.gperf"
|
||||
{"node",node},
|
||||
#line 111 "KEY1Token.gperf"
|
||||
{"level",level},
|
||||
{(char*)0},
|
||||
#line 225 "KEY1Token.gperf"
|
||||
{"visible",visible},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 95 "KEY1Token.gperf"
|
||||
{"image",image},
|
||||
{(char*)0},
|
||||
#line 171 "KEY1Token.gperf"
|
||||
{"shadow-style",shadow_style},
|
||||
{(char*)0},
|
||||
#line 67 "KEY1Token.gperf"
|
||||
{"end-color",end_color},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 208 "KEY1Token.gperf"
|
||||
{"titleVisible",titleVisible},
|
||||
#line 212 "KEY1Token.gperf"
|
||||
{"tracks-master",tracks_master},
|
||||
#line 53 "KEY1Token.gperf"
|
||||
{"data",data},
|
||||
#line 177 "KEY1Token.gperf"
|
||||
{"slide",slide},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 62 "KEY1Token.gperf"
|
||||
{"div",div},
|
||||
#line 195 "KEY1Token.gperf"
|
||||
{"tail",tail},
|
||||
#line 170 "KEY1Token.gperf"
|
||||
{"seriesDirection",seriesDirection},
|
||||
#line 169 "KEY1Token.gperf"
|
||||
{"series",series},
|
||||
{(char*)0},
|
||||
#line 162 "KEY1Token.gperf"
|
||||
{"relative",relative},
|
||||
#line 60 "KEY1Token.gperf"
|
||||
{"direction",direction},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 27 "KEY1Token.gperf"
|
||||
{"altLineVisible",altLineVisible},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 173 "KEY1Token.gperf"
|
||||
{"showGrid",showGrid},
|
||||
#line 33 "KEY1Token.gperf"
|
||||
{"axis",axis},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 161 "KEY1Token.gperf"
|
||||
{"reference",reference},
|
||||
#line 114 "KEY1Token.gperf"
|
||||
{"line-tail-style",line_tail_style},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 73 "KEY1Token.gperf"
|
||||
{"font",font},
|
||||
{(char*)0},
|
||||
#line 137 "KEY1Token.gperf"
|
||||
{"offset",offset},
|
||||
#line 92 "KEY1Token.gperf"
|
||||
{"id",id},
|
||||
{(char*)0},
|
||||
#line 160 "KEY1Token.gperf"
|
||||
{"rect",rect},
|
||||
#line 180 "KEY1Token.gperf"
|
||||
{"solid",solid},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 66 "KEY1Token.gperf"
|
||||
{"end",end},
|
||||
#line 77 "KEY1Token.gperf"
|
||||
{"font-name",font_name},
|
||||
{(char*)0},
|
||||
#line 159 "KEY1Token.gperf"
|
||||
{"radius",radius},
|
||||
#line 61 "KEY1Token.gperf"
|
||||
{"display-name",display_name},
|
||||
{(char*)0},
|
||||
#line 68 "KEY1Token.gperf"
|
||||
{"file",file},
|
||||
{(char*)0},
|
||||
#line 45 "KEY1Token.gperf"
|
||||
{"center",center},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 109 "KEY1Token.gperf"
|
||||
{"left",left},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 51 "KEY1Token.gperf"
|
||||
{"content",content},
|
||||
#line 64 "KEY1Token.gperf"
|
||||
{"duration",duration},
|
||||
#line 71 "KEY1Token.gperf"
|
||||
{"fill-type",fill_type},
|
||||
#line 163 "KEY1Token.gperf"
|
||||
{"right",right},
|
||||
#line 139 "KEY1Token.gperf"
|
||||
{"orientation",orientation},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 78 "KEY1Token.gperf"
|
||||
{"font-size",font_size},
|
||||
#line 50 "KEY1Token.gperf"
|
||||
{"color",color},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 129 "KEY1Token.gperf"
|
||||
{"name",name},
|
||||
#line 28 "KEY1Token.gperf"
|
||||
{"angle",angle},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 215 "KEY1Token.gperf"
|
||||
{"type",type},
|
||||
#line 52 "KEY1Token.gperf"
|
||||
{"dash-style",dash_style},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 82 "KEY1Token.gperf"
|
||||
{"gradient",gradient},
|
||||
#line 56 "KEY1Token.gperf"
|
||||
{"dataFormatterPrefix",dataFormatterPrefix},
|
||||
#line 54 "KEY1Token.gperf"
|
||||
{"dataFormatterHasThousandsSeparators",dataFormatterHasThousandsSeparators},
|
||||
#line 135 "KEY1Token.gperf"
|
||||
{"number",number},
|
||||
#line 38 "KEY1Token.gperf"
|
||||
{"br",br},
|
||||
#line 222 "KEY1Token.gperf"
|
||||
{"vertical",vertical},
|
||||
#line 57 "KEY1Token.gperf"
|
||||
{"dataFormatterSuffix",dataFormatterSuffix},
|
||||
#line 193 "KEY1Token.gperf"
|
||||
{"table",table},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 24 "KEY1Token.gperf"
|
||||
{"DefaultLegendRelativePosition",DefaultLegendRelativePosition},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 146 "KEY1Token.gperf"
|
||||
{"pattern",pattern},
|
||||
{(char*)0},
|
||||
#line 55 "KEY1Token.gperf"
|
||||
{"dataFormatterNumberOfDecimals",dataFormatterNumberOfDecimals},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 165 "KEY1Token.gperf"
|
||||
{"segment",segment},
|
||||
{(char*)0},
|
||||
#line 59 "KEY1Token.gperf"
|
||||
{"dict",dict},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 153 "KEY1Token.gperf"
|
||||
{"presentation",presentation},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 35 "KEY1Token.gperf"
|
||||
{"bl",bl},
|
||||
#line 126 "KEY1Token.gperf"
|
||||
{"metadata",metadata},
|
||||
{(char*)0},
|
||||
#line 86 "KEY1Token.gperf"
|
||||
{"guide",guide},
|
||||
{(char*)0},
|
||||
#line 181 "KEY1Token.gperf"
|
||||
{"spacing",spacing},
|
||||
#line 120 "KEY1Token.gperf"
|
||||
{"majorTickPositions",majorTickPositions},
|
||||
{(char*)0},
|
||||
#line 70 "KEY1Token.gperf"
|
||||
{"fill-style",fill_style},
|
||||
{(char*)0},
|
||||
#line 118 "KEY1Token.gperf"
|
||||
{"lock-aspect-ratio",lock_aspect_ratio},
|
||||
{(char*)0},
|
||||
#line 44 "KEY1Token.gperf"
|
||||
{"byte-size",byte_size},
|
||||
{(char*)0},
|
||||
#line 40 "KEY1Token.gperf"
|
||||
{"bullet",bullet},
|
||||
#line 25 "KEY1Token.gperf"
|
||||
{"DefaultLegendSize",DefaultLegendSize},
|
||||
#line 128 "KEY1Token.gperf"
|
||||
{"minorTickPositions",minorTickPositions},
|
||||
{(char*)0},
|
||||
#line 202 "KEY1Token.gperf"
|
||||
{"tickLabelsAngle",tickLabelsAngle},
|
||||
#line 127 "KEY1Token.gperf"
|
||||
{"middle",middle},
|
||||
{(char*)0},
|
||||
#line 152 "KEY1Token.gperf"
|
||||
{"pos",pos},
|
||||
#line 155 "KEY1Token.gperf"
|
||||
{"prototype-data",prototype_data},
|
||||
#line 31 "KEY1Token.gperf"
|
||||
{"array",array},
|
||||
{(char*)0},
|
||||
#line 122 "KEY1Token.gperf"
|
||||
{"master-slide",master_slide},
|
||||
#line 117 "KEY1Token.gperf"
|
||||
{"location",location},
|
||||
#line 176 "KEY1Token.gperf"
|
||||
{"size-technique",size_technique},
|
||||
{(char*)0},
|
||||
#line 79 "KEY1Token.gperf"
|
||||
{"font-superscript",font_superscript},
|
||||
#line 138 "KEY1Token.gperf"
|
||||
{"opacity",opacity},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 100 "KEY1Token.gperf"
|
||||
{"interBarGap",interBarGap},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 156 "KEY1Token.gperf"
|
||||
{"prototype-drawables",prototype_drawables},
|
||||
{(char*)0},
|
||||
#line 58 "KEY1Token.gperf"
|
||||
{"description",description},
|
||||
#line 43 "KEY1Token.gperf"
|
||||
{"bullets",bullets},
|
||||
{(char*)0},
|
||||
#line 76 "KEY1Token.gperf"
|
||||
{"font-ligatures",font_ligatures},
|
||||
{(char*)0},
|
||||
#line 191 "KEY1Token.gperf"
|
||||
{"symbol",symbol},
|
||||
#line 154 "KEY1Token.gperf"
|
||||
{"prototype-bullets",prototype_bullets},
|
||||
{(char*)0},
|
||||
#line 194 "KEY1Token.gperf"
|
||||
{"tab-stops",tab_stops},
|
||||
#line 90 "KEY1Token.gperf"
|
||||
{"horizontal",horizontal},
|
||||
{(char*)0},
|
||||
#line 204 "KEY1Token.gperf"
|
||||
{"tickLabelsVisible",tickLabelsVisible},
|
||||
{(char*)0},
|
||||
#line 192 "KEY1Token.gperf"
|
||||
{"symbolFillMode",symbolFillMode},
|
||||
#line 74 "KEY1Token.gperf"
|
||||
{"font-color",font_color},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 124 "KEY1Token.gperf"
|
||||
{"master-slides",master_slides},
|
||||
#line 147 "KEY1Token.gperf"
|
||||
{"pieSliceOffset",pieSliceOffset},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 42 "KEY1Token.gperf"
|
||||
{"bullet-indentation",bullet_indentation},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 87 "KEY1Token.gperf"
|
||||
{"guides",guides},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 88 "KEY1Token.gperf"
|
||||
{"head",head},
|
||||
#line 226 "KEY1Token.gperf"
|
||||
{"width",width},
|
||||
#line 89 "KEY1Token.gperf"
|
||||
{"hidden",hidden},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 46 "KEY1Token.gperf"
|
||||
{"character",character},
|
||||
#line 69 "KEY1Token.gperf"
|
||||
{"fill-color",fill_color},
|
||||
#line 81 "KEY1Token.gperf"
|
||||
{"g",g},
|
||||
#line 75 "KEY1Token.gperf"
|
||||
{"font-kerning",font_kerning},
|
||||
{(char*)0},
|
||||
#line 103 "KEY1Token.gperf"
|
||||
{"justified",justified},
|
||||
{(char*)0},
|
||||
#line 116 "KEY1Token.gperf"
|
||||
{"lineVisible",lineVisible},
|
||||
#line 107 "KEY1Token.gperf"
|
||||
{"labelVisible",labelVisible},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 119 "KEY1Token.gperf"
|
||||
{"locked",locked},
|
||||
#line 189 "KEY1Token.gperf"
|
||||
{"stroke-width",stroke_width},
|
||||
{(char*)0},
|
||||
#line 200 "KEY1Token.gperf"
|
||||
{"thumbnail",thumbnail},
|
||||
#line 201 "KEY1Token.gperf"
|
||||
{"thumbnails",thumbnails},
|
||||
#line 190 "KEY1Token.gperf"
|
||||
{"styles",styles},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 136 "KEY1Token.gperf"
|
||||
{"numberOfPoints",numberOfPoints},
|
||||
#line 49 "KEY1Token.gperf"
|
||||
{"chartFrame",chartFrame},
|
||||
#line 167 "KEY1Token.gperf"
|
||||
{"sequence-bullet-style",sequence_bullet_style},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 214 "KEY1Token.gperf"
|
||||
{"transition-style",transition_style},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 110 "KEY1Token.gperf"
|
||||
{"legend",legend},
|
||||
#line 148 "KEY1Token.gperf"
|
||||
{"pieSlicePercentVisible",pieSlicePercentVisible},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 47 "KEY1Token.gperf"
|
||||
{"character-bullet-style",character_bullet_style},
|
||||
{(char*)0},
|
||||
#line 213 "KEY1Token.gperf"
|
||||
{"transformation",transformation},
|
||||
#line 224 "KEY1Token.gperf"
|
||||
{"visibility",visibility},
|
||||
#line 186 "KEY1Token.gperf"
|
||||
{"string",string},
|
||||
{(char*)0},
|
||||
#line 39 "KEY1Token.gperf"
|
||||
{"buildChunkingStyle",buildChunkingStyle},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 184 "KEY1Token.gperf"
|
||||
{"start-color",start_color},
|
||||
{(char*)0},
|
||||
#line 210 "KEY1Token.gperf"
|
||||
{"top",top},
|
||||
#line 63 "KEY1Token.gperf"
|
||||
{"drawables",drawables},
|
||||
#line 179 "KEY1Token.gperf"
|
||||
{"slide-size",slide_size},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 113 "KEY1Token.gperf"
|
||||
{"line-head-style",line_head_style},
|
||||
#line 157 "KEY1Token.gperf"
|
||||
{"prototype-plugin",prototype_plugin},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 80 "KEY1Token.gperf"
|
||||
{"font-underline",font_underline},
|
||||
{(char*)0},
|
||||
#line 97 "KEY1Token.gperf"
|
||||
{"image-scale",image_scale},
|
||||
{(char*)0},
|
||||
#line 106 "KEY1Token.gperf"
|
||||
{"labelPosition",labelPosition},
|
||||
{(char*)0},
|
||||
#line 96 "KEY1Token.gperf"
|
||||
{"image-data",image_data},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 145 "KEY1Token.gperf"
|
||||
{"path",path},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 34 "KEY1Token.gperf"
|
||||
{"background-fill-style",background_fill_style},
|
||||
#line 158 "KEY1Token.gperf"
|
||||
{"prototype-plugins",prototype_plugins},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 123 "KEY1Token.gperf"
|
||||
{"master-slide-id",master_slide_id},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 178 "KEY1Token.gperf"
|
||||
{"slide-list",slide_list},
|
||||
#line 121 "KEY1Token.gperf"
|
||||
{"marker-type",marker_type},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0},
|
||||
#line 91 "KEY1Token.gperf"
|
||||
{"http://developer.apple.com/schemas/APXL",NS_URI_KEY},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 98 "KEY1Token.gperf"
|
||||
{"image-bullet-style",image_bullet_style},
|
||||
#line 30 "KEY1Token.gperf"
|
||||
{"application-version",application_version},
|
||||
{(char*)0},
|
||||
#line 149 "KEY1Token.gperf"
|
||||
{"plugin",plugin},
|
||||
#line 151 "KEY1Token.gperf"
|
||||
{"point_at_top",point_at_top},
|
||||
#line 104 "KEY1Token.gperf"
|
||||
{"key",key},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 29 "KEY1Token.gperf"
|
||||
{"application-name",application_name},
|
||||
{(char*)0},
|
||||
#line 223 "KEY1Token.gperf"
|
||||
{"vertical-alignment",vertical_alignment},
|
||||
#line 83 "KEY1Token.gperf"
|
||||
{"gradient-angle",gradient_angle},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 144 "KEY1Token.gperf"
|
||||
{"paragraph-tail-indent",paragraph_tail_indent},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0},
|
||||
#line 142 "KEY1Token.gperf"
|
||||
{"paragraph-first-line-indent",paragraph_first_line_indent},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 72 "KEY1Token.gperf"
|
||||
{"floating-content",floating_content},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 150 "KEY1Token.gperf"
|
||||
{"plugin-data",plugin_data},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 36 "KEY1Token.gperf"
|
||||
{"body",body},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 41 "KEY1Token.gperf"
|
||||
{"bullet-characters",bullet_characters},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 143 "KEY1Token.gperf"
|
||||
{"paragraph-head-indent",paragraph_head_indent},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 99 "KEY1Token.gperf"
|
||||
{"inherited",inherited},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 125 "KEY1Token.gperf"
|
||||
{"match-point",match_point},
|
||||
{(char*)0},
|
||||
#line 216 "KEY1Token.gperf"
|
||||
{"ui-state",ui_state},
|
||||
#line 102 "KEY1Token.gperf"
|
||||
{"is-filled",is_filled},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 115 "KEY1Token.gperf"
|
||||
{"lineOpacity",lineOpacity},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0},
|
||||
#line 37 "KEY1Token.gperf"
|
||||
{"bottom",bottom},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 140 "KEY1Token.gperf"
|
||||
{"page-number",page_number},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 205 "KEY1Token.gperf"
|
||||
{"time-stamp",time_stamp},
|
||||
{(char*)0},
|
||||
#line 203 "KEY1Token.gperf"
|
||||
{"tickLabelsOpacity",tickLabelsOpacity},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 94 "KEY1Token.gperf"
|
||||
{"id-ref",id_ref},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 141 "KEY1Token.gperf"
|
||||
{"paragraph-alignment",paragraph_alignment},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 164 "KEY1Token.gperf"
|
||||
{"scale-to-fit",scale_to_fit},
|
||||
{(char*)0},
|
||||
#line 101 "KEY1Token.gperf"
|
||||
{"interSeriesGap",interSeriesGap},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 219 "KEY1Token.gperf"
|
||||
{"userMaximum",userMaximum},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 217 "KEY1Token.gperf"
|
||||
{"useUserMaximum",useUserMaximum},
|
||||
#line 108 "KEY1Token.gperf"
|
||||
{"layerElementsForShadowing",layerElementsForShadowing},
|
||||
{(char*)0},
|
||||
#line 105 "KEY1Token.gperf"
|
||||
{"labelOpacity",labelOpacity},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 48 "KEY1Token.gperf"
|
||||
{"chart-prototype",chart_prototype},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 220 "KEY1Token.gperf"
|
||||
{"userMinimum",userMinimum},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 218 "KEY1Token.gperf"
|
||||
{"useUserMinimum",useUserMinimum},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 26 "KEY1Token.gperf"
|
||||
{"altLineOpacity",altLineOpacity},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0},
|
||||
#line 85 "KEY1Token.gperf"
|
||||
{"grow-horizontally",grow_horizontally},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 84 "KEY1Token.gperf"
|
||||
{"gridOpacity",gridOpacity}
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
{
|
||||
register int key = hash (str, len);
|
||||
|
||||
if (key <= MAX_HASH_VALUE && key >= 0)
|
||||
{
|
||||
register const char *s = wordlist[key].name;
|
||||
|
||||
if (s && *str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
|
||||
return &wordlist[key];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#line 227 "KEY1Token.gperf"
|
||||
|
||||
300
Common/3dParty/apple/headers/KEY2Token.inc
Normal file
300
Common/3dParty/apple/headers/KEY2Token.inc
Normal file
@ -0,0 +1,300 @@
|
||||
/* C++ code produced by gperf version 3.0.1 */
|
||||
/* Command-line: gperf --compare-strncmp --enum --null-strings --readonly-tables --language C++ --output-file KEY2Token.inc KEY2Token.gperf */
|
||||
/* Computed positions: -k'1,4,$' */
|
||||
|
||||
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
||||
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
||||
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
||||
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
||||
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
||||
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
||||
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
||||
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
||||
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
||||
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
||||
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
||||
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
||||
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
||||
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
||||
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
||||
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
||||
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
||||
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
||||
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
||||
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
||||
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
||||
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
|
||||
/* The character set is not based on ISO-646. */
|
||||
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
|
||||
#endif
|
||||
|
||||
#line 10 "KEY2Token.gperf"
|
||||
|
||||
#if defined __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
#endif
|
||||
|
||||
using namespace KEY2Token;
|
||||
#line 18 "KEY2Token.gperf"
|
||||
struct Token
|
||||
{
|
||||
const char *name;
|
||||
int id;
|
||||
};
|
||||
#include <string.h>
|
||||
/* maximum key range = 140, duplicates = 0 */
|
||||
|
||||
class Perfect_Hash
|
||||
{
|
||||
private:
|
||||
static inline unsigned int hash (const char *str, unsigned int len);
|
||||
public:
|
||||
static const struct Token *in_word_set (const char *str, unsigned int len);
|
||||
};
|
||||
|
||||
inline unsigned int
|
||||
Perfect_Hash::hash (register const char *str, register unsigned int len)
|
||||
{
|
||||
static const unsigned char asso_values[] =
|
||||
{
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 5, 65,
|
||||
0, 141, 35, 0, 141, 5, 141, 0, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 0, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 0, 25, 0,
|
||||
15, 0, 55, 10, 10, 5, 141, 15, 20, 0,
|
||||
10, 25, 40, 141, 25, 25, 5, 0, 30, 5,
|
||||
141, 40, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
|
||||
141, 141, 141, 141, 141, 141
|
||||
};
|
||||
register int hval = len;
|
||||
|
||||
switch (hval)
|
||||
{
|
||||
default:
|
||||
hval += asso_values[(unsigned char)str[3]];
|
||||
/*FALLTHROUGH*/
|
||||
case 3:
|
||||
case 2:
|
||||
case 1:
|
||||
hval += asso_values[(unsigned char)str[0]];
|
||||
break;
|
||||
}
|
||||
return hval + asso_values[(unsigned char)str[len - 1]];
|
||||
}
|
||||
|
||||
const struct Token *
|
||||
Perfect_Hash::in_word_set (register const char *str, register unsigned int len)
|
||||
{
|
||||
enum
|
||||
{
|
||||
TOTAL_KEYWORDS = 67,
|
||||
MIN_WORD_LENGTH = 1,
|
||||
MAX_WORD_LENGTH = 46,
|
||||
MIN_HASH_VALUE = 1,
|
||||
MAX_HASH_VALUE = 140
|
||||
};
|
||||
|
||||
static const struct Token wordlist[] =
|
||||
{
|
||||
{(char*)0},
|
||||
#line 49 "KEY2Token.gperf"
|
||||
{"c",c},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 65 "KEY2Token.gperf"
|
||||
{"metadata",metadata},
|
||||
#line 89 "KEY2Token.gperf"
|
||||
{"type",type},
|
||||
#line 84 "KEY2Token.gperf"
|
||||
{"theme",theme},
|
||||
#line 58 "KEY2Token.gperf"
|
||||
{"i",i},
|
||||
#line 50 "KEY2Token.gperf"
|
||||
{"comment",comment},
|
||||
#line 41 "KEY2Token.gperf"
|
||||
{"animationType",animationType},
|
||||
#line 66 "KEY2Token.gperf"
|
||||
{"name",name},
|
||||
#line 26 "KEY2Token.gperf"
|
||||
{"2005112100",VERSION_STR_3},
|
||||
{(char*)0},
|
||||
#line 62 "KEY2Token.gperf"
|
||||
{"master-slide",master_slide},
|
||||
{(char*)0},
|
||||
#line 83 "KEY2Token.gperf"
|
||||
{"text",text},
|
||||
#line 85 "KEY2Token.gperf"
|
||||
{"theme-list",theme_list},
|
||||
#line 28 "KEY2Token.gperf"
|
||||
{"92008102400",VERSION_STR_5},
|
||||
{(char*)0},
|
||||
#line 36 "KEY2Token.gperf"
|
||||
{"animationEndOffset",animationEndOffset},
|
||||
{(char*)0},
|
||||
#line 39 "KEY2Token.gperf"
|
||||
{"animationStartOffset",animationStartOffset},
|
||||
#line 27 "KEY2Token.gperf"
|
||||
{"72007061400",VERSION_STR_4},
|
||||
#line 35 "KEY2Token.gperf"
|
||||
{"animationDuration",animationDuration},
|
||||
#line 40 "KEY2Token.gperf"
|
||||
{"animationTimingReferent",animationTimingReferent},
|
||||
#line 73 "KEY2Token.gperf"
|
||||
{"size",size},
|
||||
#line 86 "KEY2Token.gperf"
|
||||
{"title",title},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 55 "KEY2Token.gperf"
|
||||
{"headline",headline},
|
||||
#line 53 "KEY2Token.gperf"
|
||||
{"direction",direction},
|
||||
#line 52 "KEY2Token.gperf"
|
||||
{"depth",depth},
|
||||
#line 78 "KEY2Token.gperf"
|
||||
{"sticky-note",sticky_note},
|
||||
#line 34 "KEY2Token.gperf"
|
||||
{"animationDelayAutomaticWith",animationDelayAutomaticWith},
|
||||
#line 30 "KEY2Token.gperf"
|
||||
{"animationAuto",animationAuto},
|
||||
{(char*)0},
|
||||
#line 67 "KEY2Token.gperf"
|
||||
{"notes",notes},
|
||||
#line 54 "KEY2Token.gperf"
|
||||
{"events",events},
|
||||
#line 42 "KEY2Token.gperf"
|
||||
{"authors",authors},
|
||||
#line 63 "KEY2Token.gperf"
|
||||
{"master-slides",master_slides},
|
||||
#line 70 "KEY2Token.gperf"
|
||||
{"page",page},
|
||||
#line 74 "KEY2Token.gperf"
|
||||
{"slide",slide},
|
||||
#line 80 "KEY2Token.gperf"
|
||||
{"string",string},
|
||||
#line 56 "KEY2Token.gperf"
|
||||
{"headlineParagraphStyle",headlineParagraphStyle},
|
||||
#line 37 "KEY2Token.gperf"
|
||||
{"animationInterchunkAuto",animationInterchunkAuto},
|
||||
{(char*)0},
|
||||
#line 24 "KEY2Token.gperf"
|
||||
{"2004102100",VERSION_STR_2},
|
||||
#line 77 "KEY2Token.gperf"
|
||||
{"slide-style",slide_style},
|
||||
#line 33 "KEY2Token.gperf"
|
||||
{"animationDelayAutmaticAfter",animationDelayAutomaticAfter},
|
||||
#line 61 "KEY2Token.gperf"
|
||||
{"keywords",keywords},
|
||||
#line 32 "KEY2Token.gperf"
|
||||
{"animationDelay",animationDelay},
|
||||
#line 75 "KEY2Token.gperf"
|
||||
{"slide-list",slide_list},
|
||||
{(char*)0},
|
||||
#line 31 "KEY2Token.gperf"
|
||||
{"animationAutoPlay",animationAutoPlay},
|
||||
#line 60 "KEY2Token.gperf"
|
||||
{"key",key},
|
||||
#line 51 "KEY2Token.gperf"
|
||||
{"decimal-number",number},
|
||||
#line 82 "KEY2Token.gperf"
|
||||
{"stylesheet",stylesheet},
|
||||
{(char*)0},
|
||||
#line 79 "KEY2Token.gperf"
|
||||
{"sticky-notes",sticky_notes},
|
||||
#line 29 "KEY2Token.gperf"
|
||||
{"BGBuildDurationProperty",BGBuildDurationProperty},
|
||||
#line 38 "KEY2Token.gperf"
|
||||
{"animationInterchunkDelay",animationInterchunkDelay},
|
||||
#line 45 "KEY2Token.gperf"
|
||||
{"build",build},
|
||||
#line 68 "KEY2Token.gperf"
|
||||
{"number",number},
|
||||
#line 87 "KEY2Token.gperf"
|
||||
{"title-placeholder",title_placeholder},
|
||||
#line 69 "KEY2Token.gperf"
|
||||
{"object-placeholder",object_placeholder},
|
||||
{(char*)0},
|
||||
#line 64 "KEY2Token.gperf"
|
||||
{"master-ref",master_ref},
|
||||
#line 46 "KEY2Token.gperf"
|
||||
{"build-chunk",build_chunk},
|
||||
#line 90 "KEY2Token.gperf"
|
||||
{"version",version},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 25 "KEY2Token.gperf"
|
||||
{"2005092101",COMPATIBLE_VERSION_STR_3,},
|
||||
{(char*)0},
|
||||
#line 48 "KEY2Token.gperf"
|
||||
{"bullets",bullets},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 47 "KEY2Token.gperf"
|
||||
{"build-chunks",build_chunks},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 72 "KEY2Token.gperf"
|
||||
{"presentation",presentation},
|
||||
{(char*)0},
|
||||
#line 76 "KEY2Token.gperf"
|
||||
{"slide-number-placeholder",slide_number_placeholder},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 59 "KEY2Token.gperf"
|
||||
{"info-ref",info_ref},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 57 "KEY2Token.gperf"
|
||||
{"http://developer.apple.com/namespaces/keynote2",NS_URI_KEY},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 88 "KEY2Token.gperf"
|
||||
{"title-placeholder-ref",title_placeholder_ref},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 43 "KEY2Token.gperf"
|
||||
{"body-placeholder",body_placeholder},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 81 "KEY2Token.gperf"
|
||||
{"style-ref",style_ref},
|
||||
{(char*)0},
|
||||
#line 71 "KEY2Token.gperf"
|
||||
{"parent-build-ref",parent_build_ref},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 44 "KEY2Token.gperf"
|
||||
{"body-placeholder-ref",body_placeholder_ref}
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
{
|
||||
register int key = hash (str, len);
|
||||
|
||||
if (key <= MAX_HASH_VALUE && key >= 0)
|
||||
{
|
||||
register const char *s = wordlist[key].name;
|
||||
|
||||
if (s && *str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
|
||||
return &wordlist[key];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#line 91 "KEY2Token.gperf"
|
||||
|
||||
151
Common/3dParty/apple/headers/NUM1Token.inc
Normal file
151
Common/3dParty/apple/headers/NUM1Token.inc
Normal file
@ -0,0 +1,151 @@
|
||||
/* C++ code produced by gperf version 3.0.1 */
|
||||
/* Command-line: gperf --compare-strncmp --enum --null-strings --readonly-tables --language C++ --output-file NUM1Token.inc NUM1Token.gperf */
|
||||
/* Computed positions: -k'$' */
|
||||
|
||||
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
||||
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
||||
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
||||
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
||||
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
||||
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
||||
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
||||
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
||||
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
||||
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
||||
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
||||
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
||||
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
||||
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
||||
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
||||
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
||||
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
||||
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
||||
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
||||
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
||||
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
||||
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
|
||||
/* The character set is not based on ISO-646. */
|
||||
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
|
||||
#endif
|
||||
|
||||
#line 10 "NUM1Token.gperf"
|
||||
|
||||
#if defined __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
#endif
|
||||
|
||||
using namespace NUM1Token;
|
||||
#line 18 "NUM1Token.gperf"
|
||||
struct Token
|
||||
{
|
||||
const char *name;
|
||||
int id;
|
||||
};
|
||||
#include <string.h>
|
||||
/* maximum key range = 34, duplicates = 0 */
|
||||
|
||||
class Perfect_Hash
|
||||
{
|
||||
private:
|
||||
static inline unsigned int hash (const char *str, unsigned int len);
|
||||
public:
|
||||
static const struct Token *in_word_set (const char *str, unsigned int len);
|
||||
};
|
||||
|
||||
inline unsigned int
|
||||
Perfect_Hash::hash (register const char *str, register unsigned int len)
|
||||
{
|
||||
static const unsigned char asso_values[] =
|
||||
{
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 0, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 0, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
0, 10, 41, 41, 41, 0, 0, 41, 41, 41,
|
||||
41, 5, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
||||
41, 41, 41, 41, 41, 41
|
||||
};
|
||||
return len + asso_values[(unsigned char)str[len - 1]];
|
||||
}
|
||||
|
||||
const struct Token *
|
||||
Perfect_Hash::in_word_set (register const char *str, register unsigned int len)
|
||||
{
|
||||
enum
|
||||
{
|
||||
TOTAL_KEYWORDS = 10,
|
||||
MIN_WORD_LENGTH = 7,
|
||||
MAX_WORD_LENGTH = 40,
|
||||
MIN_HASH_VALUE = 7,
|
||||
MAX_HASH_VALUE = 40
|
||||
};
|
||||
|
||||
static const struct Token wordlist[] =
|
||||
{
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 29 "NUM1Token.gperf"
|
||||
{"version",version},
|
||||
#line 25 "NUM1Token.gperf"
|
||||
{"document",document},
|
||||
#line 30 "NUM1Token.gperf"
|
||||
{"workspace",workspace},
|
||||
#line 28 "NUM1Token.gperf"
|
||||
{"stylesheet",stylesheet},
|
||||
#line 24 "NUM1Token.gperf"
|
||||
{"92008102400",VERSION_STR_2},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 32 "NUM1Token.gperf"
|
||||
{"workspace-name",workspace_name},
|
||||
#line 33 "NUM1Token.gperf"
|
||||
{"workspace-style",workspace_style},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 27 "NUM1Token.gperf"
|
||||
{"page-info",page_info},
|
||||
#line 31 "NUM1Token.gperf"
|
||||
{"workspace-array",workspace_array},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 26 "NUM1Token.gperf"
|
||||
{"http://developer.apple.com/namespaces/ls",NS_URI_LS}
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
{
|
||||
register int key = hash (str, len);
|
||||
|
||||
if (key <= MAX_HASH_VALUE && key >= 0)
|
||||
{
|
||||
register const char *s = wordlist[key].name;
|
||||
|
||||
if (s && *str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
|
||||
return &wordlist[key];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#line 34 "NUM1Token.gperf"
|
||||
|
||||
209
Common/3dParty/apple/headers/PAG1Token.inc
Normal file
209
Common/3dParty/apple/headers/PAG1Token.inc
Normal file
@ -0,0 +1,209 @@
|
||||
/* C++ code produced by gperf version 3.0.1 */
|
||||
/* Command-line: gperf --compare-strncmp --enum --null-strings --readonly-tables --language C++ --output-file PAG1Token.inc PAG1Token.gperf */
|
||||
/* Computed positions: -k'1,6' */
|
||||
|
||||
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
||||
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
||||
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
||||
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
||||
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
||||
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
||||
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
||||
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
||||
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
||||
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
||||
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
||||
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
||||
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
||||
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
||||
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
||||
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
||||
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
||||
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
||||
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
||||
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
||||
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
||||
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
|
||||
/* The character set is not based on ISO-646. */
|
||||
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
|
||||
#endif
|
||||
|
||||
#line 10 "PAG1Token.gperf"
|
||||
|
||||
#if defined __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
#endif
|
||||
|
||||
using namespace PAG1Token;
|
||||
#line 18 "PAG1Token.gperf"
|
||||
struct Token
|
||||
{
|
||||
const char *name;
|
||||
int id;
|
||||
};
|
||||
#include <string.h>
|
||||
/* maximum key range = 51, duplicates = 0 */
|
||||
|
||||
class Perfect_Hash
|
||||
{
|
||||
private:
|
||||
static inline unsigned int hash (const char *str, unsigned int len);
|
||||
public:
|
||||
static const struct Token *in_word_set (const char *str, unsigned int len);
|
||||
};
|
||||
|
||||
inline unsigned int
|
||||
Perfect_Hash::hash (register const char *str, register unsigned int len)
|
||||
{
|
||||
static const unsigned char asso_values[] =
|
||||
{
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 25, 55, 0, 55, 10,
|
||||
55, 55, 55, 55, 55, 55, 55, 10, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
5, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 5, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 5, 25, 15,
|
||||
20, 0, 20, 15, 5, 55, 55, 5, 10, 55,
|
||||
0, 15, 5, 55, 0, 0, 0, 55, 5, 10,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
|
||||
55, 55, 55, 55, 55, 55
|
||||
};
|
||||
register int hval = len;
|
||||
|
||||
switch (hval)
|
||||
{
|
||||
default:
|
||||
hval += asso_values[(unsigned char)str[5]];
|
||||
/*FALLTHROUGH*/
|
||||
case 5:
|
||||
case 4:
|
||||
case 3:
|
||||
case 2:
|
||||
case 1:
|
||||
hval += asso_values[(unsigned char)str[0]];
|
||||
break;
|
||||
}
|
||||
return hval;
|
||||
}
|
||||
|
||||
const struct Token *
|
||||
Perfect_Hash::in_word_set (register const char *str, register unsigned int len)
|
||||
{
|
||||
enum
|
||||
{
|
||||
TOTAL_KEYWORDS = 31,
|
||||
MIN_WORD_LENGTH = 4,
|
||||
MAX_WORD_LENGTH = 40,
|
||||
MIN_HASH_VALUE = 4,
|
||||
MAX_HASH_VALUE = 54
|
||||
};
|
||||
|
||||
static const struct Token wordlist[] =
|
||||
{
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 38 "PAG1Token.gperf"
|
||||
{"note",note},
|
||||
#line 49 "PAG1Token.gperf"
|
||||
{"rpage",rpage},
|
||||
#line 39 "PAG1Token.gperf"
|
||||
{"number",number},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 41 "PAG1Token.gperf"
|
||||
{"page",page},
|
||||
#line 52 "PAG1Token.gperf"
|
||||
{"stylesheet",stylesheet},
|
||||
#line 33 "PAG1Token.gperf"
|
||||
{"header",header},
|
||||
#line 51 "PAG1Token.gperf"
|
||||
{"slprint-info",slprint_info},
|
||||
{(char*)0},
|
||||
#line 47 "PAG1Token.gperf"
|
||||
{"prototype",prototype},
|
||||
#line 44 "PAG1Token.gperf"
|
||||
{"page-scale",page_scale},
|
||||
#line 37 "PAG1Token.gperf"
|
||||
{"layout",layout},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 27 "PAG1Token.gperf"
|
||||
{"cell",cell},
|
||||
#line 40 "PAG1Token.gperf"
|
||||
{"order",order},
|
||||
#line 43 "PAG1Token.gperf"
|
||||
{"page-height",page_height},
|
||||
#line 53 "PAG1Token.gperf"
|
||||
{"textbox",textbox},
|
||||
{(char*)0},
|
||||
#line 28 "PAG1Token.gperf"
|
||||
{"date",date},
|
||||
#line 45 "PAG1Token.gperf"
|
||||
{"page-width",page_width},
|
||||
#line 31 "PAG1Token.gperf"
|
||||
{"footer",footer},
|
||||
#line 54 "PAG1Token.gperf"
|
||||
{"version",version},
|
||||
#line 29 "PAG1Token.gperf"
|
||||
{"document",document},
|
||||
#line 26 "PAG1Token.gperf"
|
||||
{"body",body},
|
||||
#line 42 "PAG1Token.gperf"
|
||||
{"page-group",page_group},
|
||||
#line 24 "PAG1Token.gperf"
|
||||
{"92008102400",VERSION_STR_4},
|
||||
#line 25 "PAG1Token.gperf"
|
||||
{"SLCreationDateProperty",SLCreationDateProperty},
|
||||
#line 50 "PAG1Token.gperf"
|
||||
{"section-prototypes",section_prototypes},
|
||||
#line 35 "PAG1Token.gperf"
|
||||
{"kSFWPFootnoteGapProperty",kSFWPFootnoteGapProperty},
|
||||
#line 36 "PAG1Token.gperf"
|
||||
{"kSFWPFootnoteKindProperty",kSFWPFootnoteKindProperty},
|
||||
#line 48 "PAG1Token.gperf"
|
||||
{"publication-info",publication_info},
|
||||
{(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 46 "PAG1Token.gperf"
|
||||
{"print-info",print_info},
|
||||
{(char*)0}, {(char*)0},
|
||||
#line 32 "PAG1Token.gperf"
|
||||
{"footnote",footnote},
|
||||
{(char*)0},
|
||||
#line 34 "PAG1Token.gperf"
|
||||
{"http://developer.apple.com/namespaces/sl",NS_URI_SL},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
{(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
|
||||
#line 30 "PAG1Token.gperf"
|
||||
{"drawables",drawables}
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
{
|
||||
register int key = hash (str, len);
|
||||
|
||||
if (key <= MAX_HASH_VALUE && key >= 0)
|
||||
{
|
||||
register const char *s = wordlist[key].name;
|
||||
|
||||
if (s && *str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
|
||||
return &wordlist[key];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#line 55 "PAG1Token.gperf"
|
||||
|
||||
@ -25,7 +25,7 @@ namespace NSCSS
|
||||
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_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay), m_oTransform(oStyle.m_oTransform){}
|
||||
|
||||
CCompiledStyle::~CCompiledStyle()
|
||||
{
|
||||
@ -44,6 +44,7 @@ namespace NSCSS
|
||||
m_oPadding += oElement.m_oPadding;
|
||||
m_oText += oElement.m_oText;
|
||||
m_oDisplay += oElement.m_oDisplay;
|
||||
m_oTransform += oElement.m_oTransform;
|
||||
|
||||
if (!oElement.m_sId.empty())
|
||||
m_sId += L'+' + oElement.m_sId;
|
||||
@ -66,6 +67,7 @@ namespace NSCSS
|
||||
m_oPadding = oElement.m_oPadding;
|
||||
m_oText = oElement.m_oText;
|
||||
m_oDisplay = oElement.m_oDisplay;
|
||||
m_oTransform = oElement.m_oTransform;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -78,7 +80,8 @@ namespace NSCSS
|
||||
m_oMargin == oStyle.m_oMargin &&
|
||||
m_oPadding == oStyle.m_oPadding &&
|
||||
m_oText == oStyle.m_oText &&
|
||||
m_oDisplay == oStyle.m_oDisplay;
|
||||
m_oDisplay == oStyle.m_oDisplay &&
|
||||
m_oTransform == oStyle.m_oTransform;
|
||||
}
|
||||
|
||||
void CCompiledStyle::StyleEquation(CCompiledStyle &oFirstStyle, CCompiledStyle &oSecondStyle)
|
||||
@ -90,6 +93,7 @@ namespace NSCSS
|
||||
NSProperties::CText ::Equation(oFirstStyle.m_oText, oSecondStyle.m_oText);
|
||||
NSProperties::CBorder ::Equation(oFirstStyle.m_oBorder, oSecondStyle.m_oBorder);
|
||||
NSProperties::CDisplay ::Equation(oFirstStyle.m_oDisplay, oSecondStyle.m_oDisplay);
|
||||
NSProperties::CTransform ::Equation(oFirstStyle.m_oTransform, oSecondStyle.m_oTransform);
|
||||
}
|
||||
|
||||
void CCompiledStyle::SetDpi(const unsigned short &uiDpi)
|
||||
@ -431,6 +435,12 @@ namespace NSCSS
|
||||
m_oDisplay.SetVAlign(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
//TRANSFORM
|
||||
CASE(L"transform"):
|
||||
{
|
||||
m_oTransform.SetMatrix(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
default: AddOtherStyle(pPropertie, unLevel, bHardMode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,11 +31,12 @@ namespace NSCSS
|
||||
NSProperties::CText m_oText;
|
||||
NSProperties::CBorder m_oBorder;
|
||||
NSProperties::CDisplay m_oDisplay;
|
||||
NSProperties::CTransform m_oTransform;
|
||||
|
||||
CCompiledStyle();
|
||||
CCompiledStyle(const CCompiledStyle& oStyle);
|
||||
|
||||
~CCompiledStyle();
|
||||
virtual ~CCompiledStyle();
|
||||
|
||||
void SetDpi(const unsigned short& uiDpi);
|
||||
void SetUnitMeasure(const UnitMeasure& enUnitMeasure);
|
||||
|
||||
@ -13,14 +13,14 @@ namespace NSCSS
|
||||
delete m_pInternal;
|
||||
}
|
||||
|
||||
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure) const
|
||||
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors) const
|
||||
{
|
||||
return m_pInternal->GetCompiledStyle(arSelectors, bIsSettings, unitMeasure);
|
||||
return m_pInternal->GetCompiledStyle(arSelectors);
|
||||
}
|
||||
|
||||
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure) const
|
||||
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors) const
|
||||
{
|
||||
return m_pInternal->GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
|
||||
return m_pInternal->GetCompiledStyle(oStyle, arSelectors);
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator::CalculateStyleId(const CNode& oNode)
|
||||
@ -48,26 +48,11 @@ namespace NSCSS
|
||||
m_pInternal->AddStylesFromFile(wsFileName);
|
||||
}
|
||||
|
||||
void CCssCalculator::SetUnitMeasure(const UnitMeasure& nType)
|
||||
{
|
||||
m_pInternal->SetUnitMeasure(nType);
|
||||
}
|
||||
|
||||
void CCssCalculator::SetDpi(const unsigned short int& nValue)
|
||||
{
|
||||
m_pInternal->SetDpi(nValue);
|
||||
}
|
||||
|
||||
void CCssCalculator::SetBodyTree(const CTree &oTree)
|
||||
{
|
||||
m_pInternal->SetBodyTree(oTree);
|
||||
}
|
||||
|
||||
UnitMeasure CCssCalculator::GetUnitMeasure() const
|
||||
{
|
||||
return m_pInternal->GetUnitMeasure();
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator::GetEncoding() const
|
||||
{
|
||||
return m_pInternal->GetEncoding();
|
||||
@ -78,6 +63,26 @@ namespace NSCSS
|
||||
return m_pInternal->GetDpi();
|
||||
}
|
||||
|
||||
void CCssCalculator::ClearPageData()
|
||||
{
|
||||
m_pInternal->ClearPageData();
|
||||
}
|
||||
|
||||
void CCssCalculator::ClearEmbeddedStyles()
|
||||
{
|
||||
m_pInternal->ClearEmbeddedStyles();
|
||||
}
|
||||
|
||||
void CCssCalculator::ClearAllowedStyleFiles()
|
||||
{
|
||||
m_pInternal->ClearAllowedStyleFiles();
|
||||
}
|
||||
|
||||
void CCssCalculator::ClearStylesFromFile(const std::wstring& wsFilePath)
|
||||
{
|
||||
m_pInternal->ClearStylesFromFile(wsFilePath);
|
||||
}
|
||||
|
||||
void CCssCalculator::Clear()
|
||||
{
|
||||
m_pInternal->Clear();
|
||||
|
||||
@ -19,8 +19,8 @@ namespace NSCSS
|
||||
CCssCalculator();
|
||||
~CCssCalculator();
|
||||
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point) const;
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point) const;
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors) const;
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors) const;
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
@ -30,14 +30,15 @@ namespace NSCSS
|
||||
void AddStyles (const std::wstring& wsStyle);
|
||||
void AddStylesFromFile(const std::wstring& wsFileName);
|
||||
|
||||
void SetUnitMeasure(const UnitMeasure& nType);
|
||||
void SetDpi(const unsigned short int& nValue);
|
||||
void SetBodyTree(const CTree &oTree);
|
||||
|
||||
UnitMeasure GetUnitMeasure() const;
|
||||
std::wstring GetEncoding() const;
|
||||
unsigned short int GetDpi() const;
|
||||
|
||||
void ClearPageData();
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
void ClearStylesFromFile(const std::wstring& wsFilePath);
|
||||
void Clear();
|
||||
};
|
||||
}
|
||||
|
||||
@ -5,12 +5,9 @@
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
|
||||
#include "../../katana-parser/src/selector.h"
|
||||
#include "../../../../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "ConstValues.h"
|
||||
#include "../../../../../DesktopEditor/common/File.h"
|
||||
#include "StaticFunctions.h"
|
||||
|
||||
@ -41,61 +38,120 @@ bool operator<(const std::vector<NSCSS::CNode> &arLeftSelectors, const std::vect
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_UnitMeasure(Point), m_mStatictics(NULL), m_sEncoding(L"UTF-8"){}
|
||||
CStyleStorage::CStyleStorage()
|
||||
{}
|
||||
|
||||
CCssCalculator_Private::~CCssCalculator_Private()
|
||||
CStyleStorage::~CStyleStorage()
|
||||
{
|
||||
m_arFiles.clear();
|
||||
|
||||
for (std::map<std::wstring, CElement*>::iterator oIter = m_mData.begin(); oIter != m_mData.end(); ++oIter)
|
||||
if (oIter->second != NULL)
|
||||
delete oIter->second;
|
||||
|
||||
m_mData.clear();
|
||||
|
||||
if (NULL != m_mStatictics)
|
||||
delete m_mStatictics;
|
||||
Clear();
|
||||
}
|
||||
|
||||
inline void CCssCalculator_Private::GetOutputData(KatanaOutput *oOutput)
|
||||
void CStyleStorage::Clear()
|
||||
{
|
||||
if ( NULL == oOutput )
|
||||
return;
|
||||
for (TStyleFileData* pStyleFileData : m_arStyleFiles)
|
||||
{
|
||||
if (nullptr == pStyleFileData)
|
||||
continue;
|
||||
|
||||
switch (oOutput->mode) {
|
||||
case KatanaParserModeStylesheet:
|
||||
GetStylesheet(oOutput->stylesheet);
|
||||
break;
|
||||
case KatanaParserModeRule:
|
||||
GetRule(oOutput->rule);
|
||||
break;
|
||||
case KatanaParserModeKeyframeRule:
|
||||
case KatanaParserModeKeyframeKeyList:
|
||||
case KatanaParserModeMediaList:
|
||||
case KatanaParserModeValue:
|
||||
case KatanaParserModeSelector:
|
||||
case KatanaParserModeDeclarationList:
|
||||
break;
|
||||
for (std::map<std::wstring, CElement*>::iterator oIter = pStyleFileData->m_mStyleData.begin(); oIter != pStyleFileData->m_mStyleData.end(); ++oIter)
|
||||
if (oIter->second != nullptr)
|
||||
delete oIter->second;
|
||||
|
||||
delete pStyleFileData;
|
||||
}
|
||||
|
||||
m_arStyleFiles.clear();
|
||||
m_arEmptyStyleFiles.clear();
|
||||
|
||||
ClearEmbeddedStyles();
|
||||
ClearAllowedStyleFiles();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
ClearPageData();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CStyleStorage::AddStyles(const std::string& sStyle)
|
||||
{
|
||||
if (sStyle.empty())
|
||||
return;
|
||||
|
||||
KatanaOutput *output = katana_parse(sStyle.c_str(), sStyle.length(), KatanaParserModeStylesheet);
|
||||
this->GetOutputData(output, m_mEmbeddedStyleData);
|
||||
katana_destroy_output(output);
|
||||
}
|
||||
|
||||
void CStyleStorage::AddStyles(const std::wstring& wsStyle)
|
||||
{
|
||||
if (wsStyle.empty())
|
||||
return;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
std::wregex oRegex(L"@page\\s*([^{]*)(\\{[^}]*\\})");
|
||||
std::wsmatch oMatch;
|
||||
std::wstring::const_iterator oSearchStart(wsStyle.cbegin());
|
||||
|
||||
while (std::regex_search(oSearchStart, wsStyle.cend(), oMatch, oRegex))
|
||||
{
|
||||
AddPageData(oMatch[1].str(), oMatch[2].str());
|
||||
oSearchStart = oMatch.suffix().first;
|
||||
}
|
||||
#endif
|
||||
|
||||
AddStyles(U_TO_UTF8(wsStyle));
|
||||
}
|
||||
|
||||
void CStyleStorage::AddStylesFromFile(const std::wstring& wsFileName)
|
||||
{
|
||||
std::set<std::wstring>::const_iterator itEmptyFileFound = m_arEmptyStyleFiles.find(wsFileName);
|
||||
|
||||
if (m_arEmptyStyleFiles.cend() != itEmptyFileFound)
|
||||
return;
|
||||
|
||||
std::vector<TStyleFileData*>::const_iterator itFound = std::find_if(m_arStyleFiles.cbegin(), m_arStyleFiles.cend(),
|
||||
[wsFileName](const TStyleFileData* pStyleFileData)
|
||||
{ return wsFileName == pStyleFileData->m_wsStyleFilepath; });
|
||||
|
||||
m_arAllowedStyleFiles.insert(wsFileName);
|
||||
|
||||
if (m_arStyleFiles.cend() != itFound)
|
||||
return;
|
||||
|
||||
TStyleFileData *pStyleFileData = new TStyleFileData();
|
||||
|
||||
pStyleFileData->m_wsStyleFilepath = wsFileName;
|
||||
|
||||
AddStyles(NS_STATIC_FUNCTIONS::GetContentAsUTF8(wsFileName), pStyleFileData->m_mStyleData);
|
||||
|
||||
if (!pStyleFileData->m_mStyleData.empty())
|
||||
m_arStyleFiles.push_back(pStyleFileData);
|
||||
else
|
||||
{
|
||||
m_arEmptyStyleFiles.insert(wsFileName);
|
||||
delete pStyleFileData;
|
||||
}
|
||||
}
|
||||
|
||||
void CStyleStorage::ClearStylesFromFile(const std::wstring& wsFileName)
|
||||
{
|
||||
std::vector<TStyleFileData*>::const_iterator itFound = std::find_if(m_arStyleFiles.cbegin(), m_arStyleFiles.cend(),
|
||||
[wsFileName](const TStyleFileData* pStyleFileData)
|
||||
{ return wsFileName == pStyleFileData->m_wsStyleFilepath; });
|
||||
|
||||
if (m_arStyleFiles.cend() != itFound)
|
||||
{
|
||||
m_arStyleFiles.erase(itFound);
|
||||
delete *itFound;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
std::map<std::wstring, std::wstring> CCssCalculator_Private::GetPageData(const std::wstring &wsPageName)
|
||||
void CStyleStorage::AddPageData(const std::wstring& wsPageName, const std::wstring& wsStyles)
|
||||
{
|
||||
if (m_arPageDatas.empty())
|
||||
return {};
|
||||
|
||||
for (const TPageData& oPageData : m_arPageDatas)
|
||||
{
|
||||
if (std::find(oPageData.m_wsNames.begin(), oPageData.m_wsNames.end(), wsPageName) != oPageData.m_wsNames.end())
|
||||
return oPageData.m_mData;
|
||||
}
|
||||
|
||||
return {};
|
||||
m_arPageDatas.push_back({NS_STATIC_FUNCTIONS::GetWordsW(wsPageName), NS_STATIC_FUNCTIONS::GetRules(wsStyles)});
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetPageData(NSProperties::CPage &oPage, const std::map<std::wstring, std::wstring> &mData, unsigned int unLevel, bool bHardMode)
|
||||
|
||||
void CStyleStorage::SetPageData(NSProperties::CPage& oPage, const std::map<std::wstring, std::wstring>& mData, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
for (const std::pair<std::wstring, std::wstring> &oData : mData)
|
||||
{
|
||||
@ -110,162 +166,84 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors)
|
||||
std::map<std::wstring, std::wstring> CStyleStorage::GetPageData(const std::wstring& wsPageName)
|
||||
{
|
||||
std::vector<std::wstring> arNodes;
|
||||
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode)
|
||||
{
|
||||
if (!oNode->m_wsName.empty())
|
||||
arNodes.push_back(oNode->m_wsName);
|
||||
|
||||
if (!oNode->m_wsClass.empty())
|
||||
{
|
||||
if (oNode->m_wsClass.find(L' ') != std::wstring::npos)
|
||||
{
|
||||
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' ';}));
|
||||
}
|
||||
else
|
||||
arNodes.push_back(L'.' + oNode->m_wsClass);
|
||||
}
|
||||
|
||||
if (!oNode->m_wsId.empty())
|
||||
arNodes.push_back(L'#' + oNode->m_wsId);
|
||||
}
|
||||
|
||||
return arNodes;
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::FindPrevAndKindElements(const CElement *pElement, const std::vector<std::wstring> &arNextNodes, std::vector<CElement*>& arFindedElements, const std::wstring &wsName, const std::vector<std::wstring> &arClasses)
|
||||
{
|
||||
if (arNextNodes.empty())
|
||||
return;
|
||||
|
||||
const std::vector<CElement*> arTempPrev = pElement->GetPrevElements(arNextNodes.crbegin() + 1, arNextNodes.crend());
|
||||
const std::vector<CElement*> arTempKins = pElement->GetNextOfKin(wsName, arClasses);
|
||||
|
||||
if (!arTempPrev.empty())
|
||||
arFindedElements.insert(arFindedElements.end(), arTempPrev.begin(), arTempPrev.end());
|
||||
|
||||
if (!arTempKins.empty())
|
||||
arFindedElements.insert(arFindedElements.end(), arTempKins.begin(), arTempKins.end());
|
||||
}
|
||||
|
||||
std::vector<CElement*> CCssCalculator_Private::FindElements(std::vector<std::wstring> &arNodes, std::vector<std::wstring> &arNextNodes, bool bIsSettings)
|
||||
{
|
||||
if (arNodes.empty())
|
||||
if (m_arPageDatas.empty())
|
||||
return {};
|
||||
|
||||
std::vector<CElement*> arFindedElements;
|
||||
|
||||
std::wstring wsName, wsId;
|
||||
std::vector<std::wstring> arClasses;
|
||||
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'#')
|
||||
for (const TPageData& oPageData : m_arPageDatas)
|
||||
{
|
||||
wsId = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsId);
|
||||
if (std::find(oPageData.m_wsNames.begin(), oPageData.m_wsNames.end(), wsPageName) != oPageData.m_wsNames.end())
|
||||
return oPageData.m_mData;
|
||||
}
|
||||
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'.')
|
||||
{
|
||||
arClasses = NS_STATIC_FUNCTIONS::GetWordsW(arNodes.back(), false, L" ");
|
||||
arNextNodes.push_back(arNodes.back());
|
||||
arNodes.pop_back();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!arNodes.empty())
|
||||
{
|
||||
wsName = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsName);
|
||||
}
|
||||
|
||||
const std::map<std::wstring, CElement*>::const_iterator oFindName = m_mData.find(wsName);
|
||||
std::map<std::wstring, CElement*>::const_iterator oFindId;
|
||||
|
||||
if (!wsId.empty())
|
||||
{
|
||||
oFindId = m_mData.find(wsId);
|
||||
|
||||
if (oFindId != m_mData.end() && NULL != m_mStatictics)
|
||||
{
|
||||
std::map<StatistickElement, unsigned int>::const_iterator oFindCountId = m_mStatictics->find(StatistickElement{StatistickElement::IsId, wsId});
|
||||
|
||||
if ((m_mStatictics->end() != oFindCountId) &&
|
||||
(((bIsSettings && oFindCountId->second < MaxNumberRepetitions) ||
|
||||
(!bIsSettings && oFindCountId->second >= MaxNumberRepetitions))))
|
||||
{
|
||||
if (!oFindId->second->Empty())
|
||||
arFindedElements.push_back(oFindId->second);
|
||||
}
|
||||
|
||||
FindPrevAndKindElements(oFindId->second, arNextNodes, arFindedElements, wsName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!arClasses.empty())
|
||||
{
|
||||
if (!bIsSettings)
|
||||
{
|
||||
for (std::vector<std::wstring>::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass)
|
||||
{
|
||||
const std::map<std::wstring, CElement*>::const_iterator oFindClass = m_mData.find(*iClass);
|
||||
if (oFindClass != m_mData.end())
|
||||
{
|
||||
if (!oFindClass->second->Empty())
|
||||
arFindedElements.push_back(oFindClass->second);
|
||||
|
||||
FindPrevAndKindElements(oFindClass->second, arNextNodes, arFindedElements, wsName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oFindName != m_mData.end())
|
||||
{
|
||||
if (!bIsSettings)
|
||||
{
|
||||
if (!oFindName->second->Empty())
|
||||
arFindedElements.push_back(oFindName->second);
|
||||
|
||||
FindPrevAndKindElements(oFindName->second, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
}
|
||||
|
||||
if (arFindedElements.size() > 1)
|
||||
{
|
||||
std::sort(arFindedElements.rbegin(), arFindedElements.rend(),
|
||||
[](CElement* oFirstElement, CElement* oSecondElement)
|
||||
{
|
||||
return oFirstElement->GetWeight() > oSecondElement->GetWeight();
|
||||
});
|
||||
}
|
||||
|
||||
return arFindedElements;
|
||||
void CStyleStorage::ClearPageData()
|
||||
{
|
||||
m_arPageDatas.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
void CCssCalculator_Private::AddPageData(const std::wstring &wsPageNames, const std::wstring &wsStyles)
|
||||
const CElement* CStyleStorage::FindElement(const std::wstring& wsSelector)
|
||||
{
|
||||
m_arPageDatas.push_back({NS_STATIC_FUNCTIONS::GetWordsW(wsPageNames), NS_STATIC_FUNCTIONS::GetRules(wsStyles)});
|
||||
if (wsSelector.empty())
|
||||
return nullptr;
|
||||
|
||||
const CElement* pFoundElement = FindSelectorFromStyleData(wsSelector, m_mEmbeddedStyleData);
|
||||
|
||||
if (nullptr != pFoundElement)
|
||||
return pFoundElement;
|
||||
|
||||
for (std::vector<TStyleFileData*>::const_reverse_iterator itIter = m_arStyleFiles.crbegin(); itIter < m_arStyleFiles.crend(); ++itIter)
|
||||
{
|
||||
if (m_arAllowedStyleFiles.cend() == std::find(m_arAllowedStyleFiles.cbegin(), m_arAllowedStyleFiles.cend(), (*itIter)->m_wsStyleFilepath))
|
||||
continue;
|
||||
|
||||
pFoundElement = FindSelectorFromStyleData(wsSelector, (*itIter)->m_mStyleData);
|
||||
|
||||
if (nullptr != pFoundElement)
|
||||
return pFoundElement;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline void CCssCalculator_Private::GetStylesheet(const KatanaStylesheet *oStylesheet)
|
||||
|
||||
void CStyleStorage::AddStyles(const std::string& sStyle, std::map<std::wstring, CElement*>& mStyleData)
|
||||
{
|
||||
if (sStyle.empty())
|
||||
return;
|
||||
|
||||
KatanaOutput *output = katana_parse(sStyle.c_str(), sStyle.length(), KatanaParserModeStylesheet);
|
||||
this->GetOutputData(output, mStyleData);
|
||||
katana_destroy_output(output);
|
||||
}
|
||||
|
||||
void CStyleStorage::ClearEmbeddedStyles()
|
||||
{
|
||||
for (std::map<std::wstring, CElement*>::iterator oIter = m_mEmbeddedStyleData.begin(); oIter != m_mEmbeddedStyleData.end(); ++oIter)
|
||||
if (oIter->second != nullptr)
|
||||
delete oIter->second;
|
||||
|
||||
m_mEmbeddedStyleData.clear();
|
||||
}
|
||||
|
||||
void CStyleStorage::ClearAllowedStyleFiles()
|
||||
{
|
||||
m_arAllowedStyleFiles.clear();
|
||||
}
|
||||
|
||||
void CStyleStorage::GetStylesheet(const KatanaStylesheet* oStylesheet, std::map<std::wstring, CElement*>& mStyleData)
|
||||
{
|
||||
for (size_t i = 0; i < oStylesheet->imports.length; ++i)
|
||||
GetRule((KatanaRule*)oStylesheet->imports.data[i]);
|
||||
GetRule((KatanaRule*)oStylesheet->imports.data[i], mStyleData);
|
||||
|
||||
for (size_t i = 0; i < oStylesheet->rules.length; ++i)
|
||||
GetRule((KatanaRule*)oStylesheet->rules.data[i]);
|
||||
GetRule((KatanaRule*)oStylesheet->rules.data[i], mStyleData);
|
||||
}
|
||||
|
||||
inline void CCssCalculator_Private::GetRule(const KatanaRule *oRule)
|
||||
void CStyleStorage::GetRule(const KatanaRule* oRule, std::map<std::wstring, CElement*>& mStyleData)
|
||||
{
|
||||
if ( NULL == oRule )
|
||||
return;
|
||||
@ -273,7 +251,7 @@ namespace NSCSS
|
||||
switch (oRule->type) {
|
||||
case KatanaRuleStyle:
|
||||
{
|
||||
GetStyleRule((KatanaStyleRule*)oRule);
|
||||
GetStyleRule((KatanaStyleRule*)oRule, mStyleData);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -281,7 +259,7 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
inline void CCssCalculator_Private::GetStyleRule(const KatanaStyleRule *oRule)
|
||||
void CStyleStorage::GetStyleRule(const KatanaStyleRule* oRule, std::map<std::wstring, CElement*>& mStyleData)
|
||||
{
|
||||
if (oRule->declarations->length == 0)
|
||||
return;
|
||||
@ -297,7 +275,7 @@ namespace NSCSS
|
||||
|
||||
for (std::vector<std::wstring>::reverse_iterator oWord = arWords.rbegin(); oWord != arWords.rend(); ++oWord)
|
||||
{
|
||||
const size_t posPoint = oWord->find(L'.');
|
||||
const size_t posPoint = oWord->find(L'.');
|
||||
const size_t posLattice = oWord->find(L'#');
|
||||
|
||||
const std::wstring sName = (posPoint != std::wstring::npos) ? oWord->substr(0, posPoint) : (posLattice != std::wstring::npos) ? oWord->substr(0, posLattice) : *oWord;
|
||||
@ -313,8 +291,8 @@ namespace NSCSS
|
||||
{
|
||||
if (NULL == oFirstElement && bCreateFirst)
|
||||
{
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindId = m_mData.find(sId);
|
||||
if (oFindId != m_mData.end())
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindId = mStyleData.find(sId);
|
||||
if (oFindId != mStyleData.end())
|
||||
{
|
||||
oIdElement = oFindId->second;
|
||||
bCreateFirst = false;
|
||||
@ -342,8 +320,8 @@ namespace NSCSS
|
||||
{
|
||||
if (NULL == oFirstElement && bCreateFirst)
|
||||
{
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindClass = m_mData.find(sClass);
|
||||
if (oFindClass != m_mData.end())
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindClass = mStyleData.find(sClass);
|
||||
if (oFindClass != mStyleData.end())
|
||||
{
|
||||
oClassElement = oFindClass->second;
|
||||
bCreateFirst = false;
|
||||
@ -375,8 +353,8 @@ namespace NSCSS
|
||||
{
|
||||
if (NULL == oFirstElement && bCreateFirst)
|
||||
{
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindName = m_mData.find(sName);
|
||||
if (oFindName != m_mData.end())
|
||||
const std::map<std::wstring, CElement*>::const_iterator& oFindName = mStyleData.find(sName);
|
||||
if (oFindName != mStyleData.end())
|
||||
{
|
||||
oNameElement = oFindName->second;
|
||||
bCreateFirst = false;
|
||||
@ -408,11 +386,16 @@ namespace NSCSS
|
||||
oLastElement->AddProperties(mStyle);
|
||||
|
||||
if (NULL != oFirstElement)
|
||||
m_mData[oFirstElement->GetSelector()] = oFirstElement;
|
||||
mStyleData[oFirstElement->GetSelector()] = oFirstElement;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::vector<std::wstring> CCssCalculator_Private::GetSelectorList(const KatanaArray* oSelectors) const
|
||||
std::wstring CStyleStorage::GetValueList(const KatanaArray* oValues)
|
||||
{
|
||||
return StringifyValueList(oValues);
|
||||
}
|
||||
|
||||
std::vector<std::wstring> CStyleStorage::GetSelectorList(const KatanaArray* oSelectors) const
|
||||
{
|
||||
if (oSelectors->length == 0)
|
||||
return std::vector<std::wstring>();
|
||||
@ -425,7 +408,7 @@ namespace NSCSS
|
||||
return arSelectors;
|
||||
}
|
||||
|
||||
inline std::wstring CCssCalculator_Private::GetSelector(const KatanaSelector *oSelector) const
|
||||
std::wstring CStyleStorage::GetSelector(const KatanaSelector* oSelector) const
|
||||
{
|
||||
KatanaParser oParser;
|
||||
oParser.options = &kKatanaDefaultOptions;
|
||||
@ -444,7 +427,7 @@ namespace NSCSS
|
||||
return wsText;
|
||||
}
|
||||
|
||||
inline std::map<std::wstring, std::wstring> CCssCalculator_Private::GetDeclarationList(const KatanaArray* oDeclarations) const
|
||||
std::map<std::wstring, std::wstring> CStyleStorage::GetDeclarationList(const KatanaArray* oDeclarations) const
|
||||
{
|
||||
if(oDeclarations->length == 0)
|
||||
return std::map<std::wstring, std::wstring>();
|
||||
@ -457,7 +440,7 @@ namespace NSCSS
|
||||
return arDeclarations;
|
||||
}
|
||||
|
||||
inline std::pair<std::wstring, std::wstring> CCssCalculator_Private::GetDeclaration(const KatanaDeclaration* oDecl) const
|
||||
std::pair<std::wstring, std::wstring> CStyleStorage::GetDeclaration(const KatanaDeclaration* oDecl) const
|
||||
{
|
||||
std::wstring sValueList = StringifyValueList(oDecl->values);
|
||||
|
||||
@ -467,52 +450,213 @@ namespace NSCSS
|
||||
return std::make_pair(UTF8_TO_U(std::string(oDecl->property)), sValueList);
|
||||
}
|
||||
|
||||
inline std::wstring CCssCalculator_Private::GetValueList(const KatanaArray *oValues)
|
||||
void CStyleStorage::GetOutputData(KatanaOutput* oOutput, std::map<std::wstring, CElement*>& mStyleData)
|
||||
{
|
||||
return StringifyValueList(oValues);
|
||||
if ( NULL == oOutput )
|
||||
return;
|
||||
|
||||
switch (oOutput->mode) {
|
||||
case KatanaParserModeStylesheet:
|
||||
GetStylesheet(oOutput->stylesheet, mStyleData);
|
||||
break;
|
||||
case KatanaParserModeRule:
|
||||
GetRule(oOutput->rule, mStyleData);
|
||||
break;
|
||||
case KatanaParserModeKeyframeRule:
|
||||
case KatanaParserModeKeyframeKeyList:
|
||||
case KatanaParserModeMediaList:
|
||||
case KatanaParserModeValue:
|
||||
case KatanaParserModeSelector:
|
||||
case KatanaParserModeDeclarationList:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const CElement* CStyleStorage::FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData)
|
||||
{
|
||||
std::map<std::wstring, CElement*>::const_iterator itFound = mStyleData.find(wsSelector);
|
||||
|
||||
if (mStyleData.cend() != itFound)
|
||||
return itFound->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_sEncoding(L"UTF-8"){}
|
||||
|
||||
CCssCalculator_Private::~CCssCalculator_Private()
|
||||
{}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void CCssCalculator_Private::SetPageData(NSProperties::CPage &oPage, const std::map<std::wstring, std::wstring> &mData, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
//TODO:: пересмотреть данный метод
|
||||
m_oStyleStorage.SetPageData(oPage, mData, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
std::map<std::wstring, std::wstring> CCssCalculator_Private::GetPageData(const std::wstring &wsPageName)
|
||||
{
|
||||
return m_oStyleStorage.GetPageData(wsPageName);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::ClearPageData()
|
||||
{
|
||||
m_oStyleStorage.ClearPageData();
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
std::vector<std::wstring> arNodes;
|
||||
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode)
|
||||
{
|
||||
if (!oNode->m_wsName.empty())
|
||||
arNodes.push_back(oNode->m_wsName);
|
||||
|
||||
if (!oNode->m_wsClass.empty())
|
||||
{
|
||||
if (oNode->m_wsClass.find(L' ') != std::wstring::npos)
|
||||
{
|
||||
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' ';}));
|
||||
}
|
||||
else
|
||||
arNodes.push_back(L'.' + oNode->m_wsClass);
|
||||
}
|
||||
|
||||
if (!oNode->m_wsId.empty())
|
||||
arNodes.push_back(L'#' + oNode->m_wsId);
|
||||
}
|
||||
|
||||
return arNodes;
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::FindPrevAndKindElements(const CElement *pElement, const std::vector<std::wstring> &arNextNodes, std::vector<const CElement*>& arFindedElements, const std::wstring &wsName, const std::vector<std::wstring> &arClasses)
|
||||
{
|
||||
if (arNextNodes.empty())
|
||||
return;
|
||||
|
||||
const std::vector<CElement*> arTempPrev = pElement->GetPrevElements(arNextNodes.crbegin() + 1, arNextNodes.crend());
|
||||
const std::vector<CElement*> arTempKins = pElement->GetNextOfKin(wsName, arClasses);
|
||||
|
||||
if (!arTempPrev.empty())
|
||||
arFindedElements.insert(arFindedElements.end(), arTempPrev.begin(), arTempPrev.end());
|
||||
|
||||
if (!arTempKins.empty())
|
||||
arFindedElements.insert(arFindedElements.end(), arTempKins.begin(), arTempKins.end());
|
||||
}
|
||||
|
||||
std::vector<const CElement*> CCssCalculator_Private::FindElements(std::vector<std::wstring> &arNodes, std::vector<std::wstring> &arNextNodes)
|
||||
{
|
||||
if (arNodes.empty())
|
||||
return {};
|
||||
|
||||
std::vector<const CElement*> arFindedElements;
|
||||
|
||||
std::wstring wsName, 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());
|
||||
arNodes.pop_back();
|
||||
}
|
||||
|
||||
if (!arNodes.empty())
|
||||
{
|
||||
wsName = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsName);
|
||||
}
|
||||
|
||||
if (!wsId.empty())
|
||||
{
|
||||
const CElement* pFoundId = m_oStyleStorage.FindElement(wsId);
|
||||
|
||||
if(nullptr != pFoundId)
|
||||
{
|
||||
if (!pFoundId->Empty())
|
||||
arFindedElements.push_back(pFoundId);
|
||||
|
||||
FindPrevAndKindElements(pFoundId, arNextNodes, arFindedElements, wsName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!arClasses.empty())
|
||||
{
|
||||
for (std::vector<std::wstring>::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass)
|
||||
{
|
||||
const CElement* pFoundClass = m_oStyleStorage.FindElement(*iClass);
|
||||
|
||||
if (nullptr != pFoundClass)
|
||||
{
|
||||
if (!pFoundClass->Empty())
|
||||
arFindedElements.push_back(pFoundClass);
|
||||
|
||||
FindPrevAndKindElements(pFoundClass, arNextNodes, arFindedElements, wsName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const CElement* pFoundName = m_oStyleStorage.FindElement(wsName);
|
||||
|
||||
if (nullptr != pFoundName)
|
||||
{
|
||||
if (!pFoundName->Empty())
|
||||
arFindedElements.push_back(pFoundName);
|
||||
|
||||
FindPrevAndKindElements(pFoundName, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
|
||||
if (arFindedElements.size() > 1)
|
||||
{
|
||||
std::sort(arFindedElements.rbegin(), arFindedElements.rend(),
|
||||
[](const CElement* oFirstElement, const CElement* oSecondElement)
|
||||
{ return oFirstElement->GetWeight() > oSecondElement->GetWeight(); });
|
||||
}
|
||||
|
||||
return arFindedElements;
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector<CNode>& arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure)
|
||||
CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector<CNode>& arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return CCompiledStyle();
|
||||
|
||||
CCompiledStyle oStyle;
|
||||
|
||||
GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
|
||||
GetCompiledStyle(oStyle, arSelectors);
|
||||
|
||||
return oStyle;
|
||||
}
|
||||
|
||||
bool CCssCalculator_Private::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure)
|
||||
bool CCssCalculator_Private::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
SetUnitMeasure(unitMeasure);
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (!bIsSettings)
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
oStyle = oItem->second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (NULL == m_mStatictics || m_mStatictics->empty())
|
||||
{
|
||||
oStyle.SetDpi(m_nDpi);
|
||||
oStyle.SetUnitMeasure(m_UnitMeasure);
|
||||
oStyle.SetID(arSelectors.back().m_wsName + ((!arSelectors.back().m_wsClass.empty()) ? L'.' + arSelectors.back().m_wsClass : L"") + ((arSelectors.back().m_wsId.empty()) ? L"" : L'#' + arSelectors.back().m_wsId) + L'-' + std::to_wstring(++m_nCountNodes));
|
||||
|
||||
return false;
|
||||
oStyle = oItem->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
oStyle.SetDpi(m_nDpi);
|
||||
oStyle.SetUnitMeasure(m_UnitMeasure);
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors);
|
||||
std::vector<std::wstring> arPrevNodes;
|
||||
@ -535,25 +679,10 @@ namespace NSCSS
|
||||
|
||||
oTempStyle.AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes, bIsSettings))
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes))
|
||||
oTempStyle.AddStyle(oElement->GetStyle(), i + 1);
|
||||
|
||||
if (NULL != m_mStatictics)
|
||||
{
|
||||
std::map<StatistickElement, unsigned int>::const_iterator oFindCountStyle = m_mStatictics->find(StatistickElement{StatistickElement::IsStyle, arSelectors[i].m_wsStyle});
|
||||
|
||||
if (oFindCountStyle != m_mStatictics->end())
|
||||
{
|
||||
if ((bIsSettings && oFindCountStyle->second < MaxNumberRepetitions) ||
|
||||
(!bIsSettings && oFindCountStyle->second >= MaxNumberRepetitions))
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
else if (!bIsSettings)
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
}
|
||||
else /*if (bIsSettings)*/
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
}
|
||||
else
|
||||
if (!arSelectors[i].m_wsStyle.empty())
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
|
||||
oStyle += oTempStyle;
|
||||
@ -569,7 +698,7 @@ namespace NSCSS
|
||||
|
||||
oStyle.SetID(CalculateStyleId(arSelectors.back()));
|
||||
|
||||
if (!bIsSettings && !oStyle.Empty())
|
||||
if (!oStyle.Empty())
|
||||
m_mUsedStyles[arSelectors] = oStyle;
|
||||
|
||||
return true;
|
||||
@ -597,7 +726,7 @@ namespace NSCSS
|
||||
SetPageData(oPageData, GetPageData(mRules[L"page"]), i + 1, true);
|
||||
}
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arNextNodes, false))
|
||||
for (const CElement* oElement : FindElements(arNodes, arNextNodes))
|
||||
{
|
||||
std::map<std::wstring, std::wstring> mRules = oElement->GetStyle();
|
||||
if (mRules.end() != mRules.find(L"page"))
|
||||
@ -611,42 +740,20 @@ namespace NSCSS
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
void CCssCalculator_Private::AddStyles(const std::string &sStyle)
|
||||
{
|
||||
if (sStyle.empty())
|
||||
return;
|
||||
|
||||
KatanaOutput *output = katana_parse(sStyle.c_str(), sStyle.length(), KatanaParserModeStylesheet);
|
||||
this->GetOutputData(output);
|
||||
katana_destroy_output(output);
|
||||
void CCssCalculator_Private::AddStyles(const std::string& sStyle)
|
||||
{
|
||||
m_oStyleStorage.AddStyles(sStyle);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::AddStyles(const std::wstring &wsStyle)
|
||||
void CCssCalculator_Private::AddStyles(const std::wstring& wsStyle)
|
||||
{
|
||||
if (wsStyle.empty())
|
||||
return;
|
||||
|
||||
std::wregex oRegex(L"@page\\s*([^{]*)(\\{[^}]*\\})");
|
||||
std::wsmatch oMatch;
|
||||
std::wstring::const_iterator oSearchStart(wsStyle.cbegin());
|
||||
|
||||
while (std::regex_search(oSearchStart, wsStyle.cend(), oMatch, oRegex))
|
||||
{
|
||||
AddPageData(oMatch[1].str(), oMatch[2].str());
|
||||
oSearchStart = oMatch.suffix().first;
|
||||
}
|
||||
|
||||
AddStyles(U_TO_UTF8(wsStyle));
|
||||
m_oStyleStorage.AddStyles(wsStyle);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::AddStylesFromFile(const std::wstring& wsFileName)
|
||||
{
|
||||
if (std::find(m_arFiles.begin(), m_arFiles.end(), wsFileName) != m_arFiles.end())
|
||||
return;
|
||||
|
||||
m_arFiles.push_back(wsFileName);
|
||||
|
||||
AddStyles(NS_STATIC_FUNCTIONS::GetContentAsUTF8(wsFileName));
|
||||
m_oStyleStorage.AddStylesFromFile(wsFileName);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetDpi(unsigned short int nValue)
|
||||
@ -654,32 +761,28 @@ namespace NSCSS
|
||||
m_nDpi = nValue;
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetBodyTree(const CTree &oTree)
|
||||
{
|
||||
if (NULL == m_mStatictics)
|
||||
m_mStatictics = new std::map<StatistickElement, unsigned int>();
|
||||
|
||||
CTree::CountingNumberRepetitions(oTree, *m_mStatictics);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetUnitMeasure(const UnitMeasure& nType)
|
||||
{
|
||||
m_UnitMeasure = nType;
|
||||
}
|
||||
|
||||
unsigned short int CCssCalculator_Private::GetDpi() const
|
||||
{
|
||||
return m_nDpi;
|
||||
}
|
||||
|
||||
const std::map<std::wstring, CElement *> *CCssCalculator_Private::GetData() const
|
||||
void CCssCalculator_Private::ClearEmbeddedStyles()
|
||||
{
|
||||
return &m_mData;
|
||||
m_oStyleStorage.ClearEmbeddedStyles();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
m_mUsedStyles.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
UnitMeasure CCssCalculator_Private::GetUnitMeasure() const
|
||||
void CCssCalculator_Private::ClearAllowedStyleFiles()
|
||||
{
|
||||
return m_UnitMeasure;
|
||||
m_oStyleStorage.ClearAllowedStyleFiles();
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::ClearStylesFromFile(const std::wstring& wsFilePath)
|
||||
{
|
||||
m_oStyleStorage.ClearStylesFromFile(wsFilePath);
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator_Private::GetEncoding() const
|
||||
@ -691,12 +794,22 @@ namespace NSCSS
|
||||
{
|
||||
m_sEncoding = L"UTF-8";
|
||||
m_nDpi = 96;
|
||||
m_UnitMeasure = Point;
|
||||
|
||||
m_mData.clear();
|
||||
m_arFiles.clear();
|
||||
m_oStyleStorage.Clear();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
m_mUsedStyles.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsTableElement(const std::wstring& wsNameTag)
|
||||
{
|
||||
return L"td" == wsNameTag || L"tr" == wsNameTag || L"table" == wsNameTag ||
|
||||
L"tbody" == wsNameTag || L"thead" == wsNameTag || L"tfoot" == wsNameTag ||
|
||||
L"th" == wsNameTag;
|
||||
}
|
||||
}
|
||||
|
||||
inline static std::wstring StringifyValueList(const KatanaArray* oValues)
|
||||
{
|
||||
if (NULL == oValues)
|
||||
@ -797,11 +910,4 @@ inline static std::wstring StringifyValue(const KatanaValue* oValue)
|
||||
return str;
|
||||
}
|
||||
|
||||
inline static bool IsTableElement(const std::wstring& wsNameTag)
|
||||
{
|
||||
return L"td" == wsNameTag || L"tr" == wsNameTag || L"table" == wsNameTag ||
|
||||
L"tbody" == wsNameTag || L"thead" == wsNameTag || L"tfoot" == wsNameTag ||
|
||||
L"th" == wsNameTag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,11 +3,9 @@
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <functional>
|
||||
#include <set>
|
||||
#include "CElement.h"
|
||||
#include "ConstValues.h"
|
||||
#include "CUnitMeasureConverter.h"
|
||||
#include "StyleProperties.h"
|
||||
#include "../../katana-parser/src/katana.h"
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
@ -16,16 +14,43 @@
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
class CCssCalculator_Private
|
||||
class CStyleStorage
|
||||
{
|
||||
unsigned short int m_nDpi;
|
||||
unsigned short int m_nCountNodes;
|
||||
UnitMeasure m_UnitMeasure;
|
||||
public:
|
||||
CStyleStorage();
|
||||
~CStyleStorage();
|
||||
|
||||
std::list<std::wstring> m_arFiles;
|
||||
void Clear();
|
||||
|
||||
std::map<std::wstring, CElement*> m_mData;
|
||||
void AddStyles(const std::string& sStyle);
|
||||
void AddStyles(const std::wstring& wsStyle);
|
||||
void AddStylesFromFile(const std::wstring& wsFileName);
|
||||
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
void ClearStylesFromFile(const std::wstring& wsFileName);
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void AddPageData(const std::wstring& wsPageName, const std::wstring& wsStyles);
|
||||
void SetPageData(NSProperties::CPage& oPage, const std::map<std::wstring, std::wstring>& mData, unsigned int unLevel, bool bHardMode = false);
|
||||
std::map<std::wstring, std::wstring> GetPageData(const std::wstring& wsPageName);
|
||||
void ClearPageData();
|
||||
#endif
|
||||
|
||||
const CElement* FindElement(const std::wstring& wsSelector);
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
std::wstring m_wsStyleFilepath;
|
||||
std::map<std::wstring, CElement*> m_mStyleData;
|
||||
} TStyleFileData;
|
||||
|
||||
std::set<std::wstring> m_arEmptyStyleFiles;
|
||||
std::set<std::wstring> m_arAllowedStyleFiles;
|
||||
std::vector<TStyleFileData*> m_arStyleFiles;
|
||||
std::map<std::wstring, CElement*> m_mEmbeddedStyleData;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
typedef struct
|
||||
{
|
||||
std::vector<std::wstring> m_wsNames;
|
||||
@ -33,29 +58,14 @@ namespace NSCSS
|
||||
} TPageData;
|
||||
|
||||
std::vector<TPageData> m_arPageDatas;
|
||||
|
||||
std::map<StatistickElement, unsigned int> *m_mStatictics; // Количество повторений свойств id и style у селекторов
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
std::map<std::vector<CNode>, CCompiledStyle> m_mUsedStyles;
|
||||
|
||||
std::map<std::wstring, std::wstring> GetPageData(const std::wstring& wsPageName);
|
||||
void SetPageData(NSProperties::CPage& oPage, const std::map<std::wstring, std::wstring>& mData, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors);
|
||||
|
||||
void FindPrevAndKindElements(const CElement* pElement, const std::vector<std::wstring>& arNextNodes, std::vector<CElement*>& arFindedElements, const std::wstring& wsName, const std::vector<std::wstring>& arClasses = {});
|
||||
std::vector<CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes, bool bIsSettings);
|
||||
#endif
|
||||
private:
|
||||
void AddStyles(const std::string& sStyle, std::map<std::wstring, CElement*>& mStyleData);
|
||||
|
||||
std::wstring m_sEncoding;
|
||||
void GetStylesheet(const KatanaStylesheet* oStylesheet, std::map<std::wstring, CElement*>& mStyleData);
|
||||
void GetRule(const KatanaRule* oRule, std::map<std::wstring, CElement*>& mStyleData);
|
||||
|
||||
void AddPageData(const std::wstring& wsPageName, const std::wstring& wsStyles);
|
||||
|
||||
void GetStylesheet(const KatanaStylesheet* oStylesheet);
|
||||
void GetRule(const KatanaRule* oRule);
|
||||
|
||||
void GetStyleRule(const KatanaStyleRule* oRule);
|
||||
void GetStyleRule(const KatanaStyleRule* oRule, std::map<std::wstring, CElement*>& mStyleData);
|
||||
|
||||
std::wstring GetValueList(const KatanaArray* oValues);
|
||||
|
||||
@ -65,36 +75,60 @@ namespace NSCSS
|
||||
std::map<std::wstring, std::wstring> GetDeclarationList(const KatanaArray* oDeclarations) const;
|
||||
std::pair<std::wstring, std::wstring> GetDeclaration(const KatanaDeclaration* oDecl) const;
|
||||
|
||||
void GetOutputData(KatanaOutput* oOutput);
|
||||
void GetOutputData(KatanaOutput* oOutput, std::map<std::wstring, CElement*>& mStyleData);
|
||||
|
||||
const CElement* FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData);
|
||||
};
|
||||
|
||||
class CCssCalculator_Private
|
||||
{
|
||||
unsigned short int m_nDpi;
|
||||
unsigned short int m_nCountNodes;
|
||||
|
||||
CStyleStorage m_oStyleStorage;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
std::map<std::vector<CNode>, CCompiledStyle> m_mUsedStyles;
|
||||
|
||||
void SetPageData(NSProperties::CPage& oPage, const std::map<std::wstring, std::wstring>& mData, unsigned int unLevel, bool bHardMode = false);
|
||||
std::map<std::wstring, std::wstring> GetPageData(const std::wstring &wsPageName);
|
||||
#endif
|
||||
|
||||
void FindPrevAndKindElements(const CElement* pElement, const std::vector<std::wstring>& arNextNodes, std::vector<const CElement*>& arFindedElements, const std::wstring& wsName, const std::vector<std::wstring>& arClasses = {});
|
||||
|
||||
std::wstring m_sEncoding;
|
||||
public:
|
||||
CCssCalculator_Private();
|
||||
~CCssCalculator_Private();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point);
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point);
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors);
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors);
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
|
||||
void ClearPageData();
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors);
|
||||
std::vector<const CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes);
|
||||
|
||||
void AddStyles(const std::string& sStyle);
|
||||
void AddStyles(const std::wstring& wsStyle);
|
||||
void AddStylesFromFile(const std::wstring& wsFileName);
|
||||
|
||||
void SetUnitMeasure(const UnitMeasure& nType);
|
||||
void SetDpi(unsigned short int nValue);
|
||||
void SetBodyTree(const CTree &oTree);
|
||||
|
||||
UnitMeasure GetUnitMeasure() const;
|
||||
std::wstring GetEncoding() const;
|
||||
unsigned short int GetDpi() const;
|
||||
|
||||
const std::map<std::wstring, CElement*>* GetData() const;
|
||||
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
void ClearStylesFromFile(const std::wstring& wsFilePath);
|
||||
void Clear();
|
||||
|
||||
};
|
||||
|
||||
inline bool IsTableElement(const std::wstring& wsNameTag);
|
||||
}
|
||||
#endif // CCSSCALCULATOR_PRIVATE_H
|
||||
|
||||
@ -40,6 +40,7 @@ namespace NSCSS
|
||||
{
|
||||
m_sSelector = sSelector;
|
||||
m_sFullSelector = m_sSelector;
|
||||
UpdateWeight();
|
||||
}
|
||||
|
||||
void NSCSS::CElement::AddPropertie(const std::wstring &sName, const std::wstring& sValue)
|
||||
@ -67,6 +68,7 @@ namespace NSCSS
|
||||
|
||||
m_arPrevElements.push_back(oPrevElement);
|
||||
oPrevElement->m_sFullSelector += L' ' + m_sFullSelector;
|
||||
UpdateWeight();
|
||||
}
|
||||
|
||||
void CElement::AddKinElement(CElement *oKinElement)
|
||||
@ -76,6 +78,7 @@ namespace NSCSS
|
||||
|
||||
m_arKinElements.push_back(oKinElement);
|
||||
oKinElement->m_sFullSelector += m_sFullSelector;
|
||||
oKinElement->UpdateWeight();
|
||||
}
|
||||
|
||||
std::map<std::wstring, std::wstring> CElement::GetStyle() const
|
||||
@ -230,11 +233,14 @@ namespace NSCSS
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<unsigned short> CElement::GetWeight()
|
||||
void CElement::UpdateWeight()
|
||||
{
|
||||
if (m_arWeight.empty())
|
||||
m_arWeight = NS_STATIC_FUNCTIONS::GetWeightSelector(m_sFullSelector);
|
||||
}
|
||||
|
||||
std::vector<unsigned short> CElement::GetWeight() const
|
||||
{
|
||||
return m_arWeight;
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,8 @@ namespace NSCSS
|
||||
|
||||
CElement *FindPrevElement(const std::wstring& sSelector) const;
|
||||
|
||||
std::vector<unsigned short int> GetWeight();
|
||||
void UpdateWeight();
|
||||
std::vector<unsigned short int> GetWeight() const;
|
||||
void IncreasedWeight();
|
||||
};
|
||||
}
|
||||
|
||||
@ -2,29 +2,6 @@
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
bool StatistickElement::operator<(const StatistickElement &oStatistickElement) const
|
||||
{
|
||||
return sValue < oStatistickElement.sValue;
|
||||
}
|
||||
|
||||
void CTree::Clear()
|
||||
{
|
||||
m_arrChild.clear();
|
||||
m_oNode.Clear();
|
||||
}
|
||||
|
||||
void CTree::CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics)
|
||||
{
|
||||
if (!oTree.m_oNode.m_wsId.empty())
|
||||
++mStatictics[StatistickElement{StatistickElement::IsId, L'#' + oTree.m_oNode.m_wsId}];
|
||||
if (!oTree.m_oNode.m_wsStyle.empty())
|
||||
++mStatictics[StatistickElement{StatistickElement::IsStyle, oTree.m_oNode.m_wsStyle}];
|
||||
|
||||
if (!oTree.m_arrChild.empty())
|
||||
for (const CTree& oChildren : oTree.m_arrChild)
|
||||
CountingNumberRepetitions(oChildren, mStatictics);
|
||||
}
|
||||
|
||||
namespace NSConstValues
|
||||
{
|
||||
const std::map<std::wstring, std::wstring> COLORS
|
||||
|
||||
@ -16,28 +16,6 @@ namespace NSCSS
|
||||
ScalingDirectionY = 2
|
||||
} ScalingDirection;
|
||||
|
||||
struct StatistickElement
|
||||
{
|
||||
enum TypeElement
|
||||
{
|
||||
IsStyle = 0,
|
||||
IsId
|
||||
} m_enType;
|
||||
std::wstring sValue;
|
||||
|
||||
bool operator<(const StatistickElement& oStatistickElement) const;
|
||||
};
|
||||
|
||||
struct CTree
|
||||
{
|
||||
NSCSS::CNode m_oNode;
|
||||
std::vector<CTree> m_arrChild;
|
||||
|
||||
void Clear();
|
||||
|
||||
static void CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics);
|
||||
};
|
||||
|
||||
namespace NSConstValues
|
||||
{
|
||||
extern const std::map<std::wstring, std::wstring> COLORS;
|
||||
|
||||
@ -48,7 +48,6 @@ namespace NS_STATIC_FUNCTIONS
|
||||
if (sEncoding.empty())
|
||||
sEncoding = "utf-8";
|
||||
|
||||
|
||||
if (!sEncoding.empty() && sEncoding != "utf-8" && sEncoding != "UTF-8")
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
|
||||
@ -513,6 +513,9 @@ namespace NSCSS
|
||||
return (*static_cast<std::wstring*>(m_oValue)) == (*static_cast<std::wstring*>(oColor.m_oValue));
|
||||
case ColorUrl:
|
||||
return (*static_cast<CURL*>(m_oValue)) == (*static_cast<CURL*>(oColor.m_oValue));
|
||||
case ColorContextStroke:
|
||||
case ColorContextFill:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -532,6 +535,9 @@ namespace NSCSS
|
||||
return (*static_cast<std::wstring*>(m_oValue)) != (*static_cast<std::wstring*>(oColor.m_oValue));
|
||||
case ColorUrl:
|
||||
return (*static_cast<CURL*>(m_oValue)) != (*static_cast<CURL*>(oColor.m_oValue));
|
||||
case ColorContextStroke:
|
||||
case ColorContextFill:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -561,6 +567,9 @@ namespace NSCSS
|
||||
m_oValue = new CURL(*static_cast<CURL*>(oColor.m_oValue));
|
||||
break;
|
||||
}
|
||||
case ColorContextStroke:
|
||||
case ColorContextFill:
|
||||
break;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -580,6 +589,39 @@ namespace NSCSS
|
||||
: CValue(NULL, 0, false), m_oOpacity(1.), m_enType(ColorEmpty)
|
||||
{}
|
||||
|
||||
CColor::CColor(const CColor& oColor)
|
||||
: CValue(NULL, 0, false), m_oOpacity(oColor.m_oOpacity), m_enType(oColor.m_enType)
|
||||
{
|
||||
switch (m_enType)
|
||||
{
|
||||
case ColorRGB:
|
||||
{
|
||||
TRGB *pRGB = static_cast<TRGB*>(oColor.m_oValue);
|
||||
m_oValue = new TRGB(*pRGB);
|
||||
break;
|
||||
}
|
||||
case ColorHEX:
|
||||
{
|
||||
std::wstring* pValue = static_cast<std::wstring*>(oColor.m_oValue);
|
||||
m_oValue = new std::wstring(*pValue);
|
||||
break;
|
||||
}
|
||||
case ColorUrl:
|
||||
{
|
||||
CURL *pURL = static_cast<CURL*>(oColor.m_oValue);
|
||||
m_oValue = new CURL(*pURL);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CColor::~CColor()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void CColor::SetEmpty(unsigned int unLevel)
|
||||
{
|
||||
Clear();
|
||||
@ -875,6 +917,25 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring CColor::ToHEX() const
|
||||
{
|
||||
switch(m_enType)
|
||||
{
|
||||
case ColorRGB:
|
||||
{
|
||||
TRGB* pRGB = static_cast<TRGB*>(m_oValue);
|
||||
return ConvertRGBtoHEX(*pRGB);
|
||||
}
|
||||
case ColorHEX:
|
||||
{
|
||||
std::wstring *pValue = static_cast<std::wstring*>(m_oValue);
|
||||
return *pValue;
|
||||
}
|
||||
default:
|
||||
return std::wstring();
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring CColor::EquateToColor(const std::vector<std::pair<TRGB, std::wstring>> &arColors) const
|
||||
{
|
||||
if (arColors.empty())
|
||||
|
||||
@ -224,6 +224,8 @@ namespace NSCSS
|
||||
{
|
||||
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);
|
||||
@ -240,6 +242,7 @@ namespace NSCSS
|
||||
int ToInt() const override;
|
||||
double ToDouble() const override;
|
||||
std::wstring ToWString() const override;
|
||||
std::wstring ToHEX() const;
|
||||
std::wstring EquateToColor(const std::vector<std::pair<TRGB, std::wstring>>& arColors) const;
|
||||
TRGB ToRGB() const;
|
||||
|
||||
|
||||
@ -316,7 +316,7 @@ namespace NSCSS
|
||||
|
||||
std::wstring wsTextAlign{oStyle.m_oText.GetAlign().ToWString()};
|
||||
|
||||
if (wsTextAlign.empty() && bInTable)
|
||||
if (wsTextAlign.empty())
|
||||
wsTextAlign = oStyle.m_oDisplay.GetHAlign().ToWString();
|
||||
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_Jc, wsTextAlign);
|
||||
@ -485,7 +485,7 @@ namespace NSCSS
|
||||
return;
|
||||
|
||||
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. + 0.5))); // Значения шрифта увеличивает на 2
|
||||
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
|
||||
|
||||
if (oStyle.m_oText.GetDecoration().m_oLine.Underline())
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_U, (!oStyle.m_oText.GetDecoration().m_oStyle.Empty()) ? oStyle.m_oText.GetDecoration().m_oStyle.ToWString() : L"single");
|
||||
|
||||
@ -244,3 +244,4 @@
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_LIMITS (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005d)
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_ROWLIMITS (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005e)
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_DETECT (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005f)
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_CELLLIMITS (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x0060)
|
||||
|
||||
@ -68,6 +68,7 @@ public:
|
||||
bool isOOXFormatFile(const std::wstring& fileName, bool unpacked = false);
|
||||
bool isOpenOfficeFormatFile(const std::wstring& fileName, std::wstring& documentID);
|
||||
bool isOnlyOfficeFormatFile(const std::wstring& fileName);
|
||||
bool isMacFormatFile(const std::wstring& fileName);
|
||||
|
||||
bool isDocFormatFile(const std::wstring& fileName);
|
||||
bool isXlsFormatFile(const std::wstring& fileName);
|
||||
@ -80,6 +81,7 @@ public:
|
||||
bool isMS_MITCRYPTOFormatFile(POLE::Storage* storage, std::wstring& documentID);
|
||||
bool isVbaProjectFile(POLE::Storage* storage);
|
||||
bool isMS_OFFCRYPTOFormatFile(const std::wstring& fileName, std::wstring& documentID);
|
||||
bool isHwpFile(POLE::Storage* storage);
|
||||
|
||||
bool iXmlFile(const std::wstring& fileName);
|
||||
|
||||
|
||||
@ -451,6 +451,20 @@ bool COfficeFileFormatChecker::isVbaProjectFile(POLE::Storage *storage)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isHwpFile(POLE::Storage* storage)
|
||||
{
|
||||
if (storage == NULL)
|
||||
return false;
|
||||
|
||||
unsigned char buffer[10];
|
||||
|
||||
POLE::Stream stream(storage, L"BodyText/Section0");
|
||||
if (stream.read(buffer, 10) < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isXlsFormatFile(POLE::Storage *storage)
|
||||
{
|
||||
if (storage == NULL)
|
||||
@ -721,6 +735,11 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_VBAPROJECT;
|
||||
return true;
|
||||
}
|
||||
else if (isHwpFile(&storage))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
NSFile::CFileBinary file;
|
||||
if (!file.OpenFile(fileName))
|
||||
@ -740,13 +759,40 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
if (OfficeUtils.IsArchive(fileName) == S_OK && (false == isPdfFormatFile(bufferDetect, dwDetectdBytes, sDocumentID)))
|
||||
{
|
||||
if (isOOXFormatFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isOpenOfficeFormatFile(fileName, sDocumentID))
|
||||
return true;
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isOnlyOfficeFormatFile(fileName))
|
||||
return true;
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isXpsFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isMacFormatFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
@ -879,6 +925,16 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY;
|
||||
else if (0 == sExt.compare(L".txt") || 0 == sExt.compare(L".xml") || 0 == sExt.compare(L".rtf") || 0 == sExt.compare(L".doc") || 0 == sExt.compare(L".docx") || 0 == sExt.compare(L".md"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
|
||||
else if (0 == sExt.compare(L".pages"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
else if (0 == sExt.compare(L".numbers"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
else if (0 == sExt.compare(L".key"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
else if (0 == sExt.compare(L".hwp"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
else if (0 == sExt.compare(L".hwpx"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
|
||||
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
|
||||
return true;
|
||||
@ -1103,6 +1159,58 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring &fileNa
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName)
|
||||
{
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
|
||||
ULONG nBufferSize = 0;
|
||||
BYTE* pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Document.iwa", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Slide.iwa", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
return true;
|
||||
}
|
||||
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Tables/DataList.iwa", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
return true;
|
||||
}
|
||||
std::wstring::size_type nExtPos = fileName.rfind(L'.');
|
||||
std::wstring sExt = L"unknown";
|
||||
|
||||
if (nExtPos != std::wstring::npos)
|
||||
sExt = fileName.substr(nExtPos);
|
||||
|
||||
std::transform(sExt.begin(), sExt.end(), sExt.begin(), tolower);
|
||||
|
||||
if (0 == sExt.compare(L".pages"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
else if (0 == sExt.compare(L".numbers"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
else if (0 == sExt.compare(L".key"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring &fileName, std::wstring &documentID)
|
||||
{
|
||||
documentID.clear();
|
||||
@ -1345,6 +1453,7 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM:
|
||||
return L".dotm";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC:
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC_FLAT:
|
||||
return L".doc";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT:
|
||||
return L".odt";
|
||||
|
||||
@ -56,6 +56,9 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0015
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0016
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0017
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0018
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0019
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0020
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_XML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0030
|
||||
|
||||
@ -72,6 +75,7 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000a
|
||||
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX_PACKAGE AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000b
|
||||
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000c
|
||||
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000d
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET 0x0100
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0001
|
||||
@ -87,6 +91,7 @@
|
||||
#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_CROSSPLATFORM 0x0200
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0001
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include <stdio.h>
|
||||
#define LOG_BUFFER_SIZE 1000
|
||||
|
||||
// not intended for use in production. only for testing/debugging purposes
|
||||
namespace Logging
|
||||
{
|
||||
void logBytes(char* name, unsigned char* str, int len)
|
||||
|
||||
@ -847,40 +847,10 @@ namespace agg
|
||||
if (calculate_tensor_coefs)
|
||||
calculate_tensor();
|
||||
|
||||
float minxres = m_oGradientInfo.shading.patch[0][0].x;
|
||||
float minyres = m_oGradientInfo.shading.patch[0][0].y;
|
||||
float maxxres = m_oGradientInfo.shading.patch[0][0].x;
|
||||
float maxyres = m_oGradientInfo.shading.patch[0][0].y;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (m_oGradientInfo.shading.patch[i][j].x > maxxres)
|
||||
{
|
||||
maxxres = m_oGradientInfo.shading.patch[i][j].x;
|
||||
}
|
||||
if (m_oGradientInfo.shading.patch[i][j].y > maxyres)
|
||||
{
|
||||
maxyres = m_oGradientInfo.shading.patch[i][j].y;
|
||||
}
|
||||
if (m_oGradientInfo.shading.patch[i][j].x < minxres)
|
||||
{
|
||||
minxres = m_oGradientInfo.shading.patch[i][j].x;
|
||||
}
|
||||
if (m_oGradientInfo.shading.patch[i][j].y < minyres)
|
||||
{
|
||||
minyres = m_oGradientInfo.shading.patch[i][j].y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RES = std::max(1.0f, std::max(maxxres - minxres, maxyres - minyres) / 3);
|
||||
float delta = 1.0 / RES;
|
||||
float u = 0, v = 0;
|
||||
auto start_p = get_p_curve(u, v);
|
||||
xmax_curve = xmin_curve = start_p.x;
|
||||
ymax_curve = ymin_curve = start_p.y;
|
||||
precalc = std::vector<std::vector<ColorT>>(RES, std::vector<ColorT>(RES, {0, 0, 0, 0}));
|
||||
|
||||
/*
|
||||
* Небольшая оптимизация основанная на том, что данная фигура не выходит за границы своих опорных точек.
|
||||
@ -918,7 +888,7 @@ namespace agg
|
||||
RES = nRES;
|
||||
}
|
||||
precalc = std::vector<std::vector<ColorT>>(RES, std::vector<ColorT>(RES, {0, 0, 0, 0}));
|
||||
delta = 1.0f / RES;
|
||||
float delta = 1.0f / RES;
|
||||
std::vector<std::pair<int, int>> next_indexes(RES + 1);
|
||||
u = 0;
|
||||
for (int i = 0; i < RES; ++i)
|
||||
@ -956,8 +926,6 @@ namespace agg
|
||||
}
|
||||
ColorT ifswapRGB(const ColorT &c)
|
||||
{
|
||||
|
||||
|
||||
if (m_bSwapRGB) {
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -1535,6 +1535,11 @@ namespace NSFile
|
||||
return bIsSuccess;
|
||||
}
|
||||
|
||||
bool CFileBinary::IsGlobalTempPathUse()
|
||||
{
|
||||
return g_overrideTmpPath.empty() ? false : true;
|
||||
}
|
||||
|
||||
std::wstring CFileBinary::GetTempPath()
|
||||
{
|
||||
if (!g_overrideTmpPath.empty())
|
||||
|
||||
@ -189,6 +189,7 @@ namespace NSFile
|
||||
|
||||
static void SetTempPath(const std::wstring& strTempPath);
|
||||
static std::wstring GetTempPath();
|
||||
static bool IsGlobalTempPathUse();
|
||||
|
||||
static std::wstring CreateTempFileWithUniqueName(const std::wstring& strFolderPathRoot, const std::wstring& Prefix);
|
||||
static bool OpenTempFile(std::wstring *pwsName, FILE **ppFile, wchar_t *wsMode, wchar_t *wsExt, wchar_t *wsFolder, wchar_t* wsName = NULL);
|
||||
|
||||
@ -682,9 +682,10 @@ namespace NSStringUtils
|
||||
}
|
||||
if (val < 0)
|
||||
{
|
||||
val = -val;
|
||||
if (val < 0)
|
||||
if (val == -2147483648)
|
||||
val = 2147483647;
|
||||
else
|
||||
val = -val;
|
||||
|
||||
*m_pDataCur++ = (wchar_t)'-';
|
||||
++m_lSizeCur;
|
||||
|
||||
60
DesktopEditor/doctrenderer/addon/docbuilder_addon.h
Normal file
60
DesktopEditor/doctrenderer/addon/docbuilder_addon.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef DOC_BUILDER_ADDON_PRIVATE
|
||||
#define DOC_BUILDER_ADDON_PRIVATE
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
class CDocBuilderAddon
|
||||
{
|
||||
private:
|
||||
std::wstring m_sWorkDirectory;
|
||||
public:
|
||||
CDocBuilderAddon(const std::wstring& sWorkDir)
|
||||
{
|
||||
m_sWorkDirectory = sWorkDir;
|
||||
}
|
||||
public:
|
||||
std::wstring GetX2tSaveAddon()
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
int GetX2tPreSaveError()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DOC_BUILDER_ADDON_PRIVATE
|
||||
@ -38,6 +38,9 @@
|
||||
#include "../xml/include/xmlutils.h"
|
||||
#include "../fontengine/TextHyphen.h"
|
||||
|
||||
#define VALUE_TO_STRING(x) #x
|
||||
#define VALUE(x) VALUE_TO_STRING(x)
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
class CAdditionalData
|
||||
@ -188,7 +191,7 @@ namespace NSDoctRenderer
|
||||
m_strSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
if (!m_strSdkPath.empty())
|
||||
{
|
||||
if (!NSDirectory::Exists(m_strSdkPath))
|
||||
if (0 == m_strSdkPath.find(L"./") || !NSDirectory::Exists(m_strSdkPath))
|
||||
m_strSdkPath = sConfigDir + m_strSdkPath;
|
||||
}
|
||||
|
||||
@ -203,28 +206,14 @@ namespace NSDoctRenderer
|
||||
|
||||
char* GetVersion()
|
||||
{
|
||||
std::wstring sFile = m_strSdkPath + L"/word/sdk-all-min.js";
|
||||
std::string sVersion = VALUE(INTVER);
|
||||
|
||||
std::string sData;
|
||||
if (!NSFile::CFileBinary::ReadAllTextUtf8A(sFile, sData))
|
||||
return NULL;
|
||||
|
||||
std::string::size_type startPos = sData.find("Version:");
|
||||
if (std::string::npos == startPos)
|
||||
return NULL;
|
||||
|
||||
startPos += 8;
|
||||
|
||||
std::string::size_type endPos = sData.find(')', startPos);
|
||||
if (std::string::npos == endPos)
|
||||
return NULL;
|
||||
|
||||
size_t sSrcLen = endPos - startPos + 1;
|
||||
size_t sSrcLen = sVersion.size();
|
||||
if (sSrcLen == 0)
|
||||
return NULL;
|
||||
|
||||
char* sRet = new char[sSrcLen + 1];
|
||||
memcpy(sRet, sData.c_str() + startPos, sSrcLen);
|
||||
memcpy(sRet, sVersion.c_str(), sSrcLen);
|
||||
sRet[sSrcLen] = '\0';
|
||||
return sRet;
|
||||
}
|
||||
|
||||
@ -47,14 +47,6 @@ namespace NSDoctRenderer
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
}
|
||||
|
||||
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
|
||||
return m_pInternal->OpenFile(path, params);
|
||||
}
|
||||
int CDocBuilder::SaveFile(const int& type, const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
return m_pInternal->SaveFile(type, path, params);
|
||||
|
||||
@ -526,6 +526,7 @@ namespace NSDoctRenderer
|
||||
CDocBuilder_Private* m_pInternal;
|
||||
|
||||
friend class CBuilderDocumentEmbed;
|
||||
friend class CBuilderEmbed;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -56,7 +56,6 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder, cons
|
||||
CJSContextScope scope(m_context);
|
||||
|
||||
CJSContext::Embed<CNativeControlEmbed>(false);
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
NSJSBase::CreateDefaults();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
@ -83,7 +82,7 @@ CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
m_context->Dispose();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue)
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContext)
|
||||
{
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
@ -93,14 +92,20 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
std::string commandA = U_TO_UTF8(command);
|
||||
//commandA = "Api." + commandA;
|
||||
|
||||
CJSContextScope scope(m_context);
|
||||
if (isEnterContext)
|
||||
m_context->Enter();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
LOGGER_SPEED_LAP("compile_command");
|
||||
|
||||
JSSmart<CJSValue> retNativeVal = m_context->runScript(commandA, try_catch);
|
||||
if(try_catch->Check())
|
||||
{
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (retValue)
|
||||
{
|
||||
@ -111,6 +116,9 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
|
||||
LOGGER_SPEED_LAP("run_command");
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -241,6 +249,14 @@ bool CV8RealTimeWorker::InitVariables()
|
||||
if (try_catch->Check())
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_sJSCodeStart.empty())
|
||||
{
|
||||
m_context->runScript(m_sJSCodeStart, try_catch);
|
||||
if (try_catch->Check())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -297,7 +313,7 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
else if (1 == m_nFileType)
|
||||
pNative->m_strEditorType = L"presentation";
|
||||
else if (7 == m_nFileType)
|
||||
pNative->m_strEditorType = L"draw";
|
||||
pNative->m_strEditorType = L"visio";
|
||||
else
|
||||
pNative->m_strEditorType = L"spreadsheet";
|
||||
|
||||
@ -337,7 +353,17 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
return !bIsBreak;
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams)
|
||||
bool CV8RealTimeWorker::NewSimpleJSInstance()
|
||||
{
|
||||
return InitVariables();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::IsSimpleJSInstance()
|
||||
{
|
||||
return (-1 == m_nFileType);
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams, const bool& isEnterContext)
|
||||
{
|
||||
NSDoctRenderer::DoctRendererFormat::FormatFile _formatDst = NSDoctRenderer::DoctRendererFormat::DOCT;
|
||||
if (type & AVS_OFFICESTUDIO_FILE_PRESENTATION)
|
||||
@ -363,7 +389,9 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
}
|
||||
}
|
||||
|
||||
CJSContextScope scope(m_context);
|
||||
if (isEnterContext)
|
||||
m_context->Enter();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
|
||||
NSNativeControl::CNativeControl* pNative = NULL;
|
||||
@ -392,7 +420,7 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
bIsSilentMode = true;
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);");
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);", NULL, isEnterContext);
|
||||
|
||||
std::wstring strError;
|
||||
bool bIsError = Doct_renderer_SaveFile_ForBuilder(_formatDst,
|
||||
@ -404,7 +432,10 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
|
||||
sJsonParams);
|
||||
|
||||
if (bIsSilentMode)
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);");
|
||||
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);", NULL, isEnterContext);
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Exit();
|
||||
|
||||
return bIsError;
|
||||
}
|
||||
@ -1232,8 +1263,29 @@ namespace NSDoctRenderer
|
||||
nCount = nIndex;
|
||||
}
|
||||
|
||||
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
m_pInternal->m_bIsOpenedFromSimpleJS = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
|
||||
return m_pInternal->OpenFile(path, params);
|
||||
}
|
||||
|
||||
bool CDocBuilder::CreateFile(const int& type)
|
||||
{
|
||||
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
m_pInternal->m_bIsOpenedFromSimpleJS = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_pInternal->m_nFileType = -1;
|
||||
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
|
||||
@ -1392,7 +1444,7 @@ namespace NSDoctRenderer
|
||||
if (!sJsCommands.empty())
|
||||
{
|
||||
std::wstring sUnicodeCommand = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sJsCommands.c_str(), (LONG)sJsCommands.length());
|
||||
bIsNoError = this->ExecuteCommand(sUnicodeCommand.c_str());
|
||||
bIsNoError = this->m_pInternal->ExecuteCommand(sUnicodeCommand.c_str(), NULL, bIsBuilderJSCloseFile);
|
||||
sJsCommands = "";
|
||||
if (!bIsNoError)
|
||||
return false;
|
||||
@ -1414,6 +1466,10 @@ namespace NSDoctRenderer
|
||||
if (0 == _builder_params[nCheckParam].find(L"jsValue(") && _builder_params[nCheckParam].length() > 9)
|
||||
{
|
||||
std::wstring sParam = _builder_params[nCheckParam].substr(8, _builder_params[nCheckParam].length() - 9);
|
||||
|
||||
if (NULL == m_pInternal->m_pWorker)
|
||||
m_pInternal->CheckWorker();
|
||||
|
||||
_builder_params[nCheckParam] = m_pInternal->m_pWorker->GetJSVariable(sParam);
|
||||
}
|
||||
}
|
||||
@ -1479,7 +1535,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
// Такого быть не должно!!! Так как результат никуда не сохранится. пустое действие.
|
||||
std::wstring sUnicodeCommand = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sJsCommands.c_str(), (LONG)sJsCommands.length());
|
||||
bool bIsNoError = this->ExecuteCommand(sUnicodeCommand.c_str());
|
||||
bool bIsNoError = this->m_pInternal->ExecuteCommand(sUnicodeCommand.c_str(), NULL, true);
|
||||
sJsCommands = "";
|
||||
if (!bIsNoError)
|
||||
return false;
|
||||
|
||||
@ -63,6 +63,8 @@
|
||||
|
||||
#include "../common/ProcessEnv.h"
|
||||
|
||||
#include "docbuilder_addon.h"
|
||||
|
||||
#ifdef CreateFile
|
||||
#undef CreateFile
|
||||
#endif
|
||||
@ -422,6 +424,7 @@ public:
|
||||
int m_nFileType;
|
||||
std::string m_sUtf8ArgumentJSON;
|
||||
std::string m_sGlobalVariable;
|
||||
std::string m_sJSCodeStart;
|
||||
|
||||
CJSContextData m_oContextData;
|
||||
|
||||
@ -434,14 +437,17 @@ public:
|
||||
|
||||
static void _LOGGING_ERROR_(const std::wstring& strType, const std::wstring& strError);
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue = NULL);
|
||||
bool ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue = NULL, const bool& isEnterContext = true);
|
||||
|
||||
std::string GetGlobalVariable();
|
||||
std::wstring GetJSVariable(std::wstring sParam);
|
||||
|
||||
bool OpenFile(const std::wstring& sBasePath, const std::wstring& path, const NSDoctRenderer::DoctRendererEditorType& editorType, NSDoctRenderer::CDoctRendererConfig* config, CV8Params* pParams = NULL);
|
||||
bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L"");
|
||||
bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L"", const bool& isEnterContext = true);
|
||||
bool InitVariables();
|
||||
|
||||
bool NewSimpleJSInstance();
|
||||
bool IsSimpleJSInstance();
|
||||
};
|
||||
|
||||
namespace NSDoctRenderer
|
||||
@ -455,7 +461,8 @@ namespace NSDoctRenderer
|
||||
std::wstring m_sTmpFolder;
|
||||
std::wstring m_sFileDir;
|
||||
int m_nFileType;
|
||||
bool m_bJavascriptBeforeEditor;
|
||||
|
||||
std::wstring m_sCommandsBeforeContextCreated;
|
||||
|
||||
std::wstring m_sX2tPath;
|
||||
|
||||
@ -474,11 +481,13 @@ namespace NSDoctRenderer
|
||||
|
||||
NSDoctRenderer::CDocBuilder* m_pParent;
|
||||
|
||||
bool m_bIsOpenedFromSimpleJS;
|
||||
|
||||
static std::wstring m_sExternalDirectory;
|
||||
public:
|
||||
CDocBuilder_Private() : CDoctRendererConfig(), m_sTmpFolder(NSFile::CFileBinary::GetTempPath()), m_nFileType(-1),
|
||||
m_pWorker(NULL), m_pAdditionalData(NULL), m_bIsInit(false), m_bIsServerSafeVersion(false),
|
||||
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_bJavascriptBeforeEditor(false)
|
||||
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_sCommandsBeforeContextCreated(L""), m_bIsOpenedFromSimpleJS(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -637,10 +646,14 @@ namespace NSDoctRenderer
|
||||
{
|
||||
NSDirectory::CreateDirectory(m_sFileDir + L"/media");
|
||||
NSDirectory::CreateDirectory(m_sFileDir + L"/changes");
|
||||
}
|
||||
|
||||
if (m_bJavascriptBeforeEditor)
|
||||
CheckWorkerAfterOpen();
|
||||
if (m_pWorker && m_pWorker->IsSimpleJSInstance() && !m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
#else
|
||||
@ -931,8 +944,11 @@ namespace NSDoctRenderer
|
||||
|
||||
if (0 == nReturnCode)
|
||||
{
|
||||
if (m_bJavascriptBeforeEditor)
|
||||
CheckWorkerAfterOpen();
|
||||
if (m_pWorker && m_pWorker->IsSimpleJSInstance() && !m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -981,10 +997,16 @@ namespace NSDoctRenderer
|
||||
return _path;
|
||||
}
|
||||
|
||||
int SaveFile(const int& type, const std::wstring& path, const wchar_t* params = NULL)
|
||||
int SaveFile(const int& type, const std::wstring& path, const wchar_t* params = NULL, const bool& isEnterContext = true)
|
||||
{
|
||||
Init();
|
||||
|
||||
CDocBuilderAddon oSaveAddon(m_sX2tPath);
|
||||
|
||||
int nPreSaveError = oSaveAddon.GetX2tPreSaveError();
|
||||
if (0 != nPreSaveError)
|
||||
return nPreSaveError;
|
||||
|
||||
if (-1 == m_nFileType)
|
||||
{
|
||||
CV8RealTimeWorker::_LOGGING_ERROR_(L"error (save)", L"file not opened!");
|
||||
@ -1023,7 +1045,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
|
||||
this->m_pWorker->SaveFileWithChanges(type, m_sFileDir + L"/Editor2.bin", sJsonParams);
|
||||
this->m_pWorker->SaveFileWithChanges(type, m_sFileDir + L"/Editor2.bin", sJsonParams, isEnterContext);
|
||||
sFileBin = L"/Editor2.bin";
|
||||
}
|
||||
|
||||
@ -1068,6 +1090,8 @@ namespace NSDoctRenderer
|
||||
if (!sOptions.empty())
|
||||
oBuilder.WriteString(UTF8_TO_U(sOptions));
|
||||
|
||||
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon());
|
||||
|
||||
oBuilder.WriteString(L"</TaskQueueDataConvert>");
|
||||
|
||||
std::wstring sXmlConvert = oBuilder.GetData();
|
||||
@ -1220,62 +1244,75 @@ namespace NSDoctRenderer
|
||||
{
|
||||
if (NULL == m_pWorker)
|
||||
{
|
||||
m_pWorker = new CV8RealTimeWorker(m_pParent, GetEditorType(), this);
|
||||
NSDoctRenderer::DoctRendererEditorType editorType = GetEditorType();
|
||||
m_pWorker = new CV8RealTimeWorker(m_pParent, editorType, this);
|
||||
m_pWorker->m_sUtf8ArgumentJSON = m_oParams.m_sArgumentJSON;
|
||||
m_pWorker->m_sGlobalVariable = m_sGlobalVariable;
|
||||
m_pWorker->m_sJSCodeStart = U_TO_UTF8(m_sCommandsBeforeContextCreated);
|
||||
|
||||
return CheckWorkerAfterOpen();
|
||||
m_pWorker->m_nFileType = m_nFileType;
|
||||
|
||||
if (-1 != m_nFileType)
|
||||
m_sCommandsBeforeContextCreated = L"";
|
||||
else
|
||||
{
|
||||
m_pWorker->NewSimpleJSInstance();
|
||||
return true;
|
||||
}
|
||||
|
||||
CV8Params oParams;
|
||||
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
|
||||
oParams.DocumentDirectory = m_sFileDir;
|
||||
|
||||
return m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, editorType, this, &oParams);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckWorkerAfterOpen()
|
||||
{
|
||||
if (!m_pWorker)
|
||||
return false;
|
||||
|
||||
m_pWorker->m_nFileType = m_nFileType;
|
||||
if (-1 == m_nFileType)
|
||||
{
|
||||
m_bJavascriptBeforeEditor = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_bJavascriptBeforeEditor = false;
|
||||
|
||||
CV8Params oParams;
|
||||
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
|
||||
oParams.DocumentDirectory = m_sFileDir;
|
||||
|
||||
return m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, GetEditorType(), this, &oParams);
|
||||
}
|
||||
|
||||
int SaveFile(const std::wstring& ext, const std::wstring& path, const wchar_t* params = NULL)
|
||||
{
|
||||
int nType = GetFormatByTexExtention(ext);
|
||||
return SaveFile(nType, path, params);
|
||||
}
|
||||
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL)
|
||||
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL, const bool& forceExecute = false)
|
||||
{
|
||||
if (command.length() < 7 && !retValue) // minimum command (!!!)
|
||||
return true;
|
||||
|
||||
if (m_nFileType == -1 && !forceExecute)
|
||||
{
|
||||
m_sCommandsBeforeContextCreated += command;
|
||||
return true;
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
bool bRes = CheckWorker();
|
||||
if (CheckWorker())
|
||||
{
|
||||
bool bIsOpenedFromSimpleJSOld = m_bIsOpenedFromSimpleJS;
|
||||
bool bResult = m_pWorker->ExecuteCommand(command, retValue);
|
||||
if (!bResult && !bIsOpenedFromSimpleJSOld && m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
RELEASEOBJECT(m_pWorker);
|
||||
CheckWorker();
|
||||
return m_pWorker->ExecuteCommand(command, retValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bResult;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bRes && m_pWorker && m_bJavascriptBeforeEditor)
|
||||
m_pWorker->InitVariables();
|
||||
|
||||
return m_pWorker->ExecuteCommand(command, retValue);
|
||||
return false;
|
||||
}
|
||||
|
||||
CDocBuilderContext GetContext(bool enterContext)
|
||||
{
|
||||
CDocBuilderContext ctx;
|
||||
|
||||
CheckWorker();
|
||||
if (!CheckWorker())
|
||||
return ctx;
|
||||
|
||||
ctx.m_internal->m_context = m_pWorker->m_context;
|
||||
ctx.m_internal->m_context_data = &m_pWorker->m_oContextData;
|
||||
|
||||
@ -575,7 +575,6 @@ namespace NSDoctRenderer
|
||||
{
|
||||
CJSContextScope scope(context);
|
||||
CJSContext::Embed<CNativeControlEmbed>(false);
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
NSJSBase::CreateDefaults();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();
|
||||
@ -987,7 +986,7 @@ namespace NSDoctRenderer
|
||||
case DoctRendererFormat::IMAGE:
|
||||
{
|
||||
editorType = NSDoctRenderer::DoctRendererEditorType::VISIO;
|
||||
m_pInternal->m_strEditorType = L"draw";
|
||||
m_pInternal->m_strEditorType = L"visio";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -1067,7 +1066,6 @@ namespace NSDoctRenderer
|
||||
{
|
||||
CJSContextScope scope(context);
|
||||
CJSContext::Embed<CNativeControlEmbed>();
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
NSJSBase::CreateDefaults();
|
||||
|
||||
JSSmart<CJSObject> global = context->GetGlobal();
|
||||
|
||||
130
DesktopEditor/doctrenderer/doctrenderer.pri
Normal file
130
DesktopEditor/doctrenderer/doctrenderer.pri
Normal file
@ -0,0 +1,130 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
VERSION = 1.0.0.3
|
||||
TARGET = doctrenderer
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
PWD_CUR = $$PWD
|
||||
include($$PWD_CUR/../../Common/base.pri)
|
||||
|
||||
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
DEFINES += JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
|
||||
|
||||
#CONFIG += build_xp
|
||||
#CONFIG += v8_version_60
|
||||
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/config.h \
|
||||
$$PWD_CUR/editors.h \
|
||||
$$PWD_CUR/doctrenderer.h \
|
||||
$$PWD_CUR/docbuilder.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/editors.cpp \
|
||||
$$PWD_CUR/nativecontrol.cpp \
|
||||
$$PWD_CUR/doctrenderer.cpp \
|
||||
$$PWD_CUR/docbuilder.cpp \
|
||||
$$PWD_CUR/docbuilder_p.cpp \
|
||||
$$PWD_CUR/graphics.cpp \
|
||||
$$PWD_CUR/hash.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/../../Common/OfficeFileFormatChecker2.cpp \
|
||||
$$PWD_CUR/../../Common/3dParty/pole/pole.cpp \
|
||||
$$PWD_CUR/../../OOXML/Base/unicode_util.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/docbuilder_p.h \
|
||||
$$PWD_CUR/nativecontrol.h \
|
||||
$$PWD_CUR/graphics.h \
|
||||
$$PWD_CUR/hash.h \
|
||||
$$PWD_CUR/server.h
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/embed/PointerEmbed.h \
|
||||
$$PWD_CUR/embed/ZipEmbed.h \
|
||||
$$PWD_CUR/embed/GraphicsEmbed.h \
|
||||
$$PWD_CUR/embed/MemoryStreamEmbed.h \
|
||||
$$PWD_CUR/embed/NativeControlEmbed.h \
|
||||
$$PWD_CUR/embed/NativeBuilderEmbed.h \
|
||||
$$PWD_CUR/embed/NativeBuilderDocumentEmbed.h \
|
||||
$$PWD_CUR/embed/TextMeasurerEmbed.h \
|
||||
$$PWD_CUR/embed/HashEmbed.h \
|
||||
$$PWD_CUR/embed/Default.h \
|
||||
$$PWD_CUR/js_internal/js_base.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/embed/PointerEmbed.cpp \
|
||||
$$PWD_CUR/embed/ZipEmbed.cpp \
|
||||
$$PWD_CUR/embed/GraphicsEmbed.cpp \
|
||||
$$PWD_CUR/embed/MemoryStreamEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeControlEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeBuilderEmbed.cpp \
|
||||
$$PWD_CUR/embed/NativeBuilderDocumentEmbed.cpp \
|
||||
$$PWD_CUR/embed/TextMeasurerEmbed.cpp \
|
||||
$$PWD_CUR/embed/HashEmbed.cpp \
|
||||
$$PWD_CUR/embed/Default.cpp
|
||||
|
||||
# Serialize objects to JS
|
||||
HEADERS += \
|
||||
$$PWD_CUR/json/json.h \
|
||||
$$PWD_CUR/json/json_p.h \
|
||||
$$PWD_CUR/json/json_values.h \
|
||||
$$PWD_CUR/json/serialization.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/json/json.cpp \
|
||||
$$PWD_CUR/json/json_values.cpp
|
||||
|
||||
include($$PWD_CUR/js_internal/js_base.pri)
|
||||
|
||||
!use_javascript_core {
|
||||
build_xp:DESTDIR=$$DESTDIR/xp
|
||||
}
|
||||
|
||||
use_javascript_core {
|
||||
OBJECTIVE_SOURCES += $$PWD_CUR/../common/Mac/NSString+StringUtils.mm
|
||||
}
|
||||
|
||||
# files for embedded classes
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/GraphicsEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/HashEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/MemoryStreamEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeBuilderEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeBuilderDocumentEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeControlEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/PointerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/TextMeasurerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/ZipEmbed.h)
|
||||
|
||||
include($$PWD_CUR/../graphics/pro/textshaper.pri)
|
||||
include($$PWD_CUR/../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
|
||||
|
||||
CONFIG += drawingfile_support
|
||||
drawingfile_support {
|
||||
DEFINES += WASM_SERIALIZER_USE_ALLOCATOR
|
||||
ADD_DEPENDENCY(PdfFile, XpsFile, DjVuFile, DocxRenderer)
|
||||
|
||||
HEADERS += \
|
||||
$$PWD_CUR/drawingfile.h \
|
||||
$$PWD_CUR/embed/DrawingFileEmbed.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD_CUR/../graphics/pro/js/wasm/src/HTMLRendererText.cpp \
|
||||
$$PWD_CUR/embed/DrawingFileEmbed.cpp
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/DrawingFileEmbed.h)
|
||||
}
|
||||
@ -1,128 +1,3 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
INCLUDEPATH += $$PWD/addon
|
||||
|
||||
VERSION = 1.0.0.3
|
||||
TARGET = doctrenderer
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include(../../Common/base.pri)
|
||||
|
||||
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
DEFINES += JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
|
||||
|
||||
#CONFIG += build_xp
|
||||
#CONFIG += v8_version_60
|
||||
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
|
||||
HEADERS += \
|
||||
config.h \
|
||||
editors.h \
|
||||
doctrenderer.h \
|
||||
docbuilder.h
|
||||
|
||||
SOURCES += \
|
||||
editors.cpp \
|
||||
nativecontrol.cpp \
|
||||
doctrenderer.cpp \
|
||||
docbuilder.cpp \
|
||||
docbuilder_p.cpp \
|
||||
graphics.cpp \
|
||||
hash.cpp
|
||||
|
||||
SOURCES += \
|
||||
../../Common/OfficeFileFormatChecker2.cpp \
|
||||
../../Common/3dParty/pole/pole.cpp \
|
||||
../../OOXML/Base/unicode_util.cpp
|
||||
|
||||
HEADERS += \
|
||||
docbuilder_p.h \
|
||||
nativecontrol.h \
|
||||
graphics.h \
|
||||
hash.h \
|
||||
server.h
|
||||
|
||||
HEADERS += \
|
||||
embed/PointerEmbed.h \
|
||||
embed/ZipEmbed.h \
|
||||
embed/GraphicsEmbed.h \
|
||||
embed/MemoryStreamEmbed.h \
|
||||
embed/NativeControlEmbed.h \
|
||||
embed/NativeBuilderEmbed.h \
|
||||
embed/NativeBuilderDocumentEmbed.h \
|
||||
embed/TextMeasurerEmbed.h \
|
||||
embed/HashEmbed.h \
|
||||
embed/Default.h \
|
||||
js_internal/js_base.h
|
||||
|
||||
SOURCES += \
|
||||
embed/PointerEmbed.cpp \
|
||||
embed/ZipEmbed.cpp \
|
||||
embed/GraphicsEmbed.cpp \
|
||||
embed/MemoryStreamEmbed.cpp \
|
||||
embed/NativeControlEmbed.cpp \
|
||||
embed/NativeBuilderEmbed.cpp \
|
||||
embed/NativeBuilderDocumentEmbed.cpp \
|
||||
embed/TextMeasurerEmbed.cpp \
|
||||
embed/HashEmbed.cpp \
|
||||
embed/Default.cpp
|
||||
|
||||
# Serialize objects to JS
|
||||
HEADERS += \
|
||||
json/json.h \
|
||||
json/json_p.h \
|
||||
json/json_values.h \
|
||||
json/serialization.h
|
||||
|
||||
SOURCES += \
|
||||
json/json.cpp \
|
||||
json/json_values.cpp
|
||||
|
||||
include($$PWD/js_internal/js_base.pri)
|
||||
|
||||
!use_javascript_core {
|
||||
build_xp:DESTDIR=$$DESTDIR/xp
|
||||
}
|
||||
|
||||
use_javascript_core {
|
||||
OBJECTIVE_SOURCES += ../common/Mac/NSString+StringUtils.mm
|
||||
}
|
||||
|
||||
# files for embedded classes
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/GraphicsEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/HashEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/MemoryStreamEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeBuilderEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeBuilderDocumentEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeControlEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/PointerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/TextMeasurerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/ZipEmbed.h)
|
||||
|
||||
include(../graphics/pro/textshaper.pri)
|
||||
include(../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
|
||||
|
||||
CONFIG += drawingfile_support
|
||||
drawingfile_support {
|
||||
DEFINES += WASM_SERIALIZER_USE_ALLOCATOR
|
||||
ADD_DEPENDENCY(PdfFile, XpsFile, DjVuFile, DocxRenderer)
|
||||
|
||||
HEADERS += \
|
||||
drawingfile.h \
|
||||
embed/DrawingFileEmbed.h
|
||||
|
||||
SOURCES += \
|
||||
../../HtmlRenderer/src/HTMLRendererText.cpp \
|
||||
embed/DrawingFileEmbed.cpp
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/DrawingFileEmbed.h)
|
||||
}
|
||||
include(doctrenderer.pri)
|
||||
|
||||
@ -38,8 +38,8 @@
|
||||
#include "../../PdfFile/PdfFile.h"
|
||||
#include "../../XpsFile/XpsFile.h"
|
||||
#include "../../DjVuFile/DjVu.h"
|
||||
#include "../../DesktopEditor/graphics/pro/js/wasm/src/serialize.h"
|
||||
#include "../../HtmlRenderer/include/HTMLRendererText.h"
|
||||
#include "../graphics/pro/js/wasm/src/serialize.h"
|
||||
#include "../graphics/pro/js/wasm/src/HTMLRendererText.h"
|
||||
#include "../../DocxRenderer/DocxRenderer.h"
|
||||
|
||||
#define CHECKER_FILE_BUFFER_LEN 4096
|
||||
@ -542,8 +542,8 @@ private:
|
||||
}
|
||||
if (m_nType == 0)
|
||||
nRotate = ((CPdfFile*)m_pFile)->GetRotate(nPageIndex);
|
||||
nWidth = dWidth;
|
||||
nHeight = dHeight;
|
||||
nWidth = round(dWidth);
|
||||
nHeight = round(dHeight);
|
||||
nPageDpiX = dPageDpiX;
|
||||
}
|
||||
|
||||
|
||||
@ -6,16 +6,16 @@ namespace NSDoctRenderer
|
||||
{
|
||||
namespace
|
||||
{
|
||||
void AppendScript(NSStringUtils::CStringBuilderA* builder, const std::wstring& path)
|
||||
bool AppendScript(NSStringUtils::CStringBuilderA* builder, const std::wstring& path, const std::string& header = "", const std::string& footer = "")
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
|
||||
if (!oFile.OpenFile(path))
|
||||
return;
|
||||
return false;
|
||||
|
||||
int size = (int)oFile.GetFileSize();
|
||||
if (size < 3)
|
||||
return;
|
||||
return false;
|
||||
|
||||
BYTE* pData = new BYTE[size];
|
||||
DWORD dwReadSize = 0;
|
||||
@ -26,9 +26,18 @@ namespace NSDoctRenderer
|
||||
if (pData[0] == 0xEF && pData[1] == 0xBB && pData[2] == 0xBF)
|
||||
nOffset = 3;
|
||||
|
||||
if (!header.empty())
|
||||
builder->WriteString(header);
|
||||
|
||||
builder->WriteString((char*)(pData + nOffset), size - nOffset);
|
||||
|
||||
if (!footer.empty())
|
||||
builder->WriteString(footer);
|
||||
|
||||
builder->WriteString("\n\n");
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RunScript(JSSmart<NSJSBase::CJSContext>& context, JSSmart<NSJSBase::CJSTryCatch>& try_catch, const std::wstring& path)
|
||||
@ -100,12 +109,12 @@ namespace NSDoctRenderer
|
||||
}
|
||||
case DoctRendererEditorType::VISIO:
|
||||
{
|
||||
if (!NSFile::CFileBinary::Exists(config->m_strSdkPath + L"/draw/sdk-all-min.js"))
|
||||
if (!NSFile::CFileBinary::Exists(config->m_strSdkPath + L"/visio/sdk-all-min.js"))
|
||||
return L"";
|
||||
AppendScript(builder, config->m_strSdkPath + L"/draw/sdk-all-min.js");
|
||||
AppendScript(builder, config->m_strSdkPath + L"/visio/sdk-all-min.js");
|
||||
AppendScript(builder, sFontsPath);
|
||||
AppendScript(builder, config->m_strSdkPath + L"/draw/sdk-all.js");
|
||||
sCachePath = config->m_strSdkPath + L"/draw/sdk-all";
|
||||
AppendScript(builder, config->m_strSdkPath + L"/visio/sdk-all.js");
|
||||
sCachePath = config->m_strSdkPath + L"/visio/sdk-all";
|
||||
break;
|
||||
}
|
||||
case DoctRendererEditorType::PDF:
|
||||
@ -114,6 +123,7 @@ namespace NSDoctRenderer
|
||||
AppendScript(builder, sFontsPath);
|
||||
AppendScript(builder, config->m_strSdkPath + L"/word/sdk-all.js");
|
||||
AppendScript(builder, config->m_strSdkPath + L"/pdf/src/engine/drawingfile_native.js");
|
||||
AppendScript(builder, config->m_strSdkPath + L"/pdf/src/annotations/stamps.json", "window[\"native_pdf_stamps\"]=", ";");
|
||||
sCachePath = config->m_strSdkPath + L"/pdf/sdk-all";
|
||||
break;
|
||||
}
|
||||
@ -147,7 +157,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
case DoctRendererEditorType::VISIO:
|
||||
{
|
||||
return config->m_strSdkPath + L"/draw/sdk-all.bin";
|
||||
return config->m_strSdkPath + L"/visio/sdk-all.bin";
|
||||
}
|
||||
case DoctRendererEditorType::PDF:
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "./MemoryStreamEmbed.h"
|
||||
#include "./TextMeasurerEmbed.h"
|
||||
#include "./HashEmbed.h"
|
||||
#include "./GraphicsEmbed.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
@ -13,5 +14,6 @@ namespace NSJSBase
|
||||
CJSContext::Embed<CMemoryStreamEmbed>();
|
||||
CJSContext::Embed<CTextMeasurerEmbed>();
|
||||
CJSContext::Embed<CHashEmbed>();
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "DrawingFileEmbed.h"
|
||||
#include "../drawingfile.h"
|
||||
#include "../../raster/BgraFrame.h"
|
||||
|
||||
JSSmart<CJSValue> WasmMemoryToJS(BYTE* pWasmData)
|
||||
{
|
||||
|
||||
@ -1,8 +1,192 @@
|
||||
#include "GraphicsEmbed.h"
|
||||
#include "../graphics.h"
|
||||
#include <map>
|
||||
#include "../../../Common/Network/FileTransporter/include/FileTransporter.h"
|
||||
|
||||
// APPLICATION INFO
|
||||
class CGraphicsAppImage_private
|
||||
{
|
||||
public:
|
||||
NSFonts::IApplicationFonts* m_pFonts;
|
||||
std::wstring m_sFontsDirectory;
|
||||
std::wstring m_sImagesDirectory;
|
||||
std::wstring m_sThemesDirectory;
|
||||
bool m_bIsRgba;
|
||||
|
||||
std::map<std::wstring, std::wstring> m_mapDownloads;
|
||||
|
||||
CGraphicsAppImage_private()
|
||||
{
|
||||
m_pFonts = NULL;
|
||||
m_sFontsDirectory = L"";
|
||||
m_sImagesDirectory = L"";
|
||||
m_sThemesDirectory = L"";
|
||||
m_bIsRgba = false;
|
||||
}
|
||||
~CGraphicsAppImage_private()
|
||||
{
|
||||
RELEASEINTERFACE(m_pFonts);
|
||||
|
||||
for (std::map<std::wstring, std::wstring>::iterator i = m_mapDownloads.begin(); i != m_mapDownloads.end(); i++)
|
||||
{
|
||||
std::wstring sTmp = i->second;
|
||||
if (NSFile::CFileBinary::Exists(sTmp))
|
||||
NSFile::CFileBinary::Remove(sTmp);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNeedDownload(const std::wstring& sUrl)
|
||||
{
|
||||
if ((0 == sUrl.find(L"www.")) ||
|
||||
(0 == sUrl.find(L"http://")) ||
|
||||
(0 == sUrl.find(L"https://")))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::wstring GetImagePath(const std::wstring& sUrl)
|
||||
{
|
||||
std::map<std::wstring, std::wstring>::iterator find = m_mapDownloads.find(sUrl);
|
||||
if (find != m_mapDownloads.end())
|
||||
return find->second;
|
||||
|
||||
NSNetwork::NSFileTransport::CFileDownloader oDownloader(sUrl, false);
|
||||
|
||||
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"IMG");
|
||||
if (NSFile::CFileBinary::Exists(sTmpFile))
|
||||
NSFile::CFileBinary::Remove(sTmpFile);
|
||||
sTmpFile = sTmpFile + L".png";
|
||||
|
||||
oDownloader.SetFilePath(sTmpFile);
|
||||
oDownloader.Start(0);
|
||||
while ( oDownloader.IsRunned() )
|
||||
{
|
||||
NSThreads::Sleep( 10 );
|
||||
}
|
||||
bool bIsDownloaded = oDownloader.IsFileDownloaded();
|
||||
|
||||
if (bIsDownloaded)
|
||||
{
|
||||
m_mapDownloads.insert(std::pair<std::wstring, std::wstring>(sUrl, sTmpFile));
|
||||
return sTmpFile;
|
||||
}
|
||||
|
||||
return sUrl;
|
||||
}
|
||||
};
|
||||
|
||||
CGraphicsAppImage::CGraphicsAppImage()
|
||||
{
|
||||
m_internal = new CGraphicsAppImage_private();
|
||||
}
|
||||
CGraphicsAppImage::~CGraphicsAppImage()
|
||||
{
|
||||
delete m_internal;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetFontsDirectory(const std::wstring& dir)
|
||||
{
|
||||
m_internal->m_sFontsDirectory = dir;
|
||||
}
|
||||
std::wstring CGraphicsAppImage::GetFontsDirectory()
|
||||
{
|
||||
return m_internal->m_sFontsDirectory;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetImagesDirectory(const std::wstring& dir)
|
||||
{
|
||||
m_internal->m_sImagesDirectory = dir;
|
||||
}
|
||||
std::wstring CGraphicsAppImage::GetImagesDirectory()
|
||||
{
|
||||
return m_internal->m_sImagesDirectory;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetThemesDirectory(const std::wstring& dir)
|
||||
{
|
||||
m_internal->m_sThemesDirectory = dir;
|
||||
}
|
||||
std::wstring CGraphicsAppImage::GetThemesDirectory()
|
||||
{
|
||||
return m_internal->m_sThemesDirectory;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetFonts(NSFonts::IApplicationFonts* fonts)
|
||||
{
|
||||
m_internal->m_pFonts = fonts;
|
||||
ADDREFINTERFACE(fonts);
|
||||
}
|
||||
NSFonts::IApplicationFonts* CGraphicsAppImage::GetFonts()
|
||||
{
|
||||
return m_internal->m_pFonts;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetRgba(const bool& isRgba)
|
||||
{
|
||||
m_internal->m_bIsRgba = isRgba;
|
||||
}
|
||||
bool CGraphicsAppImage::GetRgba()
|
||||
{
|
||||
return m_internal->m_bIsRgba;
|
||||
}
|
||||
|
||||
unsigned char* CGraphicsAppImage::GetBits(int& w, int& h)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
unsigned char* CGraphicsAppImage::AllocBits(const int& w, const int& h)
|
||||
{
|
||||
return new unsigned char[4 * w * h];
|
||||
}
|
||||
|
||||
// APPLICATION INFO END
|
||||
|
||||
CGraphicsEmbed::CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics())
|
||||
{
|
||||
}
|
||||
CGraphicsEmbed::~CGraphicsEmbed()
|
||||
{
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
}
|
||||
|
||||
CGraphicsAppImage* CGraphicsEmbed::GetAppImage()
|
||||
{
|
||||
return m_pInternal->m_pAppImage;
|
||||
}
|
||||
|
||||
void CGraphicsEmbed::SetAppImage(CGraphicsAppImage* appImage)
|
||||
{
|
||||
m_pInternal->m_pAppImage = appImage;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm)
|
||||
{
|
||||
m_pInternal->init((NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject(), width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
|
||||
if (!Native->isNull())
|
||||
{
|
||||
JSSmart<CJSObject> pNativeObject = Native->toObject();
|
||||
CJSEmbedObject* pNativeEmbedObject = pNativeObject->getNative();
|
||||
|
||||
if (m_pInternal->m_pAppImage)
|
||||
delete m_pInternal->m_pAppImage;
|
||||
m_pInternal->m_pAppImage = new CGraphicsAppImage();
|
||||
|
||||
if (pNativeEmbedObject)
|
||||
{
|
||||
NSNativeControl::CNativeControl* pControl = (NSNativeControl::CNativeControl*)pNativeEmbedObject->getObject();
|
||||
m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory);
|
||||
m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory);
|
||||
}
|
||||
else
|
||||
{
|
||||
JSSmart<CJSValue> checkResources = pNativeObject->get("isResourcesObject");
|
||||
if (checkResources->isBool() && true == checkResources->toBool())
|
||||
{
|
||||
m_pInternal->m_pAppImage->SetFontsDirectory(pNativeObject->get("fontsDirectory")->toStringW());
|
||||
m_pInternal->m_pAppImage->SetImagesDirectory(pNativeObject->get("imagesDirectory")->toStringW());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pInternal->init(width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::Destroy()
|
||||
@ -150,11 +334,19 @@ JSSmart<CJSValue> CGraphicsEmbed::ClearLastFont()
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawImage2(JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect)
|
||||
{
|
||||
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
std::wstring sUrl = img->toStringW();
|
||||
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
|
||||
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
|
||||
|
||||
m_pInternal->drawImage(sUrl, x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawImage (JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect, JSSmart<CJSValue> nativeImage)
|
||||
{
|
||||
std::wstring sUrl = img->toStringW();
|
||||
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
|
||||
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
|
||||
|
||||
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
@ -459,7 +651,11 @@ JSSmart<CJSValue> CGraphicsEmbed::GetBrushColor()
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_brushTexture(JSSmart<CJSValue> src, JSSmart<CJSValue> type)
|
||||
{
|
||||
m_pInternal->put_brushTexture(src->toStringW(), type->toInt32());
|
||||
std::wstring sUrl = src->toStringW();
|
||||
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
|
||||
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
|
||||
|
||||
m_pInternal->put_brushTexture(sUrl, type->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_brushTextureMode(JSSmart<CJSValue> mode)
|
||||
|
||||
@ -1,21 +1,57 @@
|
||||
#ifndef _BUILD_NATIVE_GRAPHICS_EMBED_H_
|
||||
#define _BUILD_NATIVE_GRAPHICS_EMBED_H_
|
||||
|
||||
#include "../graphics.h"
|
||||
#include "../../graphics/pro/Fonts.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
|
||||
class CGraphicsAppImage_private;
|
||||
class JS_DECL CGraphicsAppImage
|
||||
{
|
||||
public:
|
||||
CGraphicsAppImage();
|
||||
virtual ~CGraphicsAppImage();
|
||||
public:
|
||||
void SetFontsDirectory(const std::wstring& dir);
|
||||
std::wstring GetFontsDirectory();
|
||||
|
||||
void SetImagesDirectory(const std::wstring& dir);
|
||||
std::wstring GetImagesDirectory();
|
||||
|
||||
void SetThemesDirectory(const std::wstring& dir);
|
||||
std::wstring GetThemesDirectory();
|
||||
|
||||
void SetFonts(NSFonts::IApplicationFonts* fonts);
|
||||
NSFonts::IApplicationFonts* GetFonts();
|
||||
|
||||
void SetRgba(const bool& isRgba);
|
||||
bool GetRgba();
|
||||
|
||||
virtual unsigned char* GetBits(int& w, int& h);
|
||||
virtual unsigned char* AllocBits(const int& w, const int& h);
|
||||
|
||||
private:
|
||||
CGraphicsAppImage_private* m_internal;
|
||||
|
||||
friend class CGraphicsEmbed;
|
||||
};
|
||||
|
||||
namespace NSGraphics { class CGraphics; }
|
||||
|
||||
using namespace NSJSBase;
|
||||
class CGraphicsEmbed : public CJSEmbedObject
|
||||
class JS_DECL CGraphicsEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
NSGraphics::CGraphics* m_pInternal;
|
||||
|
||||
public:
|
||||
CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics()) {}
|
||||
~CGraphicsEmbed() { RELEASEOBJECT(m_pInternal); }
|
||||
CGraphicsEmbed();
|
||||
~CGraphicsEmbed();
|
||||
|
||||
virtual void* getObject() override { return (void*)m_pInternal; }
|
||||
|
||||
CGraphicsAppImage* GetAppImage();
|
||||
void SetAppImage(CGraphicsAppImage* appImage);
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> create(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm);
|
||||
JSSmart<CJSValue> Destroy();
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "./../docbuilder_p.h"
|
||||
|
||||
#include "../../common/Directory.h"
|
||||
#include "../server.h"
|
||||
|
||||
JSSmart<CJSValue> CBuilderDocumentEmbed::IsValid()
|
||||
{
|
||||
@ -68,13 +69,23 @@ void CBuilderDocumentEmbed::_OpenFile(const std::wstring& sFile, const std::wstr
|
||||
int nConvertResult = pBuilder->ConvertToInternalFormat(m_sFolder, sFileCopy, sParams);
|
||||
|
||||
if (0 == nConvertResult)
|
||||
{
|
||||
if (CServerInstance::getInstance().IsEnable())
|
||||
CServerInstance::getInstance().AddTmpFile(m_sFolder);
|
||||
m_bIsValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CBuilderDocumentEmbed::_CloseFile()
|
||||
{
|
||||
if (!m_sFolder.empty())
|
||||
{
|
||||
NSDirectory::DeleteDirectory(m_sFolder);
|
||||
|
||||
if (m_bIsValid && CServerInstance::getInstance().IsEnable())
|
||||
CServerInstance::getInstance().RemoveTmpFile(m_sFolder);
|
||||
}
|
||||
|
||||
m_bIsValid = false;
|
||||
m_sFolder = L"";
|
||||
}
|
||||
|
||||
@ -8,7 +8,22 @@ JSSmart<CJSValue> CBuilderEmbed::OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSVa
|
||||
{
|
||||
std::wstring Path = sPath->toStringW();
|
||||
std::wstring Params = sParams->toStringW();
|
||||
|
||||
// Since we now use snapshots, and we can't always determine which editor is needed
|
||||
// (since the code may be BEFORE opening the file). And if the opening came from
|
||||
// builderJS.OpenFile - in this case we skip reopening.
|
||||
NSDoctRenderer::CDocBuilder_Private* pPrivate = GetPrivate();
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
pPrivate->m_bIsOpenedFromSimpleJS = true;
|
||||
|
||||
int ret = m_pBuilder->OpenFile(Path.c_str(), Params.c_str());
|
||||
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
{
|
||||
JSSmart<CJSContext> current = CJSContext::GetCurrent();
|
||||
current->runScript("throw 0;");
|
||||
}
|
||||
|
||||
return CJSContext::createInt(ret);
|
||||
}
|
||||
|
||||
@ -20,7 +35,21 @@ JSSmart<CJSValue> CBuilderEmbed::CreateFile(JSSmart<CJSValue> type)
|
||||
else
|
||||
nFormat = type->toInt32();
|
||||
|
||||
// Since we now use snapshots, and we can't always determine which editor is needed
|
||||
// (since the code may be BEFORE opening the file). And if the opening came from
|
||||
// builderJS.OpenFile - in this case we skip reopening.
|
||||
NSDoctRenderer::CDocBuilder_Private* pPrivate = GetPrivate();
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
pPrivate->m_bIsOpenedFromSimpleJS = true;
|
||||
|
||||
bool ret = m_pBuilder->CreateFile(nFormat);
|
||||
|
||||
if (pPrivate->m_pWorker->IsSimpleJSInstance())
|
||||
{
|
||||
JSSmart<CJSContext> current = CJSContext::GetCurrent();
|
||||
current->runScript("throw 0;");
|
||||
}
|
||||
|
||||
return CJSContext::createBool(ret);
|
||||
}
|
||||
|
||||
@ -41,7 +70,7 @@ JSSmart<CJSValue> CBuilderEmbed::SaveFile(JSSmart<CJSValue> type, JSSmart<CJSVal
|
||||
|
||||
std::wstring sPath = path->toStringW();
|
||||
std::wstring sParams = params->toStringW();
|
||||
int ret = m_pBuilder->SaveFile(nFormat, sPath.c_str(), sParams.empty() ? NULL : sParams.c_str());
|
||||
int ret = GetPrivate()->SaveFile(nFormat, sPath.c_str(), sParams.empty() ? NULL : sParams.c_str(), false);
|
||||
return CJSContext::createInt(ret);
|
||||
}
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ public:
|
||||
~CBuilderEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
NSDoctRenderer::CDocBuilder_Private* GetPrivate() { return m_pBuilder->GetPrivate(); }
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSValue> sParams);
|
||||
|
||||
@ -258,3 +258,64 @@ JSSmart<CJSValue> CZipEmbed::getImageType(JSSmart<CJSValue> typedArray)
|
||||
oBuffer.Free();
|
||||
return CJSContext::createInt(bIsImageFile ? oChecker.eFileType : 0);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CZipEmbed::getImageBuffer(JSSmart<CJSValue> filePath)
|
||||
{
|
||||
if (!m_pFolder || !filePath->isString())
|
||||
return CJSContext::createNull();
|
||||
|
||||
std::wstring sFilePath = filePath->toStringW();
|
||||
IFolder::CBuffer* pBuffer;
|
||||
if (!m_pFolder->read(sFilePath, pBuffer))
|
||||
return CJSContext::createNull();
|
||||
|
||||
size_t nBufferSize = (size_t)pBuffer->Size;
|
||||
|
||||
CImageFileFormatChecker oChecker;
|
||||
bool bIsImageFile = oChecker.isImageFile(pBuffer->Buffer, (DWORD)pBuffer->Size);
|
||||
|
||||
if (!bIsImageFile)
|
||||
{
|
||||
RELEASEOBJECT(pBuffer);
|
||||
return CJSContext::createNull();
|
||||
}
|
||||
|
||||
bool bIsNeedConvertMetfileToSvg = false;
|
||||
|
||||
// Make as wasm module
|
||||
if (oChecker.eFileType == _CXIMAGE_FORMAT_WMF || oChecker.eFileType == _CXIMAGE_FORMAT_EMF)
|
||||
oChecker.eFileType = _CXIMAGE_FORMAT_SVG;
|
||||
else
|
||||
bIsNeedConvertMetfileToSvg = false;
|
||||
|
||||
if (!bIsNeedConvertMetfileToSvg)
|
||||
{
|
||||
BYTE* pMemory = NSJSBase::NSAllocator::Alloc(nBufferSize);
|
||||
memcpy(pMemory, pBuffer->Buffer, nBufferSize);
|
||||
RELEASEOBJECT(pBuffer);
|
||||
|
||||
JSSmart<CJSObject> retObject = CJSContext::createObject();
|
||||
retObject->set("type", CJSContext::createInt(oChecker.eFileType));
|
||||
retObject->set("data", NSJSBase::CJSContext::createUint8Array(pMemory, (int)nBufferSize, false));
|
||||
return retObject->toValue();
|
||||
}
|
||||
|
||||
#ifndef GRAPHICS_DISABLE_METAFILE
|
||||
MetaFile::IMetaFile* pMetaFile = MetaFile::Create(NULL);
|
||||
pMetaFile->LoadFromBuffer(pBuffer->Buffer, (unsigned int)pBuffer->Size);
|
||||
std::wstring wsSvg = pMetaFile->ConvertToSvg();
|
||||
std::string sSvg = U_TO_UTF8(wsSvg);
|
||||
pMetaFile->Release();
|
||||
RELEASEOBJECT(pBuffer);
|
||||
|
||||
BYTE* pData = NSAllocator::Alloc(sSvg.length());
|
||||
memcpy(pData, sSvg.c_str(), sSvg.length());
|
||||
|
||||
JSSmart<CJSObject> retObject = CJSContext::createObject();
|
||||
retObject->set("type", CJSContext::createInt(24));
|
||||
retObject->set("data", NSJSBase::CJSContext::createUint8Array(pData, sSvg.length(), false));
|
||||
return retObject->toValue();
|
||||
#else
|
||||
return CJSContext::createNull();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ public:
|
||||
JSSmart<CJSValue> encodeImageData(JSSmart<CJSValue> typedArray, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> stride, JSSmart<CJSValue> format, JSSmart<CJSValue> isRgba);
|
||||
JSSmart<CJSValue> encodeImage(JSSmart<CJSValue> typedArray, JSSmart<CJSValue> format);
|
||||
JSSmart<CJSValue> getImageType(JSSmart<CJSValue> typedArray);
|
||||
JSSmart<CJSValue> getImageBuffer(JSSmart<CJSValue> path);
|
||||
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
-(JSValue*) encodeImageData : (JSValue*)typedArray : (JSValue*)w : (JSValue*)h : (JSValue*)stride : (JSValue*)format : (JSValue*)isRgba;
|
||||
-(JSValue*) encodeImage : (JSValue*)typedArray : (JSValue*)format;
|
||||
-(JSValue*) getImageType : (JSValue*)typedArray;
|
||||
-(JSValue*) getImageBuffer : (JSValue*)path;
|
||||
@end
|
||||
|
||||
@interface CJSCZipEmbed : NSObject<IJSCZipEmbed, JSEmbedObjectProtocol>
|
||||
@ -41,6 +42,7 @@ FUNCTION_WRAPPER_JS_2(decodeImage, decodeImage)
|
||||
FUNCTION_WRAPPER_JS_6(encodeImageData, encodeImageData)
|
||||
FUNCTION_WRAPPER_JS_2(encodeImage, encodeImage)
|
||||
FUNCTION_WRAPPER_JS_1(getImageType, getImageType)
|
||||
FUNCTION_WRAPPER_JS_1(getImageBuffer, getImageBuffer)
|
||||
@end
|
||||
|
||||
class CZipEmbedAdapter : public CJSEmbedObjectAdapterJSC
|
||||
|
||||
@ -20,6 +20,7 @@ namespace NSZipEmbed
|
||||
FUNCTION_WRAPPER_V8_6(_encodeImageData, encodeImageData)
|
||||
FUNCTION_WRAPPER_V8_2(_encodeImage, encodeImage)
|
||||
FUNCTION_WRAPPER_V8_1(_getImageType, getImageType)
|
||||
FUNCTION_WRAPPER_V8_1(_getImageBuffer, getImageBuffer)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
@ -39,6 +40,7 @@ namespace NSZipEmbed
|
||||
NSV8Objects::Template_Set(result, "encodeImageData", _encodeImageData);
|
||||
NSV8Objects::Template_Set(result, "encodeImage", _encodeImage);
|
||||
NSV8Objects::Template_Set(result, "getImageType", _getImageType);
|
||||
NSV8Objects::Template_Set(result, "getImageBuffer", _getImageBuffer);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
@ -10,18 +10,35 @@
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#define ENABLE_GR_LOGS
|
||||
#endif
|
||||
|
||||
namespace NSGraphics
|
||||
{
|
||||
void CGraphics::init(NSNativeControl::CNativeControl* oNative, double width_px, double height_px, double width_mm, double height_mm)
|
||||
void CGraphics::init(double width_px, double height_px, double width_mm, double height_mm)
|
||||
{
|
||||
m_sApplicationImagesDirectory = oNative->m_strImagesDirectory;
|
||||
m_sApplicationFontsDirectory = oNative->m_strFontsDirectory;
|
||||
#ifdef _DEBUG
|
||||
std::wcout << L"init "<< m_sApplicationImagesDirectory << L" " << m_sApplicationFontsDirectory << L" " << width_px << L" " << height_px << L" " << width_mm << L" " << height_mm << std::endl;
|
||||
if (!m_pAppImage)
|
||||
return;
|
||||
|
||||
if (NULL == m_pAppImage->GetFonts())
|
||||
{
|
||||
NSFonts::IApplicationFonts* pFonts = NSFonts::NSApplication::Create();
|
||||
std::wstring sFontsDir = m_pAppImage->GetFontsDirectory();
|
||||
pFonts->InitializeFromFolder(sFontsDir.empty() ? NSFile::GetProcessDirectory() : sFontsDir);
|
||||
m_pAppImage->SetFonts(pFonts);
|
||||
RELEASEINTERFACE(pFonts);
|
||||
}
|
||||
|
||||
NSFonts::IFontManager* pManager = m_pAppImage->GetFonts()->GenerateFontManager();
|
||||
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"init "<<
|
||||
m_pAppImage->GetImagesDirectory() << L" " <<
|
||||
m_pAppImage->GetFontsDirectory() << L" " <<
|
||||
width_px << L" " << height_px << L" " <<
|
||||
width_mm << L" " << height_mm << std::endl;
|
||||
#endif
|
||||
m_pApplicationFonts = NSFonts::NSApplication::Create();
|
||||
m_pApplicationFonts->InitializeFromFolder(m_sApplicationFontsDirectory.empty() ? NSFile::GetProcessDirectory() : m_sApplicationFontsDirectory);
|
||||
NSFonts::IFontManager* pManager = m_pApplicationFonts->GenerateFontManager();
|
||||
|
||||
m_pRenderer = NSGraphics::Create();
|
||||
m_pRenderer->SetFontManager(pManager);
|
||||
@ -42,7 +59,19 @@ namespace NSGraphics
|
||||
if (nRasterH < 1) nRasterH = 0;
|
||||
}
|
||||
|
||||
BYTE* pData = new BYTE[4 * nRasterW * nRasterH];
|
||||
int nExistW = 0;
|
||||
int nExistH = 0;
|
||||
BYTE* pData = m_pAppImage->GetBits(nExistW, nExistH);
|
||||
if (pData != NULL)
|
||||
{
|
||||
nRasterW = nExistW;
|
||||
nRasterH = nExistH;
|
||||
}
|
||||
else
|
||||
{
|
||||
pData = m_pAppImage->AllocBits(nRasterW, nRasterH);
|
||||
}
|
||||
|
||||
unsigned int back = 0xffffff;
|
||||
unsigned int* pData32 = (unsigned int*)pData;
|
||||
unsigned int* pData32End = pData32 + nRasterW * nRasterH;
|
||||
@ -55,21 +84,21 @@ namespace NSGraphics
|
||||
m_oFrame.put_Stride(4 * nRasterW);
|
||||
|
||||
m_pRenderer->CreateFromBgraFrame(&m_oFrame);
|
||||
m_pRenderer->SetSwapRGB(false);
|
||||
m_pRenderer->SetSwapRGB(m_pAppImage->GetRgba());
|
||||
|
||||
m_pRenderer->put_Width(width_mm);
|
||||
m_pRenderer->put_Height(height_mm);
|
||||
}
|
||||
void CGraphics::put_GlobalAlpha(bool enable, double alpha)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_GlobalAlpha " << enable << " " << alpha << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_GlobalAlphaEnabled(enable, alpha);
|
||||
}
|
||||
void CGraphics::End_GlobalAlpha()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "End_GlobalAlpha " << std::endl;
|
||||
#endif
|
||||
bool bIsInteger = m_pRenderer->get_IntegerGrid();
|
||||
@ -86,7 +115,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::p_color(int r, int g, int b, int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "p_color " << r << " " << g << " " << b << " " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_PenColor(r | (g << 8) | (b << 16));
|
||||
@ -94,14 +123,14 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::p_width(double w)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "p_width " << w << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_PenSize(w / 1000.0);
|
||||
}
|
||||
void CGraphics::p_dash(size_t length, double* dash)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "p_dash " << length << std::endl;
|
||||
#endif
|
||||
if(length > 0)
|
||||
@ -119,7 +148,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::b_color1(int r, int g, int b, int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "b_color1 " << r << " " << g << " " << b << " " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
@ -128,7 +157,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::b_color2(int r, int g, int b, int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "b_color2 " << r << " " << g << " " << b << " " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushColor2(r | (g << 8) | (b << 16));
|
||||
@ -136,42 +165,42 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::transform(double sx, double shy, double shx, double sy, double tx, double ty)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "transform " << sx << " " << shy << " " << shx << " " << sy << " " << tx << " " << ty << std::endl;
|
||||
#endif
|
||||
m_pRenderer->SetTransform(sx, shy, shx, sy, tx, ty);
|
||||
}
|
||||
void CGraphics::CalculateFullTransform()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "CalculateFullTransform " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CalculateFullTransform();
|
||||
}
|
||||
void CGraphics::_s()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_s " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
}
|
||||
void CGraphics::_e()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_e " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
}
|
||||
void CGraphics::_z()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_z " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandClose();
|
||||
}
|
||||
void CGraphics::_m(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_m " << x << " " << y << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -184,7 +213,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::_l(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_l " << x << " " << y << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -197,7 +226,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::_c (double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_c " << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -212,7 +241,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::_c2(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_c2 " << x1 << " " << y1 << " " << x2 << " " << y2 << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -226,28 +255,28 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::ds()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "ds " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->Stroke();
|
||||
}
|
||||
void CGraphics::df()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "df " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->Fill();
|
||||
}
|
||||
void CGraphics::save()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "save " << std::endl;
|
||||
#endif
|
||||
m_oFrame.SaveFile(m_sApplicationImagesDirectory + L"/img.png", _CXIMAGE_FORMAT_PNG);
|
||||
m_oFrame.SaveFile(m_pAppImage->GetImagesDirectory() + L"/img.png", _CXIMAGE_FORMAT_PNG);
|
||||
}
|
||||
void CGraphics::restore()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "restore " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->BeginCommand(c_nResetClipType);
|
||||
@ -255,7 +284,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::clip()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "clip " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->BeginCommand(c_nClipType);
|
||||
@ -263,43 +292,46 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::reset()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "reset " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->ResetTransform();
|
||||
}
|
||||
void CGraphics::FreeFont()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "FreeFont " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CloseFont();
|
||||
}
|
||||
void CGraphics::ClearLastFont()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "ClearLastFont " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->ClearInstallFont();
|
||||
}
|
||||
void CGraphics::drawImage(const std::wstring& img, double x, double y, double w, double h, BYTE alpha)
|
||||
{
|
||||
std::wstring strImage = (0 == img.find(L"theme") ? m_sApplicationThemesDirectory : m_sApplicationImagesDirectory) + L'/' + img;
|
||||
#ifdef _DEBUG
|
||||
std::wstring strImage = img;
|
||||
if (!NSFile::CFileBinary::Exists(img))
|
||||
strImage = (0 == img.find(L"theme") ? m_pAppImage->GetThemesDirectory() : m_pAppImage->GetImagesDirectory()) + L'/' + img;
|
||||
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"drawImage " << strImage << L" " << x << " " << y << L" " << w << L" " << h << L" " << alpha << std::endl;
|
||||
#endif
|
||||
m_pRenderer->DrawImageFromFile(strImage, x, y, w, h, alpha);
|
||||
}
|
||||
std::wstring CGraphics::GetFont()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetFont " << std::endl;
|
||||
#endif
|
||||
return m_pRenderer->GetFontManager()->GetName();
|
||||
}
|
||||
void CGraphics::SetFont(const std::wstring& name, int face, double size, int style)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"SetFont " << name << L" " << face << L" " << size << L" " << style << std::endl;
|
||||
#endif
|
||||
double DpiX, DpiY;
|
||||
@ -314,21 +346,21 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::FillText(double x, double y, int text)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"FillText " << (wchar_t)text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CommandDrawTextCHAR(text, x, y, 0, 0);
|
||||
}
|
||||
void CGraphics::t(double x, double y, const std::wstring& text)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"t " << text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CommandDrawText(text, x, y, 0, 0);
|
||||
}
|
||||
void CGraphics::tg(int text, double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"tg " << text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_FontStringGID(TRUE);
|
||||
@ -337,21 +369,21 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::SetIntegerGrid(bool param)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "SetIntegerGrid " << param << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_IntegerGrid(param);
|
||||
}
|
||||
bool CGraphics::GetIntegerGrid()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetIntegerGrid " << std::endl;
|
||||
#endif
|
||||
return m_pRenderer->get_IntegerGrid();
|
||||
}
|
||||
void CGraphics::DrawStringASCII (const std::wstring& text, double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"DrawStringASCII " << text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
double DpiY;
|
||||
@ -373,7 +405,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawHeaderEdit(double yPos)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawHeaderEdit " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -416,7 +448,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawFooterEdit(double yPos)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawFooterEdit " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -459,7 +491,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawLockParagraph (double x, double y1, double y2)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawLockParagraph " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -531,7 +563,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawLockObjectRect(double x, double y, double w, double h)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawLockObjectRect " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -557,7 +589,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawEmptyTableLine(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawEmptyTableLine " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -642,7 +674,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawSpellingLine (double y0, double x0, double x1, double w)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawSpellingLine " << std::endl;
|
||||
#endif
|
||||
Aggplus::CMatrix* pMatrix = m_pRenderer->GetTransformMatrix();
|
||||
@ -988,7 +1020,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::SaveGrState()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "SaveGrState " << std::endl;
|
||||
#endif
|
||||
CGrStateState* pState = new CGrStateState();
|
||||
@ -1004,7 +1036,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::RestoreGrState()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "RestoreGrState " << std::endl;
|
||||
#endif
|
||||
if (m_oGrState.States.empty())
|
||||
@ -1068,14 +1100,14 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::StartClipPath()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "StartClipPath " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->BeginCommand(c_nClipType);
|
||||
}
|
||||
void CGraphics::EndClipPath()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "EndClipPath " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->EndCommand(c_nClipType);
|
||||
@ -1133,7 +1165,7 @@ namespace NSGraphics
|
||||
}
|
||||
std::string CGraphics::toDataURL(std::wstring type)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << "toDataURL " << type << std::endl;
|
||||
#endif
|
||||
std::wstring sFormat = (type.length() > 6) ? type.substr(6) : type;
|
||||
@ -1178,11 +1210,11 @@ namespace NSGraphics
|
||||
{
|
||||
if (src.find(L"data:") == 0)
|
||||
{
|
||||
std::wstring strImage = m_sApplicationImagesDirectory + L"/texture.png";
|
||||
std::wstring strImage = m_pAppImage->GetImagesDirectory() + L"/texture.png";
|
||||
bool bIsOnlyOfficeHatch = false;
|
||||
if(src.find(L"onlyoffice_hatch") != std::wstring::npos)
|
||||
bIsOnlyOfficeHatch = true;
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"put_brushTexture " << src << L" " << type << std::endl;
|
||||
#endif
|
||||
src.erase(0, src.find(L',') + 1);
|
||||
@ -1221,7 +1253,10 @@ namespace NSGraphics
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring strImage = (0 == src.find(L"theme") ? m_sApplicationThemesDirectory : m_sApplicationImagesDirectory) + L'/' + src;
|
||||
std::wstring strImage = src;
|
||||
if (!NSFile::CFileBinary::Exists(src))
|
||||
strImage = (0 == src.find(L"theme") ? m_pAppImage->GetThemesDirectory() : m_pAppImage->GetImagesDirectory()) + L'/' + src;
|
||||
|
||||
std::wstring sName = strImage.substr(0, strImage.rfind(L'.') + 1);
|
||||
std::wstring sExt = src.substr(src.rfind(L'.') + 1);
|
||||
if (sExt == L"svg")
|
||||
@ -1231,7 +1266,7 @@ namespace NSGraphics
|
||||
else if (NSFile::CFileBinary::Exists(sName + L"emf") && src.find(L"display") == 0)
|
||||
strImage = sName + L"emf";
|
||||
|
||||
MetaFile::IMetaFile* pMetafile = MetaFile::Create(m_pApplicationFonts);
|
||||
MetaFile::IMetaFile* pMetafile = MetaFile::Create(m_pAppImage->GetFonts());
|
||||
pMetafile->LoadFromFile(strImage.c_str());
|
||||
|
||||
double x = 0, y = 0, w = 0, h = 0;
|
||||
@ -1244,7 +1279,7 @@ namespace NSGraphics
|
||||
}
|
||||
else
|
||||
sName += sExt;
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"put_brushTexture " << sName << L" " << type << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushType(c_BrushTypeTexture);
|
||||
@ -1254,21 +1289,21 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::put_brushTextureMode(int mode)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_brushTextureMode " << mode << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushTextureMode(mode);
|
||||
}
|
||||
void CGraphics::put_BrushTextureAlpha(int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_BrushTextureAlpha " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushTextureAlpha(a == 0 ? 255 : a);
|
||||
}
|
||||
void CGraphics::put_BrushGradient(LONG* pColors, double* pPositions, size_t nCount, double x0, double y0, double x1, double y1, double r0, double r1)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_BrushGradient " << nCount << " " << x0 << " " << y0 << " " << x1 << " " << y1 << " " << r0 << " " << r1 << std::endl;
|
||||
for (size_t i = 0; i < nCount; i++)
|
||||
std::cout << pPositions[i] << " " << pColors[i] << " ";
|
||||
@ -1293,7 +1328,7 @@ namespace NSGraphics
|
||||
}
|
||||
double CGraphics::TransformPointX(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "TransformPointX " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->GetFullTransform()->TransformPoint(x, y);
|
||||
@ -1301,7 +1336,7 @@ namespace NSGraphics
|
||||
}
|
||||
double CGraphics::TransformPointY(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "TransformPointY " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->GetFullTransform()->TransformPoint(x, y);
|
||||
@ -1309,14 +1344,14 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::put_LineJoin(int nJoin)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_LineJoin " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_PenLineJoin(nJoin);
|
||||
}
|
||||
int CGraphics::GetLineJoin()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetLineJoin " << std::endl;
|
||||
#endif
|
||||
BYTE nRes;
|
||||
@ -1325,7 +1360,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::put_TextureBounds(double x, double y, double w, double h)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_TextureBounds " << x << " " << y << " " << w << " " << h << std::endl;
|
||||
#endif
|
||||
if(m_pRenderer->get_IntegerGrid())
|
||||
@ -1341,7 +1376,7 @@ namespace NSGraphics
|
||||
}
|
||||
double CGraphics::GetlineWidth()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetlineWidth " << std::endl;
|
||||
#endif
|
||||
double nRes;
|
||||
@ -1350,7 +1385,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawPath(int path)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawPath " << path << std::endl;
|
||||
#endif
|
||||
if(path == 257)
|
||||
@ -1363,7 +1398,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::CoordTransformOffset(double tx, double ty)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "CoordTransformOffset " << tx << " " << ty << std::endl;
|
||||
#endif
|
||||
m_pRenderer->SetCoordTransformOffset(tx, ty);
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "../common/File.h"
|
||||
#include "nativecontrol.h"
|
||||
#include "../graphics/pro/Graphics.h"
|
||||
#include "embed/GraphicsEmbed.h"
|
||||
|
||||
namespace NSGraphics
|
||||
{
|
||||
@ -114,28 +115,32 @@ namespace NSGraphics
|
||||
class CGraphics
|
||||
{
|
||||
public:
|
||||
std::wstring m_sApplicationFontsDirectory;
|
||||
std::wstring m_sApplicationImagesDirectory;
|
||||
std::wstring m_sApplicationThemesDirectory;
|
||||
CGraphicsAppImage* m_pAppImage;
|
||||
CBgraFrame m_oFrame;
|
||||
|
||||
private:
|
||||
NSFonts ::IApplicationFonts* m_pApplicationFonts;
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer;
|
||||
CBgraFrame m_oFrame;
|
||||
CGrState m_oGrState;
|
||||
|
||||
public:
|
||||
CGraphics() {}
|
||||
CGraphics()
|
||||
{
|
||||
m_pAppImage = NULL;
|
||||
}
|
||||
~CGraphics()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void init(NSNativeControl::CNativeControl* oNative, double width_px, double height_px, double width_mm, double height_mm);
|
||||
void init(double width_px, double height_px, double width_mm, double height_mm);
|
||||
void Destroy()
|
||||
{
|
||||
int w, h;
|
||||
if (m_pAppImage && m_pAppImage->GetBits(w, h))
|
||||
m_oFrame.put_Data(NULL);
|
||||
|
||||
RELEASEINTERFACE(m_pRenderer);
|
||||
RELEASEINTERFACE(m_pApplicationFonts);
|
||||
RELEASEOBJECT(m_pAppImage);
|
||||
}
|
||||
void EndDraw() {}
|
||||
void put_GlobalAlpha(bool enable, double globalAlpha);
|
||||
|
||||
@ -374,7 +374,7 @@ namespace NSJSBase
|
||||
|
||||
JSSmart<CJSContext> CJSContext::GetCurrent()
|
||||
{
|
||||
CJSContext* ret = new CJSContext();
|
||||
CJSContext* ret = new CJSContext(false);
|
||||
ret->m_internal->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -54,9 +54,9 @@ v8::Local<v8::String> CreateV8String(v8::Isolate* i, const std::string& str);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#ifdef _DEBUG
|
||||
#define ANDROID_LOGS
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
#ifdef ANDROID_LOGS
|
||||
#include <android/log.h>
|
||||
@ -488,7 +488,11 @@ namespace NSJSBase
|
||||
|
||||
virtual CJSEmbedObject* getNative()
|
||||
{
|
||||
if (0 == value->InternalFieldCount())
|
||||
return NULL;
|
||||
v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(value->GetInternalField(0));
|
||||
if (field.IsEmpty())
|
||||
return NULL;
|
||||
return (CJSEmbedObject*)field->Value();
|
||||
}
|
||||
|
||||
|
||||
@ -99,6 +99,11 @@ namespace NSJSON
|
||||
return m_internal->m_type == CTypedValue::vtObject;
|
||||
}
|
||||
|
||||
bool IValue::IsImage() const
|
||||
{
|
||||
return m_internal->m_type == CTypedValue::vtImage;
|
||||
}
|
||||
|
||||
bool IValue::ToBool() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtPrimitive)
|
||||
@ -350,6 +355,11 @@ namespace NSJSON
|
||||
strRes += "}";
|
||||
break;
|
||||
}
|
||||
case CTypedValue::vtImage:
|
||||
{
|
||||
// TODO: implement like typed array?
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return strRes;
|
||||
@ -497,6 +507,82 @@ namespace NSJSON
|
||||
return static_cast<CObject*>(m_internal->m_value.get())->getPropertyNames();
|
||||
}
|
||||
|
||||
const BYTE* IValue::GetImageBits() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getBits();
|
||||
}
|
||||
|
||||
BYTE* IValue::GetImageBits()
|
||||
{
|
||||
return const_cast<BYTE*>(static_cast<const CValue&>(*this).GetImageBits());
|
||||
}
|
||||
|
||||
int IValue::GetImageWidth() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getWidth();
|
||||
}
|
||||
|
||||
int IValue::GetImageHeight() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getHeight();
|
||||
}
|
||||
|
||||
ImageFormat IValue::GetImageFormat() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return ImageFormat::ifInvalid;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getFormat();
|
||||
}
|
||||
|
||||
void IValue::ImageExternalize()
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
static_cast<CImage*>(m_internal->m_value.get())->externalize();
|
||||
}
|
||||
|
||||
void IValue::ImageAlloc(const int& width, const int& height, const ImageFormat& format)
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
static_cast<CImage*>(m_internal->m_value.get())->alloc(width, height, format);
|
||||
}
|
||||
|
||||
CValue::CValue() : IValue()
|
||||
{
|
||||
@ -590,6 +676,35 @@ namespace NSJSON
|
||||
NSJSBase::NSAllocator::Free(data, size);
|
||||
}
|
||||
|
||||
CValue CValue::CreateImage(BYTE* bits, int width, int height, ImageFormat format, bool isExternalize)
|
||||
{
|
||||
CValue ret;
|
||||
if (width <= 0 || height <= 0)
|
||||
return ret;
|
||||
|
||||
ret.m_internal->m_value = std::make_shared<CImage>(bits, width, height, format, isExternalize);
|
||||
ret.m_internal->m_type = CTypedValue::vtImage;
|
||||
return ret;
|
||||
}
|
||||
|
||||
CValue CValue::CreateEmptyImage(ImageFormat format)
|
||||
{
|
||||
CValue ret;
|
||||
ret.m_internal->m_value = std::make_shared<CImage>((BYTE*)NULL, 0, 0, format, false);
|
||||
ret.m_internal->m_type = CTypedValue::vtImage;
|
||||
return ret;
|
||||
}
|
||||
|
||||
BYTE* CValue::AllocImageBits(int width, int height)
|
||||
{
|
||||
return new BYTE[4 * width * height];
|
||||
}
|
||||
|
||||
void CValue::FreeImageBits(BYTE* bits)
|
||||
{
|
||||
delete[] bits;
|
||||
}
|
||||
|
||||
CValue CValue::CreateObject()
|
||||
{
|
||||
CValue ret;
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#endif
|
||||
|
||||
// uncomment to enable exceptions throwing
|
||||
//#define JSON_DEBUG
|
||||
// #define JSON_DEBUG
|
||||
|
||||
#ifdef JSON_DEBUG
|
||||
#include <stdexcept>
|
||||
@ -29,6 +29,14 @@
|
||||
namespace NSJSON
|
||||
{
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
enum class ImageFormat
|
||||
{
|
||||
ifRGBA,
|
||||
ifBGRA,
|
||||
ifARGB,
|
||||
ifInvalid
|
||||
};
|
||||
|
||||
class CValue;
|
||||
class CValueRef;
|
||||
@ -88,6 +96,10 @@ namespace NSJSON
|
||||
* Returns true if the value is an object.
|
||||
*/
|
||||
bool IsObject() const;
|
||||
/**
|
||||
* Returns true if the value is an image.
|
||||
*/
|
||||
bool IsImage() const;
|
||||
|
||||
// FUNCTIONS FOR WORKING WITH PRIMITIVE VALUES
|
||||
/**
|
||||
@ -193,6 +205,39 @@ namespace NSJSON
|
||||
*/
|
||||
std::vector<std::string> GetPropertyNames() const;
|
||||
|
||||
// FUNCTIONS FOR WORKING WITH IMAGES
|
||||
/**
|
||||
* Gets bits of image.
|
||||
* @return the pointer to memory, allocated for the image. If current value is not an image, returns nullptr.
|
||||
*/
|
||||
const BYTE* GetImageBits() const;
|
||||
BYTE* GetImageBits();
|
||||
/**
|
||||
* Gets width of the image.
|
||||
* @returns Returns the width of the image. If current value is not an image, returns 0.
|
||||
*/
|
||||
int GetImageWidth() const;
|
||||
/**
|
||||
* Gets height of the image.
|
||||
* @returns Returns the height of the image. If current value is not an image, returns 0.
|
||||
*/
|
||||
int GetImageHeight() const;
|
||||
/**
|
||||
* Gets format of the image.
|
||||
* @returns Returns the image format. If current value is not an image, returns ImageFormat::ifInvalid.
|
||||
*/
|
||||
ImageFormat GetImageFormat() const;
|
||||
|
||||
/**
|
||||
* Make image bits external.
|
||||
*/
|
||||
void ImageExternalize();
|
||||
|
||||
/**
|
||||
* Alloc image bits as internal.
|
||||
*/
|
||||
void ImageAlloc(const int& width, const int& height, const ImageFormat& format);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<CTypedValue> m_internal;
|
||||
};
|
||||
@ -251,6 +296,30 @@ namespace NSJSON
|
||||
*/
|
||||
static void FreeTypedArray(BYTE* data, size_t size);
|
||||
|
||||
// IMAGE
|
||||
/**
|
||||
* Creates and returns new image object.
|
||||
* @param bits The pointer to image data. The pointer should be acquired with AllocImageBits().
|
||||
* @param width The width of the image.
|
||||
* @param height The height of the image.
|
||||
* @param format The format of the image.
|
||||
* @param isExternalize If true the memory will not be reclaimed when the created image is destroyed.
|
||||
* If this parameter is false then the memory will be released using FreeImageBits() during the image object destruction.
|
||||
*/
|
||||
static CValue CreateImage(BYTE* bits, int width, int height, ImageFormat format = ImageFormat::ifBGRA, bool isExternalize = true);
|
||||
static CValue CreateEmptyImage(ImageFormat format = ImageFormat::ifBGRA);
|
||||
/**
|
||||
* Allocates the memory for an image.
|
||||
* @param width The width of the image.
|
||||
* @param height The height of the image.
|
||||
*/
|
||||
static BYTE* AllocImageBits(int width, int height);
|
||||
/**
|
||||
* Frees the memory for a image bits.
|
||||
* @param data The allocated memory to be released.
|
||||
*/
|
||||
static void FreeImageBits(BYTE* bits);
|
||||
|
||||
// OBJECT CONSTRUCTOR
|
||||
/**
|
||||
* Creates and returns empty object.
|
||||
|
||||
@ -17,7 +17,8 @@ namespace NSJSON
|
||||
vtPrimitive,
|
||||
vtArray,
|
||||
vtTypedArray,
|
||||
vtObject
|
||||
vtObject,
|
||||
vtImage
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
@ -211,4 +211,56 @@ namespace NSJSON
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
CImage::CImage(BYTE* bits, const int& width, const int& height, const ImageFormat& format, const bool& isExternalize) :
|
||||
m_bits(bits), m_width(width), m_height(height), m_format(format), m_isExternalize(isExternalize)
|
||||
{
|
||||
}
|
||||
|
||||
CImage::~CImage()
|
||||
{
|
||||
if (!m_isExternalize)
|
||||
{
|
||||
CValue::FreeImageBits(m_bits);
|
||||
}
|
||||
}
|
||||
|
||||
void CImage::alloc(const int& width, const int& height, const ImageFormat& format)
|
||||
{
|
||||
if (!m_isExternalize && m_bits)
|
||||
{
|
||||
CValue::FreeImageBits(m_bits);
|
||||
}
|
||||
|
||||
m_bits = CValue::AllocImageBits(width, height);
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
m_format = format;
|
||||
m_isExternalize = false;
|
||||
}
|
||||
|
||||
BYTE* CImage::getBits()
|
||||
{
|
||||
return m_bits;
|
||||
}
|
||||
|
||||
int CImage::getWidth()
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
int CImage::getHeight()
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
ImageFormat CImage::getFormat()
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
|
||||
void CImage::externalize()
|
||||
{
|
||||
m_isExternalize = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,6 +113,28 @@ namespace NSJSON
|
||||
private:
|
||||
storage_t m_values;
|
||||
};
|
||||
}
|
||||
|
||||
class CImage : public IBaseValue
|
||||
{
|
||||
public:
|
||||
CImage(BYTE* bits, const int& width, const int& height, const ImageFormat& format, const bool& isExternalize = true);
|
||||
~CImage();
|
||||
|
||||
public:
|
||||
BYTE* getBits();
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
ImageFormat getFormat();
|
||||
void externalize();
|
||||
void alloc(const int& width, const int& height, const ImageFormat& format);
|
||||
|
||||
private:
|
||||
BYTE* m_bits;
|
||||
int m_width;
|
||||
int m_height;
|
||||
ImageFormat m_format;
|
||||
bool m_isExternalize;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // JSON_VALUES_H_
|
||||
|
||||
@ -3,9 +3,75 @@
|
||||
|
||||
#include "json.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
#include "../embed/GraphicsEmbed.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
class CAppImageTo : public CGraphicsAppImage
|
||||
{
|
||||
private:
|
||||
NSJSON::CValueRef* m_image;
|
||||
|
||||
public:
|
||||
CAppImageTo(const NSJSON::CValue& image) : CGraphicsAppImage()
|
||||
{
|
||||
m_image = new NSJSON::CValueRef(image);
|
||||
}
|
||||
virtual ~CAppImageTo()
|
||||
{
|
||||
if (m_image)
|
||||
delete m_image;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual unsigned char* GetBits(int& w, int& h)
|
||||
{
|
||||
unsigned char* bits = m_image->GetImageBits();
|
||||
if (NULL != bits)
|
||||
{
|
||||
w = m_image->GetImageWidth();
|
||||
h = m_image->GetImageHeight();
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
virtual unsigned char* AllocBits(const int& w, const int& h)
|
||||
{
|
||||
m_image->ImageAlloc(w, h, GetRgba() ? NSJSON::ImageFormat::ifRGBA : NSJSON::ImageFormat::ifBGRA);
|
||||
return m_image->GetImageBits();
|
||||
}
|
||||
};
|
||||
|
||||
class CAppImageFrom : public CGraphicsAppImage
|
||||
{
|
||||
public:
|
||||
unsigned char* m_pData;
|
||||
int m_nW;
|
||||
int m_nH;
|
||||
public:
|
||||
CAppImageFrom() : CGraphicsAppImage()
|
||||
{
|
||||
m_pData = NULL;
|
||||
m_nW = 0;
|
||||
m_nH = 0;
|
||||
}
|
||||
virtual ~CAppImageFrom()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual unsigned char* GetBits(int& w, int& h)
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
virtual unsigned char* AllocBits(const int& w, const int& h)
|
||||
{
|
||||
m_nW = w;
|
||||
m_nH = h;
|
||||
m_pData = NSJSON::CValue::AllocImageBits(w, h);
|
||||
return m_pData;
|
||||
}
|
||||
};
|
||||
|
||||
namespace NSJSON
|
||||
{
|
||||
static JSSmart<NSJSBase::CJSValue> toJS(const CValue& value)
|
||||
@ -50,6 +116,12 @@ namespace NSJSON
|
||||
JSSmart<NSJSBase::CJSTypedArray> jsTypedArr = NSJSBase::CJSContext::createUint8Array(const_cast<BYTE*>(value.GetData()), value.GetCount());
|
||||
ret = jsTypedArr->toValue();
|
||||
}
|
||||
else if (value.IsImage())
|
||||
{
|
||||
JSSmart<CJSObject> wrap = CJSContext::createEmbedObject("CGraphicsEmbed");
|
||||
((CGraphicsEmbed*)wrap->getNative())->SetAppImage(new CAppImageTo(value));
|
||||
ret = wrap->toValue();
|
||||
}
|
||||
// objects (there is no need for IsObject())
|
||||
else
|
||||
{
|
||||
@ -130,6 +202,25 @@ namespace NSJSON
|
||||
else if (jsValue->isObject())
|
||||
{
|
||||
JSSmart<NSJSBase::CJSObject> jsObj = jsValue->toObject();
|
||||
|
||||
CJSEmbedObject* pNative = jsObj->getNative();
|
||||
if (pNative != NULL)
|
||||
{
|
||||
CGraphicsEmbed* pGrEmbed = dynamic_cast<CGraphicsEmbed*>(pNative);
|
||||
if (pGrEmbed)
|
||||
{
|
||||
CAppImageFrom* pAppImage = dynamic_cast<CAppImageFrom*>(pGrEmbed->GetAppImage());
|
||||
if (pAppImage)
|
||||
{
|
||||
return NSJSON::CValue::CreateImage(pAppImage->m_pData,
|
||||
pAppImage->m_nW,
|
||||
pAppImage->m_nH,
|
||||
pAppImage->GetRgba() ? ImageFormat::ifRGBA : ImageFormat::ifBGRA,
|
||||
false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> properties = jsObj->getPropertyNames();
|
||||
ret = CValue::CreateObject();
|
||||
for (const std::string& name : properties)
|
||||
|
||||
@ -44,7 +44,10 @@ CImagesWorker::CImagesWorker(const std::wstring& sFolder)
|
||||
std::wstring CImagesWorker::GetImageLocal(const std::wstring& sUrl)
|
||||
{
|
||||
if (CServerInstance::getInstance().IsEnable())
|
||||
return L"error";
|
||||
{
|
||||
if (!CServerInstance::getInstance().CheckTmpDirectory(sUrl))
|
||||
return L"error";
|
||||
}
|
||||
std::wstring sExt = NSFile::GetFileExtention(sUrl);
|
||||
std::wstring sRet = L"image" + std::to_wstring(m_nIndex++) + L"." + sExt;
|
||||
m_mapImages.insert(std::make_pair(sUrl, sRet));
|
||||
|
||||
@ -32,11 +32,19 @@
|
||||
#ifndef SERVER_SETTINGS_H
|
||||
#define SERVER_SETTINGS_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "../common/File.h"
|
||||
#include "../common/StringBuilder.h"
|
||||
#include <iostream>
|
||||
|
||||
// class for server version (disable local files and etc)
|
||||
class CServerInstance
|
||||
{
|
||||
private:
|
||||
bool m_bIsEnabled;
|
||||
std::map<std::wstring, bool> m_arMapTmpFiles;
|
||||
|
||||
CServerInstance()
|
||||
{
|
||||
m_bIsEnabled = false;
|
||||
@ -58,6 +66,32 @@ public:
|
||||
{
|
||||
return m_bIsEnabled;
|
||||
}
|
||||
|
||||
void AddTmpFile(const std::wstring& sFolder)
|
||||
{
|
||||
std::wstring sDirectory = sFolder + L"/media";
|
||||
NSStringUtils::string_replace(sDirectory, L"\\", L"/");
|
||||
std::map<std::wstring, bool>::iterator findDir = m_arMapTmpFiles.find(sDirectory);
|
||||
if (findDir == m_arMapTmpFiles.end())
|
||||
m_arMapTmpFiles.insert(std::make_pair(sDirectory, true));
|
||||
}
|
||||
|
||||
void RemoveTmpFile(const std::wstring& sFolder)
|
||||
{
|
||||
std::wstring sDirectory = sFolder + L"/media";
|
||||
NSStringUtils::string_replace(sDirectory, L"\\", L"/");
|
||||
std::map<std::wstring, bool>::iterator findDir = m_arMapTmpFiles.find(sDirectory);
|
||||
if (findDir != m_arMapTmpFiles.end())
|
||||
m_arMapTmpFiles.erase(findDir);
|
||||
}
|
||||
|
||||
bool CheckTmpDirectory(const std::wstring& sFile)
|
||||
{
|
||||
std::wstring sDirectory = NSFile::GetDirectoryName(sFile);
|
||||
NSStringUtils::string_replace(sDirectory, L"\\", L"/");
|
||||
std::map<std::wstring, bool>::iterator findDir = m_arMapTmpFiles.find(sDirectory);
|
||||
return (findDir != m_arMapTmpFiles.end()) ? true : false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -467,6 +467,62 @@ TEST_F(CJSONTest, object)
|
||||
EXPECT_FALSE(compare(obj, jsObj->toValue(), false));
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, image_externalize)
|
||||
{
|
||||
int width = 1080;
|
||||
int height = 480;
|
||||
BYTE* bits = CValue::AllocImageBits(width, height);
|
||||
CValue img = CValue::CreateImage(bits, width, height, ifBGRA);
|
||||
|
||||
EXPECT_TRUE(img.IsImage());
|
||||
EXPECT_EQ(img.GetImageBits(), bits);
|
||||
EXPECT_EQ(img.GetImageWidth(), width);
|
||||
EXPECT_EQ(img.GetImageHeight(), height);
|
||||
EXPECT_EQ(img.GetImageFormat(), ifBGRA);
|
||||
|
||||
CValue::FreeImageBits(bits);
|
||||
|
||||
width = 50;
|
||||
height = 100;
|
||||
bits = CValue::AllocImageBits(width, height);
|
||||
img = CValue::CreateImage(bits, width, height, ifRGBA);
|
||||
|
||||
EXPECT_TRUE(img.IsImage());
|
||||
EXPECT_EQ(img.GetImageBits(), bits);
|
||||
EXPECT_EQ(img.GetImageWidth(), width);
|
||||
EXPECT_EQ(img.GetImageHeight(), height);
|
||||
EXPECT_EQ(img.GetImageFormat(), ifRGBA);
|
||||
|
||||
CValue::FreeImageBits(bits);
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, image_not_externalize)
|
||||
{
|
||||
int width = 320;
|
||||
int height = 480;
|
||||
BYTE* bits = CValue::AllocImageBits(width, height);
|
||||
CValue img = CValue::CreateImage(bits, width, height, ifARGB, false);
|
||||
|
||||
EXPECT_TRUE(img.IsImage());
|
||||
EXPECT_EQ(img.GetImageBits(), bits);
|
||||
EXPECT_EQ(img.GetImageWidth(), width);
|
||||
EXPECT_EQ(img.GetImageHeight(), height);
|
||||
EXPECT_EQ(img.GetImageFormat(), ifARGB);
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, image_wrong_size)
|
||||
{
|
||||
BYTE* bits = CValue::AllocImageBits(100, 100);
|
||||
CValue img = CValue::CreateImage(bits, 0, 100, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
img = CValue::CreateImage(bits, -1, 100, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
img = CValue::CreateImage(bits, 0, 0, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
img = CValue::CreateImage(bits, -100, -100, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, references)
|
||||
{
|
||||
CValue val = 42;
|
||||
@ -526,12 +582,20 @@ TEST_F(CJSONTest, wrong_usage)
|
||||
EXPECT_THROW(val.GetPropertyNames(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetCount(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetData(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageBits(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageFormat(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageHeight(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageWidth(), std::bad_cast);
|
||||
#else
|
||||
EXPECT_TRUE(val["name"].IsUndefined());
|
||||
EXPECT_TRUE(val[0].IsUndefined());
|
||||
EXPECT_TRUE(val.GetPropertyNames().empty());
|
||||
EXPECT_EQ(val.GetCount(), 0);
|
||||
EXPECT_EQ(val.GetData(), nullptr);
|
||||
EXPECT_EQ(val.GetImageBits(), nullptr);
|
||||
EXPECT_EQ(val.GetImageFormat(), ifInvalid);
|
||||
EXPECT_EQ(val.GetImageHeight(), 0);
|
||||
EXPECT_EQ(val.GetImageWidth(), 0);
|
||||
#endif
|
||||
EXPECT_DOUBLE_EQ(val.ToDouble(), 42.0);
|
||||
#ifdef JSON_DEBUG
|
||||
@ -1601,7 +1665,11 @@ TEST_F(CJSONTest, FromJSON_arrays)
|
||||
CValue val = CValue::FromJSON(strJson);
|
||||
EXPECT_TRUE(val.IsArray());
|
||||
EXPECT_EQ(val.GetCount(), 0);
|
||||
#ifndef JSON_DEBUG
|
||||
EXPECT_TRUE(val[0].IsUndefined());
|
||||
#else
|
||||
EXPECT_THROW(val[0], std::out_of_range);
|
||||
#endif
|
||||
|
||||
strJson = "[1, 2, 3]";
|
||||
val = CValue::FromJSON(strJson);
|
||||
|
||||
@ -356,6 +356,8 @@ public:
|
||||
|
||||
virtual void Check(const int& nCode, const unsigned int& nIndex)
|
||||
{
|
||||
if (nCode > m_nMaxSymbols)
|
||||
return;
|
||||
if (nCode > m_nMax)
|
||||
m_nMax = nCode;
|
||||
if (nCode < m_nMin)
|
||||
@ -794,6 +796,8 @@ public:
|
||||
std::wstring sNameCorrect = pPair->second.m_sName;
|
||||
NSStringUtils::string_replace(sNameCorrect, L"\\", L"\\\\");
|
||||
NSStringUtils::string_replace(sNameCorrect, L"\"", L"\\\"");
|
||||
NSStringUtils::string_replace(sNameCorrect, L"\n", L"");
|
||||
NSStringUtils::string_replace(sNameCorrect, L"\r", L"");
|
||||
oWriterJS += sNameCorrect;
|
||||
|
||||
oWriterJS.AddSize(120);
|
||||
|
||||
@ -351,11 +351,17 @@ CFontManager::~CFontManager()
|
||||
RELEASEINTERFACE(m_pFont);
|
||||
RELEASEOBJECT(m_pOwnerCache);
|
||||
}
|
||||
|
||||
void CFontManager::SetOwnerCache(NSFonts::IFontsCache* pCache)
|
||||
{
|
||||
m_pOwnerCache = (CFontsCache*)pCache;
|
||||
}
|
||||
|
||||
void CFontManager::ClearOwnerCache()
|
||||
{
|
||||
m_pOwnerCache->Clear();
|
||||
}
|
||||
|
||||
NSFonts::IFontsCache* CFontManager::GetCache() { return m_pOwnerCache; }
|
||||
NSFonts::IApplicationFonts* CFontManager::GetApplication() { return m_pApplication; }
|
||||
NSFonts::IFontFile* CFontManager::GetFile() { return m_pFont; }
|
||||
|
||||
@ -132,6 +132,7 @@ public:
|
||||
|
||||
virtual void Initialize();
|
||||
virtual void SetOwnerCache(NSFonts::IFontsCache* pCache);
|
||||
virtual void ClearOwnerCache();
|
||||
|
||||
virtual NSFonts::IFontsCache* GetCache();
|
||||
virtual NSFonts::IApplicationFonts* GetApplication();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
* (c) Copyright Ascensio System SIA 2010-2024
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
* (c) Copyright Ascensio System SIA 2010-2024
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
* (c) Copyright Ascensio System SIA 2010-2024
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
@ -531,6 +531,45 @@ ZLib.prototype.getImageAsSvg = function(path)
|
||||
|
||||
return string;
|
||||
};
|
||||
/**
|
||||
* Get image file raw data. this memory was copied and detach from archive.
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
ZLib.prototype.getImageBuffer = function(path)
|
||||
{
|
||||
let result = {
|
||||
type : 0,
|
||||
data : null
|
||||
};
|
||||
result.type = this.getImageType(path);
|
||||
if (result.type === 0)
|
||||
return null;
|
||||
|
||||
let fileData = this.getFile(path);
|
||||
result.data = new Uint8Array(fileData.length);
|
||||
result.data.set(fileData);
|
||||
|
||||
if (result.type != 10 &&
|
||||
result.type != 21)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
result.type = 24;
|
||||
// Source was saved as result.data for using original image in native convertations.
|
||||
// But for js we need svg for metafiles.
|
||||
|
||||
let encodedData = Module["_Raster_Encode"](this.files[path].p + 4, fileData.length, 24);
|
||||
let encodedSize = Module["_Raster_GetEncodedSize"](encodedData);
|
||||
let encodedBuffer = Module["_Raster_GetEncodedBuffer"](encodedData);
|
||||
|
||||
let fileDataEnc = new Uint8Array(Module["HEAP8"].buffer, encodedBuffer, encodedSize);
|
||||
result.dataBlob = new Uint8Array(fileDataEnc.length);
|
||||
result.dataBlob.set(fileDataEnc);
|
||||
|
||||
Module["_Raster_DestroyEncodedData"](encodedData);
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Get image blob for browser
|
||||
* @returns {Blob}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
* (c) Copyright Ascensio System SIA 2010-2024
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
@ -35,7 +35,7 @@
|
||||
window['AscFonts'] = window['AscFonts'] || {};
|
||||
var AscFonts = window['AscFonts'];
|
||||
|
||||
var g_native_engine = CreateEmbedObject("CTextMeasurerEmbed");
|
||||
var g_native_engine = null;
|
||||
|
||||
function CReturnObject()
|
||||
{
|
||||
@ -236,4 +236,6 @@ AscFonts.Hyphen_Word = function(lang, word)
|
||||
AscFonts.onLoadModule();
|
||||
AscFonts.onLoadModule();
|
||||
|
||||
window["InitNativeTextMeasurer"] = function() { g_native_engine = CreateEmbedObject("CTextMeasurerEmbed"); };
|
||||
|
||||
})(window, undefined);
|
||||
|
||||
@ -100,6 +100,7 @@
|
||||
"FT_CONFIG_OPTION_SYSTEM_ZLIB",
|
||||
"GRAPHICS_NO_USE_DYNAMIC_LIBRARY",
|
||||
"HYPHEN_ENGINE_DISABLE_FILESYSTEM",
|
||||
"METAFILE_DISABLE_FILESYSTEM",
|
||||
|
||||
"HAVE_UNISTD_H", "HAVE_FCNTL_H", "_ARM_ALIGN_",
|
||||
"METAFILE_SUPPORT_WMF_EMF",
|
||||
@ -259,10 +260,13 @@
|
||||
"folder": "../../../OfficeUtils/js",
|
||||
"files": ["../src/ZipBuffer.cpp", "wasm/src/base.cpp", "../src/zlib_addon.c"]
|
||||
},
|
||||
|
||||
{
|
||||
"folder": "../../",
|
||||
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp"]
|
||||
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp", "graphics/Matrix.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../agg-2.4/src/",
|
||||
"files": ["agg_trans_affine.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../raster/",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
* (c) Copyright Ascensio System SIA 2010-2024
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
@ -761,6 +761,14 @@ function onLoadFontsModule(window, undefined)
|
||||
{
|
||||
return this.engine["getImageBlob"](path);
|
||||
};
|
||||
/**
|
||||
* Get image file raw data. this memory was copied and detach from archive.
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
ZLib.prototype.getImageBuffer = function(path)
|
||||
{
|
||||
return this.engine["getImageBuffer"](path);
|
||||
};
|
||||
/**
|
||||
* Get all file paths in archive
|
||||
* @returns {Array}
|
||||
@ -772,10 +780,84 @@ function onLoadFontsModule(window, undefined)
|
||||
|
||||
AscCommon.ZLib = ZLib;
|
||||
|
||||
function ZlibImageBlobs()
|
||||
{
|
||||
this.url2BlobUrl = {};
|
||||
this.blobUrl2Data = {};
|
||||
this.url2Base64 = {};
|
||||
|
||||
this.nativeBlobCounter = 1;
|
||||
}
|
||||
ZlibImageBlobs.prototype.getBlobUrl = function(path, zip)
|
||||
{
|
||||
if (this.url2BlobUrl[path])
|
||||
return this.url2BlobUrl[path];
|
||||
|
||||
let result = zip.getImageBuffer(path);
|
||||
if (result == null)
|
||||
return "";
|
||||
|
||||
let blobUrl = "";
|
||||
let blobType = AscCommon.openXml.GetMimeType((24 !== result["type"]) ? AscCommon.GetFileExtension(path) : "svg");
|
||||
|
||||
if (window["NATIVE_EDITOR_ENJINE"])
|
||||
{
|
||||
blobUrl = "blob:internal-image" + this.nativeBlobCounter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
let blob = new Blob([result["dataBlob"] ? result["dataBlob"] : result["data"]], {type: blobType});
|
||||
blobUrl = window.URL.createObjectURL(blob);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
blobUrl = "error";
|
||||
AscCommon.consoleLog("ERROR: Image blob was not loaded");
|
||||
}
|
||||
}
|
||||
|
||||
this.blobUrl2Data[blobUrl] = result;
|
||||
this.url2BlobUrl[path] = blobUrl;
|
||||
return blobUrl;
|
||||
};
|
||||
ZlibImageBlobs.prototype.getImageBase64 = function(url)
|
||||
{
|
||||
if (this.url2Base64[url])
|
||||
return this.url2Base64[url];
|
||||
|
||||
let obj = this.blobUrl2Data[url];
|
||||
if (!obj)
|
||||
return url;
|
||||
|
||||
let header = "";
|
||||
switch (obj.type)
|
||||
{
|
||||
case 3:
|
||||
header = "data:image/jpeg;base64,";
|
||||
break;
|
||||
case 24:
|
||||
header = "data:image/svg+xml;base64,";
|
||||
break;
|
||||
case 4:
|
||||
default:
|
||||
header = "data:image/png;base64,";
|
||||
}
|
||||
|
||||
this.url2Base64[url] = header + AscCommon.Base64.encode(obj.data);
|
||||
return this.url2Base64[url];
|
||||
};
|
||||
|
||||
window["AscCommon"].g_oDocumentBlobUrls = new ZlibImageBlobs();
|
||||
|
||||
if (AscCommon["CZLibEngineJS"])
|
||||
AscCommon["CZLibEngineJS"].prototype["isModuleInit"] = true;
|
||||
|
||||
window.nativeZlibEngine = new ZLib();
|
||||
if (window["NATIVE_EDITOR_ENJINE"])
|
||||
window["InitNativeZLib"] = function() { window.nativeZlibEngine = new ZLib(); };
|
||||
else
|
||||
window.nativeZlibEngine = new ZLib();
|
||||
|
||||
function Hyphenation()
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#include "AlphaMask.h"
|
||||
#include <string.h>
|
||||
#include "AlphaMask_p.h"
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
@ -33,7 +32,6 @@ namespace Aggplus
|
||||
{
|
||||
case EMaskDataType::ImageBuffer: return 4;
|
||||
case EMaskDataType::AlphaBuffer: return 1;
|
||||
case EMaskDataType::Alpha4Buffer: return 4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,130 +63,26 @@ namespace Aggplus
|
||||
return Ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CSoftMask::CSoftMask() : m_unWidth(0), m_unHeight(0), m_pImageData(NULL), m_pAlphaBufferData(NULL) {}
|
||||
CSoftMask::CSoftMask(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer, bool bFlip) : m_pImageData(NULL), m_pAlphaBufferData(NULL)
|
||||
CSoftMask::CSoftMask(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bFlip, bool bRGB, bool bAlpha)
|
||||
{
|
||||
LoadFromBuffer(pBuffer, unWidth, unHeight, enDataType, bExternalBuffer, bFlip);
|
||||
if (bAlpha)
|
||||
m_pInternal = new CSoftMaskAlpha(pBuffer, unWidth, unHeight, false, bFlip);
|
||||
else
|
||||
{
|
||||
if (bRGB)
|
||||
m_pInternal = new CSoftMaskBGRAgray(pBuffer, unWidth, unHeight, false, bFlip);
|
||||
else
|
||||
m_pInternal = new CSoftMaskRGBAgray(pBuffer, unWidth, unHeight, false, bFlip);
|
||||
}
|
||||
}
|
||||
CSoftMask::~CSoftMask()
|
||||
{
|
||||
BYTE* pBuffer = m_oRenderingBuffer.buf();
|
||||
if (NULL != pBuffer)
|
||||
{
|
||||
if (!m_bExternalBuffer)
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
|
||||
m_oRenderingBuffer.attach(NULL, 0, 0, 0);
|
||||
}
|
||||
|
||||
RELEASEOBJECT(m_pImageData);
|
||||
RELEASEOBJECT(m_pAlphaBufferData);
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
}
|
||||
|
||||
EMaskDataType CSoftMask::GetDataType() const { return m_enDataType; }
|
||||
unsigned int CSoftMask::GetStep() const
|
||||
{
|
||||
switch(m_enDataType)
|
||||
{
|
||||
case EMaskDataType::ImageBuffer: return 4;
|
||||
case EMaskDataType::AlphaBuffer: return 1;
|
||||
case EMaskDataType::Alpha4Buffer: return 4;
|
||||
}
|
||||
}
|
||||
unsigned int CSoftMask::GetWidth() const { return m_unWidth; }
|
||||
unsigned int CSoftMask::GetHeight() const { return m_unHeight; }
|
||||
|
||||
void CSoftMask::SetType(EMaskDataType enDataType)
|
||||
{
|
||||
m_enDataType = enDataType;
|
||||
|
||||
RELEASEOBJECT(m_pImageData);
|
||||
RELEASEOBJECT(m_pAlphaBufferData);
|
||||
|
||||
switch (enDataType)
|
||||
{
|
||||
case EMaskDataType::ImageBuffer:
|
||||
{
|
||||
m_pImageData = new AMaskFromImage(m_oRenderingBuffer);
|
||||
m_pImageData->m_oRendererBase.attach(m_pImageData->m_oPixfmt);
|
||||
m_pImageData->m_oAlphaMask.attach(m_oRenderingBuffer);
|
||||
break;
|
||||
}
|
||||
case EMaskDataType::Alpha4Buffer:
|
||||
{
|
||||
m_pAlphaBufferData = new AMaskFromABuffer(m_oRenderingBuffer);
|
||||
m_pAlphaBufferData->m_oRendererBase.attach(m_pAlphaBufferData->m_oPixfmt);
|
||||
m_pAlphaBufferData->m_oAlphaMask.attach(m_oRenderingBuffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Status CSoftMask::Create(UINT unWidth, UINT unHeight, EMaskDataType enDataType)
|
||||
{
|
||||
if (0 == unWidth || 0 == unHeight)
|
||||
return InvalidParameter;
|
||||
|
||||
m_bExternalBuffer = false;
|
||||
|
||||
UINT unSize = unWidth * unHeight * GetStep();
|
||||
BYTE* pAlphaBufffer = new BYTE[unSize];
|
||||
if (!pAlphaBufffer)
|
||||
return OutOfMemory;
|
||||
|
||||
memset(pAlphaBufffer, 0x00, unSize);
|
||||
|
||||
Set(pAlphaBufffer, unWidth, unHeight, enDataType);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CSoftMask::LoadFromBuffer(BYTE *pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer, bool bFlip)
|
||||
{
|
||||
if (NULL == pBuffer || 0 == unWidth || 0 == unHeight)
|
||||
return InvalidParameter;
|
||||
|
||||
m_bExternalBuffer = bExternalBuffer;
|
||||
|
||||
Set(pBuffer, unWidth, unHeight, enDataType, bFlip);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
RenBaseBGRA32& CSoftMask::GetRendererBaseImage()
|
||||
{
|
||||
return m_pImageData->m_oRendererBase;
|
||||
}
|
||||
|
||||
ScanlineBGRA32Gray& CSoftMask::GetScanlineImage()
|
||||
{
|
||||
return m_pImageData->m_oScanLine;
|
||||
}
|
||||
|
||||
ScanlineBGRA32A& CSoftMask::GetScanlineABuffer()
|
||||
{
|
||||
return m_pAlphaBufferData->m_oScanLine;
|
||||
}
|
||||
|
||||
BYTE* CSoftMask::GetBuffer()
|
||||
{
|
||||
return m_oRenderingBuffer.buf();
|
||||
}
|
||||
|
||||
agg::rendering_buffer& CSoftMask::GetRenderingBuffer()
|
||||
{
|
||||
return m_oRenderingBuffer;
|
||||
}
|
||||
|
||||
void CSoftMask::Set(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bFlip)
|
||||
{
|
||||
m_enDataType = enDataType;
|
||||
m_unWidth = unWidth;
|
||||
m_unHeight = unHeight;
|
||||
m_oRenderingBuffer.attach(pBuffer, unWidth, unHeight, (bFlip ? -1 : 1) * GetStep() * unWidth);
|
||||
|
||||
SetType(enDataType);
|
||||
}
|
||||
unsigned int CSoftMask::GetStep() const { return m_pInternal->GetStep(); }
|
||||
unsigned int CSoftMask::GetWidth() const { return m_pInternal->GetWidth(); }
|
||||
unsigned int CSoftMask::GetHeight() const { return m_pInternal->GetHeight(); }
|
||||
BYTE* CSoftMask::GetBuffer() { return m_pInternal->GetBuffer(); }
|
||||
ESoftMaskType CSoftMask::GetDataType() { return m_pInternal->GetDataType(); }
|
||||
}
|
||||
|
||||
@ -1,23 +1,16 @@
|
||||
#ifndef _BUILD_ALPHAMASK_H_
|
||||
#define _BUILD_ALPHAMASK_H_
|
||||
|
||||
#include <string>
|
||||
#include "aggplustypes.h"
|
||||
#include "../common/IGrObject.h"
|
||||
#include "./config.h"
|
||||
|
||||
#include "../agg-2.4/include/agg_renderer_base.h"
|
||||
#include "../agg-2.4/include/agg_pixfmt_rgba.h"
|
||||
#include "../agg-2.4/include/agg_scanline_u.h"
|
||||
#include "../agg-2.4/include/agg_alpha_mask_u8.h"
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
enum class EMaskDataType
|
||||
{
|
||||
ImageBuffer,
|
||||
AlphaBuffer,
|
||||
Alpha4Buffer
|
||||
AlphaBuffer
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CAlphaMask : public IGrObject
|
||||
@ -39,56 +32,30 @@ namespace Aggplus
|
||||
bool m_bExternalBuffer;
|
||||
};
|
||||
|
||||
template <class PixelFormat, class AlphaMask>
|
||||
struct TAlphaMaskData
|
||||
enum class ESoftMaskType
|
||||
{
|
||||
TAlphaMaskData(agg::rendering_buffer& oRenderingBuffer) : m_oPixfmt(oRenderingBuffer), m_oScanLine(m_oAlphaMask) {};
|
||||
|
||||
PixelFormat m_oPixfmt;
|
||||
agg::renderer_base<PixelFormat> m_oRendererBase;
|
||||
AlphaMask m_oAlphaMask;
|
||||
agg::scanline_u8_am<AlphaMask> m_oScanLine;
|
||||
RGBGrayBuffer,
|
||||
BGRGrayBuffer,
|
||||
Alpha4Buffer
|
||||
};
|
||||
|
||||
typedef agg::renderer_base<agg::pixfmt_bgra32> RenBaseBGRA32;
|
||||
typedef agg::scanline_u8_am<agg::alpha_mask_bgra32gray> ScanlineBGRA32Gray;
|
||||
typedef agg::scanline_u8_am<agg::alpha_mask_bgra32a> ScanlineBGRA32A;
|
||||
|
||||
class CSoftMask_private;
|
||||
class GRAPHICS_DECL CSoftMask : public IGrObject
|
||||
{
|
||||
public:
|
||||
CSoftMask();
|
||||
CSoftMask(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer = true, bool bFlip = false);
|
||||
virtual ~CSoftMask();
|
||||
CSoftMask(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bFlip, bool bRGB, bool bAlpha);
|
||||
~CSoftMask();
|
||||
|
||||
EMaskDataType GetDataType() const;
|
||||
unsigned int GetStep() const;
|
||||
unsigned int GetWidth() const;
|
||||
unsigned int GetHeight() const;
|
||||
BYTE* GetBuffer();
|
||||
ESoftMaskType GetDataType();
|
||||
|
||||
void SetType(EMaskDataType enDataType);
|
||||
Status Create(UINT unWidth, UINT unHeight, EMaskDataType enDataType);
|
||||
Status LoadFromBuffer(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer = true, bool bFlip = false);
|
||||
|
||||
agg::rendering_buffer& GetRenderingBuffer();
|
||||
RenBaseBGRA32& GetRendererBaseImage();
|
||||
ScanlineBGRA32Gray& GetScanlineImage();
|
||||
ScanlineBGRA32A& GetScanlineABuffer();
|
||||
BYTE* GetBuffer();
|
||||
private:
|
||||
void Set(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bFlip = false);
|
||||
CSoftMask_private* m_pInternal;
|
||||
|
||||
agg::rendering_buffer m_oRenderingBuffer;
|
||||
EMaskDataType m_enDataType;
|
||||
bool m_bExternalBuffer;
|
||||
unsigned int m_unWidth;
|
||||
unsigned int m_unHeight;
|
||||
|
||||
typedef TAlphaMaskData<agg::pixfmt_bgra32, agg::alpha_mask_bgra32gray> AMaskFromImage;
|
||||
typedef TAlphaMaskData<agg::pixfmt_bgra32, agg::alpha_mask_bgra32a> AMaskFromABuffer;
|
||||
|
||||
AMaskFromImage* m_pImageData;
|
||||
AMaskFromABuffer* m_pAlphaBufferData;
|
||||
friend class CGraphics;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
96
DesktopEditor/graphics/AlphaMask_p.h
Normal file
96
DesktopEditor/graphics/AlphaMask_p.h
Normal file
@ -0,0 +1,96 @@
|
||||
#ifndef _BUILD_ALPHAMASK_P_H_
|
||||
#define _BUILD_ALPHAMASK_P_H_
|
||||
|
||||
#include "AlphaMask.h"
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
#include "../agg-2.4/include/agg_rendering_buffer.h"
|
||||
#include "../agg-2.4/include/agg_scanline_u.h"
|
||||
#include "../agg-2.4/include/agg_alpha_mask_u8.h"
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
class CSoftMask_private
|
||||
{
|
||||
public:
|
||||
virtual ~CSoftMask_private()
|
||||
{
|
||||
BYTE* pBuffer = m_oRenderingBuffer.buf();
|
||||
if (NULL != pBuffer)
|
||||
{
|
||||
if (!m_bExternalBuffer)
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
|
||||
m_oRenderingBuffer.attach(NULL, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int GetStep() const { return 4; }
|
||||
unsigned int GetWidth() const { return m_unWidth; }
|
||||
unsigned int GetHeight() const { return m_unHeight; }
|
||||
BYTE* GetBuffer() { return m_oRenderingBuffer.buf(); }
|
||||
|
||||
virtual ESoftMaskType GetDataType() const = 0;
|
||||
virtual bool GetSwapRGB() const { return true; };
|
||||
|
||||
protected:
|
||||
CSoftMask_private(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
{
|
||||
m_bExternalBuffer = bExternalBuffer;
|
||||
m_unWidth = unWidth;
|
||||
m_unHeight = unHeight;
|
||||
m_oRenderingBuffer.attach(pBuffer, unWidth, unHeight, (bFlip ? -1 : 1) * GetStep() * unWidth);
|
||||
}
|
||||
|
||||
agg::rendering_buffer m_oRenderingBuffer;
|
||||
bool m_bExternalBuffer;
|
||||
unsigned int m_unWidth;
|
||||
unsigned int m_unHeight;
|
||||
};
|
||||
|
||||
class CSoftMaskBGRAgray : public CSoftMask_private
|
||||
{
|
||||
public:
|
||||
CSoftMaskBGRAgray(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
: CSoftMask_private(pBuffer, unWidth, unHeight, bExternalBuffer, bFlip), m_oAlphaMask(m_oRenderingBuffer), m_oScanLine(m_oAlphaMask) {}
|
||||
|
||||
agg::scanline_u8_am<agg::alpha_mask_bgra32gray>& GetScanline() { return m_oScanLine; }
|
||||
virtual ESoftMaskType GetDataType() const override { return ESoftMaskType::BGRGrayBuffer; }
|
||||
|
||||
private:
|
||||
agg::alpha_mask_bgra32gray m_oAlphaMask;
|
||||
agg::scanline_u8_am<agg::alpha_mask_bgra32gray> m_oScanLine;
|
||||
};
|
||||
|
||||
class CSoftMaskRGBAgray : public CSoftMask_private
|
||||
{
|
||||
public:
|
||||
CSoftMaskRGBAgray(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
: CSoftMask_private(pBuffer, unWidth, unHeight, bExternalBuffer, bFlip), m_oAlphaMask(m_oRenderingBuffer), m_oScanLine(m_oAlphaMask) {}
|
||||
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32gray>& GetScanline() { return m_oScanLine; }
|
||||
virtual bool GetSwapRGB() const override { return false; };
|
||||
virtual ESoftMaskType GetDataType() const override { return ESoftMaskType::RGBGrayBuffer; }
|
||||
|
||||
private:
|
||||
agg::alpha_mask_rgba32gray m_oAlphaMask;
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32gray> m_oScanLine;
|
||||
};
|
||||
|
||||
class CSoftMaskAlpha : public CSoftMask_private
|
||||
{
|
||||
public:
|
||||
CSoftMaskAlpha(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
: CSoftMask_private(pBuffer, unWidth, unHeight, bExternalBuffer, bFlip), m_oAlphaMask(m_oRenderingBuffer), m_oScanLine(m_oAlphaMask) {}
|
||||
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32a>& GetScanline() { return m_oScanLine; }
|
||||
virtual ESoftMaskType GetDataType() const override { return ESoftMaskType::Alpha4Buffer; }
|
||||
|
||||
private:
|
||||
agg::alpha_mask_rgba32a m_oAlphaMask;
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32a> m_oScanLine;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_ALPHAMASK_P_H_
|
||||
@ -107,9 +107,14 @@ namespace NSThreads
|
||||
{
|
||||
if (i->ID == nThreadId)
|
||||
{
|
||||
CBaseThreadInfo last;
|
||||
last.ID = i->ID;
|
||||
last.Instance = i->Instance;
|
||||
|
||||
m_listThreads.erase(i);
|
||||
m_listThreads.insert(m_listThreads.begin(), *i);
|
||||
return i->Instance;
|
||||
m_listThreads.insert(m_listThreads.begin(), last);
|
||||
|
||||
return last.Instance;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -142,6 +142,14 @@ std::vector<double> Curve::GetYValues() const noexcept
|
||||
return {Segment1.P.Y, Segment2.P.Y + Segment2.HI.Y, Segment2.P.Y + Segment2.HO.Y, Segment2.P.Y};
|
||||
}
|
||||
|
||||
std::vector<double> Curve::GetBound() const noexcept
|
||||
{
|
||||
return {min(Segment1.P.X, Segment2.P.X + Segment2.HI.X, Segment2.P.X + Segment2.HO.X, Segment2.P.X),
|
||||
min(Segment1.P.Y, Segment2.P.Y + Segment2.HI.Y, Segment2.P.Y + Segment2.HO.Y, Segment2.P.Y),
|
||||
max(Segment1.P.X, Segment2.P.X + Segment2.HI.X, Segment2.P.X + Segment2.HO.X, Segment2.P.X),
|
||||
max(Segment1.P.Y, Segment2.P.Y + Segment2.HI.Y, Segment2.P.Y + Segment2.HO.Y, Segment2.P.Y)};
|
||||
}
|
||||
|
||||
std::vector<double> Curve::GetPeeks() const
|
||||
{
|
||||
std::vector<double> x = GetXValues(),
|
||||
@ -232,6 +240,7 @@ double Curve::GetTimeOf(const PointD& point) const noexcept
|
||||
if (getDistance(point, GetPoint(u)) <= GEOMETRIC_EPSILON)
|
||||
return u;
|
||||
}
|
||||
roots.clear();
|
||||
}
|
||||
}
|
||||
bool firstDist = d0 <= GEOMETRIC_EPSILON,
|
||||
@ -269,8 +278,31 @@ double Curve::GetTimeAt(const double& offset) const noexcept
|
||||
by = 6 * (y[0] + y[2]) - 12 * y[1],
|
||||
cy = 3 * (y[1] - y[0]);
|
||||
|
||||
return findRoot(length, start, offset, ax, bx, cx,
|
||||
ay, by, cy, start + guess, a, b);
|
||||
double vx = start + guess;
|
||||
for (size_t i = 0; i < 32; i++)
|
||||
{
|
||||
length += integrate(ax, bx, cx, ay, by, cy, start, vx, getIterations(start, vx));
|
||||
start = vx;
|
||||
|
||||
double dx = vx - (length - offset) / CurveLength(vx, ax, bx, cx, ay, by, cy);
|
||||
if (fabs(vx - dx) < EPSILON)
|
||||
{
|
||||
vx = dx;
|
||||
break;
|
||||
}
|
||||
|
||||
if (length - offset > 0)
|
||||
{
|
||||
b = vx;
|
||||
vx = dx <= a ? (a + b) * 0.5 : dx;
|
||||
}
|
||||
else{
|
||||
a = vx;
|
||||
vx = dx >= b ? (a + b) * 0.5 : dx;
|
||||
}
|
||||
}
|
||||
|
||||
return clamp(vx, a, b);
|
||||
}
|
||||
|
||||
PointD Curve::Get(const double& t, const int& type) const noexcept
|
||||
@ -312,8 +344,8 @@ PointD Curve::Get(const double& t, const int& type) const noexcept
|
||||
}
|
||||
else if (t > tMax)
|
||||
{
|
||||
x0 = 3 * (x[3] - y[2]);
|
||||
y0 = 3 * (y[3] - x[2]);
|
||||
x0 = 3 * (x[3] - x[2]);
|
||||
y0 = 3 * (y[3] - y[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -369,7 +401,7 @@ Curve Curve::GetPart(double from, double to) const noexcept
|
||||
result.Segment2.HO.X -= result.Segment2.P.X;
|
||||
result.Segment2.HO.Y -= result.Segment2.P.Y;
|
||||
}
|
||||
else if (to < 1)
|
||||
if (to < 1)
|
||||
{
|
||||
result = result.Subdivide((to - from) / (1 - from))[0];
|
||||
result.Segment2.HI.X -= result.Segment2.P.X;
|
||||
@ -407,15 +439,15 @@ std::vector<std::pair<double, double>> Curve::GetOverlaps(const Curve& curve) co
|
||||
std::swap(y1, y2);
|
||||
}
|
||||
|
||||
double d20 = getDistance(px, py, vx, vy, x2[0], y2[0], true),
|
||||
d23 = getDistance(px, py, vx, vy, x2[3], y2[3], true);
|
||||
double d20 = fabs(getSignedDistance(px, py, vx, vy, x2[0], y2[0], true)),
|
||||
d23 = fabs(getSignedDistance(px, py, vx, vy, x2[3], y2[3], true));
|
||||
|
||||
if (d20 < GEOMETRIC_EPSILON && d23 < GEOMETRIC_EPSILON)
|
||||
{
|
||||
double d11 = getDistance(px, py, vx, vy, x1[1], y1[1], true),
|
||||
d12 = getDistance(px, py, vx, vy, x1[2], y1[2], true),
|
||||
d21 = getDistance(px, py, vx, vy, x2[1], y2[1], true),
|
||||
d22 = getDistance(px, py, vx, vy, x2[2], y2[2], true);
|
||||
double d11 = fabs(getSignedDistance(px, py, vx, vy, x1[1], y1[1], true)),
|
||||
d12 = fabs(getSignedDistance(px, py, vx, vy, x1[2], y1[2], true)),
|
||||
d21 = fabs(getSignedDistance(px, py, vx, vy, x2[1], y2[1], true)),
|
||||
d22 = fabs(getSignedDistance(px, py, vx, vy, x2[2], y2[2], true));
|
||||
|
||||
if (!straightBoth &&
|
||||
d11 < GEOMETRIC_EPSILON &&
|
||||
@ -611,10 +643,10 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
q = c2 * x + d;
|
||||
|
||||
double t = q / a,
|
||||
r = pow(fabs(t), 1 / 3),
|
||||
r = pow(fabs(t), 1.0 / 3.0),
|
||||
s = t < 0 ? -1 : 1,
|
||||
td = -qd / a,
|
||||
rd = td > 0 ? 1.324717957244746 * std::max(r, sqrt(td)) : r,
|
||||
rd = td > 0 ? 1.324717957244746 * std::max(r, std::sqrt(td)) : r,
|
||||
x0 = x - s * rd;
|
||||
|
||||
if (x0 != x)
|
||||
@ -653,8 +685,11 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
|
||||
void Curve::Flip() noexcept
|
||||
{
|
||||
PointD tmpHI = Segment2.P + Segment2.HI;
|
||||
PointD tmpHO = Segment2.P + Segment2.HO;
|
||||
std::swap(Segment1.P, Segment2.P);
|
||||
std::swap(Segment1.HI, Segment1.HO);
|
||||
Segment2.HI = tmpHI - Segment2.P;
|
||||
Segment2.HO = tmpHO - Segment2.P;
|
||||
}
|
||||
|
||||
bool Curve::IsStraight() const noexcept
|
||||
@ -707,10 +742,12 @@ bool Location::IsTouching() noexcept
|
||||
|
||||
CBooleanOperations::CBooleanOperations(const CGraphicsPath& path1,
|
||||
const CGraphicsPath& path2,
|
||||
BooleanOpType op) :
|
||||
BooleanOpType op,
|
||||
long fillType) :
|
||||
Op(op),
|
||||
Close1(path1.Is_poly_closed()),
|
||||
Close2(path2.Is_poly_closed()),
|
||||
FillType(fillType),
|
||||
Path1(path1),
|
||||
Path2(path2)
|
||||
{
|
||||
@ -990,7 +1027,7 @@ void CBooleanOperations::TracePaths()
|
||||
start = true;
|
||||
while (valid)
|
||||
{
|
||||
if (!start || (Op == Intersection && s.Inters))
|
||||
if (!start || (Op == Intersection && s.Inters && !GetNextSegment(s).Inters))
|
||||
SetVisited(s);
|
||||
|
||||
if (start)
|
||||
@ -1216,35 +1253,22 @@ void CBooleanOperations::SetVisited(const Segment& segment)
|
||||
Segments2[segment.Index].Visited = true;
|
||||
}
|
||||
|
||||
std::vector<std::vector<double>> CBooleanOperations::GetBoundsForCurves(const std::vector<Curve>& curves) const noexcept
|
||||
{
|
||||
std::vector<std::vector<double>> bounds;
|
||||
for (int i = 0; i < curves.size(); i++)
|
||||
{
|
||||
std::vector<double> x = curves[i].GetXValues(),
|
||||
y = curves[i].GetYValues();
|
||||
bounds.push_back({min(x[0], x[1], x[2], x[3]),
|
||||
min(y[0], y[1], y[2], y[3]),
|
||||
max(x[0], x[1], x[2], x[3]),
|
||||
max(y[0], y[1], y[2], y[3])});
|
||||
}
|
||||
return bounds;
|
||||
}
|
||||
|
||||
std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
{
|
||||
std::vector<std::vector<double>> bounds1 = GetBoundsForCurves(Curves1);
|
||||
std::vector<std::vector<double>> bounds2 = GetBoundsForCurves(Curves2);
|
||||
std::vector<std::vector<double>> allBounds, bounds2;
|
||||
for (const auto& c : Curves1)
|
||||
allBounds.push_back(c.GetBound());
|
||||
for (const auto& c : Curves2)
|
||||
bounds2.push_back(c.GetBound());
|
||||
|
||||
bool self = bounds1 == bounds2;
|
||||
bool self = allBounds == bounds2;
|
||||
|
||||
std::vector<std::vector<double>> allBounds(bounds1);
|
||||
if (!self)
|
||||
for (auto it = bounds2.begin(); it != bounds2.end(); ++it) // std::copy(bounds2.begin(), bounds2.end(), std::back_inserter(allBounds));
|
||||
for (auto it = bounds2.begin(); it != bounds2.end(); ++it)
|
||||
allBounds.push_back(*it);
|
||||
|
||||
int allLength = static_cast<int>(allBounds.size()),
|
||||
length1 = static_cast<int>(bounds1.size());
|
||||
length1 = static_cast<int>(Curves1.size());
|
||||
|
||||
std::vector<int> allIdicesByPri1(allLength);
|
||||
for (int i = 0; i < allLength; i++)
|
||||
@ -1260,56 +1284,47 @@ std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
std::vector<std::vector<int>> allCollisions(length1);
|
||||
for (int i = 0; i < allLength; i++)
|
||||
{
|
||||
int curIndex = allIdicesByPri1[i];
|
||||
std::vector<double> curBounds = allBounds[curIndex];
|
||||
std::vector<int> curCollisions;
|
||||
bool isCurrent1 = curIndex < length1,
|
||||
bool isCurrent1 = allIdicesByPri1[i] < length1,
|
||||
isCurrent2 = self || !isCurrent1;
|
||||
int origIndex = self ? curIndex : curIndex - length1;
|
||||
int origIndex = self ? allIdicesByPri1[i] : allIdicesByPri1[i] - length1;
|
||||
|
||||
if (!activeIndicesByPri2.empty())
|
||||
{
|
||||
int pruneCount = binarySearch(allBounds, activeIndicesByPri2, 2,
|
||||
curBounds[0] - GEOMETRIC_EPSILON) + 1;
|
||||
allBounds[allIdicesByPri1[i]][0] - GEOMETRIC_EPSILON) + 1;
|
||||
|
||||
activeIndicesByPri2.erase(activeIndicesByPri2.begin(),
|
||||
activeIndicesByPri2.begin() + pruneCount);
|
||||
|
||||
double curSec2 = curBounds[3],
|
||||
curSec1 = curBounds[1];
|
||||
for (int j = 0; j < static_cast<int>(activeIndicesByPri2.size()); j++)
|
||||
{
|
||||
int activeIndex = activeIndicesByPri2[j];
|
||||
std::vector<double> activeBounds = allBounds[activeIndex];
|
||||
bool isActive1 = activeIndex < length1,
|
||||
bool isActive1 = activeIndicesByPri2[j] < length1,
|
||||
isActive2 = self || !isActive1,
|
||||
isActive1Or2 = (isCurrent1 && isActive2) || (isCurrent2 && isActive1),
|
||||
inRange1 = curSec1 <= activeBounds[3] + GEOMETRIC_EPSILON,
|
||||
inRange2 = curSec2 >= activeBounds[1] - GEOMETRIC_EPSILON;
|
||||
inRange1 = allBounds[allIdicesByPri1[i]][1] <= allBounds[activeIndicesByPri2[j]][3] + GEOMETRIC_EPSILON,
|
||||
inRange2 = allBounds[allIdicesByPri1[i]][3] >= allBounds[activeIndicesByPri2[j]][1] - GEOMETRIC_EPSILON;
|
||||
|
||||
if (isActive1Or2 && (inRange2 && inRange1))
|
||||
{
|
||||
if (isCurrent1 && isActive2)
|
||||
curCollisions.push_back(self ? activeIndex : activeIndex - length1);
|
||||
curCollisions.push_back(self ? activeIndicesByPri2[j] : activeIndicesByPri2[j] - length1);
|
||||
if (isCurrent2 && isActive1)
|
||||
allCollisions[activeIndex].push_back(origIndex);
|
||||
allCollisions[activeIndicesByPri2[j]].push_back(origIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isCurrent1)
|
||||
{
|
||||
if (bounds1 == bounds2)
|
||||
curCollisions.push_back(curIndex);
|
||||
allCollisions[curIndex] = curCollisions;
|
||||
if (self) curCollisions.push_back(allIdicesByPri1[i]);
|
||||
allCollisions[allIdicesByPri1[i]] = curCollisions;
|
||||
}
|
||||
if (activeIndicesByPri2.size() > 0)
|
||||
{
|
||||
double curPri2 = curBounds[2];
|
||||
int index = binarySearch(allBounds, activeIndicesByPri2, 2, curPri2);
|
||||
activeIndicesByPri2.insert(activeIndicesByPri2.begin() + (1 + index), curIndex);
|
||||
int index = 1 + binarySearch(allBounds, activeIndicesByPri2, 2, allBounds[allIdicesByPri1[i]][2]);
|
||||
activeIndicesByPri2.insert(activeIndicesByPri2.begin() + index, allIdicesByPri1[i]);
|
||||
}
|
||||
else
|
||||
activeIndicesByPri2.push_back(curIndex);
|
||||
activeIndicesByPri2.push_back(allIdicesByPri1[i]);
|
||||
}
|
||||
|
||||
for (auto& c : allCollisions)
|
||||
@ -1382,11 +1397,6 @@ bool CBooleanOperations::IsCrossing(std::shared_ptr<Location> loc) noexcept
|
||||
return t1Inside ? inRange1 : inRange2;
|
||||
}
|
||||
|
||||
bool CBooleanOperations::FilterIntersections(std::shared_ptr<Location> loc) noexcept
|
||||
{
|
||||
return loc->Overlap || IsCrossing(loc);
|
||||
}
|
||||
|
||||
bool CBooleanOperations::IntersectsBounds() noexcept
|
||||
{
|
||||
RectF_T<double> rect1, rect2;
|
||||
@ -1401,17 +1411,12 @@ bool CBooleanOperations::IntersectsBounds() noexcept
|
||||
|
||||
void CBooleanOperations::GetIntersection()
|
||||
{
|
||||
if (!IntersectsBounds())
|
||||
return;
|
||||
if (!IntersectsBounds()) return;
|
||||
|
||||
std::vector<std::vector<int>> boundsCollisions = FindBoundsCollisions();
|
||||
for (int index1 = 0; index1 < Curves1.size(); index1++)
|
||||
{
|
||||
std::vector<int> collisions1 = boundsCollisions[index1];
|
||||
if (!collisions1.empty())
|
||||
for (int j = 0; j < collisions1.size(); j++)
|
||||
GetCurveIntersection(Curves1[index1], Curves2[collisions1[j]]);
|
||||
}
|
||||
for (int j = 0; j < boundsCollisions[index1].size(); j++)
|
||||
GetCurveIntersection(Curves1[index1], Curves2[boundsCollisions[index1][j]]);
|
||||
}
|
||||
|
||||
void CBooleanOperations::GetCurveIntersection(const Curve& curve1, const Curve& curve2)
|
||||
@ -1532,15 +1537,15 @@ int CBooleanOperations::AddCurveIntersection(const Curve& curve1, const Curve& c
|
||||
x2 = curve2.GetXValues(),
|
||||
y2 = curve2.GetYValues();
|
||||
|
||||
double d1 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x2[1], y2[1]),
|
||||
d2 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x2[2], y2[2]),
|
||||
double d1 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x2[1], y2[1], false),
|
||||
d2 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x2[2], y2[2], false),
|
||||
factor = (d1 * d2) > 0 ? 3.0 / 4.0 : 4.0 / 9.0,
|
||||
dMin = factor * min(0, d1, d2),
|
||||
dMax = factor * max(0, d1, d2),
|
||||
dp0 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[0], y1[0]),
|
||||
dp1 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[1], y1[1]),
|
||||
dp2 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[2], y1[2]),
|
||||
dp3 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[3], y1[3]);
|
||||
dp0 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[0], y1[0], false),
|
||||
dp1 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[1], y1[1], false),
|
||||
dp2 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[2], y1[2], false),
|
||||
dp3 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[3], y1[3], false);
|
||||
|
||||
std::vector<PointD> top;
|
||||
std::vector<PointD> bottom;
|
||||
@ -1705,6 +1710,10 @@ void CBooleanOperations::SetWinding()
|
||||
} while (!s.IsEmpty() && !s.Inters && s != start);
|
||||
}
|
||||
}
|
||||
|
||||
if (FillType & c_nStroke)
|
||||
for (auto& s : Segments2)
|
||||
s.Winding = 0;
|
||||
}
|
||||
|
||||
void CBooleanOperations::DivideLocations()
|
||||
@ -1874,7 +1883,7 @@ void CBooleanOperations::AddLocation(Curve curve1, Curve curve2, double t1,
|
||||
loc1->Inters = loc2;
|
||||
loc2->Inters = loc1;
|
||||
|
||||
if (!filter || FilterIntersections(loc1))
|
||||
if (!filter || loc1->Overlap || IsCrossing(loc1))
|
||||
InsertLocation(loc1, overlap);
|
||||
}
|
||||
}
|
||||
@ -1896,7 +1905,8 @@ void CBooleanOperations::AddOffsets(std::vector<double>& offsets,
|
||||
|
||||
CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
const CGraphicsPath& path2,
|
||||
BooleanOpType op)
|
||||
BooleanOpType op,
|
||||
long fillType)
|
||||
{
|
||||
std::vector<CGraphicsPath> paths1 = path1.GetSubPaths(),
|
||||
paths2 = path2.GetSubPaths(),
|
||||
@ -1906,7 +1916,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
{
|
||||
for (const auto& p2 : paths2)
|
||||
{
|
||||
CBooleanOperations operation(p1, p2, op);
|
||||
CBooleanOperations operation(p1, p2, op, fillType);
|
||||
paths.push_back(operation.GetResult());
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,6 +54,7 @@ namespace Aggplus
|
||||
|
||||
std::vector<double> GetXValues() const noexcept;
|
||||
std::vector<double> GetYValues() const noexcept;
|
||||
std::vector<double> GetBound() const noexcept;
|
||||
std::vector<double> GetPeeks() const;
|
||||
double GetLength(double a = 0, double b = 1) const;
|
||||
double GetSquaredLineLength() const noexcept;
|
||||
@ -81,7 +82,6 @@ namespace Aggplus
|
||||
void Flip() noexcept;
|
||||
|
||||
bool IsStraight() const noexcept;
|
||||
bool HasHandle() const noexcept;
|
||||
bool operator==(const Curve& other) const noexcept;
|
||||
bool operator!=(const Curve& other) const noexcept;
|
||||
};
|
||||
@ -107,7 +107,7 @@ namespace Aggplus
|
||||
class CBooleanOperations
|
||||
{
|
||||
public:
|
||||
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op);
|
||||
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType = c_nWindingFillMode);
|
||||
~CBooleanOperations();
|
||||
CGraphicsPath&& GetResult();
|
||||
|
||||
@ -128,12 +128,10 @@ namespace Aggplus
|
||||
void SetVisited(const Segment& segment);
|
||||
|
||||
// Bounds
|
||||
std::vector<std::vector<double>> GetBoundsForCurves(const std::vector<Curve>& curves) const noexcept;
|
||||
std::vector<std::vector<int>> FindBoundsCollisions();
|
||||
|
||||
// Intersection
|
||||
bool IsCrossing(std::shared_ptr<Location> loc) noexcept;
|
||||
bool FilterIntersections(std::shared_ptr<Location> loc) noexcept;
|
||||
bool IntersectsBounds() noexcept;
|
||||
void GetIntersection();
|
||||
void GetCurveIntersection(const Curve& curve1, const Curve& curve2);
|
||||
@ -159,6 +157,9 @@ namespace Aggplus
|
||||
bool Close1 = true;
|
||||
bool Close2 = true;
|
||||
|
||||
// c_nStroke, c_nWindingFillMode, c_nEvenOddFillMode
|
||||
long FillType = c_nWindingFillMode;
|
||||
|
||||
CGraphicsPath Path1;
|
||||
CGraphicsPath Path2;
|
||||
CGraphicsPath Result;
|
||||
|
||||
@ -33,479 +33,647 @@
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrush::CBrush(BrushType bType) : m_bType(bType)
|
||||
CBrush::CBrush()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CBrush::CBrush(const BrushType& type)
|
||||
: m_bType(type)
|
||||
{
|
||||
}
|
||||
|
||||
CBrush::~CBrush()
|
||||
{
|
||||
}
|
||||
|
||||
BrushType CBrush::GetType() const
|
||||
{
|
||||
return m_bType;
|
||||
BrushType CBrush::GetType() const
|
||||
{
|
||||
return m_bType;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushSolid::CBrushSolid(CColor dwColor) : CBrush(BrushTypeSolidColor), m_dwColor(dwColor)
|
||||
CBrushSolid::CBrushSolid() : CBrush()
|
||||
{
|
||||
}
|
||||
CBrushSolid::~CBrushSolid()
|
||||
|
||||
CBrushSolid::CBrushSolid(CColor color)
|
||||
: CBrush(),
|
||||
m_dwColor(color)
|
||||
{
|
||||
}
|
||||
CBrush* CBrushSolid::Clone() const
|
||||
{
|
||||
return new CBrushSolid(m_dwColor);
|
||||
|
||||
CBrushSolid::CBrushSolid(const CBrushSolid& other) : CBrush()
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
void CBrushSolid::GetColor(CColor* color) const { *color = m_dwColor; }
|
||||
void CBrushSolid::SetColor(const CColor &color) { m_dwColor = color; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushHatch::CBrushHatch() : CBrush(BrushTypeHatchFill)
|
||||
CBrushSolid::~CBrushSolid()
|
||||
{
|
||||
}
|
||||
CBrushHatch::~CBrushHatch()
|
||||
|
||||
void CBrushSolid::GetColor(CColor* color) const
|
||||
{
|
||||
*color = m_dwColor;
|
||||
}
|
||||
|
||||
void CBrushSolid::SetColor(const CColor &color)
|
||||
{
|
||||
m_dwColor = color;
|
||||
}
|
||||
|
||||
CBrushSolid& CBrushSolid::operator=(const CBrushSolid& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_dwColor = other.m_dwColor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushHatch::CBrushHatch()
|
||||
: CBrush(BrushTypeHatchFill)
|
||||
{
|
||||
}
|
||||
CBrush* CBrushHatch::Clone() const
|
||||
{
|
||||
CBrushHatch* clone = new CBrushHatch();
|
||||
clone->m_name = m_name;
|
||||
clone->m_dwColor1 = m_dwColor1;
|
||||
clone->m_dwColor2 = m_dwColor2;
|
||||
return clone;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2 )
|
||||
CBrushHatch::CBrushHatch(const CBrushHatch& other)
|
||||
: CBrush(BrushTypeHatchFill)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CBrushHatch::CBrushHatch(CBrushHatch&& other) noexcept
|
||||
: CBrush(BrushTypeHatchFill)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CBrushHatch::~CBrushHatch()
|
||||
{
|
||||
}
|
||||
|
||||
void CBrushHatch::SetName(const std::wstring& name)
|
||||
{
|
||||
m_wsName = name;
|
||||
}
|
||||
|
||||
std::wstring CBrushHatch::GetName() const
|
||||
{
|
||||
return m_wsName;
|
||||
}
|
||||
|
||||
void CBrushHatch::SetColor1(const CColor& color)
|
||||
{
|
||||
m_dwColor1 = color;
|
||||
}
|
||||
|
||||
CColor CBrushHatch::GetColor1() const
|
||||
{
|
||||
return m_dwColor1;
|
||||
}
|
||||
|
||||
void CBrushHatch::SetColor2(const CColor& color)
|
||||
{
|
||||
m_dwColor2 = color;
|
||||
}
|
||||
|
||||
CColor CBrushHatch::GetColor2() const
|
||||
{
|
||||
return m_dwColor2;
|
||||
}
|
||||
|
||||
void CBrushHatch::SetBounds(const CDoubleRect& rect)
|
||||
{
|
||||
m_oBounds = rect;
|
||||
}
|
||||
|
||||
CDoubleRect& CBrushHatch::GetBounds()
|
||||
{
|
||||
return m_oBounds;
|
||||
}
|
||||
|
||||
CBrushHatch& CBrushHatch::operator=(const CBrushHatch& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_wsName = other.m_wsName;
|
||||
m_dwColor1 = other.m_dwColor1;
|
||||
m_dwColor2 = other.m_dwColor2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushHatch& CBrushHatch::operator=(CBrushHatch&& other) noexcept
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_wsName = std::move(other.m_wsName);
|
||||
m_dwColor1 = other.m_dwColor1;
|
||||
m_dwColor2 = other.m_dwColor2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient()
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0] = p1;
|
||||
m_points[1] = p2;
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
|
||||
m_angle = 0;
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = FALSE;
|
||||
m_bRectable = FALSE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const Point& p1, const Point& p2, const CColor& c1, const CColor& c2 )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = (float)p1.X;
|
||||
m_points[0].Y = (float)p1.Y;
|
||||
m_points[1].X = (float)p2.X;
|
||||
m_points[1].Y = (float)p2.Y;
|
||||
m_arPoints[0] = p1;
|
||||
m_arPoints[1] = p2;
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
|
||||
m_angle = 0;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = FALSE;
|
||||
m_bRectable = FALSE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const Point& p1, const Point& p2, const CColor& c1, const CColor& c2)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = rect.GetLeft();
|
||||
m_points[0].Y = rect.GetTop();
|
||||
m_points[1].X = rect.GetRight();
|
||||
m_points[1].Y = rect.GetBottom();
|
||||
m_arPoints[0].X = static_cast<float>(p1.X);
|
||||
m_arPoints[0].Y = static_cast<float>(p1.Y);
|
||||
m_arPoints[1].X = static_cast<float>(p2.X);
|
||||
m_arPoints[1].Y = static_cast<float>(p2.Y);
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
}
|
||||
|
||||
m_angle = angle;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
CBrushLinearGradient::CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_arPoints[0].X = rect.GetLeft();
|
||||
m_arPoints[0].Y = rect.GetTop();
|
||||
m_arPoints[1].X = rect.GetRight();
|
||||
m_arPoints[1].Y = rect.GetBottom();
|
||||
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_fAngle = angle;
|
||||
|
||||
m_bAngleScalable = isAngleScalable;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = (float)rect.GetLeft();
|
||||
m_points[0].Y = (float)rect.GetTop();
|
||||
m_points[1].X = (float)rect.GetRight();
|
||||
m_points[1].Y = (float)rect.GetBottom();
|
||||
m_arPoints[0].X = static_cast<float>(rect.GetLeft());
|
||||
m_arPoints[0].Y = static_cast<float>(rect.GetTop());
|
||||
m_arPoints[1].X = static_cast<float>(rect.GetRight());
|
||||
m_arPoints[1].Y = static_cast<float>(rect.GetBottom());
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_angle = angle;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
m_fAngle = angle;
|
||||
|
||||
m_bAngleScalable = isAngleScalable;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = rect.GetLeft();
|
||||
m_points[0].Y = rect.GetTop();
|
||||
m_points[1].X = rect.GetRight();
|
||||
m_points[1].Y = rect.GetBottom();
|
||||
m_arPoints[0].X = rect.GetLeft();
|
||||
m_arPoints[0].Y = rect.GetTop();
|
||||
m_arPoints[1].X = rect.GetRight();
|
||||
m_arPoints[1].Y = rect.GetBottom();
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case LinearGradientModeHorizontal:
|
||||
m_angle = 0;
|
||||
m_fAngle = 0;
|
||||
break;
|
||||
|
||||
case LinearGradientModeVertical:
|
||||
m_angle = 90;
|
||||
m_fAngle = 90;
|
||||
break;
|
||||
|
||||
case LinearGradientModeForwardDiagonal:
|
||||
m_angle = 45;
|
||||
m_fAngle = 45;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_angle = 315;
|
||||
m_fAngle = 315;
|
||||
}
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = TRUE;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bAngleScalable = true;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode )
|
||||
CBrushLinearGradient::CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode)
|
||||
: CBrush(BrushTypeLinearGradient)
|
||||
{
|
||||
m_points[0].X = (REAL)rect.GetLeft();
|
||||
m_points[0].Y = (REAL)rect.GetTop();
|
||||
m_points[1].X = (REAL)rect.GetRight();
|
||||
m_points[1].Y = (REAL)rect.GetBottom();
|
||||
m_arPoints[0].X = static_cast<float>(rect.GetLeft());
|
||||
m_arPoints[0].Y = static_cast<float>(rect.GetTop());
|
||||
m_arPoints[1].X = static_cast<float>(rect.GetRight());
|
||||
m_arPoints[1].Y = static_cast<float>(rect.GetBottom());
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case LinearGradientModeHorizontal:
|
||||
m_angle = 0;
|
||||
m_fAngle = 0;
|
||||
break;
|
||||
|
||||
case LinearGradientModeVertical:
|
||||
m_angle = 90;
|
||||
m_fAngle = 90;
|
||||
break;
|
||||
|
||||
case LinearGradientModeForwardDiagonal:
|
||||
m_angle = 45;
|
||||
m_fAngle = 45;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_angle = 315;
|
||||
m_fAngle = 315;
|
||||
}
|
||||
|
||||
m_colors[0] = c1;
|
||||
m_colors[1] = c2;
|
||||
m_arColors[0] = c1;
|
||||
m_arColors[1] = c2;
|
||||
|
||||
m_wrap = Aggplus::WrapModeTile;
|
||||
|
||||
m_bAngleScalable = TRUE;
|
||||
m_bRectable = TRUE;
|
||||
m_bRelativeCoords = FALSE;
|
||||
m_bAngleScalable = true;
|
||||
m_bRectable = true;
|
||||
}
|
||||
|
||||
|
||||
CBrushLinearGradient::CBrushLinearGradient( const CBrushLinearGradient& out )
|
||||
: CBrush(out.m_bType)
|
||||
CBrushLinearGradient::CBrushLinearGradient(const CBrushLinearGradient& other)
|
||||
: CBrush(other.m_bType)
|
||||
{
|
||||
m_colors[0] = out.m_colors[0];
|
||||
m_colors[1] = out.m_colors[1];
|
||||
m_points[0] = out.m_points[0];
|
||||
m_points[1] = out.m_points[1];
|
||||
|
||||
m_subcolors = out.m_subcolors;
|
||||
|
||||
m_matrix = out.m_matrix;
|
||||
m_angle = out.m_angle;
|
||||
|
||||
m_wrap = out.m_wrap;
|
||||
m_bAngleScalable = out.m_bAngleScalable;
|
||||
m_bRectable = out.m_bRectable;
|
||||
m_bRelativeCoords = out.m_bRelativeCoords;
|
||||
*this = other;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetLinearColors( CColor* colors ) const
|
||||
CBrushLinearGradient::CBrushLinearGradient(CBrushLinearGradient&& other) noexcept
|
||||
{
|
||||
if( !colors )
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CBrushLinearGradient::~CBrushLinearGradient()
|
||||
{
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetLinearColors(CColor* colors) const
|
||||
{
|
||||
if(!colors)
|
||||
return InvalidParameter;
|
||||
|
||||
colors[0] = m_colors[0];
|
||||
colors[1] = m_colors[1];
|
||||
colors[0] = m_arColors[0];
|
||||
colors[1] = m_arColors[1];
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetRectangle( Rect *rect ) const
|
||||
Status CBrushLinearGradient::GetRectangle(Rect *rect) const
|
||||
{
|
||||
if( !rect )
|
||||
if(!rect)
|
||||
return InvalidParameter;
|
||||
|
||||
rect->X = (int)( m_points[0].X );
|
||||
rect->Y = (int)( m_points[0].Y );
|
||||
rect->Width = (int)( m_points[1].X ) - rect->X;
|
||||
rect->Height = (int)( m_points[1].Y ) - rect->Y;
|
||||
rect->X = static_cast<int>((m_arPoints[0].X));
|
||||
rect->Y = static_cast<int>((m_arPoints[0].Y));
|
||||
rect->Width = static_cast<int>((m_arPoints[1].X) - rect->X);
|
||||
rect->Height = static_cast<int>((m_arPoints[1].Y) - rect->Y);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetRectangle(RectF *rect) const
|
||||
{
|
||||
if(!rect)
|
||||
return InvalidParameter;
|
||||
|
||||
rect->X = m_arPoints[0].X;
|
||||
rect->Y = m_arPoints[0].Y;
|
||||
rect->Width = m_arPoints[1].X - rect->X;
|
||||
rect->Height = m_arPoints[1].Y - rect->Y;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetRectangle( RectF *rect ) const
|
||||
Status CBrushLinearGradient::GetTransform(CMatrix* matrix) const
|
||||
{
|
||||
if( !rect )
|
||||
if(!matrix)
|
||||
return InvalidParameter;
|
||||
|
||||
rect->X = m_points[0].X;
|
||||
rect->Y = m_points[0].Y;
|
||||
rect->Width = m_points[1].X - rect->X;
|
||||
rect->Height = m_points[1].Y - rect->Y;
|
||||
*matrix = m_Matrix;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetTransform( CMatrix* matrix ) const
|
||||
Status CBrushLinearGradient::MultiplyTransform(const CMatrix *matrix, MatrixOrder order)
|
||||
{
|
||||
if( !matrix )
|
||||
return InvalidParameter;
|
||||
|
||||
*matrix = m_matrix;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::MultiplyTransform( const CMatrix *matrix, MatrixOrder order)
|
||||
{
|
||||
if( !matrix )
|
||||
return InvalidParameter;
|
||||
|
||||
m_matrix.Multiply( matrix, order );
|
||||
m_Matrix.Multiply(matrix, order);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::ResetTransform()
|
||||
{
|
||||
m_matrix.Reset();
|
||||
m_Matrix.Reset();
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::RotateTransform( REAL angle, MatrixOrder order )
|
||||
Status CBrushLinearGradient::RotateTransform(float angle, MatrixOrder order)
|
||||
{
|
||||
m_matrix.Rotate( angle, order );
|
||||
m_Matrix.Rotate(angle, order);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::ScaleTransform( REAL sx, REAL sy, MatrixOrder order )
|
||||
Status CBrushLinearGradient::ScaleTransform(float sx, float sy, MatrixOrder order)
|
||||
{
|
||||
m_matrix.Scale( sx, sy, order );
|
||||
m_Matrix.Scale(sx, sy, order);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
void CBrushLinearGradient::SetWrapMode( WrapMode mode )
|
||||
void CBrushLinearGradient::SetWrapMode(WrapMode mode)
|
||||
{
|
||||
m_wrap = mode;
|
||||
m_eWrap = mode;
|
||||
}
|
||||
|
||||
WrapMode CBrushLinearGradient::GetWrapMode() const
|
||||
{
|
||||
return m_wrap;
|
||||
return m_eWrap;
|
||||
}
|
||||
|
||||
CBrush* CBrushLinearGradient::Clone() const
|
||||
Status CBrushLinearGradient::SetInterpolationColors(const CColor *presetColors, const float *blendPositions, int count)
|
||||
{
|
||||
return new CBrushLinearGradient( *this );
|
||||
}
|
||||
m_arSubColors.clear();
|
||||
|
||||
Status CBrushLinearGradient::SetInterpolationColors( const CColor *presetColors, const REAL *blendPositions, INT count )
|
||||
{
|
||||
m_subcolors.clear();
|
||||
|
||||
if( count > 0 && presetColors && blendPositions )
|
||||
if(count > 0 && presetColors && blendPositions)
|
||||
{
|
||||
m_subcolors.resize( count );
|
||||
m_arSubColors.resize(count);
|
||||
|
||||
for( int i = 0; i < count; i++ )
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
m_subcolors[i].color = presetColors[i];
|
||||
m_subcolors[i].position = blendPositions[i];
|
||||
m_arSubColors[i].color = presetColors[i];
|
||||
m_arSubColors[i].position = blendPositions[i];
|
||||
}
|
||||
}
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CBrushLinearGradient::GetInterpolationColors( CColor *presetColors, REAL *blendPositions, INT count ) const
|
||||
Status CBrushLinearGradient::GetInterpolationColors(CColor *presetColors, float *blendPositions, int count) const
|
||||
{
|
||||
if( count > 0 && count <= (INT)m_subcolors.size() && presetColors && blendPositions )
|
||||
if( count > 0 && count <= (int)m_arSubColors.size() && presetColors && blendPositions )
|
||||
{
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
presetColors[i] = m_subcolors[i].color;
|
||||
blendPositions[i] = m_subcolors[i].position;
|
||||
presetColors[i] = m_arSubColors[i].color;
|
||||
blendPositions[i] = m_arSubColors[i].position;
|
||||
}
|
||||
}
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
INT CBrushLinearGradient::GetInterpolationColorsCount() const
|
||||
int CBrushLinearGradient::GetInterpolationColorsCount() const
|
||||
{
|
||||
return (INT)m_subcolors.size();
|
||||
return static_cast<int>(m_arSubColors.size());
|
||||
}
|
||||
|
||||
// additional methods
|
||||
void CBrushLinearGradient::GetSubColor( int nIndex, CColor* pColor, float* pPosition ) const
|
||||
void CBrushLinearGradient::GetSubColor(int index, CColor* color, float* position) const
|
||||
{
|
||||
*pColor = m_subcolors[nIndex].color;
|
||||
*pPosition = m_subcolors[nIndex].position;
|
||||
*color = m_arSubColors[index].color;
|
||||
*position = m_arSubColors[index].position;
|
||||
}
|
||||
|
||||
void CBrushLinearGradient::SetRelativeCoords( INT bRelative )
|
||||
|
||||
void CBrushLinearGradient::SetRelativeCoords(bool relative)
|
||||
{
|
||||
m_bRelativeCoords = bRelative;
|
||||
m_bRelativeCoords = relative;
|
||||
}
|
||||
INT CBrushLinearGradient::IsRelativeCoords() const
|
||||
|
||||
bool CBrushLinearGradient::IsRelativeCoords() const
|
||||
{
|
||||
return m_bRelativeCoords;
|
||||
}
|
||||
|
||||
INT CBrushLinearGradient::IsAngleScalable() const
|
||||
bool CBrushLinearGradient::IsAngleScalable() const
|
||||
{
|
||||
return m_bAngleScalable;
|
||||
}
|
||||
INT CBrushLinearGradient::IsRectable() const
|
||||
|
||||
bool CBrushLinearGradient::IsRectable() const
|
||||
{
|
||||
return m_bRectable;
|
||||
}
|
||||
|
||||
float CBrushLinearGradient::GetAngle() const
|
||||
{
|
||||
return m_angle;
|
||||
return m_fAngle;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBrushTexture::CBrushTexture() : CBrush(BrushTypeTextureFill)
|
||||
void CBrushLinearGradient::SetBounds(const CDoubleRect& rect)
|
||||
{
|
||||
m_pImage = NULL;
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_oBounds = rect;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const std::wstring& strName, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
CDoubleRect& CBrushLinearGradient::GetBounds()
|
||||
{
|
||||
m_pImage = new CImage(strName);
|
||||
m_bReleaseImage = TRUE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
return m_oBounds;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CImage *pImage, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
CBrushLinearGradient& CBrushLinearGradient::operator=(const CBrushLinearGradient& other)
|
||||
{
|
||||
m_pImage = pImage;
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_arColors[0] = other.m_arColors[0];
|
||||
m_arColors[1] = other.m_arColors[1];
|
||||
m_arPoints[0] = other.m_arPoints[0];
|
||||
m_arPoints[1] = other.m_arPoints[1];
|
||||
|
||||
m_arSubColors = other.m_arSubColors;
|
||||
|
||||
m_Matrix = other.m_Matrix;
|
||||
m_fAngle = other.m_fAngle;
|
||||
|
||||
m_eWrap = other.m_eWrap;
|
||||
|
||||
m_bAngleScalable = other.m_bAngleScalable;
|
||||
m_bRectable = other.m_bRectable;
|
||||
m_bRelativeCoords = other.m_bRelativeCoords;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushTexture::~CBrushTexture()
|
||||
|
||||
CBrushLinearGradient& CBrushLinearGradient::operator=(CBrushLinearGradient&& other) noexcept
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_arColors[0] = other.m_arColors[0];
|
||||
m_arColors[1] = other.m_arColors[1];
|
||||
m_arPoints[0] = other.m_arPoints[0];
|
||||
m_arPoints[1] = other.m_arPoints[1];
|
||||
|
||||
m_arSubColors = other.m_arSubColors;
|
||||
|
||||
m_Matrix = std::move(other.m_Matrix);
|
||||
|
||||
m_eWrap = other.m_eWrap;
|
||||
|
||||
m_bAngleScalable = other.m_bAngleScalable;
|
||||
m_bRectable = other.m_bRectable;
|
||||
m_bRelativeCoords = other.m_bRelativeCoords;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture()
|
||||
: CBrush(BrushTypeTextureFill)
|
||||
{
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const std::wstring& name, WrapMode mode)
|
||||
: CBrush(BrushTypeTextureFill),
|
||||
m_eWrapMode(mode)
|
||||
{
|
||||
m_pImage = new CImage(name);
|
||||
m_bReleaseImage = true;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CImage *image, WrapMode mode)
|
||||
: CBrush(BrushTypeTextureFill),
|
||||
m_eWrapMode(mode)
|
||||
{
|
||||
m_pImage = image;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const CBrushTexture& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CBrushTexture&& other)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CBrushTexture::~CBrushTexture()
|
||||
{
|
||||
if (m_bReleaseImage)
|
||||
{
|
||||
RELEASEOBJECT(m_pImage);
|
||||
}
|
||||
}
|
||||
|
||||
CBrush* CBrushTexture::Clone() const
|
||||
|
||||
void CBrushTexture::TranslateTransform(double x, double y, MatrixOrder order)
|
||||
{
|
||||
CBrushTexture *pRet = new CBrushTexture(m_pImage, m_wrapMode);
|
||||
if( pRet )
|
||||
{
|
||||
pRet->m_mtx = m_mtx;
|
||||
}
|
||||
|
||||
return pRet;
|
||||
m_Matrix.Translate(x, y, order);
|
||||
}
|
||||
|
||||
void CBrushTexture::TranslateTransform(double dX, double dY, MatrixOrder order)
|
||||
{
|
||||
m_mtx.Translate(dX, dY, order);
|
||||
}
|
||||
void CBrushTexture::ScaleTransform(double dX, double dY, MatrixOrder order)
|
||||
{
|
||||
m_mtx.Scale(dX, dY, order);
|
||||
}
|
||||
void CBrushTexture::RotateTransform(double angle, MatrixOrder order)
|
||||
{
|
||||
m_mtx.Rotate(angle, order);
|
||||
}
|
||||
void CBrushTexture::GetTransform(CMatrix* matrix) const
|
||||
{
|
||||
*matrix = m_mtx;
|
||||
}
|
||||
void CBrushTexture::SetTransform(const CMatrix* matrix)
|
||||
{
|
||||
m_mtx = *matrix;
|
||||
void CBrushTexture::ScaleTransform(double x, double y, MatrixOrder order)
|
||||
{
|
||||
m_Matrix.Scale(x, y, order);
|
||||
}
|
||||
|
||||
void CBrushTexture::SetWrapMode(WrapMode wMode)
|
||||
{
|
||||
m_wrapMode = wMode;
|
||||
void CBrushTexture::RotateTransform(double angle, MatrixOrder order)
|
||||
{
|
||||
m_Matrix.Rotate(angle, order);
|
||||
}
|
||||
WrapMode CBrushTexture::GetWrapMode() const
|
||||
{
|
||||
return(m_wrapMode);
|
||||
|
||||
void CBrushTexture::GetTransform(CMatrix* matrix) const
|
||||
{
|
||||
*matrix = m_Matrix;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetTransform(const CMatrix* matrix)
|
||||
{
|
||||
m_Matrix = *matrix;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetWrapMode(WrapMode mode)
|
||||
{
|
||||
m_eWrapMode = mode;
|
||||
}
|
||||
|
||||
WrapMode CBrushTexture::GetWrapMode() const
|
||||
{
|
||||
return m_eWrapMode;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetBounds(const CDoubleRect& rect)
|
||||
{
|
||||
m_bUseBounds = true;
|
||||
m_oBounds = rect;
|
||||
}
|
||||
|
||||
CDoubleRect& CBrushTexture::GetBounds()
|
||||
{
|
||||
return m_oBounds;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetReleaseImage(bool isReleaseImage)
|
||||
{
|
||||
m_bReleaseImage = isReleaseImage;
|
||||
}
|
||||
|
||||
bool CBrushTexture::IsReleaseImage() const
|
||||
{
|
||||
return m_bReleaseImage;
|
||||
}
|
||||
|
||||
void CBrushTexture::SetAlpha(BYTE alpha)
|
||||
{
|
||||
m_Alpha = alpha;
|
||||
}
|
||||
|
||||
BYTE CBrushTexture::GetAlpha() const
|
||||
{
|
||||
return m_Alpha;
|
||||
}
|
||||
|
||||
void* CBrushTexture::GetData()
|
||||
{
|
||||
return m_pImage->m_pImgData;
|
||||
}
|
||||
|
||||
void* CBrushTexture::PatternFinalize()
|
||||
{
|
||||
{
|
||||
if (m_pImage->m_nStride < 0)
|
||||
return m_pImage->m_pImgData - ((m_pImage->m_dwHeight - 1) * m_pImage->m_nStride);
|
||||
return m_pImage->m_pImgData;
|
||||
}
|
||||
|
||||
DWORD CBrushTexture::PatternGetWidth()
|
||||
{
|
||||
{
|
||||
return m_pImage->m_dwWidth;
|
||||
}
|
||||
|
||||
DWORD CBrushTexture::PatternGetHeight()
|
||||
{
|
||||
{
|
||||
return m_pImage->m_dwHeight;
|
||||
}
|
||||
|
||||
int CBrushTexture::PatternGetStride()
|
||||
{
|
||||
{
|
||||
return m_pImage->m_nStride;
|
||||
}
|
||||
|
||||
CBrushTexture& CBrushTexture::operator=(const CBrushTexture& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_pImage = new CImage(*other.m_pImage);
|
||||
|
||||
m_Matrix = other.m_Matrix;
|
||||
|
||||
m_eWrapMode = other.m_eWrapMode;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBrushTexture& CBrushTexture::operator=(CBrushTexture&& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_pImage = std::move(other.m_pImage);
|
||||
|
||||
m_Matrix = std::move(other.m_Matrix);
|
||||
|
||||
m_eWrapMode = other.m_eWrapMode;
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,170 +43,256 @@
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
class CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
protected:
|
||||
|
||||
CBrush(BrushType bType);
|
||||
|
||||
public:
|
||||
virtual ~CBrush();
|
||||
|
||||
virtual CBrush* Clone() const = 0;
|
||||
BrushType GetType() const;
|
||||
|
||||
public:
|
||||
BrushType m_bType;
|
||||
};
|
||||
|
||||
class CBrushSolid : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushSolid(CColor dwColor);
|
||||
virtual ~CBrushSolid();
|
||||
virtual CBrush *Clone() const;
|
||||
|
||||
void GetColor(CColor* color) const;
|
||||
void SetColor(const CColor &color);
|
||||
|
||||
protected:
|
||||
CColor m_dwColor;
|
||||
};
|
||||
|
||||
class CBrushHatch : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushHatch();
|
||||
virtual ~CBrushHatch();
|
||||
virtual CBrush *Clone() const;
|
||||
|
||||
inline CDoubleRect& GetBounds() { return Bounds; }
|
||||
|
||||
|
||||
public:
|
||||
std::wstring m_name;
|
||||
CColor m_dwColor1;
|
||||
CColor m_dwColor2;
|
||||
|
||||
CDoubleRect Bounds;
|
||||
};
|
||||
|
||||
|
||||
class CBrushLinearGradient : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
public:
|
||||
CBrushLinearGradient( const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2 );
|
||||
CBrushLinearGradient( const Point& p1, const Point& p2, const CColor& c1, const CColor& c2 );
|
||||
CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable );
|
||||
CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable );
|
||||
CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode );
|
||||
CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode );
|
||||
CBrushLinearGradient( const CBrushLinearGradient& out );
|
||||
|
||||
Status GetLinearColors( CColor* colors ) const;
|
||||
Status GetRectangle( Rect *rect ) const;
|
||||
Status GetRectangle( RectF *rect ) const;
|
||||
|
||||
Status GetTransform( CMatrix* matrix ) const;
|
||||
Status MultiplyTransform( const CMatrix *matrix, MatrixOrder order = MatrixOrderPrepend);
|
||||
Status ResetTransform();
|
||||
Status RotateTransform( REAL angle, MatrixOrder order = MatrixOrderPrepend );
|
||||
Status ScaleTransform( REAL sx, REAL sy, MatrixOrder order = MatrixOrderPrepend );
|
||||
|
||||
void SetWrapMode( WrapMode mode );
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
virtual CBrush *Clone() const;
|
||||
|
||||
Status SetInterpolationColors( const CColor *presetColors, const REAL *blendPositions, INT count );
|
||||
Status GetInterpolationColors( CColor *presetColors, REAL *blendPositions, INT count ) const;
|
||||
INT GetInterpolationColorsCount() const;
|
||||
|
||||
// additional methods
|
||||
void GetSubColor( int nIndex, CColor* pColor, float* pPosition ) const;
|
||||
|
||||
void SetRelativeCoords( INT bRelative );
|
||||
INT IsRelativeCoords() const;
|
||||
INT IsAngleScalable() const;
|
||||
INT IsRectable() const;
|
||||
float GetAngle() const;
|
||||
inline void SetBounds(const CDoubleRect& oRect) { Bounds = oRect; }
|
||||
inline CDoubleRect& GetBounds() { return Bounds; }
|
||||
|
||||
// info about gradient
|
||||
NSStructures::GradientInfo m_oGradientInfo; // used in 60xx grad types
|
||||
protected:
|
||||
CColor m_colors[2];
|
||||
PointF m_points[2];
|
||||
|
||||
struct TSubColor
|
||||
/**
|
||||
* @abstract CBrush
|
||||
*
|
||||
* Base class for brushes (by default a solid brush
|
||||
* is created).
|
||||
*/
|
||||
class CBrush
|
||||
{
|
||||
CColor color;
|
||||
float position;
|
||||
friend class CGraphics;
|
||||
|
||||
protected:
|
||||
CBrush();
|
||||
CBrush(const BrushType& type);
|
||||
|
||||
public:
|
||||
virtual ~CBrush();
|
||||
|
||||
BrushType GetType() const;
|
||||
|
||||
public:
|
||||
BrushType m_bType = BrushTypeSolidColor;
|
||||
};
|
||||
|
||||
std::vector<TSubColor> m_subcolors;
|
||||
|
||||
CMatrix m_matrix;
|
||||
float m_angle; // угол поворота в градусах базовой линии p1 -> p2
|
||||
/**
|
||||
* @class CBrushSolid
|
||||
*
|
||||
* A single-color brush used to draw text, graphic paths,
|
||||
* and fills with a single color.
|
||||
*/
|
||||
class CBrushSolid : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushSolid();
|
||||
CBrushSolid(CColor color);
|
||||
virtual ~CBrushSolid();
|
||||
CBrushSolid(const CBrushSolid& other);
|
||||
|
||||
CDoubleRect Bounds;
|
||||
void GetColor(CColor* color) const;
|
||||
void SetColor(const CColor &color);
|
||||
|
||||
Aggplus::WrapMode m_wrap;
|
||||
CBrushSolid& operator=(const CBrushSolid& other);
|
||||
protected:
|
||||
CColor m_dwColor{};
|
||||
};
|
||||
|
||||
INT m_bAngleScalable; // масштабировать угол поворота относительно заданных точек b = arctan( width / height * tan(angle) );
|
||||
INT m_bRectable; // в качестве направляющей используется диагональ прямоугольника
|
||||
INT m_bRelativeCoords; // координаты точек считаются относительно рисуемого примитива
|
||||
};
|
||||
/**
|
||||
* @class CBrushHatch
|
||||
*
|
||||
* A two-color brush used to fill graphic paths using
|
||||
* one of the hatch patterns
|
||||
*/
|
||||
class CBrushHatch : public CBrush
|
||||
{
|
||||
public:
|
||||
CBrushHatch();
|
||||
CBrushHatch(const CBrushHatch& other);
|
||||
CBrushHatch(CBrushHatch&& other) noexcept;
|
||||
virtual ~CBrushHatch();
|
||||
|
||||
class CBrushTexture : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
protected:
|
||||
CBrushTexture();
|
||||
void SetName(const std::wstring& name);
|
||||
std::wstring GetName() const;
|
||||
|
||||
public:
|
||||
CBrushTexture(const std::wstring& strName, WrapMode wrapMode = WrapModeTile);
|
||||
CBrushTexture(CImage *pImage, WrapMode wrapMode = WrapModeTile);
|
||||
virtual ~CBrushTexture();
|
||||
virtual CBrush* Clone() const;
|
||||
void SetColor1(const CColor& color);
|
||||
CColor GetColor1() const;
|
||||
void SetColor2(const CColor& color);
|
||||
CColor GetColor2() const;
|
||||
|
||||
void TranslateTransform(double dX, double dY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void ScaleTransform(double dX, double dY, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateTransform(double angle, MatrixOrder order = MatrixOrderPrepend);
|
||||
void GetTransform(CMatrix* matrix) const;
|
||||
void SetTransform(const CMatrix* matrix);
|
||||
void SetBounds(const CDoubleRect& rect);
|
||||
CDoubleRect& GetBounds();
|
||||
|
||||
void SetWrapMode(WrapMode wMode);
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
public:
|
||||
CBrushHatch& operator=(const CBrushHatch& other);
|
||||
CBrushHatch& operator=(CBrushHatch&& other) noexcept;
|
||||
protected:
|
||||
/**
|
||||
* @brief m_wsName - hatch brush pattern name
|
||||
* (as default - cross)
|
||||
*
|
||||
* See all patterns in agg_span_hatch.h, array -
|
||||
* c_resource_hatches_names.
|
||||
*/
|
||||
std::wstring m_wsName;
|
||||
CColor m_dwColor1{};
|
||||
CColor m_dwColor2{};
|
||||
|
||||
void* GetData();
|
||||
void* PatternFinalize();
|
||||
DWORD PatternGetWidth();
|
||||
DWORD PatternGetHeight();
|
||||
int PatternGetStride();
|
||||
|
||||
public:
|
||||
CImage* m_pImage;
|
||||
INT m_bReleaseImage;
|
||||
|
||||
WrapMode m_wrapMode;
|
||||
CMatrix m_mtx;
|
||||
CDoubleRect m_oBounds{};
|
||||
};
|
||||
|
||||
CColor m_colors[2];
|
||||
/**
|
||||
* @class CBrushLinearGradient
|
||||
*
|
||||
* brush for drawing gradients, stores information about the gradient.
|
||||
* According to the pdf documentation, it stores the start and end point
|
||||
* and color, as well as the linear interpolation of the colors.
|
||||
*/
|
||||
class CBrushLinearGradient : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
bool m_bUseBounds;
|
||||
CDoubleRect m_oBounds;
|
||||
public:
|
||||
CBrushLinearGradient();
|
||||
CBrushLinearGradient(const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2);
|
||||
CBrushLinearGradient(const Point& p1, const Point& p2, const CColor& c1, const CColor& c2);
|
||||
CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable);
|
||||
CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, float angle, bool isAngleScalable);
|
||||
CBrushLinearGradient(const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode);
|
||||
CBrushLinearGradient(const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode);
|
||||
CBrushLinearGradient(const CBrushLinearGradient& other);
|
||||
CBrushLinearGradient(CBrushLinearGradient&& other) noexcept;
|
||||
virtual ~CBrushLinearGradient();
|
||||
|
||||
BYTE Alpha;
|
||||
};
|
||||
Status GetLinearColors(CColor* colors) const;
|
||||
Status GetRectangle(Rect *rect) const;
|
||||
Status GetRectangle(RectF *rect) const;
|
||||
|
||||
Status GetTransform(CMatrix* matrix) const;
|
||||
Status MultiplyTransform(const CMatrix *matrix, MatrixOrder order = MatrixOrderPrepend);
|
||||
Status ResetTransform();
|
||||
Status RotateTransform(float angle, MatrixOrder order = MatrixOrderPrepend );
|
||||
Status ScaleTransform(float sx, float sy, MatrixOrder order = MatrixOrderPrepend );
|
||||
|
||||
void SetWrapMode(WrapMode mode);
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
Status SetInterpolationColors(const CColor *presetColors, const float *blendPositions, int count);
|
||||
Status GetInterpolationColors(CColor *presetColors, float *blendPositions, int count) const;
|
||||
int GetInterpolationColorsCount() const;
|
||||
|
||||
void GetSubColor(int index, CColor* color, float* position) const;
|
||||
|
||||
void SetRelativeCoords(bool relative);
|
||||
bool IsRelativeCoords() const;
|
||||
bool IsAngleScalable() const;
|
||||
bool IsRectable() const;
|
||||
float GetAngle() const;
|
||||
|
||||
void SetBounds(const CDoubleRect& rect);
|
||||
CDoubleRect& GetBounds();
|
||||
|
||||
CBrushLinearGradient& operator=(const CBrushLinearGradient& other);
|
||||
CBrushLinearGradient& operator=(CBrushLinearGradient&& other) noexcept;
|
||||
|
||||
NSStructures::GradientInfo m_oGradientInfo{};
|
||||
protected:
|
||||
CColor m_arColors[2];
|
||||
PointF m_arPoints[2];
|
||||
|
||||
struct TSubColor
|
||||
{
|
||||
CColor color{};
|
||||
float position = 0;
|
||||
};
|
||||
|
||||
std::vector<TSubColor> m_arSubColors;
|
||||
|
||||
CMatrix m_Matrix{};
|
||||
|
||||
/**
|
||||
* @brief m_angle - rotation angle of line p1 - p2 (measured in degrees)
|
||||
*/
|
||||
float m_fAngle = 0;
|
||||
|
||||
CDoubleRect m_oBounds{};
|
||||
|
||||
/**
|
||||
* @brief m_eWrapMode - Used to determine the rotation of the image tiles
|
||||
* (by default, we do not change the position).
|
||||
*/
|
||||
WrapMode m_eWrap = Aggplus::WrapModeTile;
|
||||
|
||||
/**
|
||||
* @brief m_bAngleScalable - whether to scale the rotation angle relative
|
||||
* to the given points
|
||||
*
|
||||
* calculated like this b = arctan(width / height * tan(angle));
|
||||
*/
|
||||
bool m_bAngleScalable = false;
|
||||
|
||||
/**
|
||||
* @brief m_bRectable - is the diagonal of a rectangle a guide
|
||||
*/
|
||||
bool m_bRectable = false;
|
||||
|
||||
/**
|
||||
* @brief m_bRelativeCoords - are the coordinates of the points calculated
|
||||
* relative to the resulting primitive
|
||||
*/
|
||||
bool m_bRelativeCoords = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class CBrushTexture
|
||||
*
|
||||
* A texture brush that is used to draw images on the renderer.
|
||||
*/
|
||||
class CBrushTexture : public CBrush
|
||||
{
|
||||
friend class CGraphics;
|
||||
|
||||
public:
|
||||
CBrushTexture();
|
||||
CBrushTexture(const std::wstring& name, WrapMode mode = WrapModeTile);
|
||||
CBrushTexture(CImage *image, WrapMode mode = WrapModeTile);
|
||||
CBrushTexture(const CBrushTexture& other);
|
||||
CBrushTexture(CBrushTexture&& other);
|
||||
virtual ~CBrushTexture();
|
||||
|
||||
void TranslateTransform(double x, double y, MatrixOrder order = MatrixOrderPrepend);
|
||||
void ScaleTransform(double x, double y, MatrixOrder order = MatrixOrderPrepend);
|
||||
void RotateTransform(double angle, MatrixOrder order = MatrixOrderPrepend);
|
||||
void GetTransform(CMatrix* matrix) const;
|
||||
void SetTransform(const CMatrix* matrix);
|
||||
|
||||
void SetWrapMode(WrapMode mode);
|
||||
WrapMode GetWrapMode() const;
|
||||
|
||||
void SetBounds(const CDoubleRect& rect);
|
||||
CDoubleRect& GetBounds();
|
||||
|
||||
void SetReleaseImage(bool isReleaseImage);
|
||||
bool IsReleaseImage() const;
|
||||
|
||||
void SetAlpha(BYTE alpha);
|
||||
BYTE GetAlpha() const;
|
||||
|
||||
void* GetData();
|
||||
void* PatternFinalize();
|
||||
DWORD PatternGetWidth();
|
||||
DWORD PatternGetHeight();
|
||||
int PatternGetStride();
|
||||
|
||||
CBrushTexture& operator=(const CBrushTexture& other);
|
||||
CBrushTexture& operator=(CBrushTexture&& other);
|
||||
|
||||
protected:
|
||||
CImage* m_pImage{nullptr};
|
||||
bool m_bReleaseImage = false;
|
||||
|
||||
/**
|
||||
* @brief m_eWrapMode - Used to determine the rotation of the image tiles
|
||||
* (by default, we do not change the position).
|
||||
*/
|
||||
WrapMode m_eWrapMode = WrapModeTile;
|
||||
|
||||
CMatrix m_Matrix{};
|
||||
|
||||
bool m_bUseBounds = false;
|
||||
CDoubleRect m_oBounds{};
|
||||
|
||||
BYTE m_Alpha = 255;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_BRUSH_H_
|
||||
|
||||
@ -191,6 +191,16 @@ namespace Aggplus
|
||||
{
|
||||
}
|
||||
|
||||
CClipMulti::clip_rasterizer* CClipMulti::GetRasterizer()
|
||||
{
|
||||
if (!m_bIsClip)
|
||||
{
|
||||
m_rasterizer.reset();
|
||||
return &m_rasterizer;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CClipMulti::Create(LONG width, LONG height)
|
||||
{
|
||||
m_lWidth = width;
|
||||
@ -212,62 +222,52 @@ namespace Aggplus
|
||||
|
||||
typedef agg::conv_curve<trans_type> conv_crv_type;
|
||||
conv_crv_type c_c_path(trans);
|
||||
|
||||
|
||||
m_rasterizer.add_path(c_c_path);
|
||||
m_rasterizer.filling_rule(pPath->m_internal->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
|
||||
|
||||
GenerateClip2(pPath->m_internal->m_bEvenOdd);
|
||||
}
|
||||
|
||||
void CClipMulti::GenerateClip2(bool bEvenOdd)
|
||||
{
|
||||
m_rasterizer.filling_rule(bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
|
||||
|
||||
m_bIsClip = true;
|
||||
m_bIsClip2 = false;
|
||||
}
|
||||
|
||||
void CClipMulti::Combine(CGraphicsPath* pPath, CMatrix* pMatrix, agg::sbool_op_e op)
|
||||
void CClipMulti::Combine(bool bEvenOdd, agg::sbool_op_e op, clip_rasterizer* pRasterizer)
|
||||
{
|
||||
if (!pRasterizer)
|
||||
return;
|
||||
|
||||
if (!m_bIsClip)
|
||||
return GenerateClip(pPath, pMatrix);
|
||||
return GenerateClip2(bEvenOdd);
|
||||
|
||||
if (!m_bIsClip2)
|
||||
{
|
||||
// смешивать надо с растерайзером
|
||||
agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> rasterizer;
|
||||
rasterizer.clip_box(0, 0, m_lWidth, m_lHeight);
|
||||
|
||||
typedef agg::conv_transform<agg::path_storage> trans_type;
|
||||
trans_type trans(pPath->m_internal->m_agg_ps, pMatrix->m_internal->m_agg_mtx);
|
||||
|
||||
typedef agg::conv_curve<trans_type> conv_crv_type;
|
||||
conv_crv_type c_c_path(trans);
|
||||
|
||||
rasterizer.add_path(c_c_path);
|
||||
rasterizer.filling_rule(pPath->m_internal->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
|
||||
pRasterizer->filling_rule(bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
|
||||
|
||||
scanline_type sl1;
|
||||
scanline_type sl2;
|
||||
scanline_type sl;
|
||||
|
||||
agg::sbool_combine_shapes_aa(op, m_rasterizer, rasterizer, sl1, sl2, sl, m_storage1);
|
||||
agg::sbool_combine_shapes_aa(op, m_rasterizer, *pRasterizer, sl1, sl2, sl, m_storage1);
|
||||
|
||||
m_lCurStorage = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// надо смешивать со стораджем
|
||||
agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> rasterizer;
|
||||
rasterizer.clip_box(0, 0, m_lWidth, m_lHeight);
|
||||
|
||||
typedef agg::conv_transform<agg::path_storage> trans_type;
|
||||
trans_type trans(pPath->m_internal->m_agg_ps, pMatrix->m_internal->m_agg_mtx);
|
||||
|
||||
typedef agg::conv_curve<trans_type> conv_crv_type;
|
||||
conv_crv_type c_c_path(trans);
|
||||
|
||||
rasterizer.add_path(c_c_path);
|
||||
rasterizer.filling_rule(pPath->m_internal->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
|
||||
pRasterizer->filling_rule(op ? agg::fill_even_odd : agg::fill_non_zero);
|
||||
|
||||
scanline_type sl1;
|
||||
scanline_type sl2;
|
||||
scanline_type sl;
|
||||
|
||||
agg::sbool_combine_shapes_aa(op, rasterizer, (m_lCurStorage == 1) ? m_storage1 : m_storage2, sl1, sl2, sl,
|
||||
agg::sbool_combine_shapes_aa(op, *pRasterizer, (m_lCurStorage == 1) ? m_storage1 : m_storage2, sl1, sl2, sl,
|
||||
(m_lCurStorage == 1) ? m_storage2 : m_storage1);
|
||||
|
||||
if (1 == m_lCurStorage)
|
||||
|
||||
@ -138,10 +138,11 @@ public:
|
||||
|
||||
class CClipMulti
|
||||
{
|
||||
typedef agg::scanline_p8 scanline_type;
|
||||
|
||||
public:
|
||||
agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> m_rasterizer;
|
||||
typedef agg::scanline_p8 scanline_type;
|
||||
typedef agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> clip_rasterizer;
|
||||
|
||||
clip_rasterizer m_rasterizer;
|
||||
|
||||
agg::scanline_storage_aa8 m_storage1;
|
||||
agg::scanline_storage_aa8 m_storage2;
|
||||
@ -158,10 +159,13 @@ public:
|
||||
CClipMulti();
|
||||
~CClipMulti();
|
||||
|
||||
clip_rasterizer* GetRasterizer();
|
||||
|
||||
void Create(LONG width, LONG height);
|
||||
void GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix);
|
||||
void GenerateClip2(bool bEvenOdd);
|
||||
|
||||
void Combine(CGraphicsPath* pPath, CMatrix* pMatrix, agg::sbool_op_e op);
|
||||
void Combine(bool bEvenOdd, agg::sbool_op_e op, clip_rasterizer* pRasterizer);
|
||||
|
||||
bool IsClip();
|
||||
bool IsClip2();
|
||||
|
||||
@ -502,18 +502,41 @@ namespace Aggplus
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphics::CombineClip(CGraphicsPath* pPath, agg::sbool_op_e op)
|
||||
Status CGraphics::CombineClip(CGraphicsPath* pPath, agg::sbool_op_e op, NSStructures::CPen* pPen)
|
||||
{
|
||||
Aggplus::CMatrix m;
|
||||
return InternalClip(pPath, (m_bIntegerGrid || pPath->m_internal->m_pTransform != NULL) ? &m : &m_oFullTransform, op);
|
||||
return InternalClip(pPath, (m_bIntegerGrid || pPath->m_internal->m_pTransform != NULL) ? &m : &m_oFullTransform, op, pPen);
|
||||
}
|
||||
|
||||
Status CGraphics::InternalClip(CGraphicsPath* pPath, CMatrix* pTransform, agg::sbool_op_e op)
|
||||
Status CGraphics::InternalClip(CGraphicsPath* pPath, CMatrix* pTransform, agg::sbool_op_e op, NSStructures::CPen* pPen)
|
||||
{
|
||||
if (NULL == pPath)
|
||||
return InvalidParameter;
|
||||
|
||||
m_oClip.Combine(pPath, pTransform, op);
|
||||
bool bTempRasterizer = false;
|
||||
CClipMulti::clip_rasterizer* pRasterizer = m_oClip.GetRasterizer();
|
||||
if (!pRasterizer)
|
||||
{
|
||||
pRasterizer = new CClipMulti::clip_rasterizer();
|
||||
pRasterizer->clip_box(0, 0, m_oClip.m_lWidth, m_oClip.m_lHeight);
|
||||
bTempRasterizer = true;
|
||||
}
|
||||
|
||||
agg::trans_affine* pAffine = NULL;
|
||||
if (pPen)
|
||||
pAffine = DoStrokePath(pPen, pPath, pRasterizer);
|
||||
else
|
||||
{
|
||||
typedef agg::conv_transform<agg::path_storage> trans_type;
|
||||
trans_type trans(pPath->m_internal->m_agg_ps, pTransform->m_internal->m_agg_mtx);
|
||||
|
||||
typedef agg::conv_curve<trans_type> conv_crv_type;
|
||||
conv_crv_type c_c_path(trans);
|
||||
|
||||
pRasterizer->add_path(c_c_path);
|
||||
}
|
||||
|
||||
m_oClip.Combine(pPath->m_internal->m_bEvenOdd, op, pRasterizer);
|
||||
|
||||
// write to clips history
|
||||
CGraphics_ClipStateRecord* pRecord = new CGraphics_ClipStateRecord();
|
||||
@ -522,6 +545,11 @@ namespace Aggplus
|
||||
pRecord->Operation = op;
|
||||
m_oClipState.AddRecord(pRecord);
|
||||
|
||||
if (pAffine)
|
||||
delete pAffine;
|
||||
if (bTempRasterizer)
|
||||
delete pRasterizer;
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
@ -610,180 +638,7 @@ namespace Aggplus
|
||||
|
||||
m_rasterizer.get_rasterizer().reset();
|
||||
|
||||
agg::line_join_e LineJoin = agg::round_join;
|
||||
switch(pPen->LineJoin)
|
||||
{
|
||||
case LineJoinMiter : LineJoin = agg::miter_join_revert; break;
|
||||
case LineJoinBevel : LineJoin = agg::bevel_join; break;
|
||||
case LineJoinRound : LineJoin = agg::round_join; break;
|
||||
case LineJoinMiterClipped : LineJoin = agg::miter_join_revert; break;
|
||||
default: break;
|
||||
}
|
||||
agg::line_cap_e LineCap = agg::round_cap;
|
||||
switch(pPen->LineStartCap)
|
||||
{
|
||||
case LineCapFlat : LineCap = agg::butt_cap; break;
|
||||
case LineCapRound : LineCap = agg::round_cap; break;
|
||||
case LineCapSquare : LineCap = agg::square_cap; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
double dWidth = pPen->Size;
|
||||
if (!m_bIntegerGrid && m_bIs0PenWidthAs1px)
|
||||
{
|
||||
double dWidthMinSize, dSqrtDet = sqrt(abs(m_oFullTransform.m_internal->m_agg_mtx.determinant()));
|
||||
if (0 == dWidth)
|
||||
{
|
||||
double dX = 0.72, dY = 0.72;
|
||||
agg::trans_affine invert = ~m_oFullTransform.m_internal->m_agg_mtx;
|
||||
invert.transform_2x2(&dX, &dY);
|
||||
dWidth = std::min(abs(dX), abs(dY));
|
||||
}
|
||||
else if (0 != dSqrtDet && dWidth < (dWidthMinSize = 1.0 / dSqrtDet))
|
||||
dWidth = dWidthMinSize;
|
||||
}
|
||||
|
||||
double dblMiterLimit = pPen->MiterLimit;
|
||||
|
||||
agg::path_storage path_copy(pPath->m_internal->m_agg_ps);
|
||||
bool bIsUseIdentity = m_bIntegerGrid;
|
||||
if (!bIsUseIdentity)
|
||||
{
|
||||
agg::trans_affine* full_trans = &m_oFullTransform.m_internal->m_agg_mtx;
|
||||
double dDet = full_trans->determinant();
|
||||
|
||||
if (fabs(dDet) < 0.0001)
|
||||
{
|
||||
path_copy.transform_all_paths(m_oFullTransform.m_internal->m_agg_mtx);
|
||||
dWidth *= sqrt(fabs(dDet));
|
||||
|
||||
bIsUseIdentity = true;
|
||||
}
|
||||
}
|
||||
|
||||
typedef agg::conv_curve<agg::path_storage> conv_crv_type;
|
||||
|
||||
conv_crv_type c_c_path(path_copy);
|
||||
c_c_path.approximation_scale(25.0);
|
||||
c_c_path.approximation_method(agg::curve_inc);
|
||||
DashStyle eStyle = (DashStyle)pPen->DashStyle;
|
||||
|
||||
if (DashStyleCustom == eStyle)
|
||||
{
|
||||
if (0 == pPen->Count || NULL == pPen->DashPattern)
|
||||
{
|
||||
eStyle = DashStyleSolid;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool bFoundNormal = false;
|
||||
for (int i = 0; i < pPen->Count; i++)
|
||||
{
|
||||
if (fabs(pPen->DashPattern[i]) > 0.0001)
|
||||
{
|
||||
bFoundNormal = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bFoundNormal)
|
||||
eStyle = DashStyleSolid;
|
||||
}
|
||||
}
|
||||
|
||||
agg::trans_affine* pAffine = &m_oFullTransform.m_internal->m_agg_mtx;
|
||||
if (bIsUseIdentity)
|
||||
pAffine = new agg::trans_affine();
|
||||
|
||||
if (DashStyleSolid == eStyle)
|
||||
{
|
||||
typedef agg::conv_stroke<conv_crv_type> Path_Conv_StrokeN;
|
||||
Path_Conv_StrokeN pgN(c_c_path);
|
||||
|
||||
//pgN.line_join(agg::miter_join_revert);
|
||||
|
||||
pgN.line_cap(LineCap);
|
||||
|
||||
pgN.line_join(LineJoin);
|
||||
pgN.inner_join(agg::inner_round);
|
||||
|
||||
pgN.miter_limit(dblMiterLimit);
|
||||
pgN.width(dWidth);
|
||||
|
||||
pgN.approximation_scale(25.0);
|
||||
|
||||
typedef agg::conv_transform<Path_Conv_StrokeN> transStroke;
|
||||
|
||||
transStroke trans(pgN, *pAffine);
|
||||
m_rasterizer.get_rasterizer().add_path(trans);
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef agg::conv_dash<conv_crv_type> Path_Conv_Dash;
|
||||
Path_Conv_Dash poly2_dash(c_c_path);
|
||||
|
||||
typedef agg::conv_stroke<Path_Conv_Dash> Path_Conv_StrokeD;
|
||||
Path_Conv_StrokeD pgD(poly2_dash);
|
||||
|
||||
switch (eStyle)
|
||||
{
|
||||
case DashStyleDash:
|
||||
poly2_dash.add_dash(3.00*dWidth, dWidth);
|
||||
break;
|
||||
case DashStyleDot:
|
||||
poly2_dash.add_dash(dWidth, dWidth);
|
||||
break;
|
||||
case DashStyleDashDot:
|
||||
poly2_dash.add_dash(3.00*dWidth, dWidth);
|
||||
poly2_dash.add_dash(dWidth, dWidth);
|
||||
break;
|
||||
case DashStyleDashDotDot:
|
||||
poly2_dash.add_dash(3.00*dWidth, dWidth);
|
||||
poly2_dash.add_dash(dWidth, dWidth);
|
||||
poly2_dash.add_dash(dWidth, dWidth);
|
||||
break;
|
||||
default:
|
||||
case DashStyleCustom:
|
||||
{
|
||||
double offset = pPen->DashOffset;
|
||||
double* params = pPen->DashPattern;
|
||||
LONG lCount = pPen->Count;
|
||||
LONG lCount2 = lCount / 2;
|
||||
|
||||
double dKoef = 1.0;
|
||||
|
||||
for (LONG i = 0; i < lCount2; ++i)
|
||||
{
|
||||
if (0 == i)
|
||||
{
|
||||
poly2_dash.add_dash((params[i * 2]) * dKoef, params[i * 2 + 1] * dKoef);
|
||||
}
|
||||
else
|
||||
{
|
||||
poly2_dash.add_dash(params[i * 2] * dKoef, params[i * 2 + 1] * dKoef);
|
||||
}
|
||||
}
|
||||
if (1 == (lCount % 2))
|
||||
{
|
||||
poly2_dash.add_dash(params[lCount - 1] * dKoef, 0);
|
||||
}
|
||||
poly2_dash.dash_start(offset * dKoef);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double dWidthMinSize = 1.0 / sqrt(abs(m_oCoordTransform.m_internal->m_agg_mtx.determinant()));
|
||||
if ((0 == dWidth && !m_bIntegerGrid) || dWidth < dWidthMinSize)
|
||||
dWidth = dWidthMinSize;
|
||||
|
||||
pgD.line_cap(LineCap);
|
||||
pgD.line_join(LineJoin);
|
||||
pgD.miter_limit(dblMiterLimit);
|
||||
pgD.width(dWidth);
|
||||
|
||||
agg::conv_transform<Path_Conv_StrokeD> trans(pgD, *pAffine);
|
||||
m_rasterizer.get_rasterizer().add_path(trans);
|
||||
}
|
||||
agg::trans_affine* pAffine = DoStrokePath(pPen, pPath, &m_rasterizer.get_rasterizer());
|
||||
|
||||
CColor oColor((BYTE)(pPen->Alpha * m_dGlobalAlpha), pPen->Color, m_bSwapRGB);
|
||||
CBrushSolid oBrush(oColor);
|
||||
@ -798,8 +653,7 @@ namespace Aggplus
|
||||
if (gamma >= 0)
|
||||
m_rasterizer.gamma(1.0);
|
||||
|
||||
if (bIsUseIdentity)
|
||||
RELEASEOBJECT(pAffine);
|
||||
RELEASEOBJECT(pAffine);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
@ -978,7 +832,8 @@ namespace Aggplus
|
||||
b = ptxBrush->m_oBounds.bottom;
|
||||
}
|
||||
|
||||
CMatrix brushMatrix(ptxBrush->m_mtx);
|
||||
CMatrix brushMatrix;
|
||||
ptxBrush->GetTransform(&brushMatrix);
|
||||
if (ptxBrush->GetWrapMode() == Aggplus::WrapModeClamp)
|
||||
{
|
||||
double dScaleX = (r - x) / dwPatternWidth;
|
||||
@ -1297,7 +1152,9 @@ namespace Aggplus
|
||||
RELEASEINTERFACE(pCurrentGraphicsLayer);
|
||||
RELEASEINTERFACE(m_pSoftMask);
|
||||
|
||||
m_pSoftMask = new CSoftMask(pBuffer, m_frame_buffer.ren_buf().width(), m_frame_buffer.ren_buf().height(), bAlpha ? EMaskDataType::Alpha4Buffer : EMaskDataType::ImageBuffer, false, m_frame_buffer.ren_buf().stride() < 0);
|
||||
unsigned int unWidth = m_frame_buffer.ren_buf().width(), unHeight = m_frame_buffer.ren_buf().height();
|
||||
bool bFlip = m_frame_buffer.ren_buf().stride() < 0;
|
||||
m_pSoftMask = new CSoftMask(pBuffer, unWidth, unHeight, bFlip, m_bSwapRGB, bAlpha);
|
||||
|
||||
pBuffer = m_arLayers.empty() ? m_pPixels : m_arLayers.top()->GetBuffer();
|
||||
if (!pBuffer)
|
||||
@ -1306,7 +1163,7 @@ namespace Aggplus
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m_frame_buffer.ren_buf().attach(pBuffer, m_frame_buffer.ren_buf().width(), m_frame_buffer.ren_buf().height(), m_frame_buffer.ren_buf().stride());
|
||||
m_frame_buffer.ren_buf().attach(pBuffer, unWidth, unHeight, m_frame_buffer.ren_buf().stride());
|
||||
|
||||
return m_pSoftMask;
|
||||
}
|
||||
@ -1401,19 +1258,13 @@ namespace Aggplus
|
||||
}
|
||||
else if (m_pSoftMask)
|
||||
{
|
||||
switch(m_pSoftMask->GetDataType())
|
||||
{
|
||||
case EMaskDataType::ImageBuffer:
|
||||
{
|
||||
ESoftMaskType nType = m_pSoftMask->GetDataType();
|
||||
if (nType == ESoftMaskType::RGBGrayBuffer)
|
||||
Aggplus::BlendTo<agg::rgb_to_gray_mask_u8<0, 1, 2>>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pSoftMask->GetBuffer(), m_pSoftMask->GetStep());
|
||||
else if (nType == ESoftMaskType::BGRGrayBuffer)
|
||||
Aggplus::BlendTo<agg::rgb_to_gray_mask_u8<2, 1, 0>>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pSoftMask->GetBuffer(), m_pSoftMask->GetStep());
|
||||
break;
|
||||
}
|
||||
case EMaskDataType::Alpha4Buffer:
|
||||
{
|
||||
else if (nType == ESoftMaskType::Alpha4Buffer)
|
||||
Aggplus::BlendTo<agg::one_component_mask_u8>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pSoftMask->GetBuffer() + 3, m_pSoftMask->GetStep());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1549,10 +1400,13 @@ namespace Aggplus
|
||||
{
|
||||
if (m_pSoftMask)
|
||||
{
|
||||
if (m_pSoftMask->GetDataType() == EMaskDataType::ImageBuffer)
|
||||
return render_scanlines_3(ras, ren, m_pSoftMask->GetScanlineImage());
|
||||
if (m_pSoftMask->GetDataType() == EMaskDataType::Alpha4Buffer)
|
||||
return render_scanlines_3(ras, ren, m_pSoftMask->GetScanlineABuffer());
|
||||
ESoftMaskType nType = m_pSoftMask->GetDataType();
|
||||
if (nType == ESoftMaskType::RGBGrayBuffer)
|
||||
return render_scanlines_3(ras, ren, ((CSoftMaskRGBAgray*)m_pSoftMask->m_pInternal)->GetScanline());
|
||||
if (nType == ESoftMaskType::BGRGrayBuffer)
|
||||
return render_scanlines_3(ras, ren, ((CSoftMaskBGRAgray*)m_pSoftMask->m_pInternal)->GetScanline());
|
||||
if (nType == ESoftMaskType::Alpha4Buffer)
|
||||
return render_scanlines_3(ras, ren, ((CSoftMaskAlpha*)m_pSoftMask->m_pInternal)->GetScanline());
|
||||
}
|
||||
render_scanlines_3(ras, ren, m_rasterizer.get_scanline());
|
||||
}
|
||||
@ -1799,11 +1653,11 @@ namespace Aggplus
|
||||
m_rasterizer.gamma(1.0);
|
||||
}
|
||||
#else
|
||||
agg::rgba8 c1 = agg::rgba8(pBrush->m_dwColor1.GetR(), pBrush->m_dwColor1.GetG(), pBrush->m_dwColor1.GetB(), pBrush->m_dwColor1.GetA());
|
||||
agg::rgba8 c2 = agg::rgba8(pBrush->m_dwColor2.GetR(), pBrush->m_dwColor2.GetG(), pBrush->m_dwColor2.GetB(), pBrush->m_dwColor2.GetA());
|
||||
agg::rgba8 c1 = agg::rgba8(pBrush->GetColor1().GetR(), pBrush->GetColor1().GetG(), pBrush->GetColor1().GetB(), pBrush->GetColor1().GetA());
|
||||
agg::rgba8 c2 = agg::rgba8(pBrush->GetColor2().GetR(), pBrush->GetColor2().GetG(), pBrush->GetColor2().GetB(), pBrush->GetColor2().GetA());
|
||||
|
||||
BYTE* pPattern = new BYTE[HATCH_TX_SIZE * HATCH_TX_SIZE * 4];
|
||||
agg::GetHatchPattern(pBrush->m_name, (agg::rgba8*)pPattern, c1, c2);
|
||||
agg::GetHatchPattern(pBrush->GetName(), (agg::rgba8*)pPattern, c1, c2);
|
||||
|
||||
agg::trans_affine mtx_Work(m_oTransform.m_internal->m_agg_mtx);
|
||||
if (m_dDpiTile > 1)
|
||||
@ -2196,22 +2050,22 @@ namespace Aggplus
|
||||
|
||||
if(pImgBuff && dwImgWidth && dwImgHeight)
|
||||
{
|
||||
Aggplus::WrapMode wrapmode = ptxBrush->m_wrapMode;
|
||||
Aggplus::CMatrix matrix = ptxBrush->m_mtx;
|
||||
Aggplus::WrapMode wrapmode = ptxBrush->m_eWrapMode;
|
||||
Aggplus::CMatrix matrix = ptxBrush->m_Matrix;
|
||||
|
||||
if(wrapmode == WrapModeClamp)
|
||||
{
|
||||
DoFillPathTextureClampSz2( matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, ptxBrush->Alpha);
|
||||
DoFillPathTextureClampSz2( matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, ptxBrush->m_Alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_bSwapRGB)
|
||||
{
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_bgra32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->Alpha);
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_bgra32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->m_Alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_rgba32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->Alpha);
|
||||
DoFillPathTextureClampSz3<agg::pixfmt_rgba32>(matrix, pImgBuff, dwImgWidth, dwImgHeight, nImgStride, wrapmode, ptxBrush->m_Alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2244,6 +2098,186 @@ namespace Aggplus
|
||||
break;
|
||||
}
|
||||
}
|
||||
template<class Rasterizer>
|
||||
agg::trans_affine* CGraphics::DoStrokePath(NSStructures::CPen* pPen, CGraphicsPath* pPath, Rasterizer* pRasterizer)
|
||||
{
|
||||
agg::line_join_e LineJoin = agg::round_join;
|
||||
switch(pPen->LineJoin)
|
||||
{
|
||||
case LineJoinMiter : LineJoin = agg::miter_join_revert; break;
|
||||
case LineJoinBevel : LineJoin = agg::bevel_join; break;
|
||||
case LineJoinRound : LineJoin = agg::round_join; break;
|
||||
case LineJoinMiterClipped : LineJoin = agg::miter_join_revert; break;
|
||||
default: break;
|
||||
}
|
||||
agg::line_cap_e LineCap = agg::round_cap;
|
||||
switch(pPen->LineStartCap)
|
||||
{
|
||||
case LineCapFlat : LineCap = agg::butt_cap; break;
|
||||
case LineCapRound : LineCap = agg::round_cap; break;
|
||||
case LineCapSquare : LineCap = agg::square_cap; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
double dWidth = pPen->Size;
|
||||
if (!m_bIntegerGrid && m_bIs0PenWidthAs1px)
|
||||
{
|
||||
double dWidthMinSize, dSqrtDet = sqrt(abs(m_oFullTransform.m_internal->m_agg_mtx.determinant()));
|
||||
if (0 == dWidth)
|
||||
{
|
||||
double dX = 0.72, dY = 0.72;
|
||||
agg::trans_affine invert = ~m_oFullTransform.m_internal->m_agg_mtx;
|
||||
invert.transform_2x2(&dX, &dY);
|
||||
dWidth = std::min(abs(dX), abs(dY));
|
||||
}
|
||||
else if (0 != dSqrtDet && dWidth < (dWidthMinSize = 1.0 / dSqrtDet))
|
||||
dWidth = dWidthMinSize;
|
||||
}
|
||||
|
||||
double dblMiterLimit = pPen->MiterLimit;
|
||||
|
||||
agg::path_storage path_copy(pPath->m_internal->m_agg_ps);
|
||||
bool bIsUseIdentity = m_bIntegerGrid;
|
||||
if (!bIsUseIdentity)
|
||||
{
|
||||
agg::trans_affine* full_trans = &m_oFullTransform.m_internal->m_agg_mtx;
|
||||
double dDet = full_trans->determinant();
|
||||
|
||||
if (fabs(dDet) < 0.0001)
|
||||
{
|
||||
path_copy.transform_all_paths(m_oFullTransform.m_internal->m_agg_mtx);
|
||||
dWidth *= sqrt(fabs(dDet));
|
||||
|
||||
bIsUseIdentity = true;
|
||||
}
|
||||
}
|
||||
|
||||
typedef agg::conv_curve<agg::path_storage> conv_crv_type;
|
||||
|
||||
conv_crv_type c_c_path(path_copy);
|
||||
c_c_path.approximation_scale(25.0);
|
||||
c_c_path.approximation_method(agg::curve_inc);
|
||||
DashStyle eStyle = (DashStyle)pPen->DashStyle;
|
||||
|
||||
if (DashStyleCustom == eStyle)
|
||||
{
|
||||
if (0 == pPen->Count || NULL == pPen->DashPattern)
|
||||
{
|
||||
eStyle = DashStyleSolid;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool bFoundNormal = false;
|
||||
for (int i = 0; i < pPen->Count; i++)
|
||||
{
|
||||
if (fabs(pPen->DashPattern[i]) > 0.0001)
|
||||
{
|
||||
bFoundNormal = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bFoundNormal)
|
||||
eStyle = DashStyleSolid;
|
||||
}
|
||||
}
|
||||
|
||||
agg::trans_affine* pAffine = &m_oFullTransform.m_internal->m_agg_mtx;
|
||||
if (bIsUseIdentity)
|
||||
pAffine = new agg::trans_affine();
|
||||
|
||||
if (DashStyleSolid == eStyle)
|
||||
{
|
||||
typedef agg::conv_stroke<conv_crv_type> Path_Conv_StrokeN;
|
||||
Path_Conv_StrokeN pgN(c_c_path);
|
||||
|
||||
//pgN.line_join(agg::miter_join_revert);
|
||||
|
||||
pgN.line_cap(LineCap);
|
||||
|
||||
pgN.line_join(LineJoin);
|
||||
pgN.inner_join(agg::inner_round);
|
||||
|
||||
pgN.miter_limit(dblMiterLimit);
|
||||
pgN.width(dWidth);
|
||||
|
||||
pgN.approximation_scale(25.0);
|
||||
|
||||
typedef agg::conv_transform<Path_Conv_StrokeN> transStroke;
|
||||
|
||||
transStroke trans(pgN, *pAffine);
|
||||
pRasterizer->add_path(trans);
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef agg::conv_dash<conv_crv_type> Path_Conv_Dash;
|
||||
Path_Conv_Dash poly2_dash(c_c_path);
|
||||
|
||||
typedef agg::conv_stroke<Path_Conv_Dash> Path_Conv_StrokeD;
|
||||
Path_Conv_StrokeD pgD(poly2_dash);
|
||||
|
||||
switch (eStyle)
|
||||
{
|
||||
case DashStyleDash:
|
||||
poly2_dash.add_dash(3.00*dWidth, dWidth);
|
||||
break;
|
||||
case DashStyleDot:
|
||||
poly2_dash.add_dash(dWidth, dWidth);
|
||||
break;
|
||||
case DashStyleDashDot:
|
||||
poly2_dash.add_dash(3.00*dWidth, dWidth);
|
||||
poly2_dash.add_dash(dWidth, dWidth);
|
||||
break;
|
||||
case DashStyleDashDotDot:
|
||||
poly2_dash.add_dash(3.00*dWidth, dWidth);
|
||||
poly2_dash.add_dash(dWidth, dWidth);
|
||||
poly2_dash.add_dash(dWidth, dWidth);
|
||||
break;
|
||||
default:
|
||||
case DashStyleCustom:
|
||||
{
|
||||
double offset = pPen->DashOffset;
|
||||
double* params = pPen->DashPattern;
|
||||
LONG lCount = pPen->Count;
|
||||
LONG lCount2 = lCount / 2;
|
||||
|
||||
double dKoef = 1.0;
|
||||
|
||||
for (LONG i = 0; i < lCount2; ++i)
|
||||
{
|
||||
if (0 == i)
|
||||
{
|
||||
poly2_dash.add_dash((params[i * 2]) * dKoef, params[i * 2 + 1] * dKoef);
|
||||
}
|
||||
else
|
||||
{
|
||||
poly2_dash.add_dash(params[i * 2] * dKoef, params[i * 2 + 1] * dKoef);
|
||||
}
|
||||
}
|
||||
if (1 == (lCount % 2))
|
||||
{
|
||||
poly2_dash.add_dash(params[lCount - 1] * dKoef, 0);
|
||||
}
|
||||
poly2_dash.dash_start(offset * dKoef);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double dWidthMinSize = 1.0 / sqrt(abs(m_oCoordTransform.m_internal->m_agg_mtx.determinant()));
|
||||
if ((0 == dWidth && !m_bIntegerGrid) || dWidth < dWidthMinSize)
|
||||
dWidth = dWidthMinSize;
|
||||
|
||||
pgD.line_cap(LineCap);
|
||||
pgD.line_join(LineJoin);
|
||||
pgD.miter_limit(dblMiterLimit);
|
||||
pgD.width(dWidth);
|
||||
|
||||
agg::conv_transform<Path_Conv_StrokeD> trans(pgD, *pAffine);
|
||||
pRasterizer->add_path(trans);
|
||||
}
|
||||
|
||||
return bIsUseIdentity ? pAffine : NULL;
|
||||
}
|
||||
// text methods
|
||||
int CGraphics::FillGlyph2(int nX, int nY, TGlyph* pGlyph, Aggplus::CBrush* pBrush)
|
||||
{
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
#include "Matrix.h"
|
||||
#include "GraphicsLayerBlend.h"
|
||||
#include "GraphicsPath.h"
|
||||
#include "AlphaMask.h"
|
||||
#include "AlphaMask_p.h"
|
||||
#include "Clip.h"
|
||||
#include "Brush.h"
|
||||
#include "Image.h"
|
||||
@ -360,8 +360,8 @@ public:
|
||||
Status SetClip(CGraphicsPath* pPath);
|
||||
Status ResetClip();
|
||||
Status ExclugeClip(CGraphicsPath* pPath);
|
||||
Status CombineClip(CGraphicsPath* pPath, agg::sbool_op_e op);
|
||||
Status InternalClip(CGraphicsPath* pPath, CMatrix* pTransform, agg::sbool_op_e op);
|
||||
Status CombineClip(CGraphicsPath* pPath, agg::sbool_op_e op, NSStructures::CPen* pPen = NULL);
|
||||
Status InternalClip(CGraphicsPath* pPath, CMatrix* pTransform, agg::sbool_op_e op, NSStructures::CPen* pPen = NULL);
|
||||
|
||||
// измерение текста
|
||||
INT MeasureString(const std::wstring& strText, CFontManager* pManager, double* lWidth, double* lHeight);
|
||||
@ -453,6 +453,8 @@ protected:
|
||||
void DoFillPathTextureClampSz3(const CMatrix &mImgMtx, const void *pImgBuff, DWORD dwImgWidth, DWORD dwImgHeight, int nImgStride, Aggplus::WrapMode wrapmode, BYTE Alpha = 255);
|
||||
|
||||
void DoFillPath(const CBrush* Brush);
|
||||
template<class Rasterizer>
|
||||
agg::trans_affine* DoStrokePath(NSStructures::CPen* pPen, CGraphicsPath* pPath, Rasterizer* ras);
|
||||
|
||||
// text methods
|
||||
int FillGlyph2(int nX, int nY, TGlyph* pGlyph, Aggplus::CBrush* pBrush);
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Aggplus
|
||||
|
||||
CGraphicsPath::CGraphicsPath(CGraphicsPath&& other) noexcept
|
||||
{
|
||||
*this = other;
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CGraphicsPath::CGraphicsPath(const std::vector<CGraphicsPath>& paths) noexcept : CGraphicsPath()
|
||||
|
||||
@ -189,7 +189,7 @@ namespace Aggplus
|
||||
Exclusion = 3
|
||||
};
|
||||
|
||||
GRAPHICS_DECL CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op);
|
||||
GRAPHICS_DECL CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType = c_nWindingFillMode);
|
||||
|
||||
} // namespace Aggplus
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ Aggplus::CBrush* CGraphicsRenderer::CreateBrush(NSStructures::CBrush* pBrush)
|
||||
Aggplus::CColor o1((BYTE)(pBrush->Alpha1 * m_dGlobalAlpha), pBrush->Color1, bIsSwappedRGB);
|
||||
Aggplus::CColor o2((BYTE)(pBrush->Alpha2 * m_dGlobalAlpha), pBrush->Color2, bIsSwappedRGB);
|
||||
|
||||
Aggplus::CBrushLinearGradient* pNew = new Aggplus::CBrushLinearGradient( Aggplus::RectF(0.0f, 0.0f, 1.0f, 1.0f), o1, o2, (float)pBrush->LinearAngle, TRUE );
|
||||
Aggplus::CBrushLinearGradient* pNew = new Aggplus::CBrushLinearGradient(Aggplus::RectF(0.0f, 0.0f, 1.0f, 1.0f), o1, o2, (float)pBrush->LinearAngle, true);
|
||||
if( pNew )
|
||||
{
|
||||
pNew->SetRelativeCoords( TRUE );
|
||||
@ -180,11 +180,11 @@ Aggplus::CBrush* CGraphicsRenderer::CreateBrush(NSStructures::CBrush* pBrush)
|
||||
Aggplus::CColor o2((BYTE)(pBrush->Alpha2 * m_dGlobalAlpha), pBrush->Color2, bIsSwappedRGB);
|
||||
|
||||
Aggplus::CBrushHatch* pNew = new Aggplus::CBrushHatch();
|
||||
pNew->m_dwColor1 = o1;
|
||||
pNew->m_dwColor2 = o2;
|
||||
pNew->m_name = pBrush->TexturePath;
|
||||
pNew->SetColor1(o1);
|
||||
pNew->SetColor2(o2);
|
||||
pNew->SetName(pBrush->TexturePath);
|
||||
|
||||
pNew->Bounds = pBrush->Bounds;
|
||||
pNew->SetBounds(pBrush->Bounds);
|
||||
|
||||
return pNew;
|
||||
}
|
||||
@ -822,7 +822,8 @@ HRESULT CGraphicsRenderer::EndCommand(const DWORD& lType)
|
||||
m_pPath->SetRuler(bIsIn ? false : true);
|
||||
|
||||
INT bIsIntersect = (c_nClipRegionIntersect == (0x0100 & m_lCurrentClipMode));
|
||||
m_pRenderer->CombineClip(m_pPath, bIsIntersect ? agg::sbool_and : agg::sbool_or);
|
||||
INT bIsStrokePath = (c_nClipToStrokePath == (0x0010 & m_lCurrentClipMode));
|
||||
m_pRenderer->CombineClip(m_pPath, bIsIntersect ? agg::sbool_and : agg::sbool_or, bIsStrokePath ? &m_oPen : NULL);
|
||||
|
||||
//m_pRenderer->SetClip(m_pPath);
|
||||
break;
|
||||
@ -955,76 +956,76 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
}
|
||||
|
||||
Aggplus::CBrushTexture* pTextureBrush = NULL;
|
||||
|
||||
if (NULL != m_pCache)
|
||||
{
|
||||
pCacheImage = (CCacheImage*)m_pCache->Lock(m_oBrush.TexturePath);
|
||||
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), oMode);
|
||||
if (NULL != m_oBrush.Image)
|
||||
{
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
|
||||
}
|
||||
else if (m_oBrush.TexturePath.find(L"data:") == 0)
|
||||
{
|
||||
bool bIsOnlyOfficeHatch = false;
|
||||
if (m_oBrush.TexturePath.find(L"onlyoffice_hatch") != std::wstring::npos)
|
||||
bIsOnlyOfficeHatch = true;
|
||||
|
||||
int countErase = (int)(m_oBrush.TexturePath.find(',') + 1);
|
||||
int nInputSize = (int)(m_oBrush.TexturePath.length() - countErase);
|
||||
const wchar_t* pInputSrc = m_oBrush.TexturePath.c_str() + countErase;
|
||||
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nInputSize);
|
||||
BYTE* pImageData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(pInputSrc, nInputSize, pImageData, &nDecodeLen))
|
||||
{
|
||||
CBgraFrame oFrame;
|
||||
if (bIsOnlyOfficeHatch)
|
||||
{
|
||||
int nSize = (int)sqrt(nDecodeLen >> 2);
|
||||
oFrame.put_IsRGBA(true);
|
||||
oFrame.put_Data(pImageData);
|
||||
oFrame.put_Width(nSize);
|
||||
oFrame.put_Height(nSize);
|
||||
oFrame.put_Stride(4 * nSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
oFrame.put_IsRGBA(false);
|
||||
oFrame.Decode(pImageData, nDecodeLen);
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
}
|
||||
// pImage отдается pTextureBrush и освобождается вместе с pBrush
|
||||
Aggplus::CImage* pImage = new Aggplus::CImage();
|
||||
pImage->Create(oFrame.get_Data(), oFrame.get_Width(), oFrame.get_Height(), oFrame.get_Stride());
|
||||
oFrame.ClearNoAttack();
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pImage, oMode);
|
||||
pTextureBrush->SetReleaseImage(true);
|
||||
}
|
||||
else
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BUILDING_WASM_MODULE
|
||||
if (NULL != m_oBrush.Image)
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
|
||||
else if (m_oBrush.TexturePath.find(L"data:") == 0)
|
||||
if (NULL != m_pCache)
|
||||
{
|
||||
bool bIsOnlyOfficeHatch = false;
|
||||
if (m_oBrush.TexturePath.find(L"onlyoffice_hatch") != std::wstring::npos)
|
||||
bIsOnlyOfficeHatch = true;
|
||||
std::string sBase64MultyByte(m_oBrush.TexturePath.begin(), m_oBrush.TexturePath.end());
|
||||
sBase64MultyByte.erase(0, sBase64MultyByte.find(',') + 1);
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(sBase64MultyByte.length());
|
||||
BYTE* pImageData = new BYTE[nDecodeLen + 64];
|
||||
if (TRUE == NSBase64::Base64Decode(sBase64MultyByte.c_str(), sBase64MultyByte.length(), pImageData, &nDecodeLen))
|
||||
{
|
||||
CBgraFrame oFrame;
|
||||
if (bIsOnlyOfficeHatch)
|
||||
{
|
||||
int nSize = (int)sqrt(nDecodeLen >> 2);
|
||||
oFrame.put_IsRGBA(true);
|
||||
oFrame.put_Data(pImageData);
|
||||
oFrame.put_Width(nSize);
|
||||
oFrame.put_Height(nSize);
|
||||
oFrame.put_Stride(4 * nSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
oFrame.put_IsRGBA(false);
|
||||
oFrame.Decode(pImageData, nDecodeLen);
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
}
|
||||
// pImage отдается pTextureBrush и освобождается вместе с pBrush
|
||||
Aggplus::CImage* pImage = new Aggplus::CImage();
|
||||
pImage->Create(oFrame.get_Data(), oFrame.get_Width(), oFrame.get_Height(), oFrame.get_Stride());
|
||||
oFrame.ClearNoAttack();
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pImage, oMode);
|
||||
pTextureBrush->m_bReleaseImage = TRUE;
|
||||
}
|
||||
else
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
pCacheImage = (CCacheImage*)m_pCache->Lock(m_oBrush.TexturePath);
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), oMode);
|
||||
}
|
||||
#else
|
||||
if (NULL != m_oBrush.Image)
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
|
||||
else
|
||||
{
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.TexturePath, oMode);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if( pTextureBrush )
|
||||
{
|
||||
pTextureBrush->SetTransform(&m_oBrush.Transform);
|
||||
|
||||
pTextureBrush->Alpha = (BYTE)m_oBrush.TextureAlpha;
|
||||
pTextureBrush->SetAlpha(static_cast<BYTE>(m_oBrush.TextureAlpha));
|
||||
|
||||
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.right = pTextureBrush->m_oBounds.left + m_oBrush.Rect.Width;
|
||||
pTextureBrush->m_oBounds.bottom = pTextureBrush->m_oBounds.top + m_oBrush.Rect.Height;
|
||||
pTextureBrush->SetBounds({m_oBrush.Rect.X,
|
||||
m_oBrush.Rect.Y,
|
||||
m_oBrush.Rect.X + m_oBrush.Rect.Width,
|
||||
m_oBrush.Rect.Y + m_oBrush.Rect.Height});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -96,6 +96,9 @@ const long c_nBaselineShift = 0xa041;
|
||||
// типы клипа
|
||||
const long c_nClipRegionTypeWinding = 0x0000;
|
||||
const long c_nClipRegionTypeEvenOdd = 0x0001;
|
||||
// тип преобразования пути для клипов
|
||||
const long c_nClipToPath = 0x0000;
|
||||
const long c_nClipToStrokePath = 0x0010;
|
||||
// тип объединения клипов
|
||||
const long c_nClipRegionIntersect = 0x0000;
|
||||
const long c_nClipRegionUnion = 0x0100;
|
||||
|
||||
@ -51,6 +51,16 @@ namespace Aggplus
|
||||
Create(filename);
|
||||
}
|
||||
|
||||
CImage::CImage(const CImage& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CImage::CImage(CImage&& other)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CImage::~CImage()
|
||||
{
|
||||
Destroy();
|
||||
@ -136,6 +146,46 @@ namespace Aggplus
|
||||
m_bExternalBuffer = false;
|
||||
}
|
||||
|
||||
CImage& CImage::operator=(const CImage& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_Status = other.m_Status;
|
||||
|
||||
m_dwHeight = other.m_dwHeight;
|
||||
m_dwWidth = other.m_dwWidth;
|
||||
m_nStride = other.m_nStride;
|
||||
|
||||
m_bExternalBuffer = other.m_bExternalBuffer;
|
||||
|
||||
size_t size_of_data = m_dwHeight * m_nStride > 0 ? m_nStride : -m_nStride;
|
||||
m_pImgData = new BYTE[size_of_data];
|
||||
|
||||
memcpy(m_pImgData, other.m_pImgData, size_of_data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CImage& CImage::operator=(CImage&& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_Status = other.m_Status;
|
||||
|
||||
m_dwHeight = other.m_dwHeight;
|
||||
m_dwWidth = other.m_dwWidth;
|
||||
m_nStride = other.m_nStride;
|
||||
|
||||
m_bExternalBuffer = other.m_bExternalBuffer;
|
||||
|
||||
m_pImgData = other.m_pImgData;
|
||||
other.m_pImgData = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
DWORD CImage::GetWidth() const { return(m_dwWidth); }
|
||||
DWORD CImage::GetHeight() const { return(m_dwHeight); }
|
||||
long CImage::GetStride() const { return(m_nStride); }
|
||||
@ -146,10 +196,10 @@ namespace Aggplus
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
CBitmap::CBitmap(LONG width, LONG height, PixelFormat format) : CImage()
|
||||
{
|
||||
if(width <= 0 || height <= 0)
|
||||
{
|
||||
m_Status=InvalidParameter;
|
||||
return;
|
||||
if(width <= 0 || height <= 0)
|
||||
{
|
||||
m_Status=InvalidParameter;
|
||||
return;
|
||||
}
|
||||
|
||||
LONG lSize = 4 * width * height;
|
||||
@ -168,15 +218,15 @@ namespace Aggplus
|
||||
CBitmap::CBitmap(LONG width, LONG height, LONG stride, PixelFormat format, BYTE* scan0) : CImage()
|
||||
{
|
||||
//Warning! This is not Gdiplus behavior; it returns Ok!
|
||||
if(width <= 0 || height <= 0 || stride == 0)
|
||||
{
|
||||
m_Status = InvalidParameter;
|
||||
return;
|
||||
if(width <= 0 || height <= 0 || stride == 0)
|
||||
{
|
||||
m_Status = InvalidParameter;
|
||||
return;
|
||||
}
|
||||
|
||||
m_bExternalBuffer = true;
|
||||
|
||||
if (stride > 0)
|
||||
if (stride > 0)
|
||||
{
|
||||
m_pImgData = scan0;
|
||||
}
|
||||
@ -184,7 +234,7 @@ namespace Aggplus
|
||||
{
|
||||
m_pImgData = scan0 + (height - 1) * (-stride);
|
||||
}
|
||||
|
||||
|
||||
m_dwWidth = width;
|
||||
m_dwHeight = height;
|
||||
m_nStride = stride;
|
||||
|
||||
@ -49,6 +49,8 @@ public:
|
||||
public:
|
||||
CImage();
|
||||
CImage(const std::wstring& filename);
|
||||
CImage(const CImage& other);
|
||||
CImage(CImage&& other);
|
||||
virtual ~CImage();
|
||||
|
||||
DWORD GetWidth() const;
|
||||
@ -64,6 +66,9 @@ public:
|
||||
bool SaveFile(const std::wstring& strFileName, UINT nFileType);
|
||||
void Destroy();
|
||||
|
||||
CImage& operator=(const CImage& other);
|
||||
CImage& operator=(CImage&& other);
|
||||
|
||||
protected:
|
||||
Status m_Status;
|
||||
|
||||
|
||||
@ -30,127 +30,133 @@
|
||||
*
|
||||
*/
|
||||
#include "Matrix_private.h"
|
||||
#include <utility>
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
CMatrix::CMatrix(double m11, double m12, double m21, double m22, double dx, double dy)
|
||||
CMatrix::CMatrix(double m11, double m12, double m21, double m22, double dx, double dy)
|
||||
{
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx.sx = m11;
|
||||
m_internal->m_agg_mtx.shy = m12;
|
||||
m_internal->m_agg_mtx.shx = m21;
|
||||
m_internal->m_agg_mtx.sy = m22;
|
||||
m_internal->m_agg_mtx.tx = dx;
|
||||
m_internal->m_agg_mtx.ty = dy;
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx.sx = m11;
|
||||
m_internal->m_agg_mtx.shy = m12;
|
||||
m_internal->m_agg_mtx.shx = m21;
|
||||
m_internal->m_agg_mtx.sy = m22;
|
||||
m_internal->m_agg_mtx.tx = dx;
|
||||
m_internal->m_agg_mtx.ty = dy;
|
||||
}
|
||||
|
||||
CMatrix::CMatrix(const CMatrix& oSrc)
|
||||
{
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx = oSrc.m_internal->m_agg_mtx;
|
||||
}
|
||||
|
||||
CMatrix::CMatrix()
|
||||
CMatrix::CMatrix()
|
||||
{
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal = new CMatrix_private();
|
||||
}
|
||||
|
||||
|
||||
CMatrix::CMatrix(const CMatrix& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
CMatrix::CMatrix(CMatrix&& other)
|
||||
{
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
CMatrix::~CMatrix()
|
||||
{
|
||||
RELEASEOBJECT(m_internal);
|
||||
RELEASEOBJECT(m_internal);
|
||||
}
|
||||
|
||||
|
||||
void CMatrix::Translate(double offsetX, double offsetY, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_translation(offsetX, offsetY));
|
||||
}
|
||||
|
||||
void CMatrix::Scale(double scaleX, double scaleY, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
}
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_scaling(scaleX, scaleY));
|
||||
}
|
||||
|
||||
void CMatrix::Shear(double shearX, double shearY, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_skewing(shearX, shearY));
|
||||
}
|
||||
|
||||
double CMatrix::Determinant() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.determinant();
|
||||
}
|
||||
|
||||
void CMatrix::TransformVectors(PointF* pts, int count) const
|
||||
{
|
||||
// Store matrix to an array [6] of double
|
||||
double M[6]; m_internal->m_agg_mtx.store_to(M);
|
||||
double M[6];
|
||||
m_internal->m_agg_mtx.store_to(M);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = pts[i].X;
|
||||
double y = pts[i].Y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = (float)(x-M[4]);
|
||||
pts[i].Y = (float)(y-M[5]);
|
||||
double x = pts[i].X;
|
||||
double y = pts[i].Y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = static_cast<float>(x-M[4]);
|
||||
pts[i].Y = static_cast<float>(y-M[5]);
|
||||
}
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoints(PointF* pts, int count) const
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = pts[i].X;
|
||||
double y = pts[i].Y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = (float)x;
|
||||
pts[i].Y = (float)y;
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
pts[i].X = static_cast<float>(x);
|
||||
pts[i].Y = static_cast<float>(y);
|
||||
}
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoint(double& x, double& y) const
|
||||
{
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
m_internal->m_agg_mtx.transform(&x, &y);
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoints(PointF* dst, const PointF* src, int count) const
|
||||
{
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
for(int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = src[i].X * m.sx + src[i].Y * m.shx + m.tx;
|
||||
double y = src[i].Y * m.sy + src[i].X * m.shy + m.ty;
|
||||
|
||||
dst[i].X = static_cast<float>(x);
|
||||
dst[i].Y = static_cast<float>(y);
|
||||
}
|
||||
}
|
||||
|
||||
void CMatrix::Rotate(double angle, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
|
||||
void CMatrix::RotateAt(double angle, const PointF ¢er, MatrixOrder order)
|
||||
{
|
||||
Translate(-center.X, -center.Y, order);
|
||||
if(order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
|
||||
if(order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
|
||||
Translate(center.X, center.Y, order);
|
||||
return;
|
||||
}
|
||||
@ -158,168 +164,169 @@ namespace Aggplus
|
||||
void CMatrix::RotateAt(double angle, double x, double y, MatrixOrder order)
|
||||
{
|
||||
Translate(-x, -y, order);
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
}
|
||||
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
else
|
||||
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
|
||||
|
||||
Translate(x, y, order);
|
||||
}
|
||||
|
||||
void CMatrix::Multiply(const CMatrix* matrix, MatrixOrder order)
|
||||
{
|
||||
if (order == MatrixOrderPrepend)
|
||||
{
|
||||
m_internal->m_agg_mtx.premultiply(matrix->m_internal->m_agg_mtx);
|
||||
}
|
||||
if (order == MatrixOrderPrepend)
|
||||
m_internal->m_agg_mtx.premultiply(matrix->m_internal->m_agg_mtx);
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_mtx.multiply(matrix->m_internal->m_agg_mtx);
|
||||
}
|
||||
m_internal->m_agg_mtx.multiply(matrix->m_internal->m_agg_mtx);
|
||||
}
|
||||
|
||||
double CMatrix::OffsetX() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
}
|
||||
|
||||
double CMatrix::OffsetY() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
}
|
||||
|
||||
double CMatrix::sx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.sx;
|
||||
}
|
||||
double CMatrix::sy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.sy;
|
||||
}
|
||||
double CMatrix::shx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shx;
|
||||
}
|
||||
double CMatrix::shy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shy;
|
||||
}
|
||||
double CMatrix::tx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
}
|
||||
double CMatrix::ty() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
}
|
||||
double CMatrix::rotation()
|
||||
{
|
||||
return m_internal->m_agg_mtx.rotation();
|
||||
}
|
||||
|
||||
|
||||
void CMatrix::SetElements(const double& sx, const double& shy, const double& shx, const double& sy, const double& tx, const double& ty)
|
||||
{
|
||||
m_internal->m_agg_mtx.sx = sx;
|
||||
m_internal->m_agg_mtx.shy = shy;
|
||||
m_internal->m_agg_mtx.shx = shx;
|
||||
m_internal->m_agg_mtx.sy = sy;
|
||||
m_internal->m_agg_mtx.tx = tx;
|
||||
m_internal->m_agg_mtx.ty = ty;
|
||||
}
|
||||
|
||||
Status CMatrix::GetElements(REAL* m) const
|
||||
double CMatrix::sx() const
|
||||
{
|
||||
double M[6]; m_internal->m_agg_mtx.store_to(M);
|
||||
m[0]=(REAL)M[0];
|
||||
m[1]=(REAL)M[1];
|
||||
m[2]=(REAL)M[2];
|
||||
m[3]=(REAL)M[3];
|
||||
m[4]=(REAL)M[4];
|
||||
m[5]=(REAL)M[5];
|
||||
return m_internal->m_agg_mtx.sx;
|
||||
}
|
||||
|
||||
double CMatrix::sy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.sy;
|
||||
}
|
||||
|
||||
double CMatrix::shx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shx;
|
||||
}
|
||||
|
||||
double CMatrix::shy() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.shy;
|
||||
}
|
||||
|
||||
double CMatrix::tx() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.tx;
|
||||
}
|
||||
|
||||
double CMatrix::ty() const
|
||||
{
|
||||
return m_internal->m_agg_mtx.ty;
|
||||
}
|
||||
|
||||
double CMatrix::rotation()
|
||||
{
|
||||
return m_internal->m_agg_mtx.rotation();
|
||||
}
|
||||
|
||||
void CMatrix::SetElements(const double& sx, const double& shy, const double& shx,
|
||||
const double& sy, const double& tx, const double& ty)
|
||||
{
|
||||
m_internal->m_agg_mtx.sx = sx;
|
||||
m_internal->m_agg_mtx.shy = shy;
|
||||
m_internal->m_agg_mtx.shx = shx;
|
||||
m_internal->m_agg_mtx.sy = sy;
|
||||
m_internal->m_agg_mtx.tx = tx;
|
||||
m_internal->m_agg_mtx.ty = ty;
|
||||
}
|
||||
|
||||
Status CMatrix::GetElements(float* m) const
|
||||
{
|
||||
double M[6];
|
||||
m_internal->m_agg_mtx.store_to(M);
|
||||
|
||||
m[0] = static_cast<float>(M[0]);
|
||||
m[1] = static_cast<float>(M[1]);
|
||||
m[2] = static_cast<float>(M[2]);
|
||||
m[3] = static_cast<float>(M[3]);
|
||||
m[4] = static_cast<float>(M[4]);
|
||||
m[5] = static_cast<float>(M[5]);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CMatrix::GetElements(double* m) const
|
||||
{
|
||||
m_internal->m_agg_mtx.store_to(m);
|
||||
m_internal->m_agg_mtx.store_to(m);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
void CMatrix::Reset()
|
||||
{
|
||||
m_internal->m_agg_mtx.reset();
|
||||
m_internal->m_agg_mtx.reset();
|
||||
}
|
||||
|
||||
double CMatrix::Determinant() const
|
||||
bool CMatrix::IsIdentity(const double& eps) const
|
||||
{
|
||||
return m_internal->m_agg_mtx.determinant();
|
||||
}
|
||||
return m_internal->m_agg_mtx.is_identity(eps);
|
||||
}
|
||||
|
||||
const CMatrix& CMatrix::operator=(const CMatrix& Src)
|
||||
bool CMatrix::IsIdentity2(const double& eps) const
|
||||
{
|
||||
m_internal->m_agg_mtx = Src.m_internal->m_agg_mtx;
|
||||
return *this;
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
return agg::is_equal_eps(m.sx, 1.0, eps) &&
|
||||
agg::is_equal_eps(m.shy, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.shx, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.sy, 1.0, eps);
|
||||
}
|
||||
|
||||
bool CMatrix::IsEqual(const CMatrix* mm1, const CMatrix* mm2, const double& eps, bool bIsOnlyMain)
|
||||
{
|
||||
agg::trans_affine& m1 = mm1->m_internal->m_agg_mtx;
|
||||
agg::trans_affine& m2 = mm2->m_internal->m_agg_mtx;
|
||||
|
||||
bool bMain = fabs(m1.sx - m2.sx) < eps &&
|
||||
fabs(m1.sy - m2.sy) < eps &&
|
||||
fabs(m1.shx - m2.shx) < eps &&
|
||||
fabs(m1.shy - m2.shy) < eps;
|
||||
|
||||
if (!bMain || bIsOnlyMain)
|
||||
return bMain;
|
||||
|
||||
return fabs(m1.tx - m2.tx) < eps && fabs(m1.ty - m2.ty) < eps;
|
||||
}
|
||||
|
||||
Status CMatrix::Invert()
|
||||
{
|
||||
double d = m_internal->m_agg_mtx.determinant();
|
||||
if (0.0001 >= fabs(d))
|
||||
double d = m_internal->m_agg_mtx.determinant();
|
||||
if (0.0001 >= fabs(d))
|
||||
return InvalidParameter;
|
||||
|
||||
m_internal->m_agg_mtx.invert();
|
||||
m_internal->m_agg_mtx.invert();
|
||||
return Ok;
|
||||
}
|
||||
|
||||
//Temp
|
||||
//Used in X_BrushLinearGradient constructor
|
||||
double CMatrix::z_Rotation() const
|
||||
{
|
||||
return agg::rad2deg(m_internal->m_agg_mtx.rotation());
|
||||
}
|
||||
|
||||
void CMatrix::TransformPoints( PointF* dst, const PointF* src, int count ) const
|
||||
double CMatrix::z_Rotation() const
|
||||
{
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
for(int i = 0; i < count; ++i)
|
||||
{
|
||||
double x = src[i].X * m.sx + src[i].Y * m.shx + m.tx;
|
||||
double y = src[i].Y * m.sy + src[i].X * m.shy + m.ty;
|
||||
|
||||
dst[i].X = (float)x;
|
||||
dst[i].Y = (float)y;
|
||||
}
|
||||
return agg::rad2deg(m_internal->m_agg_mtx.rotation());
|
||||
}
|
||||
|
||||
bool CMatrix::IsIdentity(const double& eps) const
|
||||
const CMatrix& CMatrix::operator=(const CMatrix& other)
|
||||
{
|
||||
return m_internal->m_agg_mtx.is_identity(eps);
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_internal = new CMatrix_private();
|
||||
m_internal->m_agg_mtx = other.m_internal->m_agg_mtx;
|
||||
return *this;
|
||||
}
|
||||
bool CMatrix::IsIdentity2(const double& eps) const
|
||||
|
||||
CMatrix& CMatrix::operator=(CMatrix&& other)
|
||||
{
|
||||
agg::trans_affine& m = m_internal->m_agg_mtx;
|
||||
return agg::is_equal_eps(m.sx, 1.0, eps) &&
|
||||
agg::is_equal_eps(m.shy, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.shx, 0.0, eps) &&
|
||||
agg::is_equal_eps(m.sy, 1.0, eps);
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_internal = other.m_internal;
|
||||
other.m_internal = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CMatrix::IsEqual(const CMatrix* mm1, const CMatrix* mm2, const double& eps, bool bIsOnlyMain)
|
||||
{
|
||||
agg::trans_affine& m1 = mm1->m_internal->m_agg_mtx;
|
||||
agg::trans_affine& m2 = mm2->m_internal->m_agg_mtx;
|
||||
|
||||
bool bMain = (fabs(m1.sx - m2.sx) < eps &&
|
||||
fabs(m1.sy - m2.sy) < eps &&
|
||||
fabs(m1.shx - m2.shx) < eps &&
|
||||
fabs(m1.shy - m2.shy) < eps) ? true : false;
|
||||
|
||||
if (!bMain || bIsOnlyMain)
|
||||
return bMain;
|
||||
|
||||
return (fabs(m1.tx - m2.tx) < eps && fabs(m1.ty - m2.ty) < eps) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user