Compare commits

...

616 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
f63eac7883 Merge remote-tracking branch 'origin/hotfix/v7.4.1' into develop 2023-06-28 14:13:02 +03:00
8539dc168b Merge pull request #1209 from ONLYOFFICE/fix/v7.4-fix-bugs
Fix/v7.4 fix bugs
2023-06-28 14:10:48 +03:00
1e6e6032ee fix bug #63196 2023-06-28 14:04:49 +03:00
0fb4c8f13a Fixed bugs 2023-06-28 14:02:49 +03:00
03df0edd54 . 2023-06-28 09:27:44 +03:00
eb8e90cd94 fix bug #62861 2023-06-27 19:34:33 +03:00
f56a6ecc85 Move precompile_header detection to base.pri 2023-06-27 18:41:56 +03:00
d651d5166b Update copyright 2023-06-27 15:36:16 +03:00
20f77081d7 fix bug #59708 2023-06-27 11:10:55 +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
b3a0012222 fix bug #63158 2023-06-26 17:38:11 +03:00
575ef4ec54 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2023-06-26 17:09:45 +03:00
699acd0516 Fix bug 60851 2023-06-26 15:11:05 +03:00
7a93ec740d Fix bug 61780 2023-06-26 12:56:29 +03:00
144ef42626 fix bug #63157 2023-06-26 11:44:29 +03:00
5e9e15be57 Refactoring verify signatures 2023-06-25 13:13:36 +03:00
f2b01ac574 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2023-06-24 20:40:39 +03:00
32d2a16b2a Merge pull request #1208 from ONLYOFFICE/fix/x2ttester
Fix/x2ttester
2023-06-24 15:58:37 +03:00
e027275481 Fix bug 63073
new feature, conversion trough *t formats
2023-06-24 15:34:28 +03:00
a8e19af53c Fix bug 63072 2023-06-23 21:31:10 +03:00
3061670f2a Fix bug 62747 2023-06-23 21:30:22 +03:00
43f1d76032 testing using simple config 2023-06-23 19:30:09 +03:00
afe4cc60a5 x2ttester update 2023-06-23 19:14:02 +03:00
a63d9480e5 fix bug #56949 2023-06-23 18:00:53 +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
505739a4f0 For bug 61780 2023-06-23 13:24:41 +03:00
a3e1ddc538 Fix bug 62362 2023-06-23 13:21:25 +03:00
d676270cac Refactoring 2023-06-22 16:49:56 +03:00
a92805e33a small refactoring 2023-06-22 15:30:55 +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
054ddda825 . 2023-06-19 15:00:22 +03:00
85817c68c1 fix bug #63074 2023-06-19 12:55:36 +03:00
24ff96efae . 2023-06-19 12:10:27 +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
b8aac93241 fix bug #63020 2023-06-14 10:48:08 +03:00
c724ddf65c . 2023-06-14 10:05:03 +03:00
c7964fd079 Refactoring 2023-06-14 00:51:51 +03:00
6cf8f74592 odf sparkline 2023-06-13 19:56:44 +03:00
87c986a71d Change embed mode for native JS builders 2023-06-13 20:17:47 +04:00
b1a87e2ca9 Merge pull request #1206 from ONLYOFFICE/fix/src_over_unpremulti_alpha
Fix/src over unpremulti alpha
2023-06-13 20:08:13 +05:00
ae2ab76803 Fix crash when draw 0 alpha on 0 alpha 2023-06-13 18:06:40 +03:00
7a822494aa Merge branch release/v7.4.0 into master 2023-06-13 11:17:31 +00:00
2d07e41ccf fix typo 2023-06-13 13:12:25 +03: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
eedff7a840 fix morph 2023-06-12 12:13:40 +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
1397f4f150 Improve speed 2023-06-11 00:44:33 +03:00
b5e84edbe7 Add new blender and use in by default 2023-06-11 00:36:45 +03:00
284d2730e2 Merge remote-tracking branch 'origin/release/v7.4.0' into fix/v7.4-fix-bugs 2023-06-10 21:10:46 +03:00
7a36d76298 Merge pull request #1204 from ONLYOFFICE/fix/v7.4.0-fix-bugs
fix bug #62988
2023-06-10 22:06:59 +05:00
c3b7447c04 fix bug #62988 2023-06-10 19:50:52 +03:00
e0cc9c0409 Revert use .net 4.7.2 2023-06-10 16:11:26 +03:00
6590643894 Refactoring 2023-06-10 13:57:33 +03:00
075d6c849b . 2023-06-09 18:43:31 +03:00
a0ff455786 for bug #61780 2023-06-09 18:27:12 +03:00
ca75468fca Merge remote-tracking branch 'origin/feature/xml-sheets-2' into develop 2023-06-09 16:07:37 +03:00
c4f475167d Change .net version to 4.5.2 2023-06-09 15:54:48 +03:00
d72d03d449 Merge pull request #1203 from ONLYOFFICE/feature/pluginsmanager
fix ignore option for rmp package
2023-06-09 17:16:09 +05:00
322c7af962 fix --ignore option for rpm package 2023-06-09 14:42:25 +03:00
879ce1a66d Revert "Merge branch 'vboxtester' into feature/pluginsmanager"
This reverts commit 25a909d7a7, reversing
changes made to ed46c8521d.
2023-06-09 14:37:40 +03:00
a01b535609 minor
exclude vboxtester from release branch
2023-06-09 14:32:35 +03:00
25a909d7a7 Merge branch 'vboxtester' into feature/pluginsmanager 2023-06-09 14:06:05 +03:00
2c081fedc9 fix --ignore option 2023-06-09 14:05:13 +03:00
9fc7aa5bca for bug #61780 2023-06-09 10:02:13 +03:00
35e10ff9cd Merge branch 'release/v7.4.0' into vboxtester 2023-06-08 18:37:02 +03:00
bce86077af Merge branch 'release/v7.4.0' into vboxtester 2023-06-08 18:00:39 +03:00
ed46c8521d Merge branch 'release/v7.4.0' into feature/pluginsmanager 2023-06-08 17:58:11 +03:00
7d18fa5753 Merge pull request #1201 from ONLYOFFICE/feature/pluginsmanager
ignore option
2023-06-08 19:56:20 +05:00
bdddc1ac67 no --restore if --ignore 2023-06-08 17:48:59 +03:00
a02bd8f383 --ignore option
comma-separated quoted list of plugins to ignore actions,                        such as update, remove or rename
2023-06-08 17:30:46 +03:00
549c288bda - fix bug #59142 2023-06-08 20:14:49 +06:00
0d77b62c2d Documentation finished 2023-06-08 17:07:49 +04:00
1f59fa87d7 pdf fix V becomes shared when owned by Parent 2023-06-08 15:33:23 +03:00
caa0a45931 fix epub title 2023-06-08 11:03:33 +03:00
ade9cda2e4 Merge pull request #1200 from ONLYOFFICE/release/v7.4.0
Release/v7.4.0
2023-06-08 12:46:49 +05:00
a867a168e0 [V8] Singleton embed creation rework 2023-06-07 19:28:30 +04:00
07e8cda08d Add defined for version 2023-06-07 17:58:55 +03:00
af0836e379 Added some more description to documentation. 2023-06-07 13:30:05 +04:00
53e8fa7731 Fix bug 62923 2023-06-06 20:50:43 +03:00
cc4056a18b minor 2023-06-06 16:31:16 +03:00
37e03d6bcc Wrote some documentation for classes in js_base.h. 2023-06-06 17:26:28 +04:00
63b425763e fix no args 2023-06-06 16:06:29 +03:00
bf859f9763 Fix bug 62341 2023-06-06 16:01:47 +03:00
650c993fa0 end work 2023-06-06 15:01:50 +03:00
abba98d9d3 to test 2023-06-06 14:21:13 +03:00
e85923d94e need timeouts 2023-06-06 12:49:53 +03:00
6d548d27bc . 2023-06-06 11:54:35 +03:00
29167e6267 rpm support 2023-06-06 11:27:29 +03:00
80e2c75a54 . 2023-06-06 10:14:01 +03:00
65d5b5c628 Revision of the test example 2023-06-06 09:52:38 +03:00
9c67404b69 fixes for linux 2023-06-05 17:03:04 +03:00
c82b5c9994 fixes 2023-06-05 15:59:00 +03:00
e6205fcff9 Merge branch 'release/v7.4.0' into vboxtester 2023-06-05 15:58:44 +03:00
842103a7a0 Merge remote-tracking branch 'origin/release/v7.4.0' into develop 2023-06-05 13:35:55 +03:00
1ec0142c25 Fix bug #59143
Change the default value for shd for unknown types of pattern
2023-06-05 03:21:22 +05:00
859e96a3ab Added alpha mask test 2023-06-04 22:13:20 +03:00
f65463c96f fix bug #61612 2023-06-04 15:18:26 +03:00
133ad365f4 Fix bug 62746 2023-06-03 14:53:51 +03:00
4c077a28b8 Fix bug 62856 2023-06-03 12:15:23 +03:00
1bd7c77ead Merge pull request #1199 from ONLYOFFICE/fix/bug60993
fix bug 60993
2023-06-03 00:42:56 +03:00
fa6e1c41fe correct cell inserting 2023-06-03 00:45:49 +06:00
26e5245cf6 fixes 2023-06-02 21:23:03 +03:00
672b9fd118 fix space before table 2023-06-02 18:56:00 +03:00
c96b59cbbf [android] Fix merge 2023-06-02 18:25:41 +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
81ec34b6f9 Remove initialize/dispose v8 in x2t on mobile platforms 2023-06-02 16:05:18 +03:00
f29d83a80b Merge branch 'release/v7.4.0' into vboxtester 2023-06-02 15:59:47 +03:00
b5c44805fb Merge pull request #1198 from ONLYOFFICE/fix/bug61651
Fix bug 61651
2023-06-02 15:05:14 +03:00
01bfa49aba fix epub EncodeXmlString 2023-06-02 14:52:28 +03:00
7c0bef3c04 fix bug #62853 2023-06-02 14:23:10 +03:00
7aeaec211a fix fb2 EncodeXmlString 2023-06-02 14:08:23 +03:00
a3de9703bf fix bug #62855 2023-06-02 13:18:48 +03:00
855a04ebbc Merge remote-tracking branch 'origin/feature/xml-sheets-2' into develop 2023-06-02 13:04:22 +03:00
af743b7e25 Fix linux build 2023-06-02 10:46:56 +03:00
d4b6a05717 For bug 61940 2023-06-02 00:52:09 +03:00
de51600d34 [android] Copy icu extra to assets 2023-06-01 16:51:46 +03:00
a29605e1b7 Added adapter code generation to scipt 2023-06-01 17:03:57 +04:00
e74d681589 Merge branch 'feature/xml-sheets-2' of github.com:ONLYOFFICE/core into feature/xml-sheets-2 2023-06-01 18:58:36 +06:00
f40b6f849d [JSC] Implemented adapter. Removed Native2Value and Value2Native from js_base.h 2023-06-01 16:27:16 +04:00
3fcd251831 - fix bug #55431 2023-06-01 17:47:47 +06:00
375b5a5f4f [V8] added an option for removing void* functions from js_base.h 2023-06-01 15:28:19 +04:00
c64379636e fixes 2023-06-01 14:05:45 +03:00
d2f9c59b5f Merge branch 'release/v7.4.0' into vboxtester 2023-06-01 13:32:17 +03:00
30675ab8b9 Merge pull request #1197 from ONLYOFFICE/feature/pluginsmanager
Fix bug 62807
2023-06-01 13:31:23 +03:00
fbadc56797 Fix bug 62807 2023-06-01 13:17:42 +03:00
a568aa02c4 fix bug #62840 2023-06-01 13:12:12 +03:00
099d49b3a7 Merge branch 'release/v7.4.0' into feature/pluginsmanager 2023-06-01 12:10:12 +03:00
55a200e71d for bug 62807 2023-06-01 12:09:46 +03:00
c6586a9a17 fixes 2023-06-01 12:05:11 +03:00
fbcf56be9e . 2023-05-31 21:47:49 +03:00
83fdc52baf Merge branch 'release/v7.4.0' into vboxtester 2023-05-31 17:21:15 +03:00
966eac2367 fix bug #60467 2023-05-31 15:26:11 +03:00
76c570721c Merge remote-tracking branch 'origin/release/v7.4.0' into develop 2023-05-31 14:41:07 +03:00
32c185c089 fix bug #62303 2023-05-31 14:00:30 +03:00
623c7a9e12 correct month format, added local default date format 2023-05-31 14:22:09 +06:00
8762ec12ff add xml convert from param 2023-05-31 10:11:14 +03:00
cb66e15faf for bug #62789 2023-05-30 15:59:07 +03:00
f6a102353d fixes 2023-05-30 10:08:49 +03:00
2247d47e4b working test
alfa
2023-05-29 23:15:14 +03: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
cb77b0989c Merge pull request #1196 from ONLYOFFICE/feature/pluginsmanager
Fix bug 62807
2023-05-29 20:14:30 +03:00
5832049ebc . 2023-05-29 19:28:49 +03:00
43bc3c92b3 working script 2023-05-29 19:22:22 +03:00
50007b47ee Fix bug 62807 2023-05-29 19:19:45 +03:00
b98c51b020 fix bug #62790 2023-05-29 19:07:14 +03:00
0c5e670ad1 fix bug #45218 2023-05-29 17:54:49 +03:00
a623458a0c Merge pull request #1195 from ONLYOFFICE/release/v7.4.0
Release/v7.4.0
2023-05-29 17:52:44 +03:00
e41b892b58 Fix typo 2023-05-29 18:01:30 +05:00
527af6f669 Refactoring android build 2023-05-29 15:49:49 +03:00
19ce026b5c . 2023-05-29 15:37:17 +03:00
5e6f84ec74 Add files to docker archive 2023-05-29 15:23:11 +03:00
3b54172c0a . 2023-05-29 15:15:39 +03:00
8efb543bed Merge branch 'feature/xml-sheets2' into develop 2023-05-29 12:16:39 +03:00
21e5090b59 Merge branch 'feature/xml-sheets' into feature/xml-sheets2 2023-05-29 12:13:36 +03:00
4b38ce7d91 Merge remote-tracking branch 'origin/release/v7.4.0' into develop 2023-05-29 12:09:15 +03:00
59c4f17f88 removed local setting for every cell 2023-05-29 14:36:16 +06:00
3c7d05a33e Fix build 2023-05-29 12:49:26 +05:00
881da23a59 correct attribute parsing 2023-05-29 12:39:14 +06:00
c2d48fdd32 Fix typo 2023-05-28 21:38:43 +03: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
ebf6e9e995 Update v8 version for android 2023-05-28 17:09:09 +05:00
f87f2a47d5 Fix bug 62751 2023-05-28 11:55:11 +03:00
5728bcda76 new base funcs 2023-05-27 20:00:02 +03:00
21ee5ceecf Implemented code generation for internal embed 2023-05-27 18:19:57 +04:00
ceadb68bc6 ExecuteCommand and base funcs
GetVms, StartVm, StopVm, GetScreenshot
2023-05-27 11:26:15 +03:00
3aa94ae6ae command runner 2023-05-27 09:57:20 +03:00
b8095b3f82 to linux development 2023-05-26 22:47:05 +03: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
7448a331e9 Merge pull request #1194 from ONLYOFFICE/feature/pluginsmanager
Fixes 62704, 62727
2023-05-26 13:53:39 +03:00
940bb840be minors 2023-05-26 13:42:27 +03:00
967b0aec72 autorename options 2023-05-26 11:31:27 +03:00
59dcc3eb5c Added an option for compiling with v8_Embed.cpp but it's just terrifying 2023-05-25 20:32:03 +04:00
852989d0c9 fix bug 62704
checking permissions for the working folder
2023-05-25 17:39:52 +03:00
73ae7ceef9 Trying to understand template for generation of V8 embed file 2023-05-25 18:31:50 +04:00
c733399b88 fix bug #60467 2023-05-25 16:32:33 +03:00
8c92a944ad Merge branch 'release/v7.4.0' of https://github.com/ONLYOFFICE/core into release/v7.4.0 2023-05-25 14:32:33 +03:00
0456f9b362 fix bug #62728 2023-05-25 14:32:03 +03:00
4ec7942649 Fix typo 2023-05-25 13:49:46 +03:00
13410416a5 fix bud 62727 2023-05-25 13:30:46 +03:00
e103bcb562 correct xml conversion 2023-05-25 13:29:25 +06:00
b4d00a7a47 fix bug #62498 2023-05-24 15:40:33 +03: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
9d497e48c9 Merge pull request #1193 from ONLYOFFICE/feature/pluginsmanager
Restore error description
2023-05-23 17:47:36 +05:00
759a159005 bug fix #62707 2023-05-23 15:36:36 +03:00
92e6fa06b5 Merge branch 'release/v7.4.0' into feature/pluginsmanager 2023-05-23 15:26:57 +03:00
7b93de3e8a bug fix #62707 2023-05-23 15:26:46 +03:00
ca3e65468b fix bug #62712 2023-05-22 21:55:39 +03:00
099f3f5632 Refactoring 2023-05-22 20:26:19 +03:00
5d378ddb41 minor 2023-05-22 20:03:57 +03:00
ba05993073 settings folder tolower 2023-05-22 19:42:33 +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
6438c1cd4b For bug 62605 2023-05-22 12:49:06 +03:00
05e6f2a4fe Refactoring 2023-05-21 14:27:58 +05:00
07ad714d3a Merge pull request #1191 from ONLYOFFICE/fix/build-linux
linux fix build debug
2023-05-21 00:42:16 +05:00
1c87c34db9 Add flags for convertation to images 2023-05-20 21:57:38 +03:00
8f4956102a Fix bug 62696 2023-05-20 20:09:56 +03: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
0d8fcd1bef linux fix build debug 2023-05-20 09:22:38 +03:00
4db5c55544 Merge pull request #1190 from ONLYOFFICE/fix/pm-linux
Refactoring config parsing
2023-05-20 01:24:55 +05:00
709ac0b868 Merge branch 'release/v7.4.0' into fix/pm-linux 2023-05-19 21:53:57 +03:00
a10849ada1 jsc_Embed.mm protocol methods need to be implemented at runtime? 2023-05-19 22:21:58 +04:00
ed28078a9e correct xml reading 2023-05-19 20:27:14 +06:00
390e036b25 add value name check 2023-05-19 18:38:51 +06:00
dd73d3347f Fix build 2023-05-19 11:55:43 +03:00
4accc90216 Trying to make it build with generated jsc_Embed.mm 2023-05-18 21:47:06 +04:00
d3f75c5033 correct digit format 2023-05-18 23:19:33 +06:00
e98f981a46 fix bug #59026 2023-05-18 18:49:08 +03:00
4d4e4a5ed7 change currency format 2023-05-18 17:44:16 +06:00
71d63d560a added common fraction processing 2023-05-18 15:50:34 +06:00
6a1de3467a add leading zeros to digit format 2023-05-18 13:29:11 +06:00
d6b7aefe51 bullshit off 2023-05-17 23:31:07 +03:00
f612ca64e0 Merge pull request #1189 from ONLYOFFICE/fix/pm-linux
minor fixes
2023-05-18 01:08:00 +05:00
e3a582ee67 minor 2023-05-17 21:57:15 +03:00
fa68ba2f0d fix config spaces 2023-05-17 21:07:49 +03:00
3387f67f7e Merge pull request #1187 from ONLYOFFICE/fix/pm-linux
linux fixes
2023-05-17 22:32:28 +05:00
383e9bc971 speedup 2023-05-17 20:15:33 +03:00
c67aea9543 fix bug #62630 2023-05-17 19:53:56 +03:00
0e64e3467b linux: fix plugin version 2023-05-17 19:49:38 +03:00
cc2027edab For bug 62654 2023-05-17 19:33:08 +03:00
da3739942f Merge pull request #1186 from ONLYOFFICE/fix/pm-linux
linux fix: args
2023-05-17 21:06:58 +05:00
439f52be3d Writed code generation inside of an embedded class [V8] 2023-05-17 17:49:48 +04:00
80d5783b3b linux fix: args 2023-05-17 16:21:31 +03:00
b663d3599a correct digit reading 2023-05-17 18:59:05 +06:00
dbd5aeadd2 fix bug #62634 2023-05-17 13:49:04 +03:00
e0caa9effc add digit reader and currency reader 2023-05-16 21:17:53 +06:00
d57b69731b fix bug #62610 2023-05-16 15:44:33 +03:00
7d6b82554b Added viewBox support for markers in svg-reader 2023-05-16 15:34:01 +03:00
bb8fda207b add format creating method 2023-05-16 17:09:24 +06:00
248f9a5362 fix bug #62498 2023-05-16 12:22:50 +03:00
204ef06b1a . 2023-05-16 10:30:06 +03:00
f9171cb342 small optimization 2023-05-16 08:55:25 +03:00
6d80b8537f fix bug #62174 2023-05-15 19:40:02 +03:00
1c894b7896 Line, polyline, and polygon records are remade as heirs of path 2023-05-15 19:28:59 +03:00
c5a09b75d6 fix bug #62115 2023-05-15 18:44:55 +03:00
be77e4a00a add processing dates before 1900 2023-05-15 20:02:37 +06:00
1c8687e07f Fix build with c++11 2023-05-15 17:58:19 +05:00
28745ae49f Refacroring work with arraybuffer for support new v8 versions 2023-05-15 15:33:35 +03:00
d6b5523406 Merge pull request #1185 from ONLYOFFICE/fix/metafile_bugs
Fix metafile bugs
2023-05-15 16:17:09 +05:00
fc1d61799b Merge branch hotfix/v7.3.3 into master 2023-05-15 06:44:54 +00:00
358903d331 Fix typo 2023-05-14 01:41:32 +05:00
46e8d03eeb fix bug #62579 2023-05-12 18:29:52 +03:00
554ad261cf fix bug #62572 2023-05-12 18:15:49 +03:00
50c8f69956 removed unused methods 2023-05-12 20:35:03 +06:00
87b46539c8 correct data format 2023-05-12 20:33:27 +06:00
7ddc3234a7 Added Marker record support for Paths in svg-reader and refactoring 2023-05-12 17:19:03 +03:00
9a2d9daa87 upgrade format controller 2023-05-12 15:53:38 +06:00
78c662ea55 Merge pull request #1183 from ONLYOFFICE/feature/pluginsmanager
pluginsmanager - update on server
2023-05-12 12:29:48 +05:00
98a02441de [server] update by config
- update if plugin exists
- install if plugin is not installed and not removed before
2023-05-12 10:27:14 +03:00
efb3075e0e removing by config 2023-05-12 09:43:48 +03:00
da703d88ca Merge pull request #1182 from ONLYOFFICE/feature/pluginsmanager
pluginsmanager
2023-05-12 11:02:24 +05:00
dc73c8b2b6 minor 2023-05-12 08:33:20 +03:00
1404829b68 change settings folder 2023-05-12 08:18:48 +03:00
be9f8ba8e6 minor 2023-05-11 22:46:50 +03:00
f858b76fd4 minors
--print-removed option
2023-05-11 22:26:20 +03:00
3914b9a9d5 fix update 2023-05-11 20:47:41 +03:00
e19d1c6735 fix bug #62530 2023-05-11 19:11:43 +03:00
041d8a3dc4 install/remove settings feature 2023-05-11 18:42:12 +03:00
31ee203b92 Fix bugs in metafile to svg conversion 2023-05-11 18:03:56 +03:00
3d7eefcd3d Merge pull request #1179 from ONLYOFFICE/feature/shape-vertical-text-align
Feature/shape vertical text align
2023-05-11 16:24:19 +03:00
82db1cd0d1 fix bug #62327 2023-05-11 15:25:49 +03:00
14ea99e880 fix bug #32006 2023-05-11 14:55:17 +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
f82dc027de add format controller using to csv reader 2023-05-10 16:04:02 +06:00
45d23ed87d add format controller 2023-05-05 19:49:47 +06:00
5be6b6ebe5 Embed for jsc. It doesn't works for now. 2023-05-04 20:14:43 +04:00
0c971e9b12 add cell sorting 2023-05-04 20:24:56 +06:00
5d4adb482a correct attribute processing 2023-05-04 16:15:22 +06:00
26cbeecb76 add attribute filling 2023-05-03 22:09:31 +06: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
a25b62472c add repeatable values reading 2023-05-03 17:34:43 +06:00
b096ce8098 Correction of font selection in metafile to svg conversion 2023-05-03 14:05:44 +03:00
ffc3149d4b Fixed a bug with font size in metafile to svg conversion 2023-05-03 12:07:58 +03:00
f4cc9ec38a Fix bug #62404 2023-05-03 12:07:19 +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
3515db7e10 add processing repeatable value columns 2023-05-02 14:28:27 +06: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
7e799bd3cb add xmlConverter2 interface 2023-04-27 20:23:43 +06: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
5c7a285bb9 add new realisation with map reading 2023-04-26 17:11:03 +06:00
44016b4ccc Merge branch 'release/v7.4.0' into feature/shape-vertical-text-align 2023-04-25 14:08:12 +07:00
64cfee514f updated license text 2023-04-24 13:50:03 +06:00
f973bd2df3 refactored node reading 2023-04-21 14:06:52 +06:00
01f01ec85f vertical text align 2023-04-20 08:15:05 +03:00
ac8019e6fd removed test vars 2023-04-19 20:33:36 +06:00
f0ea14790c add styles inserting 2023-04-19 20:29:37 +06:00
5e9677cc7a . 2023-04-19 16:22:20 +03:00
cb64312b80 correct attribute inserting 2023-04-19 16:25:48 +06: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
68ad7412f6 упорядочил вставку ячеек в строку 2023-04-18 20:33:15 +06:00
7d3334b8a7 доработал код конвертации 2023-04-18 15:47:35 +06:00
a4b6d57786 Changed the principle of working with arcs in svg-reader 2023-04-17 19:56:33 +03:00
cc933d8316 обновил контроллер имён 2023-04-17 14:43:21 +06:00
a270168f7f доработки кода 2023-04-14 19:13:11 +06:00
a115bbc64e correct code 2023-04-14 15:40:01 +06:00
ffffddfd45 рефакторинг работы конвертаии xml 2023-04-14 00:05:34 +06:00
8780587532 merged 2023-04-13 13:45:27 +06:00
22fe4574ad update project file on doctrennderer.pro 2023-04-13 13:42:40 +06:00
577cd11bd5 вернул и доработалcolumnName controller 2023-04-11 20:50:22 +06:00
2402ceb055 добавил вектор с нодами-предками 2023-04-11 14:44:01 +06:00
8f378140cb изменил тип значения, добавляемого в ячейку на Ctext 2023-04-11 13:42:05 +06:00
12932ec1a7 исправил парсинг xml 2023-04-07 18:53:06 +06:00
85a6bd84b6 correct cell indexes 2023-04-05 20:26:53 +06:00
f4cabdc7ef заменил map на vector для временного хранения xml 2023-04-05 17:42:48 +06:00
7f92930c18 correct code 2023-04-05 14:30:51 +06:00
be7cd036b8 add xml parsing into x2t converter 2023-03-30 20:40:04 +06:00
58ad19b395 add xml reader realisation 2023-03-30 19:44:31 +06:00
7380c666f2 убрал не использующийся names controller 2023-03-30 18:58:07 +06:00
224eb82f58 доработана обработка нод 2023-03-30 18:53:33 +06:00
09f45b2c02 restructured xml2table converter 2023-03-30 16:21:45 +06:00
abcfc66a41 Improved arc calculations in svg-reader 2023-03-29 20:16:26 +03:00
6aee8d6374 add new files to build 2023-03-29 17:10:08 +06:00
ebd00bbc8e add xml reader files 2023-03-28 21:26:47 +06:00
b28094bed1 add v8_89 using 2023-03-28 16:39:37 +06: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
fdd3685df3 xml 2023-03-20 10:59:25 +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
fa85b389f2 Merge branch hotfix/v7.3.3 into master 2023-03-15 10:47:21 +00: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
989 changed files with 56614 additions and 44418 deletions

