Compare commits

...

352 Commits

Author SHA1 Message Date
acc81f8c8d Added gradient testing 2023-08-17 18:54:12 +03:00
c0fd800149 Merge pull request #1247 from ONLYOFFICE/fix/x2ttester
Fix bug 63562
2023-08-17 12:39:03 +05:00
0eb442dceb Fix bug 63609 2023-08-16 13:48:43 +03:00
399add2545 fix bug #63682 2023-08-16 09:01:12 +03:00
f245a5b6a5 fix bug #63681 2023-08-16 08:37:42 +03:00
bc3867f281 Fix bug 63558 2023-08-15 20:56:53 +03:00
7e27726dc2 Merge branch 'release/v7.5.0' of https://github.com/ONLYOFFICE/core into release/v7.5.0 2023-08-15 18:29:42 +03:00
ab1bc5e2a9 Merge remote-tracking branch 'origin/feature/android-fix-build' into release/v7.5.0 2023-08-15 18:29:00 +03:00
68ea0b5875 Fix crash with 2+ emf inside wmf 2023-08-15 18:25:33 +03:00
796cd30b09 Merge pull request #1249 from ONLYOFFICE/fix/Svg_Reader
Refactoring and added support for some properties in Svg Reader
2023-08-15 14:45:07 +05:00
58d023e023 Merge pull request #1248 from ONLYOFFICE/fix/MetafileToSvg
Editing metafile conversion to svg
2023-08-15 14:44:42 +05:00
0ecf5e8eee Refactoring and added support for some properties 2023-08-15 11:28:00 +03:00
6f11dd441b Refactoring 2023-08-15 11:21:14 +03:00
5b91e643bb Fix bug #63608 2023-08-15 11:21:14 +03:00
c884f2a99d Refactoring 2023-08-15 11:21:14 +03:00
fa82a15c07 Tab refactoring 2023-08-15 11:21:14 +03:00
5006bc3349 Fixed a bug with metafiles embedded in the metafile 2023-08-15 11:21:14 +03:00
d87283e485 fix bug #57247 2023-08-15 10:48:57 +03:00
77ff0a5f15 Fix bug 63609 2023-08-14 14:47:12 +03:00
b6dc29364e fix bug #62237 2023-08-11 11:36:20 +03:00
363d1d7af9 fix bug #63502 2023-08-11 11:35:49 +03:00
d6ce980b12 Add base method for sign data 2023-08-10 18:49:30 +03:00
e2289ce58d Merge pull request #1246 from ONLYOFFICE/fix/bug63540
Fix bug 63540
2023-08-10 20:25:14 +05:00
571e257211 fix bug #63608 2023-08-09 19:46:32 +03:00
fc4fadd4a6 fix bug #62851 2023-08-08 19:35:41 +03:00
4864a3c303 fix bug #62763 2023-08-08 18:20:54 +03:00
ec760c2aef for bug #56671 2023-08-08 16:17:10 +03:00
69bf4d64fb fix bug #63580 2023-08-08 15:36:05 +03:00
6e3804df33 fix bug #63536 2023-08-08 10:56:36 +03:00
19f28facf6 fix bug #63535 2023-08-07 17:50:43 +03:00
f45eee1fd6 fix bug 63540 2023-08-07 14:16:05 +03:00
a0e1760e94 fix bug #63259 2023-08-07 11:36:56 +03:00
e57b3e22fd for bug #37564 2023-08-05 17:01:36 +03:00
4c3f983cb4 Fix bug 63562 2023-08-05 16:43:44 +03:00
5db60c2581 for bug #37564 2023-08-05 11:18:22 +03:00
2bc4ccd343 for bug #37564 2023-08-05 09:40:43 +03:00
7304553448 fix bug #63551 2023-08-03 17:31:50 +03:00
fe4e668973 ExternalReference for chart 2023-08-03 14:50:49 +03:00
bd8589e586 fix bug #63506 2023-08-02 21:38:06 +03:00
2a298710a7 Fix build on new linux systems 2023-07-31 14:35:20 +03:00
83fc19672d Merge branch hotfix/v7.4.1 into master 2023-07-31 07:22:04 +00:00
3217ac7d51 Add method for cert&key generation 2023-07-28 12:09:51 +03:00
c2748fcff4 Add check buffer size for password generation 2023-07-27 18:14:06 +03:00
010c58f110 fix bug #58959 2023-07-27 17:27:46 +03:00
cbf1c9eb16 Fix builf 2023-07-27 14:56:35 +03:00
f1236fd01e . 2023-07-27 14:15:23 +03:00
ba10fb7e97 for bug #63199 2023-07-27 13:56:32 +03:00
8e2d5ee209 Fix build 2023-07-27 13:31:23 +03:00
433a0973e5 Change indents 2023-07-27 12:57:20 +03:00
3a94430a64 Fix build 2023-07-27 12:52:22 +03:00
40ca82c584 fix build 2023-07-27 11:34:07 +03:00
24b7b59af0 FIx build 2023-07-27 10:56:46 +03:00
2b494e3590 Fix indents 2023-07-26 23:21:47 +03:00
f3746f4bb8 Merge pull request #1242 from ONLYOFFICE/feature/svg_pull
Svg pull
2023-07-27 01:15:28 +05:00
9cfe99acae Add support python3+ 2023-07-26 22:33:41 +03:00
6b406945f7 for bug #63199 2023-07-26 18:10:23 +03:00
18b59bf8f8 Troubleshooting issues after merge 2023-07-26 14:37:51 +03:00
b481b0ef12 Troubleshooting issues after merge 2023-07-26 14:32:25 +03:00
caaf664633 Merge pull request #1241 from ONLYOFFICE/feature/svg
Pull svg
2023-07-26 13:33:09 +03:00
23167f6460 Merge branch 'feature/svg_pull' into feature/svg 2023-07-26 13:31:42 +03:00
6707cd05a9 fix htmlfile2.cpp 2023-07-26 12:35:57 +03:00
125d2e8b16 Remove unused class 2023-07-25 21:33:34 +03:00
79d830f2cf . 2023-07-25 16:02:51 +03:00
cba75df9d0 Fix ios build 2023-07-25 16:14:37 +05:00
38177a2793 Merge pull request #1239 from ONLYOFFICE/feature/office_utils
Feature/office utils
2023-07-25 15:41:20 +05:00
dd9ca63b54 Remove empty lines 2023-07-25 13:40:40 +03:00
ced55d3cde Remove unused sources 2023-07-25 13:39:02 +03:00
c72e44f44e Refactoring 2023-07-25 13:30:08 +03:00
bc00d63250 add non auto convert 2023-07-25 12:16:01 +03:00
94fd1d94bd Remove bad test 2023-07-25 11:42:27 +03:00
cb01a629bc . 2023-07-25 11:00:14 +03:00
93dc58c49e . 2023-07-24 10:03:53 +03:00
fa2595612e for bug #63441 2023-07-24 09:51:17 +03:00
f10c620ddb Merge remote-tracking branch 'origin/hotfix/v7.4.1' into develop 2023-07-24 09:31:56 +03:00
3c26e50b5d for bug #62990 2023-07-23 15:42:28 +03:00
9286bd4615 Add possible fix to winrar unzipping 2023-07-23 05:06:06 +03:00
2d1f53d952 Merge pull request #1238 from ONLYOFFICE/fix/v7.4.1-fix-bugs
fix bug #63443
2023-07-22 12:18:13 -04:00
5e5fb5ea6d fix bug #63443 2023-07-22 19:16:59 +03:00
34902e06cf Add test
- LoadFileFromArchive (memory)
2023-07-21 22:23:43 +03:00
1db7a6ae2a Refactoring + tests
Add new class CunzFileWrapped,
Add tests for:
- IsArchive
- IsFileExistInArchive
- LoadFileFromArchive
2023-07-21 22:20:31 +03:00
ec72a22aab Merge pull request #1237 from ONLYOFFICE/fix/bug61780
Fix bug 61780
2023-07-21 20:08:55 +05:00
6f0539df86 Fix bug 61780 2023-07-21 17:28:09 +03:00
36109d2ba8 Merge pull request #1236 from ONLYOFFICE/fix/v7.4.1-fix-bugs
fix bug #63441
2023-07-21 10:09:22 -04:00
a283d0c4ad fix bug #63441 2023-07-21 17:08:38 +03:00
1cefed92b2 Refactoring path elements in svg-reader 2023-07-21 11:47:01 +03:00
bfd2627269 Disable xml logs in release build 2023-07-20 22:37:53 +03:00
d690281b8d Fix bug with reading registry 2023-07-20 21:49:36 +03:00
b07c308e9b Fixed bugs 2023-07-20 19:32:05 +03:00
739a1d2a35 Refactoring 2023-07-20 17:28:37 +03:00
1e2964ccbe Fix bug
release obj
2023-07-20 17:20:36 +03:00
b445369410 Add more tests
Unzip file from memory
2023-07-20 17:08:50 +03:00
57cc43371c for bug #63199 2023-07-20 17:02:02 +03:00
de826c1f0f Add UnzipToDir from memory 2023-07-20 16:55:43 +03:00
e74b75a087 Fix bug 62990 2023-07-20 13:12:55 +03:00
c0ffc1dd0f . 2023-07-20 09:58:39 +03:00
c1a6b85431 back to Transitional Migration Features 2023-07-19 22:55:44 +03:00
a8978265ea Use winapi function instead ostream 2023-07-19 21:48:22 +03:00
7ec41517e1 for bug #63394 2023-07-19 16:01:06 +03:00
43880f909a fixx bug #52210 2023-07-19 11:42:34 +03:00
24d1a9b220 Add more tests 2023-07-18 16:00:42 +03:00
ebc81eb7d3 Add tests 2023-07-18 15:34:05 +03:00
529acfbd5f Refactoring 2023-07-18 10:55:09 +03:00
55e171f86e Merge pull request #1235 from ONLYOFFICE/fix/office_utils2
Fix/office utils2
2023-07-18 01:57:11 +05:00
d7254e46c9 Add support unicode names 2023-07-17 23:55:49 +03:00
633041d07f Remove unised code 2023-07-17 23:09:55 +03:00
d0afc0fdc0 Merge pull request #1234 from ONLYOFFICE/hotfix/v7.4.1
Fix NormalizePath method
2023-07-17 22:19:09 +05:00
f1b4b2ac29 Fix NormalizePath method 2023-07-17 20:13:55 +03:00
a6b590be74 Fix check paths 2023-07-17 18:45:17 +03:00
76f64547a3 Fix create directories bug 2023-07-17 18:29:52 +03:00
0a56b4348f Fix folders creation 2023-07-17 18:07:57 +03:00
f0130f92dc Added support for record <a> to svg-reader's 2023-07-17 17:50:47 +03:00
1aa1d63f61 Refactoring 2023-07-17 16:03:01 +03:00
efa6115a34 +dataDisplayOptions16 2023-07-17 14:24:56 +03:00
26f344ab99 Refactoring 2023-07-17 12:54:39 +03:00
8bc6c5abb7 Merge pull request #1233 from ONLYOFFICE/develop
Develop
2023-07-17 13:29:42 +05:00
2c294d5be6 Fix freeze on destroy 2023-07-16 01:24:40 +05:00
bbfb8553b1 Merge pull request #1232 from ONLYOFFICE/hotfix/v7.4.1
Hotfix/v7.4.1
2023-07-16 01:07:08 +05:00
d11b0c814e Fix bug 63166 2023-07-16 01:06:36 +05:00
1dba84f407 Add GetUrl method to DownloadTask 2023-07-15 22:59:27 +05:00
2a84964f3c Fix download manager 2023-07-15 04:29:46 +05:00
ff6bcdbe0d fix bug #63352 2023-07-14 13:52:21 +03:00
0d9d8fad80 Fix bug 63357 2023-07-14 15:25:24 +05:00
29bdbb8898 fix image in header/footer sheets 2023-07-14 12:17:35 +03:00
8f8d9050fa Fix android build 2023-07-14 13:34:13 +05:00
988d41bee5 Merge pull request #1231 from ONLYOFFICE/hotfix/v7.4.1
Fix bug 63357
2023-07-14 13:22:39 +05:00
18cc4c74a6 fix previus refact binary 2023-07-13 18:14:45 +03:00
588040c7ee fix bug #63211 2023-07-13 16:51:50 +03:00
6146180408 . 2023-07-13 16:24:13 +03:00
a707eddabc fix bug #63269 2023-07-13 16:06:36 +03:00
092df2d20e Fix bug 63357 2023-07-13 15:49:11 +03:00
367b2c5317 Refactoring 2023-07-13 11:46:44 +03:00
4d0f156452 Fix build 2023-07-13 04:03:36 +05:00
f8ad0484e7 Remove test code 2023-07-13 01:02:07 +03:00
bf19d59626 Merge pull request #1230 from ONLYOFFICE/feature/osign_library
Feature/osign library
2023-07-13 00:08:42 +03:00
20ec85f92f Full version 2023-07-13 00:07:28 +03:00
c0d6375bb4 Fix merge bug 2023-07-12 22:46:06 +05:00
507b86f6a2 Add tests for osign library 2023-07-12 19:49:50 +03:00
6191c1798b Revert "Merge branch 'feature/xml_writer' of https://github.com/ONLYOFFICE/core into develop"
This reverts commit fe9284ebb2, reversing
changes made to 25ddb5d8d1.
2023-07-12 18:45:36 +03:00
fe9284ebb2 Merge branch 'feature/xml_writer' of https://github.com/ONLYOFFICE/core into develop 2023-07-12 18:43:24 +03:00
cae0e85363 Merge pull request #1229 from ONLYOFFICE/develop
Develop
2023-07-12 17:19:36 +03:00
25ddb5d8d1 Merge branch 'hotfix/v7.4.1' into develop 2023-07-12 17:16:26 +03:00
96208a1c54 Fix bug 59649 2023-07-12 16:33:42 +03:00
d47bd4a0ae Merge pull request #1227 from ONLYOFFICE/fix/v7.4.1-fix-bugs
for bug #63315
2023-07-12 07:43:01 -04:00
b626b23794 for bug #63315 2023-07-12 14:41:59 +03:00
841ff873a7 Merge pull request #1226 from ONLYOFFICE/fix/v7.4.1-fix-bugs
fix bug #61780
2023-07-12 03:57:47 -04:00
9614b81aa4 fix bug #61780 2023-07-12 10:55:51 +03:00
0e1a1ca586 Refactoring 2023-07-11 21:49:10 +03:00
f7cb1e0716 Add TestBuffer 2023-07-11 18:57:01 +03:00
e354b3b3d5 Fixed bugs 2023-07-11 17:37:34 +03:00
42bbf6a487 Merge pull request #1225 from ONLYOFFICE/fix/docbuilder
Fix bugs with builderJS object
2023-07-10 22:57:19 +03:00
4973b92435 Fix bugs with builderJS object 2023-07-10 22:55:44 +03:00
e99eb7cc81 Merge pull request #1224 from ONLYOFFICE/fix/v7.4.1-fix-bugs
fix bug #63315
2023-07-10 15:44:29 -04:00
4beedf8e03 fix bug #63315 2023-07-10 22:43:44 +03:00
49cdde75b3 Fixed bugs 2023-07-10 21:11:41 +03:00
22972aad5b . 2023-07-10 19:00:46 +03:00
822a488f0c . 2023-07-10 14:57:02 +03:00
1e86a93229 . 2023-07-10 14:45:49 +03:00
2e8820e81c xls/xlsb lib refactoring 2023-07-10 14:18:33 +03:00
410db159e4 Merge pull request #1219 from ONLYOFFICE/feature/externalEmbed3
Feature/external embed3
2023-07-09 17:09:04 +03:00
08f6b4c77e Remove unused files and move base to core-ext 2023-07-09 17:04:37 +05:00
0b31bc5dc9 Fix build 2023-07-08 18:28:39 +05:00
5d888e64b0 Merge pull request #1218 from ONLYOFFICE/develop
Develop
2023-07-08 13:40:58 +03:00
a55f4b91bc Fix typo 2023-07-08 11:52:01 +03:00
f6f9c522ed Fix typos 2023-07-08 13:50:30 +05:00
e111445699 Refactoring 2023-07-07 22:13:04 +05:00
3ca59f7775 Refacroring 2023-07-07 20:10:08 +03:00
daa80a1662 fix SaveToFile when not create CPdfFile 2023-07-07 17:35:41 +03:00
f8dc7e2197 Fix bug 63267
fix WriteEncodeXmlString for attribute, fix m_bInP & m_bInTable, implementation m_oDocXmlRels for external referenses
2023-07-07 17:33:54 +03:00
8b3fdbe50a Added support for the stroke-miterlimit argument 2023-07-07 11:40:33 +03:00
5ae7d4f5cb Add session interface for downoad/upload engine 2023-07-07 01:40:43 +03:00
e779cb0b4d Fix bug 49447
implementation html & epub footnote
2023-07-06 17:05:41 +03:00
60c8623980 Fixed bug 2023-07-06 16:35:06 +03:00
6ace3e2e80 Merge pull request #1217 from ONLYOFFICE/fix/v7.4.1-fix-bugs
fix bug #63282
2023-07-06 14:48:37 +03:00
1baf789bb5 fix bug #63282 2023-07-06 14:47:49 +03:00
b52e28294f implementation Fb2 footnote 2023-07-06 13:02:32 +03:00
7fb9fbd2ce . 2023-07-06 10:27:29 +03:00
55d09d1b45 Add allocator methods to export 2023-07-06 00:05:52 +03:00
2fac19bbb8 Add export for defaults 2023-07-05 22:16:39 +03:00
cc11daedda create readFootnotes 2023-07-05 17:53:34 +03:00
8c43dbc8b9 Refactoring 2023-07-05 16:54:10 +03:00
ef81980755 Fb2 update For bug 49447 2023-07-05 15:07:36 +03:00
1915846291 odf math 2023-07-05 11:47:14 +03:00
da3edc4ba5 Merge pull request #1216 from ONLYOFFICE/develop
Develop
2023-07-05 10:42:31 +03:00
44c58e9566 . 2023-07-04 16:39:10 +03:00
1e7d4586b3 Removed unused gradient-related methods 2023-07-04 13:50:59 +03:00
5318dc1238 Refactoring 2023-07-04 13:18:12 +03:00
927585ad86 Refactoring 2023-07-04 12:25:53 +03:00
77efe21913 To the previous commit 2023-07-04 10:58:42 +03:00
cf88f807cd Added restriction on plug-in files from CssCalculator 2023-07-04 10:56:03 +03:00
b6d108dd01 Fixed bugs 2023-07-04 10:54:11 +03:00
c239040756 Merge pull request #1215 from ONLYOFFICE/fix/bug60993
Fix bug 60993
2023-07-03 17:28:58 +03:00
45a2b682e4 Merge pull request #1214 from ONLYOFFICE/fix/refactoring
Refactoring XLS
2023-07-03 16:17:04 +03:00
421c1017c2 . 2023-07-03 16:12:46 +03:00
b89d16691a Fix bug 60993 2023-07-03 16:10:52 +03:00
2ed02ddfac Fix build on xp 2023-07-03 09:41:26 +03:00
488adeb4ea Fix previous commit 2023-07-03 01:47:55 +03:00
6173c39da9 Refactoring XLS 2023-07-03 01:42:43 +03:00
0a5f9070de Adds for previous commit 2023-07-02 14:17:38 +03:00
4306486c3c Refactoring 2023-07-02 13:39:49 +03:00
9788d38a69 Merge pull request #1207 from nightBulb/patch-1
Change github URL Cyrillic "es" to latin "C" in URL
2023-07-02 10:37:04 +03:00
9c7ce59ab8 Merge pull request #1212 from ONLYOFFICE/vboxtester
Vboxtester
2023-07-02 00:40:15 +03:00
e86cde33c2 Remove extra flags 2023-07-02 00:38:59 +03:00
50e0538f06 Developing 2023-07-01 00:39:13 +03:00
a3fd4e26c2 fix bug #63197 2023-06-30 13:41:45 +03:00
e78eff38ef . 2023-06-30 12:58:11 +03:00
88a3128b87 Added display:none support and refactoring 2023-06-30 11:27:51 +03:00
17b632844a Fixed bugs 2023-06-30 10:51:38 +03:00
571a6f897b Developing 2023-06-29 23:14:25 +03:00
bf6d4b00e3 Merge pull request #1211 from ONLYOFFICE/fix/bug61780
move For bug 61780
2023-06-29 13:28:13 +03:00
4a452ee47f move For bug 61780 2023-06-29 13:27:27 +03:00
d1d35b5ccb minor 2023-06-29 07:22:56 +03:00
c75527ed3b wait network loading
test
2023-06-29 06:20:24 +03:00
8e61cd7f70 . 2023-06-28 18:48:58 +03:00
cbe7f93387 verbose log option 2023-06-28 18:47:36 +03:00
3a46d8a909 Merge pull request #1210 from ONLYOFFICE/fix/pre7.4.1
Fix/pre7.4.1
2023-06-28 14:18:27 +03:00
0fb4c8f13a Fixed bugs 2023-06-28 14:02:49 +03:00
d651d5166b Update copyright 2023-06-27 15:36:16 +03:00
bc3dfa5b3f Added the ability to install an external alpha mask 2023-06-26 20:20:53 +03:00
7af5e05ea0 Refactoring the alpha mask 2023-06-26 18:35:50 +03:00
84d19cdbe4 new features
- using custom setup scripts
- run VMs using list
2023-06-26 17:45:48 +03:00
699acd0516 Fix bug 60851 2023-06-26 15:11:05 +03:00
5e9e15be57 Refactoring verify signatures 2023-06-25 13:13:36 +03:00
43f1d76032 testing using simple config 2023-06-23 19:30:09 +03:00
Sky
2eec32df98 Change URL Cyrillic "es" to latin "C" in URL
Fix URL to github code repository,
the "code" in URL used Cyrillic "es" i.e. %d1 %81,
whereas url  https://github.com/ONLYOFFICE/core
uses latin "c"
2023-06-23 16:43:36 +05:30
d676270cac Refactoring 2023-06-22 16:49:56 +03:00
df8092017c Astra (CE, Orel), Kubuntu added 2023-06-22 12:26:21 +03:00
12dbc4aeb4 Manjaro(mandriva) added 2023-06-21 17:41:20 +03:00
5446ebc58a debian added
fix installation on openSUSE
2023-06-21 12:40:34 +03:00
77ea7fd3df Fix use private sources in export header 2023-06-21 11:58:42 +03:00
cb40323b31 Fix parse Argument param 2023-06-21 11:57:54 +03:00
5f1fbdce31 minor 2023-06-21 11:42:41 +03:00
22f5da518d openSUSE added 2023-06-21 11:40:53 +03:00
6811fc9877 openSUSE, debian 2023-06-21 09:51:30 +03:00
ccfb56fc2e Added support for Symbol record to svg 2023-06-19 20:05:54 +03:00
540e89d7a0 Added alpha channel mode for alpha mask 2023-06-19 11:43:50 +03:00
7517621bf4 Added mutex to CAllowedCreationScope 2023-06-14 16:46:28 +04:00
bec99465a9 Added a test example with the use of a mask on the alpha channel 2023-06-14 14:23:08 +03:00
03da8bc41a [JSC] Refactoring
+ Renamed methods in CGraphicsEmbed and CNativeControlEmbed
+ Generated new embed files
+ Added check for allowed embed creation
2023-06-14 15:14:03 +04:00
0c48bd4cc2 Refactoring for JSC 2023-06-14 14:29:45 +04:00
1450093760 Raw pointers from functions -> JSSmart 2023-06-14 14:15:41 +04:00
c7964fd079 Refactoring 2023-06-14 00:51:51 +03:00
87c986a71d Change embed mode for native JS builders 2023-06-13 20:17:47 +04:00
d6292219d2 Singleton rework.
Added `CAllowedCreationScope`.
2023-06-13 14:06:18 +04:00
f4661150c6 Added alpha mask support reset and selection of draw mode 2023-06-13 10:32:36 +03:00
d1e87e342f NativeBuilderEmbed refactoring
+ PointerEmbed extra files added
+ Fix for generator when ifdef blocks are empty
+ Added CJSContext::createEmbedObject()
2023-06-12 23:16:46 +04:00
442756f964 Added alpha-mask support in graphics and svg-reader 2023-06-12 15:43:14 +03:00
dda3d75bcf Fix for multiple-lined methods 2023-06-12 00:23:24 +04:00
39cbad3ebf Added #ifdef and [noexport] support for code generation. Replaced most of internal classes.
Removed unnecessary V8 code.
2023-06-11 23:30:40 +04:00
6590643894 Refactoring 2023-06-10 13:57:33 +03:00
0d77b62c2d Documentation finished 2023-06-08 17:07:49 +04:00
a867a168e0 [V8] Singleton embed creation rework 2023-06-07 19:28:30 +04:00
af0836e379 Added some more description to documentation. 2023-06-07 13:30:05 +04:00
37e03d6bcc Wrote some documentation for classes in js_base.h. 2023-06-06 17:26:28 +04:00
65d5b5c628 Revision of the test example 2023-06-06 09:52:38 +03:00
859e96a3ab Added alpha mask test 2023-06-04 22:13:20 +03:00
bc18191931 [V8] Added new adapter generation 2023-06-02 17:53:25 +04:00
11d91891a8 [V8] New adapter for external embed. js_base.h celaned up. 2023-06-02 17:31:01 +04:00
a29605e1b7 Added adapter code generation to scipt 2023-06-01 17:03:57 +04:00
f40b6f849d [JSC] Implemented adapter. Removed Native2Value and Value2Native from js_base.h 2023-06-01 16:27:16 +04:00
375b5a5f4f [V8] added an option for removing void* functions from js_base.h 2023-06-01 15:28:19 +04:00
8d945ba094 Moved CJSContext::AddEmbedCreator() definition to js_base.cpp 2023-05-29 23:51:12 +04:00
3ad595817e Refactoring: removed CreateContext, removed RegistratorPool, made Embed static function 2023-05-29 21:23:23 +04:00
ae26678a53 Implemented RegistratorPool for JSC 2023-05-28 19:11:50 +04:00
428d92e654 Added RegistratorPool for embedding in multiple contexts simultaneously 2023-05-28 18:42:39 +04:00
21ee5ceecf Implemented code generation for internal embed 2023-05-27 18:19:57 +04:00
7554d92ed9 Removed dependency from current directory when running script 2023-05-26 21:48:45 +04:00
36dd828a73 Refactoring for external embed 2023-05-26 21:30:56 +04:00
17976500bc Added option for internal embed in JSC 2023-05-26 20:05:09 +04:00
e4895fe035 Added option for internal embed in V8 2023-05-26 19:12:50 +04:00
59dcc3eb5c Added an option for compiling with v8_Embed.cpp but it's just terrifying 2023-05-25 20:32:03 +04:00
73ae7ceef9 Trying to understand template for generation of V8 embed file 2023-05-25 18:31:50 +04:00
c703722372 Improved work with embedded images in svg-reader 2023-05-24 11:19:13 +03:00
4a4a05fd8a Added partial support for record Mask in svg-reader 2023-05-23 22:23:00 +03:00
099f3f5632 Refactoring 2023-05-22 20:26:19 +03:00
a18bae045a Added generation of jsc_ files. Refactoring for js_base_embed.pri usage. 2023-05-22 20:38:06 +04:00
2386c8e1a9 Revert some files 2023-05-22 13:55:43 +03:00
96662a2382 Adding flag support for marker and refactoring in svg-reader 2023-05-22 13:52:58 +03:00
05e6f2a4fe Refactoring 2023-05-21 14:27:58 +05:00
cbed11f00b Added rgba support and refactoring in svg-reader 2023-05-20 18:21:10 +03:00
ab9fe80669 Finally made to work embedding in JSC 2023-05-20 18:13:28 +04:00
332fb3e318 Add working method of manually embeding FunctionGet into JSC 2023-05-20 15:41:56 +04:00
a10849ada1 jsc_Embed.mm protocol methods need to be implemented at runtime? 2023-05-19 22:21:58 +04:00
4accc90216 Trying to make it build with generated jsc_Embed.mm 2023-05-18 21:47:06 +04:00
439f52be3d Writed code generation inside of an embedded class [V8] 2023-05-17 17:49:48 +04:00
7d6b82554b Added viewBox support for markers in svg-reader 2023-05-16 15:34:01 +03:00
1c894b7896 Line, polyline, and polygon records are remade as heirs of path 2023-05-15 19:28:59 +03:00
7ddc3234a7 Added Marker record support for Paths in svg-reader and refactoring 2023-05-12 17:19:03 +03:00
7e16297d33 Changing how the use record works in svg-reader and refactoring 2023-05-10 20:48:50 +03:00
1833bb1333 Trying to export some class dynamically to JSC. It still seems not possible. 2023-05-10 18:44:05 +04:00
5be6b6ebe5 Embed for jsc. It doesn't works for now. 2023-05-04 20:14:43 +04:00
bc7eab7f1d Fixed problems with working with styles 2023-05-03 19:06:39 +03:00
28bc145659 CZipEmbed test minor fix 2023-05-03 19:47:53 +04:00
115a68eb09 some refactofing 2023-05-03 19:40:39 +04:00
ab291fa199 . 2023-05-03 17:47:31 +03:00
f0feaf5e1b Test version 2023-05-03 01:20:13 +03:00
1fb1c37bf9 Removed switch from Call() function 2023-05-02 21:10:52 +04:00
afc6a72b14 Add variant for external objects 2023-05-01 00:25:24 +03:00
15fdb5a8ce Refactoring and fix 2023-04-28 18:02:01 +03:00
52e52ee720 Fix 2023-04-26 17:35:01 +03:00
0343d7989d Added transparency support in stroke and fill in svg-reader 2023-04-26 16:52:10 +03:00
2e9de3748b Added implementation of arc splitting into Bezier curves and their rotation by a given angle in svg-reader 2023-04-19 12:53:04 +03:00
a4b6d57786 Changed the principle of working with arcs in svg-reader 2023-04-17 19:56:33 +03:00
abcfc66a41 Improved arc calculations in svg-reader 2023-03-29 20:16:26 +03:00
fdbc72e1b4 Working with text in svg-reader 2023-03-27 19:58:06 +03:00
77ef5ead99 Fixed bugs with texts records in svg-reader 2023-03-24 13:44:02 +03:00
c7a5f5bdb2 Fixed bugs with clip-path in svg-reader 2023-03-23 19:57:19 +03:00
9e246ae8ba Fixed bugs in rendering svg textPath record 2023-03-23 19:01:05 +03:00
dcea017b51 Added character rendering on textPath in svg 2023-03-22 21:58:47 +03:00
2a3d138459 Updated calculations of control points for working with textPath in svg reader 2023-03-21 16:07:38 +03:00
92a8bd2ed5 Added calculation of the position of points on a curve in svg-reader 2023-03-20 19:44:00 +03:00
ecec9e2e39 Start of work on textPath record, fixing bugs and refactoring in svg reader 2023-03-16 18:37:20 +03:00
e18ed76b48 Refactoring and working with paths in svg reader 2023-03-15 16:25:52 +03:00
d4dee32fe7 Work with transforms and normalization text size in svg reader 2023-03-14 13:31:46 +03:00
d5b46f74fc Fixed bugs with the position of rotated objects and others in reading svg 2023-03-13 16:22:22 +03:00
d2db5abe89 Working with text in svg and refactoring 2023-02-27 18:59:17 +03:00
db7297f5c1 Svg has added support for the use entry and improved work with the line style 2023-02-22 14:26:11 +03:00
7de16d2d49 Fix bug 2023-02-21 17:01:22 +03:00
ad1dc1ebf9 Added support for writing stroke-dasharray to svg 2023-02-21 16:52:34 +03:00
fc3e54c485 Added support for recording clip-path in svg and refactoring 2023-02-21 16:44:00 +03:00
bad7cc3c86 Refactoring 2023-02-21 11:16:46 +03:00
ea7030d58e Added svg file scanning for defs and styles 2023-02-20 14:12:43 +03:00
dded7e69ef Working on the gradient in svg and refactoring 2023-02-17 18:07:33 +03:00
bacec90b2e Fixed a bug in rendering roundrect in svg 2023-02-16 19:08:28 +03:00
cfe6264404 Started working with gradients in svg and refactoring 2023-02-16 17:04:56 +03:00
478e3e9dc3 Changed the principle of working with Patterns in Svg 2023-02-16 13:39:32 +03:00
2f5035d0e3 Fix bugы 2023-02-14 14:13:08 +03:00
5633b92d19 Added support for text-decoration in svg text 2023-02-14 14:12:23 +03:00
b2f2017158 Added support for multiple values in svg transform 2023-02-14 14:11:47 +03:00
0ed1fa08e1 Working with svg text styles 2023-02-13 19:58:41 +03:00
76b90d43a4 Added support for Pattern record 2023-02-13 15:06:57 +03:00
f89f66df45 Added partial support for Image records 2023-02-10 17:22:22 +03:00
68922675b5 Improved work with Transform property and refactoring 2023-02-09 16:44:50 +03:00
dc0c6c369c Added support for Transform properties in svg reader 2023-02-08 19:21:06 +03:00
0661c9b552 Changed working with svg records data and refactoring 2023-02-07 18:42:34 +03:00
c18251dcfd Refactoring is finished 2023-02-03 18:12:32 +03:00
f86ef63f58 Continuing refactoring 2023-02-02 14:51:42 +03:00
2b29420eb1 Continuing refactoring 2023-01-31 19:44:21 +03:00
085940c37b The beginning of refactoring 2023-01-30 19:08:55 +03:00
891dab4016 Refactoring and working styles in SVG 2023-01-12 19:34:29 +03:00
2e2bdcdbf1 Working with SVG styles and transformation 2023-01-09 13:30:39 +03:00
ec0b85511b Added support for Polyline and polygon records 2023-01-05 12:37:33 +03:00
62710bb443 Working with SVG styles 2022-12-27 21:15:36 +03:00
5d666a0d10 Working with SVG styles 2022-12-26 19:28:37 +03:00
4f97c72212 Started working with svg styles 2022-12-22 16:14:11 +03:00
dadd3987f0 Added a draft version of working with text 2022-12-19 18:51:27 +03:00
1e8d0d62b2 Added support for ellipses and working with the path 2022-12-19 14:42:47 +03:00
417aab6cee Added path implementation in svg 2022-12-13 17:40:37 +03:00
35dc17e584 The creation of a new svg-reader has begun 2022-12-13 11:27:17 +03:00
1ed96f295a Fix unzip without path 2022-12-11 18:36:02 +03:00
b3e95df084 Fix pro file 2022-12-11 18:21:23 +03:00
2942452a61 unzip fix + add tests 2022-12-11 18:00:14 +03:00
2212c3b26f Fix chdir 2022-12-05 03:28:21 +03:00
753 changed files with 45125 additions and 38055 deletions

View File

@ -3,7 +3,28 @@ DEPENDPATH += $$PWD
CORE_ROOT_DIR = $$PWD/../../../..
HEADERS += $$files($$PWD/src/*.h, true)
SOURCES += $$files($$PWD/src/*.cpp, true)
css_calculator_without_xhtml {
HEADERS += \
$$PWD/src/CCssCalculator_Private.h \
$$PWD/src/CElement.h \
$$PWD/src/CNode.h \
$$PWD/src/ConstValues.h \
$$PWD/src/StaticFunctions.h \
$$PWD/src/StyleProperties.h \
$$PWD/src/CUnitMeasureConverter.h
SOURCES += \
$$PWD/src/CCssCalculator_Private.cpp \
$$PWD/src/CElement.cpp \
$$PWD/src/CNode.cpp \
$$PWD/src/ConstValues.cpp \
$$PWD/src/StaticFunctions.cpp \
$$PWD/src/StyleProperties.cpp \
$$PWD/src/CUnitMeasureConverter.cpp
} else {
HEADERS += $$files($$PWD/src/*.h, true)
SOURCES += $$files($$PWD/src/*.cpp, true)
DEFINES += CSS_CALCULATOR_WITH_XHTML
}
include($$CORE_ROOT_DIR/Common/3dParty/html/katana.pri)

File diff suppressed because it is too large Load Diff

View File

@ -9,105 +9,60 @@
#include <vector>
#include <string>
#include "StyleProperties.h"
namespace NSCSS
{
class CSSCALCULATOR_EXPORT CCompiledStyle
{
std::set<std::wstring> m_arParentsStyles;
std::wstring m_sId;
class CCompiledStyle
{
friend class CStyle;
std::set<std::wstring> m_arParentsStyles;
std::wstring m_sId;
unsigned short int m_nDpi;
UnitMeasure m_UnitMeasure;
unsigned short int m_nDpi;
UnitMeasure m_UnitMeasure;
CSizeWindow m_oSourceWindow;
CSizeWindow m_oDeviceWindow;
CSizeWindow m_oSourceWindow;
CSizeWindow m_oDeviceWindow;
std::wstring ConvertUnitMeasure(const std::wstring& sValue, const float& fPreviousValue, ScalingDirection enScalingDirection = ScalingDirectionNone) const;
public:
NSProperties::CFont m_oFont;
NSProperties::CIndent m_oMargin;
NSProperties::CIndent m_oPadding;
NSProperties::CBackground m_oBackground;
NSProperties::CText m_oText;
NSProperties::CBorder m_oBorder;
NSProperties::CDisplay m_oDisplay;
void Scale(int &nValue, ScalingDirection enScalingDirection) const;
CCompiledStyle();
CCompiledStyle(const CCompiledStyle& oStyle);
int ConvertPx(const std::wstring& sValue) const;
int ConvertPxToCm(const float& dValue) const;
int ConvertPxToIn(const float& dValue) const;
int ConvertPxToMm(const float& dValue) const;
int ConvertPxToPt(const float& dValue) const;
int ConvertPxToPc(const float& dValue) const;
~CCompiledStyle();
int ConvertCm(const std::wstring& sValue) const;
int ConvertCmToPx(const float& dValue) const;
int ConvertCmToIn(const float& dValue) const;
int ConvertCmToMm(const float& dValue) const;
int ConvertCmToPt(const float& dValue) const;
int ConvertCmToPc(const float& dValue) const;
void SetDpi(const unsigned short& uiDpi);
void SetUnitMeasure(const UnitMeasure& enUnitMeasure);
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
int ConvertMm(const std::wstring& sValue) const;
int ConvertMmToPx(const float& dValue) const;
int ConvertMmToIn(const float& dValue) const;
int ConvertMmToCm(const float& dValue) const;
int ConvertMmToPt(const float& dValue) const;
int ConvertMmToPc(const float& dValue) const;
bool Empty() const;
int ConvertIn(const std::wstring& sValue) const;
int ConvertInToPx(const float& dValue) const;
int ConvertInToMm(const float& dValue) const;
int ConvertInToCm(const float& dValue) const;
int ConvertInToPt(const float& dValue) const;
int ConvertInToPc(const float& dValue) const;
void AddPropSel(const std::wstring& sProperty, const std::wstring& sValue, const unsigned int unLevel, const bool& bHardMode = true);
void AddStyle(const std::map<std::wstring, std::wstring>& mStyle, const unsigned int unLevel, const bool& bHardMode = true);
void AddStyle(const std::wstring& sStyle, const unsigned int unLevel, const bool& bHardMode = false);
virtual void AddOtherStyle(const std::pair<std::wstring, std::wstring>& oStyle, const unsigned int unLevel, const bool& bHardMode = true) {};
void AddParent(const std::wstring& sParentName);
int ConvertPt(const std::wstring& sValue) const;
int ConvertPtToPx(const float& dValue) const;
int ConvertPtToMm(const float& dValue) const;
int ConvertPtToCm(const float& dValue) const;
int ConvertPtToIn(const float& dValue) const;
int ConvertPtToPc(const float& dValue) const;
std::vector<std::wstring> GetParentsName() const;
int ConvertPc(const std::wstring& sValue) const;
int ConvertPcToPx(const float& dValue) const;
int ConvertPcToMm(const float& dValue) const;
int ConvertPcToCm(const float& dValue) const;
int ConvertPcToIn(const float& dValue) const;
int ConvertPcToPt(const float& dValue) const;
void SetID(const std::wstring& sId);
std::wstring GetId() const;
public:
CCompiledStyle& operator+= (const CCompiledStyle& oElement);
CCompiledStyle& operator= (const CCompiledStyle& oElement);
bool operator== (const CCompiledStyle& oElement) const;
NSConstValues::NSCssProperties::Font m_pFont;
NSConstValues::NSCssProperties::Margin m_pMargin;
NSConstValues::NSCssProperties::Background m_pBackground;
NSConstValues::NSCssProperties::Text m_pText;
NSConstValues::NSCssProperties::Border m_pBorder;
NSConstValues::NSCssProperties::Display m_pDisplay;
CCompiledStyle();
explicit CCompiledStyle(const std::map<std::wstring, std::wstring>& mStyle);
CCompiledStyle(const CCompiledStyle& oStyle);
~CCompiledStyle();
void SetDpi(const unsigned short& uiDpi);
void SetUnitMeasure(const UnitMeasure& enUnitMeasure);
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
bool Empty() const;
void AddPropSel(const std::wstring& sProperty, const std::wstring& sValue, const unsigned int unLevel, const bool& bHardMode = true);
void AddStyle(const std::map<std::wstring, std::wstring>& mStyle, const unsigned int unLevel, const bool& bHardMode = true);
void AddStyle(const std::wstring& sStyle, const unsigned int unLevel, const bool& bHardMode = false);
void AddParent(const std::wstring& sParentName);
std::vector<std::wstring> GetParentsName() const;
void SetID(const std::wstring& sId);
std::wstring GetId() const;
void ClearImportants();
CCompiledStyle& operator+= (const CCompiledStyle& oElement);
CCompiledStyle& operator= (const CCompiledStyle& oElement);
bool operator== (const CCompiledStyle& oElement) const;
static void StyleEquation(CCompiledStyle& oFirstStyle, CCompiledStyle& oSecondStyle);
};
static void StyleEquation(CCompiledStyle& oFirstStyle, CCompiledStyle& oSecondStyle);
};
}
#endif // CCOMPILEDSTYLE_H

View File

@ -4,88 +4,93 @@
namespace NSCSS
{
CCssCalculator::CCssCalculator()
{
m_pInternal = new CCssCalculator_Private();
}
CCssCalculator::CCssCalculator()
{
m_pInternal = new CCssCalculator_Private();
}
CCssCalculator::~CCssCalculator()
{
delete m_pInternal;
}
CCssCalculator::~CCssCalculator()
{
delete m_pInternal;
}
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure) const
{
return m_pInternal->GetCompiledStyle(arSelectors, bIsSettings, unitMeasure);
}
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure) const
{
return m_pInternal->GetCompiledStyle(arSelectors, bIsSettings, unitMeasure);
}
void CCssCalculator::AddStyles(const std::string &sStyle)
{
m_pInternal->AddStyles(sStyle);
}
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure) const
{
return m_pInternal->GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
}
void CCssCalculator::AddStyles(const std::wstring &sStyle)
{
m_pInternal->AddStyles(sStyle);
}
void CCssCalculator::AddStyles(const std::string &sStyle)
{
m_pInternal->AddStyles(sStyle);
}
void CCssCalculator::AddStylesFromFile(const std::wstring &sFileName)
{
m_pInternal->AddStylesFromFile(sFileName);
}
void CCssCalculator::AddStyles(const std::wstring &wsStyle)
{
m_pInternal->AddStyles(wsStyle);
}
void CCssCalculator::SetUnitMeasure(const UnitMeasure& nType)
{
m_pInternal->SetUnitMeasure(nType);
}
void CCssCalculator::AddStylesFromFile(const std::wstring &wsFileName)
{
m_pInternal->AddStylesFromFile(wsFileName);
}
void CCssCalculator::SetDpi(const unsigned short int& nValue)
{
m_pInternal->SetDpi(nValue);
}
void CCssCalculator::SetUnitMeasure(const UnitMeasure& nType)
{
m_pInternal->SetUnitMeasure(nType);
}
void CCssCalculator::SetBodyTree(const CTree &oTree)
{
m_pInternal->SetBodyTree(oTree);
}
void CCssCalculator::SetDpi(const unsigned short int& nValue)
{
m_pInternal->SetDpi(nValue);
}
void CCssCalculator::SetSizeSourceWindow(const CSizeWindow &oSizeWindow)
{
m_pInternal->SetSizeSourceWindow(oSizeWindow);
}
void CCssCalculator::SetBodyTree(const CTree &oTree)
{
m_pInternal->SetBodyTree(oTree);
}
void CCssCalculator::SetSizeDeviceWindow(const CSizeWindow &oSizeWindow)
{
m_pInternal->SetSizeDeviceWindow(oSizeWindow);
}
void CCssCalculator::SetSizeSourceWindow(const CSizeWindow &oSizeWindow)
{
m_pInternal->SetSizeSourceWindow(oSizeWindow);
}
CSizeWindow CCssCalculator::GetSizeSourceWindow() const
{
return m_pInternal->GetSizeSourceWindow();
}
void CCssCalculator::SetSizeDeviceWindow(const CSizeWindow &oSizeWindow)
{
m_pInternal->SetSizeDeviceWindow(oSizeWindow);
}
CSizeWindow CCssCalculator::GetSizeDeviceWindow() const
{
return m_pInternal->GetSizeDeviceWindow();
}
CSizeWindow CCssCalculator::GetSizeSourceWindow() const
{
return m_pInternal->GetSizeSourceWindow();
}
UnitMeasure CCssCalculator::GetUnitMeasure() const
{
return m_pInternal->GetUnitMeasure();
}
CSizeWindow CCssCalculator::GetSizeDeviceWindow() const
{
return m_pInternal->GetSizeDeviceWindow();
}
std::wstring CCssCalculator::GetEncoding() const
{
return m_pInternal->GetEncoding();
}
UnitMeasure CCssCalculator::GetUnitMeasure() const
{
return m_pInternal->GetUnitMeasure();
}
unsigned short int CCssCalculator::GetDpi() const
{
return m_pInternal->GetDpi();
}
std::wstring CCssCalculator::GetEncoding() const
{
return m_pInternal->GetEncoding();
}
void CCssCalculator::Clear()
{
m_pInternal->Clear();
}
unsigned short int CCssCalculator::GetDpi() const
{
return m_pInternal->GetDpi();
}
void CCssCalculator::Clear()
{
m_pInternal->Clear();
}
}

View File

@ -10,38 +10,39 @@
namespace NSCSS
{
class CCssCalculator_Private;
class CSSCALCULATOR_EXPORT CCssCalculator
{
protected:
CCssCalculator_Private* m_pInternal;
public:
CCssCalculator();
~CCssCalculator();
class CCssCalculator_Private;
class CSSCALCULATOR_EXPORT CCssCalculator
{
protected:
CCssCalculator_Private* m_pInternal;
public:
CCssCalculator();
~CCssCalculator();
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Default) const;
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;
// void AddStyle(const std::vector<std::string>& sSelectors, const std::string& sStyle);
void AddStyles (const std::string& sStyle);
void AddStyles (const std::wstring& sStyle);
void AddStylesFromFile(const std::wstring& sFileName);
// void AddStyle(const std::vector<std::string>& sSelectors, const std::string& sStyle);
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(const unsigned short int& nValue);
void SetBodyTree(const CTree &oTree);
void SetUnitMeasure(const UnitMeasure& nType);
void SetDpi(const unsigned short int& nValue);
void SetBodyTree(const CTree &oTree);
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
CSizeWindow GetSizeSourceWindow() const;
CSizeWindow GetSizeDeviceWindow() const;
CSizeWindow GetSizeSourceWindow() const;
CSizeWindow GetSizeDeviceWindow() const;
UnitMeasure GetUnitMeasure() const;
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;
UnitMeasure GetUnitMeasure() const;
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;
void Clear();
};
void Clear();
};
}
#endif // CCSSCALCULATOR_H

File diff suppressed because it is too large Load Diff

View File

@ -3,74 +3,86 @@
#include <vector>
#include <map>
#include "CCssCalculator.h"
#include <list>
#include <functional>
#include "CElement.h"
#include "ConstValues.h"
#include "CUnitMeasureConverter.h"
#include "../../katana-parser/src/katana.h"
#ifdef CSS_CALCULATOR_WITH_XHTML
#include "CCompiledStyle.h"
#endif
namespace NSCSS
{
class CCssCalculator_Private
{
unsigned short int m_nDpi;
unsigned short int m_nCountNodes;
UnitMeasure m_UnitMeasure;
class CCssCalculator_Private
{
unsigned short int m_nDpi;
unsigned short int m_nCountNodes;
UnitMeasure m_UnitMeasure;
std::list<std::wstring> m_arFiles;
std::list<std::wstring> m_arFiles;
std::map<std::wstring, CElement*> m_mData;
std::map<std::wstring, CElement*> m_mData;
std::map<StatistickElement, unsigned int> *m_mStatictics; // Количество повторений свойств id и style у селекторов
std::map<StatistickElement, unsigned int> *m_mStatictics; // Количество повторений свойств id и style у селекторов
std::map<std::vector<CNode>, CCompiledStyle*> m_mUsedStyles;
#ifdef CSS_CALCULATOR_WITH_XHTML
std::map<std::vector<CNode>, CCompiledStyle*> m_mUsedStyles;
#endif
std::wstring m_sEncoding;
std::wstring m_sEncoding;
CSizeWindow m_oSourceWindow;
CSizeWindow m_oDeviceWindow;
CSizeWindow m_oSourceWindow;
CSizeWindow m_oDeviceWindow;
void GetStylesheet(const KatanaStylesheet* oStylesheet);
void GetRule(const KatanaRule* oRule);
void GetStylesheet(const KatanaStylesheet* oStylesheet);
void GetRule(const KatanaRule* oRule);
void GetStyleRule(const KatanaStyleRule* oRule);
void GetStyleRule(const KatanaStyleRule* oRule);
std::wstring GetValueList(const KatanaArray* oValues);
std::wstring GetValueList(const KatanaArray* oValues);
std::vector<std::wstring> GetSelectorList(const KatanaArray* oSelectors) const;
std::wstring GetSelector(const KatanaSelector* oSelector) const;
std::vector<std::wstring> GetSelectorList(const KatanaArray* oSelectors) const;
std::wstring GetSelector(const KatanaSelector* oSelector) const;
std::map<std::wstring, std::wstring> GetDeclarationList(const KatanaArray* oDeclarations) const;
std::pair<std::wstring, std::wstring> GetDeclaration(const KatanaDeclaration* oDecl) const;
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);
public:
CCssCalculator_Private();
~CCssCalculator_Private();
public:
CCssCalculator_Private();
~CCssCalculator_Private();
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Default);
#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);
#endif
void AddStyles(const std::string& sStyle);
void AddStyles(const std::wstring& sStyle);
void AddStylesFromFile(const std::wstring& sFileName);
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);
void SetUnitMeasure(const UnitMeasure& nType);
void SetDpi(unsigned short int nValue);
void SetBodyTree(const CTree &oTree);
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
CSizeWindow GetSizeSourceWindow() const;
CSizeWindow GetSizeDeviceWindow() const;
CSizeWindow GetSizeSourceWindow() const;
CSizeWindow GetSizeDeviceWindow() const;
UnitMeasure GetUnitMeasure() const;
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;
UnitMeasure GetUnitMeasure() const;
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;
void Clear();
const std::map<std::wstring, CElement*>* GetData() const;
};
void Clear();
};
}
#endif // CCSSCALCULATOR_PRIVATE_H

View File

@ -6,275 +6,245 @@
namespace NSCSS
{
CElement::CElement()
{
}
CElement::~CElement()
{
for (CElement* oElement : m_arPrevElements)
if (oElement != NULL)
delete oElement;
else
continue;
CElement::CElement()
{
}
CElement::~CElement()
{
for (CElement* oElement : m_arPrevElements)
if (oElement != NULL)
delete oElement;
else
continue;
m_mStyle.clear();
m_mStyle.clear();
}
}
std::wstring CElement::GetSelector() const
{
return m_sSelector;
}
std::wstring CElement::GetSelector() const
{
return m_sSelector;
}
std::wstring CElement::GetFullSelector() const
{
return m_sFullSelector;
}
std::wstring CElement::GetFullSelector() const
{
return m_sFullSelector;
}
bool CElement::Empty() const
{
return m_mStyle.empty();
}
bool CElement::Empty() const
{
return m_mStyle.empty();
}
void CElement::SetSelector(const std::wstring &sSelector)
{
m_sSelector = sSelector;
m_sFullSelector = m_sSelector;
}
void CElement::SetSelector(const std::wstring &sSelector)
{
m_sSelector = sSelector;
m_sFullSelector = m_sSelector;
}
void NSCSS::CElement::AddPropertie(const std::wstring &sName, const std::wstring& sValue)
{
m_mStyle[sName] = sValue;
}
void NSCSS::CElement::AddPropertie(const std::wstring &sName, const std::wstring& sValue)
{
m_mStyle[sName] = sValue;
}
void CElement::AddProperties(const std::map<std::wstring, std::wstring>& mProperties)
{
for (std::pair<std::wstring, std::wstring> pPropertie : mProperties)
{
std::transform(pPropertie.first.begin(), pPropertie.first.end(), pPropertie.first.begin(), tolower);
std::transform(pPropertie.second.begin(), pPropertie.second.end(), pPropertie.second.begin(), tolower);
void CElement::AddProperties(const std::map<std::wstring, std::wstring>& mProperties)
{
for (std::pair<std::wstring, std::wstring> pPropertie : mProperties)
{
std::transform(pPropertie.first.begin(), pPropertie.first.end(), pPropertie.first.begin(), tolower);
if (!m_mStyle[pPropertie.first].empty() && m_mStyle[pPropertie.first].find(L'!') != std::wstring::npos)
continue;
if (!m_mStyle[pPropertie.first].empty() && m_mStyle[pPropertie.first].find(L'!') != std::wstring::npos)
continue;
if (pPropertie.second.substr(0, 3) == L"rgb")
m_mStyle[pPropertie.first] = NSCSS::NS_STATIC_FUNCTIONS::ConvertRgbToHex(pPropertie.second);
else
m_mStyle[pPropertie.first] = pPropertie.second;
}
}
m_mStyle[pPropertie.first] = pPropertie.second;
}
}
void CElement::AddPrevElement(CElement *oPrevElement)
{
if (NULL == oPrevElement)
return;
void CElement::AddPrevElement(CElement *oPrevElement)
{
if (NULL == oPrevElement)
return;
m_arPrevElements.push_back(oPrevElement);
oPrevElement->m_sFullSelector += L' ' + m_sFullSelector;
}
m_arPrevElements.push_back(oPrevElement);
oPrevElement->m_sFullSelector += L' ' + m_sFullSelector;
}
void CElement::AddKinElement(CElement *oKinElement)
{
if (NULL == oKinElement)
return;
void CElement::AddKinElement(CElement *oKinElement)
{
if (NULL == oKinElement)
return;
m_arKinElements.push_back(oKinElement);
oKinElement->m_sFullSelector += m_sFullSelector;
}
m_arKinElements.push_back(oKinElement);
oKinElement->m_sFullSelector += m_sFullSelector;
}
std::map<std::wstring, std::wstring> CElement::GetStyle() const
{
return m_mStyle;
}
std::map<std::wstring, std::wstring> CElement::GetStyle() const
{
return m_mStyle;
}
std::map<std::wstring, std::wstring> CElement::GetFullStyle(const std::vector<CNode>& arSelectors) const
{
if (arSelectors.empty())
return std::map<std::wstring, std::wstring>();
std::map<std::wstring, std::wstring> CElement::GetFullStyle(const std::vector<CNode>& arSelectors) const
{
if (arSelectors.empty())
return std::map<std::wstring, std::wstring>();
std::map<std::wstring, std::wstring> mStyle(m_mStyle);
std::map<std::wstring, std::wstring> mStyle(m_mStyle);
// Print();
// std::wcout << L"++++++++++++++++++++++++++++++++++++++++" << std::endl;
for (const CElement* oElement : m_arPrevElements)
{
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode)
{
std::map<std::wstring, std::wstring> mTempStyle;
if (oElement->GetSelector() == L'.' + oNode->m_sClass ||
oElement->GetSelector() == oNode->m_sName)
{
for (const std::pair<std::wstring, std::wstring> pPropertie : oElement->GetFullStyle(arSelectors))
mStyle[pPropertie.first] = pPropertie.second;
for (const CElement* oElement : m_arPrevElements)
{
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode)
{
std::map<std::wstring, std::wstring> mTempStyle;
if (oElement->GetSelector() == L'.' + oNode->m_wsClass ||
oElement->GetSelector() == oNode->m_wsName)
{
for (const std::pair<std::wstring, std::wstring> pPropertie : oElement->GetFullStyle(arSelectors))
mStyle[pPropertie.first] = pPropertie.second;
// const std::map<std::wstring, std::wstring> mTempStyle = oElement->GetFullStyle(arSelectors);
// mStyle.insert(mTempStyle.begin(), mTempStyle.end());
}
}
}
}
}
}
return mStyle;
}
return mStyle;
}
std::map<std::wstring, std::wstring> CElement::GetFullStyle(const std::vector<std::wstring> &arNodes) const
{
if (arNodes.empty() || (m_mStyle.empty() && m_arPrevElements.empty()))
return std::map<std::wstring, std::wstring>();
std::map<std::wstring, std::wstring> CElement::GetFullStyle(const std::vector<std::wstring> &arNodes) const
{
if (arNodes.empty() || (m_mStyle.empty() && m_arPrevElements.empty()))
return std::map<std::wstring, std::wstring>();
std::map<std::wstring, std::wstring> mStyle(m_mStyle);
std::map<std::wstring, std::wstring> mStyle(m_mStyle);
for (const CElement* oElement : m_arPrevElements)
{
for (std::vector<std::wstring>::const_reverse_iterator sNode = arNodes.rbegin(); sNode != arNodes.rend(); ++sNode)
{
if ((*sNode)[0] == L'.')
{
for (const std::wstring& sClass : NS_STATIC_FUNCTIONS::GetWordsW(*sNode, L" "))
{
if (oElement->GetSelector() == sClass)
{
std::vector<std::wstring> sTempNodes = arNodes;
sTempNodes.pop_back();
for (const CElement* oElement : m_arPrevElements)
{
for (std::vector<std::wstring>::const_reverse_iterator sNode = arNodes.rbegin(); sNode != arNodes.rend(); ++sNode)
{
if ((*sNode)[0] == L'.')
{
for (const std::wstring& sClass : NS_STATIC_FUNCTIONS::GetWordsW(*sNode, false, L" "))
{
if (oElement->GetSelector() == sClass)
{
std::vector<std::wstring> sTempNodes = arNodes;
sTempNodes.pop_back();
for (const std::pair<std::wstring, std::wstring> pPropertie : oElement->GetFullStyle(sTempNodes))
mStyle[pPropertie.first] = pPropertie.second;
}
}
}
else if (oElement->GetSelector() == *sNode)
{
std::vector<std::wstring> sTempNodes = arNodes;
sTempNodes.pop_back();
for (const std::pair<std::wstring, std::wstring> pPropertie : oElement->GetFullStyle(sTempNodes))
mStyle[pPropertie.first] = pPropertie.second;
}
}
}
for (const std::pair<std::wstring, std::wstring> pPropertie : oElement->GetFullStyle(sTempNodes))
mStyle[pPropertie.first] = pPropertie.second;
}
}
}
else if (oElement->GetSelector() == *sNode)
{
std::vector<std::wstring> sTempNodes = arNodes;
sTempNodes.pop_back();
for (const std::pair<std::wstring, std::wstring> pPropertie : oElement->GetFullStyle(sTempNodes))
mStyle[pPropertie.first] = pPropertie.second;
}
}
}
return mStyle;
}
return mStyle;
}
std::vector<CElement *> CElement::GetNextOfKin(const std::wstring &sName, const std::vector<std::wstring>& arClasses) const
{
if (m_arKinElements.empty())
return std::vector<CElement*>();
std::vector<CElement *> CElement::GetNextOfKin(const std::wstring &sName, const std::vector<std::wstring>& arClasses) const
{
if (m_arKinElements.empty())
return std::vector<CElement*>();
std::vector<CElement*> arElements;
for (CElement* oElement : m_arKinElements)
{
if (!sName.empty() && oElement->m_sSelector == sName)
{
arElements.push_back(oElement);
continue;
}
std::vector<CElement*> arElements;
for (CElement* oElement : m_arKinElements)
{
if (!sName.empty() && oElement->m_sSelector == sName)
{
arElements.push_back(oElement);
continue;
}
for (const std::wstring& sClass : arClasses)
{
if (oElement->m_sSelector == sClass)
arElements.push_back(oElement);
}
}
return arElements;
}
for (const std::wstring& sClass : arClasses)
{
if (oElement->m_sSelector == sClass)
arElements.push_back(oElement);
}
}
return arElements;
}
std::vector<CElement *> CElement::GetPrevElements(const std::vector<std::wstring>::reverse_iterator &arNodesRBegin, const std::vector<std::wstring>::reverse_iterator &arNodesREnd) const
{
if (arNodesRBegin >= arNodesREnd || m_arPrevElements.empty())
return std::vector<CElement*>();
std::vector<CElement *> CElement::GetPrevElements(const std::vector<std::wstring>::reverse_iterator &arNodesRBegin, const std::vector<std::wstring>::reverse_iterator &arNodesREnd) const
{
if (arNodesRBegin >= arNodesREnd || m_arPrevElements.empty())
return std::vector<CElement*>();
std::vector<CElement*> arElements;
std::vector<CElement*> arElements;
for (std::vector<std::wstring>::reverse_iterator iWord = arNodesRBegin; iWord != arNodesREnd; ++iWord)
{
if ((*arNodesRBegin) == L".module_title")
std::wcout << *iWord << std::endl;
if ((*iWord)[0] == L'.' && ((*iWord).find(L" ") != std::wstring::npos))
{
std::vector<std::wstring> arClasses = NS_STATIC_FUNCTIONS::GetWordsW(*iWord, L" ");
for (std::wstring sClass : arClasses)
{
for (CElement* oPrevElement : m_arPrevElements)
{
if (oPrevElement->m_sSelector == sClass)
{
arElements.push_back(oPrevElement);
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, arNodesREnd);
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
}
}
}
}
else
{
for (CElement* oPrevElement : m_arPrevElements)
{
if (oPrevElement->m_sSelector == *iWord)
{
arElements.push_back(oPrevElement);
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, arNodesREnd);
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
// return arElements;
}
}
}
}
for (std::vector<std::wstring>::reverse_iterator iWord = arNodesRBegin; iWord != arNodesREnd; ++iWord)
{
if ((*iWord)[0] == L'.' && ((*iWord).find(L" ") != std::wstring::npos))
{
std::vector<std::wstring> arClasses = NS_STATIC_FUNCTIONS::GetWordsW(*iWord, false, L" ");
for (std::wstring sClass : arClasses)
{
for (CElement* oPrevElement : m_arPrevElements)
{
if (oPrevElement->m_sSelector == sClass)
{
arElements.push_back(oPrevElement);
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, arNodesREnd);
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
}
}
}
}
else
{
for (CElement* oPrevElement : m_arPrevElements)
{
if (oPrevElement->m_sSelector == *iWord)
{
arElements.push_back(oPrevElement);
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, arNodesREnd);
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
// return arElements;
}
}
}
}
return arElements;
return arElements;
}
}
CElement *CElement::FindPrevElement(const std::wstring &sSelector) const
{
if (sSelector.empty())
return NULL;
CElement *CElement::FindPrevElement(const std::wstring &sSelector) const
{
if (sSelector.empty())
return NULL;
for (CElement* oElement : m_arPrevElements)
{
if (oElement->m_sSelector == sSelector)
return oElement;
}
return NULL;
}
for (CElement* oElement : m_arPrevElements)
{
if (oElement->m_sSelector == sSelector)
return oElement;
}
return NULL;
}
std::vector<unsigned short> CElement::GetWeight()
{
if (m_arWeight.empty())
m_arWeight = NS_STATIC_FUNCTIONS::GetWeightSelector(m_sFullSelector);
std::vector<unsigned short> CElement::GetWeight()
{
if (m_arWeight.empty())
m_arWeight = NS_STATIC_FUNCTIONS::GetWeightSelector(m_sFullSelector);
return m_arWeight;
}
void CElement::IncreasedWeight()
{
if (!m_arWeight.empty())
{
m_arWeight = NS_STATIC_FUNCTIONS::GetWeightSelector(m_sFullSelector);
++m_arWeight[3];
}
}
void CElement::Print() const
{
std::wcout << L"Selector: " << m_sSelector << std::endl;
std::wcout << L"Full Selector: " << m_sFullSelector << std::endl;
std::wcout << L"===========STYLE(" << m_mStyle.size() << ")===========" << std::endl;
for (const std::pair<std::wstring, std::wstring> oPropertie : m_mStyle)
std::wcout << oPropertie.first << L" - " << oPropertie.second << std::endl;
std::wcout << L"===========================" << std::endl;
std::wcout << m_arKinElements.size() << L" --- " << m_arPrevElements.size() << std::endl;
if (!m_arKinElements.empty())
{
std::wcout << L"\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/" << std::endl;
for (CElement* oElement : m_arKinElements)
oElement->Print();
std::wcout << L"/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\" << std::endl;
}
for (CElement* oElement : m_arPrevElements)
oElement->Print();
}
return m_arWeight;
}
void CElement::IncreasedWeight()
{
if (!m_arWeight.empty())
{
m_arWeight = NS_STATIC_FUNCTIONS::GetWeightSelector(m_sFullSelector);
++m_arWeight[3];
}
}
}

View File

@ -3,51 +3,50 @@
#include <map>
#include <vector>
#include "CCssCalculator.h"
#include <string>
#include "CNode.h"
namespace NSCSS
{
class CElement
{
std::map<std::wstring, std::wstring> m_mStyle;
class CElement
{
std::map<std::wstring, std::wstring> m_mStyle;
std::vector<CElement*> m_arPrevElements;
std::vector<CElement*> m_arKinElements;
std::vector<CElement*> m_arPrevElements;
std::vector<CElement*> m_arKinElements;
std::wstring m_sSelector;
std::wstring m_sFullSelector;
std::wstring m_sSelector;
std::wstring m_sFullSelector;
std::vector<unsigned short int> m_arWeight;
std::vector<unsigned short int> m_arWeight;
public:
CElement();
~CElement();
public:
CElement();
~CElement();
std::wstring GetSelector() const;
std::wstring GetFullSelector() const;
std::wstring GetSelector() const;
std::wstring GetFullSelector() const;
bool Empty() const;
bool Empty() const;
void SetSelector(const std::wstring& sSelector);
void AddPropertie(const std::wstring& sName, const std::wstring& sValue);
void AddProperties(const std::map<std::wstring, std::wstring>& mProperties);
void AddPrevElement(CElement* oPrevElement);
void AddKinElement(CElement* oKinElement);
void SetSelector(const std::wstring& sSelector);
void AddPropertie(const std::wstring& sName, const std::wstring& sValue);
void AddProperties(const std::map<std::wstring, std::wstring>& mProperties);
void AddPrevElement(CElement* oPrevElement);
void AddKinElement(CElement* oKinElement);
std::map<std::wstring, std::wstring> GetStyle() const;
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<CNode>& arSelectors) const;
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<std::wstring>& arNodes) const;
std::vector<CElement *> GetNextOfKin(const std::wstring& sName, const std::vector<std::wstring>& arClasses = {}) const;
std::vector<CElement *> GetPrevElements(const std::vector<std::wstring>::reverse_iterator &arNodesRBegin, const std::vector<std::wstring>::reverse_iterator &arNodesREnd) const;
std::map<std::wstring, std::wstring> GetConvertStyle(const std::vector<CNode>& arNodes) const;
std::map<std::wstring, std::wstring> GetStyle() const;
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<CNode>& arSelectors) const;
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<std::wstring>& arNodes) const;
std::vector<CElement *> GetNextOfKin(const std::wstring& sName, const std::vector<std::wstring>& arClasses = {}) const;
std::vector<CElement *> GetPrevElements(const std::vector<std::wstring>::reverse_iterator &arNodesRBegin, const std::vector<std::wstring>::reverse_iterator &arNodesREnd) const;
std::map<std::wstring, std::wstring> GetConvertStyle(const std::vector<CNode>& arNodes) const;
CElement *FindPrevElement(const std::wstring& sSelector) const;
CElement *FindPrevElement(const std::wstring& sSelector) const;
std::vector<unsigned short int> GetWeight();
void IncreasedWeight();
void Print() const;
};
std::vector<unsigned short int> GetWeight();
void IncreasedWeight();
};
}

View File

@ -0,0 +1,55 @@
#include "CNode.h"
namespace NSCSS
{
CNode::CNode()
{}
CNode::CNode(std::wstring wsName, std::wstring wsClass, std::wstring wsId)
: m_wsName(wsName), m_wsClass(wsClass), m_wsId(wsId)
{}
bool CNode::Empty() const
{
return m_wsName.empty() && m_wsClass.empty() && m_wsId.empty() && m_wsStyle.empty();
}
std::vector<std::wstring> CNode::GetData() const
{
std::vector<std::wstring> arValues;
if (!m_wsClass.empty())
arValues.push_back(m_wsClass);
if (!m_wsName.empty())
arValues.push_back(m_wsName);
return arValues;
}
bool CNode::operator<(const CNode& oNode) const
{
if(m_wsName != oNode.m_wsName)
return m_wsName < oNode.m_wsName;
if(m_wsClass != oNode.m_wsClass)
return m_wsClass < oNode.m_wsClass;
if(m_wsId != oNode.m_wsId)
return m_wsId < oNode.m_wsId;
if(m_wsStyle != oNode.m_wsStyle)
return m_wsStyle < oNode.m_wsStyle;
if (m_mAttributes != oNode.m_mAttributes)
return m_mAttributes < oNode.m_mAttributes;
return false;
}
bool CNode::operator==(const CNode& oNode) const
{
return((m_wsId == oNode.m_wsId) &&
(m_wsName == oNode.m_wsName) &&
(m_wsClass == oNode.m_wsClass) &&
(m_wsStyle == oNode.m_wsStyle) &&
(m_mAttributes == oNode.m_mAttributes));
}
}

View File

@ -7,57 +7,25 @@
namespace NSCSS
{
struct CNode
{
std::wstring m_sName; // Имя тэга
std::wstring m_sClass; // Класс тэга
std::wstring m_sId; // Id тэга
std::wstring m_sStyle; // Стиль тэга
std::map<std::wstring, std::wstring> m_mAttrs; // Остальные аттрибуты тэга
class CNode
{
public:
std::wstring m_wsName; // Имя тэга
std::wstring m_wsClass; // Класс тэга
std::wstring m_wsId; // Id тэга
std::wstring m_wsStyle; // Стиль тэга
std::map<std::wstring, std::wstring> m_mAttributes; // Остальные аттрибуты тэга
CNode(){};
CNode(std::wstring sName, std::wstring sClass, std::wstring sId) : m_sName(sName), m_sClass(sClass), m_sId(sId){};
public:
CNode();
CNode(std::wstring wsName, std::wstring wsClass, std::wstring wsId);
bool Empty() const
{
return m_sName.empty() && m_sClass.empty() && m_sId.empty() && m_sStyle.empty();
}
bool Empty() const;
std::vector<std::wstring> GetData() const
{
std::vector<std::wstring> arValues;
if (!m_sClass.empty())
arValues.push_back(m_sClass);
if (!m_sName.empty())
arValues.push_back(m_sName);
return arValues;
}
bool operator< (const CNode& oNode) const
{
if(m_sName != oNode.m_sName)
return m_sName < oNode.m_sName;
if(m_sClass != oNode.m_sClass)
return m_sClass < oNode.m_sClass;
if(m_sId != oNode.m_sId)
return m_sId < oNode.m_sId;
if(m_sStyle != oNode.m_sStyle)
return m_sStyle < oNode.m_sStyle;
return false;
}
bool operator== (const CNode& oNode) const
{
return((m_sId == oNode.m_sId) &&
(m_sName == oNode.m_sName) &&
(m_sClass == oNode.m_sClass) &&
(m_sStyle == oNode.m_sStyle));
}
};
std::vector<std::wstring> GetData() const;
bool operator< (const CNode& oNode) const;
bool operator== (const CNode& oNode) const;
};
}
#endif // CNODE_H

View File

@ -0,0 +1,178 @@
#include "CUnitMeasureConverter.h"
#include <sstream>
#include <algorithm>
#include <vector>
#include "StaticFunctions.h"
namespace NSCSS
{
CUnitMeasureConverter::CUnitMeasureConverter()
{}
double CUnitMeasureConverter::ConvertPx(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI)
{
switch (enUnitMeasure)
{
case NSCSS::Pixel:
return dValue;
case NSCSS::Point:
return 72. / (double)ushDPI * dValue;
case NSCSS::Cantimeter:
return dValue / (double)ushDPI * 2.54;
case NSCSS::Millimeter:
return dValue / (double)ushDPI * 25.4;
case NSCSS::Inch:
return 1. / (double)ushDPI * dValue;
case NSCSS::Peak:
return 0.16667 / (double)ushDPI * dValue;
}
return 0.;
}
double CUnitMeasureConverter::ConvertCm(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI)
{
switch (enUnitMeasure)
{
case NSCSS::Point:
return 28.35 * dValue;
case NSCSS::Pixel:
return (double)ushDPI / 2.54 * dValue;
case NSCSS::Cantimeter:
return dValue;
case NSCSS::Millimeter:
return dValue * 10.;
case NSCSS::Inch:
return dValue / 2.54f;
case NSCSS::Peak:
return 2.36 * dValue;
}
return 0.;
}
double CUnitMeasureConverter::ConvertMm(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
{
switch (enUnitMeasure)
{
case NSCSS::Point:
return 2.835 * dValue;
case NSCSS::Pixel:
return (double)ushDPI / 25.4 * dValue;
case NSCSS::Cantimeter:
return dValue / 10.;
case NSCSS::Millimeter:
return dValue;
case NSCSS::Inch:
return dValue / 25.4;
case NSCSS::Peak:
return 0.236 * dValue;
}
return 0.;
}
double CUnitMeasureConverter::ConvertIn(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
{
switch (enUnitMeasure)
{
case NSCSS::Point:
return dValue / 6.;
case NSCSS::Pixel:
return dValue * (double)ushDPI;
case NSCSS::Cantimeter:
return dValue * 2.54;
case NSCSS::Millimeter:
return dValue * 25.4;
case NSCSS::Inch:
return dValue;
case NSCSS::Peak:
return dValue / 72.;
}
return 0.;
}
double CUnitMeasureConverter::ConvertPt(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
{
switch (enUnitMeasure)
{
case NSCSS::Point:
return dValue;
case NSCSS::Pixel:
return (double)ushDPI / 72. * dValue;
case NSCSS::Cantimeter:
return dValue * 0.03528;
case NSCSS::Millimeter:
return dValue * 0.3528;
case NSCSS::Inch:
return dValue / 72.;
case NSCSS::Peak:
return dValue / 12.;
}
return 0.;
}
double CUnitMeasureConverter::ConvertPc(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
{
switch (enUnitMeasure)
{
case NSCSS::Point:
return dValue * 12.;
case NSCSS::Pixel:
return (double)ushDPI / 6. * dValue;
case NSCSS::Cantimeter:
return dValue * 0.423;
case NSCSS::Millimeter:
return dValue * 4.23;
case NSCSS::Inch:
return dValue / 6.;
case NSCSS::Peak:
return dValue;
}
return 0.;
}
bool CUnitMeasureConverter::GetValue(const std::wstring &wsValue, double &dValue, UnitMeasure &enUnitMeasure)
{
std::wstring::const_iterator oFoundDigit = std::find_if(wsValue.begin(), wsValue.end(), std::iswdigit);
if (wsValue.end() == oFoundDigit)
return false;
std::wistringstream(wsValue) >> dValue;
std::wstring::const_iterator oFoundUM = std::find_if(oFoundDigit, wsValue.end(), [](wchar_t wcSymbol){ return std::iswalpha(wcSymbol) || L'%' == wcSymbol; });
if (wsValue.end() != oFoundUM)
{
if (L'%' == *oFoundUM)
{
enUnitMeasure = Percent;
return true;
}
std::wstring wsUnitMeasure(oFoundUM, oFoundUM + 2);
if (L"px" == wsUnitMeasure)
enUnitMeasure = Pixel;
else if (L"pt" == wsUnitMeasure)
enUnitMeasure = Point;
else if (L"cm" == wsUnitMeasure)
enUnitMeasure = Cantimeter;
else if (L"mm" == wsUnitMeasure)
enUnitMeasure = Millimeter;
else if (L"in" == wsUnitMeasure)
enUnitMeasure = Inch;
else if (L"pc" == wsUnitMeasure)
enUnitMeasure = Peak;
}
else
enUnitMeasure = None;
return true;
}
}

View File

@ -0,0 +1,35 @@
#ifndef CUNITMEASURECONVERTER_H
#define CUNITMEASURECONVERTER_H
#include <string>
namespace NSCSS
{
typedef enum
{
None,
Percent,
Pixel,
Point,
Cantimeter,
Millimeter,
Inch,
Peak
} UnitMeasure;
class CUnitMeasureConverter
{
CUnitMeasureConverter();
public:
static double ConvertPx(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
static double ConvertCm(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
static double ConvertMm(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
static double ConvertIn(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
static double ConvertPt(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
static double ConvertPc(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
static bool GetValue(const std::wstring& wsValue, double& dValue, UnitMeasure& enUnitMeasure);
};
}
#endif // CUNITMEASURECONVERTER_H

View File

@ -0,0 +1,182 @@
#include "ConstValues.h"
namespace NSCSS
{
CSizeWindow::CSizeWindow()
: m_ushWidth(0), m_ushHeight(0)
{}
CSizeWindow::CSizeWindow(unsigned short unWidth, unsigned short unHeight)
: m_ushWidth(unWidth), m_ushHeight(unHeight)
{}
bool CSizeWindow::Empty() const
{
return ((0 == m_ushWidth) && (0 == m_ushHeight));
}
void CSizeWindow::Clear()
{
m_ushWidth = m_ushHeight = 0;
}
bool CSizeWindow::operator==(const CSizeWindow &oSizeWindow) const
{
return ((m_ushWidth == oSizeWindow.m_ushWidth) && (m_ushHeight == oSizeWindow.m_ushHeight));
}
bool CSizeWindow::operator!=(const CSizeWindow &oSizeWindow) const
{
return ((m_ushWidth != oSizeWindow.m_ushWidth) || (m_ushHeight != oSizeWindow.m_ushHeight));
}
bool StatistickElement::operator<(const StatistickElement &oStatistickElement) const
{
return sValue < oStatistickElement.sValue;
}
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
{
/* Red tones */
{L"indianeed", L"CD5C5C"}, {L"lightcoral", L"F08080"}, {L"salmon", L"FA8072"},
{L"darksalmon", L"E9967A"}, {L"lightsalmon", L"FFA07A"}, {L"crimson", L"DC143C"},
{L"red", L"FF0000"}, {L"firebrick", L"B22222"}, {L"darkred", L"8B0000"},
/* Pink tones */
{L"pink", L"FFC0CB"}, {L"lightpink", L"FFB6C1"}, {L"hotpink", L"FF69B4"},
{L"deeppink", L"FF1493"}, {L"mediumvioletred", L"C71585"}, {L"palevioleteed", L"DB7093"},
/* Orange tones */
{L"lightsalmon", L"FFA07A"}, {L"coral", L"FF7F50"}, {L"tomato", L"FF6347"},
{L"orangered", L"FF4500"}, {L"darkorange", L"FF8C00"}, {L"orange", L"FFA500"},
/* Yellow tones */
{L"gold", L"FFD700"}, {L"yellow", L"FFFF00"}, {L"lightyellow", L"FFFFE0"},
{L"lemonchiffon", L"FFFACD"}, {L"lightgoldenrodyellow", L"FAFAD2"}, {L"papayawhip", L"FFEFD5"},
{L"moccasin", L"FFE4B5"}, {L"peachpuff", L"FFDAB9"}, {L"palegoldenrod", L"EEE8AA"},
{L"khaki", L"F0E68C"}, {L"darkkhaki", L"BDB76B"},
/* Purple tones */
{L"lavender", L"E6E6FA"}, {L"thistle", L"D8BFD8"}, {L"plum", L"DDA0DD"},
{L"violet", L"EE82EE"}, {L"orchid", L"DA70D6"}, {L"fuchsia", L"FF00FF"},
{L"magenta", L"FF00FF"}, {L"mediumorchid", L"BA55D3"}, {L"mediumpurple", L"9370DB"},
{L"blueviolet", L"8A2BE2"}, {L"darkviolet", L"9400D3"}, {L"darkorchid", L"9932CC"},
{L"darkmagenta", L"8B008B"}, {L"purple", L"800080"}, {L"indigo", L"4B0082"},
{L"slateblue", L"6A5ACD"}, {L"darkslateblue", L"483D8B"},
/* Brown tones */
{L"cornsilk", L"FFF8DC"}, {L"blanchedalmond", L"FFEBCD"}, {L"bisque", L"FFE4C4"},
{L"navajowhite", L"FFDEAD"}, {L"wheat", L"F5DEB3"}, {L"burlywood", L"DEB887"},
{L"tan", L"D2B48C"}, {L"rosybrown", L"BC8F8F"}, {L"sandybrown", L"F4A460"},
{L"goldenrod", L"DAA520"}, {L"darkgoldenrod", L"B8860B"}, {L"peru", L"CD853F"},
{L"chocolate", L"D2691E"}, {L"saddlebrown", L"8B4513"}, {L"sienna", L"A0522D"},
{L"brown", L"A52A2A"}, {L"maroon", L"800000"},
/* Green tones */
{L"greenyellow", L"ADFF2F"}, {L"chartreuse", L"7FFF00"}, {L"lawngreen", L"7CFC00"},
{L"lime", L"00FF00"}, {L"limegreen", L"32CD32"}, {L"palegreen", L"98FB98"},
{L"lightgreen", L"90EE90"}, {L"mediumspringgreen", L"00FA9A"}, {L"springgreen", L"00FF7F"},
{L"mediumseagreen", L"3CB371"}, {L"seagreen", L"2E8B57"}, {L"forestgreen", L"228B22"},
{L"green", L"008000"}, {L"darkgreen", L"006400"}, {L"yellowgreen", L"9ACD32"},
{L"olivedrab", L"6B8E23"}, {L"olive", L"808000"}, {L"darkolivegreen",L"556B2F"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"},
{L"mediumaquamarine", L"66CDAA"}, {L"darkseagreen", L"8FBC8F"}, {L"lightseagreen", L"20B2AA"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"},
{L"darkcyan", L"008B8B"}, {L"teal", L"008080"},
/* Blue tones */
{L"aqua", L"00FFFF"}, {L"cyan", L"00FFFF"}, {L"lightcyan", L"E0FFFF"},
{L"paleturquoise", L"AFEEEE"}, {L"aquamarine", L"7FFFD4"}, {L"turquoise", L"40E0D0"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"},
{L"mediumturquoise", L"48D1CC"}, {L"darkturquoise", L"00CED1"}, {L"cadetblue", L"5F9EA0"},
{L"steelblue", L"4682B4"}, {L"lightsteelblue", L"B0C4DE"}, {L"powderblue", L"B0E0E6"},
{L"lightblue", L"ADD8E6"}, {L"skyblue", L"87CEEB"}, {L"lightskyblue", L"87CEFA"},
{L"deepskyblue", L"00BFFF"}, {L"dodgerblue", L"1E90FF"}, {L"cornflowerblue",L"6495ED"},
{L"mediumdlateblue", L"7B68EE"}, {L"royalblue", L"4169E1"}, {L"blue", L"0000FF"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"},
{L"mediumblue", L"0000CD"}, {L"darkblue", L"00008B"}, {L"navy", L"000080"},
{L"midnightblue", L"191970"},
/* White tones */
{L"white", L"FFFFFF"}, {L"snow", L"FFFAFA"}, {L"honeydew", L"F0FFF0"},
{L"mintcream", L"F5FFFA"}, {L"azure", L"F0FFFF"}, {L"aliceblue", L"F0F8FF"},
{L"ghostwhite", L"F8F8FF"}, {L"whitesmoke", L"F5F5F5"}, {L"seashell", L"FFF5EE"},
{L"beige", L"F5F5DC"}, {L"oldlace", L"FDF5E6"}, {L"floralwhite", L"FFFAF0"},
{L"ivory", L"FFFFF0"}, {L"antiquewhite", L"FAEBD7"}, {L"linen", L"FAF0E6"},
{L"lavenderblush", L"FFF0F5"}, {L"mistyrose", L"FFE4E1"},
/* Gray tones */
{L"gainsboro", L"DCDCDC"}, {L"lightgray", L"D3D3D3"}, {L"silver", L"C0C0C0"},
{L"darkgray", L"A9A9A9"}, {L"gray", L"808080"}, {L"dimgray", L"696969"},
{L"lightslategray", L"778899"}, {L"slategray", L"708090"}, {L"darkslategray", L"2F4F4F"},
{L"black", L"000000"},
/* Outdated */
{L"windowtext", L"000000"}, {L"transparent", L"000000"}
};
const std::vector<std::wstring> DISPLAY_VALUES
{
/* <display-outside> values */
L"block", L"inline", L"run-in",
/* <display-inside> values */
L"flow", L"flow-root", L"table", L"flex", L"grid", L"ruby",
/* <display-outside> plus <display-inside> values */
L"block flow", L"inline table", L"flex run-in",
/* <display-listitem> values */
L"list-item", L"list-item block", L"list-item inline", L"list-item flow",
L"list-item flow-root", L"list-item block flow",
L"list-item block flow-root", L"flow list-item block",
/* <display-internal> values */
L"table-row-group", L"table-header-group", L"table-footer-group",
L"table-row", L"table-cell", L"table-column-group", L"table-column",
L"table-caption", L"ruby-base", L"ruby-text", L"ruby-base-container",
L"ruby-text-container",
/* <display-box> values */
L"contents", L"none",
/* <display-legacy> values */
L"inline-block", L"inline-table", L"inline-flex", L"inline-grid",
/* Global values */
L"inherit", L"initial", L"unset"
};
#ifdef CSS_CALCULATOR_WITH_XHTML
const std::wstring PSEUDO_CLASSES[33]
{
L"invalid",
L"read-only",
L"-moz-placeholder",
L"-webkit-input-placeholder",
L"active",
L"checked",
L"default",
L"disabled",
L"empty",
L"enabled",
L"first-child",
L"first-of-type",
L"focus",
L"hover",
L"indeterminate",
L"lang",
L"last-child",
L"last-of-type",
L"link",
L"not",
L"nth-child",
L"nth-last-child",
L"nth-last-of-type",
L"nth-of-type",
L"only-child",
L"only-of-type",
L"optional",
L"read-write",
L"required",
L"root",
L"target",
L"valid",
L"visited"
};
#endif
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,179 @@
#include "StaticFunctions.h"
namespace NSCSS
{
namespace NS_STATIC_FUNCTIONS
{
std::string GetContentAsUTF8(const std::string &sString, const std::wstring &sEncoding)
{
const std::string& sEnc = U_TO_UTF8(sEncoding);
NSUnicodeConverter::CUnicodeConverter oConverter;
const std::wstring& sUnicodeContent = oConverter.toUnicode(sString, sEnc.c_str());
return U_TO_UTF8(oConverter.toUnicode(sString, sEnc.c_str()));
}
std::string GetContentAsUTF8(const std::wstring& sFileName)
{
std::string sContent;
// читаем файл как есть. utf-8 тут просто название.
if(!NSFile::CFileBinary::ReadAllTextUtf8A(sFileName, sContent))
return sContent;
std::string sEncoding;
if (true)
{
// определяем кодировку
const std::string::size_type& posCharset = sContent.find("@charset");
if (std::string::npos != posCharset)
{
std::string::size_type pos1 = sContent.find_first_of("\"';", posCharset);
if (std::string::npos != pos1)
{
pos1 += 1;
std::string::size_type pos2 = sContent.find_first_of("\"';", pos1);
if (std::string::npos != pos2)
{
sEncoding = sContent.substr(pos1, pos2 - pos1);
}
// check valid
if (std::string::npos != sEncoding.find_first_of(" \n\r\t\f\v"))
sEncoding = "";
}
}
}
if (sEncoding.empty())
sEncoding = "utf-8";
if (!sEncoding.empty() && sEncoding != "utf-8" && sEncoding != "UTF-8")
{
NSUnicodeConverter::CUnicodeConverter oConverter;
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sEncoding.c_str()));
}
return sContent;
}
double ReadDouble(const std::wstring& wsValue)
{
double dValue;
std::wistringstream(wsValue) >> dValue;
return dValue;
}
std::vector<double> ReadDoubleValues(const std::wstring& wsValue)
{
std::vector<double> arValues;
std::wregex oPattern(LR"([-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)");
std::wsregex_iterator oIter(wsValue.begin(), wsValue.end(), oPattern);
std::wsregex_iterator oEndIter;
for (; oIter != oEndIter; ++oIter)
arValues.push_back(std::stod(oIter->str()));
return arValues;
}
std::vector<std::wstring> GetWordsW(const std::wstring& wsLine, bool bWithSigns, const std::wstring& wsDelimiters)
{
if (wsLine.empty())
return {};
size_t unEnd = wsLine.find_first_of(wsDelimiters);
if (std::wstring::npos == unEnd)
return {wsLine};
size_t unStart = 0;
std::vector<std::wstring> arWords;
while (std::wstring::npos != unEnd)
{
arWords.emplace_back(wsLine.data() + unStart, unEnd - unStart + ((bWithSigns) ? 1 : 0));
unStart = wsLine.find_first_not_of(wsDelimiters, unEnd);
unEnd = wsLine.find_first_of(wsDelimiters, unStart);
}
arWords.emplace_back(wsLine.data() + unStart);
return arWords;
}
std::vector<unsigned short int> GetWeightSelector(const std::wstring& wsSelector)
{
if (wsSelector.empty())
return std::vector<unsigned short int>{0, 0, 0, 0};
std::vector<unsigned short int> arWeight = {0, 0, 0, 0};
std::wstring sReverseSelector = wsSelector;
std::reverse(sReverseSelector.begin(), sReverseSelector.end());
const std::vector<std::wstring> arSelectors = NS_STATIC_FUNCTIONS::GetWordsW(sReverseSelector, true, L" .#:");
for (const std::wstring& sSel : arSelectors)
{
if (sSel == L"*")
++arWeight[3];
else if (sSel.rfind(L'#') != std::wstring::npos)
++arWeight[0];
else if (sSel.rfind(L':') != std::wstring::npos)
{
std::wstring sTemp(sSel);
sTemp.erase(std::remove_if(sTemp.begin(), sTemp.end(), [] (const wchar_t& wc) { return !std::iswalpha(wc);}));
// std::find(NSConstValues::arPseudoClasses.begin(), NSConstValues::arPseudoClasses.end(), sTemp) != NSConstValues::arPseudoClasses.end() ? ++arWeight[1] : ++arWeight[2];
}
else if (sSel.find_last_of(L".[]") != std::wstring::npos)
++arWeight[1];
else
++arWeight[2];
}
return arWeight;
}
std::map<std::wstring, std::wstring> GetRules(const std::wstring& wsStyles)
{
if (wsStyles.empty())
return {};
std::map<std::wstring, std::wstring> mRules;
std::wstring::const_iterator oStartProperty = std::find_if_not(wsStyles.begin(), wsStyles.end(), std::iswspace);
std::wstring::const_iterator oEndProperty, oStartValue, oEndValue;
while (wsStyles.end() != oStartProperty)
{
oEndProperty = std::find_if(oStartProperty, wsStyles.end(), [](const wchar_t &wcChar){ return L':' == wcChar;});
oStartValue = std::find_if_not(oEndProperty + 1, wsStyles.end(), std::iswspace);
if (wsStyles.end() == oEndProperty || wsStyles.end() == oStartValue)
break;
oEndValue = std::find_if(oStartValue, wsStyles.end(), [](const wchar_t &wcChar){ return L';' == wcChar;});
mRules.insert({std::wstring(oStartProperty, oEndProperty), std::wstring(oStartValue, oEndValue)});
if (wsStyles.end() == oEndValue)
break;
oStartProperty = std::find_if_not(oEndValue + 1, wsStyles.end(), std::iswspace);
}
return mRules;
}
std::wstring RemoveSpaces(std::wstring &wsString)
{
std::wstring::const_iterator ciStart = std::find_if_not(wsString.begin(), wsString.end(), std::iswspace);
std::wstring::const_reverse_iterator criEnd = std::find_if_not(wsString.rbegin(),wsString.rend(), std::iswspace);
return std::wstring(ciStart, criEnd.base());
}
}
}

View File

@ -3,466 +3,73 @@
#include "../../../../../UnicodeConverter/UnicodeConverter.h"
#include "../../../../../DesktopEditor/common/File.h"
#include "CNode.h"
#include <algorithm>
#include <cwctype>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
namespace NSCSS
{
namespace NS_STATIC_FUNCTIONS
{
inline static std::wstring stringToWstring(const std::string& sString)
{
return UTF8_TO_U(sString);
}
namespace NS_STATIC_FUNCTIONS
{
std::string GetContentAsUTF8(const std::string &sString, const std::wstring &sEncoding);
std::string GetContentAsUTF8(const std::wstring& sFileName);
inline static std::string wstringToString(const std::wstring& sWstring)
{
return U_TO_UTF8(sWstring);
}
double ReadDouble(const std::wstring& wsValue);
std::vector<double> ReadDoubleValues(const std::wstring& wsValue);
inline static std::string GetContentAsUTF8(const std::string &sString, const std::wstring &sEncoding)
{
const std::string& sEnc = U_TO_UTF8(sEncoding);
std::vector<std::wstring> GetWordsW(const std::wstring& wsLine, bool bWithSigns = false, const std::wstring& wsDelimiters = L" \n\r\t\f\v:;,!");
std::vector<unsigned short int> GetWeightSelector(const std::wstring& sSelector);
std::map<std::wstring, std::wstring> GetRules(const std::wstring& wsStyles);
NSUnicodeConverter::CUnicodeConverter oConverter;
const std::wstring& sUnicodeContent = oConverter.toUnicode(sString, sEnc.c_str());
return U_TO_UTF8(sUnicodeContent);
}
std::wstring RemoveSpaces(std::wstring& wsString);
}
inline static std::string GetContentAsUTF8(const std::wstring& sFileName)
{
std::string sFileContent;
#define SWITCH(str) switch(SWITCH_CASE::str_hash_for_switch(str))
#define CASE(str) static_assert(SWITCH_CASE::str_is_correct(str) && (SWITCH_CASE::str_len(str) <= SWITCH_CASE::MAX_LEN),\
"CASE string contains wrong characters, or its length is greater than 9");\
case SWITCH_CASE::str_hash(str, SWITCH_CASE::str_len(str))
#define DEFAULT default
// читаем файл как есть. utf-8 тут просто название.
if(!NSFile::CFileBinary::ReadAllTextUtf8A(sFileName, sFileContent))
return sFileContent;
namespace SWITCH_CASE
{
typedef unsigned long long ullong;
std::string sEncoding;
if (true)
{
// определяем кодировку
const std::string::size_type& posCharset = sFileContent.find("@charset");
const unsigned int MAX_LEN = 32;
const ullong N_HASH = static_cast<ullong>(-1);
if (std::string::npos != posCharset)
{
std::string::size_type pos1 = sFileContent.find_first_of("\"';", posCharset);
if (std::string::npos != pos1)
{
pos1 += 1;
std::string::size_type pos2 = sFileContent.find_first_of("\"';", pos1);
if (std::string::npos != pos2)
{
sEncoding = sFileContent.substr(pos1, pos2 - pos1);
}
// check valid
if (std::string::npos != sEncoding.find_first_of(" \n\r\t\f\v"))
sEncoding = "";
}
}
}
if (sEncoding.empty())
sEncoding = "utf-8";
if (!sEncoding.empty() && sEncoding != "utf-8" && sEncoding != "UTF-8")
{
NSUnicodeConverter::CUnicodeConverter oConverter;
sFileContent = U_TO_UTF8(oConverter.toUnicode(sFileContent, sEncoding.c_str()));
}
return sFileContent;
}
inline static bool NumberInWString(const std::wstring& sString)
{
if (sString.empty())
return false;
size_t posDigit = sString.find_first_of(L"0123456789");
// size_t posNoDigit = sString.find_first_not_of(L" \n\r\t\f\v123456789.");
if (posDigit != std::wstring::npos)
return true;
return false;
}
inline std::wstring StripSymbols(const std::wstring& sValue, const std::wstring& sSymbols = L" \n\r\t\f\v")
{
if (sValue.empty())
return std::wstring();
size_t start = sValue.find_first_not_of(sSymbols);
if (std::wstring::npos == start)
return sValue;
size_t end = sValue.find_last_not_of(sSymbols); // точно >=0
return sValue.substr(start, end - start + 1);
}
inline std::vector<std::string> GetWords(const std::wstring& sLine)
{
if (sLine.empty())
return {};
std::vector<std::string> arWords;
arWords.reserve(16);
const std::string sTemp = wstringToString(sLine);
size_t posFirstNotSpace = sTemp.find_first_not_of(" \n\r\t\f\v:;,");
while (posFirstNotSpace != std::wstring::npos)
{
const size_t& posLastNotSpace = sTemp.find_first_of(" \n\r\t\f\v:;,", posFirstNotSpace);
arWords.push_back(sTemp.substr(posFirstNotSpace, posLastNotSpace - posFirstNotSpace));
posFirstNotSpace = sTemp.find_first_not_of(" \n\r\t\f\v:;,", posLastNotSpace);
}
return arWords;
}
inline std::vector<std::wstring> GetWordsW(const std::wstring& sLine, const std::wstring& sSigns = L" \n\r\t\f\v:;,")
{
if (sLine.empty())
return {};
if (sLine.find_first_of(sSigns) == std::wstring::npos)
return std::vector<std::wstring>({sLine});
std::vector<std::wstring> arWords;
arWords.reserve(16);
size_t posFirstNotSpace = sLine.find_first_not_of(sSigns);
while (posFirstNotSpace != std::wstring::npos)
{
const size_t& posLastNotSpace = sLine.find_first_of(sSigns, posFirstNotSpace);
arWords.push_back(sLine.substr(posFirstNotSpace, posLastNotSpace - posFirstNotSpace));
posFirstNotSpace = sLine.find_first_not_of(sSigns, posLastNotSpace);
}
return arWords;
}
inline bool ConvertAbsoluteValue(std::wstring& sAbsoluteValue, const float &unId)
{
if (sAbsoluteValue.empty())
return false;
bool bIsConvert = false;
std::map<std::wstring, std::wstring> arAbsoluteFontValues = {{L"xx-small", L"9px"}, {L"x-small", L"10px"},
{L"small", L"13px"}, {L"medium", L"16px"},
{L"large", L"18px"}, {L"x-large", L"24px"},
{L"xx-large", L"32px"}};
std::map<std::wstring, std::wstring> arAbsoluteBorderValues = {{L"thin", L"2px"},
{L"medium", L"4px"},
{L"thick", L"6px"}};
std::map<std::wstring, std::wstring> arAbsoluteValues = ((unId == 0.0f) ? arAbsoluteBorderValues : arAbsoluteFontValues);
if (sAbsoluteValue.find(L' ') == std::wstring::npos && arAbsoluteValues.find(sAbsoluteValue) != arAbsoluteValues.end())
{
sAbsoluteValue = arAbsoluteValues[sAbsoluteValue];
return true;
}
std::wstring sValue;
sValue.reserve(sAbsoluteValue.length() + 1);
for (const std::wstring& sWord : GetWordsW(sAbsoluteValue))
{
std::map<std::wstring, std::wstring>::iterator oFind = arAbsoluteValues.find(sWord);
if (oFind != arAbsoluteValues.end())
{
bIsConvert = true;
sValue += oFind->second + L' ';
}
else
sValue += sWord + L' ';
}
sValue.pop_back();
if (bIsConvert)
sAbsoluteValue = sValue;
return bIsConvert;
}
inline std::vector<std::string> GetSelectorsList(const std::wstring& sSelectors)
{
if (sSelectors.empty())
return std::vector<std::string>();
std::wstring sNames = sSelectors;
std::wstring sClasses;
std::wstring sIds;
size_t posLattice = sNames.find(L"#");
if (posLattice != std::wstring::npos)
{
sNames = sSelectors.substr(0, posLattice);
sIds = sSelectors.substr(posLattice);
}
size_t posPoint = sNames.find(L'.');
if (posPoint != std::wstring::npos)
{
sNames = sSelectors.substr(0, posPoint);
sClasses = sSelectors.substr(posPoint);
posLattice = sClasses.find(L'#');
if (posLattice != std::wstring::npos)
sClasses = sClasses.substr(0, posLattice);
}
std::vector<std::string> arNames = GetWords(sNames);
std::vector<std::string> arClasses = GetWords(sClasses);
std::vector<std::string> arIds = GetWords(sIds);
std::vector<std::string> arSelectors(arNames);
arSelectors.reserve(arNames.size() * arClasses.size() + arNames.size() * arIds.size() + arClasses.size() * arIds.size());
for (std::string& sClass : arClasses)
{
if (sClass.find('.') == std::string::npos)
sClass = '.' + sClass;
arSelectors.push_back(sClass);
for (const std::string& sName : arNames)
arSelectors.push_back(sName + sClass);
for (const std::string& sId : arIds)
arSelectors.push_back(sClass + sId);
}
for (std::string& sId : arIds)
{
if (sId.find('#') == std::string::npos)
sId = '#' + sId;
arSelectors.push_back(sId);
for (const std::string& sName : arNames)
arSelectors.push_back(sName + sId);
}
return arSelectors;
}
inline std::vector<std::string> GetSelectorsListWithParents(const std::vector<CNode> &arParents)
{
if (arParents.size() < 2)
return std::vector<std::string>();
if (arParents.back().m_sName.empty())
return std::vector<std::string>();
std::vector<std::string> arSelectors;
short int nIndex = 0;
while (nIndex < static_cast<short int>(arParents.size() - 1))
{
std::wstring sSelector;
for (unsigned short int i = nIndex; i < arParents.size() - 1; ++i)
{
if (arParents[i].m_sName.empty())
continue;
std::wstring sParentSelector = arParents[i].m_sName;
if (!arParents[i].m_sClass.empty())
sParentSelector += L'.' + arParents[i].m_sClass;
if (!arParents[i].m_sId.empty())
sParentSelector += L'#' + arParents[i].m_sId;
sSelector += sParentSelector + L' ';
}
std::wstring sChildrenSelector = arParents.back().m_sName;
if (!arParents.back().m_sClass.empty())
sChildrenSelector += L'.' + arParents.back().m_sClass;
if (!arParents.back().m_sId.empty())
sChildrenSelector += L'#' + arParents.back().m_sId;
sSelector += sChildrenSelector;
++nIndex;
arSelectors.push_back(wstringToString(sSelector));
}
return arSelectors;
}
inline std::vector<std::wstring> GetWordsWithSigns(const std::wstring& sLine, const std::wstring& sSigns = L" \n\r\t\f\v:;,")
{
if (sLine.empty())
return {};
if (sLine.find_first_of(sSigns) == std::wstring::npos)
return std::vector<std::wstring>({sLine});
std::vector<std::wstring> arWords;
arWords.reserve(16);
size_t posFirstNotSpace = sLine.find_first_not_of(sSigns);
while (posFirstNotSpace != std::wstring::npos)
{
const size_t posLastNotSpace = sLine.find_first_of(sSigns, posFirstNotSpace);
arWords.push_back(sLine.substr(posFirstNotSpace, (posLastNotSpace != std::wstring::npos) ? posLastNotSpace - posFirstNotSpace + 1 : posLastNotSpace - posFirstNotSpace ));
posFirstNotSpace = sLine.find_first_not_of(sSigns, posLastNotSpace);
}
return arWords;
}
inline bool IsDigit(const std::wstring& sValue)
{
return sValue.empty() ? false : std::all_of(sValue.begin(), sValue.end(), [] (const wchar_t& cChar) { return iswdigit(cChar); });
}
inline std::wstring NormalizeRGB(const std::wstring& wsValue)
constexpr ullong raise_128_to(const wchar_t power)
{
std::wstring wsNewValue = wsValue;
size_t unBegin = 0, unEnd;
while (std::wstring::npos != (unBegin = wsNewValue.find(L"rgb(", unBegin)))
{
unEnd = wsNewValue.find(L")", unBegin);
while ((unBegin = wsNewValue.find(L" ", unBegin)) != std::wstring::npos && unBegin < unEnd)
{
wsNewValue.replace(unBegin, 1, L",");
++unBegin;
}
}
return wsNewValue;
return (1ULL << 7) * power;
}
inline std::wstring ConvertRgbToHex(const std::wstring& sRgbValue)
{
size_t posFirst = sRgbValue.find_first_of(L"01234567890");
if (posFirst == std::wstring::npos)
return std::wstring();
constexpr bool str_is_correct(const wchar_t* const str)
{
return (static_cast<wchar_t>(*str) > 0) ? str_is_correct(str + 1) : (*str ? false : true);
}
const wchar_t cHex[17]{L"0123456789abcdef"};
constexpr unsigned int str_len(const wchar_t* const str)
{
return *str ? (1 + str_len(str + 1)) : 0;
}
std::wstring sValue;
constexpr ullong str_hash(const wchar_t* const str, const wchar_t current_len)
{
return *str ? (raise_128_to(current_len - 1) * static_cast<wchar_t>(*str) + str_hash(str + 1, current_len - 1)) : 0;
}
while (posFirst != std::wstring::npos)
{
std::wstring sHex;
inline ullong str_hash_for_switch(const wchar_t* const str)
{
return (str_is_correct(str) && (str_len(str) <= MAX_LEN)) ? str_hash(str, str_len(str)) : N_HASH;
}
const size_t posSecond = sRgbValue.find_first_of(L", )", posFirst);
short int nValue = std::stoi(sRgbValue.substr(posFirst, posSecond - posFirst));
if (nValue < 0)
sHex += L"00";
else if (nValue > 255)
sHex += L"ff";
else
{
do
{
sHex = cHex[nValue % 16] + sHex;
nValue /= 16;
}
while (nValue != 0);
}
if (sHex.length() < 2)
sHex = L"0" + sHex;
sValue += sHex;
posFirst = sRgbValue.find_first_of(L"01234567890", posSecond);
}
return sValue;
}
inline std::vector<unsigned short int> GetWeightSelector(const std::wstring& sSelector)
{
if (sSelector.empty())
return std::vector<unsigned short int>{0, 0, 0, 0};
std::vector<unsigned short int> arWeight = {0, 0, 0, 0};
std::wstring sReverseSelector = sSelector;
std::reverse(sReverseSelector.begin(), sReverseSelector.end());
const std::vector<std::wstring> arSelectors = NS_STATIC_FUNCTIONS::GetWordsWithSigns(sReverseSelector, L" .#:");
for (const std::wstring& sSel : arSelectors)
{
if (sSel == L"*")
++arWeight[3];
else if (sSel.rfind(L'#') != std::wstring::npos)
++arWeight[0];
else if (sSel.rfind(L':') != std::wstring::npos)
{
std::wstring sTemp(sSel);
sTemp.erase(std::remove_if(sTemp.begin(), sTemp.end(), [] (const wchar_t& wc) { return !std::iswalpha(wc);}));
// std::find(NSConstValues::arPseudoClasses.begin(), NSConstValues::arPseudoClasses.end(), sTemp) != NSConstValues::arPseudoClasses.end() ? ++arWeight[1] : ++arWeight[2];
}
else if (sSel.find_last_of(L".[]") != std::wstring::npos)
++arWeight[1];
else
++arWeight[2];
}
return arWeight;
}
inline bool IsTrue(const std::vector<bool> arValues)
{
for (const bool bValue : arValues)
if (!bValue)
return false;
return true;
}
}
#define SWITCH(str) switch(SWITCH_CASE::str_hash_for_switch(str))
#define CASE(str) static_assert(SWITCH_CASE::str_is_correct(str) && (SWITCH_CASE::str_len(str) <= SWITCH_CASE::MAX_LEN),\
"CASE string contains wrong characters, or its length is greater than 9");\
case SWITCH_CASE::str_hash(str, SWITCH_CASE::str_len(str))
#define DEFAULT default
namespace SWITCH_CASE
{
typedef unsigned long long ullong;
const unsigned int MAX_LEN = 32;
const ullong N_HASH = static_cast<ullong>(-1);
constexpr ullong raise_128_to(const wchar_t power)
{
return (1ULL << 7) * power;
}
constexpr bool str_is_correct(const wchar_t* const str)
{
return (static_cast<wchar_t>(*str) > 0) ? str_is_correct(str + 1) : (*str ? false : true);
}
constexpr unsigned int str_len(const wchar_t* const str)
{
return *str ? (1 + str_len(str + 1)) : 0;
}
constexpr ullong str_hash(const wchar_t* const str, const wchar_t current_len)
{
return *str ? (raise_128_to(current_len - 1) * static_cast<wchar_t>(*str) + str_hash(str + 1, current_len - 1)) : 0;
}
inline ullong str_hash_for_switch(const wchar_t* const str)
{
return (str_is_correct(str) && (str_len(str) <= MAX_LEN)) ? str_hash(str, str_len(str)) : N_HASH;
}
inline ullong str_hash_for_switch(const std::wstring& str)
{
return (str_is_correct(str.c_str()) && (str.length() <= MAX_LEN)) ? str_hash(str.c_str(), str.length()) : N_HASH;
}
}
inline ullong str_hash_for_switch(const std::wstring& str)
{
return (str_is_correct(str.c_str()) && (str.length() <= MAX_LEN)) ? str_hash(str.c_str(), str.length()) : N_HASH;
}
}
}
#endif // STATICFUNCTIONS_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,636 @@
#ifndef STYLEPROPERTIES_H
#define STYLEPROPERTIES_H
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include "../../../../DesktopEditor/graphics/Matrix.h"
#include "CUnitMeasureConverter.h"
namespace NSCSS
{
namespace NSProperties
{
template<typename T>
class CValue
{
friend class CString;
friend class CMatrix;
friend class CDigit;
friend class CColor;
friend class CEnum;
T m_oValue;
unsigned int m_unLevel;
bool m_bImportant;
public:
CValue(const T& oValue, unsigned int unLevel, bool bImportant) :
m_oValue(oValue), m_unLevel(unLevel), m_bImportant(bImportant)
{
}
virtual bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) = 0;
virtual bool Empty() const = 0;
virtual void Clear() = 0;
virtual int ToInt() const = 0;
virtual double ToDouble() const = 0;
virtual std::wstring ToWString() const = 0;
static void Equation(CValue &oFirstValue, CValue &oSecondValue)
{
if (oFirstValue.m_bImportant && !oSecondValue.m_bImportant && oFirstValue.Empty())
oSecondValue.Clear();
else if (oSecondValue.m_bImportant && !oFirstValue.m_bImportant && !oSecondValue.Empty())
oFirstValue.Clear();
else if (!oSecondValue.Empty())
{
if (oFirstValue.m_unLevel < oSecondValue.m_unLevel)
oFirstValue.Clear();
else
oSecondValue.Clear();
}
}
bool operator==(const T& oValue) const { return m_oValue == oValue; }
bool operator>=(const T& oValue) const { return m_oValue >= oValue; }
bool operator<=(const T& oValue) const { return m_oValue <= oValue; }
bool operator> (const T& oValue) const { return m_oValue > oValue; }
bool operator< (const T& oValue) const { return m_oValue < oValue; }
virtual CValue& operator =(const CValue& oValue)
{
m_oValue = oValue.m_oValue;
m_unLevel = oValue.m_unLevel;
m_bImportant = oValue.m_bImportant;
return *this;
}
CValue& operator =(const T& oValue)
{
//m_oValue = oValue.m_oValue;
return *this;
}
CValue& operator+=(const CValue& oValue)
{
if (m_unLevel > oValue.m_unLevel || (m_bImportant && !oValue.m_bImportant) || oValue.Empty())
return *this;
m_oValue = oValue.m_oValue;
m_unLevel = std::max(m_unLevel, oValue.m_unLevel);
m_bImportant = std::max(m_bImportant, oValue.m_bImportant);
return *this;
}
bool operator==(const CValue& oValue) const
{
return m_oValue == oValue.m_oValue;
}
};
class CString : public CValue<std::wstring>
{
public:
CString();
CString(const std::wstring& wsValue, unsigned int unLevel, bool bImportant = false);
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
bool SetValue(const std::wstring& wsValue, const std::vector<std::wstring>& arValiableValues, unsigned int unLevel, bool bHardMode);
bool SetValue(const std::wstring& wsValue, const std::map<std::wstring, std::wstring>& arValiableValues, unsigned int unLevel, bool bHardMode);
bool Empty() const override;
void Clear() override;
int ToInt() const override;
double ToDouble() const override;
std::wstring ToWString() const override;
CString& operator+=(const CString& oString);
};
class CDigit : public CValue<double>
{
UnitMeasure m_enUnitMeasure;
double ConvertValue(double dPrevValue, UnitMeasure enUnitMeasure) const;
public:
CDigit();
CDigit(double dValue);
CDigit(double dValue, unsigned int unLevel, bool bImportant = false);
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
bool Empty() const override;
bool Zero() const;
void Clear() override;
int ToInt() const override;
double ToDouble() const override;
std::wstring ToWString() const override;
int ToInt(UnitMeasure enUnitMeasure, double dPrevValue = 0.) const;
double ToDouble(UnitMeasure enUnitMeasure, double dPrevValue = 0.) const;
std::wstring ToWString(UnitMeasure enUnitMeasure, double dPrevValue = 0.) const;
UnitMeasure GetUnitMeasure() const;
CDigit operator+(const CDigit& oDigit) const;
CDigit operator-(const CDigit& oDigit) const;
CDigit operator*(const CDigit& oDigit) const;
CDigit operator/(const CDigit& oDigit) const;
CDigit operator*(double dValue) const;
CDigit& operator+=(const CDigit& oDigit);
CDigit& operator-=(const CDigit& oDigit);
CDigit& operator+=(double dValue);
CDigit& operator-=(double dValue);
CDigit& operator*=(double dValue);
CDigit& operator/=(double dValue);
CDigit& operator =(double dValue);
};
struct TRGB
{
unsigned char uchRed;
unsigned char uchGreen;
unsigned char uchBlue;
bool Empty() const;
bool operator==(const TRGB& oRGB) const;
};
typedef enum
{
ColorEmpty,
ColorNone,
ColorRGB,
ColorHEX,
ColorUrl
} ColorType;
class Q_DECL_EXPORT CColorValue
{
public:
CColorValue();
CColorValue(const CColorValue& oColorValue);
~CColorValue();
void SetRGB(unsigned char uchR, unsigned char uchG, unsigned char uchB);
void SetRGB(const TRGB& oRGB);
void SetHEX(const std::wstring& wsValue);
void SetUrl(const std::wstring& wsValue);
void SetNone();
void Clear();
bool Empty() const;
ColorType m_enType;
void* m_pColor = NULL;
std::wstring GetColor() const;
bool operator==(const CColorValue& oColorValue) const;
CColorValue& operator= (const CColorValue& oColorValue);
};
class CColor : public CValue<CColorValue>
{
CDigit m_oOpacity;
static TRGB ConvertHEXtoRGB(const std::wstring& wsValue);
static std::wstring ConvertRGBtoHEX(const TRGB& oValue);
static std::wstring CutURL(const std::wstring& wsValue);
public:
CColor();
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
bool SetOpacity(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true);
bool Empty() const override;
void Clear() override;
ColorType GetType() const;
double GetOpacity() const;
int ToInt() const override;
double ToDouble() const override;
std::wstring ToWString() const override;
TRGB ToRGB() const;
};
typedef enum
{
TransformMatrix,
TransformTranslate,
TransformScale,
TransformRotate,
TransformNone
} TransformType;
typedef std::vector<std::pair<std::vector<double>, TransformType>> MatrixValues;
class CMatrix : public CValue<MatrixValues>
{
std::vector<std::wstring> CutTransforms(const std::wstring& wsValue) const;
public:
CMatrix();
CMatrix(const MatrixValues& oValue, unsigned int unLevel, bool bImportant = false);
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
bool SetMatrix(const Aggplus::CMatrix& oValue);
bool AddValue(const std::vector<double>& arValues, TransformType enType);
bool Empty() const override;
void Clear() override;
int ToInt() const override;
double ToDouble() const override;
std::wstring ToWString() const override;
Aggplus::CMatrix GetFinalValue(TransformType oWithoutType = TransformNone) const;
void ApplyTranform(Aggplus::CMatrix& oMatrix, Aggplus::MatrixOrder order = Aggplus::MatrixOrderPrepend) const;
bool operator==(const CMatrix& oMatrix) const;
};
class CEnum : public CValue<int>
{
std::map<std::wstring, int> m_mMap;
public:
CEnum();
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
void SetMapping(const std::map<std::wstring, int>& mMap);
bool Empty() const override;
void Clear() override;
CEnum &operator =(int nValue);
bool operator==(int nValue) const;
bool operator!=(int nValue) const;
int ToInt() const override;
private:
double ToDouble() const override;
std::wstring ToWString() const override;
};
// PROPERTIES
class CDisplay
{
public:
CDisplay();
static void Equation(CDisplay &oFirstDisplay, CDisplay &oSecondDisplay);
bool SetX (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetY (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool AddX (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool AddY (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetHeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetHAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetVAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetDisplay(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
const CDigit& GetX() const;
const CDigit& GetY() const;
const CDigit& GetWidth() const;
const CDigit& GetHeight() const;
const CString& GetHAlign() const;
const CString& GetVAlign() const;
const CString& GetDisplay() const;
bool Empty() const;
CDisplay& operator+=(const CDisplay& oDisplay);
bool operator==(const CDisplay& oDisplay) const;
private:
CDigit m_oX;
CDigit m_oY;
CDigit m_oWidth;
CDigit m_oHeight;
CString m_oHAlign;
CString m_oVAlign;
CString m_oDisplay;
};
class CStroke
{
public:
CStroke();
static void Equation(CStroke &oFirstStroke, CStroke &oSecondStroke);
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
const CColor& GetColor() const;
const CDigit& GetWidth() const;
bool Empty() const;
CStroke& operator+=(const CStroke& oStroke);
bool operator==(const CStroke& oStroke) const;
private:
CColor m_oColor;
CDigit m_oWidth;
};
class CBackground
{
public:
CBackground();
static void Equation(CBackground &oFirstBackground, CBackground &oSecondBackground);
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetBackground(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
void InBorder();
const CColor& GetColor() const;
bool IsInBorder() const;
bool Empty() const;
CBackground& operator =(const CBackground& oBackground);
CBackground& operator+=(const CBackground& oBackground);
bool operator==(const CBackground& oBackground) const;
private:
CColor m_oColor;
bool m_bInBorder;
};
class CTransform
{
public:
CTransform();
void Clear();
static void Equation(CTransform &oFirstTransform, CTransform &oSecondTransform);
bool SetMatrix(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetMatrix(const Aggplus::CMatrix &oMatrix);
const CMatrix& GetMatrix() const;
bool Empty() const;
CTransform& operator+=(const CTransform& oTransform);
bool operator==(const CTransform& oTransform) const;
private:
CMatrix m_oMatrix;
};
class CBorderSide
{
public:
CBorderSide();
static void Equation(CBorderSide &oFirstBorderSide, CBorderSide &oSecondBorderSide);
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
void Block();
void Unblock();
bool IsBlock() const;
const CDigit& GetWidth() const;
const CString& GetStyle() const;
const CColor& GetColor() const;
bool Empty() const;
CBorderSide& operator+=(const CBorderSide& oBorderSide);
bool operator==(const CBorderSide& oBorderSide) const;
private:
CDigit m_oWidth;
CString m_oStyle;
CColor m_oColor;
bool m_bBlock;
};
class CBorder
{
public:
CBorder();
static void Equation(CBorder &oFirstBorder, CBorder &oSecondBorder);
bool SetSides(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
//Left Side
bool SetLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyleLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
//Top Side
bool SetTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyleTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
//Right Side
bool SetRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyleRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
//Bottom Side
bool SetBottomSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyleBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
void Block();
void Unblock();
bool Empty() const;
bool EqualSides() const;
const CBorderSide& GetLeftBorder() const;
const CBorderSide& GetTopBorder() const;
const CBorderSide& GetRightBorder() const;
const CBorderSide& GetBottomBorder() const;
CBorder& operator+=(const CBorder& oBorder);
bool operator==(const CBorder& oBorder) const;
private:
CBorderSide m_oLeft;
CBorderSide m_oTop;
CBorderSide m_oRight;
CBorderSide m_oBottom;
};
class CTextDecorationLine
{
bool m_bUnderline;
bool m_bOverline;
bool m_bLineThrough;
public:
CTextDecorationLine();
bool Empty() const;
bool SetValue(const std::wstring& wsValue);
bool Underline() const;
bool Overline() const;
bool LineThrough() const;
CTextDecorationLine &operator+=(const CTextDecorationLine& oTextDecoration);
};
struct TTextDecoration
{
CTextDecorationLine m_oLine;
CString m_oStyle;
CColor m_oColor;
TTextDecoration& operator+=(const TTextDecoration& oTextDecoration);
};
class CText
{
public:
CText();
static void Equation(CText &oFirstText, CText &oSecondText);
bool SetIndent (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetDecoration(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
const CDigit& GetIndent() const;
const CString& GetAlign() const;
const TTextDecoration& GetDecoration() const;
const CColor& GetColor() const;
bool Empty() const;
bool Underline() const;
bool Overline() const;
bool LineThrough() const;
CText& operator+=(const CText& oText);
bool operator==(const CText& oText) const;
private:
TTextDecoration m_oDecoration;
CDigit m_oIndent;
CString m_oAlign;
CColor m_oColor;
};
class CIndent
{
public:
CIndent();
static void Equation(CIndent &oFirstMargin, CIndent &oSecondMargin);
void SetPermisson(bool bPermission);
bool AddValue (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool AddLeft (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool AddTop (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool AddRight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool AddBottom (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
const CDigit& GetLeft () const;
const CDigit& GetTop () const;
const CDigit& GetRight () const;
const CDigit& GetBottom() const;
bool Empty() const;
CIndent& operator+=(const CIndent& oMargin);
bool operator==(const CIndent& oMargin) const;
private:
bool AddValue(CDigit& oValue, const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
CDigit m_oLeft;
CDigit m_oTop;
CDigit m_oRight;
CDigit m_oBottom;
bool m_bPermission;
};
class CFont
{
public:
CFont();
static void Equation(CFont &oFirstFont, CFont &oSecondFont);
bool SetValue (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetSize (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetLineHeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetFamily (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetStretch (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyle (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetVariant (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool UpdateSize(double dSize);
void Clear();
bool Bold() const;
bool Italic() const;
const CDigit& GetSize() const;
const CDigit& GetLineHeight() const;
const CString& GetFamily() const;
const CString& GetStretch() const;
const CString& GetStyle() const;
const CString& GetVariant() const;
const CString& GetWeight() const;
bool Empty() const;
CFont& operator+=(const CFont& oFont);
bool operator==(const CFont& oFont) const;
private:
CDigit m_oSize;
CDigit m_oLineHeight;
CString m_oFamily;
//TODO:: возможно стоит перейти в слудующих переменных на enum
CString m_oStretch;
CString m_oStyle;
CString m_oVariant;
CString m_oWeight;
TTextDecoration m_oTextDecoration;
};
}
}
#endif // STYLEPROPERTIES_H

View File

@ -8,467 +8,488 @@
namespace NSCSS
{
CDocumentStyle::CDocumentStyle() : m_arStandardStyles({L"a", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6", L"h1-c",
L"h2-c", L"h3-c", L"h4-c", L"h5-c", L"h6-c", L"p-c", L"p", L"div-c", L"div", L"a-c"}) {}
CDocumentStyle::~CDocumentStyle()
{
m_arStandardStyles. clear();
m_arStyleUsed. clear();
m_arStandardStylesUsed.clear();
}
std::wstring CDocumentStyle::GetStyle() const
{
return m_sStyle;
}
std::wstring CDocumentStyle::GetIdAndClear()
{
std::wstring sId = m_sId;
Clear();
return sId;
}
void CDocumentStyle::Clear()
{
m_sId.clear();
m_sStyle.clear();
}
void CDocumentStyle::SetStyle(const std::wstring& sStyle)
{
if (sStyle.empty())
return;
m_sStyle = sStyle;
}
void CDocumentStyle::SetId (const std::wstring& sId)
{
if (sId.empty())
return;
m_sId = sId;
}
void CDocumentStyle::CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement)
{
if (arStandartedStyles.empty())
return;
std::vector<std::wstring> arStyles;
for (const std::wstring& sStyleName : arStandartedStyles)
{
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sStyleName) != m_arStandardStyles.end())
arStyles.push_back(sStyleName);
}
if (arStyles.empty())
return;
std::wstring sId;
for (std::vector<std::wstring>::const_reverse_iterator iStyleName = arStyles.rbegin(); iStyleName != arStyles.rend(); ++iStyleName)
{
sId += *iStyleName + L'+';
CXmlElement oTempElement;
CreateStandardStyle(*iStyleName, oTempElement);
if (std::find(m_arStandardStylesUsed.begin(), m_arStandardStylesUsed.end(), *iStyleName) == m_arStandardStylesUsed.end())
{
m_sStyle = oTempElement.GetStyle() + m_sStyle;
m_arStandardStylesUsed.push_back(*iStyleName);
}
oElement += oTempElement;
}
sId.pop_back();
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Name, sId);
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, sId);
}
void CDocumentStyle::CreateStandardStyle(const std::wstring& sNameStyle, CXmlElement& oElement)
{
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sNameStyle) != m_arStandardStyles.end())
oElement.CreateDefaultElement(sNameStyle);
}
void CDocumentStyle::ConvertStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle)
{
if (oStyle.GetId().empty())
return;
std::wstring sName = oStyle.GetId();
const size_t posPoint = sName.find(L'.');
if (posPoint != std::wstring::npos)
sName = sName.substr(0, posPoint);
else
{
const size_t posLattice = sName.find(L'#');
if (posLattice != std::wstring::npos)
sName = sName.substr(0, posLattice);
else
{
const size_t posDash = sName.find(L'-');
if (posDash != std::wstring::npos)
sName = sName.substr(0, posDash);
}
}
if (!bIsPStyle)
sName += L"-c";
CXmlElement oParentStyle;
std::vector<std::wstring> arParentsName = oStyle.GetParentsName();
if (!bIsPStyle)
for (std::wstring& sParentName : arParentsName)
sParentName += L"-c";
if (!arParentsName.empty())
{
CombineStandardStyles(arParentsName, oParentStyle);
if (!oParentStyle.Empty())
{
oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, L"(" + oParentStyle.GetStyleId() + L")");
if (!bIsPStyle)
{
oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, oParentStyle.GetStyleId() + L"-c");
oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Type, L"character");
}
}
}
CXmlElement oStandardXmlElement;
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sName) != m_arStandardStyles.end())
CreateStandardStyle(sName, oStandardXmlElement);
if (oStandardXmlElement.Empty() && !oParentStyle.Empty())
{
const std::wstring sParentsStyleID = oParentStyle.GetStyleId();
if (std::find(m_arStandardStylesUsed.begin(), m_arStandardStylesUsed.end(), sParentsStyleID) == m_arStandardStylesUsed.end())
{
if (bIsPStyle)
{
oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
m_sStyle += oParentStyle.GetPStyle();
}
else
m_sStyle += oParentStyle.GetRStyle();
m_arStandardStylesUsed.push_back(sParentsStyleID);
}
if (oStyle.Empty())
{
m_sId = sParentsStyleID;
return;
}
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sParentsStyleID);
}
else if (!oStandardXmlElement.Empty() && !oParentStyle.Empty())
{
std::wstring sStandPlusParent = oStandardXmlElement.GetStyleId() + L"+" + oParentStyle.GetStyleId();
if(std::find(m_arStandardStylesUsed.begin(), m_arStandardStylesUsed.end(), sStandPlusParent) != m_arStandardStylesUsed.end())
{
if (oStyle.Empty())
{
m_sId = sStandPlusParent;
return;
}
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sStandPlusParent);
}
else
{
CXmlElement oTempElement = oParentStyle;
oTempElement += oStandardXmlElement;
oTempElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, sStandPlusParent);
if (bIsPStyle)
{
oTempElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
m_sStyle += oTempElement.GetPStyle();
}
else
m_sStyle += oTempElement.GetRStyle();
m_arStandardStylesUsed.push_back(sStandPlusParent);
if (oStyle.Empty())
{
m_sId = sStandPlusParent;
return;
}
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, oTempElement.GetStyleId());
}
}
else if (!oStandardXmlElement.Empty() && oParentStyle.Empty())
{
std::wstring sStandartStyleID = oStandardXmlElement.GetStyleId();
if (std::find(m_arStandardStylesUsed.begin(), m_arStandardStylesUsed.end(), sStandartStyleID) == m_arStandardStylesUsed.end())
{
if (bIsPStyle)
{
oStandardXmlElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
m_sStyle += oStandardXmlElement.GetPStyle();
}
else
m_sStyle += oStandardXmlElement.GetRStyle();
m_arStandardStylesUsed.push_back(sStandartStyleID);
}
if (oStyle.Empty())
{
m_sId = sStandartStyleID;
return;
}
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sStandartStyleID);
}
if (oStyle.Empty() && oElement.Empty())
{
m_sId = L"normal";
return;
}
m_sId = oStyle.GetId();
if(!bIsPStyle)
m_sId += L"-c";
else
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, m_sId);
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Name, m_sId);
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Type, bIsPStyle ? L"paragraph" : L"character");
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1");
}
void CDocumentStyle::SetPStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement)
{
ConvertStyle(oStyle, oXmlElement, true);
if (oStyle.Empty() && oXmlElement.Empty())
return;
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Jc, oStyle.m_pText.GetAlign());
std::wstring sInfValue;
sInfValue.reserve(64);
if (!oStyle.m_pMargin.Empty() && oStyle.m_pMargin.GetPermission())
{
const std::wstring& sLeftSide = oStyle.m_pMargin.GetLeftSideW();
const std::wstring& sRightSide = oStyle.m_pMargin.GetRightSideW();
if (!sLeftSide.empty())
sInfValue += L"w:left=\"" + sLeftSide + L"\" ";
if (!sRightSide.empty())
sInfValue += L"w:right=\"" + sRightSide + L"\" ";
}
const std::wstring& sIndent = oStyle.m_pText.GetIndentW();
if (!sIndent.empty())
sInfValue += L"w:firstLine=\"" + sIndent + L"\" ";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Ind, sInfValue);
std::wstring sSpacingValue;
sSpacingValue.reserve(128);
if (!oStyle.m_pMargin.Empty() && oStyle.m_pMargin.GetPermission())
{
sSpacingValue += L"w:afterAutospacing=\"1\" w:after=\"" + oStyle.m_pMargin.GetTopSideW() + L"\" ";
sSpacingValue += L"w:beforeAutospacing=\"1\" w:before=\"" + oStyle.m_pMargin.GetTopSideW() + L"\" ";
}
else/* if (!oStyle.m_pBorder.Empty() || !oStyle.m_pMargin.GetPermission())*/
sSpacingValue += L"w:after=\"0\" w:before=\"0\"";
const std::wstring &sLineHeight = oStyle.m_pFont.GetLineHeight();
if (!sLineHeight.empty())
{
sSpacingValue += L" w:line=\"" + sLineHeight + L"\" w:lineRule=\"auto\"";
}
else if (!oStyle.m_pBorder.Empty())
{
sSpacingValue += L" w:line=\"" + std::to_wstring(static_cast<short int>(oStyle.m_pFont.GetSize() * 12 + 0.5f)) + L"\" w:lineRule=\"auto\"";
}
else if (!oStyle.m_pBorder.Empty())
sSpacingValue += L"w:line=\"240\" w:lineRule=\"auto\" ";
if (!sSpacingValue.empty())
{
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Spacing, sSpacingValue);
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_ContextualSpacing, L"true");
}
if (!oStyle.m_pBackground.Empty())
{
const std::wstring wsColor = oStyle.m_pBackground.GetColorHex();
if (wsColor != L"ffffff")
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Shd, wsColor);
}
if (!oStyle.m_pBorder.Empty())
{
if (oStyle.m_pBorder.EqualSides())
{
const std::wstring sBorderColor = oStyle.m_pBorder.GetColorBottomSide();
const std::wstring sBorderStyle = oStyle.m_pBorder.GetStyleBottomSide();
const std::wstring sBorderWidth = oStyle.m_pBorder.GetWidthBottomSideW();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"0\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_TopBorder, sBorder);
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_LeftBorder, sBorder);
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_BottomBorder, sBorder);
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_RightBorder, sBorder);
}
else
{
if (!oStyle.m_pBorder.EmptyTopSide())
{
const std::wstring sBorderColor = oStyle.m_pBorder.GetColorTopSide();
const std::wstring sBorderStyle = oStyle.m_pBorder.GetStyleTopSide();
const std::wstring sBorderWidth = oStyle.m_pBorder.GetWidthTopSideW();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_TopBorder, sBorder);
}
if (!oStyle.m_pBorder.EmptyRightSide())
{
const std::wstring sBorderColor = oStyle.m_pBorder.GetColorRightSide();
const std::wstring sBorderStyle = oStyle.m_pBorder.GetStyleRightSide();
const std::wstring sBorderWidth = oStyle.m_pBorder.GetWidthRightSideW();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_RightBorder, sBorder);
}
if (!oStyle.m_pBorder.EmptyBottomSide())
{
const std::wstring sBorderColor = oStyle.m_pBorder.GetColorBottomSide();
const std::wstring sBorderStyle = oStyle.m_pBorder.GetStyleBottomSide();
const std::wstring sBorderWidth = oStyle.m_pBorder.GetWidthBottomSideW();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_BottomBorder, sBorder);
}
if (!oStyle.m_pBorder.EmptyLeftSide())
{
const std::wstring sBorderColor = oStyle.m_pBorder.GetColorLeftSide();
const std::wstring sBorderStyle = oStyle.m_pBorder.GetStyleLeftSide();
const std::wstring sBorderWidth = oStyle.m_pBorder.GetWidthLeftSideW();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_LeftBorder, sBorder);
}
}
}
}
void CDocumentStyle::SetRStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement)
{
ConvertStyle(oStyle, oXmlElement, false);
if (oStyle.Empty() && oXmlElement.Empty())
return;
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Highlight, oStyle.m_pBackground.GetColor());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Color, oStyle.m_pText.GetColor());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_U, oStyle.m_pText.GetDecoration());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Sz, oStyle.m_pFont.GetSizeW());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_RFonts, oStyle.m_pFont.GetFamily());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_I, oStyle.m_pFont.GetStyle());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_B, oStyle.m_pFont.GetWeight());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_SmallCaps, oStyle.m_pFont.GetVariant());
}
void CDocumentStyle::WriteRStyle (const NSCSS::CCompiledStyle& oStyle)
{
if(oStyle.GetId().empty())
{
m_sId = L"normal";
return;
}
CStyleUsed structStyle(oStyle, false);
std::list<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
if (oItem != m_arStyleUsed.end())
{
m_sId = (*oItem).getId();
return;
}
CXmlElement oXmlElement;
SetRStyle(oStyle, oXmlElement);
if (!oStyle.Empty() || !oXmlElement.Empty())
{
structStyle.setId(oXmlElement.GetStyleId());
m_arStyleUsed.push_back(structStyle);
m_sStyle += oXmlElement.GetRStyle();
}
}
void CDocumentStyle::WriteLitePStyle(const CCompiledStyle &oStyle)
{
if (oStyle.Empty())
return;
CXmlElement oXmlElement;
SetPStyle(oStyle, oXmlElement);
if (!oXmlElement.Empty())
m_sStyle += oXmlElement.GetLitePStyle();
}
void CDocumentStyle::WriteLiteRStyle(const CCompiledStyle &oStyle)
{
if (oStyle.Empty())
return;
CXmlElement oXmlElement;
SetRStyle(oStyle, oXmlElement);
if (!oXmlElement.Empty())
m_sStyle += oXmlElement.GetLiteRStyle();
}
void CDocumentStyle::WritePStyle (const NSCSS::CCompiledStyle& oStyle)
{
if(oStyle.GetId().empty())
{
m_sId = L"normal";
return;
}
CStyleUsed structStyle(oStyle, true);
std::list<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
if (oItem != m_arStyleUsed.end())
{
m_sId = (*oItem).getId();
return;
}
CXmlElement oXmlElement;
SetPStyle(oStyle, oXmlElement);
if (!oStyle.Empty() || !oXmlElement.Empty())
{
structStyle.setId(oXmlElement.GetStyleId());
m_arStyleUsed.push_back(structStyle);
m_sStyle += oXmlElement.GetPStyle();
}
}
CStyleUsed::CStyleUsed(const CCompiledStyle &oStyle, bool bIsPStyle)
: m_oStyle(oStyle), m_bIsPStyle(bIsPStyle)
{}
bool CStyleUsed::operator==(const CStyleUsed &oUsedStyle) const
{
return (m_bIsPStyle == oUsedStyle.m_bIsPStyle) && (m_oStyle == oUsedStyle.m_oStyle);
}
std::wstring CStyleUsed::getId()
{
return m_sId;
}
void CStyleUsed::setId(const std::wstring &sId)
{
m_sId = sId;
}
CDocumentStyle::CDocumentStyle() : m_arStandardStyles({L"a", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6", L"h1-c",
L"h2-c", L"h3-c", L"h4-c", L"h5-c", L"h6-c", L"p-c", L"p", L"div-c", L"div", L"a-c"}) {}
CDocumentStyle::~CDocumentStyle()
{
m_arStandardStyles. clear();
m_arStyleUsed. clear();
m_arStandardStylesUsed.clear();
}
std::wstring CDocumentStyle::GetStyle() const
{
return m_sStyle;
}
std::wstring CDocumentStyle::GetIdAndClear()
{
std::wstring sId = m_sId;
Clear();
return sId;
}
void CDocumentStyle::Clear()
{
m_sId.clear();
m_sStyle.clear();
}
void CDocumentStyle::SetStyle(const std::wstring& sStyle)
{
if (sStyle.empty())
return;
m_sStyle = sStyle;
}
void CDocumentStyle::SetId (const std::wstring& sId)
{
if (sId.empty())
return;
m_sId = sId;
}
void CDocumentStyle::CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement)
{
if (arStandartedStyles.empty())
return;
std::vector<std::wstring> arStyles;
for (const std::wstring& sStyleName : arStandartedStyles)
{
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sStyleName) != m_arStandardStyles.end())
arStyles.push_back(sStyleName);
}
if (arStyles.empty())
return;
std::wstring sId;
for (std::vector<std::wstring>::const_reverse_iterator iStyleName = arStyles.rbegin(); iStyleName != arStyles.rend(); ++iStyleName)
{
sId += *iStyleName + L'+';
CXmlElement oTempElement;
CreateStandardStyle(*iStyleName, oTempElement);
if (std::find(m_arStandardStylesUsed.begin(), m_arStandardStylesUsed.end(), *iStyleName) == m_arStandardStylesUsed.end())
{
m_sStyle = oTempElement.GetStyle() + m_sStyle;
m_arStandardStylesUsed.push_back(*iStyleName);
}
oElement += oTempElement;
}
sId.pop_back();
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Name, sId);
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, sId);
}
void CDocumentStyle::CreateStandardStyle(const std::wstring& sNameStyle, CXmlElement& oElement)
{
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sNameStyle) != m_arStandardStyles.end())
oElement.CreateDefaultElement(sNameStyle);
}
void CDocumentStyle::ConvertStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle)
{
if (oStyle.GetId().empty())
return;
std::wstring sName = oStyle.GetId();
const size_t posPoint = sName.find(L'.');
if (posPoint != std::wstring::npos)
sName = sName.substr(0, posPoint);
else
{
const size_t posLattice = sName.find(L'#');
if (posLattice != std::wstring::npos)
sName = sName.substr(0, posLattice);
else
{
const size_t posDash = sName.find(L'-');
if (posDash != std::wstring::npos)
sName = sName.substr(0, posDash);
}
}
if (!bIsPStyle)
sName += L"-c";
CXmlElement oParentStyle;
std::vector<std::wstring> arParentsName = oStyle.GetParentsName();
if (!bIsPStyle)
for (std::wstring& sParentName : arParentsName)
sParentName += L"-c";
if (!arParentsName.empty())
{
CombineStandardStyles(arParentsName, oParentStyle);
if (!oParentStyle.Empty())
{
oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, L"(" + oParentStyle.GetStyleId() + L")");
if (!bIsPStyle)
{
oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, oParentStyle.GetStyleId() + L"-c");
oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Type, L"character");
}
}
}
CXmlElement oStandardXmlElement;
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sName) != m_arStandardStyles.end())
CreateStandardStyle(sName, oStandardXmlElement);
if (oStandardXmlElement.Empty() && !oParentStyle.Empty())
{
const std::wstring sParentsStyleID = oParentStyle.GetStyleId();
if (std::find(m_arStandardStylesUsed.begin(), m_arStandardStylesUsed.end(), sParentsStyleID) == m_arStandardStylesUsed.end())
{
if (bIsPStyle)
{
oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
m_sStyle += oParentStyle.GetPStyle();
}
else
m_sStyle += oParentStyle.GetRStyle();
m_arStandardStylesUsed.push_back(sParentsStyleID);
}
if (oStyle.Empty())
{
m_sId = sParentsStyleID;
return;
}
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sParentsStyleID);
}
else if (!oStandardXmlElement.Empty() && !oParentStyle.Empty())
{
std::wstring sStandPlusParent = oStandardXmlElement.GetStyleId() + L"+" + oParentStyle.GetStyleId();
if(std::find(m_arStandardStylesUsed.begin(), m_arStandardStylesUsed.end(), sStandPlusParent) != m_arStandardStylesUsed.end())
{
if (oStyle.Empty())
{
m_sId = sStandPlusParent;
return;
}
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sStandPlusParent);
}
else
{
CXmlElement oTempElement = oParentStyle;
oTempElement += oStandardXmlElement;
oTempElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, sStandPlusParent);
if (bIsPStyle)
{
oTempElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
m_sStyle += oTempElement.GetPStyle();
}
else
m_sStyle += oTempElement.GetRStyle();
m_arStandardStylesUsed.push_back(sStandPlusParent);
if (oStyle.Empty())
{
m_sId = sStandPlusParent;
return;
}
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, oTempElement.GetStyleId());
}
}
else if (!oStandardXmlElement.Empty() && oParentStyle.Empty())
{
std::wstring sStandartStyleID = oStandardXmlElement.GetStyleId();
if (std::find(m_arStandardStylesUsed.begin(), m_arStandardStylesUsed.end(), sStandartStyleID) == m_arStandardStylesUsed.end())
{
if (bIsPStyle)
{
oStandardXmlElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
m_sStyle += oStandardXmlElement.GetPStyle();
}
else
m_sStyle += oStandardXmlElement.GetRStyle();
m_arStandardStylesUsed.push_back(sStandartStyleID);
}
if (oStyle.Empty())
{
m_sId = sStandartStyleID;
return;
}
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sStandartStyleID);
}
if (oStyle.Empty() && oElement.Empty())
{
m_sId = L"normal";
return;
}
m_sId = oStyle.GetId();
if(!bIsPStyle)
m_sId += L"-c";
else
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true");
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, m_sId);
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Name, m_sId);
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Type, bIsPStyle ? L"paragraph" : L"character");
oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1");
}
void CDocumentStyle::SetPStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement)
{
ConvertStyle(oStyle, oXmlElement, true);
if (oStyle.Empty() && oXmlElement.Empty())
return;
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Jc, oStyle.m_oText.GetAlign().ToWString());
std::wstring sInfValue;
sInfValue.reserve(64);
//TODO:: проверить Permission в Margin
if (!oStyle.m_oMargin.Empty() || !oStyle.m_oPadding.Empty() /*&& oStyle.m_oMargin.GetPermission()*/)
{
const std::wstring& sLeftSide = (oStyle.m_oMargin.GetLeft() + oStyle.m_oPadding.GetLeft()) .ToWString();
const std::wstring& sRightSide = (oStyle.m_oMargin.GetRight() + oStyle.m_oPadding.GetRight()).ToWString();
if (!sLeftSide.empty())
sInfValue += L"w:left=\"" + sLeftSide + L"\" ";
if (!sRightSide.empty())
sInfValue += L"w:right=\"" + sRightSide + L"\" ";
}
const std::wstring& sIndent = oStyle.m_oText.GetIndent().ToWString();
if (!sIndent.empty())
sInfValue += L"w:firstLine=\"" + sIndent + L"\" ";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Ind, sInfValue);
std::wstring sSpacingValue;
sSpacingValue.reserve(128);
//TODO:: проверить Permission в Margin
if (!oStyle.m_oMargin.Empty() || !oStyle.m_oPadding.Empty() /*&& oStyle.m_oMargin.GetPermission()*/)
{
sSpacingValue += L"w:afterAutospacing=\"1\" w:after=\"" + (oStyle.m_oMargin.GetBottom() + oStyle.m_oPadding.GetBottom()).ToWString() + L"\" ";
sSpacingValue += L"w:beforeAutospacing=\"1\" w:before=\"" + (oStyle.m_oMargin.GetTop() + oStyle.m_oPadding.GetTop()) .ToWString() + L"\" ";
}
else/* if (!oStyle.m_pBorder.Empty() || !oStyle.m_oMargin.GetPermission())*/
sSpacingValue += L"w:after=\"0\" w:before=\"0\"";
const std::wstring &sLineHeight = oStyle.m_oFont.GetLineHeight().ToWString();
if (!sLineHeight.empty())
{
sSpacingValue += L" w:line=\"" + sLineHeight + L"\" w:lineRule=\"auto\"";
}
else if (!oStyle.m_oBorder.Empty())
{
sSpacingValue += L" w:line=\"" + std::to_wstring(static_cast<short int>(oStyle.m_oFont.GetSize().ToDouble() * 12 + 0.5f)) + L"\" w:lineRule=\"auto\"";
}
else if (!oStyle.m_oBorder.Empty())
sSpacingValue += L"w:line=\"240\" w:lineRule=\"auto\" ";
if (!sSpacingValue.empty())
{
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Spacing, sSpacingValue);
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_ContextualSpacing, L"true");
}
if (!oStyle.m_oBackground.Empty())
{
const std::wstring wsColor = oStyle.m_oBackground.GetColor().ToWString();
if (wsColor != L"ffffff")
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Shd, wsColor);
}
if (!oStyle.m_oBorder.Empty())
{
if (oStyle.m_oBorder.EqualSides())
{
const std::wstring sBorderColor = oStyle.m_oBorder.GetLeftBorder().GetColor().ToWString();
const std::wstring sBorderStyle = oStyle.m_oBorder.GetLeftBorder().GetStyle().ToWString();
const std::wstring sBorderWidth = oStyle.m_oBorder.GetLeftBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"0\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_TopBorder, sBorder);
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_LeftBorder, sBorder);
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_BottomBorder, sBorder);
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_RightBorder, sBorder);
}
else
{
if (!oStyle.m_oBorder.GetTopBorder().Empty())
{
const std::wstring sBorderColor = oStyle.m_oBorder.GetTopBorder().GetColor().ToWString();
const std::wstring sBorderStyle = oStyle.m_oBorder.GetTopBorder().GetStyle().ToWString();
const std::wstring sBorderWidth = oStyle.m_oBorder.GetTopBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_TopBorder, sBorder);
}
if (!oStyle.m_oBorder.GetRightBorder().Empty())
{
const std::wstring sBorderColor = oStyle.m_oBorder.GetRightBorder().GetColor().ToWString();
const std::wstring sBorderStyle = oStyle.m_oBorder.GetRightBorder().GetStyle().ToWString();
const std::wstring sBorderWidth = oStyle.m_oBorder.GetRightBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_RightBorder, sBorder);
}
if (!oStyle.m_oBorder.GetBottomBorder().Empty())
{
const std::wstring sBorderColor = oStyle.m_oBorder.GetBottomBorder().GetColor().ToWString();
const std::wstring sBorderStyle = oStyle.m_oBorder.GetBottomBorder().GetStyle().ToWString();
const std::wstring sBorderWidth = oStyle.m_oBorder.GetBottomBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_BottomBorder, sBorder);
}
if (!oStyle.m_oBorder.GetLeftBorder().Empty())
{
const std::wstring sBorderColor = oStyle.m_oBorder.GetLeftBorder().GetColor().ToWString();
const std::wstring sBorderStyle = oStyle.m_oBorder.GetLeftBorder().GetStyle().ToWString();
const std::wstring sBorderWidth = oStyle.m_oBorder.GetLeftBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_LeftBorder, sBorder);
}
}
}
}
void CDocumentStyle::SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement)
{
ConvertStyle(oStyle, oXmlElement, false);
if (oStyle.Empty() && oXmlElement.Empty())
return;
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Highlight, oStyle.m_oBackground.GetColor().ToWString());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Color, oStyle.m_oText.GetColor().ToWString());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_U, (oStyle.m_oText.GetDecoration().m_oLine.Underline()) ? L"underline" : L"");
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Sz, oStyle.m_oFont.GetSize().ToWString());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_RFonts, oStyle.m_oFont.GetFamily().ToWString());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_I, oStyle.m_oFont.GetStyle().ToWString());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_B, oStyle.m_oFont.GetWeight().ToWString());
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_SmallCaps, oStyle.m_oFont.GetVariant().ToWString());
}
void CDocumentStyle::WriteRStyle (const NSCSS::CCompiledStyle& oStyle)
{
if(oStyle.GetId().empty())
{
m_sId = L"normal";
return;
}
CStyleUsed structStyle(oStyle, false);
std::list<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
if (oItem != m_arStyleUsed.end())
{
m_sId = (*oItem).getId();
return;
}
CXmlElement oXmlElement;
SetRStyle(oStyle, oXmlElement);
if (!oStyle.Empty() || !oXmlElement.Empty())
{
structStyle.setId(oXmlElement.GetStyleId());
m_arStyleUsed.push_back(structStyle);
m_sStyle += oXmlElement.GetRStyle();
}
}
void CDocumentStyle::WriteLitePStyle(const CCompiledStyle &oStyle)
{
if (oStyle.Empty())
return;
CXmlElement oXmlElement;
SetPStyle(oStyle, oXmlElement);
if (!oXmlElement.Empty())
m_sStyle += oXmlElement.GetLitePStyle();
}
void CDocumentStyle::WriteLiteRStyle(const CCompiledStyle &oStyle)
{
if (oStyle.Empty())
return;
CXmlElement oXmlElement;
SetRStyle(oStyle, oXmlElement);
if (!oXmlElement.Empty())
m_sStyle += oXmlElement.GetLiteRStyle();
}
void CDocumentStyle::WritePStyle (const NSCSS::CCompiledStyle& oStyle)
{
if(oStyle.GetId().empty())
{
m_sId = L"normal";
return;
}
CStyleUsed structStyle(oStyle, true);
std::list<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
if (oItem != m_arStyleUsed.end())
{
m_sId = (*oItem).getId();
return;
}
CXmlElement oXmlElement;
SetPStyle(oStyle, oXmlElement);
if (!oStyle.Empty() || !oXmlElement.Empty())
{
structStyle.setId(oXmlElement.GetStyleId());
m_arStyleUsed.push_back(structStyle);
m_sStyle += oXmlElement.GetPStyle();
}
}
}

View File

@ -4,68 +4,57 @@
#include "../CssCalculator_global.h"
#include "../CCompiledStyle.h"
#include "CXmlElement.h"
#include <list>
#include <iostream>
namespace NSCSS
{
class CStyleUsed
{
CCompiledStyle m_oStyle;
bool m_bIsPStyle;
std::wstring m_sId;
class CStyleUsed
{
CCompiledStyle m_oStyle;
bool m_bIsPStyle;
std::wstring m_sId;
public:
CStyleUsed(const CCompiledStyle& oStyle, bool bIsPStyle) : m_oStyle(oStyle), m_bIsPStyle(bIsPStyle) {}
public:
CStyleUsed(const CCompiledStyle& oStyle, bool bIsPStyle);
bool operator==(const CStyleUsed& oUsedStyle) const
{
return (m_bIsPStyle == oUsedStyle.m_bIsPStyle) && (m_oStyle == oUsedStyle.m_oStyle);
}
bool operator==(const CStyleUsed& oUsedStyle) const;
std::wstring getId()
{
return m_sId;
}
std::wstring getId();
void setId(const std::wstring& sId);
};
void setId(const std::wstring& sId)
{
m_sId = sId;
}
class CSSCALCULATOR_EXPORT CDocumentStyle
{
std::list<std::wstring> m_arStandardStylesUsed;
std::list<std::wstring> m_arStandardStyles;
std::list<CStyleUsed> m_arStyleUsed;
};
std::wstring m_sStyle;
std::wstring m_sId;
class CSSCALCULATOR_EXPORT CDocumentStyle
{
std::list<std::wstring> m_arStandardStylesUsed;
std::list<std::wstring> m_arStandardStyles;
std::list<CStyleUsed> m_arStyleUsed;
void CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement);
void CreateStandardStyle (const std::wstring& sNameStyle, CXmlElement& oElement);
void ConvertStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle);
std::wstring m_sStyle;
std::wstring m_sId;
void SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement);
void SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement);
void CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement);
void CreateStandardStyle (const std::wstring& sNameStyle, CXmlElement& oElement);
void ConvertStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle);
public:
CDocumentStyle();
~CDocumentStyle();
void SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement);
void SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement);
void WritePStyle(const NSCSS::CCompiledStyle& oStyle);
void WriteRStyle(const NSCSS::CCompiledStyle& oStyle);
void WriteLitePStyle(const NSCSS::CCompiledStyle& oStyle);
void WriteLiteRStyle(const NSCSS::CCompiledStyle& oStyle);
public:
CDocumentStyle();
~CDocumentStyle();
void SetStyle(const std::wstring& sStyle);
void SetId (const std::wstring& sId);
void WritePStyle(const NSCSS::CCompiledStyle& oStyle);
void WriteRStyle(const NSCSS::CCompiledStyle& oStyle);
void WriteLitePStyle(const NSCSS::CCompiledStyle& oStyle);
void WriteLiteRStyle(const NSCSS::CCompiledStyle& oStyle);
std::wstring GetStyle() const;
std::wstring GetIdAndClear();
void SetStyle(const std::wstring& sStyle);
void SetId (const std::wstring& sId);
std::wstring GetStyle() const;
std::wstring GetIdAndClear();
void Clear();
};
void Clear();
};
}
#endif // CDOCUMENTSTYLE_H

File diff suppressed because it is too large Load Diff

View File

@ -4,44 +4,46 @@
#include <string>
#include <map>
#include "../ConstValues.h"
#include "list"
namespace { namespace CSSProperties = NSCSS::NSConstValues::NSProperties; }
class CXmlElement
{
std::map<NSCSS::NSConstValues::NSProperties::RunnerProperties, std::wstring> m_mRStyleValues;
std::map<NSCSS::NSConstValues::NSProperties::ParagraphProperties, std::wstring> m_mPStyleValues;
std::map<NSCSS::NSConstValues::NSProperties::BasicProperties, std::wstring> m_mBasicValues;
std::map<CSSProperties::RunnerProperties, std::wstring> m_mRStyleValues;
std::map<CSSProperties::ParagraphProperties, std::wstring> m_mPStyleValues;
std::map<CSSProperties::BasicProperties, std::wstring> m_mBasicValues;
std::wstring ConvertPStyle() const;
std::wstring ConvertRStyle() const;
std::wstring ConvertBasicInfoStyle() const;
std::wstring ConvertPStyle() const;
std::wstring ConvertRStyle() const;
std::wstring ConvertBasicInfoStyle() const;
public:
CXmlElement();
CXmlElement(const std::wstring& sNameDefaultElement);
~CXmlElement();
CXmlElement();
CXmlElement(const std::wstring& sNameDefaultElement);
~CXmlElement();
bool Empty() const;
bool Empty() const;
void CreateDefaultElement(const std::wstring& sNameDefaultElement);
void Clear();
void CreateDefaultElement(const std::wstring& sNameDefaultElement);
void Clear();
void AddPropertiesInP (const NSCSS::NSConstValues::NSProperties::ParagraphProperties& nProperties, const std::wstring& sValue);
void AddPropertiesInR (const NSCSS::NSConstValues::NSProperties::RunnerProperties& nProperties, const std::wstring& sValue);
void AddBasicProperties(const NSCSS::NSConstValues::NSProperties::BasicProperties& nProperties, const std::wstring& sValue);
void AddPropertiesInP (const CSSProperties::ParagraphProperties& enProperties, const std::wstring& sValue);
void AddPropertiesInR (const CSSProperties::RunnerProperties& enProperties, const std::wstring& sValue);
void AddBasicProperties(const CSSProperties::BasicProperties& enProperties, const std::wstring& sValue);
std::wstring GetLitePStyle() const;
std::wstring GetLiteRStyle() const;
std::wstring GetPStyle() const;
std::wstring GetRStyle() const;
std::wstring GetStyle() const;
std::wstring GetBasedOn() const;
std::wstring GetStyleId() const;
std::wstring GetName() const;
std::wstring GetLitePStyle() const;
std::wstring GetLiteRStyle() const;
std::wstring GetPStyle() const;
std::wstring GetRStyle() const;
std::wstring GetStyle() const;
std::wstring GetBasedOn() const;
std::wstring GetStyleId() const;
std::wstring GetName() const;
CXmlElement& operator+=(const CXmlElement& oElement);
CXmlElement& operator= (const CXmlElement& oelement);
bool operator== (const CXmlElement& oElement);
CXmlElement& operator+=(const CXmlElement& oElement);
CXmlElement& operator= (const CXmlElement& oelement);
bool operator== (const CXmlElement& oElement);
};
#endif // CXMLELEMENT_H

View File

@ -21,8 +21,8 @@ if not base.is_dir("katana-parser"):
base.cmd_in_dir("katana-parser", "git", ["checkout", "be6df458d4540eee375c513958dcb862a391cdd1"])
# fix katana
base.replaceInFile(base_directory + "/katana-parser/src/tokenizer.c", "static inline bool katana_is_html_space(char c);", "static inline bool2 katana_is_html_space(char c);")
base.replaceInFile(base_directory + "/katana-parser/src/tokenizer.c", "inline bool katana_is_html_space(char c)", "static inline bool katana_is_html_space(char c)")
base.replaceInFile(base_directory + "/katana-parser/src/tokenizer.c", "static inline bool2 katana_is_html_space(char c);", "static inline bool katana_is_html_space(char c);")
base.replaceInFile(base_directory + "/katana-parser/src/parser.c", "katanaget_text(parser->scanner)", "/*katanaget_text(parser->scanner)*/\"error\"")
base.replaceInFile(base_directory + "/katana-parser/src/parser.c", "#define KATANA_PARSER_STRING(literal) (KatanaParserString){", "#define KATANA_PARSER_STRING(literal) {")
base.replaceInFileUtf8(base_directory + "/katana-parser/src/tokenizer.c", "static inline bool katana_is_html_space(char c);", "static inline bool2 katana_is_html_space(char c);")
base.replaceInFileUtf8(base_directory + "/katana-parser/src/tokenizer.c", "inline bool katana_is_html_space(char c)", "static inline bool katana_is_html_space(char c)")
base.replaceInFileUtf8(base_directory + "/katana-parser/src/tokenizer.c", "static inline bool2 katana_is_html_space(char c);", "static inline bool katana_is_html_space(char c);")
base.replaceInFileUtf8(base_directory + "/katana-parser/src/parser.c", "katanaget_text(parser->scanner)", "/*katanaget_text(parser->scanner)*/\"error\"")
base.replaceInFileUtf8(base_directory + "/katana-parser/src/parser.c", "#define KATANA_PARSER_STRING(literal) (KatanaParserString){", "#define KATANA_PARSER_STRING(literal) {")

View File

@ -694,17 +694,14 @@ namespace NSOpenSSL
return key;
}
bool AES_Decrypt_desktop_GCM(const unsigned char* key, const std::string& input, std::string& output, const int header_offset)
bool AES_Decrypt_desktop_GCM(const unsigned char* key, const unsigned char* input, const int& input_len, CMemoryData& buffer)
{
unsigned char* input_ptr = NULL;
int input_ptr_len = 0;
bool bBase64 = NSFile::CBase64Converter::Decode(input.c_str() + header_offset, (int)input.length() - header_offset, input_ptr, input_ptr_len);
if (!bBase64)
return false;
const unsigned char* input_ptr = input;
int input_ptr_len = input_len;
unsigned char* iv_ptr = input_ptr;
unsigned char* tag_ptr = input_ptr + GCM_IV_LENGTH;
unsigned char* ciphertext_ptr = tag_ptr + GCM_TAG_LENGHT;
const unsigned char* iv_ptr = input_ptr;
const unsigned char* tag_ptr = input_ptr + GCM_IV_LENGTH;
const unsigned char* ciphertext_ptr = tag_ptr + GCM_TAG_LENGHT;
int ciphertext_len = input_ptr_len - (GCM_IV_LENGTH + GCM_TAG_LENGHT);
unsigned char* output_ptr = NULL;
int output_len = 0;
@ -729,7 +726,7 @@ namespace NSOpenSSL
if (!EVP_DecryptUpdate(ctx, output_ptr, &output_len, ciphertext_ptr, ciphertext_len))
goto end;
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, GCM_TAG_LENGHT, tag_ptr))
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, GCM_TAG_LENGHT, (void*)tag_ptr))
goto end;
if (EVP_DecryptFinal_ex(ctx, output_ptr + output_len, &final_len))
@ -739,24 +736,44 @@ namespace NSOpenSSL
}
end:
RELEASEARRAYOBJECTS(input_ptr);
if (ctx)
EVP_CIPHER_CTX_free(ctx);
if (bResult)
{
output = std::string((char*)output_ptr, output_len);
buffer.Data = output_ptr;
buffer.Size = output_len;
}
if (output_ptr)
else
openssl_free(output_ptr);
return bResult;
}
bool AES_Encrypt_desktop_GCM(const unsigned char* key, const std::string& input, std::string& output)
bool AES_Decrypt_desktop_GCM(const unsigned char* key, const std::string& input, std::string& output, const int header_offset)
{
const unsigned char* input_ptr = (const unsigned char*)input.c_str();
int input_len = (int)input.length();
unsigned char* input_ptr = NULL;
int input_ptr_len = 0;
bool bBase64 = NSFile::CBase64Converter::Decode(input.c_str() + header_offset, (int)input.length() - header_offset, input_ptr, input_ptr_len);
if (!bBase64)
return false;
CMemoryData oBuffer;
bool bResult = AES_Decrypt_desktop_GCM(key, input_ptr, input_ptr_len, oBuffer);
RELEASEARRAYOBJECTS(input_ptr);
if (bResult)
{
output = std::string((char*)oBuffer.Data, oBuffer.Size);
}
return bResult;
}
bool AES_Encrypt_desktop_GCM(const unsigned char* key, const unsigned char* input, const int& input_len, CMemoryData& buffer)
{
const unsigned char* input_ptr = input;
int output_buffer_all_offset = GCM_IV_LENGTH + GCM_TAG_LENGHT;
int output_buffer_len = input_len + output_buffer_all_offset;
@ -807,12 +824,29 @@ end:
if (ctx)
EVP_CIPHER_CTX_free(ctx);
if (bResult)
{
buffer.Data = output_ptr;
buffer.Size = (size_t)(ciphertext_len + output_buffer_all_offset);
}
else
{
openssl_free(output_ptr);
}
return bResult;
}
bool AES_Encrypt_desktop_GCM(const unsigned char* key, const std::string& input, std::string& output)
{
CMemoryData buffer;
bool bResult = AES_Encrypt_desktop_GCM(key, (const unsigned char*)input.c_str(), (int)input.length(), buffer);
if (bResult)
{
// header + base64
char* pDataDst = NULL;
int nDataDst = 0;
NSFile::CBase64Converter::Encode(output_ptr, ciphertext_len + output_buffer_all_offset, pDataDst, nDataDst, NSBase64::B64_BASE64_FLAG_NOCRLF);
NSFile::CBase64Converter::Encode(buffer.Data, (int)buffer.Size, pDataDst, nDataDst, NSBase64::B64_BASE64_FLAG_NOCRLF);
output = "";
output.reserve(g_aes_header.length() + (size_t)nDataDst + 1);
output.append(g_aes_header);
@ -820,9 +854,6 @@ end:
RELEASEARRAYOBJECTS(pDataDst);
}
if (output_ptr)
openssl_free(output_ptr);
return bResult;
}

View File

@ -110,8 +110,11 @@ namespace NSOpenSSL
// GCM
OPENSSL_DECL unsigned char* PBKDF2_desktop_GCM(const std::string& pass, const std::string& salt = "");
OPENSSL_DECL bool AES_Decrypt_desktop_GCM(const unsigned char* key, const unsigned char* input, const int& input_len, CMemoryData& buffer);
OPENSSL_DECL bool AES_Decrypt_desktop_GCM(const unsigned char* key, const std::string& input, std::string& output, const int header_offset = 0);
OPENSSL_DECL bool AES_Decrypt_desktop_GCM(const std::string& pass, const std::string& input, std::string& output, const std::string& salt = "", const int header_offset = 0);
OPENSSL_DECL bool AES_Encrypt_desktop_GCM(const unsigned char* key, const unsigned char* input, const int& input_len, CMemoryData& buffer);
OPENSSL_DECL bool AES_Encrypt_desktop_GCM(const unsigned char* key, const std::string& input, std::string& output);
OPENSSL_DECL bool AES_Encrypt_desktop_GCM(const std::string& pass, const std::string& input, std::string& output, const std::string& salt = "");
}

View File

@ -677,13 +677,13 @@ public:
}
};
static std::wstring msLCID2wstring(int id)
{
MS_LCID_converter lcid;
return lcid.get_wstring(id);
}
static int msLCID2DefCodePage(int id)
{
MS_LCID_converter lcid;
return lcid.get_codepage(id);
}
//static std::wstring msLCID2wstring(int id)
//{
// MS_LCID_converter lcid;
// return lcid.get_wstring(id);
//}
//static int msLCID2DefCodePage(int id)
//{
// MS_LCID_converter lcid;
// return lcid.get_codepage(id);
//}

View File

@ -1,9 +1,14 @@
HEADERS += \
$$PWD/include/FileTransporter.h \
$$PWD/include/manager.h \
$$PWD/src/FileTransporter_private.h \
$$PWD/src/transport_external.h
$$PWD/src/transport_external.h \
$$PWD/src/Session.h
SOURCES += $$PWD/src/FileTransporter.cpp
SOURCES += \
$$PWD/src/FileTransporter.cpp \
$$PWD/src/Session.cpp \
$$PWD/src/manager.cpp
core_windows {
SOURCES += $$PWD/src/FileTransporter_win.cpp
@ -31,9 +36,7 @@ core_mac {
}
core_ios {
OBJECTIVE_SOURCES += \
$$PWD/src/FileTransporter_mac.mm
OBJECTIVE_SOURCES += $$PWD/src/FileTransporter_mac.mm
LIBS += -framework Foundation
}

View File

@ -37,103 +37,121 @@
namespace NSNetwork
{
namespace NSFileTransport
{
//typedef void (*CFileTransporter_OnComplete)(int error);
// <return> cancel: 1, else 0
//typedef int (*CFileTransporter_OnProgress)(int percent);
namespace NSFileTransport
{
class CSession_private;
class KERNEL_DECL CSession
{
public:
CSession();
~CSession();
class KERNEL_DECL IFileTransporter
{
public:
IFileTransporter() {}
virtual ~IFileTransporter() {}
void SetProperty(const std::string& name, const std::string& value);
void Initialize();
public:
// thread
virtual void Start(int lPriority) = 0;
virtual int GetPriority() = 0;
virtual void Suspend() = 0;
virtual void Resume() = 0;
virtual void Stop() = 0;
virtual void StopNoJoin() = 0;
virtual void Cancel() = 0;
virtual int IsRunned() = 0;
public:
CSession_private* m_pInternal;
};
//events
virtual void SetEvent_OnProgress(std::function<void(int)>) = 0;
virtual void SetEvent_OnComplete(std::function<void(int)>) = 0;
};
class KERNEL_DECL IFileTransporter
{
public:
IFileTransporter() {}
virtual ~IFileTransporter() {}
public:
// manager must release. FileTransporter save link only
virtual void SetSession(CSession* session) = 0;
public:
// thread
virtual void Start(int lPriority) = 0;
virtual int GetPriority() = 0;
virtual void Suspend() = 0;
virtual void Resume() = 0;
virtual void Stop() = 0;
virtual void StopNoJoin() = 0;
virtual void Cancel() = 0;
virtual int IsRunned() = 0;
//events
virtual void SetEvent_OnProgress(std::function<void(int)>) = 0;
virtual void SetEvent_OnComplete(std::function<void(int)>) = 0;
};
#ifdef _MAC
KERNEL_DECL void SetARCEnabled(const bool& enabled);
KERNEL_DECL bool GetARCEnabled();
KERNEL_DECL void SetARCEnabled(const bool& enabled);
KERNEL_DECL bool GetARCEnabled();
#endif
class CFileTransporter_private;
class CFileTransporter_private;
class KERNEL_DECL CFileDownloader: public IFileTransporter
{
public:
CFileDownloader(std::wstring sFileUrl, bool bDelete = true);
virtual ~CFileDownloader();
class KERNEL_DECL CFileDownloader: public IFileTransporter
{
public:
CFileDownloader(std::wstring sFileUrl, bool bDelete = true);
virtual ~CFileDownloader();
void SetFilePath(const std::wstring& sFilePath);
std::wstring GetFilePath();
virtual void SetSession(CSession* session);
bool IsFileDownloaded();
void SetFilePath(const std::wstring& sFilePath);
std::wstring GetFilePath();
void SetFileUrl(const std::wstring &sFileUrl, bool bDelete = true);
bool IsFileDownloaded();
bool DownloadSync();
void DownloadAsync();
void SetFileUrl(const std::wstring &sFileUrl, bool bDelete = true);
public:
virtual void Start(int lPriority);
virtual int GetPriority();
virtual void Suspend();
virtual void Resume();
virtual void Stop();
virtual void StopNoJoin();
virtual void Cancel();
virtual int IsRunned();
virtual void SetEvent_OnProgress(std::function<void(int)>);
virtual void SetEvent_OnComplete(std::function<void(int)>);
bool DownloadSync();
void DownloadAsync();
private:
CFileTransporter_private* m_pInternal;
};
public:
virtual void Start(int lPriority);
virtual int GetPriority();
virtual void Suspend();
virtual void Resume();
virtual void Stop();
virtual void StopNoJoin();
virtual void Cancel();
virtual int IsRunned();
virtual void SetEvent_OnProgress(std::function<void(int)>);
virtual void SetEvent_OnComplete(std::function<void(int)>);
class KERNEL_DECL CFileUploader: public IFileTransporter
{
public:
CFileUploader(std::wstring sUrl, const unsigned char* cData, const int nSize);
CFileUploader(std::wstring sUrl, std::wstring sFilePath);
virtual ~CFileUploader();
private:
CFileTransporter_private* m_pInternal;
};
void SetUrl(const std::wstring& sUrl);
void SetBinaryData(const unsigned char* data, const int size);
void SetFilePath(const std::wstring &sFilePath);
class KERNEL_DECL CFileUploader: public IFileTransporter
{
public:
CFileUploader(std::wstring sUrl, const unsigned char* cData, const int nSize);
CFileUploader(std::wstring sUrl, std::wstring sFilePath);
virtual ~CFileUploader();
bool UploadSync();
void UploadAsync();
virtual void SetSession(CSession* session);
std::wstring GetResponse();
void SetUrl(const std::wstring& sUrl);
void SetBinaryData(const unsigned char* data, const int size);
void SetFilePath(const std::wstring &sFilePath);
public:
virtual void Start(int lPriority);
virtual int GetPriority();
virtual void Suspend();
virtual void Resume();
virtual void Stop();
virtual void StopNoJoin();
virtual void Cancel();
virtual int IsRunned();
virtual void SetEvent_OnProgress(std::function<void(int)>);
virtual void SetEvent_OnComplete(std::function<void(int)>);
bool UploadSync();
void UploadAsync();
private:
CFileTransporter_private* m_pInternal;
};
}
std::wstring GetResponse();
public:
virtual void Start(int lPriority);
virtual int GetPriority();
virtual void Suspend();
virtual void Resume();
virtual void Stop();
virtual void StopNoJoin();
virtual void Cancel();
virtual int IsRunned();
virtual void SetEvent_OnProgress(std::function<void(int)>);
virtual void SetEvent_OnComplete(std::function<void(int)>);
private:
CFileTransporter_private* m_pInternal;
};
}
}

View File

@ -0,0 +1,87 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef APPLICATION_DOWNLOAD_MANAGER_H
#define APPLICATION_DOWNLOAD_MANAGER_H
#include <string>
#include <functional>
#include "./FileTransporter.h"
namespace ASC
{
enum DownloadStatus
{
Error = 0,
Success = 1
};
class IDownloadTask
{
public:
IDownloadTask();
virtual ~IDownloadTask();
public:
virtual std::wstring GetPath() = 0;
virtual std::wstring GetUrl() = 0;
virtual DownloadStatus GetStatus() = 0;
};
class CDownloadManager_private;
class KERNEL_DECL CDownloadManager
{
public:
CDownloadManager();
~CDownloadManager();
public:
NSNetwork::NSFileTransport::CSession* GetSession();
void SetMaxConcurrentDownloadCount(const int& count);
void AddTask(const std::wstring& url,
const std::wstring& directory,
const std::wstring& filename,
void* observer,
std::function<void(IDownloadTask*)> handler);
void OnDestroyObserver(void* observer);
void Clear();
static bool DownloadExternal(const std::wstring& url, const std::wstring& path);
private:
CDownloadManager_private* m_internal;
};
}
#endif // APPLICATION_DOWNLOAD_MANAGER_H

View File

@ -33,150 +33,165 @@
#include "./FileTransporter_private.h"
#include "../include/FileTransporter.h"
#include "./Session.h"
namespace NSNetwork
{
namespace NSFileTransport
{
namespace NSFileTransport
{
#ifdef _MAC
bool m_bIsARCEnabled = false;
void SetARCEnabled(const bool& enabled)
{
m_bIsARCEnabled = enabled;
}
bool GetARCEnabled()
{
return m_bIsARCEnabled;
}
#ifdef _IOS
bool m_bIsARCEnabled = true;
#else
bool m_bIsARCEnabled = false;
#endif
}
void SetARCEnabled(const bool& enabled)
{
m_bIsARCEnabled = enabled;
}
bool GetARCEnabled()
{
return m_bIsARCEnabled;
}
#endif
}
}
namespace NSNetwork
{
namespace NSFileTransport
{
// DOWNLOADER
CFileDownloader::CFileDownloader(std::wstring sFileUrl, bool bDelete)
{
m_pInternal = new CFileTransporter_private(sFileUrl, bDelete);
}
CFileDownloader::~CFileDownloader()
{
Stop();
delete m_pInternal;
}
namespace NSFileTransport
{
// DOWNLOADER
CFileDownloader::CFileDownloader(std::wstring sFileUrl, bool bDelete)
{
m_pInternal = new CFileTransporter_private(sFileUrl, bDelete);
}
CFileDownloader::~CFileDownloader()
{
Stop();
delete m_pInternal;
}
void CFileDownloader::SetFilePath(const std::wstring &sFilePath)
{
m_pInternal->SetDownloadFilePath(sFilePath);
}
std::wstring CFileDownloader::GetFilePath()
{
return m_pInternal->GetDownloadFilePath();
}
void CFileDownloader::SetSession(CSession* session)
{
m_pInternal->SetSession(session);
}
bool CFileDownloader::IsFileDownloaded()
{
return m_pInternal->IsFileDownloaded();
}
void CFileDownloader::SetFilePath(const std::wstring &sFilePath)
{
m_pInternal->SetDownloadFilePath(sFilePath);
}
std::wstring CFileDownloader::GetFilePath()
{
return m_pInternal->GetDownloadFilePath();
}
void CFileDownloader::SetFileUrl(const std::wstring &sFileUrl, bool bDelete)
{
m_pInternal->SetDownloadFileUrl(sFileUrl, bDelete);
}
bool CFileDownloader::IsFileDownloaded()
{
return m_pInternal->IsFileDownloaded();
}
bool CFileDownloader::DownloadSync()
{
return m_pInternal->TransferSync();
}
void CFileDownloader::DownloadAsync()
{
m_pInternal->TransferAsync();
}
void CFileDownloader::SetFileUrl(const std::wstring &sFileUrl, bool bDelete)
{
m_pInternal->SetDownloadFileUrl(sFileUrl, bDelete);
}
void CFileDownloader::Start(int lPriority) { m_pInternal->Start(lPriority); }
int CFileDownloader::GetPriority() { return m_pInternal->GetPriority(); }
void CFileDownloader::Suspend() { m_pInternal->Suspend(); }
void CFileDownloader::Resume() { m_pInternal->Resume(); }
void CFileDownloader::Stop() { m_pInternal->Stop(); }
void CFileDownloader::StopNoJoin() { m_pInternal->StopNoJoin(); }
void CFileDownloader::Cancel() { m_pInternal->Cancel(); }
int CFileDownloader::IsRunned() { return m_pInternal->IsRunned(); }
bool CFileDownloader::DownloadSync()
{
return m_pInternal->TransferSync();
}
void CFileDownloader::DownloadAsync()
{
m_pInternal->TransferAsync();
}
void CFileDownloader::SetEvent_OnProgress(std::function<void(int)> func)
{
m_pInternal->GetInternal()->m_func_onProgress = func;
}
void CFileDownloader::SetEvent_OnComplete(std::function<void(int)> func)
{
m_pInternal->GetInternal()->m_func_onComplete = func;
}
}
void CFileDownloader::Start(int lPriority) { m_pInternal->Start(lPriority); }
int CFileDownloader::GetPriority() { return m_pInternal->GetPriority(); }
void CFileDownloader::Suspend() { m_pInternal->Suspend(); }
void CFileDownloader::Resume() { m_pInternal->Resume(); }
void CFileDownloader::Stop() { m_pInternal->Stop(); }
void CFileDownloader::StopNoJoin() { m_pInternal->StopNoJoin(); }
void CFileDownloader::Cancel() { m_pInternal->Cancel(); }
int CFileDownloader::IsRunned() { return m_pInternal->IsRunned(); }
void CFileDownloader::SetEvent_OnProgress(std::function<void(int)> func)
{
m_pInternal->GetInternal()->m_func_onProgress = func;
}
void CFileDownloader::SetEvent_OnComplete(std::function<void(int)> func)
{
m_pInternal->GetInternal()->m_func_onComplete = func;
}
}
}
namespace NSNetwork
{
namespace NSFileTransport
{
CFileUploader::CFileUploader(std::wstring sUrl, const unsigned char* cData, const int nSize)
{
m_pInternal = new CFileTransporter_private(sUrl, cData, nSize);
}
CFileUploader::CFileUploader(std::wstring sUrl, std::wstring sFilePath)
{
m_pInternal = new CFileTransporter_private(sUrl, sFilePath);
}
CFileUploader::~CFileUploader()
{
Stop();
delete m_pInternal;
}
namespace NSFileTransport
{
CFileUploader::CFileUploader(std::wstring sUrl, const unsigned char* cData, const int nSize)
{
m_pInternal = new CFileTransporter_private(sUrl, cData, nSize);
}
CFileUploader::CFileUploader(std::wstring sUrl, std::wstring sFilePath)
{
m_pInternal = new CFileTransporter_private(sUrl, sFilePath);
}
CFileUploader::~CFileUploader()
{
Stop();
delete m_pInternal;
}
void CFileUploader::SetUrl(const std::wstring& sUrl)
{
m_pInternal->SetUploadUrl(sUrl);
}
void CFileUploader::SetBinaryData(const unsigned char* data, const int size)
{
m_pInternal->SetUploadBinaryDara(data, size);
}
void CFileUploader::SetFilePath(const std::wstring &sFilePath)
{
m_pInternal->SetUploadFilePath(sFilePath);
}
void CFileUploader::SetSession(CSession* session)
{
m_pInternal->SetSession(session);
}
bool CFileUploader::UploadSync()
{
return m_pInternal->TransferSync();
}
void CFileUploader::UploadAsync()
{
m_pInternal->TransferAsync();
}
void CFileUploader::SetUrl(const std::wstring& sUrl)
{
m_pInternal->SetUploadUrl(sUrl);
}
void CFileUploader::SetBinaryData(const unsigned char* data, const int size)
{
m_pInternal->SetUploadBinaryDara(data, size);
}
void CFileUploader::SetFilePath(const std::wstring &sFilePath)
{
m_pInternal->SetUploadFilePath(sFilePath);
}
std::wstring CFileUploader::GetResponse()
{
return m_pInternal->GetResponse();
}
bool CFileUploader::UploadSync()
{
return m_pInternal->TransferSync();
}
void CFileUploader::UploadAsync()
{
m_pInternal->TransferAsync();
}
void CFileUploader::Start(int lPriority) { m_pInternal->Start(lPriority); }
int CFileUploader::GetPriority() { return m_pInternal->GetPriority(); }
void CFileUploader::Suspend() { m_pInternal->Suspend(); }
void CFileUploader::Resume() { m_pInternal->Resume(); }
void CFileUploader::Stop() { m_pInternal->Stop(); }
void CFileUploader::StopNoJoin() { m_pInternal->StopNoJoin(); }
void CFileUploader::Cancel() { m_pInternal->Cancel(); }
int CFileUploader::IsRunned() { return m_pInternal->IsRunned(); }
std::wstring CFileUploader::GetResponse()
{
return m_pInternal->GetResponse();
}
void CFileUploader::SetEvent_OnProgress(std::function<void(int)> func)
{
m_pInternal->GetInternal()->m_func_onProgress = func;
}
void CFileUploader::SetEvent_OnComplete(std::function<void(int)> func)
{
m_pInternal->GetInternal()->m_func_onComplete = func;
}
}
void CFileUploader::Start(int lPriority) { m_pInternal->Start(lPriority); }
int CFileUploader::GetPriority() { return m_pInternal->GetPriority(); }
void CFileUploader::Suspend() { m_pInternal->Suspend(); }
void CFileUploader::Resume() { m_pInternal->Resume(); }
void CFileUploader::Stop() { m_pInternal->Stop(); }
void CFileUploader::StopNoJoin() { m_pInternal->StopNoJoin(); }
void CFileUploader::Cancel() { m_pInternal->Cancel(); }
int CFileUploader::IsRunned() { return m_pInternal->IsRunned(); }
void CFileUploader::SetEvent_OnProgress(std::function<void(int)> func)
{
m_pInternal->GetInternal()->m_func_onProgress = func;
}
void CFileUploader::SetEvent_OnComplete(std::function<void(int)> func)
{
m_pInternal->GetInternal()->m_func_onComplete = func;
}
}
}

View File

@ -51,235 +51,235 @@
namespace NSNetwork
{
namespace NSFileTransport
{
class CFileTransporterBaseCURL : public CFileTransporterBase
{
public :
CFileTransporterBaseCURL(const std::wstring &sDownloadFileUrl, bool bDelete = true)
: CFileTransporterBase(sDownloadFileUrl, bDelete)
{
}
CFileTransporterBaseCURL(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
: CFileTransporterBase(sUploadUrl, cData, nSize)
{
}
CFileTransporterBaseCURL(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
: CFileTransporterBase(sUploadUrl, sUploadFilePath)
{
namespace NSFileTransport
{
class CFileTransporterBaseCURL : public CFileTransporterBase
{
public :
CFileTransporterBaseCURL(const std::wstring &sDownloadFileUrl, bool bDelete = true)
: CFileTransporterBase(sDownloadFileUrl, bDelete)
{
}
CFileTransporterBaseCURL(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
: CFileTransporterBase(sUploadUrl, cData, nSize)
{
}
CFileTransporterBaseCURL(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
: CFileTransporterBase(sUploadUrl, sUploadFilePath)
{
}
virtual ~CFileTransporterBaseCURL()
{
if (m_bDelete && !m_sDownloadFilePath.empty())
{
std::string sFilePath = U_TO_UTF8(m_sDownloadFilePath);
unlink(sFilePath.c_str());
}
}
}
virtual ~CFileTransporterBaseCURL()
{
if (m_bDelete && !m_sDownloadFilePath.empty())
{
std::string sFilePath = U_TO_UTF8(m_sDownloadFilePath);
unlink(sFilePath.c_str());
}
}
#ifndef USE_EXTERNAL_TRANSPORT
static size_t write_data(void *ptr, size_t size, size_t nmemb, int fd) {
size_t written = write(fd, ptr, size * nmemb);
return written;
}
#ifndef USE_EXTERNAL_TRANSPORT
static size_t write_data(void *ptr, size_t size, size_t nmemb, int fd) {
size_t written = write(fd, ptr, size * nmemb);
return written;
}
/*int progress_func(void* ptr, double TotalToDownload, double NowDownloaded, double TotalToUpload, double NowUploaded)
{
// It's here you will write the code for the progress message or bar
int percent = static_cast<int>((100.0 * NowDownloaded) / TotalToDownload);
/*int progress_func(void* ptr, double TotalToDownload, double NowDownloaded, double TotalToUpload, double NowUploaded)
{
// It's here you will write the code for the progress message or bar
int percent = static_cast<int>((100.0 * NowDownloaded) / TotalToDownload);
if(CFileTransporterBase::m_func_onProgress)
CFileTransporterBase::m_func_onProgress(percent);
return 0;
}
*/
if(CFileTransporterBase::m_func_onProgress)
CFileTransporterBase::m_func_onProgress(percent);
return 0;
}
*/
static size_t write_data_to_string(char *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
static size_t write_data_to_string(char *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
virtual int DownloadFile() override
{
CURL *curl;
int fp;
CURLcode res;
std::string sUrl = U_TO_UTF8(m_sDownloadFileUrl);
std::string sOut;
const char *url = sUrl.c_str();
curl = curl_easy_init();
if (curl)
{
fp = createUniqueTempFile(sOut);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
//curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
// Install the callback function
//curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_func);
#if defined(__linux__)
//в linux нет встроенных в систему корневых сертификатов, поэтому отключаем проверку
//http://curl.haxx.se/docs/sslcerts.html
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
#endif
/* tell libcurl to follow redirection(default false) */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* some servers don't like requests that are made without a user-agent field, so we provide one */
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0");
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
close(fp);
}
virtual int DownloadFile() override
{
CURL *curl;
int fp;
CURLcode res;
std::string sUrl = U_TO_UTF8(m_sDownloadFileUrl);
std::string sOut;
const char *url = sUrl.c_str();
curl = curl_easy_init();
if (curl)
{
fp = createUniqueTempFile(sOut);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
//curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
// Install the callback function
//curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_func);
#if defined(__linux__)
//в linux нет встроенных в систему корневых сертификатов, поэтому отключаем проверку
//http://curl.haxx.se/docs/sslcerts.html
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
#endif
/* tell libcurl to follow redirection(default false) */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* some servers don't like requests that are made without a user-agent field, so we provide one */
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0");
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
close(fp);
}
m_bComplete = (CURLE_OK == res);
if (m_bComplete)
{
if (m_sDownloadFilePath.empty())
m_sDownloadFilePath = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sOut.c_str(), sOut.length());
else
NSFile::CFileBinary::Move(UTF8_TO_U(sOut), m_sDownloadFilePath);
}
//int nRes = execl("/usr/bin/wget", stringWstingToUtf8String (m_sFileUrl).c_str(), "-P", stringWstingToUtf8String (m_sDownloadFilePath).c_str(), (char *)NULL);
//m_bComplete = nRes >= 0;
m_bComplete = (CURLE_OK == res);
if (m_bComplete)
{
if (m_sDownloadFilePath.empty())
m_sDownloadFilePath = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sOut.c_str(), sOut.length());
else
NSFile::CFileBinary::Move(UTF8_TO_U(sOut), m_sDownloadFilePath);
}
//int nRes = execl("/usr/bin/wget", stringWstingToUtf8String (m_sFileUrl).c_str(), "-P", stringWstingToUtf8String (m_sDownloadFilePath).c_str(), (char *)NULL);
//m_bComplete = nRes >= 0;
return m_bComplete ? 0 : 1;
}
return m_bComplete ? 0 : 1;
}
virtual int UploadData() override
{
CURL *curl;
CURLcode res;
std::string sUrl = U_TO_UTF8(m_sUploadUrl);
const char *url = sUrl.c_str();
struct curl_slist *headerlist = NULL;
std::string readBuffer;
virtual int UploadData() override
{
CURL *curl;
CURLcode res;
std::string sUrl = U_TO_UTF8(m_sUploadUrl);
const char *url = sUrl.c_str();
struct curl_slist *headerlist = NULL;
std::string readBuffer;
/* get a curl handle */
curl = curl_easy_init();
if(curl) {
/* get a curl handle */
curl = curl_easy_init();
if(curl) {
headerlist = curl_slist_append(headerlist, "Content-Type: application/octet-stream");
headerlist = curl_slist_append(headerlist, "Content-Type: application/octet-stream");
curl_easy_setopt(curl, CURLOPT_POST, true);
curl_easy_setopt(curl, CURLOPT_HEADER, true);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
/* First set the URL that is about to receive our POST. This URL can
just as well be a https:// URL if that is what should receive the
data. */
curl_easy_setopt(curl, CURLOPT_URL, url);
/* Now specify the POST data */
/* size of the POST data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, m_nSize);
/* binary data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, m_cData);
curl_easy_setopt(curl, CURLOPT_POST, true);
curl_easy_setopt(curl, CURLOPT_HEADER, true);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
/* First set the URL that is about to receive our POST. This URL can
just as well be a https:// URL if that is what should receive the
data. */
curl_easy_setopt(curl, CURLOPT_URL, url);
/* Now specify the POST data */
/* size of the POST data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, m_nSize);
/* binary data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, m_cData);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data_to_string);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data_to_string);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
#if defined(__linux__)
//в linux нет встроенных в систему корневых сертификатов, поэтому отключаем проверку
//http://curl.haxx.se/docs/sslcerts.html
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
#endif
#if defined(__linux__)
//в linux нет встроенных в систему корневых сертификатов, поэтому отключаем проверку
//http://curl.haxx.se/docs/sslcerts.html
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
#endif
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
long http_code = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
long http_code = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
if (res == CURLE_OK)
{
if (http_code == 200 || http_code == 1223)
{
size_t startLenghtPos = readBuffer.find("Content-Length:") + sizeof("Content-Length:");
size_t endLenghtPos = readBuffer.substr(startLenghtPos, readBuffer.length()).find("\r");
std::string dataSize = readBuffer.substr(startLenghtPos, endLenghtPos);
readBuffer = readBuffer.substr(readBuffer.length() - std::stoi(dataSize));
NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)readBuffer.c_str(), (LONG)readBuffer.length(), m_sResponse);
}
else
{
res = CURLE_HTTP_RETURNED_ERROR;
}
}
if (res == CURLE_OK)
{
if (http_code == 200 || http_code == 1223)
{
size_t startLenghtPos = readBuffer.find("Content-Length:") + sizeof("Content-Length:");
size_t endLenghtPos = readBuffer.substr(startLenghtPos, readBuffer.length()).find("\r");
std::string dataSize = readBuffer.substr(startLenghtPos, endLenghtPos);
readBuffer = readBuffer.substr(readBuffer.length() - std::stoi(dataSize));
NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)readBuffer.c_str(), (LONG)readBuffer.length(), m_sResponse);
}
else
{
res = CURLE_HTTP_RETURNED_ERROR;
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
m_bComplete = (CURLE_OK == res);
/* always cleanup */
curl_easy_cleanup(curl);
}
m_bComplete = (CURLE_OK == res);
return m_bComplete ? 0 : 1;
}
return m_bComplete ? 0 : 1;
}
virtual int UploadFile() override
{
//stub
return -1;
}
virtual int UploadFile() override
{
//stub
return -1;
}
protected:
int createUniqueTempFile (std::string &filename)
{
std::string sTempPath = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(NSDirectory::GetTempPath());
sTempPath += "/fileXXXXXX";
int fd = mkstemp(const_cast <char *> (sTempPath.c_str()));
if (-1 != fd)
filename = sTempPath;
return fd;
}
#else
virtual int DownloadFile() override
{
if (m_sDownloadFilePath.empty())
{
m_sDownloadFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSDirectory::GetTempPath(), L"DW");
if (NSFile::CFileBinary::Exists(m_sDownloadFilePath))
NSFile::CFileBinary::Remove(m_sDownloadFilePath);
}
return download_external(m_sDownloadFileUrl, m_sDownloadFilePath, m_func_onProgress, m_check_aborted);
}
virtual int UploadData() override
{
if (!m_sUploadUrl.empty() && m_cData != NULL && m_nSize != 0)
{
return uploaddata_external(m_sUploadUrl, m_cData, m_nSize);
}
return -1;
}
virtual int UploadFile() override
{
if (!m_sUploadUrl.empty() && !m_sUploadFilePath.empty())
{
return uploadfile_external(m_sUploadUrl, m_sUploadFilePath);
}
return -1;
}
protected:
int createUniqueTempFile (std::string &filename)
{
std::string sTempPath = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(NSDirectory::GetTempPath());
sTempPath += "/fileXXXXXX";
int fd = mkstemp(const_cast <char *> (sTempPath.c_str()));
if (-1 != fd)
filename = sTempPath;
return fd;
}
#else
virtual int DownloadFile() override
{
if (m_sDownloadFilePath.empty())
{
m_sDownloadFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSDirectory::GetTempPath(), L"DW");
if (NSFile::CFileBinary::Exists(m_sDownloadFilePath))
NSFile::CFileBinary::Remove(m_sDownloadFilePath);
}
return download_external(m_sDownloadFileUrl, m_sDownloadFilePath, m_func_onProgress, m_check_aborted);
}
virtual int UploadData() override
{
if (!m_sUploadUrl.empty() && m_cData != NULL && m_nSize != 0)
{
return uploaddata_external(m_sUploadUrl, m_cData, m_nSize);
}
return -1;
}
virtual int UploadFile() override
{
if (!m_sUploadUrl.empty() && !m_sUploadFilePath.empty())
{
return uploadfile_external(m_sUploadUrl, m_sUploadFilePath);
}
return -1;
}
#endif
};
#endif
};
CFileTransporter_private::CFileTransporter_private(const std::wstring &sDownloadFileUrl, bool bDelete)
: m_pInternal(new CFileTransporterBaseCURL(sDownloadFileUrl, bDelete))
CFileTransporter_private::CFileTransporter_private(const std::wstring &sDownloadFileUrl, bool bDelete)
: m_pInternal(new CFileTransporterBaseCURL(sDownloadFileUrl, bDelete))
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
: m_pInternal(new CFileTransporterBaseCURL(sUploadUrl, cData, nSize))
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
: m_pInternal(new CFileTransporterBaseCURL(sUploadUrl, cData, nSize))
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
: m_pInternal(new CFileTransporterBaseCURL(sUploadUrl, sUploadFilePath))
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
: m_pInternal(new CFileTransporterBaseCURL(sUploadUrl, sUploadFilePath))
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
}
}

View File

@ -32,141 +32,234 @@
#include "FileTransporter_private.h"
#include "../include/FileTransporter.h"
#include "Session.h"
#ifdef USE_EXTERNAL_TRANSPORT
#include "transport_external.h"
#endif
#if _IOS
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
#else
#include <Cocoa/Cocoa.h>
#include <Cocoa/Cocoa.h>
#endif
namespace NSNetwork
{
namespace NSFileTransport
{
static NSString* StringWToNSString ( const std::wstring& Str )
{
NSString* pString = [ [ NSString alloc ]
initWithBytes : (char*)Str.data()
length : Str.size() * sizeof(wchar_t)
encoding : CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE ) ];
return pString;
}
class CFileTransporterBaseCocoa : public CFileTransporterBase
{
public :
CFileTransporterBaseCocoa(const std::wstring &sDownloadFileUrl, bool bDelete = true)
: CFileTransporterBase(sDownloadFileUrl, bDelete)
{
}
CFileTransporterBaseCocoa(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
: CFileTransporterBase(sUploadUrl, cData, nSize)
{
}
CFileTransporterBaseCocoa(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
: CFileTransporterBase(sUploadUrl, sUploadFilePath)
{
namespace NSFileTransport
{
class CSessionMAC : public CSession_private
{
public:
NSURLSession* m_session;
}
virtual ~CFileTransporterBaseCocoa()
{
}
public:
CSessionMAC()
{
m_session = nil;
}
~CSessionMAC()
{
m_session = nil;
}
virtual int DownloadFile() override
{
if (m_sDownloadFilePath.empty())
{
m_sDownloadFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"DWD");
if (NSFile::CFileBinary::Exists(m_sDownloadFilePath))
NSFile::CFileBinary::Remove(m_sDownloadFilePath);
}
void Create()
{
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
#ifdef USE_EXTERNAL_TRANSPORT
int nExternalTransport = download_external(m_sDownloadFileUrl, m_sDownloadFilePath);
if (0 == nExternalTransport)
return 0;
#endif
std::map<std::string, std::string>::iterator iter;
NSString* stringURL = StringWToNSString(m_sDownloadFileUrl);
NSString *escapedURL = [stringURL stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSURL *url = [NSURL URLWithString:escapedURL];
NSData *urlData = [NSData dataWithContentsOfURL:url];
if ( urlData )
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
iter = m_props.find("timeoutIntervalForResource");
if (iter != m_props.end())
configuration.timeoutIntervalForResource = std::stoi(iter->second);
NSString *filePath = StringWToNSString ( m_sDownloadFilePath );
[urlData writeToFile:filePath atomically:YES];
iter = m_props.find("HTTPMaximumConnectionsPerHost");
if (iter != m_props.end())
configuration.HTTPMaximumConnectionsPerHost = std::stoi(iter->second);
#if defined(_IOS)
return 0;
#else
#ifndef _ASC_USE_ARC_
if (!GetARCEnabled())
{
[stringURL release];
//[url release];
[urlData release];
}
#endif
#endif
return 0;
}
iter = m_props.find("allowsCellularAccess");
if (iter != m_props.end())
configuration.allowsCellularAccess = (std::stoi(iter->second) == 1) ? YES : NO;
#if defined(_IOS)
return 1;
#else
#ifndef _ASC_USE_ARC_
if (!GetARCEnabled())
{
[stringURL release];
//[url release];
}
#endif
#endif
return 1;
}
iter = m_props.find("requestCachePolicy");
if (iter != m_props.end())
{
if ("NSURLRequestUseProtocolCachePolicy" == iter->second)
configuration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
}
virtual int UploadData() override
{
#ifdef USE_EXTERNAL_TRANSPORT
int nExternalTransport = uploaddata_external(m_sUploadUrl, m_cData, m_nSize);
if (0 == nExternalTransport)
return 0;
#endif
//stub
return -1;
}
m_session = [NSURLSession sessionWithConfiguration:configuration];
}
};
virtual int UploadFile() override
{
#ifdef USE_EXTERNAL_TRANSPORT
int nExternalTransport = uploadfile_external(m_sUploadUrl, m_sUploadFilePath);
if (0 == nExternalTransport)
return 0;
#endif
//stub
return -1;
}
};
CFileTransporter_private::CFileTransporter_private(const std::wstring &sDownloadFileUrl, bool bDelete)
{
m_pInternal = new CFileTransporterBaseCocoa(sDownloadFileUrl, bDelete);
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
{
m_pInternal = new CFileTransporterBaseCocoa(sUploadUrl, cData, nSize);
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
{
m_pInternal = new CFileTransporterBaseCocoa(sUploadUrl, sUploadFilePath);
}
}
CSession_private* CreateSession()
{
return new CSessionMAC();
}
}
}
namespace NSNetwork
{
namespace NSFileTransport
{
static NSString* StringWToNSString ( const std::wstring& Str )
{
NSString* pString = [ [ NSString alloc ]
initWithBytes : (char*)Str.data() length : Str.size() * sizeof(wchar_t)
encoding : CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE ) ];
return pString;
}
class CFileTransporterBaseCocoa : public CFileTransporterBase
{
public :
CFileTransporterBaseCocoa(const std::wstring &sDownloadFileUrl, bool bDelete = true)
: CFileTransporterBase(sDownloadFileUrl, bDelete)
{
}
CFileTransporterBaseCocoa(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
: CFileTransporterBase(sUploadUrl, cData, nSize)
{
}
CFileTransporterBaseCocoa(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
: CFileTransporterBase(sUploadUrl, sUploadFilePath)
{
}
virtual ~CFileTransporterBaseCocoa()
{
}
virtual int DownloadFile() override
{
if (m_sDownloadFilePath.empty())
{
m_sDownloadFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"DWD");
if (NSFile::CFileBinary::Exists(m_sDownloadFilePath))
NSFile::CFileBinary::Remove(m_sDownloadFilePath);
}
#ifdef USE_EXTERNAL_TRANSPORT
int nExternalTransport = download_external(m_sDownloadFileUrl, m_sDownloadFilePath);
if (0 == nExternalTransport)
return 0;
#endif
NSString* stringURL = StringWToNSString(m_sDownloadFileUrl);
NSString* escapedURL = [stringURL stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
int nResult = 1;
if (m_pSession)
{
NSURLRequest* urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:escapedURL]];
__block NSData* result = nil;
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
NSURLSession* _session = ((CSessionMAC*)m_pSession->m_pInternal)->m_session;
if (nil == _session)
_session = [NSURLSession sharedSession];
[[_session dataTaskWithRequest:urlRequest
completionHandler:^(NSData *data, NSURLResponse* response, NSError *error) {
if (error == nil)
result = data;
dispatch_semaphore_signal(sem);
}] resume];
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
if (result)
{
NSString* filePath = StringWToNSString(m_sDownloadFilePath);
[result writeToFile:filePath atomically:YES];
nResult = 0;
}
else
{
nResult = 1;
}
return nResult;
}
else
{
NSURL* url = [NSURL URLWithString:escapedURL];
NSData* urlData = [NSData dataWithContentsOfURL:url];
if ( urlData )
{
NSString* filePath = StringWToNSString(m_sDownloadFilePath);
[urlData writeToFile:filePath atomically:YES];
#if defined(_IOS)
return 0;
#else
#ifndef _ASC_USE_ARC_
if (!GetARCEnabled())
{
[stringURL release];
//[url release];
[urlData release];
}
#endif
#endif
return 0;
}
#if defined(_IOS)
return 1;
#else
#ifndef _ASC_USE_ARC_
if (!GetARCEnabled())
{
[stringURL release];
//[url release];
}
#endif
#endif
return 1;
}
}
virtual int UploadData() override
{
#ifdef USE_EXTERNAL_TRANSPORT
int nExternalTransport = uploaddata_external(m_sUploadUrl, m_cData, m_nSize);
if (0 == nExternalTransport)
return 0;
#endif
//stub
return -1;
}
virtual int UploadFile() override
{
#ifdef USE_EXTERNAL_TRANSPORT
int nExternalTransport = uploadfile_external(m_sUploadUrl, m_sUploadFilePath);
if (0 == nExternalTransport)
return 0;
#endif
//stub
return -1;
}
};
CFileTransporter_private::CFileTransporter_private(const std::wstring &sDownloadFileUrl, bool bDelete)
{
m_pInternal = new CFileTransporterBaseCocoa(sDownloadFileUrl, bDelete);
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
{
m_pInternal = new CFileTransporterBaseCocoa(sUploadUrl, cData, nSize);
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
{
m_pInternal = new CFileTransporterBaseCocoa(sUploadUrl, sUploadFilePath);
}
}
}

View File

@ -37,218 +37,231 @@
namespace NSNetwork
{
namespace NSFileTransport
{
class CFileTransporterBase
{
public :
CFileTransporterBase(const std::wstring &sDownloadFileUrl, bool bDelete)
{
m_sDownloadFilePath = L"";
m_sDownloadFileUrl = sDownloadFileUrl;
m_sUploadFilePath = L"";
m_sUploadUrl = L"";
namespace NSFileTransport
{
class CFileTransporterBase
{
public :
CFileTransporterBase(const std::wstring &sDownloadFileUrl, bool bDelete)
{
m_sDownloadFilePath = L"";
m_sDownloadFileUrl = sDownloadFileUrl;
m_sUploadFilePath = L"";
m_sUploadUrl = L"";
m_bComplete = false;
m_bDelete = bDelete;
m_eLoadType = DOWNLOADFILE;
m_bComplete = false;
m_bDelete = bDelete;
m_eLoadType = DOWNLOADFILE;
m_cData = NULL;
m_nSize = 0;
m_cData = NULL;
m_nSize = 0;
// m_bIsExit = nullptr;
}
m_pSession = NULL;
CFileTransporterBase(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
{
m_sDownloadFilePath = L"";
m_sDownloadFileUrl = L"";
m_sUploadFilePath = L"";
m_sUploadUrl = sUploadUrl;
// m_bIsExit = nullptr;
}
m_bComplete = false;
m_bDelete = true;
m_eLoadType = UPLOADDATA;
CFileTransporterBase(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
{
m_sDownloadFilePath = L"";
m_sDownloadFileUrl = L"";
m_sUploadFilePath = L"";
m_sUploadUrl = sUploadUrl;
m_cData = cData;
m_nSize = nSize;
m_bComplete = false;
m_bDelete = true;
m_eLoadType = UPLOADDATA;
// m_bIsExit = nullptr;
}
m_cData = cData;
m_nSize = nSize;
CFileTransporterBase(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
{
m_sDownloadFilePath = L"";
m_sDownloadFileUrl = L"";
m_sUploadFilePath = sUploadFilePath;
m_sUploadUrl = sUploadUrl;
m_pSession = NULL;
m_bComplete = false;
m_bDelete = true;
m_eLoadType = UPLOADFILE;
// m_bIsExit = nullptr;
}
m_cData = NULL;
m_nSize = 0;
CFileTransporterBase(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
{
m_sDownloadFilePath = L"";
m_sDownloadFileUrl = L"";
m_sUploadFilePath = sUploadFilePath;
m_sUploadUrl = sUploadUrl;
// m_bIsExit = nullptr;
}
m_bComplete = false;
m_bDelete = true;
m_eLoadType = UPLOADFILE;
virtual ~CFileTransporterBase ()
{
if ( m_sDownloadFilePath.length() > 0 && m_bDelete )
{
NSFile::CFileBinary::Remove(m_sDownloadFilePath);
m_sDownloadFilePath = L"";
}
// m_bIsExit = nullptr;
}
m_cData = NULL;
m_nSize = 0;
virtual int DownloadFile() = 0;
virtual int UploadFile() = 0;
virtual int UploadData() = 0;
m_pSession = NULL;
public:
std::wstring m_sDownloadFilePath; // Путь к сохраненному файлу на диске
std::wstring m_sDownloadFileUrl;// Ссылка на скачивание файла
std::wstring m_sUploadFilePath; // Путь к файлу для выгрузки на сервер
std::wstring m_sUploadUrl; // URL для выгрузки данных
// m_bIsExit = nullptr;
}
bool m_bComplete; // Закачался файл или нет
bool m_bDelete; // Удалять ли файл в деструкторе
virtual ~CFileTransporterBase ()
{
if ( m_sDownloadFilePath.length() > 0 && m_bDelete )
{
NSFile::CFileBinary::Remove(m_sDownloadFilePath);
m_sDownloadFilePath = L"";
}
// m_bIsExit = nullptr;
}
typedef enum LoadType
{
DOWNLOADFILE,
UPLOADFILE,
UPLOADDATA
} LoadType;
virtual int DownloadFile() = 0;
virtual int UploadFile() = 0;
virtual int UploadData() = 0;
LoadType m_eLoadType; // Тип загрузки/выгрузки данных/файла
public:
std::wstring m_sDownloadFilePath; // Путь к сохраненному файлу на диске
std::wstring m_sDownloadFileUrl;// Ссылка на скачивание файла
std::wstring m_sUploadFilePath; // Путь к файлу для выгрузки на сервер
std::wstring m_sUploadUrl; // URL для выгрузки данных
const unsigned char* m_cData; // Данные в сыром виде для выгрузки
int m_nSize; // Размер данных
bool m_bComplete; // Закачался файл или нет
bool m_bDelete; // Удалять ли файл в деструкторе
std::wstring m_sResponse = L""; // Ответ сервера
typedef enum LoadType
{
DOWNLOADFILE,
UPLOADFILE,
UPLOADDATA
} LoadType;
std::function<void(int)> m_func_onComplete = nullptr;
std::function<void(int)> m_func_onProgress = nullptr;
std::function<bool(void)> m_check_aborted = nullptr;
LoadType m_eLoadType; // Тип загрузки/выгрузки данных/файла
// std::atomic<bool>* m_bIsExit; // Для остановки и выхода потока
};
const unsigned char* m_cData; // Данные в сыром виде для выгрузки
int m_nSize; // Размер данных
class CFileTransporter_private : public NSThreads::CBaseThread
{
protected:
// создаем в зависимости от платформы
CFileTransporterBase* m_pInternal;
std::wstring m_sResponse = L""; // Ответ сервера
public:
CFileTransporterBase* GetInternal()
{
return m_pInternal;
}
std::function<void(int)> m_func_onComplete = nullptr;
std::function<void(int)> m_func_onProgress = nullptr;
std::function<bool(void)> m_check_aborted = nullptr;
public:
CFileTransporter_private(const std::wstring &sDownloadFileUrl, bool bDelete = true);
CFileTransporter_private(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize);
CFileTransporter_private(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath);
CSession* m_pSession;
virtual ~CFileTransporter_private()
{
Stop();
if (NULL != m_pInternal)
delete m_pInternal;
}
// std::atomic<bool>* m_bIsExit; // Для остановки и выхода потока
};
void SetDownloadFileUrl(const std::wstring &sDownloadFileUrl, bool bDelete = true)
{
m_pInternal->m_sDownloadFileUrl = sDownloadFileUrl;
m_pInternal->m_bDelete = bDelete;
m_pInternal->m_eLoadType = m_pInternal->DOWNLOADFILE;
}
class CFileTransporter_private : public NSThreads::CBaseThread
{
protected:
// создаем в зависимости от платформы
CFileTransporterBase* m_pInternal;
void SetDownloadFilePath(const std::wstring& sDownloadFilePat)
{
m_pInternal->m_sDownloadFilePath = sDownloadFilePat;
}
public:
CFileTransporterBase* GetInternal()
{
return m_pInternal;
}
std::wstring GetDownloadFilePath()
{
return m_pInternal->m_sDownloadFilePath;
}
public:
CFileTransporter_private(const std::wstring &sDownloadFileUrl, bool bDelete = true);
CFileTransporter_private(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize);
CFileTransporter_private(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath);
bool IsFileDownloaded()
{
return m_pInternal->m_bComplete;
}
virtual ~CFileTransporter_private()
{
Stop();
if (NULL != m_pInternal)
delete m_pInternal;
}
void SetUploadUrl(const std::wstring &sUploadUrl)
{
m_pInternal->m_sUploadUrl = sUploadUrl;
}
void SetDownloadFileUrl(const std::wstring &sDownloadFileUrl, bool bDelete = true)
{
m_pInternal->m_sDownloadFileUrl = sDownloadFileUrl;
m_pInternal->m_bDelete = bDelete;
m_pInternal->m_eLoadType = m_pInternal->DOWNLOADFILE;
}
void SetUploadBinaryDara(const unsigned char* cData, const int nSize)
{
m_pInternal->m_cData = cData;
m_pInternal->m_nSize = nSize;
m_pInternal->m_eLoadType = m_pInternal->UPLOADDATA;
}
void SetDownloadFilePath(const std::wstring& sDownloadFilePat)
{
m_pInternal->m_sDownloadFilePath = sDownloadFilePat;
}
void SetUploadFilePath(const std::wstring &sUploadFilePath)
{
m_pInternal->m_sUploadFilePath = sUploadFilePath;
m_pInternal->m_eLoadType = m_pInternal->UPLOADFILE;
}
std::wstring GetDownloadFilePath()
{
return m_pInternal->m_sDownloadFilePath;
}
std::wstring& GetResponse()
{
return m_pInternal->m_sResponse;
}
bool IsFileDownloaded()
{
return m_pInternal->m_bComplete;
}
bool TransferSync()
{
this->Start( 1 );
while ( this->IsRunned() )
{
NSThreads::Sleep( 10 );
}
return IsFileDownloaded();
}
void SetUploadUrl(const std::wstring &sUploadUrl)
{
m_pInternal->m_sUploadUrl = sUploadUrl;
}
void TransferAsync()
{
this->Start( 1 );
}
void SetUploadBinaryDara(const unsigned char* cData, const int nSize)
{
m_pInternal->m_cData = cData;
m_pInternal->m_nSize = nSize;
m_pInternal->m_eLoadType = m_pInternal->UPLOADDATA;
}
protected :
void SetUploadFilePath(const std::wstring &sUploadFilePath)
{
m_pInternal->m_sUploadFilePath = sUploadFilePath;
m_pInternal->m_eLoadType = m_pInternal->UPLOADFILE;
}
virtual DWORD ThreadProc ()
{
m_pInternal->m_bComplete = false;
std::wstring& GetResponse()
{
return m_pInternal->m_sResponse;
}
int hrResultAll = 0;
if(m_pInternal->m_eLoadType == m_pInternal->DOWNLOADFILE)
hrResultAll = m_pInternal->DownloadFile();
else if(m_pInternal->m_eLoadType == m_pInternal->UPLOADFILE)
hrResultAll = m_pInternal->UploadFile();
else if(m_pInternal->m_eLoadType == m_pInternal->UPLOADDATA)
hrResultAll = m_pInternal->UploadData();
bool TransferSync()
{
this->Start( 1 );
while ( this->IsRunned() )
{
NSThreads::Sleep( 10 );
}
return IsFileDownloaded();
}
if (0 == hrResultAll)
m_pInternal->m_bComplete = true;
else
{
if (NSFile::CFileBinary::Exists(m_pInternal->m_sDownloadFilePath))
NSFile::CFileBinary::Remove(m_pInternal->m_sDownloadFilePath);
}
void TransferAsync()
{
this->Start( 1 );
}
if (m_pInternal->m_func_onComplete)
m_pInternal->m_func_onComplete(hrResultAll);
void SetSession(CSession* session)
{
m_pInternal->m_pSession = session;
}
m_bRunThread = FALSE;
return 0;
}
};
}
protected :
virtual DWORD ThreadProc ()
{
m_pInternal->m_bComplete = false;
int hrResultAll = 0;
if(m_pInternal->m_eLoadType == m_pInternal->DOWNLOADFILE)
hrResultAll = m_pInternal->DownloadFile();
else if(m_pInternal->m_eLoadType == m_pInternal->UPLOADFILE)
hrResultAll = m_pInternal->UploadFile();
else if(m_pInternal->m_eLoadType == m_pInternal->UPLOADDATA)
hrResultAll = m_pInternal->UploadData();
if (0 == hrResultAll)
m_pInternal->m_bComplete = true;
else
{
if (NSFile::CFileBinary::Exists(m_pInternal->m_sDownloadFilePath))
NSFile::CFileBinary::Remove(m_pInternal->m_sDownloadFilePath);
}
if (m_pInternal->m_func_onComplete)
m_pInternal->m_func_onComplete(hrResultAll);
m_bRunThread = FALSE;
return 0;
}
};
}
}

View File

@ -56,459 +56,459 @@
namespace NSNetwork
{
namespace NSFileTransport
{
class CFileTransporterBaseWin : public CFileTransporterBase
{
public :
CFileTransporterBaseWin(const std::wstring &sDownloadFileUrl, bool bDelete = true) :
CFileTransporterBase(sDownloadFileUrl, bDelete)
{
}
namespace NSFileTransport
{
class CFileTransporterBaseWin : public CFileTransporterBase
{
public :
CFileTransporterBaseWin(const std::wstring &sDownloadFileUrl, bool bDelete = true) :
CFileTransporterBase(sDownloadFileUrl, bDelete)
{
}
CFileTransporterBaseWin(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize) :
CFileTransporterBase(sUploadUrl, cData, nSize)
{
}
CFileTransporterBaseWin(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize) :
CFileTransporterBase(sUploadUrl, cData, nSize)
{
}
CFileTransporterBaseWin(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath) :
CFileTransporterBase(sUploadUrl, sUploadFilePath)
{
}
CFileTransporterBaseWin(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath) :
CFileTransporterBase(sUploadUrl, sUploadFilePath)
{
}
virtual ~CFileTransporterBaseWin()
{
if ( m_pFile )
{
::fclose( m_pFile );
m_pFile = NULL;
}
}
virtual ~CFileTransporterBaseWin()
{
if ( m_pFile )
{
::fclose( m_pFile );
m_pFile = NULL;
}
}
virtual int DownloadFile() override
{
CoInitialize ( NULL );
if ( /*S_OK != _DownloadFile ( m_sFileUrl )*/TRUE )
{
if (m_sDownloadFilePath.empty())
{
m_sDownloadFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"DWD");
if (NSFile::CFileBinary::Exists(m_sDownloadFilePath))
NSFile::CFileBinary::Remove(m_sDownloadFilePath);
}
virtual int DownloadFile() override
{
CoInitialize ( NULL );
if ( /*S_OK != _DownloadFile ( m_sFileUrl )*/TRUE )
{
if (m_sDownloadFilePath.empty())
{
m_sDownloadFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"DWD");
if (NSFile::CFileBinary::Exists(m_sDownloadFilePath))
NSFile::CFileBinary::Remove(m_sDownloadFilePath);
}
HRESULT hrResultAll = DownloadFileAll(m_sDownloadFileUrl, m_sDownloadFilePath);
HRESULT hrResultAll = DownloadFileAll(m_sDownloadFileUrl, m_sDownloadFilePath);
if(E_ABORT == hrResultAll /*&& m_bIsExit->load()*/)
{
//DeleteUrlCacheEntry(m_sDownloadFileUrl.c_str());
CoUninitialize ();
return hrResultAll;
}
if (S_OK != hrResultAll)
{
hrResultAll = (true == DownloadFilePS(m_sDownloadFileUrl, m_sDownloadFilePath)) ? S_OK : S_FALSE;
CoUninitialize ();
return hrResultAll;
}
}
if(E_ABORT == hrResultAll /*&& m_bIsExit->load()*/)
{
//DeleteUrlCacheEntry(m_sDownloadFileUrl.c_str());
CoUninitialize ();
return hrResultAll;
}
if (S_OK != hrResultAll)
{
hrResultAll = (true == DownloadFilePS(m_sDownloadFileUrl, m_sDownloadFilePath)) ? S_OK : S_FALSE;
CoUninitialize ();
return hrResultAll;
}
}
CoUninitialize ();
m_bComplete = true;
return S_OK;
}
CoUninitialize ();
m_bComplete = true;
return S_OK;
}
virtual int UploadData() override
{
//stub
return S_OK;
}
virtual int UploadData() override
{
//stub
return S_OK;
}
virtual int UploadFile() override
{
//stub
return S_OK;
}
virtual int UploadFile() override
{
//stub
return S_OK;
}
protected:
FILE * m_pFile = nullptr; // Хэндл на временный файл
unsigned int _DownloadFile(std::wstring sFileUrl)
{
// Проверяем состояние соединения
if ( FALSE == InternetGetConnectedState ( 0, 0 ) )
return S_FALSE;
protected:
FILE * m_pFile = nullptr; // Хэндл на временный файл
unsigned int _DownloadFile(std::wstring sFileUrl)
{
// Проверяем состояние соединения
if ( FALSE == InternetGetConnectedState ( 0, 0 ) )
return S_FALSE;
wchar_t sTempPath[MAX_PATH], sTempFile[MAX_PATH];
if ( 0 == GetTempPathW( MAX_PATH, sTempPath ) )
return S_FALSE;
wchar_t sTempPath[MAX_PATH], sTempFile[MAX_PATH];
if ( 0 == GetTempPathW( MAX_PATH, sTempPath ) )
return S_FALSE;
if ( 0 == GetTempFileNameW( sTempPath, L"CSS", 0, sTempFile ) )
return S_FALSE;
if ( 0 == GetTempFileNameW( sTempPath, L"CSS", 0, sTempFile ) )
return S_FALSE;
m_pFile = ::_wfopen( sTempFile, L"wb" );
if ( !m_pFile )
return S_FALSE;
m_pFile = ::_wfopen( sTempFile, L"wb" );
if ( !m_pFile )
return S_FALSE;
m_sDownloadFilePath = std::wstring( sTempFile );
m_sDownloadFilePath = std::wstring( sTempFile );
// Открываем сессию
HINTERNET hInternetSession = InternetOpenW ( L"Mozilla/4.0 (compatible; MSIE 5.0; Windows 98)", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if ( NULL == hInternetSession )
return S_FALSE;
// Открываем сессию
HINTERNET hInternetSession = InternetOpenW ( L"Mozilla/4.0 (compatible; MSIE 5.0; Windows 98)", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if ( NULL == hInternetSession )
return S_FALSE;
// Заголовок запроса ( пока содержит 0 байт ( необходимо для проверки ) )
std::wstring sHTTPHdr = L"Range: bytes=0-0";
// Открываем ссылку для проверки на ее существование, а также на возможность чтения частями
HINTERNET hInternetOpenURL = InternetOpenUrlW ( hInternetSession, sFileUrl.c_str(), sHTTPHdr.c_str(), -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
if ( NULL != hInternetOpenURL )
{
// Открытие произошло, проверяем ответ
if ( TRUE == QueryStatusCode ( hInternetOpenURL, TRUE ) )
{
// Запрос прошел удачно, проверяем возможность чтения частями и получаем размер данных
LONGLONG nFileSize = IsAccept_Ranges ( hInternetOpenURL );
// Закрываем хендл
InternetCloseHandle ( hInternetOpenURL );
if ( -1 == nFileSize )
{
// Чтение частями недоступно
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
// Закрываем файл (сделается на DownloadAll)
// Попробуем записать его целиком
return S_FALSE;
}
else
{
// Чтение частями доступно
LONGLONG nStartByte = 0;
while ( true )
{
// Если закачали весь файл - то выходим
if ( nStartByte == nFileSize - 1 )
{
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
return S_OK;
}
LONGLONG nEndByte = nStartByte + DOWNLOAD_FILE_SIZE;
// Если файл заканчивается, то загружаем меньшее колличество байт ( на 1 меньше, чем размер, т.к. начинается с 0 )
if ( nEndByte >= nFileSize )
nEndByte = nFileSize - 1;
// Заголовок запроса ( пока содержит 0 байт ( необходимо для проверки ) )
std::wstring sHTTPHdr = L"Range: bytes=0-0";
// Открываем ссылку для проверки на ее существование, а также на возможность чтения частями
HINTERNET hInternetOpenURL = InternetOpenUrlW ( hInternetSession, sFileUrl.c_str(), sHTTPHdr.c_str(), -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
if ( NULL != hInternetOpenURL )
{
// Открытие произошло, проверяем ответ
if ( TRUE == QueryStatusCode ( hInternetOpenURL, TRUE ) )
{
// Запрос прошел удачно, проверяем возможность чтения частями и получаем размер данных
LONGLONG nFileSize = IsAccept_Ranges ( hInternetOpenURL );
// Закрываем хендл
InternetCloseHandle ( hInternetOpenURL );
if ( -1 == nFileSize )
{
// Чтение частями недоступно
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
// Закрываем файл (сделается на DownloadAll)
// Попробуем записать его целиком
return S_FALSE;
}
else
{
// Чтение частями доступно
LONGLONG nStartByte = 0;
while ( true )
{
// Если закачали весь файл - то выходим
if ( nStartByte == nFileSize - 1 )
{
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
return S_OK;
}
LONGLONG nEndByte = nStartByte + DOWNLOAD_FILE_SIZE;
// Если файл заканчивается, то загружаем меньшее колличество байт ( на 1 меньше, чем размер, т.к. начинается с 0 )
if ( nEndByte >= nFileSize )
nEndByte = nFileSize - 1;
// Буффер для закачки
BYTE arrBuffer [ DOWNLOAD_FILE_SIZE ] = { 0 };
DWORD dwBytesDownload = DownloadFilePath ( hInternetSession, arrBuffer, nStartByte, nEndByte, sFileUrl );
// Буффер для закачки
BYTE arrBuffer [ DOWNLOAD_FILE_SIZE ] = { 0 };
DWORD dwBytesDownload = DownloadFilePath ( hInternetSession, arrBuffer, nStartByte, nEndByte, sFileUrl );
nStartByte = nEndByte;
if ( -1 == dwBytesDownload )
{
// Ничего не прочиталось - это плохо!!!!
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
// Закрываем файл (сделается на DownloadAll)
// Попробуем записать его целиком
return S_FALSE;
}
nStartByte = nEndByte;
if ( -1 == dwBytesDownload )
{
// Ничего не прочиталось - это плохо!!!!
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
// Закрываем файл (сделается на DownloadAll)
// Попробуем записать его целиком
return S_FALSE;
}
// Пишем в файл
::fwrite( (BYTE*)arrBuffer, 1, dwBytesDownload, m_pFile );
::fflush( m_pFile );
// Пишем в файл
::fwrite( (BYTE*)arrBuffer, 1, dwBytesDownload, m_pFile );
::fflush( m_pFile );
NSThreads::Sleep(10);
}
}
}
else
{
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
// Закрываем файл (сделается на DownloadAll)
// Попробуем записать его целиком
return S_FALSE;
}
}
else
{
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
// Закрываем файл (сделается на DownloadAll)
// Попробуем записать его целиком
return S_FALSE;
}
NSThreads::Sleep(10);
}
}
}
else
{
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
// Закрываем файл (сделается на DownloadAll)
// Попробуем записать его целиком
return S_FALSE;
}
}
else
{
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
// Закрываем файл (сделается на DownloadAll)
// Попробуем записать его целиком
return S_FALSE;
}
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
// Закрываем хендл соединения
InternetCloseHandle ( hInternetSession );
return S_OK;
}
DWORD DownloadFilePath ( HINTERNET hInternet, LPBYTE pBuffer, LONGLONG nStartByte, LONGLONG nEndByte, std::wstring sFileURL )
{
// Неоткрытая сессия
if ( NULL == hInternet )
return -1;
return S_OK;
}
DWORD DownloadFilePath ( HINTERNET hInternet, LPBYTE pBuffer, LONGLONG nStartByte, LONGLONG nEndByte, std::wstring sFileURL )
{
// Неоткрытая сессия
if ( NULL == hInternet )
return -1;
// Пришли непонятные параметры
if ( nStartByte > nEndByte || !pBuffer )
return -1;
// Пришли непонятные параметры
if ( nStartByte > nEndByte || !pBuffer )
return -1;
// Заголовок запроса ( содержит nEndByte - nStartByte байт )
std::wstring sHTTPHdr = L"Range: bytes=" + std::to_wstring(nStartByte) + L"-" + std::to_wstring(nEndByte);
// Открываем ссылку для закачки
HINTERNET hInternetOpenURL = InternetOpenUrlW ( hInternet, sFileURL.c_str(), sHTTPHdr.c_str(), -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
if ( NULL == hInternetOpenURL )
return -1;
// Открытие произошло, проверяем ответ
if ( FALSE == QueryStatusCode ( hInternetOpenURL, TRUE ) )
{
// Закрываем хендл соединения
InternetCloseHandle ( hInternetOpenURL );
return -1;
}
// Заголовок запроса ( содержит nEndByte - nStartByte байт )
std::wstring sHTTPHdr = L"Range: bytes=" + std::to_wstring(nStartByte) + L"-" + std::to_wstring(nEndByte);
// Открываем ссылку для закачки
HINTERNET hInternetOpenURL = InternetOpenUrlW ( hInternet, sFileURL.c_str(), sHTTPHdr.c_str(), -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
if ( NULL == hInternetOpenURL )
return -1;
// Открытие произошло, проверяем ответ
if ( FALSE == QueryStatusCode ( hInternetOpenURL, TRUE ) )
{
// Закрываем хендл соединения
InternetCloseHandle ( hInternetOpenURL );
return -1;
}
// Какое колличество байт прочитано
DWORD dwBytesRead = 0;
// Читаем файл
if ( FALSE == InternetReadFile ( hInternetOpenURL, pBuffer, DOWNLOAD_FILE_SIZE, &dwBytesRead ) )
{
// Закрываем хендл соединения
InternetCloseHandle ( hInternetOpenURL );
return -1;
}
// Какое колличество байт прочитано
DWORD dwBytesRead = 0;
// Читаем файл
if ( FALSE == InternetReadFile ( hInternetOpenURL, pBuffer, DOWNLOAD_FILE_SIZE, &dwBytesRead ) )
{
// Закрываем хендл соединения
InternetCloseHandle ( hInternetOpenURL );
return -1;
}
// Закрываем хендл соединения
InternetCloseHandle ( hInternetOpenURL );
// Закрываем хендл соединения
InternetCloseHandle ( hInternetOpenURL );
return dwBytesRead;
}
return dwBytesRead;
}
BOOL QueryStatusCode ( HINTERNET hInternet, BOOL bIsRanges )
{
// Зачем проверять у неоткрытой сессии что-то
if ( NULL == hInternet )
return FALSE;
BOOL QueryStatusCode ( HINTERNET hInternet, BOOL bIsRanges )
{
// Зачем проверять у неоткрытой сессии что-то
if ( NULL == hInternet )
return FALSE;
// Результат ответа
INT nResult = 0;
// Размер данных ответа ( должно быть = 4 )
DWORD dwLengthDataSize = 4;
// Результат ответа
INT nResult = 0;
// Размер данных ответа ( должно быть = 4 )
DWORD dwLengthDataSize = 4;
// Делаем запрос, если не проходит - то возвращаем FALSE
if ( FALSE == HttpQueryInfo ( hInternet, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &nResult, &dwLengthDataSize, NULL ) )
return FALSE;
// Делаем запрос, если не проходит - то возвращаем FALSE
if ( FALSE == HttpQueryInfo ( hInternet, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &nResult, &dwLengthDataSize, NULL ) )
return FALSE;
// Запрос прошел, теперь проверяем код ответа
if ( HTTP_STATUS_NOT_FOUND == nResult )
{
// Объект не найден, плохая ссылка или что-то еще
return FALSE;
}
else if ( ( HTTP_STATUS_OK != nResult && FALSE == bIsRanges ) || ( HTTP_STATUS_PARTIAL_CONTENT != nResult && TRUE == bIsRanges ) )
{
// Запрос не прошел по какой-то причине
return FALSE;
}
// Запрос прошел, теперь проверяем код ответа
if ( HTTP_STATUS_NOT_FOUND == nResult )
{
// Объект не найден, плохая ссылка или что-то еще
return FALSE;
}
else if ( ( HTTP_STATUS_OK != nResult && FALSE == bIsRanges ) || ( HTTP_STATUS_PARTIAL_CONTENT != nResult && TRUE == bIsRanges ) )
{
// Запрос не прошел по какой-то причине
return FALSE;
}
// Все отлично, запрос прошел
return TRUE;
}
// Проверяет, доступно ли для ресурса чтение частями и возвращает -1 если не доступно и размер данных, если доступно
LONGLONG IsAccept_Ranges ( HINTERNET hInternet )
{
// Зачем проверять у неоткрытой сессии что-то
if ( NULL == hInternet )
return -1;
// Все отлично, запрос прошел
return TRUE;
}
// Проверяет, доступно ли для ресурса чтение частями и возвращает -1 если не доступно и размер данных, если доступно
LONGLONG IsAccept_Ranges ( HINTERNET hInternet )
{
// Зачем проверять у неоткрытой сессии что-то
if ( NULL == hInternet )
return -1;
// Результат ответа
wchar_t arrResult [ MAX_SIZE ] = { 0 };
// Размер данных ответа
DWORD dwLengthDataSize = sizeof ( arrResult );
// Результат ответа
wchar_t arrResult [ MAX_SIZE ] = { 0 };
// Размер данных ответа
DWORD dwLengthDataSize = sizeof ( arrResult );
// Делаем запрос, если не проходит - то возвращаем FALSE
if ( FALSE == HttpQueryInfoW ( hInternet, HTTP_QUERY_CONTENT_RANGE, &arrResult, &dwLengthDataSize, NULL ) )
{
// Получаем последнюю ошибку
DWORD dwLastError = GetLastError ();
if ( dwLastError == ERROR_HTTP_HEADER_NOT_FOUND )
{
// Не пришел заголовок, значит ресурс не поддерживает чтение частями
return -1;
}
// Делаем запрос, если не проходит - то возвращаем FALSE
if ( FALSE == HttpQueryInfoW ( hInternet, HTTP_QUERY_CONTENT_RANGE, &arrResult, &dwLengthDataSize, NULL ) )
{
// Получаем последнюю ошибку
DWORD dwLastError = GetLastError ();
if ( dwLastError == ERROR_HTTP_HEADER_NOT_FOUND )
{
// Не пришел заголовок, значит ресурс не поддерживает чтение частями
return -1;
}
// Возникла какая-то другая ошибка - возвращаем FALSE
return -1;
}
// Возникла какая-то другая ошибка - возвращаем FALSE
return -1;
}
// Если размер 0, то заголовка нет
if ( 0 >= dwLengthDataSize )
return -1;
// Если размер 0, то заголовка нет
if ( 0 >= dwLengthDataSize )
return -1;
// Приведем к std::wstring
std::wstring strResult ( arrResult );
// Приведем к std::wstring
std::wstring strResult ( arrResult );
// Содержит размер данных
LONGLONG nFileSize = 0;
// Содержит размер данных
LONGLONG nFileSize = 0;
try
{
// Ищем индекс размера данных в строке
INT nStartIndex = (INT)strResult.find ( CONTENT_RANGE );
if ( -1 == nStartIndex )
return -1;
try
{
// Ищем индекс размера данных в строке
INT nStartIndex = (INT)strResult.find ( CONTENT_RANGE );
if ( -1 == nStartIndex )
return -1;
// Оставляем в строке только размер данных
strResult = strResult.substr( nStartIndex + CONTENT_RANGE_SIZE );
// Теперь получим размер данных, переводя стринг в LONGLONG
nFileSize = _wtoi64 ( strResult.c_str() );
// Т.к. реально нумерация с 0 ( поэтому добавляем еще 1 байт )
if ( 0 < nFileSize )
nFileSize += 1;
}
catch ( ... )
{
// не нашли возвращаем ошибку
return -1;
}
// Оставляем в строке только размер данных
strResult = strResult.substr( nStartIndex + CONTENT_RANGE_SIZE );
// Теперь получим размер данных, переводя стринг в LONGLONG
nFileSize = _wtoi64 ( strResult.c_str() );
// Т.к. реально нумерация с 0 ( поэтому добавляем еще 1 байт )
if ( 0 < nFileSize )
nFileSize += 1;
}
catch ( ... )
{
// не нашли возвращаем ошибку
return -1;
}
// Все отлично, ресурс поддерживает чтение частями, возвращаем размер
return nFileSize;
}
// Все отлично, ресурс поддерживает чтение частями, возвращаем размер
return nFileSize;
}
HRESULT DownloadFileAll(std::wstring sFileURL, std::wstring strFileOutput)
{
if ( m_pFile )
{
::fclose( m_pFile );
m_pFile = NULL;
}
HRESULT DownloadFileAll(std::wstring sFileURL, std::wstring strFileOutput)
{
if ( m_pFile )
{
::fclose( m_pFile );
m_pFile = NULL;
}
DownloadProgress progress;
progress.func_checkAborted = m_check_aborted;
progress.func_onProgress = m_func_onProgress;
// Скачиваем файл с возвратом процентов состояния
return URLDownloadToFileW (NULL, sFileURL.c_str(), strFileOutput.c_str(), NULL, static_cast<IBindStatusCallback*>(&progress));
}
DownloadProgress progress;
progress.func_checkAborted = m_check_aborted;
progress.func_onProgress = m_func_onProgress;
// Скачиваем файл с возвратом процентов состояния
return URLDownloadToFileW (NULL, sFileURL.c_str(), strFileOutput.c_str(), NULL, static_cast<IBindStatusCallback*>(&progress));
}
class DownloadProgress : public IBindStatusCallback {
public:
HRESULT __stdcall QueryInterface(const IID &,void **) {
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef(void) {
return 1;
}
ULONG STDMETHODCALLTYPE Release(void) {
return 1;
}
HRESULT STDMETHODCALLTYPE OnStartBinding(DWORD dwReserved, IBinding *pib) {
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE GetPriority(LONG *pnPriority) {
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE OnLowResource(DWORD reserved) {
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE OnStopBinding(HRESULT hresult, LPCWSTR szError) {
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE GetBindInfo(DWORD *grfBINDF, BINDINFO *pbindinfo) {
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE OnDataAvailable(DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed) {
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE OnObjectAvailable(REFIID riid, IUnknown *punk) {
return E_NOTIMPL;
}
class DownloadProgress : public IBindStatusCallback {
public:
HRESULT __stdcall QueryInterface(const IID &,void **) {
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef(void) {
return 1;
}
ULONG STDMETHODCALLTYPE Release(void) {
return 1;
}
HRESULT STDMETHODCALLTYPE OnStartBinding(DWORD dwReserved, IBinding *pib) {
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE GetPriority(LONG *pnPriority) {
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE OnLowResource(DWORD reserved) {
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE OnStopBinding(HRESULT hresult, LPCWSTR szError) {
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE GetBindInfo(DWORD *grfBINDF, BINDINFO *pbindinfo) {
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE OnDataAvailable(DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed) {
return E_NOTIMPL;
}
virtual HRESULT STDMETHODCALLTYPE OnObjectAvailable(REFIID riid, IUnknown *punk) {
return E_NOTIMPL;
}
virtual HRESULT __stdcall OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
{
if(func_checkAborted && func_checkAborted())
{
return E_ABORT;
}
if(ulProgressMax != 0)
{
int percent = static_cast<int>((100.0 * ulProgress) / ulProgressMax);
if(func_onProgress)
func_onProgress(percent);
}
return S_OK;
}
virtual HRESULT __stdcall OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
{
if(func_checkAborted && func_checkAborted())
{
return E_ABORT;
}
if(ulProgressMax != 0)
{
int percent = static_cast<int>((100.0 * ulProgress) / ulProgressMax);
if(func_onProgress)
func_onProgress(percent);
}
return S_OK;
}
std::function<bool(void)> func_checkAborted = nullptr;
std::function<void(int)> func_onProgress = nullptr;
};
std::function<bool(void)> func_checkAborted = nullptr;
std::function<void(int)> func_onProgress = nullptr;
};
bool DownloadFilePS(const std::wstring& sFileURL, const std::wstring& strFileOutput)
{
STARTUPINFO sturtupinfo;
ZeroMemory(&sturtupinfo,sizeof(STARTUPINFO));
sturtupinfo.cb = sizeof(STARTUPINFO);
bool DownloadFilePS(const std::wstring& sFileURL, const std::wstring& strFileOutput)
{
STARTUPINFO sturtupinfo;
ZeroMemory(&sturtupinfo,sizeof(STARTUPINFO));
sturtupinfo.cb = sizeof(STARTUPINFO);
std::wstring sFileDst = strFileOutput;
size_t posn = 0;
while (std::wstring::npos != (posn = sFileDst.find('\\', posn)))
{
sFileDst.replace(posn, 1, L"/");
posn += 1;
}
std::wstring sFileDst = strFileOutput;
size_t posn = 0;
while (std::wstring::npos != (posn = sFileDst.find('\\', posn)))
{
sFileDst.replace(posn, 1, L"/");
posn += 1;
}
std::wstring sApp = L"powershell.exe c \"(new-object System.Net.WebClient).DownloadFile('" + sFileURL + L"','" + sFileDst + L"')\"";
wchar_t* pCommandLine = new wchar_t[sApp.length() + 1];
memcpy(pCommandLine, sApp.c_str(), sApp.length() * sizeof(wchar_t));
pCommandLine[sApp.length()] = (wchar_t)'\0';
std::wstring sApp = L"powershell.exe c \"(new-object System.Net.WebClient).DownloadFile('" + sFileURL + L"','" + sFileDst + L"')\"";
wchar_t* pCommandLine = new wchar_t[sApp.length() + 1];
memcpy(pCommandLine, sApp.c_str(), sApp.length() * sizeof(wchar_t));
pCommandLine[sApp.length()] = (wchar_t)'\0';
HANDLE ghJob = CreateJobObject(NULL, NULL);
HANDLE ghJob = CreateJobObject(NULL, NULL);
if (ghJob)
{
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 };
if (ghJob)
{
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 };
// Configure all child processes associated with the job to terminate when the
jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
if ( 0 == SetInformationJobObject( ghJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli)))
{
CloseHandle(ghJob);
ghJob = NULL;
}
}
// Configure all child processes associated with the job to terminate when the
jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
if ( 0 == SetInformationJobObject( ghJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli)))
{
CloseHandle(ghJob);
ghJob = NULL;
}
}
PROCESS_INFORMATION processinfo;
ZeroMemory(&processinfo,sizeof(PROCESS_INFORMATION));
BOOL bResult = CreateProcessW(NULL, pCommandLine, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &sturtupinfo, &processinfo);
PROCESS_INFORMATION processinfo;
ZeroMemory(&processinfo,sizeof(PROCESS_INFORMATION));
BOOL bResult = CreateProcessW(NULL, pCommandLine, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &sturtupinfo, &processinfo);
if (bResult && ghJob)
{
AssignProcessToJobObject(ghJob, processinfo.hProcess);
}
if (bResult && ghJob)
{
AssignProcessToJobObject(ghJob, processinfo.hProcess);
}
::WaitForSingleObject(processinfo.hProcess, INFINITE);
::WaitForSingleObject(processinfo.hProcess, INFINITE);
RELEASEARRAYOBJECTS(pCommandLine);
RELEASEARRAYOBJECTS(pCommandLine);
return NSFile::CFileBinary::Exists(sFileDst);
}
};
return NSFile::CFileBinary::Exists(sFileDst);
}
};
CFileTransporter_private::CFileTransporter_private(const std::wstring &sDownloadFileUrl, bool bDelete)
: m_pInternal(new CFileTransporterBaseWin(sDownloadFileUrl, bDelete))
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sDownloadFileUrl, bool bDelete)
: m_pInternal(new CFileTransporterBaseWin(sDownloadFileUrl, bDelete))
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
: m_pInternal(new CFileTransporterBaseWin(sUploadUrl, cData, nSize))
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const unsigned char* cData, const int nSize)
: m_pInternal(new CFileTransporterBaseWin(sUploadUrl, cData, nSize))
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
: m_pInternal(new CFileTransporterBaseWin(sUploadUrl, sUploadFilePath))
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
}
CFileTransporter_private::CFileTransporter_private(const std::wstring &sUploadUrl, const std::wstring &sUploadFilePath)
: m_pInternal(new CFileTransporterBaseWin(sUploadUrl, sUploadFilePath))
{
m_pInternal->m_check_aborted = std::bind(&CBaseThread::isAborted, this);
}
}
}

View File

@ -29,49 +29,37 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "Session.h"
#include "SXDB.h"
#include "DREF.h"
#include "SXTBL.h"
#include "DBQUERY.h"
namespace XLS
namespace NSNetwork
{
SXDB::SXDB()
{
}
SXDB::~SXDB()
{
}
BaseObjectPtr SXDB::clone()
{
return BaseObjectPtr(new SXDB(*this));
}
// SXDB = DREF / SXTBL / DBQUERY
const bool SXDB::loadContent(BinProcessor& proc)
{
if(!proc.optional<DREF>())
namespace NSFileTransport
{
if(!proc.optional<SXTBL>())
CSession::CSession()
{
if(!proc.optional<DBQUERY>())
{
return false;
}
m_pInternal = CreateSession();
}
CSession::~CSession()
{
delete m_pInternal;
}
void CSession::SetProperty(const std::string& name, const std::string& value)
{
m_pInternal->m_props.insert(std::make_pair(name, value));
}
void CSession::Initialize()
{
m_pInternal->Create();
}
#if !defined(_IOS) && !defined(_MAC)
CSession_private* CreateSession()
{
return new CSession_private();
}
#endif
}
m_source = elements_.back();
elements_.pop_back();
return true;
}
} // namespace XLS

View File

@ -31,26 +31,29 @@
*/
#pragma once
#include "../CompositeObject.h"
#include "../include/FileTransporter.h"
#include <map>
namespace XLS
namespace NSNetwork
{
namespace NSFileTransport
{
class CSession_private
{
public:
std::map<std::string, std::string> m_props;
class SXDB: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(SXDB)
public:
SXDB();
~SXDB();
public:
CSession_private()
{
}
~CSession_private()
{
}
BaseObjectPtr clone();
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeSXDB;
BaseObjectPtr m_source;
};
} // namespace XLS
virtual void Create() {}
};
CSession_private* CreateSession();
}
}

View File

@ -0,0 +1,291 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <list>
#include "./../include/manager.h"
#include "./../../../core/DesktopEditor/graphics/TemporaryCS.h"
#include "./../../../core/DesktopEditor/graphics/BaseThread.h"
namespace ASC
{
class CDownloadTask : public IDownloadTask, public NSThreads::CBaseThread
{
public:
std::wstring Directory;
std::wstring FileName;
std::wstring Url;
DownloadStatus Status;
int ID;
void* Observer;
std::function<void(CDownloadTask*)> Handler;
bool IsDeleted;
CDownloadManager_private* m_manager;
public:
CDownloadTask(CDownloadManager_private* manager) : IDownloadTask()
{
m_manager = manager;
IsDeleted = false;
Observer = nullptr;
Handler = nullptr;
}
virtual ~CDownloadTask()
{
}
virtual DWORD ThreadProc();
public:
std::wstring GetPath()
{
return Directory + L"/" + FileName;
}
DownloadStatus GetStatus()
{
return Status;
}
std::wstring GetUrl()
{
return Url;
}
};
class CDownloadManager_private
{
public:
NSCriticalSection::CRITICAL_SECTION m_oCS;
NSNetwork::NSFileTransport::CSession m_oSession;
std::list<CDownloadTask*> m_arTasks;
std::list<CDownloadTask*> m_arWaitTasks;
int m_nMaxConcurrentDownloadCount;
int m_nTaskID;
int m_nPriority;
public:
CDownloadManager_private()
{
m_oCS.InitializeCriticalSection();
m_nMaxConcurrentDownloadCount = 5;
m_nTaskID = 0;
m_nPriority = 0;
}
~CDownloadManager_private()
{
Clear();
}
public:
IDownloadTask* Create(const std::wstring& url,
const std::wstring& directory,
const std::wstring& filename,
void* observer,
std::function<void(IDownloadTask*)> handler)
{
CTemporaryCS oCS(&m_oCS);
CDownloadTask* pTask = new CDownloadTask(this);
pTask->Url = url;
pTask->Directory = directory;
pTask->FileName = filename;
pTask->Observer = observer;
pTask->Handler = handler;
pTask->ID = m_nTaskID++;
if (m_nMaxConcurrentDownloadCount > (int)m_arTasks.size())
{
m_arTasks.push_back(pTask);
pTask->DestroyOnFinish();
pTask->Start(m_nPriority);
}
else
{
m_arWaitTasks.push_back(pTask);
}
return pTask;
}
void OnDownloadTask(CDownloadTask* task)
{
m_oCS.Enter();
for (std::list<CDownloadTask*>::iterator iter = m_arTasks.begin(); iter != m_arTasks.end(); iter++)
{
if (task == (*iter))
{
m_arTasks.erase(iter);
break;
}
}
if (!m_arWaitTasks.empty())
{
std::list<CDownloadTask*>::iterator iter = m_arWaitTasks.begin();
CDownloadTask* pNewTask = *iter;
m_arWaitTasks.erase(iter);
m_arTasks.push_back(pNewTask);
pNewTask->DestroyOnFinish();
pNewTask->Start(m_nPriority);
}
m_oCS.Leave();
if (task->Handler)
task->Handler(task);
}
void OnDestroyObserver(void* observer)
{
CTemporaryCS oCS(&m_oCS);
for (std::list<CDownloadTask*>::iterator iter = m_arTasks.begin(); iter != m_arTasks.end(); iter++)
{
(*iter)->Handler = nullptr;
}
for (std::list<CDownloadTask*>::iterator iter = m_arWaitTasks.begin(); iter != m_arWaitTasks.end();)
{
CDownloadTask* pTask = *iter;
if (pTask->Observer == observer)
{
iter = m_arTasks.erase(iter);
delete pTask;
}
else
iter++;
}
}
void Clear()
{
m_oCS.Enter();
for (std::list<CDownloadTask*>::iterator iter = m_arWaitTasks.begin(); iter != m_arWaitTasks.end();)
{
CDownloadTask* pTask = *iter;
delete pTask;
}
m_arWaitTasks.clear();
for (std::list<CDownloadTask*>::iterator iter = m_arTasks.begin(); iter != m_arTasks.end(); iter++)
{
(*iter)->Handler = nullptr;
}
m_oCS.Leave();
while (!m_arTasks.empty())
NSThreads::Sleep(100);
}
};
DWORD CDownloadTask::ThreadProc()
{
NSNetwork::NSFileTransport::CFileDownloader oDownloader(Url, false);
oDownloader.SetSession(&m_manager->m_oSession);
oDownloader.SetFilePath(GetPath());
oDownloader.Start( 0 );
while ( oDownloader.IsRunned() )
{
NSThreads::Sleep( 10 );
}
Status = oDownloader.IsFileDownloaded() ? ASC::Success : ASC::Error;
m_manager->OnDownloadTask(this);
return 0;
}
// INTERFACE
IDownloadTask::IDownloadTask() {}
IDownloadTask::~IDownloadTask() {}
CDownloadManager::CDownloadManager()
{
m_internal = new CDownloadManager_private();
}
CDownloadManager::~CDownloadManager()
{
Clear();
delete m_internal;
}
NSNetwork::NSFileTransport::CSession* CDownloadManager::GetSession()
{
return &m_internal->m_oSession;
}
void CDownloadManager::SetMaxConcurrentDownloadCount(const int& count)
{
m_internal->m_nMaxConcurrentDownloadCount = count;
}
void CDownloadManager::AddTask(const std::wstring& url,
const std::wstring& directory,
const std::wstring& filename,
void* observer,
std::function<void(IDownloadTask*)> handler)
{
m_internal->Create(url, directory, filename, observer, handler);
}
void CDownloadManager::OnDestroyObserver(void* observer)
{
m_internal->OnDestroyObserver(observer);
}
void CDownloadManager::Clear()
{
m_internal->Clear();
}
bool CDownloadManager::DownloadExternal(const std::wstring& url, const std::wstring& path)
{
NSNetwork::NSFileTransport::CFileDownloader oDownloader(url, false);
oDownloader.SetFilePath(path);
oDownloader.Start( 0 );
while ( oDownloader.IsRunned() )
{
NSThreads::Sleep( 10 );
}
return oDownloader.IsFileDownloaded();
}
}

View File

@ -59,8 +59,9 @@ libsocketio {
_WEBSOCKETPP_CPP11_CHRONO_ \
\
"SIO_TLS=1" \
"SIO_TLS_NO=0" \
"PING_TIMEOUT_INTERVAL=20000"
"SIO_TLS_NO=0"
#DEFINES += "PING_TIMEOUT_INTERVAL=20000"
include($$PWD/../../3dParty/boost/boost.pri)

View File

@ -243,3 +243,4 @@
#define AVS_FILEUTILS_ERROR_CONVERT_ICU (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005c)
#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)

File diff suppressed because it is too large Load Diff

View File

@ -1,891 +0,0 @@
/*
* (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 _BUILD_EDITOR_DEFINES_CROSSPLATFORM_H_
#define _BUILD_EDITOR_DEFINES_CROSSPLATFORM_H_
#define g_bDate1904 = false;
#define CellValueType_Number 0
#define CellValueType_String 1
#define CellValueType_Bool 2
#define CellValueType_Error 3
//NumFormat defines
#define c_oAscNumFormatType_General 0
#define c_oAscNumFormatType_Custom 1
#define c_oAscNumFormatType_Text 2
#define c_oAscNumFormatType_Number 3
#define c_oAscNumFormatType_Integer 4
#define c_oAscNumFormatType_Scientific 5
#define c_oAscNumFormatType_Currency 6
#define c_oAscNumFormatType_Date 7
#define c_oAscNumFormatType_Time 8
#define c_oAscNumFormatType_Percent 9
#define c_oAscNumFormatType_Fraction 10
#define c_oAscDrawingLayerType_BringToFront 0
#define c_oAscDrawingLayerType_BringForward 1
#define c_oAscDrawingLayerType_SendToBack 2
#define c_oAscDrawingLayerType_SendBackward 3
#define c_oAscTransactionState_No -1
#define c_oAscTransactionState_Start 0
#define c_oAscTransactionState_Stop 1
#define c_oAscCellAnchorType_cellanchorAbsolute 0
#define c_oAscCellAnchorType_cellanchorOneCell 1
#define c_oAscCellAnchorType_cellanchorTwoCell 2
#define c_oAscChartDefines_defaultChartWidth 478
#define c_oAscChartDefines_defaultChartHeight 286
#define c_oAscLineDrawingRule_Left 0
#define c_oAscLineDrawingRule_Center 1
#define c_oAscLineDrawingRule_Right 2
#define c_oAscLineDrawingRule_Top 0
#define c_oAscLineDrawingRule_Bottom 2
#define align_Right 0
#define align_Left 1
#define align_Center 2
#define align_Justify 3
#define linerule_AtLeast 0
#define linerule_Auto 1
#define linerule_Exact 2
#define shd_Clear 0
#define shd_Nil 1
#define vertalign_Baseline 0
#define vertalign_SuperScript 1
#define vertalign_SubScript 2
#define hdrftr_Header 0x01
#define hdrftr_Footer 0x02
#define c_oAscChartTitleShowSettings_none 0
#define c_oAscChartTitleShowSettings_overlay 1
#define c_oAscChartTitleShowSettings_noOverlay 2
#define c_oAscChartHorAxisLabelShowSettings_none 0
#define c_oAscChartHorAxisLabelShowSettings_noOverlay 1
#define c_oAscChartVertAxisLabelShowSettings_none 0
#define c_oAscChartVertAxisLabelShowSettings_rotated 1
#define c_oAscChartVertAxisLabelShowSettings_vertical 2
#define c_oAscChartVertAxisLabelShowSettings_horizontal 3
#define c_oAscChartLegendShowSettings_none 0
#define c_oAscChartLegendShowSettings_left 1
#define c_oAscChartLegendShowSettings_top 2
#define c_oAscChartLegendShowSettings_right 3
#define c_oAscChartLegendShowSettings_bottom 4
#define c_oAscChartLegendShowSettings_leftOverlay 5
#define c_oAscChartLegendShowSettings_rightOverlay 6
#define c_oAscChartLegendShowSettings_layout 7
#define c_oAscChartDataLabelsPos_none 0
#define c_oAscChartDataLabelsPos_b 1
#define c_oAscChartDataLabelsPos_bestFit 2
#define c_oAscChartDataLabelsPos_ctr 3
#define c_oAscChartDataLabelsPos_inBase 4
#define c_oAscChartDataLabelsPos_inEnd 5
#define c_oAscChartDataLabelsPos_l 6
#define c_oAscChartDataLabelsPos_outEnd 7
#define c_oAscChartDataLabelsPos_r 8
#define c_oAscChartDataLabelsPos_t 9
#define c_oAscChartCatAxisSettings_none 0
#define c_oAscChartCatAxisSettings_leftToRight 1
#define c_oAscChartCatAxisSettings_rightToLeft 2
#define c_oAscChartCatAxisSettings_noLabels 3
#define c_oAscChartValAxisSettings_none 0
#define c_oAscChartValAxisSettings_byDefault 1
#define c_oAscChartValAxisSettings_thousands 2
#define c_oAscChartValAxisSettings_millions 3
#define c_oAscChartValAxisSettings_billions 4
#define c_oAscChartValAxisSettings_log 5
#define c_oAscAxisTypeSettings_vert 0
#define c_oAscAxisTypeSettings_hor 1
#define c_oAscGridLinesSettings_none 0
#define c_oAscGridLinesSettings_major 1
#define c_oAscGridLinesSettings_minor 2
#define c_oAscGridLinesSettings_majorMinor 3
#define c_oAscChartTypeSettings_barNormal 0
#define c_oAscChartTypeSettings_barStacked 1
#define c_oAscChartTypeSettings_barStackedPer 2
#define c_oAscChartTypeSettings_barNormal3d 3
#define c_oAscChartTypeSettings_barStacked3d 4
#define c_oAscChartTypeSettings_barStackedPer3d 5
#define c_oAscChartTypeSettings_barNormal3dPerspective 6
#define c_oAscChartTypeSettings_lineNormal 7
#define c_oAscChartTypeSettings_lineStacked 8
#define c_oAscChartTypeSettings_lineStackedPer 9
#define c_oAscChartTypeSettings_lineNormalMarker 10
#define c_oAscChartTypeSettings_lineStackedMarker 11
#define c_oAscChartTypeSettings_lineStackedPerMarker 12
#define c_oAscChartTypeSettings_line3d 13
#define c_oAscChartTypeSettings_pie 14
#define c_oAscChartTypeSettings_pie3d 15
#define c_oAscChartTypeSettings_hBarNormal 16
#define c_oAscChartTypeSettings_hBarStacked 17
#define c_oAscChartTypeSettings_hBarStackedPer 18
#define c_oAscChartTypeSettings_hBarNormal3d 19
#define c_oAscChartTypeSettings_hBarStacked3d 20
#define c_oAscChartTypeSettings_hBarStackedPer3d 21
#define c_oAscChartTypeSettings_areaNormal 22
#define c_oAscChartTypeSettings_areaStacked 23
#define c_oAscChartTypeSettings_areaStackedPer 24
#define c_oAscChartTypeSettings_doughnut 25
#define c_oAscChartTypeSettings_stock 26
#define c_oAscChartTypeSettings_scatter 27
#define c_oAscChartTypeSettings_scatterLine 28
#define c_oAscChartTypeSettings_scatterLineMarker 29
#define c_oAscChartTypeSettings_scatterMarker 30
#define c_oAscChartTypeSettings_scatterNone 31
#define c_oAscChartTypeSettings_scatterSmooth 32
#define c_oAscChartTypeSettings_scatterSmoothMarker 33
#define c_oAscChartTypeSettings_unknown 34
#define c_oAscValAxisRule_auto 0
#define c_oAscValAxisRule_fixed 1
#define c_oAscValAxUnits_none 0
#define c_oAscValAxUnits_BILLIONS 1
#define c_oAscValAxUnits_HUNDRED_MILLIONS 2
#define c_oAscValAxUnits_HUNDREDS 3
#define c_oAscValAxUnits_HUNDRED_THOUSANDS 4
#define c_oAscValAxUnits_MILLIONS 5
#define c_oAscValAxUnits_TEN_MILLIONS 6
#define c_oAscValAxUnits_TEN_THOUSANDS 7
#define c_oAscValAxUnits_TRILLIONS 8
#define c_oAscValAxUnits_CUSTOM 9
#define c_oAscValAxUnits_THOUSANDS 10
#define c_oAscTickMark_TICK_MARK_CROSS 0
#define c_oAscTickMark_TICK_MARK_IN 1
#define c_oAscTickMark_TICK_MARK_NONE 2
#define c_oAscTickMark_TICK_MARK_OUT 3
#define c_oAscTickLabelsPos_TICK_LABEL_POSITION_HIGH 0
#define c_oAscTickLabelsPos_TICK_LABEL_POSITION_LOW 1
#define c_oAscTickLabelsPos_TICK_LABEL_POSITION_NEXT_TO 2
#define c_oAscTickLabelsPos_TICK_LABEL_POSITION_NONE 3
#define c_oAscCrossesRule_auto 0
#define c_oAscCrossesRule_maxValue 1
#define c_oAscCrossesRule_value 2
#define c_oAscCrossesRule_minValue 3
#define c_oAscHorAxisType_auto 0
#define c_oAscHorAxisType_date 1
#define c_oAscHorAxisType_text 2
#define c_oAscBetweenLabelsRule_auto 0
#define c_oAscBetweenLabelsRule_manual 1
#define c_oAscLabelsPosition_byDivisions 0
#define c_oAscLabelsPosition_betweenDivisions 1
#define c_oAscAxisType_auto 0
#define c_oAscAxisType_date 1
#define c_oAscAxisType_text 2
#define c_oAscAxisType_cat 3
#define c_oAscAxisType_val 4
#define c_oAscHAnchor_Margin 0x00
#define c_oAscHAnchor_Page 0x01
#define c_oAscHAnchor_Text 0x02
#define c_oAscHAnchor_PageInternal 0xFF // только для внутреннего использования
#define c_oAscXAlign_Center 0x00
#define c_oAscXAlign_Inside 0x01
#define c_oAscXAlign_Left 0x02
#define c_oAscXAlign_Outside 0x03
#define c_oAscXAlign_Right 0x04
#define c_oAscYAlign_Bottom 0x00
#define c_oAscYAlign_Center 0x01
#define c_oAscYAlign_Inline 0x02
#define c_oAscYAlign_Inside 0x03
#define c_oAscYAlign_Outside 0x04
#define c_oAscYAlign_Top 0x05
#define c_oAscVAnchor_Margin 0x00
#define c_oAscVAnchor_Page 0x01
#define c_oAscVAnchor_Text 0x02
#define c_oAscRelativeFromH_Character 0x00
#define c_oAscRelativeFromH_Column 0x01
#define c_oAscRelativeFromH_InsideMargin 0x02
#define c_oAscRelativeFromH_LeftMargin 0x03
#define c_oAscRelativeFromH_Margin 0x04
#define c_oAscRelativeFromH_OutsideMargin 0x05
#define c_oAscRelativeFromH_Page 0x06
#define c_oAscRelativeFromH_RightMargin 0x07
#define c_oAscRelativeFromV_BottomMargin 0x00
#define c_oAscRelativeFromV_InsideMargin 0x01
#define c_oAscRelativeFromV_Line 0x02
#define c_oAscRelativeFromV_Margin 0x03
#define c_oAscRelativeFromV_OutsideMargin 0x04
#define c_oAscRelativeFromV_Page 0x05
#define c_oAscRelativeFromV_Paragraph 0x06
#define c_oAscRelativeFromV_TopMargin 0x07
// image wrap style
#define c_oAscWrapStyle_Inline 0
#define c_oAscWrapStyle_Flow 1
// math
#define c_oAscLimLoc_SubSup 0x00
#define c_oAscLimLoc_UndOvr 0x01
#define c_oAscMathJc_Center 0x00
#define c_oAscMathJc_CenterGroup 0x01
#define c_oAscMathJc_Left 0x02
#define c_oAscMathJc_Right 0x03
#define c_oAscTopBot_Bot 0x00
#define c_oAscTopBot_Top 0x01
#define c_oAscScript_DoubleStruck 0x00
#define c_oAscScript_Fraktur 0x01
#define c_oAscScript_Monospace 0x02
#define c_oAscScript_Roman 0x03
#define c_oAscScript_SansSerif 0x04
#define c_oAscScript_Script 0x05
#define c_oAscShp_Centered 0x00
#define c_oAscShp_Match 0x01
#define c_oAscSty_Bold 0x00
#define c_oAscSty_BoldItalic 0x01
#define c_oAscSty_Italic 0x02
#define c_oAscSty_Plain 0x03
#define c_oAscFType_Bar 0x00
#define c_oAscFType_Lin 0x01
#define c_oAscFType_NoBar 0x02
#define c_oAscFType_Skw 0x03
#define c_oAscBrkBin_After 0x00
#define c_oAscBrkBin_Before 0x01
#define c_oAscBrkBin_Repeat 0x02
#define c_oAscBrkBinSub_PlusMinus 0x00
#define c_oAscBrkBinSub_MinusPlus 0x01
#define c_oAscBrkBinSub_MinusMinus 0x02
// Толщина бордера
#define c_oAscBorderWidth_None 0 // 0px
#define c_oAscBorderWidth_Thin 1 // 1px
#define c_oAscBorderWidth_Medium 2 // 2px
#define c_oAscBorderWidth_Thick 3 // 3px
// Располагаются в порядке значимости для отрисовки
#define c_oAscBorderStyles_None 0
#define c_oAscBorderStyles_Double 1
#define c_oAscBorderStyles_Hair 2
#define c_oAscBorderStyles_DashDotDot 3
#define c_oAscBorderStyles_DashDot 4
#define c_oAscBorderStyles_Dotted 5
#define c_oAscBorderStyles_Dashed 6
#define c_oAscBorderStyles_Thin 7
#define c_oAscBorderStyles_MediumDashDotDot 8
#define c_oAscBorderStyles_SlantDashDot 9
#define c_oAscBorderStyles_MediumDashDot 10
#define c_oAscBorderStyles_MediumDashed 11
#define c_oAscBorderStyles_Medium 12
#define c_oAscBorderStyles_Thick 13
// PageOrientation
#define c_oAscPageOrientation_PagePortrait 1
#define c_oAscPageOrientation_PageLandscape 2
/**
* lock types
* @const
*/
#define c_oAscLockTypes_kLockTypeNone 1 // никто не залочил данный объект
#define c_oAscLockTypes_kLockTypeMine 2 // данный объект залочен текущим пользователем
#define c_oAscLockTypes_kLockTypeOther 3 // данный объект залочен другим(не текущим) пользователем
#define c_oAscLockTypes_kLockTypeOther2 4 // данный объект залочен другим(не текущим) пользователем (обновления уже пришли)
#define c_oAscLockTypes_kLockTypeOther3 5 // данный объект был залочен (обновления пришли) и снова стал залочен
#define c_oAscFormatPainterState_kOff 0
#define c_oAscFormatPainterState_kOn 1
#define c_oAscFormatPainterState_kMultiple 2
#define c_oAscZoomType_Current 0
#define c_oAscZoomType_FitWidth 1
#define c_oAscZoomType_FitPage 2
#define c_oAscLockLockTypeNone 1 // никто не залочил данный объект
#define c_oAscLockLockTypeMine 2 // данный объект залочен текущим пользователем
#define c_oAscLockLockTypeOther 3 // данный объект залочен другим(не текущим) пользователем
#define c_oAscLockLockTypeOther2 4 // данный объект залочен другим(не текущим) пользователем (обновления уже пришли)
#define c_oAscLockLockTypeOther3 5 // данный объект был залочен (обновления пришли) и снова стал залочен
#define c_oAscAsyncActionType_Information 0
#define c_oAscAsyncActionType_BlockInteraction 1
#define c_oAscAsyncAction_Open 0 // открытие документа
#define c_oAscAsyncAction_Save 1
#define c_oAscAsyncAction_LoadDocumentFonts 2 // загружаем фонты документа (сразу после открытия)
#define c_oAscAsyncAction_LoadDocumentImages 3 // загружаем картинки документа (сразу после загрузки шрифтов)
#define c_oAscAsyncAction_ LoadFont 4 // подгрузка нужного шрифта
#define c_oAscAsyncAction_LoadImage 5 // подгрузка картинки
#define c_oAscAsyncAction_DownloadAs 6
#define c_oAscAsyncAction_Print 7 // конвертация в PDF и сохранение у пользователя
#define c_oAscAsyncAction_UploadImage 8
#define c_oAscAsyncAction_ApplyChanges 9 // применение изменений от другого пользователя.
#define c_oAscAsyncAction_PrepareToSave 10 // Подготовка к сохранению
//files type for Saving & DownloadAs
#define c_oAscFileType_INNER 0x0041
#define c_oAscFileType_DOCX 0x0041
#define c_oAscFileType_DOC 0x0042
#define c_oAscFileType_ODT 0x0043
#define c_oAscFileType_RTF 0x0044
#define c_oAscFileType_TXT 0x0045
#define c_oAscFileType_HTML_ZIP 0x0803
#define c_oAscFileType_MHT 0x0047
#define c_oAscFileType_PDF 0x0201
#define c_oAscFileType_EPUB 0x0048
#define c_oAscFileType_FB2 0x0049
#define c_oAscFileType_MOBI 0x004a
#define c_oAscFileType_DOCY 0x1001
// Right = 0; Left = 1; Center = 2; Justify = 3;
#define c_oAscAlignType_LEFT 0
#define c_oAscAlignType_CENTER 1
#define c_oAscAlignType_RIGHT 2
#define c_oAscAlignType_JUSTIFY 3
#define c_oAscAlignType_TOP 4
#define c_oAscAlignType_MIDDLE 5
#define c_oAscAlignType_BOTTOM 6
#define c_oAscWrapStyle2_Inline 0
#define c_oAscWrapStyle2_Square 1
#define c_oAscWrapStyle2_Tight 2
#define c_oAscWrapStyle2_Through 3
#define c_oAscWrapStyle2_TopAndBottom 4
#define c_oAscWrapStyle2_Behind 5
#define c_oAscWrapStyle2_InFront 6
/*Error level & ID*/
#define c_oAscError_Level_Critical -1
#define c_oAscError_Level_NoCritical 0
#define c_oAscError_ID_ServerSaveComplete 3
#define c_oAscError_ID_ConvertationProgress 2
#define c_oAscError_ID_DownloadProgress 1
#define c_oAscError_ID_No 0
#define c_oAscError_ID_Unknown -1
#define c_oAscError_ID_ConvertationTimeout -2
#define c_oAscError_ID_ConvertationError -3
#define c_oAscError_ID_DownloadError -4
#define c_oAscError_ID_UnexpectedGuid -5
#define c_oAscError_ID_Database -6
#define c_oAscError_ID_FileRequest -7
#define c_oAscError_ID_FileVKey -8
#define c_oAscError_ID_UplImageSize -9
#define c_oAscError_ID_UplImageExt -10
#define c_oAscError_ID_UplImageFileCount -11
#define c_oAscError_ID_NoSupportClipdoard -12
#define c_oAscError_ID_UplImageUrl -13
#define c_oAscError_ID_StockChartError -17
#define c_oAscError_ID_CoAuthoringDisconnect -18
#define c_oAscError_ID_ConvertationPassword -19
#define c_oAscError_ID_VKeyEncrypt -20
#define c_oAscError_ID_KeyExpire -21
#define c_oAscError_ID_UserCountExceed -22
#define c_oAscError_ID_SplitCellMaxRows -30
#define c_oAscError_ID_SplitCellMaxCols -31
#define c_oAscError_ID_SplitCellRowsDivider -32
#define c_oAscError_ID_MobileUnexpectedCharCount -35
#define c_oAscError_ID_MailMergeLoadFile -40
#define c_oAscError_ID_MailMergeSaveFile -41
#define c_oAscError_ID_AutoFilterDataRangeError -50
#define c_oAscError_ID_AutoFilterChangeFormatTableError -51
#define c_oAscError_ID_AutoFilterChangeError -52
#define c_oAscError_ID_AutoFilterMoveToHiddenRangeError -53
#define c_oAscError_ID_LockedAllError -54
#define c_oAscError_ID_LockedWorksheetRename -55
#define c_oAscError_ID_FTChangeTableRangeError -56
#define c_oAscError_ID_FTRangeIncludedOtherTables -57
#define c_oAscError_ID_PasteMaxRangeError -64
#define c_oAscError_ID_PastInMergeAreaError -65
#define c_oAscError_ID_DataRangeError -72
#define c_oAscError_ID_CannotMoveRange -71
#define c_oAscError_ID_MaxDataSeriesError -80
#define c_oAscError_ID_CannotFillRange -81
#define c_oAscError_ID_UserDrop -100
#define c_oAscError_ID_Warning -101
#define c_oAscError_ID_FrmlWrongCountParentheses -300
#define c_oAscError_ID_FrmlWrongOperator -301
#define c_oAscError_ID_FrmlWrongMaxArgument -302
#define c_oAscError_ID_FrmlWrongCountArgument -303
#define c_oAscError_ID_FrmlWrongFunctionName -304
#define c_oAscError_ID_FrmlAnotherParsingError -305
#define c_oAscError_ID_FrmlWrongArgumentRange -306
#define c_oAscError_ID_FrmlOperandExpected -307
#define c_oAscError_ID_FrmlParenthesesCorrectCount -308
#define c_oAscError_ID_FrmlWrongReferences -309
#define c_oAscError_ID_InvalidReferenceOrName -310
#define c_oAscError_ID_LockCreateDefName -311
#define c_oAscError_ID_OpenWarning 500
#define c_oAscError_ID_EvaluteJSError -1000
#define c_oAscTypeSelectElement_Paragraph 0
#define c_oAscTypeSelectElement_Table 1
#define c_oAscTypeSelectElement_Image 2
#define c_oAscTypeSelectElement_Header 3
#define c_oAscTypeSelectElement_Hyperlink 4
#define c_oAscTypeSelectElement_SpellCheck 5
#define c_oAscTypeSelectElement_Shape 6
#define c_oAscTypeSelectElement_Slide 7
#define c_oAscTypeSelectElement_Chart 8
#define c_oAscTypeSelectElement_Math 9
#define c_oAscTypeSelectElement_MailMerge 10
#define c_oAscTypeSelectElement_ContentControl 11
#define c_oAscTableBordersType_LEFT 0
#define c_oAscTableBordersType_TOP 1
#define c_oAscTableBordersType_RIGHT 2
#define c_oAscTableBordersType_BOTTOM 3
#define c_oAscTableBordersType_VERTLINE 4
#define c_oAscTableBordersType_HORIZONTLINE 5
#define c_oAscTableBordersType_INSIDE 6
#define c_oAscTableBordersType_OUTSIDE 7
#define c_oAscTableBordersType_ALL 8
#define FONT_THUMBNAIL_HEIGHT 26
#define c_oAscStyleImage_Default 0
#define c_oAscStyleImage_Document 1
#define c_oAscLineDrawingRule_Left 0
#define c_oAscLineDrawingRule_Center 1
#define c_oAscLineDrawingRule_Right 2
#define c_oAscLineDrawingRule_Top 0
#define c_oAscLineDrawingRule_Bottom 2
// Chart defines
#define c_oAscChartType_line 0
#define c_oAscChartType_bar 1
#define c_oAscChartType_hbar 2
#define c_oAscChartType_area 3
#define c_oAscChartType_pie 4
#define c_oAscChartType_scatter 5
#define c_oAscChartType_stock 6
#define c_oAscChartSubType_normal 0
#define c_oAscChartSubType_stacked 1
#define c_oAscChartSubType_stackedPer 2
#define vertalign_Baseline 0
#define vertalign_SuperScript 1
#define vertalign_SubScript 2
#define hdrftr_Header 0x01
#define hdrftr_Footer 0x02
#define hdrftr_Default 0x01
#define hdrftr_Even 0x02
#define hdrftr_First 0x03
#define c_oAscTableSelectionType_Cell 0
#define c_oAscTableSelectionType_Row 1
#define c_oAscTableSelectionType_Column 2
#define c_oAscTableSelectionType_Table 3
#define linerule_AtLeast 0
#define linerule_Auto 1
#define linerule_Exact 2
#define shd_Clear 0
#define shd_Nil 1
#define c_oAscHyperlinkType_InternalLink 0
#define c_oAscHyperlinkType_WebLink 1
#define c_oAscHyperlinkType_RangeLink 2
#define c_oAscContextMenuTypes_Common 0 // Обычное контекстное меню
#define c_oAscContextMenuTypes_ChangeHdrFtr 1 // Специальное контестное меню для попадания в колонтитул
#define c_oAscMouseMoveDataTypes_Common 0
#define c_oAscMouseMoveDataTypes_Hyperlink 1
#define c_oAscMouseMoveDataTypes_LockedObject 2
#define c_oAscMouseMoveLockedObjectType_Common 0
#define c_oAscMouseMoveLockedObjectType_Header 1
#define c_oAscMouseMoveLockedObjectType_Footer 2
#define c_oAscCollaborativeMarksShowType_None -1
#define c_oAscCollaborativeMarksShowType_All 0
#define c_oAscCollaborativeMarksShowType_LastChanges 1
#define c_oAscAlignH_Center 0x00
#define c_oAscAlignH_Inside 0x01
#define c_oAscAlignH_Left 0x02
#define c_oAscAlignH_Outside 0x03
#define c_oAscAlignH_Right 0x04
#define c_oAscChangeLevel_BringToFront 0x00
#define c_oAscChangeLevel_BringForward 0x01
#define c_oAscChangeLevel_SendToBack 0x02
#define c_oAscChangeLevel_BringBackward 0x03
#define c_oAscAlignV_Bottom 0x00
#define c_oAscAlignV_Center 0x01
#define c_oAscAlignV_Inside 0x02
#define c_oAscAlignV_Outside 0x03
#define c_oAscAlignV_Top 0x04
#define c_oAscVertAlignJc_Top 0x00
#define c_oAscVertAlignJc_Center 0x01
#define c_oAscVertAlignJc_Bottom 0x02
#define c_oAscTableLayout_AutoFit 0x00
#define c_oAscTableLayout_Fixed 0x01
#define c_oAscColor_COLOR_TYPE_SRGB 1
#define c_oAscColor_COLOR_TYPE_PRST 2
#define c_oAscColor_COLOR_TYPE_SCHEME 3
#define c_oAscFill_FILL_TYPE_BLIP 1
#define c_oAscFill_FILL_TYPE_NOFILL 2
#define c_oAscFill_FILL_TYPE_SOLID 3
#define c_oAscFill_FILL_TYPE_GRAD 4
#define c_oAscFill_FILL_TYPE_PATT 5
#define c_oAscFillGradType_GRAD_LINEAR 1
#define c_oAscFillGradType_GRAD_PATH 2
#define c_oAscFillBlipType_STRETCH 1
#define c_oAscFillBlipType_TILE 2
#define c_oAscStrokeType_STROKE_NONE 0
#define c_oAscStrokeType_STROKE_COLOR 1
#define c_oAscAlignShapeType_ALIGN_LEFT 0
#define c_oAscAlignShapeType_ALIGN_RIGHT 1
#define c_oAscAlignShapeType_ALIGN_TOP 2
#define c_oAscAlignShapeType_ALIGN_BOTTOM 3
#define c_oAscAlignShapeType_ALIGN_CENTER 4
#define c_oAscAlignShapeType_ALIGN_MIDDLE 5
#define c_oAscVerticalTextAlign_TEXT_ALIGN_BOTTOM 0 // (Text Anchor Enum ( Bottom ))
#define c_oAscVerticalTextAlign_TEXT_ALIGN_CTR 1 // (Text Anchor Enum ( Center ))
#define c_oAscVerticalTextAlign_TEXT_ALIGN_DIST 2 // (Text Anchor Enum ( Distributed ))
#define c_oAscVerticalTextAlign_TEXT_ALIGN_JUST 3 // (Text Anchor Enum ( Justified ))
#define c_oAscVerticalTextAlign_TEXT_ALIGN_TOP 4 // Top
#define c_oAscLineJoinType_Round 1
#define c_oAscLineJoinType_Bevel 2
#define c_oAscLineJoinType_Miter 3
#define c_oAscLineCapType_Flat 0
#define c_oAscLineCapType_Round 1
#define c_oAscLineCapType_Square 2
#define c_oAscLineBeginType_None 0
#define c_oAscLineBeginType_Arrow 1
#define c_oAscLineBeginType_Diamond 2
#define c_oAscLineBeginType_Oval 3
#define c_oAscLineBeginType_Stealth 4
#define c_oAscLineBeginType_Triangle 5
#define c_oAscLineBeginSize_small_small 0
#define c_oAscLineBeginSize_small_mid 1
#define c_oAscLineBeginSize_small_large 2
#define c_oAscLineBeginSize_mid_small 3
#define c_oAscLineBeginSize_mid_mid 4
#define c_oAscLineBeginSize_mid_large 5
#define c_oAscLineBeginSize_large_small 6
#define c_oAscLineBeginSize_large_mid 7
#define c_oAscLineBeginSize_large_large 8
#define TABLE_STYLE_WIDTH_PIX 70
#define TABLE_STYLE_HEIGHT_PIX 50
#define c_oAscDropCap_None 0
#define c_oAscDropCap_Drop 1
#define c_oAscDropCap_Margin 2
#define c_oAsc_wrap_Around 0x01
#define c_oAsc_wrap_Auto 0x02
#define c_oAsc_wrap_None 0x03
#define c_oAsc_wrap_NotBeside 0x04
#define c_oAsc_wrap_Through 0x05
#define c_oAsc_wrap_Tight 0x06
#define c_oAscSectionBreakType_NextPage 0x00
#define c_oAscSectionBreakType_OddPage 0x01
#define c_oAscSectionBreakType_EvenPage 0x02
#define c_oAscSectionBreakType_Continuous 0x03
#define c_oAscSectionBreakType_Column 0x04
#define c_oAscRestriction_None 0x00
#define c_oAscRestriction_OnlyForms 0x01
#define c_oAscRestriction_OnlyComments 0x02
#define c_oAscRestriction_OnlySignatures 0x04
#define c_oAscRestriction_View 0x80
#define c_oAscAdvancedOptionsID_CSV 0
#define c_oAscAdvancedOptionsID_TXT 1
#define c_oAscAdvancedOptionsID_DRM 2
#define c_oAscContentControlSpecificTypeNone 0
#define c_oAscContentControlSpecificTypeCheckBox 1
#define c_oAscContentControlSpecificTypePicture 2
#define c_oAscContentControlSpecificTypeComboBox 3
#define c_oAscContentControlSpecificTypeDropDownList 4
#define c_oAscContentControlSpecificTypeDateTime 5
#define c_oAscContentControlSpecificTypeTOC 10
#define c_oAscEDocProtectComments 0
#define c_oAscEDocProtectForms 1
#define c_oAscEDocProtectNone 2
#define c_oAscEDocProtectReadOnly 3
#define c_oAscEDocProtectTrackedChanges 4
#define INSERT_PAGE_NUM_PARAM(AlignV, AlignH) ((AlignV << 16) | AlignH)
// MENU COMMANDS
#define ASC_MENU_EVENT_TYPE_TEXTPR 1
#define ASC_MENU_EVENT_TYPE_PARAPR 2
#define ASC_MENU_EVENT_TYPE_UNDO 3
#define ASC_MENU_EVENT_TYPE_REDO 4
#define ASC_MENU_EVENT_TYPE_LOADDOCUMENT 5
#define ASC_MENU_EVENT_TYPE_STACK_OBJECTS 6
#define ASC_MENU_EVENT_TYPE_HEADERFOOTER 7
#define ASC_MENU_EVENT_TYPE_HYPERLINK 8
#define ASC_MENU_EVENT_TYPE_IMAGE 9
#define ASC_MENU_EVENT_TYPE_TABLE 10
#define ASC_MENU_EVENT_TYPE_PARAGRAPHSTYLES 11
#define ASC_MENU_EVENT_TYPE_TABLESTYLES 12
#define ASC_MENU_EVENT_TYPE_INCREASEPARAINDENT 13
#define ASC_MENU_EVENT_TYPE_DECREASEPARAINDENT 14
#define ASC_MENU_EVENT_TYPE_TABLEMERGECELLS 15
#define ASC_MENU_EVENT_TYPE_TABLESPLITCELLS 16
#define ASC_MENU_EVENT_TYPE_SECTION 17
#define ASC_MENU_EVENT_TYPE_SHAPE 18
#define ASC_MENU_EVENT_TYPE_SLIDE 20
#define ASC_MENU_EVENT_TYPE_CHART 21
#define ASC_MENU_EVENT_TYPE_MATH 22
// insert commands
#define ASC_MENU_EVENT_TYPE_INSERT_IMAGE 50
#define ASC_MENU_EVENT_TYPE_INSERT_TABLE 51
#define ASC_MENU_EVENT_TYPE_INSERT_HYPERLINK 52
#define ASC_MENU_EVENT_TYPE_INSERT_SHAPE 53
#define ASC_MENU_EVENT_TYPE_INSERT_PAGEBREAK 54
#define ASC_MENU_EVENT_TYPE_INSERT_LINEBREAK 55
#define ASC_MENU_EVENT_TYPE_INSERT_PAGENUMBER 56
#define ASC_MENU_EVENT_TYPE_INSERT_SECTIONBREAK 57
// hyperlink
#define ASC_MENU_EVENT_TYPE_CAN_ADD_HYPERLINK 58
#define ASC_MENU_EVENT_TYPE_REMOVE_HYPERLINK 59
// undo/redo
#define ASC_MENU_EVENT_TYPE_CAN_UNDO 60
#define ASC_MENU_EVENT_TYPE_CAN_REDO 61
#define ASC_MENU_EVENT_TYPE_SEARCH_FINDTEXT 62
#define ASC_MENU_EVENT_TYPE_SEARCH_REPLACETEXT 63
#define ASC_MENU_EVENT_TYPE_SEARCH_SELECTRESULTS 64
#define ASC_MENU_EVENT_TYPE_SEARCH_ISSELECTRESULTS 65
#define ASC_MENU_EVENT_TYPE_DOCUMETN_MODIFITY 66
// statictic
#define ASC_MENU_EVENT_TYPE_STATISTIC_START 67
#define ASC_MENU_EVENT_TYPE_STATISTIC_STOP 68
#define ASC_MENU_EVENT_TYPE_STATISTIC_END 69
#define ASC_MENU_EVENT_TYPE_STATISTIC_INFO 70
#define ASC_MENU_EVENT_TYPE_TABLE_INSERTDELETE_ROWCOLUMN 71
#define ASC_MENU_EVENT_TYPE_KEYBOARD_SHOW 100
#define ASC_MENU_EVENT_TYPE_KEYBOARD_UNSHOW 101
#define ASC_MENU_EVENT_TYPE_CONTEXTMENU_SHOW 102
#define ASC_MENU_EVENT_TYPE_CONTEXTMENU_UNSHOW 103
#define ASC_MENU_EVENT_TYPE_CONTEXTMENU_COMMANDS_AVAILIBLE 104
#define ASC_MENU_EVENT_TYPE_CONTEXTMENU_COPY 110
#define ASC_MENU_EVENT_TYPE_CONTEXTMENU_CUT 111
#define ASC_MENU_EVENT_TYPE_CONTEXTMENU_PASTE 112
#define ASC_MENU_EVENT_TYPE_CONTEXTMENU_DELETE 113
#define ASC_MENU_EVENT_TYPE_CONTEXTMENU_SELECT 114
#define ASC_MENU_EVENT_TYPE_CONTEXTMENU_SELECTALL 115
#define ASC_MENU_EVENT_TYPE_DOCUMENT_BASE64 200
#define ASC_MENU_EVENT_TYPE_DOCUMENT_CHARTSTYLES 201
#define ASC_MENU_EVENT_TYPE_DOCUMENT_PDFBASE64 202
#define ASC_MENU_EVENT_TYPE_DOCUMENT_PDFBASE64_PRINT 203
#define ASC_MENU_EVENT_TYPE_USER_SCROLL_PAGE 300
#define ASC_MENU_EVENT_TYPE_USER_ZOOM 301
#define ASC_MENU_EVENT_TYPE_INSERT_CHART 400
#define ASC_MENU_EVENT_TYPE_INSERT_SCREEN_IMAGE 401
#define ASC_MENU_EVENT_TYPE_ADD_CHART_DATA 440
#define ASC_MENU_EVENT_TYPE_GET_CHART_DATA 450
#define ASC_MENU_EVENT_TYPE_SET_CHART_DATA 460
#define ASC_MENU_EVENT_TYPE_ERROR 500
#define ASC_EVENT_TYPE_DROP_OPERATION_COPY_TEXT 600
#define ASC_MENU_EVENT_TYPE_COLOR_SCHEMES 2404 // CAscColorSchemes
#define ASC_MENU_EVENT_TYPE_CHANGE_COLOR_SCHEME 2415 // SET(int)
#define ASC_MENU_EVENT_TYPE_GET_COLOR_SCHEME 2416 // GET(int)
#define ASC_MENU_EVENT_TYPE_THEMECOLORS 2417
#define ASC_MENU_EVENT_TYPE_CHANGE_MOBILE_MODE 2500
#define ASC_MENU_EVENT_TYPE_GO_TO_INTERNAL_LINK 5000
#define ASC_SOCKET_EVENT_TYPE_OPEN 10000
#define ASC_SOCKET_EVENT_TYPE_ON_CLOSE 10010
#define ASC_SOCKET_EVENT_TYPE_MESSAGE 10020
#define ASC_SOCKET_EVENT_TYPE_ON_DISCONNECT 11010
#define ASC_SOCKET_EVENT_TYPE_TRY_RECONNECT 11020
#define ASC_COAUTH_EVENT_TYPE_PARTICIPANTS_CHANGED 20101
#define ASC_COAUTH_EVENT_TYPE_LOST_CONNECTION 20102
#define ASC_COAUTH_EVENT_TYPE_DROP_CONNECTION 20103
#define ASC_COAUTH_EVENT_TYPE_ERROR_CONNECTION 20104
#define ASC_COAUTH_EVENT_TYPE_INSERT_URL_IMAGE 21000
#define ASC_COAUTH_EVENT_TYPE_LOAD_URL_IMAGE 21001
#define ASC_COAUTH_EVENT_TYPE_REPLACE_URL_IMAGE 21002
#define ASC_COAUTH_EVENT_TYPE_INSERT_SCREEN_URL_IMAGE 21003
#define ASC_MENU_EVENT_TYPE_ADVANCED_OPTIONS 22000
#define ASC_MENU_EVENT_TYPE_SET_PASSWORD 22001
#define ASC_MENU_EVENT_TYPE_SET_TRANSLATIONS 22002
#define ASC_MENU_EVENT_TYPE_ON_EDIT_TEXT 22003
#define ASC_EVENT_TYPE_SPELLCHECK_MESSAGE 22004
#define ASC_EVENT_TYPE_SPELLCHECK_TURN_ON 22005
#define ASC_MENU_EVENT_TYPE_DO_NONPRINTING_DISPLAY 22006
#define ASC_MENU_EVENT_RUN_JS_SCRIPT 22007
#define ASC_MENU_EVENT_RUN_JS_SCRIPT_FUNCTION 22008
// Comments
#define ASC_MENU_EVENT_TYPE_ADD_COMMENT 23001
#define ASC_MENU_EVENT_TYPE_ADD_COMMENTS 23002
#define ASC_MENU_EVENT_TYPE_REMOVE_COMMENT 23003
#define ASC_MENU_EVENT_TYPE_CHANGE_COMMENTS 23004
#define ASC_MENU_EVENT_TYPE_REMOVE_COMMENTS 23005
#define ASC_MENU_EVENT_TYPE_CHANGE_COMMENT_DATA 23006
#define ASC_MENU_EVENT_TYPE_LOCK_COMMENT 23007
#define ASC_MENU_EVENT_TYPE_UNLOCK_COMMENT 23008
#define ASC_MENU_EVENT_TYPE_SHOW_COMMENT 23009
#define ASC_MENU_EVENT_TYPE_HIDE_COMMENT 23010
#define ASC_MENU_EVENT_TYPE_UPDATE_COMMENT_POSITION 23011
#define ASC_MENU_EVENT_TYPE_DOCUMENT_PLACE_CHANGED 23012
#define ASC_MENU_EVENT_TYPE_DO_SELECT_COMMENT 23101
#define ASC_MENU_EVENT_TYPE_DO_SHOW_COMMENT 23102
#define ASC_MENU_EVENT_TYPE_DO_SELECT_COMMENTS 23103
#define ASC_MENU_EVENT_TYPE_DO_DESELECT_COMMENTS 23104
#define ASC_MENU_EVENT_TYPE_DO_ADD_COMMENT 23105
#define ASC_MENU_EVENT_TYPE_DO_REMOVE_COMMENT 23106
#define ASC_MENU_EVENT_TYPE_DO_REMOVE_ALL_COMMENTS 23107
#define ASC_MENU_EVENT_TYPE_DO_CHANGE_COMMENT 23108
#define ASC_MENU_EVENT_TYPE_DO_CAN_ADD_QUOTED_COMMENT 23109
// Track reviews
#define ASC_MENU_EVENT_TYPE_SHOW_REVISIONS_CHANGE 24001
#define ASC_MENU_EVENT_TYPE_DO_SET_TRACK_REVISIONS 24101
#define ASC_MENU_EVENT_TYPE_DO_BEGIN_VIEWMODE_IN_REVIEW 24102
#define ASC_MENU_EVENT_TYPE_DO_END_VIEWMODE_IN_REVIEW 24103
#define ASC_MENU_EVENT_TYPE_DO_ACCEPT_ALL_CHANGES 24104
#define ASC_MENU_EVENT_TYPE_DO_REJECT_ALL_CHANGES 24105
#define ASC_MENU_EVENT_TYPE_DO_GET_PREV_REVISIONS_CHANGE 24106
#define ASC_MENU_EVENT_TYPE_DO_GET_NEXT_REVISIONS_CHANGE 24107
#define ASC_MENU_EVENT_TYPE_DO_ACCEPT_CHANGES 24108
#define ASC_MENU_EVENT_TYPE_DO_REJECT_CHANGES 24109
#define ASC_MENU_EVENT_TYPE_DO_FOLLOW_REVISION_MOVE 24110
// Universal call
#define ASC_MENU_EVENT_TYPE_DO_API_FUNCTION_CALL 25001
// Fill forms
#define ASC_MENU_EVENT_TYPE_SHOW_CONTENT_CONTROLS_ACTIONS 26001
#define ASC_MENU_EVENT_TYPE_HIDE_CONTENT_CONTROLS_ACTIONS 26002
#define ASC_MENU_EVENT_TYPE_DO_SET_CONTENTCONTROL_PICTURE 26003
#define ASC_MENU_EVENT_TYPE_DO_SET_CONTENTCONTROL_PICTURE_URL 26004
// Footnote
#define ASC_MENU_EVENT_TYPE_SET_FOOTNOTE_PROP 27001
// Others
#define ASC_MENU_EVENT_TYPE_FOCUS_OBJECT 26101
#define ASC_MENU_EVENT_TYPE_LONGACTION_BEGIN 26102
#define ASC_MENU_EVENT_TYPE_LONGACTION_END 26103
#define ASC_MENU_EVENT_TYPE_API_ERROR 26104
// Document Processing
#define ASC_EVENT_TYPE_OPEN_DOCUMENT_PROCESSING_BEGIN 60100
#define ASC_EVENT_TYPE_OPEN_DOCUMENT_PROCESSING_END 60101
#define ASC_EVENT_TYPE_OPEN_DOCUMENT_ERROR 60102
#endif //_BUILD_EDITOR_DEFINES_CROSSPLATFORM_H_

View File

@ -1,99 +0,0 @@
/*
* (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
*
*/
//
// DocumentEditorCtrl.h
// DocumentEditorCtrl
//
// Created by NewOleg on 07.07.14.
// Copyright (c) 2014 Ascensio System. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GLKit/GLKView.h>
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#include "./Editor_Api.h"
@interface DocumentEditorContextMenuHandler : UIScrollView
{
@public
UIView* m_pParent;
}
@end
@interface DocumentEditorCtrl : GLKView<UIKeyInput, UITextInput, UIScrollViewDelegate, UITextFieldDelegate>
-(void) TM_InvalidateRectNative: (CGRect)rect;
-(void) TM_InvalidateRectNativeOnlyTarget;
-(void) TM_SetCursorTypeNative: (const wchar_t*) strType;
-(void) TM_CaptureMouse;
-(void) TM_UnCaptureMouse;
-(void) TM_SetSettings: (const NSEditorApi::CAscEditorSettings&)settings;
-(void) TM_SetScriptPath: (NSString*)path;
-(void) TM_SetFontsPath: (NSString*)path;
-(void) TM_SetApplicationInfo: (unsigned char*)data : (unsigned int)len;
-(void) TM_LoadDocument: (NSString*)filename;
-(void) TM_Zoom: (double)zoom;
-(void) TM_Destroy;
-(void) TM_Apply : (NSEditorApi::CAscMenuEvent*)pEvent;
-(NSEditorApi::CAscMenuEvent*) TM_ApplySync : (NSEditorApi::CAscMenuEvent*)pEvent;
-(void) TM_SetListener : (NSEditorApi::CAscMenuEventListener*)pListener;
-(void) TM_ShowKeyboard;
-(void) TM_UnShowKeyboard;
-(void) private_DrawSnapshot:(CGContextRef)ctx : (CGRect)rect;
-(void) private_StartDrawLock;
-(void) private_EndDrawLock;
-(void) TM_OnUpdateContentSizes;
-(void) TM_CheckTargetOnScreen;
-(void) TM_Init:(UIViewController*)controller : (DocumentEditorContextMenuHandler*)handler;
-(void) TM_SetOffsetY:(int)offset;
-(int) TM_GetOffsetY;
-(bool) TM_Clipboard_Copy;
-(bool) TM_Clipboard_Cut;
-(bool) TM_Clipboard_Paste;
-(NSString*) TM_GetDocumentBase64;
-(bool) TM_SavePDF:(NSString*)path;
-(UIViewController*) GetController;
@property(nonatomic) UITextAutocorrectionType autocorrectionType;
@property(nonatomic) UIKeyboardType keyboardType;
@end

View File

@ -1,86 +0,0 @@
/*
* (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 NATIVECONTROL_H
#define NATIVECONTROL_H
#include <QWidget>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QKeyEvent>
#include <QPaintEvent>
#include <QGLWidget>
class CEditorCtrlWrapper;
class CNativeCtrl : public QGLWidget
{
Q_OBJECT
signals:
void signal_threadRepaint();
protected slots:
void slot_threadRepaint();
public:
CNativeCtrl(QWidget *parent = 0, const char *name = NULL);
virtual ~CNativeCtrl();
public:
virtual void initializeGL();
virtual void paintGL();
virtual void resizeGL(int width, int height);
virtual void closeEvent(QCloseEvent* e);
virtual void mousePressEvent(QMouseEvent* e);
virtual void mouseMoveEvent(QMouseEvent* e);
virtual void mouseReleaseEvent(QMouseEvent* e);
virtual void wheelEvent(QWheelEvent* event);
virtual void keyPressEvent(QKeyEvent* e);
virtual void keyReleaseEvent(QKeyEvent* e);
virtual void InvalidateRectNative(int x, int y, int w, int h);
public:
void InitSDK(const std::wstring& sFontsPath, const std::wstring& sSdkPath);
void OpenFile(const std::wstring& sFilePath);
void SetZoom(double dZoom);
void ChangeCountPagesInBlock();
private:
CEditorCtrlWrapper* m_pWrapper;
};
#endif // NATIVECONTROL_H

View File

@ -1,67 +0,0 @@
/*
* (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
*
*/
//
// X2tConverter.h
// X2tConverter
//
// Created by alexey.musinov on 25.03.15.
// Copyright (c) 2015 Ascensio System SIA. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface X2tConverter : NSObject
- (int)sdk_docx2doct_bin:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_docx2doct:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_doct_bin2docx:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath fromChanges:(NSNumber*)fromChanges nsThemeDir:(NSString*)nsThemeDir;
- (int)sdk_doct2docx:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath fromChanges:(NSNumber*)fromChanges nsThemeDir:(NSString*)nsThemeDir;
- (int)sdk_xlsx2xlst_bin:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_xlsx2xlst:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_xlst_bin2xlsx:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath fromChanges:(NSNumber*)fromChanges nsThemeDir:(NSString*)nsThemeDir;
- (int)sdk_xlst2xlsx:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath fromChanges:(NSNumber*)fromChanges nsThemeDir:(NSString*)nsThemeDir;
- (int)sdk_pptx2pptt_bin:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_pptx2pptt:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_pptt_bin2pptx:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath fromChanges:(NSNumber*)fromChanges nsThemeDir:(NSString*)nsThemeDir;
- (int)sdk_pptt2pptx:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath fromChanges:(NSNumber*)fromChanges nsThemeDir:(NSString*)nsThemeDir;
- (int)sdk_csv2xlst:(NSString*)nsFrom nsTo:(NSString*)nsTo xmlOptions:(NSString*)xmlOptions nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_csv2xlsx:(NSString*)nsFrom nsTo:(NSString*)nsTo xmlOptions:(NSString*)xmlOptions nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_xlst2csv:(NSString*)nsFrom nsTo:(NSString*)nsTo xmlOptions:(NSString*)xmlOptions nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_xlsx2csv:(NSString*)nsFrom nsTo:(NSString*)nsTo xmlOptions:(NSString*)xmlOptions nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_dir2zip:(NSString*)nsFrom nsTo:(NSString*)nsTo;
- (int)sdk_zip2dir:(NSString*)nsFrom nsTo:(NSString*)nsTo;
@end

View File

@ -16,14 +16,6 @@
#ifndef AGG_SPAN_GRADIENT_INCLUDED
#define AGG_SPAN_GRADIENT_INCLUDED
#include <stdlib.h>
#include <string.h>
#include "../../graphics/structures.h"
#include "agg_math.h"
#include "agg_array.h"
#include "agg_trans_affine.h"
#include <iostream>
#include <cmath>
#include "./test_grads/custom_gradients.h"
namespace agg
{

View File

@ -1,9 +1,11 @@
#include <algorithm>
#include <time.h>
#include <math.h>
#include "../../../graphics/AggPlusEnums.h"
#include "../../../graphics/structures.h"
#include <cmath>
#include "agg_math.h"
#include "agg_array.h"
#include "agg_trans_affine.h"
#ifndef M_1_PI
#define M_1_PI 0.318309886183790671538
#endif

View File

@ -31,25 +31,25 @@
*/
#if defined(_WIN32) || defined (_WIN64)
#include "windows.h"
#include "windef.h"
#include <shlobj.h>
#include <Rpc.h>
#include "windows.h"
#include "windef.h"
#include <shlobj.h>
#include <Rpc.h>
#elif __linux__
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#elif MAC
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#elif _IOS
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#endif
#include <string.h>
@ -58,187 +58,187 @@
namespace NSDirectory
{
#if !defined(_WIN32) && !defined (_WIN64)
static bool is_directory_exist(char* dir)
{
struct stat st;
bool bRes = (0 == stat(dir, &st)) && S_ISDIR(st.st_mode);
return bRes;
}
static bool is_directory_exist(char* dir)
{
struct stat st;
bool bRes = (0 == stat(dir, &st)) && S_ISDIR(st.st_mode);
return bRes;
}
static bool _mkdir (const char *dir)
{
char tmp[MAX_PATH];
char *p = NULL;
size_t len;
bool res = true;
static bool _mkdir (const char *dir)
{
char tmp[MAX_PATH];
char *p = NULL;
size_t len;
bool res = true;
snprintf(tmp, sizeof(tmp),"%s",dir);
len = strlen(tmp);
if(tmp[len - 1] == '/')
tmp[len - 1] = 0;
for(p = tmp + 1; *p; p++)
if(*p == '/') {
*p = 0;
res = is_directory_exist(tmp);
if (!res)
res = (0 == mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH));
*p = '/';
if (!res)
break;
}
if (res)
res = (0 == mkdir(tmp, S_IRWXU));
return res;
}
snprintf(tmp, sizeof(tmp),"%s",dir);
len = strlen(tmp);
if(tmp[len - 1] == '/')
tmp[len - 1] = 0;
for(p = tmp + 1; *p; p++)
if(*p == '/') {
*p = 0;
res = is_directory_exist(tmp);
if (!res)
res = (0 == mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH));
*p = '/';
if (!res)
break;
}
if (res)
res = (0 == mkdir(tmp, S_IRWXU));
return res;
}
#endif
void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion)
{
void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion)
{
#if defined(_WIN32) || defined (_WIN64)
WIN32_FIND_DATAW oFD;
WIN32_FIND_DATAW oFD;
std::wstring sSpec = strDirectory + L"\\*.*";
HANDLE hRes = FindFirstFileW( sSpec.c_str(), &oFD );
if( INVALID_HANDLE_VALUE == hRes )
return;
do
{
sSpec = oFD.cFileName;
if (sSpec != L"." && sSpec != L"..")
{
sSpec = strDirectory + L"\\" + sSpec;
if( !( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
{
oArray.push_back(sSpec);
}
else if (bIsRecursion)
{
GetFiles2(sSpec, oArray, bIsRecursion);
}
}
} while( FindNextFileW( hRes, &oFD ) );
FindClose( hRes );
std::wstring sSpec = strDirectory + L"\\*.*";
HANDLE hRes = FindFirstFileW( sSpec.c_str(), &oFD );
if( INVALID_HANDLE_VALUE == hRes )
return;
do
{
sSpec = oFD.cFileName;
if (sSpec != L"." && sSpec != L"..")
{
sSpec = strDirectory + L"\\" + sSpec;
if( !( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
{
oArray.push_back(sSpec);
}
else if (bIsRecursion)
{
GetFiles2(sSpec, oArray, bIsRecursion);
}
}
} while( FindNextFileW( hRes, &oFD ) );
FindClose( hRes );
#endif
#ifdef __linux__
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
DIR *dp;
struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL)
{
while ((dirp = readdir(dp)) != NULL)
{
int nType = 0;
if(DT_REG == dirp->d_type)
nType = 2;
else if (DT_DIR == dirp->d_type)
nType = 1;
else if (DT_UNKNOWN == dirp->d_type)
{
// XFS problem
struct stat buff;
std::string sTmp = std::string((char*)pUtf8) + "/" + std::string(dirp->d_name);
stat(sTmp.c_str(), &buff);
if (S_ISREG(buff.st_mode))
nType = 2;
else if (S_ISDIR(buff.st_mode))
nType = 1;
}
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
DIR *dp;
struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL)
{
while ((dirp = readdir(dp)) != NULL)
{
int nType = 0;
if(DT_REG == dirp->d_type)
nType = 2;
else if (DT_DIR == dirp->d_type)
nType = 1;
else if (DT_UNKNOWN == dirp->d_type)
{
// XFS problem
struct stat buff;
std::string sTmp = std::string((char*)pUtf8) + "/" + std::string(dirp->d_name);
stat(sTmp.c_str(), &buff);
if (S_ISREG(buff.st_mode))
nType = 2;
else if (S_ISDIR(buff.st_mode))
nType = 1;
}
if (2 == nType)
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.push_back(strDirectory + L"/" + sName);
}
if (2 == nType)
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.push_back(strDirectory + L"/" + sName);
}
if (bIsRecursion && (1 == nType))
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
GetFiles2(strDirectory + L"/" + sName, oArray, bIsRecursion);
}
}
}
closedir(dp);
}
delete [] pUtf8;
if (bIsRecursion && (1 == nType))
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
GetFiles2(strDirectory + L"/" + sName, oArray, bIsRecursion);
}
}
}
closedir(dp);
}
delete [] pUtf8;
#endif
#if defined(MAC) || defined (_IOS)
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
DIR *dp;
struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL)
{
while ((dirp = readdir(dp)) != NULL)
{
if(DT_REG == dirp->d_type)
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.push_back(strDirectory + L"/" + sName);
}
if (bIsRecursion && DT_DIR == dirp->d_type)
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
GetFiles2(strDirectory + L"/" + sName, oArray, bIsRecursion);
}
}
}
closedir(dp);
}
delete [] pUtf8;
return;
#endif
}
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
DIR *dp;
struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL)
{
while ((dirp = readdir(dp)) != NULL)
{
if(DT_REG == dirp->d_type)
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.push_back(strDirectory + L"/" + sName);
}
std::vector<std::wstring> GetFiles(std::wstring strDirectory, bool bIsRecursion)
if (bIsRecursion && DT_DIR == dirp->d_type)
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
GetFiles2(strDirectory + L"/" + sName, oArray, bIsRecursion);
}
}
}
closedir(dp);
}
delete [] pUtf8;
return;
#endif
}
std::vector<std::wstring> GetFiles(std::wstring strDirectory, bool bIsRecursion)
{
std::vector<std::wstring> oArray;
if (!strDirectory.empty())
{
{
GetFiles2(strDirectory, oArray, bIsRecursion);
}
return oArray;
}
std::vector<std::wstring> GetDirectories(std::wstring strDirectory)
std::vector<std::wstring> GetDirectories(std::wstring strDirectory)
{
std::vector<std::wstring> oArray;
if (strDirectory.empty()) return oArray;
#if defined(_WIN32) || defined (_WIN64)
WIN32_FIND_DATAW oFD;
WIN32_FIND_DATAW oFD;
std::wstring sSpec = strDirectory + L"\\*";
HANDLE hRes = FindFirstFileW( sSpec.c_str(), &oFD );
if( INVALID_HANDLE_VALUE == hRes )
return oArray;
do
do
{
sSpec = oFD.cFileName;
if (sSpec != L"." && sSpec != L"..")
{
sSpec = strDirectory + L"\\" + sSpec;
if( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
if( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
oArray.push_back(sSpec);
}
}
} while( FindNextFileW( hRes, &oFD ) );
} while( FindNextFileW( hRes, &oFD ) );
FindClose( hRes );
#elif __linux__
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
DIR *dp;
struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL)
@ -270,54 +270,54 @@ namespace NSDirectory
}
delete [] pUtf8;
#elif MAC
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
DIR *dp;
struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL)
{
while ((dirp = readdir(dp)) != NULL)
{
if(DT_DIR == dirp->d_type)
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.push_back(strDirectory + L"/" + sName);
}
}
}
closedir(dp);
}
delete [] pUtf8;
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
DIR *dp;
struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL)
{
while ((dirp = readdir(dp)) != NULL)
{
if(DT_DIR == dirp->d_type)
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.push_back(strDirectory + L"/" + sName);
}
}
}
closedir(dp);
}
delete [] pUtf8;
#endif
return oArray;
}
bool Exists(const std::wstring& strDirectory)
bool Exists(const std::wstring& strDirectory)
{
#if defined(_WIN32) || defined (_WIN64)
DWORD dwAttrib = ::GetFileAttributesW(strDirectory.c_str());
return (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
#elif __linux__
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
bool bRes = is_directory_exist((char*)pUtf8);
delete [] pUtf8;
return bRes;
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
bool bRes = is_directory_exist((char*)pUtf8);
delete [] pUtf8;
return bRes;
#elif MAC
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
struct stat st;
bool bRes = is_directory_exist((char*)pUtf8);
delete [] pUtf8;
return bRes;
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
struct stat st;
bool bRes = is_directory_exist((char*)pUtf8);
delete [] pUtf8;
return bRes;
#endif
return false;
return false;
}
bool CreateDirectory(const std::wstring& strDirectory)
bool CreateDirectory(const std::wstring& strDirectory)
{
if (Exists(strDirectory) == true) return true;
@ -326,7 +326,7 @@ namespace NSDirectory
#else
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
struct stat st;
int nRes = 0;
if (stat((char*)pUtf8, &st) == -1) {
@ -336,7 +336,7 @@ namespace NSDirectory
return 0 == nRes;
#endif
}
bool CreateDirectories(const std::wstring& strDirectory)
bool CreateDirectories(const std::wstring& strDirectory)
{
if (Exists(strDirectory) == true) return true;
@ -367,119 +367,119 @@ namespace NSDirectory
#endif
return false;
}
bool CopyDirectory(const std::wstring& strSrc, const std::wstring& strDst, bool bIsRecursion)
{
if (!NSDirectory::Exists(strDst))
NSDirectory::CreateDirectory(strDst);
bool CopyDirectory(const std::wstring& strSrc, const std::wstring& strDst, bool bIsRecursion)
{
if (!NSDirectory::Exists(strDst))
NSDirectory::CreateDirectory(strDst);
#ifdef WIN32
WIN32_FIND_DATAW oFD;
WIN32_FIND_DATAW oFD;
std::wstring sSpec = strSrc + L"\\*.*";
HANDLE hRes = FindFirstFileW( sSpec.c_str(), &oFD );
if( INVALID_HANDLE_VALUE == hRes )
return false;
do
{
sSpec = oFD.cFileName;
if (sSpec != L"." && sSpec != L"..")
{
if( !( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
{
NSFile::CFileBinary::Copy(strSrc + L"/" + sSpec, strDst + L"/" + sSpec);
}
else if (bIsRecursion)
{
CopyDirectory(strSrc + L"/" + sSpec, strDst + L"/" + sSpec, bIsRecursion);
}
}
} while( FindNextFileW( hRes, &oFD ) );
FindClose( hRes );
return true;
std::wstring sSpec = strSrc + L"\\*.*";
HANDLE hRes = FindFirstFileW( sSpec.c_str(), &oFD );
if( INVALID_HANDLE_VALUE == hRes )
return false;
do
{
sSpec = oFD.cFileName;
if (sSpec != L"." && sSpec != L"..")
{
if( !( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
{
NSFile::CFileBinary::Copy(strSrc + L"/" + sSpec, strDst + L"/" + sSpec);
}
else if (bIsRecursion)
{
CopyDirectory(strSrc + L"/" + sSpec, strDst + L"/" + sSpec, bIsRecursion);
}
}
} while( FindNextFileW( hRes, &oFD ) );
FindClose( hRes );
return true;
#endif
#ifdef __linux__
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strSrc.c_str(), strSrc.length(), pUtf8, lLen, false);
DIR *dp;
struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL)
{
while ((dirp = readdir(dp)) != NULL)
{
int nType = 0;
if(DT_REG == dirp->d_type)
nType = 2;
else if (DT_DIR == dirp->d_type)
nType = 1;
else if (DT_UNKNOWN == dirp->d_type)
{
// XFS problem
struct stat buff;
std::string sTmp = std::string((char*)pUtf8) + "/" + std::string(dirp->d_name);
stat(sTmp.c_str(), &buff);
if (S_ISREG(buff.st_mode))
nType = 2;
else if (S_ISDIR(buff.st_mode))
nType = 1;
}
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strSrc.c_str(), strSrc.length(), pUtf8, lLen, false);
DIR *dp;
struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL)
{
while ((dirp = readdir(dp)) != NULL)
{
int nType = 0;
if(DT_REG == dirp->d_type)
nType = 2;
else if (DT_DIR == dirp->d_type)
nType = 1;
else if (DT_UNKNOWN == dirp->d_type)
{
// XFS problem
struct stat buff;
std::string sTmp = std::string((char*)pUtf8) + "/" + std::string(dirp->d_name);
stat(sTmp.c_str(), &buff);
if (S_ISREG(buff.st_mode))
nType = 2;
else if (S_ISDIR(buff.st_mode))
nType = 1;
}
if (2 == nType)
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
NSFile::CFileBinary::Copy(strSrc + L"/" + sName, strDst + L"/" + sName);
}
if (2 == nType)
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
NSFile::CFileBinary::Copy(strSrc + L"/" + sName, strDst + L"/" + sName);
}
if (bIsRecursion && (1 == nType))
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
CopyDirectory(strSrc + L"/" + sName, strDst + L"/" + sName, bIsRecursion);
}
}
}
closedir(dp);
}
delete [] pUtf8;
return true;
if (bIsRecursion && (1 == nType))
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
CopyDirectory(strSrc + L"/" + sName, strDst + L"/" + sName, bIsRecursion);
}
}
}
closedir(dp);
}
delete [] pUtf8;
return true;
#endif
#if defined(MAC) || defined (_IOS)
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strSrc.c_str(), strSrc.length(), pUtf8, lLen, false);
DIR *dp;
struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL)
{
while ((dirp = readdir(dp)) != NULL)
{
if(DT_REG == dirp->d_type)
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
NSFile::CFileBinary::Copy(strSrc + L"/" + sName, strDst + L"/" + sName);
}
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strSrc.c_str(), strSrc.length(), pUtf8, lLen, false);
DIR *dp;
struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL)
{
while ((dirp = readdir(dp)) != NULL)
{
if(DT_REG == dirp->d_type)
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
NSFile::CFileBinary::Copy(strSrc + L"/" + sName, strDst + L"/" + sName);
}
if (bIsRecursion && DT_DIR == dirp->d_type)
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
CopyDirectory(strSrc + L"/" + sName, strDst + L"/" + sName, bIsRecursion);
}
}
}
closedir(dp);
}
delete [] pUtf8;
return true;
if (bIsRecursion && DT_DIR == dirp->d_type)
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
CopyDirectory(strSrc + L"/" + sName, strDst + L"/" + sName, bIsRecursion);
}
}
}
closedir(dp);
}
delete [] pUtf8;
return true;
#endif
return false;
}
void DeleteDirectory(const std::wstring& strDirectory, bool deleteRoot)
return false;
}
void DeleteDirectory(const std::wstring& strDirectory, bool deleteRoot)
{
if (strDirectory.empty()) return;
@ -498,22 +498,22 @@ namespace NSDirectory
#elif __linux__
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
rmdir((char*)pUtf8);
delete [] pUtf8;
if (deleteRoot = false)CreateDirectory(strDirectory);
#elif MAC
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
rmdir((char*)pUtf8);
delete [] pUtf8;
if (deleteRoot = false)CreateDirectory(strDirectory);
BYTE* pUtf8 = NULL;
LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
rmdir((char*)pUtf8);
delete [] pUtf8;
if (deleteRoot = false)CreateDirectory(strDirectory);
#endif
}
std::wstring GetFolderPath(const std::wstring& wsFolderPath)
std::wstring GetFolderPath(const std::wstring& wsFolderPath)
{
int n1 = (int)wsFolderPath.rfind('\\');
if (n1 < 0)
@ -527,64 +527,64 @@ namespace NSDirectory
}
return wsFolderPath.substr(0, n1);
}
std::wstring CreateTempFileWithUniqueName (const std::wstring & strFolderPathRoot, std::wstring Prefix)
{
return NSFile::CFileBinary::CreateTempFileWithUniqueName(strFolderPathRoot, Prefix);
}
std::wstring CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot)
{
std::wstring CreateTempFileWithUniqueName (const std::wstring & strFolderPathRoot, std::wstring Prefix)
{
return NSFile::CFileBinary::CreateTempFileWithUniqueName(strFolderPathRoot, Prefix);
}
std::wstring CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot)
{
#if defined(_WIN32) || defined (_WIN64)
UUID uuid;
RPC_WSTR str_uuid;
UuidCreate (&uuid);
UuidToStringW (&uuid, &str_uuid);
std::wstring pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (wchar_t *) str_uuid;
RpcStringFreeW (&str_uuid);
UUID uuid;
RPC_WSTR str_uuid;
UuidCreate (&uuid);
UuidToStringW (&uuid, &str_uuid);
std::wstring pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (wchar_t *) str_uuid;
RpcStringFreeW (&str_uuid);
int attemps = 10;
while (!CreateDirectory(pcTemplate))
{
UuidCreate (&uuid);
UuidToStringW (&uuid, &str_uuid);
pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (wchar_t *) str_uuid;
RpcStringFreeW (&str_uuid);
attemps--;
int attemps = 10;
while (!CreateDirectory(pcTemplate))
{
UuidCreate (&uuid);
UuidToStringW (&uuid, &str_uuid);
pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (wchar_t *) str_uuid;
RpcStringFreeW (&str_uuid);
attemps--;
if (0 == attemps)
{
pcTemplate = L"";
break;
}
}
return pcTemplate;
if (0 == attemps)
{
pcTemplate = L"";
break;
}
}
return pcTemplate;
#else
std::string pcTemplate = U_TO_UTF8(strFolderPathRoot) + "/ascXXXXXX";
char *pcRes = mkdtemp(const_cast <char *> (pcTemplate.c_str()));
if (NULL == pcRes)
return L"";
std::string pcTemplate = U_TO_UTF8(strFolderPathRoot) + "/ascXXXXXX";
char *pcRes = mkdtemp(const_cast <char *> (pcTemplate.c_str()));
if (NULL == pcRes)
return L"";
std::string sRes = pcRes;
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sRes.c_str(), (LONG)sRes.length());
std::string sRes = pcRes;
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sRes.c_str(), (LONG)sRes.length());
#endif
}
std::wstring GetTempPath()
{
return NSFile::CFileBinary::GetTempPath();
}
}
std::wstring GetTempPath()
{
return NSFile::CFileBinary::GetTempPath();
}
int GetFilesCount(const std::wstring& path, const bool& recursive)
{
std::vector<std::wstring> arrFiles = NSDirectory::GetFiles(path, recursive);
int GetFilesCount(const std::wstring& path, const bool& recursive)
{
std::vector<std::wstring> arrFiles = NSDirectory::GetFiles(path, recursive);
#if defined(_WIN32) || defined (_WIN64)
return (int)arrFiles.size();
return (int)arrFiles.size();
#endif
return (int)arrFiles.size() + 1;
// ???
}
bool PathIsDirectory(const std::wstring& pathName)
{
return Exists(pathName);
}
return (int)arrFiles.size() + 1;
// ???
}
bool PathIsDirectory(const std::wstring& pathName)
{
return Exists(pathName);
}
}

View File

@ -46,41 +46,45 @@
#include "File.h"
#ifndef FILE_SEPARATOR
#if defined(_WIN32) || defined(_WIN64)
#define FILE_SEPARATOR
#define FILE_SEPARATOR_CHAR '\\'
#define FILE_SEPARATOR_STR L"\\"
#define FILE_SEPARATOR_STRA "\\"
#else
#define FILE_SEPARATOR
#define FILE_SEPARATOR_CHAR '/'
#define FILE_SEPARATOR_STR L"/"
#define FILE_SEPARATOR_STRA "/"
#endif
#if defined(_WIN32) || defined(_WIN64)
#define FILE_SEPARATOR
#define FILE_SEPARATOR_CHAR '\\'
#define FILE_SEPARATOR_STR L"\\"
#define FILE_SEPARATOR_STRA "\\"
#else
#define FILE_SEPARATOR
#define FILE_SEPARATOR_CHAR '/'
#define FILE_SEPARATOR_STR L"/"
#define FILE_SEPARATOR_STRA "/"
#endif
#endif
#include "../../Common/kernel_config.h"
namespace NSDirectory
{
KERNEL_DECL std::vector<std::wstring> GetFiles(std::wstring strDirectory, bool bIsRecursion = false);
KERNEL_DECL void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion = false);
KERNEL_DECL std::vector<std::wstring> GetDirectories(std::wstring strDirectory);
KERNEL_DECL bool Exists(const std::wstring& strDirectory);
KERNEL_DECL bool CreateDirectory(const std::wstring& strDirectory);
KERNEL_DECL bool CreateDirectories(const std::wstring& strDirectory);
KERNEL_DECL bool CopyDirectory(const std::wstring& strSrc, const std::wstring& strDst, bool bIsRecursion = true);
KERNEL_DECL void DeleteDirectory(const std::wstring& strDirectory, bool deleteRoot = true);
KERNEL_DECL std::wstring GetFolderPath(const std::wstring& wsFolderPath);
KERNEL_DECL std::wstring CreateTempFileWithUniqueName (const std::wstring & strFolderPathRoot, std::wstring Prefix);
KERNEL_DECL std::wstring CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot);
KERNEL_DECL std::wstring GetTempPath();
KERNEL_DECL int GetFilesCount(const std::wstring& path, const bool& recursive);
KERNEL_DECL bool PathIsDirectory(const std::wstring& pathName);
#ifdef _IOS
KERNEL_DECL void GetFiles2_ios(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion);
namespace NSIOS
{
KERNEL_DECL void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion = false);
}
#endif
KERNEL_DECL void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion = false);
KERNEL_DECL std::vector<std::wstring> GetFiles(std::wstring strDirectory, bool bIsRecursion = false);
KERNEL_DECL std::vector<std::wstring> GetDirectories(std::wstring strDirectory);
KERNEL_DECL bool Exists(const std::wstring& strDirectory);
KERNEL_DECL bool CreateDirectory(const std::wstring& strDirectory);
KERNEL_DECL bool CreateDirectories(const std::wstring& strDirectory);
KERNEL_DECL bool CopyDirectory(const std::wstring& strSrc, const std::wstring& strDst, bool bIsRecursion = true);
KERNEL_DECL void DeleteDirectory(const std::wstring& strDirectory, bool deleteRoot = true);
KERNEL_DECL std::wstring GetFolderPath(const std::wstring& wsFolderPath);
KERNEL_DECL std::wstring CreateTempFileWithUniqueName (const std::wstring & strFolderPathRoot, std::wstring Prefix);
KERNEL_DECL std::wstring CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot);
KERNEL_DECL std::wstring GetTempPath();
KERNEL_DECL int GetFilesCount(const std::wstring& path, const bool& recursive);
KERNEL_DECL bool PathIsDirectory(const std::wstring& pathName);
}
#endif //_BUILD_DIRECTORY_CROSSPLATFORM_H_

View File

@ -45,10 +45,6 @@
#include <sys/stat.h>
#endif
#ifdef _IOS
const char* fileSystemRepresentation(const std::wstring& sFileName);
#endif
#ifdef _MAC
#include <mach-o/dyld.h>
#endif
@ -624,7 +620,7 @@ namespace NSFile
}
}
lOutputCount = pUnicodeString - pStart;
lOutputCount = (LONG)(pUnicodeString - pStart);
*pUnicodeString++ = 0;
}
void CUtf8Converter::GetUnicodeStringFromUTF8WithHHHH( const BYTE* pBuffer, LONG lCount, wchar_t*& pUnicodes, LONG& lOutputCount )
@ -959,64 +955,15 @@ namespace NSFile
return (unsigned long)m_lFilePosition;
}
#ifdef _IOS
bool CFileBinary::OpenFile(const std::wstring& sFileName, bool bRewrite)
{
m_pFile = fopen(fileSystemRepresentation(sFileName), bRewrite ? "rb+" : "rb");
if (NULL == m_pFile) {
#if DEBUG
// printf ("NSFile::OpenFile - error open file : %s\n",strerror(errno));
#endif
return false;
}
fseek(m_pFile, 0, SEEK_END);
m_lFileSize = ftell(m_pFile);
fseek(m_pFile, 0, SEEK_SET);
m_lFilePosition = 0;
if (0 < sFileName.length())
{
if (((wchar_t)'/') == sFileName.c_str()[sFileName.length() - 1])
m_lFileSize = 0x7FFFFFFF;
}
unsigned int err = 0x7FFFFFFF;
unsigned int cur = (unsigned int)m_lFileSize;
if (err == cur)
{
CloseFile();
return false;
}
return true;
}
bool CFileBinary::CreateFileW(const std::wstring& sFileName)
{
m_pFile = fopen(fileSystemRepresentation(sFileName), "wb");
if (NULL == m_pFile) {
#if DEBUG
// printf ("NSFile::CreateFileW - error create file : %s\n",strerror(errno));
#endif
return false;
}
m_lFilePosition = 0;
return true;
}
#else
bool CFileBinary::OpenFile(const std::wstring& sFileName, bool bRewrite)
{
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
if ( NULL == (m_pFile = _wfsopen( sFileName.c_str(), bRewrite ? L"rb+" : L"rb", _SH_DENYNO)))
return false;
#else
#ifdef _IOS
std::string sFilePath = NSIOS::GetFileSystemRepresentation(sFileName);
m_pFile = fopen((char*)sFilePath.c_str(), bRewrite ? "rb+" : "rb");
#else
BYTE* pUtf8 = NULL;
LONG lLen = 0;
@ -1027,9 +974,10 @@ namespace NSFile
return false;
m_pFile = fopen((char*)pUtf8, bRewrite ? "rb+" : "rb");
delete [] pUtf8;
#endif
#endif
if (NULL == m_pFile)
return false;
@ -1061,12 +1009,17 @@ namespace NSFile
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
if ( 0 != _wfopen_s(&m_pFile, sFileName.c_str(), L"wb"))
return false;
#else
#ifdef _IOS
std::string sFilePath = NSIOS::GetFileSystemRepresentation(sFileName);
m_pFile = fopen((char*)sFilePath.c_str(), "wb");
#else
BYTE* pUtf8 = NULL;
LONG lLen = 0;
CUtf8Converter::GetUtf8StringFromUnicode(sFileName.c_str(), sFileName.length(), pUtf8, lLen, false);
m_pFile = fopen((char*)pUtf8, "wb");
delete [] pUtf8;
#endif
#endif
if (NULL == m_pFile)
return false;
@ -1075,8 +1028,6 @@ namespace NSFile
return true;
}
#endif
bool CFileBinary::CreateFile(const std::wstring& sFileName)
{
return CreateFileW(sFileName);
@ -1414,6 +1365,12 @@ namespace NSFile
close(dst);
return (-1 != read_size_marker) ? true : false;
#else
#ifdef _WIN32
if (0 != ::CopyFileW(strSrc.c_str(), strDst.c_str(), 1))
return true;
#endif
std::ifstream src;
std::ofstream dst;

View File

@ -201,6 +201,13 @@ namespace NSFile
static bool Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
static bool Decode(const char* pDataSrc, int nLenSrc, BYTE*& pDataDst, int& nLenDst);
};
#ifdef _IOS
namespace NSIOS
{
KERNEL_DECL std::string GetFileSystemRepresentation(const std::wstring& path);
}
#endif
}
namespace NSFile

View File

@ -31,21 +31,49 @@
*/
#ifdef __OBJC__
#import <CoreFoundation/CoreFoundation.h>
#import <CoreFoundation/CoreFoundation.h>
#else
#include <objc/objc.h>
#include <objc/objc.h>
#endif
#include "./File.h"
#include <vector>
#import <Foundation/Foundation.h>
const char* fileSystemRepresentation(const std::wstring& sFileName)
namespace NSFile
{
if (sFileName.empty())
return NULL;
NSString *path = [[NSString alloc] initWithBytes:(char*)sFileName.data()
length:sFileName.size()* sizeof(wchar_t)
encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingUTF32LE)];
namespace NSIOS
{
std::string GetFileSystemRepresentation(const std::wstring& path)
{
if (path.empty())
return "";
return (const char*)[path fileSystemRepresentation];
NSString* _path = [[NSString alloc] initWithBytes:(char*)path.data() length:path.size() * sizeof(wchar_t)
encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingUTF32LE)];
return std::string((const char*)[_path fileSystemRepresentation]);
}
}
}
namespace NSDirectory
{
namespace NSIOS
{
void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion)
{
NSStringEncoding pEncode = CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE );
NSString* directoryPath = [[NSString alloc] initWithBytes : (char*)strDirectory.data()
length : strDirectory.size() * sizeof(wchar_t) encoding : pEncode];
NSArray* directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:NULL];
for (int count = 0; count < (int)[directoryContent count]; count++)
{
NSData* pSData = [[directoryContent objectAtIndex:count] dataUsingEncoding : pEncode];
oArray.emplace_back(std::wstring((wchar_t*)[pSData bytes], [pSData length] / sizeof (wchar_t)));
}
}
}
}

View File

@ -43,49 +43,49 @@ class IGrObject
protected:
#ifdef __APPLE__
volatile int32_t m_lRef;
volatile int32_t m_lRef;
#else
ULONG m_lRef;
ULONG m_lRef;
#endif
public:
IGrObject()
{
m_lRef = 1;
}
IGrObject()
{
m_lRef = 1;
}
virtual ~IGrObject()
{
}
virtual ~IGrObject()
{
}
#ifdef __APPLE__
virtual ULONG AddRef()
{
OSAtomicIncrement32(&m_lRef);
return (ULONG)m_lRef;
}
virtual ULONG Release()
{
int32_t ret = OSAtomicDecrement32(&m_lRef);
if (0 == m_lRef)
delete this;
virtual ULONG AddRef()
{
OSAtomicIncrement32(&m_lRef);
return (ULONG)m_lRef;
}
virtual ULONG Release()
{
int32_t ret = OSAtomicDecrement32(&m_lRef);
if (0 == m_lRef)
delete this;
return (ULONG)ret;
}
return (ULONG)ret;
}
#else
virtual ULONG AddRef()
{
++m_lRef;
return m_lRef;
}
virtual ULONG AddRef()
{
++m_lRef;
return m_lRef;
}
virtual ULONG Release()
{
ULONG ret = --m_lRef;
if (0 == m_lRef)
delete this;
return ret;
}
virtual ULONG Release()
{
ULONG ret = --m_lRef;
if (0 == m_lRef)
delete this;
return ret;
}
#endif
};

View File

@ -33,9 +33,9 @@
#include "File.h"
#if defined(_WIN32) || defined (_WIN64)
#include <tchar.h>
#include <tchar.h>
#elif __linux__ || MAC
#include <libgen.h>
#include <libgen.h>
#endif
namespace NSSystemPath
@ -61,7 +61,7 @@ namespace NSSystemPath
sRes = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)pDirName, strlen(pDirName));
delete [] pUtf8;
#endif
return sRes;
return sRes;
}
std::wstring GetFileName(const std::wstring& strFileName)
{
@ -103,17 +103,19 @@ namespace NSSystemPath
sRes = strLeft + strRight.substr(1);
}
else if(!bLeftSlash && !bRightSlash)
sRes = strLeft + L"/" + strRight;
sRes = strLeft + L"/" + strRight;
else
sRes = strLeft + strRight;
return sRes;
}
std::string NormalizePath(const std::string& strFileName)
{
const char* pData = strFileName.c_str();
int nLen = (int) strFileName.length();
char* pDataNorm = new char[nLen + 1];
template<class CHAR, class STRING = std::basic_string<CHAR, std::char_traits<CHAR>, std::allocator<CHAR>>>
STRING NormalizePathTemplate(const STRING& strFileName)
{
const CHAR* pData = strFileName.c_str();
int nLen = (int) strFileName.length();
CHAR* pDataNorm = new CHAR[nLen + 1];
int* pSlashPoints = new int[nLen + 1];
int nStart = 0;
@ -122,10 +124,15 @@ namespace NSSystemPath
int nCurrentW = 0;
bool bIsUp = false;
#if !defined(_WIN32) && !defined (_WIN64)
if (pData[nCurrent] == '/' || pData[nCurrent] == '\\')
{
#if !defined(_WIN32) && !defined (_WIN64)
pDataNorm[nCurrentW++] = pData[nCurrent];
#endif
#endif
++nCurrentSlash;
pSlashPoints[nCurrentSlash] = nCurrentW;
}
while (nCurrent < nLen)
{
if (pData[nCurrent] == '/' || pData[nCurrent] == '\\')
@ -135,7 +142,7 @@ namespace NSSystemPath
bIsUp = false;
if ((nCurrent - nStart) == 2)
{
if (pData[nStart] == (char)'.' && pData[nStart + 1] == (char)'.')
if (pData[nStart] == (CHAR)'.' && pData[nStart + 1] == (CHAR)'.')
{
if (nCurrentSlash > 0)
{
@ -147,7 +154,7 @@ namespace NSSystemPath
}
if (!bIsUp)
{
pDataNorm[nCurrentW++] = (char)'/';
pDataNorm[nCurrentW++] = (CHAR)'/';
++nCurrentSlash;
pSlashPoints[nCurrentSlash] = nCurrentW;
}
@ -160,13 +167,22 @@ namespace NSSystemPath
++nCurrent;
}
pDataNorm[nCurrentW] = (char)'\0';
pDataNorm[nCurrentW] = (CHAR)'\0';
std::string result = std::string(pDataNorm, nCurrentW);
STRING result = STRING(pDataNorm, nCurrentW);
delete[] pDataNorm;
delete[] pSlashPoints;
return result;
}
std::string NormalizePath(const std::string& strFileName)
{
return NormalizePathTemplate<char>(strFileName);
}
std::wstring NormalizePath(const std::wstring& strFileName)
{
return NormalizePathTemplate<wchar_t>(strFileName);
}
}

View File

@ -38,10 +38,11 @@
namespace NSSystemPath
{
KERNEL_DECL std::wstring GetDirectoryName(const std::wstring& strFileName);
KERNEL_DECL std::wstring GetFileName(const std::wstring& strFileName);
KERNEL_DECL std::wstring Combine(const std::wstring& strLeft, const std::wstring& strRight);
KERNEL_DECL std::string NormalizePath(const std::string& strFileName);
KERNEL_DECL std::wstring GetDirectoryName(const std::wstring& strFileName);
KERNEL_DECL std::wstring GetFileName(const std::wstring& strFileName);
KERNEL_DECL std::wstring Combine(const std::wstring& strLeft, const std::wstring& strRight);
KERNEL_DECL std::string NormalizePath(const std::string& strFileName);
KERNEL_DECL std::wstring NormalizePath(const std::wstring& strFileName);
}
#endif //_BUILD_PATH_CROSSPLATFORM_H_

View File

@ -78,9 +78,9 @@ namespace NSStringUtils
{
while ((m_lSizeCur + nSize) > m_lSize)
{
if (m_lSize > 10485760/*10 * 1024 * 1024*/)
if (m_lSize > 10485760/*10 * 1024 * 1024*/)
{
m_lSize += (std::max)((int)nSize * 10, 1048576/*1024 * 1024*/);
m_lSize += (std::max)((int)nSize * 10, 1048576/*1024 * 1024*/);
}
else
{
@ -218,9 +218,9 @@ namespace NSStringUtils
{
while ((m_lSizeCur + nSize) > m_lSize)
{
if (m_lSize > 10485760/*10 * 1024 * 1024*/)
if (m_lSize > 10485760/*10 * 1024 * 1024*/)
{
m_lSize += (std::max)((int)nSize * 10, 1048576/*1024 * 1024*/);
m_lSize += (std::max)((int)nSize * 10, 1048576/*1024 * 1024*/);
}
else
{
@ -252,17 +252,17 @@ namespace NSStringUtils
ClearNoAttack();
WriteString(bsText);
for (size_t i = 0; i < m_lSizeCur; ++i)
for (size_t i = 0; i < m_lSizeCur; ++i)
{
if (WCHAR(8233) == m_pData[i])
m_pData[i] = WCHAR(' ');
}
}
void CStringBuilder::operator+=(const std::wstring& oTemp)
{
WriteString(oTemp.c_str(), oTemp.length());
}
void CStringBuilder::operator+=(const std::wstring& oTemp)
{
WriteString(oTemp.c_str(), oTemp.length());
}
void CStringBuilder::WriteStringNoSafe(const wchar_t* pString, size_t nLen)
{
@ -604,17 +604,17 @@ namespace NSStringUtils
std::wstring str(m_pData, (int)m_lSizeCur);
return str;
}
std::wstring CStringBuilder::GetSubData(const size_t& start, const size_t& count)
{
if (start >= m_lSizeCur)
return L"";
std::wstring CStringBuilder::GetSubData(const size_t& start, const size_t& count)
{
if (start >= m_lSizeCur)
return L"";
size_t nCountMax = m_lSizeCur - start;
if (count != std::wstring::npos && count <= nCountMax)
nCountMax = count;
size_t nCountMax = m_lSizeCur - start;
if (count != std::wstring::npos && count <= nCountMax)
nCountMax = count;
return std::wstring(m_pData + start, nCountMax);
}
return std::wstring(m_pData + start, nCountMax);
}
wchar_t* CStringBuilder::GetBuffer()
{
@ -676,14 +676,14 @@ namespace NSStringUtils
{
if (0 == val)
{
*m_pDataCur++ = (wchar_t)'0';
*m_pDataCur++ = (wchar_t)'0';
++m_lSizeCur;
return;
}
if (val < 0)
{
val = -val;
*m_pDataCur++ = (wchar_t)'-';
*m_pDataCur++ = (wchar_t)'-';
++m_lSizeCur;
}
@ -698,7 +698,7 @@ namespace NSStringUtils
oval = 1;
while (val > 0)
{
m_pDataCur[len - oval] = (wchar_t)('0' + (val % 10));
m_pDataCur[len - oval] = (wchar_t)('0' + (val % 10));
++oval;
val /= 10;
}
@ -711,14 +711,14 @@ namespace NSStringUtils
{
if (0 == val)
{
*m_pDataCur++ = (wchar_t)'0';
*m_pDataCur++ = (wchar_t)'0';
++m_lSizeCur;
return;
}
if (val < 0)
{
val = -val;
*m_pDataCur++ = (wchar_t)'-';
*m_pDataCur++ = (wchar_t)'-';
++m_lSizeCur;
}
@ -735,9 +735,9 @@ namespace NSStringUtils
if (0 != nLastS)
{
++len;
m_pDataCur[len - oval] = (wchar_t)('0' + nLastS);
m_pDataCur[len - oval] = (wchar_t)('0' + nLastS);
++oval;
m_pDataCur[len - oval] = (wchar_t)('.');
m_pDataCur[len - oval] = (wchar_t)('.');
++oval;
val /= 10;
}
@ -749,7 +749,7 @@ namespace NSStringUtils
while (val > 0)
{
m_pDataCur[len - oval] = (wchar_t)('0' + (val % 10));
m_pDataCur[len - oval] = (wchar_t)('0' + (val % 10));
++oval;
val /= 10;
}
@ -852,14 +852,14 @@ namespace NSStringUtils
WriteHexByteNoSafe((value >> 8) & 0xFF);
WriteHexByteNoSafe(value & 0xFF);
}
void CStringBuilder::WriteHexInt4(const unsigned int& value)
{
AddSize(8);
WriteHexByteNoSafe((value >> 24) & 0xFF);
WriteHexByteNoSafe((value >> 16) & 0xFF);
WriteHexByteNoSafe((value >> 8) & 0xFF);
WriteHexByteNoSafe(value & 0xFF);
}
void CStringBuilder::WriteHexInt4(const unsigned int& value)
{
AddSize(8);
WriteHexByteNoSafe((value >> 24) & 0xFF);
WriteHexByteNoSafe((value >> 16) & 0xFF);
WriteHexByteNoSafe((value >> 8) & 0xFF);
WriteHexByteNoSafe(value & 0xFF);
}
void CStringBuilder::WriteHexColor3(const unsigned char& r, const unsigned char& g, const unsigned char& b)
{
AddSize(7);
@ -874,16 +874,16 @@ namespace NSStringUtils
AddSize(7);
*m_pDataCur++ = (wchar_t)'#';
++m_lSizeCur;
WriteHexByteNoSafe(value & 0xFF);
WriteHexByteNoSafe((value >> 8) & 0xFF);
WriteHexByteNoSafe((value >> 16) & 0xFF);
WriteHexByteNoSafe(value & 0xFF);
WriteHexByteNoSafe((value >> 8) & 0xFF);
WriteHexByteNoSafe((value >> 16) & 0xFF);
}
void CStringBuilder::Skip(int nSkip)
{
m_pDataCur += nSkip;
m_lSizeCur += nSkip;
}
void CStringBuilder::Skip(int nSkip)
{
m_pDataCur += nSkip;
m_lSizeCur += nSkip;
}
void CStringBuilder::StartNode(const std::wstring& name)
{
WriteString(g_bstr_nodeopen);
@ -1121,22 +1121,22 @@ namespace NSStringUtils
return 0;
}
void string_replace(std::wstring& text, const std::wstring& replaceFrom, const std::wstring& replaceTo)
{
size_t posn = 0;
while (std::wstring::npos != (posn = text.find(replaceFrom, posn)))
{
text.replace(posn, replaceFrom.length(), replaceTo);
posn += replaceTo.length();
}
}
void string_replaceA(std::string& text, const std::string& replaceFrom, const std::string& replaceTo)
{
size_t posn = 0;
while (std::string::npos != (posn = text.find(replaceFrom, posn)))
{
text.replace(posn, replaceFrom.length(), replaceTo);
posn += replaceTo.length();
}
}
void string_replace(std::wstring& text, const std::wstring& replaceFrom, const std::wstring& replaceTo)
{
size_t posn = 0;
while (std::wstring::npos != (posn = text.find(replaceFrom, posn)))
{
text.replace(posn, replaceFrom.length(), replaceTo);
posn += replaceTo.length();
}
}
void string_replaceA(std::string& text, const std::string& replaceFrom, const std::string& replaceTo)
{
size_t posn = 0;
while (std::string::npos != (posn = text.find(replaceFrom, posn)))
{
text.replace(posn, replaceFrom.length(), replaceTo);
posn += replaceTo.length();
}
}
}

View File

@ -60,11 +60,11 @@ BEGIN
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "Ascensio System SIA 2022"
VALUE "CompanyName", "Ascensio System SIA 2023"
VALUE "FileDescription", "ONLYOFFICE docbuilder ActiveX DLL"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "docbuilder.com.dll"
VALUE "LegalCopyright", "Copyright (C) Ascensio System SIA 2022. All rights reserved."
VALUE "LegalCopyright", "Copyright (C) Ascensio System SIA 2023. All rights reserved."
VALUE "OriginalFilename", "docbuilder.com.dll"
VALUE "ProductName", "docbuilder.com"
VALUE "ProductVersion", "1.0.0.1"

View File

@ -71,7 +71,7 @@ BEGIN
VALUE "FileDescription", "Document Builder .NET"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "docbuilder.net"
VALUE "LegalCopyright", "Copyright (C) 2023"
VALUE "LegalCopyright", "Copyright (C) Ascensio System SIA 2023. All rights reserved."
VALUE "OriginalFilename", "docbuilder.net"
VALUE "ProductName", "docbuilder.net"
VALUE "ProductVersion", "1.0.0.1"

View File

@ -48,16 +48,28 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder)
m_nFileType = -1;
m_context = new CJSContext();
m_context->CreateContext();
CJSContextScope scope(m_context);
CNativeControlEmbed::CreateObjectBuilderInContext("CreateNativeEngine", m_context);
CGraphicsEmbed::CreateObjectInContext("CreateNativeGraphics", m_context);
NSJSBase::CreateDefaults(m_context);
CJSContext::Embed<CNativeControlEmbed>(false);
CJSContext::Embed<CGraphicsEmbed>();
NSJSBase::CreateDefaults();
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
builder_CreateNative("builderJS", m_context, pBuilder);
CJSContext::Embed<CBuilderEmbed>(false);
CJSContext::Embed<CBuilderDocumentEmbed>(false);
JSSmart<CJSObject> global = m_context->GetGlobal();
global->set("window", global);
JSSmart<CJSObject> oBuilderJS = CJSContext::createEmbedObject("CBuilderEmbed");
global->set("builderJS", oBuilderJS);
JSSmart<CJSObject> oNativeCtrl = CJSContext::createEmbedObject("CNativeControlEmbed");
global->set("native", oNativeCtrl);
CBuilderEmbed* pBuilderJSNative = static_cast<CBuilderEmbed*>(oBuilderJS->getNative());
pBuilderJSNative->m_pBuilder = pBuilder;
}
CV8RealTimeWorker::~CV8RealTimeWorker()
{
@ -128,6 +140,69 @@ std::wstring CV8RealTimeWorker::GetJSVariable(std::wstring sParam)
return L"jsValue(" + sParam + L")";
}
std::string GetCorrectArgument(const std::string& sInput)
{
if (sInput.empty())
return "{}";
const char* input = sInput.c_str();
std::string::size_type len = sInput.length();
std::string sResult;
sResult.reserve(len);
bool bIsInsideString = false;
int nQouteMarkCounter = 0;
for (std::string::size_type pos = 0; pos < len; ++pos)
{
char cur = input[pos];
if (bIsInsideString)
{
if ('\\' == cur)
++nQouteMarkCounter;
else if ('\"' == cur)
{
if (nQouteMarkCounter & 1)
{
// внутренняя кавычка - ничего не делаем
}
else
{
bIsInsideString = false;
nQouteMarkCounter = 0;
}
}
else
{
nQouteMarkCounter = 0;
}
sResult += cur;
}
else
{
switch (cur)
{
case '\\':
{
while (pos < (len - 1) && isalpha(input[pos + 1]))
++pos;
break;
}
case '\n':
case '\r':
case '\t':
break;
case '\"':
bIsInsideString = true;
default:
sResult += cur;
}
}
}
return sResult;
}
bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstring& path, const std::string& sString, const std::wstring& sCachePath, CV8Params* pParams)
{
LOGGER_SPEED_START();
@ -145,9 +220,8 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
if (true)
{
std::string sArg = m_sUtf8ArgumentJSON;
if (sArg.empty())
sArg = "{}";
std::string sArg = GetCorrectArgument(m_sUtf8ArgumentJSON);
NSStringUtils::string_replaceA(sArg, "\\", "\\\\");
NSStringUtils::string_replaceA(sArg, "\"", "\\\"");
std::string sArgument = "var Argument = JSON.parse(\"" + sArg + "\");";
@ -182,10 +256,8 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
// GET_NATIVE_ENGINE
if (!bIsBreak)
{
JSSmart<CJSValue> js_result2 = global_js->call_func("GetNativeEngine", 1, args);
if (try_catch->Check())
bIsBreak = true;
else
JSSmart<CJSValue> js_result2 = global_js->get("native");
if (js_result2.is_init())
{
JSSmart<CJSObject> objNative = js_result2->toObject();
pNative = (NSNativeControl::CNativeControl*)objNative->getNative()->getObject();
@ -257,7 +329,18 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
else if (type & AVS_OFFICESTUDIO_FILE_CROSSPLATFORM)
_formatDst = NSDoctRenderer::DoctRendererFormat::PDF;
else if (type & AVS_OFFICESTUDIO_FILE_IMAGE)
{
_formatDst = NSDoctRenderer::DoctRendererFormat::IMAGE;
// не поддерживает x2т прямую конвертацию. делаем ***T format
switch (m_nFileType)
{
case 0: { _formatDst = NSDoctRenderer::DoctRendererFormat::DOCT; break; }
case 1: { _formatDst = NSDoctRenderer::DoctRendererFormat::PPTT; break; }
case 2: { _formatDst = NSDoctRenderer::DoctRendererFormat::XLST; break; }
default:
break;
}
}
CJSContextScope scope(m_context);
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
@ -271,8 +354,8 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
// GET_NATIVE_ENGINE
if (true)
{
JSSmart<CJSValue> js_result2 = global_js->call_func("GetNativeEngine", 1, args);
if (!try_catch->Check())
JSSmart<CJSValue> js_result2 = global_js->get("native");
if (js_result2.is_init())
{
JSSmart<CJSObject> objNative = js_result2->toObject();
pNative = (NSNativeControl::CNativeControl*)objNative->getNative()->getObject();
@ -583,7 +666,7 @@ namespace NSDoctRenderer
return ret;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->get(name);
ret.m_internal->m_value = m_internal->m_value->toObject()->get(name);
ret.m_internal->m_parent = new CDocBuilderValue_Private::CParentValueInfo();
ret.m_internal->m_parent->m_parent = m_internal->m_value;
@ -641,7 +724,7 @@ namespace NSDoctRenderer
std::string sPropA = U_TO_UTF8(sProp);
value.m_internal->CheckNative();
m_internal->m_value->toObjectSmart()->set(sPropA.c_str(), value.m_internal->m_value.GetPointer());
m_internal->m_value->toObject()->set(sPropA.c_str(), value.m_internal->m_value.GetPointer());
}
void CDocBuilderValue::SetProperty(const wchar_t* name, CDocBuilderValue value)
{
@ -710,7 +793,7 @@ namespace NSDoctRenderer
return ret;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(name);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(name);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1)
@ -724,7 +807,7 @@ namespace NSDoctRenderer
argv[0] = p1.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(name, 1, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(name, 1, argv);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2)
@ -740,7 +823,7 @@ namespace NSDoctRenderer
argv[1] = p2.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(name, 2, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(name, 2, argv);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3)
@ -758,7 +841,7 @@ namespace NSDoctRenderer
argv[2] = p3.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(name, 3, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(name, 3, argv);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4)
@ -778,7 +861,7 @@ namespace NSDoctRenderer
argv[3] = p4.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(name, 4, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(name, 4, argv);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5)
@ -800,7 +883,7 @@ namespace NSDoctRenderer
argv[4] = p5.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(name, 5, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(name, 5, argv);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const char* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5, CDocBuilderValue p6)
@ -824,7 +907,7 @@ namespace NSDoctRenderer
argv[5] = p6.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(name, 6, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(name, 6, argv);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name)
@ -837,7 +920,7 @@ namespace NSDoctRenderer
std::string sPropA = U_TO_UTF8(sProp);
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(sPropA.c_str());
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(sPropA.c_str());
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1)
@ -854,7 +937,7 @@ namespace NSDoctRenderer
argv[0] = p1.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(sPropA.c_str(), 1, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(sPropA.c_str(), 1, argv);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2)
@ -873,7 +956,7 @@ namespace NSDoctRenderer
argv[1] = p2.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(sPropA.c_str(), 2, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(sPropA.c_str(), 2, argv);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3)
@ -894,7 +977,7 @@ namespace NSDoctRenderer
argv[2] = p3.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(sPropA.c_str(), 3, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(sPropA.c_str(), 3, argv);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4)
@ -917,7 +1000,7 @@ namespace NSDoctRenderer
argv[3] = p4.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(sPropA.c_str(), 4, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(sPropA.c_str(), 4, argv);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5)
@ -942,7 +1025,7 @@ namespace NSDoctRenderer
argv[4] = p5.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(sPropA.c_str(), 5, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(sPropA.c_str(), 5, argv);
return ret;
}
CDocBuilderValue CDocBuilderValue::Call(const wchar_t* name, CDocBuilderValue p1, CDocBuilderValue p2, CDocBuilderValue p3, CDocBuilderValue p4, CDocBuilderValue p5, CDocBuilderValue p6)
@ -969,7 +1052,7 @@ namespace NSDoctRenderer
argv[5] = p6.m_internal->m_value;
ret.m_internal->m_context = m_internal->m_context;
ret.m_internal->m_value = m_internal->m_value->toObjectSmart()->call_func(sPropA.c_str(), 6, argv);
ret.m_internal->m_value = m_internal->m_value->toObject()->call_func(sPropA.c_str(), 6, argv);
return ret;
}
@ -1250,6 +1333,15 @@ namespace NSDoctRenderer
size_t _len = command.length();
bool bIsBuilder = false;
bool bIsBuilderJSCloseFile = false;
while (_len > 0)
{
if (' ' != *_data && '\t' != *_data)
break;
++_data;
--_len;
}
if (_len > 8)
{
if (_data[0] == 'b' &&
@ -1258,9 +1350,32 @@ namespace NSDoctRenderer
_data[3] == 'l' &&
_data[4] == 'd' &&
_data[5] == 'e' &&
_data[6] == 'r' &&
_data[7] == '.')
bIsBuilder = true;
_data[6] == 'r')
{
if (_data[7] == '.')
bIsBuilder = true;
else if (_len > 20)
{
if (_data[7] == 'J' &&
_data[8] == 'S' &&
_data[9] == '.' &&
_data[10] == 'C' &&
_data[11] == 'l' &&
_data[12] == 'o' &&
_data[13] == 's' &&
_data[14] == 'e' &&
_data[15] == 'F' &&
_data[16] == 'i' &&
_data[17] == 'l' &&
_data[18] == 'e' &&
_data[19] == '(' &&
_data[20] == ')')
{
bIsBuilder = true;
bIsBuilderJSCloseFile = true;
}
}
}
}
bool bIsNoError = true;
@ -1280,6 +1395,9 @@ namespace NSDoctRenderer
++_pos;
std::string sFuncNum(_data + 8, _pos - 8);
if (bIsBuilderJSCloseFile)
sFuncNum = "CloseFile";
int nCountParameters = 0;
ParceParameters(command, _builder_params, nCountParameters);

View File

@ -44,6 +44,7 @@
#include "js_internal/js_base.h"
#include "embed/NativeBuilderEmbed.h"
#include "embed/NativeBuilderDocumentEmbed.h"
#include "embed/NativeControlEmbed.h"
#include "embed/GraphicsEmbed.h"
#include "embed/Default.h"
@ -94,11 +95,11 @@ namespace NSDoctRenderer
else if (L"pdf" == sExt)
nFormat = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
else if (L"image" == sExt)
nFormat = AVS_OFFICESTUDIO_FILE_IMAGE;
nFormat = AVS_OFFICESTUDIO_FILE_IMAGE_PNG;
else if (L"jpg" == sExt)
nFormat = AVS_OFFICESTUDIO_FILE_IMAGE;
nFormat = AVS_OFFICESTUDIO_FILE_IMAGE_JPG;
else if (L"png" == sExt)
nFormat = AVS_OFFICESTUDIO_FILE_IMAGE;
nFormat = AVS_OFFICESTUDIO_FILE_IMAGE_PNG;
return nFormat;
}
}
@ -452,6 +453,7 @@ namespace NSDoctRenderer
std::wstring m_sTmpFolder;
std::wstring m_sFileDir;
int m_nFileType;
bool m_bJavascriptBeforeEditor;
std::wstring m_sX2tPath;
@ -476,7 +478,7 @@ namespace NSDoctRenderer
public:
CDocBuilder_Private() : CDoctRendererConfig(), m_sTmpFolder(NSFile::CFileBinary::GetTempPath()), m_nFileType(-1),
m_pWorker(NULL), m_pAdditionalData(NULL), m_bIsInit(false), m_bIsCacheScript(true), m_bIsServerSafeVersion(false),
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL)
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_bJavascriptBeforeEditor(false)
{
}
@ -624,6 +626,9 @@ namespace NSDoctRenderer
NSDirectory::CreateDirectory(m_sFileDir + L"/changes");
}
if (m_bJavascriptBeforeEditor)
CheckWorkerAfterOpen();
return bRet;
#else
std::wstring sPath = m_sX2tPath + L"/empty/new.";
@ -912,7 +917,11 @@ namespace NSDoctRenderer
LOGGER_SPEED_LAP("open_convert");
if (0 == nReturnCode)
{
if (m_bJavascriptBeforeEditor)
CheckWorkerAfterOpen();
return 0;
}
NSDirectory::DeleteDirectory(m_sFileDir);
m_sFileDir = L"";
@ -923,7 +932,7 @@ namespace NSDoctRenderer
return nReturnCode;
}
void CloseFile()
void CloseFile(bool bIsDestroyJS = true)
{
Init();
@ -935,7 +944,9 @@ namespace NSDoctRenderer
if (m_pWorker)
m_sGlobalVariable = m_pWorker->GetGlobalVariable();
RELEASEOBJECT(m_pWorker);
if (bIsDestroyJS)
RELEASEOBJECT(m_pWorker);
}
std::wstring GetSaveFilePath(const std::wstring& path)
@ -989,6 +1000,9 @@ namespace NSDoctRenderer
{
sJsonParams = sJsonParams.substr(pos1 + 1, pos2 - pos1 - 1);
NSStringUtils::string_replace(sJsonParams, L"&quot;", L"\"");
if (0 != sJsonParams.find(L"{"))
sJsonParams = L"";
}
else
{
@ -1196,34 +1210,41 @@ namespace NSDoctRenderer
bool CheckWorker()
{
if (-1 == m_nFileType)
{
CV8RealTimeWorker::_LOGGING_ERROR_(L"error (command)", L"file not opened!");
return false;
}
if (NULL == m_pWorker)
{
m_pWorker = new CV8RealTimeWorker(m_pParent);
m_pWorker->m_nFileType = m_nFileType;
m_pWorker->m_sUtf8ArgumentJSON = m_oParams.m_sArgumentJSON;
m_pWorker->m_sGlobalVariable = m_sGlobalVariable;
std::wstring sCachePath = L"";
if (m_bIsCacheScript)
sCachePath = GetScriptCache();
CV8Params oParams;
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
oParams.DocumentDirectory = m_sFileDir;
bool bOpen = m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, GetScript(), sCachePath, &oParams);
if (!bOpen)
return false;
return CheckWorkerAfterOpen();
}
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;
std::wstring sCachePath = L"";
if (m_bIsCacheScript)
sCachePath = GetScriptCache();
CV8Params oParams;
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
oParams.DocumentDirectory = m_sFileDir;
return m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, GetScript(), sCachePath, &oParams);
}
int SaveFile(const std::wstring& ext, const std::wstring& path, const wchar_t* params = NULL)
{
int nType = -1;
@ -1270,9 +1291,7 @@ namespace NSDoctRenderer
Init();
if (!CheckWorker())
return false;
CheckWorker();
return m_pWorker->ExecuteCommand(command, retValue);
}
@ -1280,8 +1299,7 @@ namespace NSDoctRenderer
{
CDocBuilderContext ctx;
if (!CheckWorker())
return ctx;
CheckWorker();
ctx.m_internal->m_context = m_pWorker->m_context;
ctx.m_internal->m_context_data = &m_pWorker->m_oContextData;

View File

@ -548,6 +548,8 @@ namespace NSDoctRenderer
bool ExecuteScript(const std::string& strScript, const std::wstring& sCachePath, std::wstring& strError, std::wstring& strReturnParams)
{
if (strScript.empty() && sCachePath.empty()) return true;
LOGGER_SPEED_START();
bool bIsBreak = false;
@ -555,14 +557,22 @@ namespace NSDoctRenderer
if (true)
{
context->CreateContext();
CJSContextScope scope(context);
CNativeControlEmbed::CreateObjectBuilderInContext("CreateNativeEngine", context);
CGraphicsEmbed::CreateObjectInContext("CreateNativeGraphics", context);
NSJSBase::CreateDefaults(context);
CJSContext::Embed<CNativeControlEmbed>(false);
CJSContext::Embed<CGraphicsEmbed>();
NSJSBase::CreateDefaults();
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();
JSSmart<CJSObject> global_js = context->GetGlobal();
global_js->set("window", global_js);
JSSmart<CJSObject> oNativeCtrl = CJSContext::createEmbedObject("CNativeControlEmbed");
global_js->set("native", oNativeCtrl);
NSNativeControl::CNativeControl* pNative = static_cast<NSNativeControl::CNativeControl*>(oNativeCtrl->getNative()->getObject());
pNative->m_sConsoleLogFile = m_sConsoleLogFile;
LOGGER_SPEED_LAP("compile");
JSSmart<CJSValue> res = context->runScript(strScript, try_catch, sCachePath);
@ -575,29 +585,10 @@ namespace NSDoctRenderer
LOGGER_SPEED_LAP("run");
//---------------------------------------------------------------
JSSmart<CJSObject> global_js = context->GetGlobal();
JSSmart<CJSValue> args[1];
args[0] = CJSContext::createInt(0);
NSNativeControl::CNativeControl* pNative = NULL;
// GET_NATIVE_ENGINE
if (!bIsBreak)
{
JSSmart<CJSValue> js_result2 = global_js->call_func("GetNativeEngine", 1, args);
if (try_catch->Check())
{
strError = L"code=\"run\"";
bIsBreak = true;
}
else
{
JSSmart<CJSObject> objNative = js_result2->toObject();
pNative = (NSNativeControl::CNativeControl*)objNative->getNative()->getObject();
pNative->m_sConsoleLogFile = m_sConsoleLogFile;
}
}
if (pNative != NULL)
{
pNative->m_pChanges = &m_oParams.m_arChanges;
@ -1091,11 +1082,14 @@ namespace NSDoctRenderer
if (true)
{
context->CreateContext();
CJSContextScope scope(context);
CNativeControlEmbed::CreateObjectBuilderInContext("CreateNativeEngine", context);
CGraphicsEmbed::CreateObjectInContext("CreateNativeGraphics", context);
NSJSBase::CreateDefaults(context);
CJSContext::Embed<CNativeControlEmbed>();
CJSContext::Embed<CGraphicsEmbed>();
NSJSBase::CreateDefaults();
JSSmart<CJSObject> global = context->GetGlobal();
global->set("window", global);
global->set("native", CJSContext::createEmbedObject("CNativeControlEmbed"));
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();

View File

@ -13,9 +13,11 @@ 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 += \
@ -49,6 +51,7 @@ HEADERS += \
embed/MemoryStreamEmbed.h \
embed/NativeControlEmbed.h \
embed/NativeBuilderEmbed.h \
embed/NativeBuilderDocumentEmbed.h \
embed/TextMeasurerEmbed.h \
embed/HashEmbed.h \
embed/Default.h \
@ -61,6 +64,7 @@ SOURCES += \
embed/MemoryStreamEmbed.cpp \
embed/NativeControlEmbed.cpp \
embed/NativeBuilderEmbed.cpp \
embed/NativeBuilderDocumentEmbed.cpp \
embed/TextMeasurerEmbed.cpp \
embed/HashEmbed.cpp \
embed/Default.cpp
@ -68,32 +72,24 @@ SOURCES += \
include($$PWD/js_internal/js_base.pri)
!use_javascript_core {
SOURCES += \
embed/v8/v8_MemoryStream.cpp \
embed/v8/v8_NativeControl.cpp \
embed/v8/v8_NativeBuilder.cpp \
embed/v8/v8_Graphics.cpp \
embed/v8/v8_Zip.cpp \
embed/v8/v8_Pointer.cpp \
embed/v8/v8_TextMeasurer.cpp \
embed/v8/v8_Hash.cpp
build_xp:DESTDIR=$$DESTDIR/xp
} else {
OBJECTIVE_SOURCES += ../common/Mac/NSString+StringUtils.mm
OBJECTIVE_SOURCES += \
embed/jsc/jsc_Graphics.mm \
embed/jsc/jsc_MemoryStream.mm \
embed/jsc/jsc_NativeControl.mm \
embed/jsc/jsc_NativeBuilder.mm \
embed/jsc/jsc_Zip.mm \
embed/jsc/jsc_Pointer.mm \
embed/jsc/jsc_TextMeasurer.mm \
embed/jsc/jsc_Hash.mm
LIBS += -framework Foundation
}
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)

View File

@ -1,17 +1,17 @@
#include "Default.h"
#include "./ZipEmbed.h"
#include "./TextMeasurerEmbed.h"
#include "./MemoryStreamEmbed.h"
#include "./TextMeasurerEmbed.h"
#include "./HashEmbed.h"
namespace NSJSBase
{
void CreateDefaults(JSSmart<CJSContext>& context)
void CreateDefaults()
{
CZipEmbed::CreateObjectInContext("CreateNativeZip", context);
CTextMeasurerEmbed::CreateObjectInContext("CreateNativeTextMeasurer", context);
CMemoryStreamEmbed::CreateObjectInContext("CreateNativeMemoryStream", context);
CHashEmbed::CreateObjectInContext("CreateNativeHash", context);
CJSContext::Embed<CZipEmbed>();
CJSContext::Embed<CMemoryStreamEmbed>();
CJSContext::Embed<CTextMeasurerEmbed>();
CJSContext::Embed<CHashEmbed>();
}
}

View File

@ -5,7 +5,7 @@
namespace NSJSBase
{
void JS_DECL CreateDefaults(JSSmart<CJSContext>& context);
void JS_DECL CreateDefaults();
}
#endif // _BUILD_NATIVE_DEFAULT_EMBED_H_

View File

@ -1,8 +1,8 @@
#include "GraphicsEmbed.h"
JSSmart<CJSValue> CGraphicsEmbed::init(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm)
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->toObjectSmart()->getNative()->getObject(), width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
m_pInternal->init((NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject(), width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
return NULL;
}
JSSmart<CJSValue> CGraphicsEmbed::Destroy()

View File

@ -17,7 +17,7 @@ public:
virtual void* getObject() override { return (void*)m_pInternal; }
public:
JSSmart<CJSValue> init(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm);
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();
JSSmart<CJSValue> EndDraw();
JSSmart<CJSValue> put_GlobalAlpha(JSSmart<CJSValue> enable, JSSmart<CJSValue> globalAlpha);
@ -132,7 +132,7 @@ public:
JSSmart<CJSValue> CoordTransformOffset(JSSmart<CJSValue> tx, JSSmart<CJSValue> ty);
JSSmart<CJSValue> GetTransform();
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
DECLARE_EMBED_METHODS
};
#endif // _BUILD_NATIVE_GRAPHICS_EMBED_H_

View File

@ -5,7 +5,7 @@
#include "../hash.h"
using namespace NSJSBase;
class CHashEmbed : public CJSEmbedObject
class JS_DECL CHashEmbed : public CJSEmbedObject
{
public:
CHash* m_pHash;
@ -24,8 +24,7 @@ public:
JSSmart<CJSValue> hash(JSSmart<CJSValue> data, JSSmart<CJSValue> size, JSSmart<CJSValue> alg);
JSSmart<CJSValue> hash2(JSSmart<CJSValue> password, JSSmart<CJSValue> salt, JSSmart<CJSValue> spinCount, JSSmart<CJSValue> alg);
public:
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
DECLARE_EMBED_METHODS
};
#endif // _BUILD_NATIVE_HASH_EMBED_H_

View File

@ -5,7 +5,7 @@
#include "../js_internal/js_base.h"
using namespace NSJSBase;
class CMemoryStreamEmbed : public CJSEmbedObject
class JS_DECL CMemoryStreamEmbed : public CJSEmbedObject
{
public:
NSMemoryStream::CMemoryStream* m_pInternal;
@ -29,7 +29,7 @@ public:
JSSmart<CJSValue> WriteString(JSSmart<CJSValue> value);
JSSmart<CJSValue> WriteString2(JSSmart<CJSValue> value);
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
DECLARE_EMBED_METHODS
};
#endif // _BUILD_NATIVE_MEMORYSTREAM_EMBED_H_

View File

@ -0,0 +1,80 @@
#include "NativeBuilderDocumentEmbed.h"
#include "./../docbuilder_p.h"
#include "../../common/Directory.h"
JSSmart<CJSValue> CBuilderDocumentEmbed::IsValid()
{
return CJSContext::createBool(m_bIsValid);
}
JSSmart<CJSValue> CBuilderDocumentEmbed::GetBinary()
{
return CJSContext::createUint8Array(m_sFolder + L"/Editor.bin");
}
JSSmart<CJSValue> CBuilderDocumentEmbed::GetFolder()
{
return CJSContext::createString(m_sFolder);
}
JSSmart<CJSValue> CBuilderDocumentEmbed::Close()
{
_CloseFile();
return NULL;
}
JSSmart<CJSValue> CBuilderDocumentEmbed::GetImageMap()
{
std::vector<std::wstring> files = NSDirectory::GetFiles(m_sFolder + L"/media");
JSSmart<CJSObject> obj = CJSContext::createObject();
for (std::vector<std::wstring>::iterator i = files.begin(); i != files.end(); i++)
{
std::wstring sFile = *i;
NSStringUtils::string_replace(sFile, L"\\", L"/");
std::wstring sName = L"media/" + NSFile::GetFileName(sFile);
obj->set(U_TO_UTF8(sName).c_str(), CJSContext::createString(sFile));
}
return obj->toValue();
}
void CBuilderDocumentEmbed::_OpenFile(const std::wstring& sFile, const std::wstring& sParams)
{
NSDoctRenderer::CDocBuilder_Private* pBuilder = GetPrivate(m_pBuilder);
std::wstring sTmpDir = pBuilder->m_sTmpFolder;
m_sFolder = NSFile::CFileBinary::CreateTempFileWithUniqueName(sTmpDir, L"DE_");
if (NSFile::CFileBinary::Exists(m_sFolder))
NSFile::CFileBinary::Remove(m_sFolder);
NSStringUtils::string_replace(m_sFolder, L"\\", L"/");
std::wstring::size_type nPosPoint = m_sFolder.rfind('.');
if (nPosPoint != std::wstring::npos && nPosPoint > sTmpDir.length())
{
m_sFolder = m_sFolder.substr(0, nPosPoint);
}
NSDirectory::CreateDirectory(m_sFolder);
std::wstring sExtCopy = pBuilder->GetFileCopyExt(sFile);
std::wstring sFileCopy = m_sFolder + L"/origin." + sExtCopy;
pBuilder->MoveFileOpen(sFile, sFileCopy);
int nConvertResult = pBuilder->ConvertToInternalFormat(m_sFolder, sFileCopy, sParams);
if (0 == nConvertResult)
m_bIsValid = true;
}
void CBuilderDocumentEmbed::_CloseFile()
{
if (!m_sFolder.empty())
NSDirectory::DeleteDirectory(m_sFolder);
m_bIsValid = false;
m_sFolder = L"";
}

View File

@ -29,39 +29,39 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef BUILDER_WRAPPER_BUILDER
#define BUILDER_WRAPPER_BUILDER
#ifndef _BUILD_NATIVE_BUILDER_DOCUMENT_EMBED_H_
#define _BUILD_NATIVE_BUILDER_DOCUMENT_EMBED_H_
#include "../docbuilder.h"
#include "../nativecontrol.h"
#include "../js_internal/js_base.h"
class CBuilderObject
using namespace NSJSBase;
class CBuilderDocumentEmbed : public CJSEmbedObject
{
public:
NSDoctRenderer::CDocBuilder* m_pBuilder;
NSDoctRenderer::CDocBuilder* m_pBuilder;
bool m_bIsValid;
std::wstring m_sFolder;
public:
CBuilderObject()
{
m_pBuilder = NULL;
}
~CBuilderObject()
{
}
CBuilderDocumentEmbed() : m_pBuilder(NULL), m_bIsValid(false) {}
~CBuilderDocumentEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
virtual void* getObject() { return (void*)m_pBuilder; }
NSDoctRenderer::CDocBuilder_Private* GetPrivate(NSDoctRenderer::CDocBuilder* pBuilder) { return pBuilder->GetPrivate(); }
public:
void _OpenFile(const std::wstring& sFile, const std::wstring& sParams);
void _CloseFile();
public:
JSSmart<CJSValue> IsValid();
JSSmart<CJSValue> GetBinary();
JSSmart<CJSValue> GetFolder();
JSSmart<CJSValue> Close();
JSSmart<CJSValue> GetImageMap();
DECLARE_EMBED_METHODS
};
// wrap_methods -------------
CBuilderObject* unwrap_builder(v8::Handle<v8::Object> obj);
void _b_openfile(const v8::FunctionCallbackInfo<v8::Value>& args);
void _b_createfile(const v8::FunctionCallbackInfo<v8::Value>& args);
void _b_settmpfolder(const v8::FunctionCallbackInfo<v8::Value>& args);
void _b_savefile(const v8::FunctionCallbackInfo<v8::Value>& args);
void _b_closefile(const v8::FunctionCallbackInfo<v8::Value>& args);
void _b_writefile(const v8::FunctionCallbackInfo<v8::Value>& args);
v8::Handle<v8::ObjectTemplate> CreateBuilderTemplate(v8::Isolate* isolate);
void CreateBuilderObject(const v8::FunctionCallbackInfo<v8::Value>& args);
#endif // BUILDER_WRAPPER_BUILDER
#endif // _BUILD_NATIVE_BUILDER_DOCUMENT_EMBED_H_

View File

@ -1,16 +1,18 @@
#include "NativeBuilderEmbed.h"
#include "NativeBuilderDocumentEmbed.h"
#include "./../docbuilder_p.h"
#include "../../common/Directory.h"
JSSmart<CJSValue> CBuilderEmbed::builder_OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSValue> sParams)
JSSmart<CJSValue> CBuilderEmbed::OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSValue> sParams)
{
std::wstring Path = sPath->toStringW();
std::wstring Params = sParams->toStringW();
int ret = m_pBuilder->OpenFile(Path.c_str(), Params.c_str());
return CJSContext::createInt(ret);
}
JSSmart<CJSValue> CBuilderEmbed::builder_CreateFile(JSSmart<CJSValue> type)
JSSmart<CJSValue> CBuilderEmbed::CreateFile(JSSmart<CJSValue> type)
{
int nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
if (type->isString())
@ -21,13 +23,15 @@ JSSmart<CJSValue> CBuilderEmbed::builder_CreateFile(JSSmart<CJSValue> type)
bool ret = m_pBuilder->CreateFile(nFormat);
return CJSContext::createBool(ret);
}
JSSmart<CJSValue> CBuilderEmbed::builder_SetTmpFolder(JSSmart<CJSValue> path)
JSSmart<CJSValue> CBuilderEmbed::SetTmpFolder(JSSmart<CJSValue> path)
{
std::wstring sPath = path->toStringW();
m_pBuilder->SetTmpFolder(sPath.c_str());
return NULL;
}
JSSmart<CJSValue> CBuilderEmbed::builder_SaveFile(JSSmart<CJSValue> type, JSSmart<CJSValue> path, JSSmart<CJSValue> params)
JSSmart<CJSValue> CBuilderEmbed::SaveFile(JSSmart<CJSValue> type, JSSmart<CJSValue> path, JSSmart<CJSValue> params)
{
int nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX;
if (type->isString())
@ -40,80 +44,21 @@ JSSmart<CJSValue> CBuilderEmbed::builder_SaveFile(JSSmart<CJSValue> type, JSSmar
int ret = m_pBuilder->SaveFile(nFormat, sPath.c_str(), sParams.empty() ? NULL : sParams.c_str());
return CJSContext::createInt(ret);
}
JSSmart<CJSValue> CBuilderEmbed::builder_CloseFile()
JSSmart<CJSValue> CBuilderEmbed::CloseFile()
{
m_pBuilder->CloseFile();
std::cout << "Warning: use builderJS.CloseFile(); separately!";
m_pBuilder->GetPrivate()->CloseFile(false);
return NULL;
}
JSSmart<CJSValue> CBuilderDocumentEmbed::builder_doc_IsValid()
JSSmart<CJSValue> CBuilderEmbed::OpenTmpFile(JSSmart<CJSValue> path, JSSmart<CJSValue> params)
{
return CJSContext::createBool(m_bIsValid);
}
JSSmart<CJSValue> CBuilderDocumentEmbed::builder_doc_GetBinary()
{
return CJSContext::createUint8Array(m_sFolder + L"/Editor.bin");
}
JSSmart<CJSValue> CBuilderDocumentEmbed::builder_doc_GetFolder()
{
return CJSContext::createString(m_sFolder);
}
JSSmart<CJSValue> CBuilderDocumentEmbed::builder_doc_CloseFile()
{
CloseFile();
return NULL;
}
JSSmart<CJSValue> CBuilderDocumentEmbed::builder_doc_GetImageMap()
{
std::vector<std::wstring> files = NSDirectory::GetFiles(m_sFolder + L"/media");
JSSmart<CJSObject> obj = CJSContext::createObject();
for (std::vector<std::wstring>::iterator i = files.begin(); i != files.end(); i++)
{
std::wstring sFile = *i;
NSStringUtils::string_replace(sFile, L"\\", L"/");
std::wstring sName = L"media/" + NSFile::GetFileName(sFile);
obj->set(U_TO_UTF8(sName).c_str(), CJSContext::createString(sFile));
}
return obj->toValue();
}
void CBuilderDocumentEmbed::OpenFile(const std::wstring& sFile, const std::wstring& sParams)
{
NSDoctRenderer::CDocBuilder_Private* pBuilder = GetPrivate(m_pBuilder);
std::wstring sTmpDir = pBuilder->m_sTmpFolder;
m_sFolder = NSFile::CFileBinary::CreateTempFileWithUniqueName(sTmpDir, L"DE_");
if (NSFile::CFileBinary::Exists(m_sFolder))
NSFile::CFileBinary::Remove(m_sFolder);
NSStringUtils::string_replace(m_sFolder, L"\\", L"/");
std::wstring::size_type nPosPoint = m_sFolder.rfind('.');
if (nPosPoint != std::wstring::npos && nPosPoint > sTmpDir.length())
{
m_sFolder = m_sFolder.substr(0, nPosPoint);
}
NSDirectory::CreateDirectory(m_sFolder);
std::wstring sExtCopy = pBuilder->GetFileCopyExt(sFile);
std::wstring sFileCopy = m_sFolder + L"/origin." + sExtCopy;
pBuilder->MoveFileOpen(sFile, sFileCopy);
int nConvertResult = pBuilder->ConvertToInternalFormat(m_sFolder, sFileCopy, sParams);
if (0 == nConvertResult)
m_bIsValid = true;
}
void CBuilderDocumentEmbed::CloseFile()
{
if (!m_sFolder.empty())
NSDirectory::DeleteDirectory(m_sFolder);
m_bIsValid = false;
m_sFolder = L"";
std::wstring sPath = path->toStringW();
std::wstring sParams = params->toStringW();
JSSmart<CJSObject> oBuilderTmpDoc = CJSContext::createEmbedObject("CBuilderDocumentEmbed");
CBuilderDocumentEmbed* pBuilderTmpDocNative = static_cast<CBuilderDocumentEmbed*>(oBuilderTmpDoc->getNative());
pBuilderTmpDocNative->m_pBuilder = m_pBuilder;
pBuilderTmpDocNative->_OpenFile(sPath, sParams);
return oBuilderTmpDoc->toValue();
}

View File

@ -29,12 +29,17 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef NATIVECONTROLBUILDER
#define NATIVECONTROLBUILDER
#ifndef _BUILD_NATIVE_BUILDER_EMBED_H_
#define _BUILD_NATIVE_BUILDER_EMBED_H_
#include "../docbuilder.h"
#include "../js_internal/js_base.h"
// For windows fileapi
#ifdef CreateFile
#undef CreateFile
#endif
using namespace NSJSBase;
class CBuilderEmbed : public CJSEmbedObject
{
@ -47,40 +52,16 @@ public:
virtual void* getObject() { return (void*)m_pBuilder; }
public:
JSSmart<CJSValue> builder_OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSValue> sParams);
JSSmart<CJSValue> builder_CreateFile(JSSmart<CJSValue> type);
JSSmart<CJSValue> builder_SetTmpFolder(JSSmart<CJSValue> path);
JSSmart<CJSValue> builder_SaveFile(JSSmart<CJSValue> type, JSSmart<CJSValue> path, JSSmart<CJSValue> params);
JSSmart<CJSValue> builder_CloseFile();
JSSmart<CJSValue> builder_OpenTmpFile(JSSmart<CJSValue> path, JSSmart<CJSValue> params);
};
JSSmart<CJSValue> OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSValue> sParams);
JSSmart<CJSValue> CreateFile(JSSmart<CJSValue> type);
JSSmart<CJSValue> SetTmpFolder(JSSmart<CJSValue> path);
JSSmart<CJSValue> SaveFile(JSSmart<CJSValue> type, JSSmart<CJSValue> path, JSSmart<CJSValue> params);
JSSmart<CJSValue> CloseFile();
JSSmart<CJSValue> OpenTmpFile(JSSmart<CJSValue> path, JSSmart<CJSValue> params);
class CBuilderDocumentEmbed : public CJSEmbedObject
{
public:
NSDoctRenderer::CDocBuilder* m_pBuilder;
bool m_bIsValid;
std::wstring m_sFolder;
public:
CBuilderDocumentEmbed() : m_pBuilder(NULL), m_bIsValid(false) {}
~CBuilderDocumentEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
virtual void* getObject() { return (void*)m_pBuilder; }
NSDoctRenderer::CDocBuilder_Private* GetPrivate(NSDoctRenderer::CDocBuilder* pBuilder) { return pBuilder->GetPrivate(); }
public:
void OpenFile(const std::wstring& sFile, const std::wstring& sParams);
void CloseFile();
public:
JSSmart<CJSValue> builder_doc_IsValid();
JSSmart<CJSValue> builder_doc_GetBinary();
JSSmart<CJSValue> builder_doc_GetFolder();
JSSmart<CJSValue> builder_doc_CloseFile();
JSSmart<CJSValue> builder_doc_GetImageMap();
DECLARE_EMBED_METHODS
};
void builder_CreateNative(const std::string& name, JSSmart<CJSContext> context, NSDoctRenderer::CDocBuilder* builder);
#endif // NATIVECONTROLBUILDER
#endif // _BUILD_NATIVE_BUILDER_EMBED_H_

View File

@ -147,7 +147,7 @@ JSSmart<CJSValue> CNativeControlEmbed::SaveChanges(JSSmart<CJSValue> sParam, JSS
return NULL;
}
JSSmart<CJSValue> CNativeControlEmbed::zipOpenFile(JSSmart<CJSValue> name)
JSSmart<CJSValue> CNativeControlEmbed::ZipOpen(JSSmart<CJSValue> name)
{
bool bIsOpen = m_pInternal->m_oZipWorker.Open(name->toStringW());
if (!bIsOpen)
@ -163,7 +163,7 @@ JSSmart<CJSValue> CNativeControlEmbed::zipOpenFile(JSSmart<CJSValue> name)
return obj->toValue();
}
JSSmart<CJSValue> CNativeControlEmbed::zipOpenFileBase64(JSSmart<CJSValue> name)
JSSmart<CJSValue> CNativeControlEmbed::ZipOpenBase64(JSSmart<CJSValue> name)
{
bool bIsOpen = m_pInternal->m_oZipWorker.OpenBase64(name->toStringA());
if (!bIsOpen)
@ -179,7 +179,7 @@ JSSmart<CJSValue> CNativeControlEmbed::zipOpenFileBase64(JSSmart<CJSValue> name)
return obj->toValue();
}
JSSmart<CJSValue> CNativeControlEmbed::zipGetFileAsString(JSSmart<CJSValue> name)
JSSmart<CJSValue> CNativeControlEmbed::ZipFileAsString(JSSmart<CJSValue> name)
{
BYTE* pData = NULL;
DWORD len = 0;
@ -187,12 +187,12 @@ JSSmart<CJSValue> CNativeControlEmbed::zipGetFileAsString(JSSmart<CJSValue> name
return CJSContext::createString((char*)pData, len);
}
JSSmart<CJSValue> CNativeControlEmbed::zipGetFileAsBinary(JSSmart<CJSValue> name)
JSSmart<CJSValue> CNativeControlEmbed::ZipFileAsBinary(JSSmart<CJSValue> name)
{
return CJSContext::createUint8Array(m_pInternal->m_oZipWorker.m_sTmpFolder + L"/" + name->toStringW());
}
JSSmart<CJSValue> CNativeControlEmbed::zipCloseFile()
JSSmart<CJSValue> CNativeControlEmbed::ZipClose()
{
m_pInternal->m_oZipWorker.Close();
return NULL;

View File

@ -30,23 +30,22 @@ public:
JSSmart<CJSValue> CheckNextChange();
JSSmart<CJSValue> GetCountChanges();
JSSmart<CJSValue> GetChangesFile(JSSmart<CJSValue> index);
JSSmart<CJSValue> Save_AllocNative(JSSmart<CJSValue> nLen);
JSSmart<CJSValue> Save_ReAllocNative(JSSmart<CJSValue> pos, JSSmart<CJSValue> len);
/*[noexport]*/JSSmart<CJSValue> Save_AllocNative(JSSmart<CJSValue> nLen);
/*[noexport]*/JSSmart<CJSValue> Save_ReAllocNative(JSSmart<CJSValue> pos, JSSmart<CJSValue> len);
JSSmart<CJSValue> Save_End(JSSmart<CJSValue> pos, JSSmart<CJSValue> len);
JSSmart<CJSValue> AddImageInChanges(JSSmart<CJSValue> img);
JSSmart<CJSValue> ConsoleLog(JSSmart<CJSValue> message);
JSSmart<CJSValue> SaveChanges(JSSmart<CJSValue> sParam, JSSmart<CJSValue> nDeleteIndex, JSSmart<CJSValue> nCount);
JSSmart<CJSValue> zipOpenFile(JSSmart<CJSValue> name);
JSSmart<CJSValue> zipOpenFileBase64(JSSmart<CJSValue> name);
JSSmart<CJSValue> zipGetFileAsString(JSSmart<CJSValue> name);
JSSmart<CJSValue> zipGetFileAsBinary(JSSmart<CJSValue> name);
JSSmart<CJSValue> zipCloseFile();
/*[noexport]*/JSSmart<CJSValue> SaveChanges(JSSmart<CJSValue> sParam, JSSmart<CJSValue> nDeleteIndex, JSSmart<CJSValue> nCount);
JSSmart<CJSValue> ZipOpen(JSSmart<CJSValue> name);
JSSmart<CJSValue> ZipOpenBase64(JSSmart<CJSValue> name);
JSSmart<CJSValue> ZipFileAsString(JSSmart<CJSValue> name);
JSSmart<CJSValue> ZipFileAsBinary(JSSmart<CJSValue> name);
JSSmart<CJSValue> ZipClose();
JSSmart<CJSValue> GetImageUrl(JSSmart<CJSValue> sUrl);
JSSmart<CJSValue> GetImagesPath();
JSSmart<CJSValue> GetImageOriginalSize(JSSmart<CJSValue> sUrl);
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
static void CreateObjectBuilderInContext(const std::string& name, JSSmart<CJSContext> context);
DECLARE_EMBED_METHODS
};
#endif // _BUILD_NATIVE_NATIVECONTROL_EMBED_H_

View File

@ -14,7 +14,7 @@ namespace NSPointerObjectDeleters
#define POINTER_DELETER(CLASS_NAME, NAME) void NAME(void* data) { CLASS_NAME* p = (CLASS_NAME*)data; delete data; }
using namespace NSJSBase;
class CPointerEmbedObject : public CJSEmbedObject
class JS_DECL CPointerEmbedObject : public CJSEmbedObject
{
public:
void* Data;

View File

@ -1,8 +1,9 @@
#include "./TextMeasurerEmbed.h"
#include "./PointerEmbed.h"
#include "./../../fontengine/TextShaper.h"
#define RAW_POINTER(value) ((CPointerEmbedObject*)value->toObjectSmart()->getNative())->Data
#define POINTER_OBJECT(value) ((CPointerEmbedObject*)value->toObjectSmart()->getNative())
#define RAW_POINTER(value) ((CPointerEmbedObject*)value->toObject()->getNative())->Data
#define POINTER_OBJECT(value) ((CPointerEmbedObject*)value->toObject()->getNative())
// в js не хотим следить, чтобы в каждом face была ссылка на library - т.е. чтобы
// сначала удалились все face, а потом library - поэтому делаем свой счетчик ссылок
@ -54,7 +55,7 @@ JSSmart<CJSValue> CTextMeasurerEmbed::FT_Malloc(JSSmart<CJSValue> typed_array_or
}
JSSmart<CJSValue> CTextMeasurerEmbed::FT_Free(JSSmart<CJSValue> pointer)
{
CPointerEmbedObject* pEmbed = (CPointerEmbedObject*)pointer->toObjectSmart()->getNative();
CPointerEmbedObject* pEmbed = (CPointerEmbedObject*)pointer->toObject()->getNative();
pEmbed->Free();
return CJSContext::createUndefined();
}

View File

@ -2,14 +2,13 @@
#define _BUILD_NATIVE_TEXT_MEASURER_EMBED_H_
#include "../js_internal/js_base.h"
#include "./PointerEmbed.h"
#if defined(__ANDROID__) || defined(_IOS)
#define SUPPORT_HARFBUZZ_SHAPER
#endif
using namespace NSJSBase;
class CTextMeasurerEmbed : public CJSEmbedObject
class JS_DECL CTextMeasurerEmbed : public CJSEmbedObject
{
public:
CTextMeasurerEmbed()
@ -51,7 +50,7 @@ public:
JSSmart<CJSValue> HB_FontFree(JSSmart<CJSValue> font);
#endif
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
DECLARE_EMBED_METHODS
};
#endif // _BUILD_NATIVE_TEXT_MEASURER_EMBED_H_

View File

@ -5,7 +5,7 @@
#include "../js_internal/js_base.h"
using namespace NSJSBase;
class CZipEmbed : public CJSEmbedObject
class JS_DECL CZipEmbed : public CJSEmbedObject
{
public:
IFolder* m_pFolder;
@ -37,7 +37,7 @@ public:
JSSmart<CJSValue> encodeImage(JSSmart<CJSValue> typedArray, JSSmart<CJSValue> format);
JSSmart<CJSValue> getImageType(JSSmart<CJSValue> typedArray);
static void CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context);
DECLARE_EMBED_METHODS
};
#endif // _BUILD_NATIVE_ZIP_EMBED_H_

View File

@ -0,0 +1,347 @@
import sys
import re
import os
import argparse
class MethodInfo:
def __init__(self, name, args):
self.name = name
self.args = args
class MethodList:
def __init__(self, ifdef, methods):
self.ifdef = ifdef
self.methods = methods
def makeDir(dirname):
if not os.path.exists(dirname):
os.mkdir(dirname)
def getMethods(content):
methods = []
# Extract name and argument list of the methods that return JSSmart<CJSValue>
src_methods = re.findall(r'JSSmart\<CJSValue\>\s+(\w+)\s*\(([^\)]*)\)\s*;', content)
# Get method names and argument lists
for src_method in src_methods:
args = re.findall(r'JSSmart\<CJSValue\>\s+(\w+)', src_method[1])
method = MethodInfo(src_method[0], args)
methods.append(method)
return methods
def parseHeader(header_file):
class_name = ''
method_lists = []
with open(header_file, 'r') as file:
content = file.read()
# Extract the class name
match = re.search(r'class\s+(\w+)\s*:\s*public\s+CJSEmbedObject', content)
if match:
class_name = match.group(1)
else:
print("No class derived from CJSEmbedObject was found")
sys.exit(1)
# Remove all functions which start with "/*[noexport]*/" comment
content = re.sub(r'/\*\[noexport\]\*/\s*JSSmart\<CJSValue\>\s+\w+\s*\([^\)]*\)\s*;', '', content)
# Handle methods inside of ifdef blocks
ifdef_blocks = re.findall(r'#ifdef\s+([\w\d_]+)\s+(.*?)#endif', content, re.DOTALL)
for ifdef_block in ifdef_blocks:
methods = getMethods(ifdef_block[1])
if len(methods) > 0:
method_lists.append(MethodList(ifdef_block[0], methods))
content = content.replace(ifdef_block[1], '')
# Add all other methods
method_lists.append(MethodList(None, getMethods(content)))
return class_name, method_lists
def generateCommonCode(class_name):
code = "std::string " + class_name + "::getName() { return \"" + class_name + "\"; }\n"
code += "\n"
code += "CJSEmbedObject* " + class_name + "::getCreator()\n"
code += "{\n"
code += " return new " + class_name + "();\n"
code += "}\n"
return code
def generateV8InternalCode(class_name, method_lists, header_file):
code = "// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!\n"
code += "// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH \"--internal\" OPTION.\n\n"
code += "#include \"../" + header_file + "\"\n"
code += "#include \"../../js_internal/v8/v8_base.h\"\n\n"
namespace_name = "NS" + header_file[:-2]
code += "namespace " + namespace_name + "\n"
code += "{\n"
code += "#define CURRENTWRAPPER " + class_name + "\n\n"
for method_list in method_lists:
if method_list.ifdef:
code += "#ifdef " + method_list.ifdef + "\n"
for method in method_list.methods:
code += " FUNCTION_WRAPPER_V8_" + str(len(method.args)) + "(_" + method.name + ", " + method.name + ")\n"
if method_list.ifdef:
code += "#endif\n"
code += "\n"
code += " v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)\n"
code += " {\n"
code += " v8::EscapableHandleScope handle_scope(isolate);\n"
code += " v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);\n"
code += " result->SetInternalFieldCount(1);\n"
code += "\n"
for method_list in method_lists:
if method_list.ifdef:
code += "#ifdef " + method_list.ifdef + "\n"
for method in method_list.methods:
code += " NSV8Objects::Template_Set(result, \"" + method.name + "\", _" + method.name + ");\n"
if method_list.ifdef:
code += "#endif\n"
code += "\n"
code += " return handle_scope.Escape(result);\n"
code += " }\n"
code += "}\n"
code += "\n"
adapter_name = class_name + "Adapter"
code += "class " + adapter_name + " : public CJSEmbedObjectAdapterV8Template\n"
code += "{\n"
code += "public:\n"
code += " virtual v8::Local<v8::ObjectTemplate> getTemplate(v8::Isolate* isolate) override\n"
code += " {\n"
code += " v8::EscapableHandleScope handle_scope(isolate);\n"
code += " v8::Local<v8::ObjectTemplate> templ = " + namespace_name + "::CreateTemplate(isolate);\n"
code += " return handle_scope.Escape(templ);\n"
code += " }\n"
code += "};\n"
code += "\n"
code += "CJSEmbedObjectAdapterBase* " + class_name + "::getAdapter()\n"
code += "{\n"
code += " if (m_pAdapter == nullptr)\n"
code += " m_pAdapter = new " + adapter_name + "();\n"
code += " return m_pAdapter;\n"
code += "}\n\n"
return code
def generateJSCInternalCode(class_name, method_lists, header_file):
code = "// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!\n"
code += "// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH \"--internal\" OPTION.\n\n"
code += "#include \"../" + header_file + "\"\n"
code += "#include \"../../js_internal/jsc/jsc_base.h\"\n\n"
objc_protocol_name = "IJS" + class_name
code += "@protocol " + objc_protocol_name + " <JSExport>\n"
for method_list in method_lists:
if method_list.ifdef:
code += "#ifdef " + method_list.ifdef + "\n"
for method in method_list.methods:
code += "-(JSValue*) " + method.name
for arg in method.args:
code += " : (JSValue*)" + arg
code += ";\n"
if method_list.ifdef:
code += "#endif\n"
code += "@end\n\n"
objc_class_name = "CJS" + class_name
code += "@interface " + objc_class_name + " : NSObject<" + objc_protocol_name + ", JSEmbedObjectProtocol>\n"
code += "{\n"
code += "@public\n"
code += " " + class_name + "* m_internal;\n"
code += "}\n"
code += "@end\n\n"
code += "@implementation " + objc_class_name + "\n"
code += "EMBED_OBJECT_WRAPPER_METHODS(" + class_name + ");\n"
code += "\n"
for method_list in method_lists:
if method_list.ifdef:
code += "#ifdef " + method_list.ifdef + "\n"
for method in method_list.methods:
code += "FUNCTION_WRAPPER_JS_" + str(len(method.args)) + "(" + method.name + ", " + method.name + ")\n"
if method_list.ifdef:
code += "#endif\n"
code += "@end\n"
code += "\n"
adapter_name = class_name + "Adapter"
code += "class " + adapter_name + " : public CJSEmbedObjectAdapterJSC\n"
code += "{\n"
code += "public:\n"
code += " virtual id getExportedObject(CJSEmbedObject* pNative) override\n"
code += " {\n"
code += " return [[" + objc_class_name + " alloc] init:(" + class_name + "*)pNative];\n"
code += " }\n"
code += "};\n"
code += "\n"
code += "CJSEmbedObjectAdapterBase* " + class_name + "::getAdapter()\n"
code += "{\n"
code += " if (m_pAdapter == nullptr)\n"
code += " m_pAdapter = new " + adapter_name + "();\n"
code += " return m_pAdapter;\n"
code += "}\n\n"
return code
def generateV8ExternalCode(class_name, method_lists, header_file):
code = "// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!\n"
code += "// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT.\n\n"
code += "#include \"../" + header_file + "\"\n"
code += "#include \"js_embed.h\"\n\n"
adapter_name = class_name + "Adapter"
code += "class " + adapter_name + " : public CJSEmbedObjectAdapterV8\n"
code += "{\n"
code += "public:\n"
code += " virtual std::vector<std::string> getMethodNames() override\n"
code += " {\n"
code += " return std::vector<std::string> {\n"
for method_list in method_lists:
if method_list.ifdef:
code += "#ifdef " + method_list.ifdef + "\n"
for method in method_list.methods:
code += " \"" + method.name + "\",\n"
if method_list.ifdef:
code += "#endif\n"
code += " };\n"
code += " }\n"
code += "\n"
code += " virtual void initFunctions(CJSEmbedObject* pNativeObjBase) override\n"
code += " {\n"
code += " " + class_name + "* pNativeObj = static_cast<" + class_name + "*>(pNativeObjBase);\n"
code += " m_functions = std::vector<EmbedFunctionType> {\n"
for method_list in method_lists:
if method_list.ifdef:
code += "#ifdef " + method_list.ifdef + "\n"
for method in method_list.methods:
code += " [pNativeObj](CJSFunctionArguments* args) { return pNativeObj->" + method.name + "("
for i in range(len(method.args)):
code += "args->Get(" + str(i) + ")"
if i != len(method.args) - 1:
code += ", "
code += "); },\n"
if method_list.ifdef:
code += "#endif\n"
code += " };\n"
code += " }\n"
code += "};\n"
code += "\n"
code += "CJSEmbedObjectAdapterBase* " + class_name + "::getAdapter()\n"
code += "{\n"
code += " if (m_pAdapter == nullptr)\n"
code += " m_pAdapter = new " + adapter_name + "();\n"
code += " return m_pAdapter;\n"
code += "}\n\n"
return code
def generateJSCExternalCode(class_name, method_lists, header_file):
code = "// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!\n"
code += "// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT.\n\n"
code += "#include \"../" + header_file + "\"\n"
code += "#import \"js_embed.h\"\n\n"
objc_protocol_name = "IJS" + class_name
code += "@protocol " + objc_protocol_name + " <JSExport>\n"
for method_list in method_lists:
if method_list.ifdef:
code += "#ifdef " + method_list.ifdef + "\n"
for method in method_list.methods:
code += "-(JSValue*) " + method.name
for arg in method.args:
code += " : (JSValue*)" + arg
code += ";\n"
if method_list.ifdef:
code += "#endif\n"
code += "@end\n"
code += "\n"
objc_class_name = "CJS" + class_name
code += "@interface " + objc_class_name + " : NSObject<" + objc_protocol_name + ", JSEmbedObjectProtocol>\n"
code += "{\n"
code += "@public\n"
code += " " + class_name + "* m_internal;\n"
code += "}\n"
code += "@end\n"
code += "\n"
code += "@implementation " + objc_class_name + "\n"
code += "EMBED_OBJECT_WRAPPER_METHODS(" + class_name + ");\n"
code += "\n"
for method_list in method_lists:
if method_list.ifdef:
code += "#ifdef " + method_list.ifdef + "\n"
for method in method_list.methods:
code += "-(JSValue*) " + method.name
for arg in method.args:
code += " : (JSValue*)" + arg
code += "\n{\n"
code += " JSSmart<CJSValue> ret = m_internal->" + method.name + "("
for arg in method.args:
code += "CJSEmbedObjectAdapterJSC::Native2Value(" + arg + ")"
if arg != method.args[-1]:
code += ", "
code += ");\n"
code += " return CJSEmbedObjectAdapterJSC::Value2Native(ret);\n"
code += "}\n"
if method_list.ifdef:
code += "#endif\n\n"
code += "@end\n\n"
adapter_name = class_name + "Adapter"
code += "class " + adapter_name + " : public CJSEmbedObjectAdapterJSC\n"
code += "{\n"
code += "public:\n"
code += " virtual id getExportedObject(CJSEmbedObject* pNative) override\n"
code += " {\n"
code += " return [[" + objc_class_name + " alloc] init:(" + class_name + "*)pNative];\n"
code += " }\n"
code += "};\n"
code += "\n"
code += "CJSEmbedObjectAdapterBase* " + class_name + "::getAdapter()\n"
code += "{\n"
code += " if (m_pAdapter == nullptr)\n"
code += " m_pAdapter = new " + adapter_name + "();\n"
code += " return m_pAdapter;\n"
code += "}\n\n"
return code
def writeToFile(file_name, content):
with open(file_name, 'w') as file:
file.write(content)
print("\t" + file_name)
# MAIN
parser = argparse.ArgumentParser(description='Generate files for embedding your class into JS')
parser.add_argument('filename', help='the path to .h file with class you want to embed');
parser.add_argument('-i', '--internal', action='store_true', help='for internal library usage')
# if filename wasn't specified the programm will stop here
args = parser.parse_args()
header_file = args.filename;
if header_file[-2:] != ".h":
print("Argument must be a header file with \".h\" extension!")
sys.exit(1);
header_dir = os.path.dirname(header_file)
if len(header_dir) == 0:
header_dir = "."
header_base_name = os.path.basename(header_file)
header_base_name_no_extension = header_base_name[:-2]
class_name, method_lists = parseHeader(header_file)
if not class_name:
print("Proper class was not found in specified header file.")
sys.exit(1)
v8_dir = header_dir + "/v8"
jsc_dir = header_dir + "/jsc"
makeDir(v8_dir)
makeDir(jsc_dir)
code_common = generateCommonCode(class_name)
code_v8 = ""
code_jsc = ""
if args.internal:
code_v8 = generateV8InternalCode(class_name, method_lists, header_base_name)
code_jsc = generateJSCInternalCode(class_name, method_lists, header_base_name)
else:
code_v8 = generateV8ExternalCode(class_name, method_lists, header_base_name)
code_jsc = generateJSCExternalCode(class_name, method_lists, header_base_name)
print("Generated code was written to:")
writeToFile(v8_dir + "/v8_" + header_base_name_no_extension + ".cpp", code_v8 + code_common)
writeToFile(jsc_dir + "/jsc_" + header_base_name_no_extension + ".mm", code_jsc + code_common)

View File

@ -1,255 +0,0 @@
#include "../GraphicsEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCGraphics <JSExport>
-(JSValue*) create : (JSValue*)Native : (JSValue*)width_px : (JSValue*)height_px : (JSValue*)width_mm : (JSValue*)height_mm;
-(JSValue*) Destroy;
-(JSValue*) EndDraw;
-(JSValue*) put_GlobalAlpha : (JSValue*)enable : (JSValue*)globalAlpha;
-(JSValue*) Start_GlobalAlpha;
-(JSValue*) End_GlobalAlpha;
// pen methods
-(JSValue*) p_color : (JSValue*)r : (JSValue*)g : (JSValue*)b : (JSValue*)a;
-(JSValue*) p_width : (JSValue*)w;
-(JSValue*) p_dash : (JSValue*)params;
// brush methods
-(JSValue*) b_color1 : (JSValue*)r : (JSValue*)g : (JSValue*)b :(JSValue*)a;
-(JSValue*) b_color2 : (JSValue*)r : (JSValue*)g : (JSValue*)b :(JSValue*)a;
-(JSValue*) transform : (JSValue*)sx : (JSValue*)shy : (JSValue*)shx : (JSValue*)sy : (JSValue*)tx : (JSValue*)ty;
-(JSValue*) CalculateFullTransform : (JSValue*)isInvertNeed;
// path commands
-(JSValue*) _s;
-(JSValue*) _e;
-(JSValue*) _z;
-(JSValue*) _m : (JSValue*)x : (JSValue*)y;
-(JSValue*) _l : (JSValue*)x : (JSValue*)y;
-(JSValue*) _c : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)x2 : (JSValue*)y2 : (JSValue*)x3 : (JSValue*)y3;
-(JSValue*) _c2 : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)x2 : (JSValue*)y2;
-(JSValue*) ds;
-(JSValue*) df;
// canvas state
-(JSValue*)save;
-(JSValue*)restore;
-(JSValue*)clip;
-(JSValue*)reset;
-(JSValue*)FreeFont;
-(JSValue*)ClearLastFont;
// images
-(JSValue*)drawImage2 : (JSValue*)img : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h : (JSValue*)alpha : (JSValue*)srcRect;
-(JSValue*)drawImage : (JSValue*)img : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h : (JSValue*)alpha : (JSValue*)srcRect : (JSValue*)nativeImage;
// text
-(JSValue*)GetFont;
-(JSValue*)font : (JSValue*)font_id : (JSValue*)font_size;
-(JSValue*)SetFont : (JSValue*)path : (JSValue*)face : (JSValue*)size : (JSValue*)style;
-(JSValue*)GetTextPr;
-(JSValue*)FillText : (JSValue*)x : (JSValue*)y : (JSValue*)text;
-(JSValue*)t : (JSValue*)x : (JSValue*)y : (JSValue*)_arr;
-(JSValue*)FillText2 : (JSValue*)x : (JSValue*)y : (JSValue*)text : (JSValue*)cropX : (JSValue*)cropW;
-(JSValue*)t2 : (JSValue*)text : (JSValue*)x : (JSValue*)y : (JSValue*)cropX : (JSValue*)cropW;
-(JSValue*)FillTextCode : (JSValue*)x : (JSValue*)y : (JSValue*)lUnicode;
-(JSValue*)tg : (JSValue*)text : (JSValue*)x : (JSValue*)y;
-(JSValue*)charspace : (JSValue*)space;
// private methods
-(JSValue*)private_FillGlyph : (JSValue*)pGlyph : (JSValue*)_bounds;
-(JSValue*)private_FillGlyphC : (JSValue*)pGlyph : (JSValue*)cropX : (JSValue*)cropW;
-(JSValue*)private_FillGlyph2 : (JSValue*)pGlyph;
-(JSValue*)SetIntegerGrid : (JSValue*)param;
-(JSValue*)GetIntegerGrid;
-(JSValue*)DrawStringASCII : (JSValue*)text : (JSValue*)x : (JSValue*)y;
-(JSValue*)DrawStringASCII2 : (JSValue*)text : (JSValue*)x : (JSValue*)y;
-(JSValue*)DrawHeaderEdit : (JSValue*)yPos : (JSValue*)lock_type : (JSValue*)sectionNum : (JSValue*)bIsRepeat : (JSValue*)type;
-(JSValue*)DrawFooterEdit : (JSValue*)yPos : (JSValue*)lock_type : (JSValue*)sectionNum : (JSValue*)bIsRepeat : (JSValue*)type;
-(JSValue*)DrawLockParagraph : (JSValue*)x : (JSValue*)y1 : (JSValue*)y2;
-(JSValue*)DrawLockObjectRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*)DrawEmptyTableLine : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)x2 : (JSValue*)y2;
-(JSValue*)DrawSpellingLine : (JSValue*)y0 : (JSValue*)x0 : (JSValue*)x1 : (JSValue*)w;
// smart methods for horizontal / vertical lines
-(JSValue*)drawHorLine : (JSValue*)align : (JSValue*)y : (JSValue*)x : (JSValue*)r : (JSValue*)penW;
-(JSValue*)drawHorLine2 : (JSValue*)align : (JSValue*)y : (JSValue*)x : (JSValue*)r : (JSValue*)penW;
-(JSValue*)drawVerLine : (JSValue*)align : (JSValue*)x : (JSValue*)y : (JSValue*)b : (JSValue*)penW;
// мега крутые функции для таблиц
-(JSValue*)drawHorLineExt : (JSValue*)align : (JSValue*)y : (JSValue*)x : (JSValue*)r : (JSValue*)penW : (JSValue*)leftMW : (JSValue*)rightMW;
-(JSValue*)rect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*)TableRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
// функции клиппирования
-(JSValue*)AddClipRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*)RemoveClipRect;
-(JSValue*)SetClip : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*)RemoveClip;
-(JSValue*)drawMailMergeField : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*)drawSearchResult : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*)drawFlowAnchor : (JSValue*)x : (JSValue*)y;
-(JSValue*)SavePen;
-(JSValue*)RestorePen;
-(JSValue*)SaveBrush;
-(JSValue*)RestoreBrush;
-(JSValue*)SavePenBrush;
-(JSValue*)RestorePenBrush;
-(JSValue*)SaveGrState;
-(JSValue*)RestoreGrState;
-(JSValue*)StartClipPath;
-(JSValue*)EndClipPath;
-(JSValue*)StartCheckTableDraw;
-(JSValue*)SetTextClipRect : (JSValue*)_l : (JSValue*)_t : (JSValue*)_r : (JSValue*)_b;
-(JSValue*)AddSmartRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h : (JSValue*)pen_w;
-(JSValue*)CheckUseFonts2 : (JSValue*)_transform;
-(JSValue*)UncheckUseFonts2;
-(JSValue*)Drawing_StartCheckBounds : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*)Drawing_EndCheckBounds;
-(JSValue*)DrawPresentationComment : (JSValue*)type : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*)DrawPolygon : (JSValue*)oPath : (JSValue*)lineWidth : (JSValue*)shift;
-(JSValue*)DrawFootnoteRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
// new methods
-(JSValue*)toDataURL: (JSValue*)type;
-(JSValue*)GetPenColor;
-(JSValue*)GetBrushColor;
-(JSValue*)put_brushTexture : (JSValue*)src : (JSValue*)type;
-(JSValue*)put_brushTextureMode : (JSValue*)mode;
-(JSValue*)put_BrushTextureAlpha : (JSValue*)a;
-(JSValue*)put_BrushGradient : (JSValue*)colors : (JSValue*)n : (JSValue*)x0 : (JSValue*)y0 : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)r0 : (JSValue*)r1;
-(JSValue*)TransformPointX : (JSValue*)x : (JSValue*)y;
-(JSValue*)TransformPointY : (JSValue*)x : (JSValue*)y;
-(JSValue*)put_LineJoin : (JSValue*)join;
-(JSValue*)get_LineJoin;
-(JSValue*)put_TextureBounds : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*)GetlineWidth;
-(JSValue*)DrawPath : (JSValue*)path;
-(JSValue*)CoordTransformOffset : (JSValue*)tx : (JSValue*)ty;
-(JSValue*)GetTransform;
@end
@interface CJSCGraphics : NSObject<IJSCGraphics, JSEmbedObjectProtocol>
{
@public
CGraphicsEmbed* m_internal;
}
@end
@implementation CJSCGraphics
EMBED_OBJECT_WRAPPER_METHODS(CGraphicsEmbed)
FUNCTION_WRAPPER_JS_5(create, init)
FUNCTION_WRAPPER_JS(Destroy, Destroy)
FUNCTION_WRAPPER_JS(EndDraw, EndDraw)
FUNCTION_WRAPPER_JS_2(put_GlobalAlpha, put_GlobalAlpha)
FUNCTION_WRAPPER_JS(Start_GlobalAlpha, Start_GlobalAlpha)
FUNCTION_WRAPPER_JS(End_GlobalAlpha, End_GlobalAlpha)
// pen methods
FUNCTION_WRAPPER_JS_4(p_color, p_color)
FUNCTION_WRAPPER_JS_1(p_width, p_width)
FUNCTION_WRAPPER_JS_1(p_dash, p_dash)
// brush methods
FUNCTION_WRAPPER_JS_4(b_color1, b_color1)
FUNCTION_WRAPPER_JS_4(b_color2, b_color2)
FUNCTION_WRAPPER_JS_6(transform, transform)
FUNCTION_WRAPPER_JS_1(CalculateFullTransform, CalculateFullTransform)
// path commands
FUNCTION_WRAPPER_JS(_s, _s)
FUNCTION_WRAPPER_JS(_e, _e)
FUNCTION_WRAPPER_JS(_z, _z)
FUNCTION_WRAPPER_JS_2(_m, _m)
FUNCTION_WRAPPER_JS_2(_l, _l)
FUNCTION_WRAPPER_JS_6(_c, _c)
FUNCTION_WRAPPER_JS_4(_c2, _c2)
FUNCTION_WRAPPER_JS(ds, ds)
FUNCTION_WRAPPER_JS(df, df)
// canvas state
FUNCTION_WRAPPER_JS(save, save)
FUNCTION_WRAPPER_JS(restore, restore)
FUNCTION_WRAPPER_JS(clip, clip)
FUNCTION_WRAPPER_JS(reset, reset)
FUNCTION_WRAPPER_JS(FreeFont, FreeFont)
FUNCTION_WRAPPER_JS(ClearLastFont, ClearLastFont)
// images
FUNCTION_WRAPPER_JS_7(drawImage2, drawImage2)
FUNCTION_WRAPPER_JS_8(drawImage, drawImage)
// text
FUNCTION_WRAPPER_JS(GetFont, GetFont)
FUNCTION_WRAPPER_JS_2(font, font)
FUNCTION_WRAPPER_JS_4(SetFont, SetFont)
FUNCTION_WRAPPER_JS (GetTextPr, GetTextPr)
FUNCTION_WRAPPER_JS_3(FillText, FillText)
FUNCTION_WRAPPER_JS_3(t, t)
FUNCTION_WRAPPER_JS_5(FillText2, FillText2)
FUNCTION_WRAPPER_JS_5(t2, t2)
FUNCTION_WRAPPER_JS_3(FillTextCode, FillTextCode)
FUNCTION_WRAPPER_JS_3(tg, tg)
FUNCTION_WRAPPER_JS_1(charspace, charspace)
// private methods
FUNCTION_WRAPPER_JS_2(private_FillGlyph, private_FillGlyph)
FUNCTION_WRAPPER_JS_3(private_FillGlyphC, private_FillGlyphC)
FUNCTION_WRAPPER_JS_1(private_FillGlyph2, private_FillGlyph2)
FUNCTION_WRAPPER_JS_1(SetIntegerGrid, SetIntegerGrid)
FUNCTION_WRAPPER_JS (GetIntegerGrid, GetIntegerGrid)
FUNCTION_WRAPPER_JS_3(DrawStringASCII, DrawStringASCII)
FUNCTION_WRAPPER_JS_3(DrawStringASCII2, DrawStringASCII2)
FUNCTION_WRAPPER_JS_5(DrawHeaderEdit, DrawHeaderEdit)
FUNCTION_WRAPPER_JS_5(DrawFooterEdit, DrawFooterEdit)
FUNCTION_WRAPPER_JS_3(DrawLockParagraph, DrawLockParagraph)
FUNCTION_WRAPPER_JS_4(DrawLockObjectRect, DrawLockObjectRect)
FUNCTION_WRAPPER_JS_4(DrawEmptyTableLine, DrawEmptyTableLine)
FUNCTION_WRAPPER_JS_4(DrawSpellingLine, DrawSpellingLine)
// smart methods for horizontal / vertical lines
FUNCTION_WRAPPER_JS_5(drawHorLine, drawHorLine)
FUNCTION_WRAPPER_JS_5(drawHorLine2, drawHorLine2)
FUNCTION_WRAPPER_JS_5(drawVerLine, drawVerLine)
// мега крутые функции для таблиц
FUNCTION_WRAPPER_JS_7(drawHorLineExt, drawHorLineExt)
FUNCTION_WRAPPER_JS_4(rect, rect)
FUNCTION_WRAPPER_JS_4(TableRect, TableRect)
// функции клиппирования
FUNCTION_WRAPPER_JS_4(AddClipRect, AddClipRect)
FUNCTION_WRAPPER_JS (RemoveClipRect, RemoveClipRect)
FUNCTION_WRAPPER_JS_4(SetClip, SetClip)
FUNCTION_WRAPPER_JS(RemoveClip, RemoveClip)
FUNCTION_WRAPPER_JS_4(drawMailMergeField, drawMailMergeField)
FUNCTION_WRAPPER_JS_4(drawSearchResult, drawSearchResult)
FUNCTION_WRAPPER_JS_2(drawFlowAnchor, drawFlowAnchor)
FUNCTION_WRAPPER_JS(SavePen, SavePen)
FUNCTION_WRAPPER_JS(RestorePen, RestorePen)
FUNCTION_WRAPPER_JS(SaveBrush, SaveBrush)
FUNCTION_WRAPPER_JS(RestoreBrush, RestoreBrush)
FUNCTION_WRAPPER_JS(SavePenBrush, SavePenBrush)
FUNCTION_WRAPPER_JS(RestorePenBrush, RestorePenBrush)
FUNCTION_WRAPPER_JS(SaveGrState, SaveGrState)
FUNCTION_WRAPPER_JS(RestoreGrState, RestoreGrState)
FUNCTION_WRAPPER_JS(StartClipPath, StartClipPath)
FUNCTION_WRAPPER_JS(EndClipPath, EndClipPath)
FUNCTION_WRAPPER_JS(StartCheckTableDraw, StartCheckTableDraw)
FUNCTION_WRAPPER_JS_4(SetTextClipRect, SetTextClipRect)
FUNCTION_WRAPPER_JS_5(AddSmartRect, AddSmartRect)
FUNCTION_WRAPPER_JS_1(CheckUseFonts2, CheckUseFonts2)
FUNCTION_WRAPPER_JS(UncheckUseFonts2, UncheckUseFonts2)
FUNCTION_WRAPPER_JS_4(Drawing_StartCheckBounds, Drawing_StartCheckBounds)
FUNCTION_WRAPPER_JS(Drawing_EndCheckBounds, Drawing_EndCheckBounds)
FUNCTION_WRAPPER_JS_5(DrawPresentationComment, DrawPresentationComment)
FUNCTION_WRAPPER_JS_3(DrawPolygon, DrawPolygon)
FUNCTION_WRAPPER_JS_4(DrawFootnoteRect, DrawFootnoteRect)
// new methods
FUNCTION_WRAPPER_JS_1(toDataURL, toDataURL)
FUNCTION_WRAPPER_JS(GetPenColor, GetPenColor)
FUNCTION_WRAPPER_JS(GetBrushColor, GetBrushColor)
FUNCTION_WRAPPER_JS_2(put_brushTexture, put_brushTexture)
FUNCTION_WRAPPER_JS_1(put_brushTextureMode, put_brushTextureMode)
FUNCTION_WRAPPER_JS_1(put_BrushTextureAlpha, put_BrushTextureAlpha)
FUNCTION_WRAPPER_JS_8(put_BrushGradient, put_BrushGradient)
FUNCTION_WRAPPER_JS_2(TransformPointX, TransformPointX)
FUNCTION_WRAPPER_JS_2(TransformPointY, TransformPointY)
FUNCTION_WRAPPER_JS_1(put_LineJoin, put_LineJoin)
FUNCTION_WRAPPER_JS(get_LineJoin, get_LineJoin)
FUNCTION_WRAPPER_JS_4(put_TextureBounds, put_TextureBounds)
FUNCTION_WRAPPER_JS(GetlineWidth, GetlineWidth)
FUNCTION_WRAPPER_JS_1(DrawPath, DrawPath)
FUNCTION_WRAPPER_JS_2(CoordTransformOffset, CoordTransformOffset)
FUNCTION_WRAPPER_JS(GetTransform, GetTransform)
@end
void CGraphicsEmbed::CreateObjectInContext(const std::string &name, JSSmart<CJSContext> context)
{
context->m_internal->context[[NSString stringWithAString:name]] = ^(){
return [[CJSCGraphics alloc] init];
};
}

View File

@ -0,0 +1,249 @@
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
#include "../GraphicsEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCGraphicsEmbed <JSExport>
-(JSValue*) create : (JSValue*)Native : (JSValue*)width_px : (JSValue*)height_px : (JSValue*)width_mm : (JSValue*)height_mm;
-(JSValue*) Destroy;
-(JSValue*) EndDraw;
-(JSValue*) put_GlobalAlpha : (JSValue*)enable : (JSValue*)globalAlpha;
-(JSValue*) Start_GlobalAlpha;
-(JSValue*) End_GlobalAlpha;
-(JSValue*) p_color : (JSValue*)r : (JSValue*)g : (JSValue*)b : (JSValue*)a;
-(JSValue*) p_width : (JSValue*)w;
-(JSValue*) p_dash : (JSValue*)params;
-(JSValue*) b_color1 : (JSValue*)r : (JSValue*)g : (JSValue*)b : (JSValue*)a;
-(JSValue*) b_color2 : (JSValue*)r : (JSValue*)g : (JSValue*)b : (JSValue*)a;
-(JSValue*) transform : (JSValue*)sx : (JSValue*)shy : (JSValue*)shx : (JSValue*)sy : (JSValue*)tx : (JSValue*)ty;
-(JSValue*) CalculateFullTransform : (JSValue*)isInvertNeed;
-(JSValue*) _s;
-(JSValue*) _e;
-(JSValue*) _z;
-(JSValue*) _m : (JSValue*)x : (JSValue*)y;
-(JSValue*) _l : (JSValue*)x : (JSValue*)y;
-(JSValue*) _c : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)x2 : (JSValue*)y2 : (JSValue*)x3 : (JSValue*)y3;
-(JSValue*) _c2 : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)x2 : (JSValue*)y2;
-(JSValue*) ds;
-(JSValue*) df;
-(JSValue*) save;
-(JSValue*) restore;
-(JSValue*) clip;
-(JSValue*) reset;
-(JSValue*) FreeFont;
-(JSValue*) ClearLastFont;
-(JSValue*) drawImage2 : (JSValue*)img : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h : (JSValue*)alpha : (JSValue*)srcRect;
-(JSValue*) drawImage : (JSValue*)img : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h : (JSValue*)alpha : (JSValue*)srcRect : (JSValue*)nativeImage;
-(JSValue*) GetFont;
-(JSValue*) font : (JSValue*)font_id : (JSValue*)font_size;
-(JSValue*) SetFont : (JSValue*)path : (JSValue*)face : (JSValue*)size : (JSValue*)style;
-(JSValue*) GetTextPr;
-(JSValue*) FillText : (JSValue*)x : (JSValue*)y : (JSValue*)text;
-(JSValue*) t : (JSValue*)x : (JSValue*)y : (JSValue*)_arr;
-(JSValue*) FillText2 : (JSValue*)x : (JSValue*)y : (JSValue*)text : (JSValue*)cropX : (JSValue*)cropW;
-(JSValue*) t2 : (JSValue*)text : (JSValue*)x : (JSValue*)y : (JSValue*)cropX : (JSValue*)cropW;
-(JSValue*) FillTextCode : (JSValue*)x : (JSValue*)y : (JSValue*)lUnicode;
-(JSValue*) tg : (JSValue*)text : (JSValue*)x : (JSValue*)y;
-(JSValue*) charspace : (JSValue*)space;
-(JSValue*) private_FillGlyph : (JSValue*)pGlyph : (JSValue*)_bounds;
-(JSValue*) private_FillGlyphC : (JSValue*)pGlyph : (JSValue*)cropX : (JSValue*)cropW;
-(JSValue*) private_FillGlyph2 : (JSValue*)pGlyph;
-(JSValue*) SetIntegerGrid : (JSValue*)param;
-(JSValue*) GetIntegerGrid;
-(JSValue*) DrawStringASCII : (JSValue*)text : (JSValue*)x : (JSValue*)y;
-(JSValue*) DrawStringASCII2 : (JSValue*)text : (JSValue*)x : (JSValue*)y;
-(JSValue*) DrawHeaderEdit : (JSValue*)yPos : (JSValue*)lock_type : (JSValue*)sectionNum : (JSValue*)bIsRepeat : (JSValue*)type;
-(JSValue*) DrawFooterEdit : (JSValue*)yPos : (JSValue*)lock_type : (JSValue*)sectionNum : (JSValue*)bIsRepeat : (JSValue*)type;
-(JSValue*) DrawLockParagraph : (JSValue*)x : (JSValue*)y1 : (JSValue*)y2;
-(JSValue*) DrawLockObjectRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*) DrawEmptyTableLine : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)x2 : (JSValue*)y2;
-(JSValue*) DrawSpellingLine : (JSValue*)y0 : (JSValue*)x0 : (JSValue*)x1 : (JSValue*)w;
-(JSValue*) drawHorLine : (JSValue*)align : (JSValue*)y : (JSValue*)x : (JSValue*)r : (JSValue*)penW;
-(JSValue*) drawHorLine2 : (JSValue*)align : (JSValue*)y : (JSValue*)x : (JSValue*)r : (JSValue*)penW;
-(JSValue*) drawVerLine : (JSValue*)align : (JSValue*)x : (JSValue*)y : (JSValue*)b : (JSValue*)penW;
-(JSValue*) drawHorLineExt : (JSValue*)align : (JSValue*)y : (JSValue*)x : (JSValue*)r : (JSValue*)penW : (JSValue*)leftMW : (JSValue*)rightMW;
-(JSValue*) rect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*) TableRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*) AddClipRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*) RemoveClipRect;
-(JSValue*) SetClip : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*) RemoveClip;
-(JSValue*) drawMailMergeField : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*) drawSearchResult : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*) drawFlowAnchor : (JSValue*)x : (JSValue*)y;
-(JSValue*) SavePen;
-(JSValue*) RestorePen;
-(JSValue*) SaveBrush;
-(JSValue*) RestoreBrush;
-(JSValue*) SavePenBrush;
-(JSValue*) RestorePenBrush;
-(JSValue*) SaveGrState;
-(JSValue*) RestoreGrState;
-(JSValue*) StartClipPath;
-(JSValue*) EndClipPath;
-(JSValue*) StartCheckTableDraw;
-(JSValue*) SetTextClipRect : (JSValue*)_l : (JSValue*)_t : (JSValue*)_r : (JSValue*)_b;
-(JSValue*) AddSmartRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h : (JSValue*)pen_w;
-(JSValue*) CheckUseFonts2 : (JSValue*)_transform;
-(JSValue*) UncheckUseFonts2;
-(JSValue*) Drawing_StartCheckBounds : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*) Drawing_EndCheckBounds;
-(JSValue*) DrawPresentationComment : (JSValue*)type : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*) DrawPolygon : (JSValue*)oPath : (JSValue*)lineWidth : (JSValue*)shift;
-(JSValue*) DrawFootnoteRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*) toDataURL : (JSValue*)type;
-(JSValue*) GetPenColor;
-(JSValue*) GetBrushColor;
-(JSValue*) put_brushTexture : (JSValue*)src : (JSValue*)type;
-(JSValue*) put_brushTextureMode : (JSValue*)mode;
-(JSValue*) put_BrushTextureAlpha : (JSValue*)a;
-(JSValue*) put_BrushGradient : (JSValue*)colors : (JSValue*)n : (JSValue*)x0 : (JSValue*)y0 : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)r0 : (JSValue*)r1;
-(JSValue*) TransformPointX : (JSValue*)x : (JSValue*)y;
-(JSValue*) TransformPointY : (JSValue*)x : (JSValue*)y;
-(JSValue*) put_LineJoin : (JSValue*)join;
-(JSValue*) get_LineJoin;
-(JSValue*) put_TextureBounds : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h;
-(JSValue*) GetlineWidth;
-(JSValue*) DrawPath : (JSValue*)path;
-(JSValue*) CoordTransformOffset : (JSValue*)tx : (JSValue*)ty;
-(JSValue*) GetTransform;
@end
@interface CJSCGraphicsEmbed : NSObject<IJSCGraphicsEmbed, JSEmbedObjectProtocol>
{
@public
CGraphicsEmbed* m_internal;
}
@end
@implementation CJSCGraphicsEmbed
EMBED_OBJECT_WRAPPER_METHODS(CGraphicsEmbed);
FUNCTION_WRAPPER_JS_5(create, create)
FUNCTION_WRAPPER_JS_0(Destroy, Destroy)
FUNCTION_WRAPPER_JS_0(EndDraw, EndDraw)
FUNCTION_WRAPPER_JS_2(put_GlobalAlpha, put_GlobalAlpha)
FUNCTION_WRAPPER_JS_0(Start_GlobalAlpha, Start_GlobalAlpha)
FUNCTION_WRAPPER_JS_0(End_GlobalAlpha, End_GlobalAlpha)
FUNCTION_WRAPPER_JS_4(p_color, p_color)
FUNCTION_WRAPPER_JS_1(p_width, p_width)
FUNCTION_WRAPPER_JS_1(p_dash, p_dash)
FUNCTION_WRAPPER_JS_4(b_color1, b_color1)
FUNCTION_WRAPPER_JS_4(b_color2, b_color2)
FUNCTION_WRAPPER_JS_6(transform, transform)
FUNCTION_WRAPPER_JS_1(CalculateFullTransform, CalculateFullTransform)
FUNCTION_WRAPPER_JS_0(_s, _s)
FUNCTION_WRAPPER_JS_0(_e, _e)
FUNCTION_WRAPPER_JS_0(_z, _z)
FUNCTION_WRAPPER_JS_2(_m, _m)
FUNCTION_WRAPPER_JS_2(_l, _l)
FUNCTION_WRAPPER_JS_6(_c, _c)
FUNCTION_WRAPPER_JS_4(_c2, _c2)
FUNCTION_WRAPPER_JS_0(ds, ds)
FUNCTION_WRAPPER_JS_0(df, df)
FUNCTION_WRAPPER_JS_0(save, save)
FUNCTION_WRAPPER_JS_0(restore, restore)
FUNCTION_WRAPPER_JS_0(clip, clip)
FUNCTION_WRAPPER_JS_0(reset, reset)
FUNCTION_WRAPPER_JS_0(FreeFont, FreeFont)
FUNCTION_WRAPPER_JS_0(ClearLastFont, ClearLastFont)
FUNCTION_WRAPPER_JS_7(drawImage2, drawImage2)
FUNCTION_WRAPPER_JS_8(drawImage, drawImage)
FUNCTION_WRAPPER_JS_0(GetFont, GetFont)
FUNCTION_WRAPPER_JS_2(font, font)
FUNCTION_WRAPPER_JS_4(SetFont, SetFont)
FUNCTION_WRAPPER_JS_0(GetTextPr, GetTextPr)
FUNCTION_WRAPPER_JS_3(FillText, FillText)
FUNCTION_WRAPPER_JS_3(t, t)
FUNCTION_WRAPPER_JS_5(FillText2, FillText2)
FUNCTION_WRAPPER_JS_5(t2, t2)
FUNCTION_WRAPPER_JS_3(FillTextCode, FillTextCode)
FUNCTION_WRAPPER_JS_3(tg, tg)
FUNCTION_WRAPPER_JS_1(charspace, charspace)
FUNCTION_WRAPPER_JS_2(private_FillGlyph, private_FillGlyph)
FUNCTION_WRAPPER_JS_3(private_FillGlyphC, private_FillGlyphC)
FUNCTION_WRAPPER_JS_1(private_FillGlyph2, private_FillGlyph2)
FUNCTION_WRAPPER_JS_1(SetIntegerGrid, SetIntegerGrid)
FUNCTION_WRAPPER_JS_0(GetIntegerGrid, GetIntegerGrid)
FUNCTION_WRAPPER_JS_3(DrawStringASCII, DrawStringASCII)
FUNCTION_WRAPPER_JS_3(DrawStringASCII2, DrawStringASCII2)
FUNCTION_WRAPPER_JS_5(DrawHeaderEdit, DrawHeaderEdit)
FUNCTION_WRAPPER_JS_5(DrawFooterEdit, DrawFooterEdit)
FUNCTION_WRAPPER_JS_3(DrawLockParagraph, DrawLockParagraph)
FUNCTION_WRAPPER_JS_4(DrawLockObjectRect, DrawLockObjectRect)
FUNCTION_WRAPPER_JS_4(DrawEmptyTableLine, DrawEmptyTableLine)
FUNCTION_WRAPPER_JS_4(DrawSpellingLine, DrawSpellingLine)
FUNCTION_WRAPPER_JS_5(drawHorLine, drawHorLine)
FUNCTION_WRAPPER_JS_5(drawHorLine2, drawHorLine2)
FUNCTION_WRAPPER_JS_5(drawVerLine, drawVerLine)
FUNCTION_WRAPPER_JS_7(drawHorLineExt, drawHorLineExt)
FUNCTION_WRAPPER_JS_4(rect, rect)
FUNCTION_WRAPPER_JS_4(TableRect, TableRect)
FUNCTION_WRAPPER_JS_4(AddClipRect, AddClipRect)
FUNCTION_WRAPPER_JS_0(RemoveClipRect, RemoveClipRect)
FUNCTION_WRAPPER_JS_4(SetClip, SetClip)
FUNCTION_WRAPPER_JS_0(RemoveClip, RemoveClip)
FUNCTION_WRAPPER_JS_4(drawMailMergeField, drawMailMergeField)
FUNCTION_WRAPPER_JS_4(drawSearchResult, drawSearchResult)
FUNCTION_WRAPPER_JS_2(drawFlowAnchor, drawFlowAnchor)
FUNCTION_WRAPPER_JS_0(SavePen, SavePen)
FUNCTION_WRAPPER_JS_0(RestorePen, RestorePen)
FUNCTION_WRAPPER_JS_0(SaveBrush, SaveBrush)
FUNCTION_WRAPPER_JS_0(RestoreBrush, RestoreBrush)
FUNCTION_WRAPPER_JS_0(SavePenBrush, SavePenBrush)
FUNCTION_WRAPPER_JS_0(RestorePenBrush, RestorePenBrush)
FUNCTION_WRAPPER_JS_0(SaveGrState, SaveGrState)
FUNCTION_WRAPPER_JS_0(RestoreGrState, RestoreGrState)
FUNCTION_WRAPPER_JS_0(StartClipPath, StartClipPath)
FUNCTION_WRAPPER_JS_0(EndClipPath, EndClipPath)
FUNCTION_WRAPPER_JS_0(StartCheckTableDraw, StartCheckTableDraw)
FUNCTION_WRAPPER_JS_4(SetTextClipRect, SetTextClipRect)
FUNCTION_WRAPPER_JS_5(AddSmartRect, AddSmartRect)
FUNCTION_WRAPPER_JS_1(CheckUseFonts2, CheckUseFonts2)
FUNCTION_WRAPPER_JS_0(UncheckUseFonts2, UncheckUseFonts2)
FUNCTION_WRAPPER_JS_4(Drawing_StartCheckBounds, Drawing_StartCheckBounds)
FUNCTION_WRAPPER_JS_0(Drawing_EndCheckBounds, Drawing_EndCheckBounds)
FUNCTION_WRAPPER_JS_5(DrawPresentationComment, DrawPresentationComment)
FUNCTION_WRAPPER_JS_3(DrawPolygon, DrawPolygon)
FUNCTION_WRAPPER_JS_4(DrawFootnoteRect, DrawFootnoteRect)
FUNCTION_WRAPPER_JS_1(toDataURL, toDataURL)
FUNCTION_WRAPPER_JS_0(GetPenColor, GetPenColor)
FUNCTION_WRAPPER_JS_0(GetBrushColor, GetBrushColor)
FUNCTION_WRAPPER_JS_2(put_brushTexture, put_brushTexture)
FUNCTION_WRAPPER_JS_1(put_brushTextureMode, put_brushTextureMode)
FUNCTION_WRAPPER_JS_1(put_BrushTextureAlpha, put_BrushTextureAlpha)
FUNCTION_WRAPPER_JS_8(put_BrushGradient, put_BrushGradient)
FUNCTION_WRAPPER_JS_2(TransformPointX, TransformPointX)
FUNCTION_WRAPPER_JS_2(TransformPointY, TransformPointY)
FUNCTION_WRAPPER_JS_1(put_LineJoin, put_LineJoin)
FUNCTION_WRAPPER_JS_0(get_LineJoin, get_LineJoin)
FUNCTION_WRAPPER_JS_4(put_TextureBounds, put_TextureBounds)
FUNCTION_WRAPPER_JS_0(GetlineWidth, GetlineWidth)
FUNCTION_WRAPPER_JS_1(DrawPath, DrawPath)
FUNCTION_WRAPPER_JS_2(CoordTransformOffset, CoordTransformOffset)
FUNCTION_WRAPPER_JS_0(GetTransform, GetTransform)
@end
class CGraphicsEmbedAdapter : public CJSEmbedObjectAdapterJSC
{
public:
virtual id getExportedObject(CJSEmbedObject* pNative) override
{
return [[CJSCGraphicsEmbed alloc] init:(CGraphicsEmbed*)pNative];
}
};
CJSEmbedObjectAdapterBase* CGraphicsEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CGraphicsEmbedAdapter();
return m_pAdapter;
}
std::string CGraphicsEmbed::getName() { return "CGraphicsEmbed"; }
CJSEmbedObject* CGraphicsEmbed::getCreator()
{
return new CGraphicsEmbed();
}

View File

@ -1,31 +0,0 @@
#include "../HashEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCHash <JSExport>
-(JSValue*) hash : (JSValue*)data : (JSValue*)size : (JSValue*)alg;
-(JSValue*) hash2 : (JSValue*)password : (JSValue*)salt : (JSValue*)spinCount : (JSValue*)alg;
@end
@interface CJSCHash : NSObject<IJSCHash, JSEmbedObjectProtocol>
{
@public
CHashEmbed* m_internal;
}
@end
@implementation CJSCHash
EMBED_OBJECT_WRAPPER_METHODS(CHashEmbed)
FUNCTION_WRAPPER_JS_3(hash, hash)
FUNCTION_WRAPPER_JS_4(hash2, hash2)
@end
void CHashEmbed::CreateObjectInContext(const std::string &name, JSSmart<CJSContext> context)
{
context->m_internal->context[[NSString stringWithAString:name]] = ^(){
return [[CJSCHash alloc] init];
};
}

View File

@ -0,0 +1,47 @@
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
#include "../HashEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCHashEmbed <JSExport>
-(JSValue*) hash : (JSValue*)data : (JSValue*)size : (JSValue*)alg;
-(JSValue*) hash2 : (JSValue*)password : (JSValue*)salt : (JSValue*)spinCount : (JSValue*)alg;
@end
@interface CJSCHashEmbed : NSObject<IJSCHashEmbed, JSEmbedObjectProtocol>
{
@public
CHashEmbed* m_internal;
}
@end
@implementation CJSCHashEmbed
EMBED_OBJECT_WRAPPER_METHODS(CHashEmbed);
FUNCTION_WRAPPER_JS_3(hash, hash)
FUNCTION_WRAPPER_JS_4(hash2, hash2)
@end
class CHashEmbedAdapter : public CJSEmbedObjectAdapterJSC
{
public:
virtual id getExportedObject(CJSEmbedObject* pNative) override
{
return [[CJSCHashEmbed alloc] init:(CHashEmbed*)pNative];
}
};
CJSEmbedObjectAdapterBase* CHashEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CHashEmbedAdapter();
return m_pAdapter;
}
std::string CHashEmbed::getName() { return "CHashEmbed"; }
CJSEmbedObject* CHashEmbed::getCreator()
{
return new CHashEmbed();
}

View File

@ -1,46 +0,0 @@
#include "../MemoryStreamEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCMemoryStream <JSExport>
-(JSValue*) Copy : (JSValue*)value : (JSValue*)pos : (JSValue*)len;
-(JSValue*) ClearNoAttack;
-(JSValue*) WriteByte : (JSValue*)value;
-(JSValue*) WriteBool : (JSValue*)value;
-(JSValue*) WriteLong : (JSValue*)value;
-(JSValue*) WriteDouble : (JSValue*)value;
-(JSValue*) WriteDouble2 : (JSValue*)value;
-(JSValue*) WriteStringA : (JSValue*)value;
-(JSValue*) WriteString : (JSValue*)value;
-(JSValue*) WriteString2 : (JSValue*)value;
@end
@interface CJSCMemoryStream : NSObject<IJSCMemoryStream, JSEmbedObjectProtocol>
{
@public
CMemoryStreamEmbed* m_internal;
}
@end
@implementation CJSCMemoryStream
EMBED_OBJECT_WRAPPER_METHODS(CMemoryStreamEmbed)
FUNCTION_WRAPPER_JS_3(Copy, Copy)
FUNCTION_WRAPPER_JS(ClearNoAttack, ClearNoAttack)
FUNCTION_WRAPPER_JS_1(WriteByte, WriteByte)
FUNCTION_WRAPPER_JS_1(WriteBool, WriteBool)
FUNCTION_WRAPPER_JS_1(WriteLong, WriteLong)
FUNCTION_WRAPPER_JS_1(WriteDouble, WriteDouble)
FUNCTION_WRAPPER_JS_1(WriteDouble2, WriteDouble2)
FUNCTION_WRAPPER_JS_1(WriteStringA, WriteStringA)
FUNCTION_WRAPPER_JS_1(WriteString, WriteString)
FUNCTION_WRAPPER_JS_1(WriteString2, WriteString2)
@end
void CMemoryStreamEmbed::CreateObjectInContext(const std::string &name, JSSmart<CJSContext> context)
{
context->m_internal->context[[NSString stringWithAString:name]] = ^(){
return [[CJSCMemoryStream alloc] init];
};
}

View File

@ -0,0 +1,63 @@
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
#include "../MemoryStreamEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCMemoryStreamEmbed <JSExport>
-(JSValue*) Copy : (JSValue*)stream : (JSValue*)pos : (JSValue*)len;
-(JSValue*) ClearNoAttack;
-(JSValue*) WriteByte : (JSValue*)value;
-(JSValue*) WriteBool : (JSValue*)value;
-(JSValue*) WriteLong : (JSValue*)value;
-(JSValue*) WriteDouble : (JSValue*)value;
-(JSValue*) WriteDouble2 : (JSValue*)value;
-(JSValue*) WriteStringA : (JSValue*)value;
-(JSValue*) WriteString : (JSValue*)value;
-(JSValue*) WriteString2 : (JSValue*)value;
@end
@interface CJSCMemoryStreamEmbed : NSObject<IJSCMemoryStreamEmbed, JSEmbedObjectProtocol>
{
@public
CMemoryStreamEmbed* m_internal;
}
@end
@implementation CJSCMemoryStreamEmbed
EMBED_OBJECT_WRAPPER_METHODS(CMemoryStreamEmbed);
FUNCTION_WRAPPER_JS_3(Copy, Copy)
FUNCTION_WRAPPER_JS_0(ClearNoAttack, ClearNoAttack)
FUNCTION_WRAPPER_JS_1(WriteByte, WriteByte)
FUNCTION_WRAPPER_JS_1(WriteBool, WriteBool)
FUNCTION_WRAPPER_JS_1(WriteLong, WriteLong)
FUNCTION_WRAPPER_JS_1(WriteDouble, WriteDouble)
FUNCTION_WRAPPER_JS_1(WriteDouble2, WriteDouble2)
FUNCTION_WRAPPER_JS_1(WriteStringA, WriteStringA)
FUNCTION_WRAPPER_JS_1(WriteString, WriteString)
FUNCTION_WRAPPER_JS_1(WriteString2, WriteString2)
@end
class CMemoryStreamEmbedAdapter : public CJSEmbedObjectAdapterJSC
{
public:
virtual id getExportedObject(CJSEmbedObject* pNative) override
{
return [[CJSCMemoryStreamEmbed alloc] init:(CMemoryStreamEmbed*)pNative];
}
};
CJSEmbedObjectAdapterBase* CMemoryStreamEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CMemoryStreamEmbedAdapter();
return m_pAdapter;
}
std::string CMemoryStreamEmbed::getName() { return "CMemoryStreamEmbed"; }
CJSEmbedObject* CMemoryStreamEmbed::getCreator()
{
return new CMemoryStreamEmbed();
}

View File

@ -1,111 +0,0 @@
/*
* (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 "../NativeBuilderEmbed.h"
#include "../../docbuilder_p.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCBuilderDocumentEmbed <JSExport>
-(JSValue*) IsValid;
-(JSValue*) GetBinary;
-(JSValue*) GetFolder;
-(JSValue*) CloseFile;
-(JSValue*) GetImageMap;
@end
@interface CJSCBuilderDocumentEmbed : NSObject<IJSCBuilderDocumentEmbed, JSEmbedObjectProtocol>
{
@public
CBuilderDocumentEmbed* m_internal;
}
@end
@implementation CJSCBuilderDocumentEmbed
EMBED_OBJECT_WRAPPER_METHODS(CBuilderDocumentEmbed)
FUNCTION_WRAPPER_JS(IsValid, builder_doc_IsValid)
FUNCTION_WRAPPER_JS(GetBinary, builder_doc_GetBinary)
FUNCTION_WRAPPER_JS(GetFolder, builder_doc_GetFolder)
FUNCTION_WRAPPER_JS(CloseFile, builder_doc_CloseFile)
FUNCTION_WRAPPER_JS(GetImageMap, builder_doc_GetImageMap)
@end
@protocol IJSCNativeBuilder <JSExport>
-(JSValue*) OpenFile : (JSValue*)sPath : (JSValue*)sParams;
-(JSValue*) CreateFile : (JSValue*)type;
-(JSValue*) SetTmpFolder : (JSValue*)path;
-(JSValue*) SaveFile : (JSValue*)t : (JSValue*)path : (JSValue*)params;
-(JSValue*) CloseFile;
-(JSValue*) OpenTmpFile : (JSValue*)path : (JSValue*)params;
@end
@interface CJSCNativeBuilder : NSObject<IJSCNativeBuilder, JSEmbedObjectProtocol>
{
@public
CBuilderEmbed* m_internal;
}
@end
@implementation CJSCNativeBuilder
EMBED_OBJECT_WRAPPER_METHODS(CBuilderEmbed)
FUNCTION_WRAPPER_JS_2(OpenFile, builder_OpenFile)
FUNCTION_WRAPPER_JS_1(CreateFile, builder_CreateFile)
FUNCTION_WRAPPER_JS_1(SetTmpFolder, builder_SetTmpFolder)
FUNCTION_WRAPPER_JS_3(SaveFile, builder_SaveFile)
FUNCTION_WRAPPER_JS(CloseFile, builder_CloseFile)
FUNCTION_WRAPPER_JS_2(OpenTmpFile, builder_OpenTmpFile)
@end
JSSmart<CJSValue> CBuilderEmbed::builder_OpenTmpFile(JSSmart<CJSValue> path, JSSmart<CJSValue> params)
{
std::wstring sPath = path->toStringW();
std::wstring sParams = params->toStringW();
CJSCBuilderDocumentEmbed* p = [[CJSCBuilderDocumentEmbed alloc] init];
p->m_internal->m_pBuilder = m_pBuilder;
p->m_internal->OpenFile(sPath, sParams);
CJSValueJSC* pRet = new CJSValueJSC();
pRet->value = [JSValue valueWithObject:(id)p inContext:NSJSBase::CJSContextPrivate::GetCurrentContext()];
return pRet;
}
void builder_CreateNative(const std::string& name, JSSmart<CJSContext> context, NSDoctRenderer::CDocBuilder* builder)
{
context->m_internal->context[[NSString stringWithAString:name]] = ^(){
CJSCNativeBuilder* p = [[CJSCNativeBuilder alloc] init];
p->m_internal->m_pBuilder = builder;
return p;
};
}

View File

@ -0,0 +1,53 @@
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
#include "../NativeBuilderDocumentEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCBuilderDocumentEmbed <JSExport>
-(JSValue*) IsValid;
-(JSValue*) GetBinary;
-(JSValue*) GetFolder;
-(JSValue*) Close;
-(JSValue*) GetImageMap;
@end
@interface CJSCBuilderDocumentEmbed : NSObject<IJSCBuilderDocumentEmbed, JSEmbedObjectProtocol>
{
@public
CBuilderDocumentEmbed* m_internal;
}
@end
@implementation CJSCBuilderDocumentEmbed
EMBED_OBJECT_WRAPPER_METHODS(CBuilderDocumentEmbed);
FUNCTION_WRAPPER_JS_0(IsValid, IsValid)
FUNCTION_WRAPPER_JS_0(GetBinary, GetBinary)
FUNCTION_WRAPPER_JS_0(GetFolder, GetFolder)
FUNCTION_WRAPPER_JS_0(Close, Close)
FUNCTION_WRAPPER_JS_0(GetImageMap, GetImageMap)
@end
class CBuilderDocumentEmbedAdapter : public CJSEmbedObjectAdapterJSC
{
public:
virtual id getExportedObject(CJSEmbedObject* pNative) override
{
return [[CJSCBuilderDocumentEmbed alloc] init:(CBuilderDocumentEmbed*)pNative];
}
};
CJSEmbedObjectAdapterBase* CBuilderDocumentEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CBuilderDocumentEmbedAdapter();
return m_pAdapter;
}
std::string CBuilderDocumentEmbed::getName() { return "CBuilderDocumentEmbed"; }
CJSEmbedObject* CBuilderDocumentEmbed::getCreator()
{
return new CBuilderDocumentEmbed();
}

View File

@ -0,0 +1,55 @@
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
#include "../NativeBuilderEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCBuilderEmbed <JSExport>
-(JSValue*) OpenFile : (JSValue*)sPath : (JSValue*)sParams;
-(JSValue*) CreateFile : (JSValue*)type;
-(JSValue*) SetTmpFolder : (JSValue*)path;
-(JSValue*) SaveFile : (JSValue*)type : (JSValue*)path : (JSValue*)params;
-(JSValue*) CloseFile;
-(JSValue*) OpenTmpFile : (JSValue*)path : (JSValue*)params;
@end
@interface CJSCBuilderEmbed : NSObject<IJSCBuilderEmbed, JSEmbedObjectProtocol>
{
@public
CBuilderEmbed* m_internal;
}
@end
@implementation CJSCBuilderEmbed
EMBED_OBJECT_WRAPPER_METHODS(CBuilderEmbed);
FUNCTION_WRAPPER_JS_2(OpenFile, OpenFile)
FUNCTION_WRAPPER_JS_1(CreateFile, CreateFile)
FUNCTION_WRAPPER_JS_1(SetTmpFolder, SetTmpFolder)
FUNCTION_WRAPPER_JS_3(SaveFile, SaveFile)
FUNCTION_WRAPPER_JS_0(CloseFile, CloseFile)
FUNCTION_WRAPPER_JS_2(OpenTmpFile, OpenTmpFile)
@end
class CBuilderEmbedAdapter : public CJSEmbedObjectAdapterJSC
{
public:
virtual id getExportedObject(CJSEmbedObject* pNative) override
{
return [[CJSCBuilderEmbed alloc] init:(CBuilderEmbed*)pNative];
}
};
CJSEmbedObjectAdapterBase* CBuilderEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CBuilderEmbedAdapter();
return m_pAdapter;
}
std::string CBuilderEmbed::getName() { return "CBuilderEmbed"; }
CJSEmbedObject* CBuilderEmbed::getCreator()
{
return new CBuilderEmbed();
}

View File

@ -1,85 +0,0 @@
#include "../NativeControlEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCNativeControl <JSExport>
-(JSValue*) GetFilePath;
-(JSValue*) SetFilePath : (JSValue*)path;
-(JSValue*) GetFileId;
-(JSValue*) SetFileId : (JSValue*)fileid;
-(JSValue*) GetFileBinary : (JSValue*)file;
-(JSValue*) GetFontBinary : (JSValue*)file;
-(JSValue*) GetFontsDirectory;
-(JSValue*) GetFileString : (JSValue*)file;
-(JSValue*) GetEditorType;
-(JSValue*) CheckNextChange;
-(JSValue*) GetCountChanges;
-(JSValue*) GetChangesFile : (JSValue*)index;
//-(JSValue*) Save_AllocNative : (JSValue*)len;
//-(JSValue*) Save_ReAllocNative : (JSValue*)pos : (JSValue*)len;
-(JSValue*) Save_End : (JSValue*)pos : (JSValue*)len;
-(JSValue*) AddImageInChanges : (JSValue*)img;
-(JSValue*) ConsoleLog : (JSValue*)message;
-(JSValue*) SaveChanges : (JSValue*)param : (JSValue*)delete_index : (JSValue*)count;
-(JSValue*) ZipOpen : (JSValue*)name;
-(JSValue*) ZipOpenBase64 : (JSValue*)name;
-(JSValue*) ZipFileAsString : (JSValue*)name;
-(JSValue*) ZipFileAsBinary : (JSValue*)name;
-(JSValue*) ZipClose;
-(JSValue*) GetImageUrl : (JSValue*)url;
-(JSValue*) GetImagesPath;
-(JSValue*) GetImageOriginalSize : (JSValue*)url;
@end
@interface CJSCNativeControl : NSObject<IJSCNativeControl, JSEmbedObjectProtocol>
{
@public
CNativeControlEmbed* m_internal;
}
@end
@implementation CJSCNativeControl
EMBED_OBJECT_WRAPPER_METHODS(CNativeControlEmbed)
FUNCTION_WRAPPER_JS(GetFilePath, GetFilePath)
FUNCTION_WRAPPER_JS_1(SetFilePath, SetFilePath)
FUNCTION_WRAPPER_JS(GetFileId, GetFileId)
FUNCTION_WRAPPER_JS_1(SetFileId, SetFileId)
FUNCTION_WRAPPER_JS_1(GetFileBinary, GetFileBinary)
FUNCTION_WRAPPER_JS_1(GetFontBinary, GetFontBinary);
FUNCTION_WRAPPER_JS(GetFontsDirectory, GetFontsDirectory)
FUNCTION_WRAPPER_JS_1(GetFileString, GetFileString)
FUNCTION_WRAPPER_JS(GetEditorType, GetEditorType)
FUNCTION_WRAPPER_JS(CheckNextChange, CheckNextChange)
FUNCTION_WRAPPER_JS(GetCountChanges, GetCountChanges)
FUNCTION_WRAPPER_JS_1(GetChangesFile, GetChangesFile)
//FUNCTION_WRAPPER_JS_1(Save_AllocNative, Save_AllocNative)
//FUNCTION_WRAPPER_JS_2(Save_ReAllocNative, Save_ReAllocNative)
FUNCTION_WRAPPER_JS_2(Save_End, Save_End)
FUNCTION_WRAPPER_JS_1(AddImageInChanges, AddImageInChanges)
FUNCTION_WRAPPER_JS_1(ConsoleLog, ConsoleLog)
FUNCTION_WRAPPER_JS_3(SaveChanges, SaveChanges)
FUNCTION_WRAPPER_JS_1(ZipOpen, zipOpenFile)
FUNCTION_WRAPPER_JS_1(ZipOpenBase64, zipOpenFileBase64)
FUNCTION_WRAPPER_JS_1(ZipFileAsString, zipGetFileAsString)
FUNCTION_WRAPPER_JS_1(ZipFileAsBinary, zipGetFileAsBinary)
FUNCTION_WRAPPER_JS(ZipClose, zipCloseFile);
FUNCTION_WRAPPER_JS_1(GetImageUrl, GetImageUrl);
FUNCTION_WRAPPER_JS(GetImagesPath, GetImagesPath)
FUNCTION_WRAPPER_JS_1(GetImageOriginalSize, GetImageOriginalSize);
@end
void CNativeControlEmbed::CreateObjectInContext(const std::string &name, JSSmart<CJSContext> context)
{
context->m_internal->context[[NSString stringWithAString:name]] = ^(){
return [[CJSCNativeControl alloc] init];
};
}
void CNativeControlEmbed::CreateObjectBuilderInContext(const std::string &name, JSSmart<CJSContext> context)
{
context->m_internal->context[[NSString stringWithAString:name]] = ^(){
return [[CJSCNativeControl alloc] init];
};
}

View File

@ -0,0 +1,89 @@
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
#include "../NativeControlEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCNativeControlEmbed <JSExport>
-(JSValue*) SetFilePath : (JSValue*)path;
-(JSValue*) GetFilePath;
-(JSValue*) SetFileId : (JSValue*)fileId;
-(JSValue*) GetFileId;
-(JSValue*) GetFileBinary : (JSValue*)file;
-(JSValue*) GetFontBinary : (JSValue*)file;
-(JSValue*) GetFontsDirectory;
-(JSValue*) GetFileString : (JSValue*)file;
-(JSValue*) GetEditorType;
-(JSValue*) CheckNextChange;
-(JSValue*) GetCountChanges;
-(JSValue*) GetChangesFile : (JSValue*)index;
-(JSValue*) Save_End : (JSValue*)pos : (JSValue*)len;
-(JSValue*) AddImageInChanges : (JSValue*)img;
-(JSValue*) ConsoleLog : (JSValue*)message;
-(JSValue*) ZipOpen : (JSValue*)name;
-(JSValue*) ZipOpenBase64 : (JSValue*)name;
-(JSValue*) ZipFileAsString : (JSValue*)name;
-(JSValue*) ZipFileAsBinary : (JSValue*)name;
-(JSValue*) ZipClose;
-(JSValue*) GetImageUrl : (JSValue*)sUrl;
-(JSValue*) GetImagesPath;
-(JSValue*) GetImageOriginalSize : (JSValue*)sUrl;
@end
@interface CJSCNativeControlEmbed : NSObject<IJSCNativeControlEmbed, JSEmbedObjectProtocol>
{
@public
CNativeControlEmbed* m_internal;
}
@end
@implementation CJSCNativeControlEmbed
EMBED_OBJECT_WRAPPER_METHODS(CNativeControlEmbed);
FUNCTION_WRAPPER_JS_1(SetFilePath, SetFilePath)
FUNCTION_WRAPPER_JS_0(GetFilePath, GetFilePath)
FUNCTION_WRAPPER_JS_1(SetFileId, SetFileId)
FUNCTION_WRAPPER_JS_0(GetFileId, GetFileId)
FUNCTION_WRAPPER_JS_1(GetFileBinary, GetFileBinary)
FUNCTION_WRAPPER_JS_1(GetFontBinary, GetFontBinary)
FUNCTION_WRAPPER_JS_0(GetFontsDirectory, GetFontsDirectory)
FUNCTION_WRAPPER_JS_1(GetFileString, GetFileString)
FUNCTION_WRAPPER_JS_0(GetEditorType, GetEditorType)
FUNCTION_WRAPPER_JS_0(CheckNextChange, CheckNextChange)
FUNCTION_WRAPPER_JS_0(GetCountChanges, GetCountChanges)
FUNCTION_WRAPPER_JS_1(GetChangesFile, GetChangesFile)
FUNCTION_WRAPPER_JS_2(Save_End, Save_End)
FUNCTION_WRAPPER_JS_1(AddImageInChanges, AddImageInChanges)
FUNCTION_WRAPPER_JS_1(ConsoleLog, ConsoleLog)
FUNCTION_WRAPPER_JS_1(ZipOpen, ZipOpen)
FUNCTION_WRAPPER_JS_1(ZipOpenBase64, ZipOpenBase64)
FUNCTION_WRAPPER_JS_1(ZipFileAsString, ZipFileAsString)
FUNCTION_WRAPPER_JS_1(ZipFileAsBinary, ZipFileAsBinary)
FUNCTION_WRAPPER_JS_0(ZipClose, ZipClose)
FUNCTION_WRAPPER_JS_1(GetImageUrl, GetImageUrl)
FUNCTION_WRAPPER_JS_0(GetImagesPath, GetImagesPath)
FUNCTION_WRAPPER_JS_1(GetImageOriginalSize, GetImageOriginalSize)
@end
class CNativeControlEmbedAdapter : public CJSEmbedObjectAdapterJSC
{
public:
virtual id getExportedObject(CJSEmbedObject* pNative) override
{
return [[CJSCNativeControlEmbed alloc] init:(CNativeControlEmbed*)pNative];
}
};
CJSEmbedObjectAdapterBase* CNativeControlEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CNativeControlEmbedAdapter();
return m_pAdapter;
}
std::string CNativeControlEmbed::getName() { return "CNativeControlEmbed"; }
CJSEmbedObject* CNativeControlEmbed::getCreator()
{
return new CNativeControlEmbed();
}

View File

@ -1,81 +1,87 @@
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
#include "../TextMeasurerEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCTextMeasurer <JSExport>
@protocol IJSCTextMeasurerEmbed <JSExport>
#ifdef SUPPORT_HARFBUZZ_SHAPER
-(JSValue*) HB_LanguageFromString : (JSValue*)language_bcp_47;
-(JSValue*) HB_ShapeText : (JSValue*)face : (JSValue*)font : (JSValue*)text : (JSValue*)nFeatures : (JSValue*)nScript : (JSValue*)nDirection : (JSValue*)nLanguage;
-(JSValue*) HB_FontMalloc;
-(JSValue*) HB_FontFree : (JSValue*)font;
#endif
-(JSValue*) FT_Malloc : (JSValue*)typed_array_or_len;
-(JSValue*) FT_Free : (JSValue*)pointer;
-(JSValue*) FT_Init;
-(JSValue*) FT_Set_TrueType_HintProp : (JSValue*)library : (JSValue*)tt_interpreter;
-(JSValue*) FT_Open_Face : (JSValue*)library : (JSValue*)memory : (JSValue*)size : (JSValue*)face_index;
-(JSValue*) FT_Open_Face2 : (JSValue*)library : (JSValue*)array : (JSValue*)face_index;
-(JSValue*) FT_GetFaceInfo : (JSValue*)face;
-(JSValue*) FT_Load_Glyph : (JSValue*)face : (JSValue*)gid : (JSValue*)mode;
-(JSValue*) FT_Get_Glyph_Measure_Params : (JSValue*)face : (JSValue*)is_vector;
-(JSValue*) FT_Get_Glyph_Render_Params : (JSValue*)face : (JSValue*)render_mode;
-(JSValue*) FT_Get_Glyph_Render_Buffer : (JSValue*)face : (JSValue*)size;
-(JSValue*) FT_Set_Transform : (JSValue*)face : (JSValue*)xx : (JSValue*)yx : (JSValue*)xy : (JSValue*)yy;
-(JSValue*) FT_Set_Char_Size : (JSValue*)face : (JSValue*)cw : (JSValue*)ch : (JSValue*)hres : (JSValue*)vres;
-(JSValue*) FT_Set_Char_Size : (JSValue*)face : (JSValue*)char_width : (JSValue*)char_height : (JSValue*)hres : (JSValue*)vres;
-(JSValue*) FT_SetCMapForCharCode : (JSValue*)face : (JSValue*)unicode;
-(JSValue*) FT_GetKerningX : (JSValue*)face : (JSValue*)gid1 : (JSValue*)gid2;
-(JSValue*) FT_GetFaceMaxAdvanceX : (JSValue*)face;
#ifdef SUPPORT_HARFBUZZ_SHAPER
-(JSValue*) HB_LanguageFromString : (JSValue*)lang;
-(JSValue*) HB_ShapeText : (JSValue*) face : (JSValue*) font : (JSValue*) text : (JSValue*) nFeatures : (JSValue*) nScript : (JSValue*) nDirection : (JSValue*) nLanguage;
-(JSValue*) HB_FontMalloc;
-(JSValue*) HB_FontFree : (JSValue*)font;
#endif
@end
@interface CJSCTextMeasurer : NSObject<IJSCTextMeasurer, JSEmbedObjectProtocol>
@interface CJSCTextMeasurerEmbed : NSObject<IJSCTextMeasurerEmbed, JSEmbedObjectProtocol>
{
@public
CTextMeasurerEmbed* m_internal;
CTextMeasurerEmbed* m_internal;
}
@end
@implementation CJSCTextMeasurer
EMBED_OBJECT_WRAPPER_METHODS(CTextMeasurerEmbed)
@implementation CJSCTextMeasurerEmbed
EMBED_OBJECT_WRAPPER_METHODS(CTextMeasurerEmbed);
#ifdef SUPPORT_HARFBUZZ_SHAPER
FUNCTION_WRAPPER_JS_1(HB_LanguageFromString, HB_LanguageFromString)
FUNCTION_WRAPPER_JS_7(HB_ShapeText, HB_ShapeText)
FUNCTION_WRAPPER_JS_0(HB_FontMalloc, HB_FontMalloc)
FUNCTION_WRAPPER_JS_1(HB_FontFree, HB_FontFree)
#endif
FUNCTION_WRAPPER_JS_1(FT_Malloc, FT_Malloc)
FUNCTION_WRAPPER_JS_1(FT_Free, FT_Free)
FUNCTION_WRAPPER_JS(FT_Init, FT_Init)
FUNCTION_WRAPPER_JS_0(FT_Init, FT_Init)
FUNCTION_WRAPPER_JS_2(FT_Set_TrueType_HintProp, FT_Set_TrueType_HintProp)
FUNCTION_WRAPPER_JS_4(FT_Open_Face, FT_Open_Face)
FUNCTION_WRAPPER_JS_3(FT_Open_Face2, FT_Open_Face2)
FUNCTION_WRAPPER_JS_1(FT_GetFaceInfo, FT_GetFaceInfo)
FUNCTION_WRAPPER_JS_3(FT_Load_Glyph, FT_Load_Glyph)
FUNCTION_WRAPPER_JS_2(FT_Get_Glyph_Measure_Params, FT_Get_Glyph_Measure_Params)
FUNCTION_WRAPPER_JS_2(FT_Get_Glyph_Render_Params, FT_Get_Glyph_Render_Params)
FUNCTION_WRAPPER_JS_2(FT_Get_Glyph_Render_Buffer, FT_Get_Glyph_Render_Buffer)
FUNCTION_WRAPPER_JS_5(FT_Set_Transform, FT_Set_Transform)
FUNCTION_WRAPPER_JS_5(FT_Set_Char_Size, FT_Set_Char_Size)
FUNCTION_WRAPPER_JS_2(FT_SetCMapForCharCode, FT_SetCMapForCharCode)
FUNCTION_WRAPPER_JS_3(FT_GetKerningX, FT_GetKerningX)
FUNCTION_WRAPPER_JS_1(FT_GetFaceMaxAdvanceX, FT_GetFaceMaxAdvanceX)
#ifdef SUPPORT_HARFBUZZ_SHAPER
FUNCTION_WRAPPER_JS_1(HB_LanguageFromString, HB_LanguageFromString)
FUNCTION_WRAPPER_JS_7(HB_ShapeText, HB_ShapeText)
FUNCTION_WRAPPER_JS(HB_FontMalloc, HB_FontMalloc)
FUNCTION_WRAPPER_JS_1(HB_FontFree, HB_FontFree)
#endif
@end
void CTextMeasurerEmbed::CreateObjectInContext(const std::string &name, JSSmart<CJSContext> context)
class CTextMeasurerEmbedAdapter : public CJSEmbedObjectAdapterJSC
{
context->m_internal->context[[NSString stringWithAString:name]] = ^(){
return [[CJSCTextMeasurer alloc] init];
};
public:
virtual id getExportedObject(CJSEmbedObject* pNative) override
{
return [[CJSCTextMeasurerEmbed alloc] init:(CTextMeasurerEmbed*)pNative];
}
};
CJSEmbedObjectAdapterBase* CTextMeasurerEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CTextMeasurerEmbedAdapter();
return m_pAdapter;
}
std::string CTextMeasurerEmbed::getName() { return "CTextMeasurerEmbed"; }
CJSEmbedObject* CTextMeasurerEmbed::getCreator()
{
return new CTextMeasurerEmbed();
}

View File

@ -1,53 +0,0 @@
#include "../ZipEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCZip <JSExport>
-(JSValue*) open : (JSValue*)file;
-(JSValue*) create;
-(JSValue*) save;
-(JSValue*) getFile : (JSValue*)path;
-(JSValue*) addFile : (JSValue*)path : (JSValue*)data;
-(JSValue*) removeFile : (JSValue*)path;
-(JSValue*) close;
-(JSValue*) getPaths;
-(JSValue*) decodeImage : (JSValue*)typedArray : (JSValue*)isRgba;
-(JSValue*) encodeImageData : (JSValue*)typedArray : (JSValue*)w : (JSValue*)h : (JSValue*)stride : (JSValue*)format : (JSValue*)isRgba;
-(JSValue*) encodeImage : (JSValue*)typedArray : (JSValue*)format;
-(JSValue*) getImageType : (JSValue*)typedArray;
@end
@interface CJSCZip : NSObject<IJSCZip, JSEmbedObjectProtocol>
{
@public
CZipEmbed* m_internal;
}
@end
@implementation CJSCZip
EMBED_OBJECT_WRAPPER_METHODS(CZipEmbed)
FUNCTION_WRAPPER_JS_1(open, open)
FUNCTION_WRAPPER_JS(create, create)
FUNCTION_WRAPPER_JS(save, save)
FUNCTION_WRAPPER_JS_1(getFile, getFile)
FUNCTION_WRAPPER_JS_2(addFile, addFile)
FUNCTION_WRAPPER_JS_1(removeFile, removeFile)
FUNCTION_WRAPPER_JS(close, close)
FUNCTION_WRAPPER_JS(getPaths, getPaths)
FUNCTION_WRAPPER_JS_2(decodeImage, decodeImage)
FUNCTION_WRAPPER_JS_6(encodeImageData, encodeImageData)
FUNCTION_WRAPPER_JS_2(encodeImage, encodeImage)
FUNCTION_WRAPPER_JS_1(getImageType, getImageType)
@end
void CZipEmbed::CreateObjectInContext(const std::string &name, JSSmart<CJSContext> context)
{
context->m_internal->context[[NSString stringWithAString:name]] = ^(){
return [[CJSCZip alloc] init];
};
}

View File

@ -0,0 +1,67 @@
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
#include "../ZipEmbed.h"
#include "../../js_internal/jsc/jsc_base.h"
@protocol IJSCZipEmbed <JSExport>
-(JSValue*) open : (JSValue*)typedArray_or_Folder;
-(JSValue*) create;
-(JSValue*) save;
-(JSValue*) getFile : (JSValue*)filePath;
-(JSValue*) addFile : (JSValue*)filePath : (JSValue*)typedArray;
-(JSValue*) removeFile : (JSValue*)filePath;
-(JSValue*) close;
-(JSValue*) getPaths;
-(JSValue*) decodeImage : (JSValue*)typedArray : (JSValue*)isRgba;
-(JSValue*) encodeImageData : (JSValue*)typedArray : (JSValue*)w : (JSValue*)h : (JSValue*)stride : (JSValue*)format : (JSValue*)isRgba;
-(JSValue*) encodeImage : (JSValue*)typedArray : (JSValue*)format;
-(JSValue*) getImageType : (JSValue*)typedArray;
@end
@interface CJSCZipEmbed : NSObject<IJSCZipEmbed, JSEmbedObjectProtocol>
{
@public
CZipEmbed* m_internal;
}
@end
@implementation CJSCZipEmbed
EMBED_OBJECT_WRAPPER_METHODS(CZipEmbed);
FUNCTION_WRAPPER_JS_1(open, open)
FUNCTION_WRAPPER_JS_0(create, create)
FUNCTION_WRAPPER_JS_0(save, save)
FUNCTION_WRAPPER_JS_1(getFile, getFile)
FUNCTION_WRAPPER_JS_2(addFile, addFile)
FUNCTION_WRAPPER_JS_1(removeFile, removeFile)
FUNCTION_WRAPPER_JS_0(close, close)
FUNCTION_WRAPPER_JS_0(getPaths, getPaths)
FUNCTION_WRAPPER_JS_2(decodeImage, decodeImage)
FUNCTION_WRAPPER_JS_6(encodeImageData, encodeImageData)
FUNCTION_WRAPPER_JS_2(encodeImage, encodeImage)
FUNCTION_WRAPPER_JS_1(getImageType, getImageType)
@end
class CZipEmbedAdapter : public CJSEmbedObjectAdapterJSC
{
public:
virtual id getExportedObject(CJSEmbedObject* pNative) override
{
return [[CJSCZipEmbed alloc] init:(CZipEmbed*)pNative];
}
};
CJSEmbedObjectAdapterBase* CZipEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CZipEmbedAdapter();
return m_pAdapter;
}
std::string CZipEmbed::getName() { return "CZipEmbed"; }
CJSEmbedObject* CZipEmbed::getCreator()
{
return new CZipEmbed();
}

View File

@ -1,250 +0,0 @@
#include "../GraphicsEmbed.h"
#include "../../js_internal/v8/v8_base.h"
namespace NSGraphics
{
#define CURRENTWRAPPER CGraphicsEmbed
// FUNCTION
FUNCTION_WRAPPER_V8_5(_init, init)
FUNCTION_WRAPPER_V8 (_destroy, Destroy)
FUNCTION_WRAPPER_V8 (_EndDraw, EndDraw)
FUNCTION_WRAPPER_V8_2(_put_GlobalAlpha, put_GlobalAlpha)
FUNCTION_WRAPPER_V8 (_Start_GlobalAlpha, Start_GlobalAlpha)
FUNCTION_WRAPPER_V8 (_End_GlobalAlpha, End_GlobalAlpha)
// pen methods
FUNCTION_WRAPPER_V8_4(_p_color, p_color)
FUNCTION_WRAPPER_V8_1(_p_width, p_width)
FUNCTION_WRAPPER_V8_1(_p_dash, p_dash)
// brush methods
FUNCTION_WRAPPER_V8_4(_b_color1, b_color1)
FUNCTION_WRAPPER_V8_4(_b_color2, b_color2)
FUNCTION_WRAPPER_V8_6(_transform, transform)
FUNCTION_WRAPPER_V8_1(_CalculateFullTransform, CalculateFullTransform)
// path commands
FUNCTION_WRAPPER_V8 (__s, _s)
FUNCTION_WRAPPER_V8 (__e, _e)
FUNCTION_WRAPPER_V8 (__z, _z)
FUNCTION_WRAPPER_V8_2(__m, _m)
FUNCTION_WRAPPER_V8_2(__l, _l)
FUNCTION_WRAPPER_V8_6(__c, _c)
FUNCTION_WRAPPER_V8_4(__c2, _c2)
FUNCTION_WRAPPER_V8 (_ds, ds)
FUNCTION_WRAPPER_V8 (_df, df)
// canvas state
FUNCTION_WRAPPER_V8 (_save, save)
FUNCTION_WRAPPER_V8 (_restore, restore)
FUNCTION_WRAPPER_V8 (_clip, clip)
FUNCTION_WRAPPER_V8 (_reset, reset)
FUNCTION_WRAPPER_V8 (_FreeFont, FreeFont)
FUNCTION_WRAPPER_V8 (_ClearLastFont, ClearLastFont)
// images
FUNCTION_WRAPPER_V8_7(_drawImage2, drawImage2)
FUNCTION_WRAPPER_V8_8(_drawImage, drawImage)
// text
FUNCTION_WRAPPER_V8 (_GetFont, GetFont)
FUNCTION_WRAPPER_V8_2(_font, font)
FUNCTION_WRAPPER_V8_4(_SetFont, SetFont)
FUNCTION_WRAPPER_V8 (_GetTextPr, GetTextPr)
FUNCTION_WRAPPER_V8_3(_FillText, FillText)
FUNCTION_WRAPPER_V8_3(_t, t)
FUNCTION_WRAPPER_V8_5(_FillText2, FillText2)
FUNCTION_WRAPPER_V8_5(_t2, t2)
FUNCTION_WRAPPER_V8_3(_FillTextCode, FillTextCode)
FUNCTION_WRAPPER_V8_3(_tg, tg)
FUNCTION_WRAPPER_V8_1(_charspace, charspace)
// private methods
FUNCTION_WRAPPER_V8_2(_private_FillGlyph, private_FillGlyph)
FUNCTION_WRAPPER_V8_3(_private_FillGlyphC, private_FillGlyphC)
FUNCTION_WRAPPER_V8_1(_private_FillGlyph2, private_FillGlyph2)
FUNCTION_WRAPPER_V8_1(_SetIntegerGrid, SetIntegerGrid)
FUNCTION_WRAPPER_V8 (_GetIntegerGrid, GetIntegerGrid)
FUNCTION_WRAPPER_V8_3(_DrawStringASCII, DrawStringASCII)
FUNCTION_WRAPPER_V8_3(_DrawStringASCII2, DrawStringASCII2)
FUNCTION_WRAPPER_V8_5(_DrawHeaderEdit, DrawHeaderEdit)
FUNCTION_WRAPPER_V8_5(_DrawFooterEdit, DrawFooterEdit)
FUNCTION_WRAPPER_V8_3(_DrawLockParagraph, DrawLockParagraph)
FUNCTION_WRAPPER_V8_4(_DrawLockObjectRect, DrawLockObjectRect)
FUNCTION_WRAPPER_V8_4(_DrawEmptyTableLine, DrawEmptyTableLine)
FUNCTION_WRAPPER_V8_4(_DrawSpellingLine, DrawSpellingLine)
// smart methods for horizontal / vertical lines
FUNCTION_WRAPPER_V8_5(_drawHorLine, drawHorLine)
FUNCTION_WRAPPER_V8_5(_drawHorLine2, drawHorLine2)
FUNCTION_WRAPPER_V8_5(_drawVerLine, drawVerLine)
// мега крутые функции для таблиц
FUNCTION_WRAPPER_V8_7(_drawHorLineExt, drawHorLineExt)
FUNCTION_WRAPPER_V8_4(_rect, rect)
FUNCTION_WRAPPER_V8_4(_TableRect, TableRect)
// функции клиппирования
FUNCTION_WRAPPER_V8_4(_AddClipRect, AddClipRect)
FUNCTION_WRAPPER_V8 (_RemoveClipRect, RemoveClipRect)
FUNCTION_WRAPPER_V8_4(_SetClip, SetClip)
FUNCTION_WRAPPER_V8 (_RemoveClip, RemoveClip)
FUNCTION_WRAPPER_V8_4(_drawMailMergeField, drawMailMergeField)
FUNCTION_WRAPPER_V8_4(_drawSearchResult, drawSearchResult)
FUNCTION_WRAPPER_V8_2(_drawFlowAnchor, drawFlowAnchor)
FUNCTION_WRAPPER_V8 (_SavePen, SavePen)
FUNCTION_WRAPPER_V8 (_RestorePen, RestorePen)
FUNCTION_WRAPPER_V8 (_SaveBrush, SaveBrush)
FUNCTION_WRAPPER_V8 (_RestoreBrush, RestoreBrush)
FUNCTION_WRAPPER_V8 (_SavePenBrush, SavePenBrush)
FUNCTION_WRAPPER_V8 (_RestorePenBrush, RestorePenBrush)
FUNCTION_WRAPPER_V8 (_SaveGrState, SaveGrState)
FUNCTION_WRAPPER_V8 (_RestoreGrState, RestoreGrState)
FUNCTION_WRAPPER_V8 (_StartClipPath, StartClipPath)
FUNCTION_WRAPPER_V8 (_EndClipPath, EndClipPath)
FUNCTION_WRAPPER_V8 (_StartCheckTableDraw, StartCheckTableDraw)
FUNCTION_WRAPPER_V8_4(_SetTextClipRect, SetTextClipRect)
FUNCTION_WRAPPER_V8_5(_AddSmartRect, AddSmartRect)
FUNCTION_WRAPPER_V8_1(_CheckUseFonts2, CheckUseFonts2)
FUNCTION_WRAPPER_V8 (_UncheckUseFonts2, UncheckUseFonts2)
FUNCTION_WRAPPER_V8_4(_Drawing_StartCheckBounds, Drawing_StartCheckBounds)
FUNCTION_WRAPPER_V8 (_Drawing_EndCheckBounds, Drawing_EndCheckBounds)
FUNCTION_WRAPPER_V8_5(_DrawPresentationComment, DrawPresentationComment)
FUNCTION_WRAPPER_V8_3(_DrawPolygon, DrawPolygon)
FUNCTION_WRAPPER_V8_4(_DrawFootnoteRect, DrawFootnoteRect)
// new methods
FUNCTION_WRAPPER_V8_1(_toDataURL, toDataURL)
FUNCTION_WRAPPER_V8 (_GetPenColor, GetPenColor)
FUNCTION_WRAPPER_V8 (_GetBrushColor, GetBrushColor)
FUNCTION_WRAPPER_V8_2(_put_brushTexture, put_brushTexture)
FUNCTION_WRAPPER_V8_1(_put_brushTextureMode, put_brushTextureMode)
FUNCTION_WRAPPER_V8_1(_put_BrushTextureAlpha, put_BrushTextureAlpha)
FUNCTION_WRAPPER_V8_8(_put_BrushGradient, put_BrushGradient)
FUNCTION_WRAPPER_V8_2(_TransformPointX, TransformPointX)
FUNCTION_WRAPPER_V8_2(_TransformPointY, TransformPointY)
FUNCTION_WRAPPER_V8_1(_put_LineJoin, put_LineJoin)
FUNCTION_WRAPPER_V8 (_get_LineJoin, get_LineJoin)
FUNCTION_WRAPPER_V8_4(_put_TextureBounds, put_TextureBounds)
FUNCTION_WRAPPER_V8 (_GetlineWidth, GetlineWidth)
FUNCTION_WRAPPER_V8_1(_DrawPath, DrawPath)
FUNCTION_WRAPPER_V8_2(_CoordTransformOffset, CoordTransformOffset)
FUNCTION_WRAPPER_V8 (_GetTransform, GetTransform)
v8::Handle<v8::ObjectTemplate> CreateGraphicsTemplate(v8::Isolate* isolate)
{
v8::EscapableHandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
result->SetInternalFieldCount(1);
v8::Isolate* current = v8::Isolate::GetCurrent();
// методы
NSV8Objects::Template_Set(result, "create", _init);
NSV8Objects::Template_Set(result, "Destroy", _destroy);
NSV8Objects::Template_Set(result, "EndDraw", _EndDraw);
NSV8Objects::Template_Set(result, "put_GlobalAlpha", _put_GlobalAlpha);
NSV8Objects::Template_Set(result, "Start_GlobalAlpha", _Start_GlobalAlpha);
NSV8Objects::Template_Set(result, "End_GlobalAlpha", _End_GlobalAlpha);
NSV8Objects::Template_Set(result, "p_color", _p_color);
NSV8Objects::Template_Set(result, "p_width", _p_width);
NSV8Objects::Template_Set(result, "p_dash", _p_dash);
NSV8Objects::Template_Set(result, "b_color1", _b_color1);
NSV8Objects::Template_Set(result, "b_color2", _b_color2);
NSV8Objects::Template_Set(result, "transform", _transform);
NSV8Objects::Template_Set(result, "CalculateFullTransform", _CalculateFullTransform);
NSV8Objects::Template_Set(result, "_s", __s);
NSV8Objects::Template_Set(result, "_e", __e);
NSV8Objects::Template_Set(result, "_z", __z);
NSV8Objects::Template_Set(result, "_m", __m);
NSV8Objects::Template_Set(result, "_l", __l);
NSV8Objects::Template_Set(result, "_c", __c);
NSV8Objects::Template_Set(result, "_c2", __c2);
NSV8Objects::Template_Set(result, "ds", _ds);
NSV8Objects::Template_Set(result, "df", _df);
NSV8Objects::Template_Set(result, "save", _save);
NSV8Objects::Template_Set(result, "restore", _restore);
NSV8Objects::Template_Set(result, "clip", _clip);
NSV8Objects::Template_Set(result, "reset", _reset);
NSV8Objects::Template_Set(result, "FreeFont", _FreeFont);
NSV8Objects::Template_Set(result, "ClearLastFont", _ClearLastFont);
NSV8Objects::Template_Set(result, "drawImage2", _drawImage2);
NSV8Objects::Template_Set(result, "drawImage", _drawImage);
NSV8Objects::Template_Set(result, "GetFont", _GetFont);
NSV8Objects::Template_Set(result, "font", _font);
NSV8Objects::Template_Set(result, "SetFont", _SetFont);
NSV8Objects::Template_Set(result, "GetTextPr", _GetTextPr);
NSV8Objects::Template_Set(result, "FillText", _FillText);
NSV8Objects::Template_Set(result, "t", _t);
NSV8Objects::Template_Set(result, "FillText2", _FillText2);
NSV8Objects::Template_Set(result, "t2", _t2);
NSV8Objects::Template_Set(result, "FillTextCode", _FillTextCode);
NSV8Objects::Template_Set(result, "tg", _tg);
NSV8Objects::Template_Set(result, "charspace", _charspace);
NSV8Objects::Template_Set(result, "private_FillGlyph", _private_FillGlyph);
NSV8Objects::Template_Set(result, "private_FillGlyphC", _private_FillGlyphC);
NSV8Objects::Template_Set(result, "private_FillGlyph2", _private_FillGlyph2);
NSV8Objects::Template_Set(result, "SetIntegerGrid", _SetIntegerGrid);
NSV8Objects::Template_Set(result, "GetIntegerGrid", _GetIntegerGrid);
NSV8Objects::Template_Set(result, "DrawStringASCII", _DrawStringASCII);
NSV8Objects::Template_Set(result, "DrawStringASCII2", _DrawStringASCII2);
NSV8Objects::Template_Set(result, "DrawHeaderEdit", _DrawHeaderEdit);
NSV8Objects::Template_Set(result, "DrawFooterEdit", _DrawFooterEdit);
NSV8Objects::Template_Set(result, "DrawLockParagraph", _DrawLockParagraph);
NSV8Objects::Template_Set(result, "DrawLockObjectRect", _DrawLockObjectRect);
NSV8Objects::Template_Set(result, "DrawEmptyTableLine", _DrawEmptyTableLine);
NSV8Objects::Template_Set(result, "DrawSpellingLine", _DrawSpellingLine);
NSV8Objects::Template_Set(result, "drawHorLine", _drawHorLine);
NSV8Objects::Template_Set(result, "drawHorLine2", _drawHorLine2);
NSV8Objects::Template_Set(result, "drawVerLine", _drawVerLine);
NSV8Objects::Template_Set(result, "drawHorLineExt", _drawHorLineExt);
NSV8Objects::Template_Set(result, "rect", _rect);
NSV8Objects::Template_Set(result, "TableRect", _TableRect);
NSV8Objects::Template_Set(result, "AddClipRect", _AddClipRect);
NSV8Objects::Template_Set(result, "RemoveClipRect", _RemoveClipRect);
NSV8Objects::Template_Set(result, "SetClip", _SetClip);
NSV8Objects::Template_Set(result, "RemoveClip", _RemoveClip);
NSV8Objects::Template_Set(result, "drawMailMergeField", _drawMailMergeField);
NSV8Objects::Template_Set(result, "drawSearchResult", _drawSearchResult);
NSV8Objects::Template_Set(result, "drawFlowAnchor", _drawFlowAnchor);
NSV8Objects::Template_Set(result, "SavePen", _SavePen);
NSV8Objects::Template_Set(result, "RestorePen", _RestorePen);
NSV8Objects::Template_Set(result, "SaveBrush", _SaveBrush);
NSV8Objects::Template_Set(result, "RestoreBrush", _RestoreBrush);
NSV8Objects::Template_Set(result, "SavePenBrush", _SavePenBrush);
NSV8Objects::Template_Set(result, "RestorePenBrush", _RestorePenBrush);
NSV8Objects::Template_Set(result, "SaveGrState", _SaveGrState);
NSV8Objects::Template_Set(result, "RestoreGrState", _RestoreGrState);
NSV8Objects::Template_Set(result, "StartClipPath", _StartClipPath);
NSV8Objects::Template_Set(result, "EndClipPath", _EndClipPath);
NSV8Objects::Template_Set(result, "StartCheckTableDraw", _StartCheckTableDraw);
NSV8Objects::Template_Set(result, "SetTextClipRect", _SetTextClipRect);
NSV8Objects::Template_Set(result, "AddSmartRect", _AddSmartRect);
NSV8Objects::Template_Set(result, "CheckUseFonts2", _CheckUseFonts2);
NSV8Objects::Template_Set(result, "UncheckUseFonts2", _UncheckUseFonts2);
NSV8Objects::Template_Set(result, "Drawing_StartCheckBounds", _Drawing_StartCheckBounds);
NSV8Objects::Template_Set(result, "Drawing_EndCheckBounds", _Drawing_EndCheckBounds);
NSV8Objects::Template_Set(result, "DrawPresentationComment", _DrawPresentationComment);
NSV8Objects::Template_Set(result, "DrawPolygon", _DrawPolygon);
NSV8Objects::Template_Set(result, "DrawFootnoteRect", _DrawFootnoteRect);
NSV8Objects::Template_Set(result, "toDataURL", _toDataURL);
NSV8Objects::Template_Set(result, "GetPenColor", _GetPenColor);
NSV8Objects::Template_Set(result, "GetBrushColor", _GetBrushColor);
NSV8Objects::Template_Set(result, "put_brushTexture", _put_brushTexture);
NSV8Objects::Template_Set(result, "put_brushTextureMode", _put_brushTextureMode);
NSV8Objects::Template_Set(result, "put_BrushTextureAlpha", _put_BrushTextureAlpha);
NSV8Objects::Template_Set(result, "put_BrushGradient", _put_BrushGradient);
NSV8Objects::Template_Set(result, "TransformPointX", _TransformPointX);
NSV8Objects::Template_Set(result, "TransformPointY", _TransformPointY);
NSV8Objects::Template_Set(result, "put_LineJoin", _put_LineJoin);
NSV8Objects::Template_Set(result, "get_LineJoin", _get_LineJoin);
NSV8Objects::Template_Set(result, "put_TextureBounds", _put_TextureBounds);
NSV8Objects::Template_Set(result, "GetlineWidth", _GetlineWidth);
NSV8Objects::Template_Set(result, "DrawPath", _DrawPath);
NSV8Objects::Template_Set(result, "CoordTransformOffset", _CoordTransformOffset);
NSV8Objects::Template_Set(result, "GetTransform", _GetTransform);
return handle_scope.Escape(result);
}
void CreateNativeGraphics(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CreateNativeInternalField(new CGraphicsEmbed(), NSGraphics::CreateGraphicsTemplate, args);
}
}
void CGraphicsEmbed::CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context)
{
InsertToGlobal(name, context, NSGraphics::CreateNativeGraphics);
}

View File

@ -0,0 +1,252 @@
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
#include "../GraphicsEmbed.h"
#include "../../js_internal/v8/v8_base.h"
namespace NSGraphicsEmbed
{
#define CURRENTWRAPPER CGraphicsEmbed
FUNCTION_WRAPPER_V8_5(_create, create)
FUNCTION_WRAPPER_V8_0(_Destroy, Destroy)
FUNCTION_WRAPPER_V8_0(_EndDraw, EndDraw)
FUNCTION_WRAPPER_V8_2(_put_GlobalAlpha, put_GlobalAlpha)
FUNCTION_WRAPPER_V8_0(_Start_GlobalAlpha, Start_GlobalAlpha)
FUNCTION_WRAPPER_V8_0(_End_GlobalAlpha, End_GlobalAlpha)
FUNCTION_WRAPPER_V8_4(_p_color, p_color)
FUNCTION_WRAPPER_V8_1(_p_width, p_width)
FUNCTION_WRAPPER_V8_1(_p_dash, p_dash)
FUNCTION_WRAPPER_V8_4(_b_color1, b_color1)
FUNCTION_WRAPPER_V8_4(_b_color2, b_color2)
FUNCTION_WRAPPER_V8_6(_transform, transform)
FUNCTION_WRAPPER_V8_1(_CalculateFullTransform, CalculateFullTransform)
FUNCTION_WRAPPER_V8_0(__s, _s)
FUNCTION_WRAPPER_V8_0(__e, _e)
FUNCTION_WRAPPER_V8_0(__z, _z)
FUNCTION_WRAPPER_V8_2(__m, _m)
FUNCTION_WRAPPER_V8_2(__l, _l)
FUNCTION_WRAPPER_V8_6(__c, _c)
FUNCTION_WRAPPER_V8_4(__c2, _c2)
FUNCTION_WRAPPER_V8_0(_ds, ds)
FUNCTION_WRAPPER_V8_0(_df, df)
FUNCTION_WRAPPER_V8_0(_save, save)
FUNCTION_WRAPPER_V8_0(_restore, restore)
FUNCTION_WRAPPER_V8_0(_clip, clip)
FUNCTION_WRAPPER_V8_0(_reset, reset)
FUNCTION_WRAPPER_V8_0(_FreeFont, FreeFont)
FUNCTION_WRAPPER_V8_0(_ClearLastFont, ClearLastFont)
FUNCTION_WRAPPER_V8_7(_drawImage2, drawImage2)
FUNCTION_WRAPPER_V8_8(_drawImage, drawImage)
FUNCTION_WRAPPER_V8_0(_GetFont, GetFont)
FUNCTION_WRAPPER_V8_2(_font, font)
FUNCTION_WRAPPER_V8_4(_SetFont, SetFont)
FUNCTION_WRAPPER_V8_0(_GetTextPr, GetTextPr)
FUNCTION_WRAPPER_V8_3(_FillText, FillText)
FUNCTION_WRAPPER_V8_3(_t, t)
FUNCTION_WRAPPER_V8_5(_FillText2, FillText2)
FUNCTION_WRAPPER_V8_5(_t2, t2)
FUNCTION_WRAPPER_V8_3(_FillTextCode, FillTextCode)
FUNCTION_WRAPPER_V8_3(_tg, tg)
FUNCTION_WRAPPER_V8_1(_charspace, charspace)
FUNCTION_WRAPPER_V8_2(_private_FillGlyph, private_FillGlyph)
FUNCTION_WRAPPER_V8_3(_private_FillGlyphC, private_FillGlyphC)
FUNCTION_WRAPPER_V8_1(_private_FillGlyph2, private_FillGlyph2)
FUNCTION_WRAPPER_V8_1(_SetIntegerGrid, SetIntegerGrid)
FUNCTION_WRAPPER_V8_0(_GetIntegerGrid, GetIntegerGrid)
FUNCTION_WRAPPER_V8_3(_DrawStringASCII, DrawStringASCII)
FUNCTION_WRAPPER_V8_3(_DrawStringASCII2, DrawStringASCII2)
FUNCTION_WRAPPER_V8_5(_DrawHeaderEdit, DrawHeaderEdit)
FUNCTION_WRAPPER_V8_5(_DrawFooterEdit, DrawFooterEdit)
FUNCTION_WRAPPER_V8_3(_DrawLockParagraph, DrawLockParagraph)
FUNCTION_WRAPPER_V8_4(_DrawLockObjectRect, DrawLockObjectRect)
FUNCTION_WRAPPER_V8_4(_DrawEmptyTableLine, DrawEmptyTableLine)
FUNCTION_WRAPPER_V8_4(_DrawSpellingLine, DrawSpellingLine)
FUNCTION_WRAPPER_V8_5(_drawHorLine, drawHorLine)
FUNCTION_WRAPPER_V8_5(_drawHorLine2, drawHorLine2)
FUNCTION_WRAPPER_V8_5(_drawVerLine, drawVerLine)
FUNCTION_WRAPPER_V8_7(_drawHorLineExt, drawHorLineExt)
FUNCTION_WRAPPER_V8_4(_rect, rect)
FUNCTION_WRAPPER_V8_4(_TableRect, TableRect)
FUNCTION_WRAPPER_V8_4(_AddClipRect, AddClipRect)
FUNCTION_WRAPPER_V8_0(_RemoveClipRect, RemoveClipRect)
FUNCTION_WRAPPER_V8_4(_SetClip, SetClip)
FUNCTION_WRAPPER_V8_0(_RemoveClip, RemoveClip)
FUNCTION_WRAPPER_V8_4(_drawMailMergeField, drawMailMergeField)
FUNCTION_WRAPPER_V8_4(_drawSearchResult, drawSearchResult)
FUNCTION_WRAPPER_V8_2(_drawFlowAnchor, drawFlowAnchor)
FUNCTION_WRAPPER_V8_0(_SavePen, SavePen)
FUNCTION_WRAPPER_V8_0(_RestorePen, RestorePen)
FUNCTION_WRAPPER_V8_0(_SaveBrush, SaveBrush)
FUNCTION_WRAPPER_V8_0(_RestoreBrush, RestoreBrush)
FUNCTION_WRAPPER_V8_0(_SavePenBrush, SavePenBrush)
FUNCTION_WRAPPER_V8_0(_RestorePenBrush, RestorePenBrush)
FUNCTION_WRAPPER_V8_0(_SaveGrState, SaveGrState)
FUNCTION_WRAPPER_V8_0(_RestoreGrState, RestoreGrState)
FUNCTION_WRAPPER_V8_0(_StartClipPath, StartClipPath)
FUNCTION_WRAPPER_V8_0(_EndClipPath, EndClipPath)
FUNCTION_WRAPPER_V8_0(_StartCheckTableDraw, StartCheckTableDraw)
FUNCTION_WRAPPER_V8_4(_SetTextClipRect, SetTextClipRect)
FUNCTION_WRAPPER_V8_5(_AddSmartRect, AddSmartRect)
FUNCTION_WRAPPER_V8_1(_CheckUseFonts2, CheckUseFonts2)
FUNCTION_WRAPPER_V8_0(_UncheckUseFonts2, UncheckUseFonts2)
FUNCTION_WRAPPER_V8_4(_Drawing_StartCheckBounds, Drawing_StartCheckBounds)
FUNCTION_WRAPPER_V8_0(_Drawing_EndCheckBounds, Drawing_EndCheckBounds)
FUNCTION_WRAPPER_V8_5(_DrawPresentationComment, DrawPresentationComment)
FUNCTION_WRAPPER_V8_3(_DrawPolygon, DrawPolygon)
FUNCTION_WRAPPER_V8_4(_DrawFootnoteRect, DrawFootnoteRect)
FUNCTION_WRAPPER_V8_1(_toDataURL, toDataURL)
FUNCTION_WRAPPER_V8_0(_GetPenColor, GetPenColor)
FUNCTION_WRAPPER_V8_0(_GetBrushColor, GetBrushColor)
FUNCTION_WRAPPER_V8_2(_put_brushTexture, put_brushTexture)
FUNCTION_WRAPPER_V8_1(_put_brushTextureMode, put_brushTextureMode)
FUNCTION_WRAPPER_V8_1(_put_BrushTextureAlpha, put_BrushTextureAlpha)
FUNCTION_WRAPPER_V8_8(_put_BrushGradient, put_BrushGradient)
FUNCTION_WRAPPER_V8_2(_TransformPointX, TransformPointX)
FUNCTION_WRAPPER_V8_2(_TransformPointY, TransformPointY)
FUNCTION_WRAPPER_V8_1(_put_LineJoin, put_LineJoin)
FUNCTION_WRAPPER_V8_0(_get_LineJoin, get_LineJoin)
FUNCTION_WRAPPER_V8_4(_put_TextureBounds, put_TextureBounds)
FUNCTION_WRAPPER_V8_0(_GetlineWidth, GetlineWidth)
FUNCTION_WRAPPER_V8_1(_DrawPath, DrawPath)
FUNCTION_WRAPPER_V8_2(_CoordTransformOffset, CoordTransformOffset)
FUNCTION_WRAPPER_V8_0(_GetTransform, GetTransform)
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
{
v8::EscapableHandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
result->SetInternalFieldCount(1);
NSV8Objects::Template_Set(result, "create", _create);
NSV8Objects::Template_Set(result, "Destroy", _Destroy);
NSV8Objects::Template_Set(result, "EndDraw", _EndDraw);
NSV8Objects::Template_Set(result, "put_GlobalAlpha", _put_GlobalAlpha);
NSV8Objects::Template_Set(result, "Start_GlobalAlpha", _Start_GlobalAlpha);
NSV8Objects::Template_Set(result, "End_GlobalAlpha", _End_GlobalAlpha);
NSV8Objects::Template_Set(result, "p_color", _p_color);
NSV8Objects::Template_Set(result, "p_width", _p_width);
NSV8Objects::Template_Set(result, "p_dash", _p_dash);
NSV8Objects::Template_Set(result, "b_color1", _b_color1);
NSV8Objects::Template_Set(result, "b_color2", _b_color2);
NSV8Objects::Template_Set(result, "transform", _transform);
NSV8Objects::Template_Set(result, "CalculateFullTransform", _CalculateFullTransform);
NSV8Objects::Template_Set(result, "_s", __s);
NSV8Objects::Template_Set(result, "_e", __e);
NSV8Objects::Template_Set(result, "_z", __z);
NSV8Objects::Template_Set(result, "_m", __m);
NSV8Objects::Template_Set(result, "_l", __l);
NSV8Objects::Template_Set(result, "_c", __c);
NSV8Objects::Template_Set(result, "_c2", __c2);
NSV8Objects::Template_Set(result, "ds", _ds);
NSV8Objects::Template_Set(result, "df", _df);
NSV8Objects::Template_Set(result, "save", _save);
NSV8Objects::Template_Set(result, "restore", _restore);
NSV8Objects::Template_Set(result, "clip", _clip);
NSV8Objects::Template_Set(result, "reset", _reset);
NSV8Objects::Template_Set(result, "FreeFont", _FreeFont);
NSV8Objects::Template_Set(result, "ClearLastFont", _ClearLastFont);
NSV8Objects::Template_Set(result, "drawImage2", _drawImage2);
NSV8Objects::Template_Set(result, "drawImage", _drawImage);
NSV8Objects::Template_Set(result, "GetFont", _GetFont);
NSV8Objects::Template_Set(result, "font", _font);
NSV8Objects::Template_Set(result, "SetFont", _SetFont);
NSV8Objects::Template_Set(result, "GetTextPr", _GetTextPr);
NSV8Objects::Template_Set(result, "FillText", _FillText);
NSV8Objects::Template_Set(result, "t", _t);
NSV8Objects::Template_Set(result, "FillText2", _FillText2);
NSV8Objects::Template_Set(result, "t2", _t2);
NSV8Objects::Template_Set(result, "FillTextCode", _FillTextCode);
NSV8Objects::Template_Set(result, "tg", _tg);
NSV8Objects::Template_Set(result, "charspace", _charspace);
NSV8Objects::Template_Set(result, "private_FillGlyph", _private_FillGlyph);
NSV8Objects::Template_Set(result, "private_FillGlyphC", _private_FillGlyphC);
NSV8Objects::Template_Set(result, "private_FillGlyph2", _private_FillGlyph2);
NSV8Objects::Template_Set(result, "SetIntegerGrid", _SetIntegerGrid);
NSV8Objects::Template_Set(result, "GetIntegerGrid", _GetIntegerGrid);
NSV8Objects::Template_Set(result, "DrawStringASCII", _DrawStringASCII);
NSV8Objects::Template_Set(result, "DrawStringASCII2", _DrawStringASCII2);
NSV8Objects::Template_Set(result, "DrawHeaderEdit", _DrawHeaderEdit);
NSV8Objects::Template_Set(result, "DrawFooterEdit", _DrawFooterEdit);
NSV8Objects::Template_Set(result, "DrawLockParagraph", _DrawLockParagraph);
NSV8Objects::Template_Set(result, "DrawLockObjectRect", _DrawLockObjectRect);
NSV8Objects::Template_Set(result, "DrawEmptyTableLine", _DrawEmptyTableLine);
NSV8Objects::Template_Set(result, "DrawSpellingLine", _DrawSpellingLine);
NSV8Objects::Template_Set(result, "drawHorLine", _drawHorLine);
NSV8Objects::Template_Set(result, "drawHorLine2", _drawHorLine2);
NSV8Objects::Template_Set(result, "drawVerLine", _drawVerLine);
NSV8Objects::Template_Set(result, "drawHorLineExt", _drawHorLineExt);
NSV8Objects::Template_Set(result, "rect", _rect);
NSV8Objects::Template_Set(result, "TableRect", _TableRect);
NSV8Objects::Template_Set(result, "AddClipRect", _AddClipRect);
NSV8Objects::Template_Set(result, "RemoveClipRect", _RemoveClipRect);
NSV8Objects::Template_Set(result, "SetClip", _SetClip);
NSV8Objects::Template_Set(result, "RemoveClip", _RemoveClip);
NSV8Objects::Template_Set(result, "drawMailMergeField", _drawMailMergeField);
NSV8Objects::Template_Set(result, "drawSearchResult", _drawSearchResult);
NSV8Objects::Template_Set(result, "drawFlowAnchor", _drawFlowAnchor);
NSV8Objects::Template_Set(result, "SavePen", _SavePen);
NSV8Objects::Template_Set(result, "RestorePen", _RestorePen);
NSV8Objects::Template_Set(result, "SaveBrush", _SaveBrush);
NSV8Objects::Template_Set(result, "RestoreBrush", _RestoreBrush);
NSV8Objects::Template_Set(result, "SavePenBrush", _SavePenBrush);
NSV8Objects::Template_Set(result, "RestorePenBrush", _RestorePenBrush);
NSV8Objects::Template_Set(result, "SaveGrState", _SaveGrState);
NSV8Objects::Template_Set(result, "RestoreGrState", _RestoreGrState);
NSV8Objects::Template_Set(result, "StartClipPath", _StartClipPath);
NSV8Objects::Template_Set(result, "EndClipPath", _EndClipPath);
NSV8Objects::Template_Set(result, "StartCheckTableDraw", _StartCheckTableDraw);
NSV8Objects::Template_Set(result, "SetTextClipRect", _SetTextClipRect);
NSV8Objects::Template_Set(result, "AddSmartRect", _AddSmartRect);
NSV8Objects::Template_Set(result, "CheckUseFonts2", _CheckUseFonts2);
NSV8Objects::Template_Set(result, "UncheckUseFonts2", _UncheckUseFonts2);
NSV8Objects::Template_Set(result, "Drawing_StartCheckBounds", _Drawing_StartCheckBounds);
NSV8Objects::Template_Set(result, "Drawing_EndCheckBounds", _Drawing_EndCheckBounds);
NSV8Objects::Template_Set(result, "DrawPresentationComment", _DrawPresentationComment);
NSV8Objects::Template_Set(result, "DrawPolygon", _DrawPolygon);
NSV8Objects::Template_Set(result, "DrawFootnoteRect", _DrawFootnoteRect);
NSV8Objects::Template_Set(result, "toDataURL", _toDataURL);
NSV8Objects::Template_Set(result, "GetPenColor", _GetPenColor);
NSV8Objects::Template_Set(result, "GetBrushColor", _GetBrushColor);
NSV8Objects::Template_Set(result, "put_brushTexture", _put_brushTexture);
NSV8Objects::Template_Set(result, "put_brushTextureMode", _put_brushTextureMode);
NSV8Objects::Template_Set(result, "put_BrushTextureAlpha", _put_BrushTextureAlpha);
NSV8Objects::Template_Set(result, "put_BrushGradient", _put_BrushGradient);
NSV8Objects::Template_Set(result, "TransformPointX", _TransformPointX);
NSV8Objects::Template_Set(result, "TransformPointY", _TransformPointY);
NSV8Objects::Template_Set(result, "put_LineJoin", _put_LineJoin);
NSV8Objects::Template_Set(result, "get_LineJoin", _get_LineJoin);
NSV8Objects::Template_Set(result, "put_TextureBounds", _put_TextureBounds);
NSV8Objects::Template_Set(result, "GetlineWidth", _GetlineWidth);
NSV8Objects::Template_Set(result, "DrawPath", _DrawPath);
NSV8Objects::Template_Set(result, "CoordTransformOffset", _CoordTransformOffset);
NSV8Objects::Template_Set(result, "GetTransform", _GetTransform);
return handle_scope.Escape(result);
}
}
class CGraphicsEmbedAdapter : public CJSEmbedObjectAdapterV8Template
{
public:
virtual v8::Local<v8::ObjectTemplate> getTemplate(v8::Isolate* isolate) override
{
v8::EscapableHandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> templ = NSGraphicsEmbed::CreateTemplate(isolate);
return handle_scope.Escape(templ);
}
};
CJSEmbedObjectAdapterBase* CGraphicsEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CGraphicsEmbedAdapter();
return m_pAdapter;
}
std::string CGraphicsEmbed::getName() { return "CGraphicsEmbed"; }
CJSEmbedObject* CGraphicsEmbed::getCreator()
{
return new CGraphicsEmbed();
}

View File

@ -1,34 +0,0 @@
#include "../HashEmbed.h"
#include "../../js_internal/v8/v8_base.h"
namespace NSHash
{
#define CURRENTWRAPPER CHashEmbed
FUNCTION_WRAPPER_V8_3(_hash, hash)
FUNCTION_WRAPPER_V8_4(_hash2, hash2)
v8::Handle<v8::ObjectTemplate> CreateHashTemplate(v8::Isolate* isolate)
{
v8::EscapableHandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
result->SetInternalFieldCount(1);
// methods
NSV8Objects::Template_Set(result, "hash", _hash);
NSV8Objects::Template_Set(result, "hash2", _hash2);
return handle_scope.Escape(result);
}
void CreateNativeHash(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CreateNativeInternalField(new CHashEmbed(), NSHash::CreateHashTemplate, args);
}
}
void CHashEmbed::CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context)
{
InsertToGlobal(name, context, NSHash::CreateNativeHash);
}

View File

@ -0,0 +1,50 @@
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
#include "../HashEmbed.h"
#include "../../js_internal/v8/v8_base.h"
namespace NSHashEmbed
{
#define CURRENTWRAPPER CHashEmbed
FUNCTION_WRAPPER_V8_3(_hash, hash)
FUNCTION_WRAPPER_V8_4(_hash2, hash2)
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
{
v8::EscapableHandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
result->SetInternalFieldCount(1);
NSV8Objects::Template_Set(result, "hash", _hash);
NSV8Objects::Template_Set(result, "hash2", _hash2);
return handle_scope.Escape(result);
}
}
class CHashEmbedAdapter : public CJSEmbedObjectAdapterV8Template
{
public:
virtual v8::Local<v8::ObjectTemplate> getTemplate(v8::Isolate* isolate) override
{
v8::EscapableHandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> templ = NSHashEmbed::CreateTemplate(isolate);
return handle_scope.Escape(templ);
}
};
CJSEmbedObjectAdapterBase* CHashEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CHashEmbedAdapter();
return m_pAdapter;
}
std::string CHashEmbed::getName() { return "CHashEmbed"; }
CJSEmbedObject* CHashEmbed::getCreator()
{
return new CHashEmbed();
}

View File

@ -1,58 +0,0 @@
#include "../MemoryStreamEmbed.h"
#include "../../js_internal/v8/v8_base.h"
namespace NSMemoryStream
{
#define CURRENTWRAPPER CMemoryStreamEmbed
FUNCTION_WRAPPER_V8_1(_ms_write_byte, WriteByte)
FUNCTION_WRAPPER_V8_1(_ms_write_bool, WriteBool)
FUNCTION_WRAPPER_V8_1(_ms_write_long, WriteLong)
FUNCTION_WRAPPER_V8_1(_ms_write_double, WriteDouble)
FUNCTION_WRAPPER_V8_1(_ms_write_double2, WriteDouble2)
FUNCTION_WRAPPER_V8_1(_ms_writestringA, WriteStringA)
FUNCTION_WRAPPER_V8_1(_ms_writestring1, WriteString)
FUNCTION_WRAPPER_V8_1(_ms_writestring2, WriteString2)
FUNCTION_WRAPPER_V8_3(_ms_copy, Copy)
FUNCTION_WRAPPER_V8(_ms_clearnoattack, ClearNoAttack)
void _ms_pos(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& args)
{
CMemoryStreamEmbed* _this = (CMemoryStreamEmbed*)unwrap_native(args.This());
args.GetReturnValue().Set(v8::Integer::New(CV8Worker::GetCurrent(), _this->m_pInternal->GetSize()));
}
v8::Handle<v8::ObjectTemplate> CreateMemoryStreamTemplate(v8::Isolate* isolate)
{
v8::EscapableHandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(V8IsolateOneArg);
result->SetInternalFieldCount(1);
// property
result->SetAccessor(CreateV8String(CV8Worker::GetCurrent(), "pos"), _ms_pos);
NSV8Objects::Template_Set(result, "Copy", _ms_copy);
NSV8Objects::Template_Set(result, "ClearNoAttack", _ms_clearnoattack);
NSV8Objects::Template_Set(result, "WriteByte", _ms_write_byte);
NSV8Objects::Template_Set(result, "WriteBool", _ms_write_bool);
NSV8Objects::Template_Set(result, "WriteLong", _ms_write_long);
NSV8Objects::Template_Set(result, "WriteDouble", _ms_write_double);
NSV8Objects::Template_Set(result, "WriteDouble2", _ms_write_double2);
NSV8Objects::Template_Set(result, "WriteStringA", _ms_writestringA);
NSV8Objects::Template_Set(result, "WriteString", _ms_writestring1);
NSV8Objects::Template_Set(result, "WriteString2", _ms_writestring2);
return handle_scope.Escape(result);
}
void CreateNativeMemoryStream(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CreateNativeInternalField(new CMemoryStreamEmbed(), NSMemoryStream::CreateMemoryStreamTemplate, args);
}
}
void CMemoryStreamEmbed::CreateObjectInContext(const std::string& name, JSSmart<CJSContext> context)
{
InsertToGlobal(name, context, NSMemoryStream::CreateNativeMemoryStream);
}

View File

@ -0,0 +1,66 @@
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
#include "../MemoryStreamEmbed.h"
#include "../../js_internal/v8/v8_base.h"
namespace NSMemoryStreamEmbed
{
#define CURRENTWRAPPER CMemoryStreamEmbed
FUNCTION_WRAPPER_V8_3(_Copy, Copy)
FUNCTION_WRAPPER_V8_0(_ClearNoAttack, ClearNoAttack)
FUNCTION_WRAPPER_V8_1(_WriteByte, WriteByte)
FUNCTION_WRAPPER_V8_1(_WriteBool, WriteBool)
FUNCTION_WRAPPER_V8_1(_WriteLong, WriteLong)
FUNCTION_WRAPPER_V8_1(_WriteDouble, WriteDouble)
FUNCTION_WRAPPER_V8_1(_WriteDouble2, WriteDouble2)
FUNCTION_WRAPPER_V8_1(_WriteStringA, WriteStringA)
FUNCTION_WRAPPER_V8_1(_WriteString, WriteString)
FUNCTION_WRAPPER_V8_1(_WriteString2, WriteString2)
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
{
v8::EscapableHandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
result->SetInternalFieldCount(1);
NSV8Objects::Template_Set(result, "Copy", _Copy);
NSV8Objects::Template_Set(result, "ClearNoAttack", _ClearNoAttack);
NSV8Objects::Template_Set(result, "WriteByte", _WriteByte);
NSV8Objects::Template_Set(result, "WriteBool", _WriteBool);
NSV8Objects::Template_Set(result, "WriteLong", _WriteLong);
NSV8Objects::Template_Set(result, "WriteDouble", _WriteDouble);
NSV8Objects::Template_Set(result, "WriteDouble2", _WriteDouble2);
NSV8Objects::Template_Set(result, "WriteStringA", _WriteStringA);
NSV8Objects::Template_Set(result, "WriteString", _WriteString);
NSV8Objects::Template_Set(result, "WriteString2", _WriteString2);
return handle_scope.Escape(result);
}
}
class CMemoryStreamEmbedAdapter : public CJSEmbedObjectAdapterV8Template
{
public:
virtual v8::Local<v8::ObjectTemplate> getTemplate(v8::Isolate* isolate) override
{
v8::EscapableHandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> templ = NSMemoryStreamEmbed::CreateTemplate(isolate);
return handle_scope.Escape(templ);
}
};
CJSEmbedObjectAdapterBase* CMemoryStreamEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CMemoryStreamEmbedAdapter();
return m_pAdapter;
}
std::string CMemoryStreamEmbed::getName() { return "CMemoryStreamEmbed"; }
CJSEmbedObject* CMemoryStreamEmbed::getCreator()
{
return new CMemoryStreamEmbed();
}

Some files were not shown because too many files have changed in this diff Show More