2
.gitignore vendored
View File

@ -40,7 +40,7 @@ Thumbs.db
*.opendb
.vs
.vscode
DesktopEditor/fontengine/js/common/freetype-2.10.4
*_resource.rc

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

@ -3,7 +3,7 @@
# Based on Ubuntu
############################################################
# Set the base image to Ubuntu
FROM ubuntu:14.04
FROM ubuntu:18.04
# File Author / Maintainer
MAINTAINER onlyoffice.com
################## BEGIN INSTALLATION ######################
@ -23,12 +23,25 @@ RUN sudo apt-get install -y \
curl \
wget \
xz-utils \
zip
zip \
python2.7 \
python3 \
autoconf \
build-essential \
cmake \
pkg-config \
libc6-i386 \
gcc-multilib \
software-properties-common
WORKDIR /home/docker
RUN mkdir v8
WORKDIR /home/docker/v8
COPY ./build.sh ./build.sh
RUN ./build.sh
COPY ./build.py ./build.py
RUN sudo add-apt-repository -y ppa:deadsnakes/ppa
RUN sudo apt install -y python3.8
RUN sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1000
RUN sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1000
RUN python ./build.py
RUN zip -r ./build.zip ./build/*
RUN ls -al /home/docker/v8/build.zip
#End of docker Command

View File

@ -0,0 +1,199 @@
#!/usr/bin/env python
import sys
import platform
import os
import subprocess
import glob
import shutil
import codecs
# BASE --------------------------------------------
def host_platform():
ret = platform.system().lower()
if (ret == "darwin"):
return "mac"
return ret
def get_path(path):
if "windows" == host_platform():
return path.replace("/", "\\")
return path
def is_file(path):
return os.path.isfile(get_path(path))
def is_dir(path):
return os.path.isdir(get_path(path))
def copy_file(src, dst):
if is_file(dst):
delete_file(dst)
if not is_file(src):
print("copy warning [file not exist]: " + src)
return
return shutil.copy2(get_path(src), get_path(dst))
def delete_file(path):
if not is_file(path):
print("delete warning [file not exist]: " + path)
return
return os.remove(get_path(path))
def create_dir(path):
path2 = get_path(path)
if not os.path.exists(path2):
os.makedirs(path2)
return
def copy_dir(src, dst):
if is_dir(dst):
delete_dir(dst)
try:
shutil.copytree(get_path(src), get_path(dst))
except OSError as e:
print('Directory not copied. Error: %s' % e)
return
def delete_dir(path):
if not is_dir(path):
print("delete warning [folder not exist]: " + path)
return
shutil.rmtree(get_path(path), ignore_errors=True)
return
def cmd(prog, args=[], is_no_errors=False):
ret = 0
command = prog
for arg in args:
command += (" \"" + arg + "\"")
ret = subprocess.call(command, stderr=subprocess.STDOUT, shell=True)
if ret != 0 and True != is_no_errors:
sys.exit("Error (" + prog + "): " + str(ret))
return ret
def cmd2(prog, args=[], is_no_errors=False):
ret = 0
command = get_path(prog)
for arg in args:
command += (" " + arg)
print(command)
ret = subprocess.call(command, stderr=subprocess.STDOUT, shell=True)
if ret != 0 and True != is_no_errors:
sys.exit("Error (" + prog + "): " + str(ret))
return ret
def get_script_dir():
test_file = __file__
scriptPath = os.path.realpath(test_file)
scriptDir = os.path.dirname(scriptPath)
return scriptDir
def get_env(name):
return os.getenv(name, "")
def set_env(name, value):
os.environ[name] = value
return
def replaceInFile(path, text, textReplace):
if not is_file(path):
print("[replaceInFile] file not exist: " + path)
return
filedata = ""
with open(get_path(path), "r") as file:
filedata = file.read()
filedata = filedata.replace(text, textReplace)
delete_file(path)
with open(get_path(path), "w") as file:
file.write(filedata)
return
# -------------------------------------------------
def get_android_args(platform, sdk_ver=21):
gn_args = ["is_component_build=false",
"is_clang=true",
"is_debug=false",
"use_sysroot=true",
"target_os=\\\"android\\\"",
"target_cpu=\\\"" + platform + "\\\"",
"v8_target_cpu=\\\"" + platform + "\\\"",
"v8_enable_i18n_support=true",
"v8_static_library=true",
"v8_monolithic=true",
"use_custom_libcxx=false",
"android_ndk_version=\\\"21.1.6352462\\\"",
"android_sdk_version=\\\"" + str(sdk_ver) + "\\\"",
"clang_use_chrome_plugins=false",
"v8_use_external_startup_data=false",
"treat_warnings_as_errors=false"]
return gn_args
def deploy_libs():
if is_dir("../build"):
delete_dir("../build")
create_dir("../build")
platforms = ["arm64", "arm", "x86_64", "x86"]
dirs = ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
for index, item in enumerate(platforms):
input_dir = "./out.gn/android/" + platforms[index]
output_dir = "../build/" + dirs[index]
create_dir(output_dir)
copy_file(input_dir + "/icudtl.dat", output_dir + "/icudtl.dat")
copy_file(input_dir + "/icudtl_extra.dat", output_dir + "/icudtl_extra.dat")
copy_file(input_dir + "/obj/libv8_monolith.a", output_dir + "/libv8_monolith.a")
create_dir("../build/v8")
copy_dir("./include", "../build/v8/include")
copy_dir("./src", "../build/v8/src")
return
def make():
old_env = dict(os.environ)
old_cur = os.getcwd()
base_dir = get_script_dir()
os.chdir(base_dir)
if not is_dir("depot_tools"):
cmd("git", ["clone", "https://chromium.googlesource.com/chromium/tools/depot_tools.git"])
os.environ["PATH"] = base_dir + "/depot_tools" + os.pathsep + os.environ["PATH"]
if not is_dir("v8"):
cmd("./depot_tools/fetch", ["v8"], True)
copy_dir("./v8/third_party", "./v8/third_party_new")
v8_branch_version = "remotes/branch-heads/8.9"
cmd("./depot_tools/gclient", ["sync", "-r", v8_branch_version], True)
replaceInFile("./.gclient", "]", "];target_os=['android'];")
cmd("gclient", ["sync", "--force"], True)
copy_dir("./v8/third_party_new/ninja", "./v8/third_party/ninja")
if not is_file("v8/third_party/jinja2/tests.py.bak"):
copy_file("v8/third_party/jinja2/tests.py", "v8/third_party/jinja2/tests.py.bak")
replaceInFile("v8/third_party/jinja2/tests.py", "from collections import Mapping", "try:\n from collections.abc import Mapping\nexcept ImportError:\n from collections import Mapping")
os.chdir("v8")
cmd2("gn", ["gen", "out.gn/android/arm64", "--args=\"" + " ".join(get_android_args("arm64")) + "\""])
cmd("ninja", ["-C", "out.gn/android/arm64"])
cmd2("gn", ["gen", "out.gn/android/arm", "--args=\"" + " ".join(get_android_args("arm")) + "\""])
cmd("ninja", ["-C", "out.gn/android/arm"])
cmd2("gn", ["gen", "out.gn/android/x86_64", "--args=\"" + " ".join(get_android_args("x64", 16)) + "\""])
cmd("ninja", ["-C", "out.gn/android/x86_64"])
cmd2("gn", ["gen", "out.gn/android/x86", "--args=\"" + " ".join(get_android_args("x86", 16)) + "\""])
cmd("ninja", ["-C", "out.gn/android/x86"])
deploy_libs()
os.chdir(old_cur)
os.environ.clear()
os.environ.update(old_env)
make()

View File

@ -3,23 +3,34 @@ sys.path.append('./../../../../../build_tools/scripts')
import base
import os
if ("linux" == base.host_platform()):
if not base.is_dir("./build"):
base.bash("./build")
def build_func():
if ("linux" == base.host_platform()):
if not base.is_dir("./build"):
base.cmd("python", ["./build.py"])
if ("mac" == base.host_platform()):
if not base.is_file("./build.zip"):
base.bash("./run_docker")
if not base.is_dir("./build"):
base.configure_common_apps("./../../../../../build_tools/scripts/base.py")
base.extract("./build.zip", "./")
if not base.is_dir("v8"):
if not base.is_dir("depot_tools"):
base.cmd("git", ["clone", "https://chromium.googlesource.com/chromium/tools/depot_tools.git"])
old_cur = os.getcwd()
os.environ["PATH"] = old_cur + "/depot_tools" + os.pathsep + os.environ["PATH"]
base.cmd("./depot_tools/fetch", ["v8"], True)
os.chdir(old_cur + "/v8")
base.cmd("git", ["checkout", "-b", "6.0", "branch-heads/6.0"], True)
os.chdir(old_cur)
base.cmd("gclient", ["sync"])
if ("mac" == base.host_platform()):
if not base.is_file("./build.zip"):
base.bash("./run_docker")
if not base.is_dir("./build"):
base.configure_common_apps("./../../../../../build_tools/scripts/base.py")
base.extract("./build.zip", "./")
if not base.is_dir("v8"):
if not base.is_dir("depot_tools"):
base.cmd("git", ["clone", "https://chromium.googlesource.com/chromium/tools/depot_tools.git"])
old_cur = os.getcwd()
os.environ["PATH"] = old_cur + "/depot_tools" + os.pathsep + os.environ["PATH"]
base.cmd("./depot_tools/fetch", ["v8"], True)
base.cmd("./depot_tools/gclient", ["sync", "-r", "remotes/branch-heads/8.9"], True)
base.cmd("gclient", ["sync", "--force"], True)
return
# build function. for speed we just download the build archive
# archive built with this func
if False:
build_func()
else:
if not base.is_file("./build.7z"):
base.download("http://d2ettrnqo7v976.cloudfront.net/v8/android/build.7z", "./build.7z")
base.extract("./build.7z", "./")
base.copy_dir("./build/v8", "./v8")
base.delete_dir("./build/v8")

View File

@ -8,6 +8,12 @@ v8_version_89 {
core_win_32:CONFIG += build_platform_32
core_linux_32:CONFIG += build_platform_32
core_android {
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_armv7):CONFIG += build_platform_32
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86):CONFIG += build_platform_32
}
!build_platform_32:DEFINES += V8_COMPRESS_POINTERS
CORE_V8_PATH_OVERRIDE = $$PWD/../v8_89
@ -17,12 +23,13 @@ CORE_V8_PATH_INCLUDE = $$CORE_V8_PATH_OVERRIDE/v8
CORE_V8_PATH_LIBS = $$CORE_V8_PATH_INCLUDE/out.gn/$$CORE_BUILDS_PLATFORM_PREFIX/obj
core_android {
CORE_V8_PATH_INCLUDE = $$CORE_V8_PATH_OVERRIDE/android/v8
CORE_V8_PATH_INCLUDE = $$PWD/android/v8
CORE_V8_PATH_LIBS = $$PWD/android/build
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_arm64_v8a):CORE_V8_PATH_LIBS=$$CORE_V8_PATH_OVERRIDE/android/build/arm64-v8a
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_armv7): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_OVERRIDE/android/build/armeabi-v7a
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_OVERRIDE/android/build/x86
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86_64): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_OVERRIDE/android/build/x86_64
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_arm64_v8a):CORE_V8_PATH_LIBS=$$CORE_V8_PATH_LIBS/arm64-v8a
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_armv7): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_LIBS/armeabi-v7a
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_LIBS/x86
isEqual(CORE_BUILDS_PLATFORM_PREFIX, android_x86_64): CORE_V8_PATH_LIBS=$$CORE_V8_PATH_LIBS/x86_64
}
INCLUDEPATH += \
@ -76,6 +83,5 @@ core_mac {
}
core_android {
LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libplatform -lv8_libbase -lv8_nosnapshot -lv8_libsampler
LIBS += -L$$CORE_V8_PATH_LIBS -licui18n -licuuc
LIBS += -L$$CORE_V8_PATH_LIBS -lv8_monolith
}

View File

@ -524,6 +524,7 @@ public:
m_mapLCID2DefCodePage.insert(std::make_pair(0x40E, 1250));
m_mapLCID2DefCodePage.insert(std::make_pair(0x40F, 1252));
m_mapLCID2DefCodePage.insert(std::make_pair(0x410, 1252));
m_mapLCID2DefCodePage.insert(std::make_pair(0x412, 949));
m_mapLCID2DefCodePage.insert(std::make_pair(0x413, 1252));
m_mapLCID2DefCodePage.insert(std::make_pair(0x414, 1252));
m_mapLCID2DefCodePage.insert(std::make_pair(0x415, 1250));
@ -676,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

@ -239,8 +239,6 @@ namespace NSNetwork
nargs[8] = NULL;
#endif
nargs[7] = NULL;
const char* nenv[2];
nenv[0] = "LD_PRELOAD=";
nenv[1] = NULL;

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)

View File

@ -80,6 +80,8 @@ public:
bool isVbaProjectFile(POLE::Storage * storage);
bool isMS_OFFCRYPTOFormatFile (const std::wstring & fileName, std::wstring & documentID);
bool iXmlFile(const std::wstring & fileName);
std::wstring getDocumentID (const std::wstring & fileName);
bool isOOXFlatFormatFile(unsigned char* pBuffer,int dwBytes);

View File

@ -33,6 +33,7 @@
#include "../DesktopEditor/common/Directory.h"
#include "../OfficeUtils/src/OfficeUtils.h"
#include "../DesktopEditor/xml/include/xmlutils.h"
//#if defined FILE_FORMAT_CHECKER_WITH_MACRO
// #include "../MsBinaryFile/PptFile/Main/PPTFormatLib.h"
@ -68,6 +69,18 @@ bool COfficeFileFormatChecker::isMultiPartsHtmlFormatFile(unsigned char* pBuffer
}
return false;
}
bool COfficeFileFormatChecker::iXmlFile(const std::wstring & fileName)
{
XmlUtils::CXmlLiteReader oReader;
if (!oReader.FromFile(fileName))
return false;
if (!oReader.ReadNextNode())
return false;
return true;
}
bool COfficeFileFormatChecker::isHtmlFormatFile(unsigned char* pBuffer, int dwBytes, bool testCloseTag)
{
if (pBuffer == NULL || dwBytes < 4) return false;
@ -585,6 +598,11 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName)
}
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN) return true;
//------------------------------------------------------------------------------------------------
if (iXmlFile(fileName))
{
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_XML;
return true;
}
//// by Extension
std::wstring::size_type nExtPos = fileName.rfind(L'.');

View File

@ -56,6 +56,8 @@
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0015
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0016
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_XML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0030
#define AVS_OFFICESTUDIO_FILE_PRESENTATION 0x0080
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0001
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0002

View File

@ -11,11 +11,19 @@ BUILD_NUMBER = $$(BUILD_NUMBER)
DEFINES += INTVER=$$VERSION
WIN_VERSION = $$replace(VERSION, \., ",")
DEFINES += WIN_INTVER=$$WIN_VERSION
PUBLISHER_NAME = $$(PUBLISHER_NAME)
isEmpty(PUBLISHER_NAME){
PUBLISHER_NAME = $$cat(copyright.txt)
}
APPLICATION_NAME_DEFAULT = $$(APPLICATION_NAME_DEFAULT)
!isEmpty(APPLICATION_NAME_DEFAULT){
DEFINES += "APPLICATION_NAME_DEFAULT=$${APPLICATION_NAME_DEFAULT}"
}
OO_BUILD_BRANDING = $$(OO_BRANDING)
OO_DESTDIR_BUILD_OVERRIDE = $$(DESTDIR_BUILD_OVERRIDE)
@ -31,6 +39,8 @@ win32 {
CURRENT_YEAR = $$system(date +%Y)
}
DEFINES += COPYRIGHT_YEAR=$${CURRENT_YEAR}
QMAKE_TARGET_COMPANY = $$PUBLISHER_NAME
QMAKE_TARGET_COPYRIGHT = Copyright (C) $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved
@ -560,3 +570,7 @@ ADD_INC_PATH = $$(ADDITIONAL_INCLUDE_PATH)
CONFIG += warn_off
}
}
!disable_precompiled_header {
CONFIG += precompile_header
}

View File

@ -68,6 +68,9 @@ public:
inline void close() override {
std::fstream::close();
}
inline bool isError() override {
return (std::fstream::bad() || std::fstream::fail());
}
};
}

View File

@ -48,6 +48,7 @@ namespace CFCPP
virtual void write (const char* buffer, _INT64 len) = 0;
virtual void flush() = 0;
virtual void close() = 0;
virtual bool isError() = 0;
};
using Stream = std::shared_ptr<IStream>;

View File

@ -67,9 +67,9 @@ std::shared_ptr<CFStorage> CompoundFile::RootStorage()
{
return _impl->RootStorage();
}
void CompoundFile::Save(std::wstring wFileName)
bool CompoundFile::Save(std::wstring wFileName)
{
_impl->Save(wFileName);
return _impl->Save(wFileName);
}
void CompoundFile::Save(Stream stream)
{
@ -316,15 +316,23 @@ void CompoundFile_impl::Load(Stream stream)
}
}
void CompoundFile_impl::Save(std::wstring wFileName)
{
if (isDisposed)
throw CFException("Compound File closed: cannot save data");
bool CompoundFile_impl::Save(std::wstring wFileName)
{
if (isDisposed)
{
//throw CFException("Compound File closed: cannot save data");
return false;
}
Stream file = OpenFileStream(wFileName, true, true);
file->seek(0, std::ios::beg);
try
if (!file) return false;
if (file->isError()) return false;
file->seek(0, std::ios::beg);
bool result = true;
try
{
Save(file);
@ -343,7 +351,9 @@ void CompoundFile_impl::Save(std::wstring wFileName)
file->close();
throw CFException("Error saving file [" + fileName + "]", ex);
result = false;
}
return result;
}

View File

@ -64,7 +64,7 @@ public:
std::shared_ptr<CFStorage> RootStorage();
void Save(std::wstring wFileName);
bool Save(std::wstring wFileName);
void Save(Stream stream);
void Commit(bool releaseMemory = false);

View File

@ -59,7 +59,7 @@ public:
// Main methods
std::shared_ptr<CFStorage> RootStorage();
void Save(std::wstring wFileName);
bool Save(std::wstring wFileName);
void Save(Stream stream);
void Commit(bool releaseMemory = false);

View File

@ -123,6 +123,14 @@ void StreamView::close()
if (std::dynamic_pointer_cast<std::iostream>(stream) != nullptr)
stream->close();
}
bool StreamView::isError()
{
if (std::dynamic_pointer_cast<std::iostream>(stream) == nullptr) return true;
if ((std::dynamic_pointer_cast<std::iostream>(stream))->bad()) return true;
if ((std::dynamic_pointer_cast<std::iostream>(stream))->fail()) return true;
return false;
}
_INT64 StreamView::read(char *buffer, _INT64 len)
{

View File

@ -46,14 +46,13 @@ public:
StreamView(const SVector<Sector> &sectorChain, _INT32 sectorSize, _INT64 length,
SList<Sector> &availableSectors, Stream stream, bool isFatStream = false);
_INT64 tell() override;
_INT64 seek(_INT64 offset, std::ios_base::seekdir mode = std::ios::beg) override;
_INT64 read(char *buffer, _INT64 count) override;
void write(const char *buffer, _INT64 count) override;
void flush() override {}
void close() override;
bool isError() override;
_INT64 getPosition() const;
void SetLength(_INT64 value);

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,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

@ -170,6 +170,64 @@ namespace agg
}
};
//=============================================================blender_rgba_src_over
template<class ColorT, class Order> struct blender_rgba_unpre
{
typedef ColorT color_type;
typedef Order order_type;
typedef typename color_type::value_type value_type;
typedef typename color_type::calc_type calc_type;
enum base_scale_e
{
base_shift = color_type::base_shift,
base_mask = color_type::base_mask
};
//--------------------------------------------------------------------
static AGG_INLINE void blend_pix(value_type* p,
unsigned cr, unsigned cg, unsigned cb,
unsigned alpha,
unsigned cover=0)
{
if (0 == alpha)
return;
calc_type r = p[Order::R];
calc_type g = p[Order::G];
calc_type b = p[Order::B];
calc_type a = p[Order::A];
if (a == base_mask)
{
p[Order::R] = (value_type)(((cr - r) * alpha + (r << base_shift)) >> base_shift);
p[Order::G] = (value_type)(((cg - g) * alpha + (g << base_shift)) >> base_shift);
p[Order::B] = (value_type)(((cb - b) * alpha + (b << base_shift)) >> base_shift);
p[Order::A] = (value_type)((alpha + a) - ((alpha * a + base_mask) >> base_shift));
return;
}
p[Order::A] = (value_type)((alpha + a) - ((alpha * a + base_mask) >> base_shift));
p[Order::R] = (value_type)((alpha * cr + a * r - ((a * r * alpha + base_mask) >> base_shift)) / p[Order::A]);
p[Order::G] = (value_type)((alpha * cg + a * g - ((a * g * alpha + base_mask) >> base_shift)) / p[Order::A]);
p[Order::B] = (value_type)((alpha * cb + a * b - ((a * b * alpha + base_mask) >> base_shift)) / p[Order::A]);
}
static AGG_INLINE void blend_pix_subpix(value_type* p,
unsigned cr, unsigned cg, unsigned cb,
unsigned* covers,
unsigned cover=0)
{
calc_type r = p[Order::R];
calc_type g = p[Order::G];
calc_type b = p[Order::B];
//calc_type a = p[Order::A];
p[Order::R] = (value_type)(((cr - r) * covers[Order::R] + (r << base_shift)) >> base_shift);
p[Order::G] = (value_type)(((cg - g) * covers[Order::G] + (g << base_shift)) >> base_shift);
p[Order::B] = (value_type)(((cb - b) * covers[Order::B] + (b << base_shift)) >> base_shift);
//p[Order::A] = (value_type)((alpha + a) - ((alpha * a + base_mask) >> base_shift));
}
};
//=========================================================blender_rgba_pre
template<class ColorT, class Order> struct blender_rgba_pre
{

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

@ -11,10 +11,11 @@ namespace agg
namespace svg
{
//---------------------------------------------------------------------------
template<class Blender=agg::blender_rgba<color_type, component_order>>
class frame_buffer_rgba
{
public:
typedef agg::blender_rgba<color_type, component_order> blender_type;
typedef Blender blender_type;
typedef agg::pixfmt_alpha_blend_rgba<blender_type, agg::rendering_buffer, pixel_type> pixfmt_type;
typedef agg::renderer_base<pixfmt_type> renderer_base_type;
typedef agg::renderer_scanline_aa_solid<renderer_base_type> renderer_solid_type;

View File

@ -414,8 +414,8 @@ int main(int argc, char** argv)
NSStringUtils::CStringBuilder oBuilderJS;
oBuilderJS.WriteString(L"[");
#define COUNT_FONTS_SCALE 5
double support_scales[COUNT_FONTS_SCALE] = { 1, 1.25, 1.5, 1.75, 2 };
#define COUNT_FONTS_SCALE 11
double support_scales[COUNT_FONTS_SCALE] = { 1, 1.25, 1.5, 1.75, 2, 2.5, 3, 3.5, 4, 4.5, 5 };
int nThemeIndex = 0;
for (std::vector<std::wstring>::iterator iter = arThemes.begin(); iter != arThemes.end(); iter++)

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

@ -35,12 +35,23 @@
#include <string>
#include "../../Common/kernel_config.h"
#define VALUE_STRINGIFY(d) L##d
#define VALUE_TO_STR(v) VALUE_STRINGIFY(v)
namespace NSSystemUtils
{
static const wchar_t* gc_EnvApplicationName = L"APPLICATION_NAME";
#ifndef APPLICATION_NAME_DEFAULT
static const wchar_t* gc_EnvApplicationNameDefault = L"ONLYOFFICE";
#else
static const wchar_t* gc_EnvApplicationNameDefault = VALUE_TO_STR(APPLICATION_NAME_DEFAULT);
#endif
static const wchar_t* gc_EnvCompanyName = L"COMPANY_NAME";
#ifndef COMPANY_NAME_DEFAULT
static const wchar_t* gc_EnvCompanyNameDefault = L"Ascensio System SIA Copyright (c) 2022";
#else
static const wchar_t* gc_EnvCompanyNameDefault = VALUE_TO_STR(COMPANY_NAME_DEFAULT);
#endif
static const wchar_t* gc_EnvMethodEncrypt = L"METHOD_CRYPT";
static const wchar_t* gc_EnvMethodEncryptDefault = L"Strong";
static const wchar_t* gc_EnvCreator = L"CREATOR";

View File

@ -5,18 +5,6 @@ TARGET = docbuilder
CONFIG += console
CONFIG -= app_bundle
PRODUCT_VERSION=$$(PRODUCT_VERSION)
BUILD_NUMBER=$$(BUILD_NUMBER)
isEmpty(PRODUCT_VERSION) {
BINARYVERSION = 0.0.0.0
}
else {
BINARYVERSION = $$(PRODUCT_VERSION).$$(BUILD_NUMBER)
}
DEFINES += INTVER=$$BINARYVERSION
TEMPLATE = app
CORE_ROOT_DIR = $$PWD/../../../../core

View File

@ -50,32 +50,32 @@ void parse_args(NSDoctRenderer::CDocBuilder* builder, int argc, wchar_t *argv[])
void parse_args(NSDoctRenderer::CDocBuilder* builder, int argc, char *argv[])
#endif
{
for (int i = 0; i < argc; ++i)
{
for (int i = 0; i < argc; ++i)
{
#ifdef WIN32
std::wstring sW(argv[i]);
std::string sParam = U_TO_UTF8(sW);
std::wstring sW(argv[i]);
std::string sParam = U_TO_UTF8(sW);
#else
std::string sParam(argv[i]);
std::string sParam(argv[i]);
#endif
if (sParam.find("--") == 0)
{
std::string::size_type _pos = sParam.find('=');
if (std::string::npos == _pos)
builder->SetProperty(sParam.c_str(), L"");
else
{
std::string sName = sParam.substr(0, _pos);
std::string sValue = sParam.substr(_pos + 1);
if (sParam.find("--") == 0)
{
std::string::size_type _pos = sParam.find('=');
if (std::string::npos == _pos)
builder->SetProperty(sParam.c_str(), L"");
else
{
std::string sName = sParam.substr(0, _pos);
std::string sValue = sParam.substr(_pos + 1);
std::wstring sValueW = UTF8_TO_U(sValue);
builder->SetProperty(sName.c_str(), sValueW.c_str());
}
}
else
continue;
}
std::wstring sValueW = UTF8_TO_U(sValue);
builder->SetProperty(sName.c_str(), sValueW.c_str());
}
}
else
continue;
}
}
#ifdef WIN32
@ -84,102 +84,84 @@ int wmain(int argc, wchar_t *argv[])
int main(int argc, char *argv[])
#endif
{
if (argc <= 0)
return 0;
if (argc <= 0)
return 0;
bool bIsHelp = false;
bool bIsFonts = false;
for (int i = 0; i < argc; ++i)
{
bool bIsHelp = false;
bool bIsFonts = false;
for (int i = 0; i < argc; ++i)
{
#ifdef WIN32
std::wstring sW(argv[i]);
std::string sParam(sW.begin(), sW.end());
std::wstring sW(argv[i]);
std::string sParam(sW.begin(), sW.end());
#else
std::string sParam(argv[i]);
std::string sParam(argv[i]);
#endif
if (sParam == "-v" || sParam == "-version")
{
std::cout << "v" VALUE(INTVER) << std::endl;
NSDoctRenderer::CDocBuilder oBuilder;
oBuilder.ExecuteCommand(L"checkL");
if (sParam == "-v" || sParam == "-version")
{
std::cout << "v" VALUE(INTVER) << std::endl;
NSDoctRenderer::CDocBuilder oBuilder;
oBuilder.ExecuteCommand(L"checkL");
char* sSdkVer = oBuilder.GetVersion();
if (NULL != sSdkVer)
{
std::string sSdkVerStd(sSdkVer);
std::cout << "sdk version: " << sSdkVerStd << std::endl;
delete [] sSdkVer;
}
char* sSdkVer = oBuilder.GetVersion();
if (NULL != sSdkVer)
{
std::string sSdkVerStd(sSdkVer);
std::cout << "sdk version: " << sSdkVerStd << std::endl;
delete [] sSdkVer;
}
return 0;
}
if (sParam == "-h" || sParam == "-help")
{
bIsHelp = true;
}
else if (sParam == "-f" || sParam == "-fonts")
{
bIsFonts = true;
}
}
return 0;
}
if (sParam == "-h" || sParam == "-help")
{
bIsHelp = true;
}
else if (sParam == "-f" || sParam == "-fonts")
{
bIsFonts = true;
}
}
if (bIsFonts)
{
NSDoctRenderer::CDocBuilder oBuilder;
parse_args(&oBuilder, argc, argv);
if (bIsFonts)
{
NSDoctRenderer::CDocBuilder oBuilder;
parse_args(&oBuilder, argc, argv);
oBuilder.ExecuteCommand(L"checkL");
return 0;
}
oBuilder.ExecuteCommand(L"checkL");
return 0;
}
if (argc < 2 || bIsHelp)
{
std::cout << "USAGE: documentbuilder \"path_to_script_file\"" << std::endl;
NSDoctRenderer::CDocBuilder oBuilder;
oBuilder.ExecuteCommand(L"checkL");
return 0;
}
if (argc < 2 || bIsHelp)
{
std::cout << "USAGE: documentbuilder \"path_to_script_file\"" << std::endl;
NSDoctRenderer::CDocBuilder oBuilder;
oBuilder.ExecuteCommand(L"checkL");
return 0;
}
#ifdef WIN32
std::wstring sBuildFile(argv[argc - 1]);
std::wstring sBuildFile(argv[argc - 1]);
#else
std::string sBuildFileA(argv[argc - 1]);
std::wstring sBuildFile = UTF8_TO_U(sBuildFileA);
std::string sBuildFileA(argv[argc - 1]);
std::wstring sBuildFile = UTF8_TO_U(sBuildFileA);
#endif
if (true)
{
NSDoctRenderer::CDocBuilder::Initialize(L"/home/mihail/main/build_tools/out/linux_64/onlyoffice/documentbuilder");
NSDoctRenderer::CDocBuilder oBuilder;
if (true)
{
NSDoctRenderer::CDocBuilder oBuilder;
// если отключена эта опция - то она отключится на parse_args
// если отключена эта опция - то она отключится на parse_args
oBuilder.SetProperty("--check-fonts", L"");
oBuilder.SetProperty("--cache-scripts", L"false");
oBuilder.SetTmpFolder(L"tmp");
//oBuilder.SetProperty("--use-doctrenderer-scheme", L"");
//oBuilder.SetProperty("--work-directory", L"builder");
parse_args(&oBuilder, argc - 1, argv);
parse_args(&oBuilder, argc - 1, argv);
// oBuilder.WriteData(L"result.log", L"Alert!", false);
// формируем документ SampleTetxt2.docx - с одним вырезанным из SampleDocument.docx абзаца
oBuilder.Run(sBuildFile.c_str());
// включаем вторую схему сохранения
oBuilder.SetProperty("--use-doctrenderer-scheme", L"");
// перекрашиваем абзац в красный цвет
oBuilder.Run(L"/home/mihail/script2.docbuilder");
// oBuilder.OpenFile(L"SampleText2.docx", L"");
// oBuilder.ExecuteCommand(L"var oParagraph = Api.GetDocument().GetElement(1);\n"
// L"oParagraph.SetColor(255, 0, 0);\n"
// L"\n");
// // сохраняем
// oBuilder.SaveFile(OFFICESTUDIO_FILE_DOCUMENT_DOCX, L"SampleText2.docx");
// oBuilder.CloseFile();
}
}
NSDoctRenderer::CDocBuilder::Dispose();
return 0;
NSDoctRenderer::CDocBuilder::Dispose();
return 0;
}

View File

@ -1,14 +1,17 @@
#ifndef VERSION_H
#define VERSION_H
#define VER_FILEVERSION 1,0,0,2
#define VER_FILEVERSION_STR "1.0.0.2\0"
#define VER_STRINGIFY(d) #d
#define TO_STR(v) VER_STRINGIFY(v)
#define VER_FILEVERSION WIN_INTVER
#define VER_FILEVERSION_STR TO_STR(WIN_INTVER)"\0"
#define VER_PRODUCTVERSION VER_FILEVERSION
#define VER_PRODUCTVERSION_STR "1.0\0"
#define VER_COMPANYNAME_STR "Ascensio System SIA\0"
#define VER_LEGALCOPYRIGHT_STR "Ascensio System SIA 2016\0"
#define VER_LEGALCOPYRIGHT_STR "Ascensio System SIA " TO_STR(COPYRIGHT_YEAR) "\0"
#define VER_COMPANYDOMAIN_STR "www.onlyoffice.com\0"
#define ABOUT_COPYRIGHT_STR VER_LEGALCOPYRIGHT_STR

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

@ -20,7 +20,7 @@
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{10124551-28B8-4CA0-8FBA-420CF9602CF3}</ProjectGuid>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>doctrendererwrapper</RootNamespace>
<ProjectName>docbuilder.net</ProjectName>

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();
}

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