Compare commits

..

179 Commits

Author SHA1 Message Date
3d7638c3cc Merge branch hotfix/v8.3.1 into master 2025-02-27 13:17:57 +00:00
dd60367d01 Fix building fonts module 2025-02-27 11:18:24 +03:00
54bbbbc3d7 Merge pull request 'fix bug #73349' (#241) from fix/bug73349 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/241
2025-02-26 19:29:42 +00:00
9b901f7834 fix bug #73349 2025-02-26 17:56:41 +03:00
4f59af17b8 Fix bug 72130 2025-02-26 15:08:48 +03:00
b9258429f6 Merge pull request 'Fix bug #73343' (#240) from fix/bug73343 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/240
2025-02-25 15:20:32 +00:00
e8f2c55ad4 Merge pull request 'Fix bug #72788' (#239) from fix/bug72788 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/239
2025-02-25 15:20:12 +00:00
46f6ba4d0a Fix for subsystem python module 2025-02-25 16:55:32 +03:00
09b55bd1f1 Merge pull request 'Fix bug 71688' (#238) from fix/bug-71688 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/238
2025-02-24 13:29:36 +00:00
176053e8d8 Fix bug 71688 2025-02-24 16:16:51 +03:00
01365f938c Fix bug 73299 2025-02-24 15:09:43 +03:00
d168e4594f Fix bug #73343 2025-02-24 17:09:36 +05:00
0c9fa4709f Merge branch release/v8.3.0 into master 2025-02-24 09:08:09 +00:00
27d2e40da7 Merge pull request 'fix bug #73336' (#237) from fix/bug73336 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/237
2025-02-24 09:00:39 +00:00
14b09ce582 fix bug #73336 2025-02-24 11:49:41 +03:00
aeeab690b1 Fix builder bugs. Recteate context with snapshots if needed. 2025-02-24 01:10:39 +03:00
016a0a971b Fix bug #72788 2025-02-20 20:28:22 +05:00
afe55a456f Merge branch 'fix/bug70671' into hotfix/v8.3.1 2025-02-19 18:06:22 +03:00
efc1149235 Merge pull request 'Fix bug #70575' (#236) from fix/bug70575 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/236
2025-02-19 14:58:17 +00:00
567cc14bc7 Merge pull request 'Fix bug #72790' (#232) from fix/bug72790 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/232
2025-02-19 12:51:51 +00:00
2c27cfc720 . 2025-02-19 15:32:12 +03:00
1d31e5836b fix fileFormatChecker 2025-02-18 20:23:49 +03:00
6adf65d3a8 fix bug #73221 2025-02-18 09:51:43 +03:00
093e1348fa Merge pull request 'Fix bug #71975' (#235) from fix/bug71975 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/235
2025-02-17 13:40:22 +00:00
b78157487a Merge pull request 'Fix bug #73238' (#233) from fix/bug73238 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/233
2025-02-17 13:37:03 +00:00
77b30109f0 Merge remote-tracking branch 'origin/hotfix/v8.3.1' into fix/bug71975 2025-02-17 18:33:19 +05:00
efd047be74 Fix bug #71975 2025-02-17 18:27:48 +05:00
61abfdb272 Merge pull request 'Fix bugs 73220, 73178' (#234) from fix/bug-73220 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/234
2025-02-17 11:16:05 +00:00
f5088f43d8 Fix bug 73178 2025-02-17 14:10:38 +03:00
6b3c395220 Fix bug 73220 2025-02-17 13:44:01 +03:00
67cb29652d Fix bug #73238 2025-02-15 17:41:26 +05:00
d0cb082b33 Fix bug #72790 2025-02-15 12:53:35 +05:00
2eff67efc3 Merge pull request 'Fix bug #73222' (#231) from fix/bug73222 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/231
2025-02-14 12:09:16 +00:00
84416ef5b6 Merge pull request 'Fix bug #72871' (#230) from fix/bug72871 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/230
2025-02-14 12:08:56 +00:00
447ade207f Fix bug #73222 2025-02-14 13:56:53 +05:00
ddd7628bbe fix bug #73097 2025-02-13 17:48:33 +03:00
1f86b0265a Fix bug #72871 2025-02-13 18:20:31 +05:00
e484db496b . 2025-02-13 15:14:51 +03:00
5bc1c8d860 fix bug #73215 2025-02-13 15:12:58 +03:00
dbdf4bd120 Merge pull request 'Fix Metafile conversion' (#228) from fix/bugs-metafile into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/228
2025-02-13 09:59:40 +00:00
a93db0e012 . 2025-02-12 18:15:00 +03:00
f145378002 fix additional sdtPr 2025-02-12 15:35:26 +03:00
8098fec345 Merge pull request 'Fix bug #72825' (#227) from fix/bug72825 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/227
2025-02-11 18:11:08 +00:00
7bfcea0fff Merge pull request 'Fix bug #72875' (#226) from fix/bug72875 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/226
2025-02-11 18:10:41 +00:00
4b4845c558 Merge pull request 'Fix bug #72414' (#225) from fix/bug72414 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/225
2025-02-11 18:10:03 +00:00
b26e3e2fee Merge pull request 'fix/bug70675' (#224) from fix/bug70675 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/224
2025-02-11 18:09:33 +00:00
388951670c Merge pull request 'Fix bug #72790' (#223) from fix/bug72790 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/223
2025-02-11 18:08:55 +00:00
7d3488abc9 Merge pull request 'fix/bug-68408' (#229) from fix/bug-68408 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/229
2025-02-11 11:10:20 +00:00
fea3910254 adding reading attributes 2025-02-11 13:22:50 +03:00
2d58b08f0f Merge pull request 'PDF MovePage' (#222) from fix/pre8.3.1 into hotfix/v8.3.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/222
2025-02-11 09:06:33 +00:00
612142f0ae Refactoring 2025-02-11 11:24:08 +03:00
2a0c84513b For bug #72962 2025-02-11 11:24:07 +03:00
b7d3464609 Edited default mode ShapeRendering for metafile to svg conversion 2025-02-11 11:24:07 +03:00
beb8574dfd Fix bug #72962 2025-02-11 11:24:07 +03:00
c22cc89ef0 Merge remote-tracking branch 'origin/release/v8.3.0' into fix/bug71975 2025-02-11 13:10:43 +05:00
58255093bf Fix bug #70575 2025-02-11 05:49:33 +05:00
50846677d5 Add missed files 2025-02-10 13:30:46 +03:00
3b450306f1 Merge branch 'hotfix/v8.3.1' of git.onlyoffice.com:ONLYOFFICE/core into hotfix/v8.3.1 2025-02-10 12:07:58 +03:00
c67ec5f632 Add missed file 2025-02-10 11:20:06 +03:00
62450ee1fb add additional props sdt 2025-02-10 10:46:34 +03:00
ad301b6f50 Merge branch 'feature/docbuilder-license' into hotfix/v8.3.1 2025-02-09 00:46:23 +03:00
d251682639 Refactoring 2025-02-09 00:32:48 +03:00
896427db83 For bug 72964 2025-02-08 21:59:52 +03:00
e03f02103b For bug #70575 2025-02-07 18:22:26 +05:00
27c7920def Fix actual pos MovePage 2025-02-07 13:02:22 +03:00
a1b0421ec1 Fix MovePage 2025-02-07 13:02:21 +03:00
b7972ea391 Create MovePage 2025-02-07 13:02:21 +03:00
17840c5ed7 for bug #68408 2025-02-06 16:58:59 +03:00
ff4726e6ec for bug #68408 2025-02-06 15:53:53 +03:00
4e9cd74367 for bug #68408 2025-02-06 15:52:02 +03:00
b8737d2474 for bug #68408 2025-02-06 15:50:15 +03:00
2f4b7442c7 Fix CJSContext::GetCurrent method for jsc version 2025-02-06 12:44:39 +03:00
d97d2668d2 Merge branch release/v8.3.0 into master 2025-02-05 17:15:43 +00:00
45da53e9ae Refactoring standarttester 2025-02-04 20:12:07 +03:00
618a7ea09e Merge remote-tracking branch 'origin/release/v8.3.0' into fix/bug70675 2025-02-04 17:19:00 +05:00
a33743cff2 fix bug #73052 2025-02-04 13:44:41 +06:00
a83e19cbdf fix bug #72176 2025-02-03 16:35:23 +00:00
8a991ae24a Merge pull request 'Fix bug #72857' (#208) from fix/bug72857 into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/208
2025-02-03 14:35:21 +00:00
6caca87b64 Merge pull request 'For bug #72496' (#207) from fix/bug72496 into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/207
2025-02-03 14:35:10 +00:00
9ab884ae24 Merge pull request 'Fix hwp conversion' (#217) from fix/hwp into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/217
2025-02-03 14:15:54 +00:00
e493d976e3 Fix bug #73036 2025-02-03 16:59:47 +03:00
d75e7342cf Fix bug #73042 2025-02-03 15:45:09 +03:00
ddd750be9c Merge pull request 'Fix write base fonts' (#216) from fix/pdf-standart-fonts into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/216
2025-02-03 12:40:28 +00:00
79a4434583 Fix bug #73040 2025-02-03 15:35:39 +03:00
44ff2aff3c Fix empty FreeText AP 2025-02-03 15:32:41 +03:00
2f4b3e41b3 Fix write base fonts 2025-02-03 15:24:08 +03:00
fe208f5243 Merge pull request 'Fix bug #72961' (#215) from fix/bug-72961 into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/215
2025-02-03 11:15:35 +00:00
e41c1d9703 Fix bug #72961 2025-02-03 14:12:29 +03:00
1cb56e532c Fix bug #72790 2025-02-03 15:39:18 +05:00
5c5f98a6e3 Fix bug 73014 2025-02-03 10:45:38 +03:00
f9dd82ad47 Merge pull request 'Fix HWP conversion' (#211) from fix/hwp into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/211
2025-02-03 06:43:31 +00:00
084c8f4b94 Fix bug #72999 2025-02-03 07:17:39 +03:00
bf15325a9e Fix bug #73000 2025-02-03 05:25:55 +03:00
1b50b3a53a Fix bug 72868 2025-02-01 17:39:08 +03:00
70b40c46d2 Fix bug #72721 2025-02-01 11:36:52 +03:00
23798f3c96 Fix ios build 2025-01-31 17:14:07 +03:00
1e8d22080d Merge pull request 'Fix hwp bugs' (#209) from fix/hwp into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/209
2025-01-31 05:08:55 +00:00
90bcd47fb7 The conversion of the character spacing to hwp has been removed 2025-01-31 03:15:19 +03:00
c1adf0b30c Fix bug #72685 2025-01-31 03:15:12 +03:00
b65ed1ccb4 Fix bug #72825 2025-01-31 03:40:47 +05:00
8e4bbb5e27 Fix bug #72875 2025-01-30 22:13:22 +05:00
81a4d9ccd0 Fix bug 72936 2025-01-30 16:51:25 +03:00
a97014c173 Disable use filesystem in metafiles (js module) 2025-01-30 14:26:57 +03:00
b3951d083a Fix elements align in html conversion 2025-01-30 10:37:42 +00:00
7d78b37540 Fix bug #72932 2025-01-30 10:37:42 +00:00
ff162d451e Merge pull request 'Fix hwp bug' (#205) from fix/hwp into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/205
2025-01-30 10:33:13 +00:00
5dc6402006 Fix test file 2025-01-30 13:12:27 +03:00
fae17d9bfc Merge pull request 'For bug #72694' (#204) from fix/bug72694 into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/204
2025-01-30 08:02:28 +00:00
931f4edae4 For bug #72694 2025-01-30 13:36:42 +06:00
3609cf1237 Fix bug #72933 2025-01-30 00:49:49 +03:00
cc8fa641aa Merge pull request 'Fix bug 72811' (#203) from fix/bug-72811 into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/203
2025-01-29 16:20:19 +00:00
3b9a865d77 Fix bug 72811 2025-01-29 19:07:58 +03:00
f3b0a992bd Fix typo 2025-01-29 18:57:35 +03:00
74f3e7f279 Merge pull request 'Fix hwp conversion' (#202) from fix/hwp into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/202
2025-01-29 15:45:08 +00:00
d195aa4a79 Fix build 2025-01-29 18:31:12 +03:00
4a384edf08 For bug #72496 2025-01-29 20:23:33 +05:00
30f96cbc6c Fix bug #72705 2025-01-29 18:15:29 +03:00
007362d8be Fix bug #72780 2025-01-29 17:57:54 +03:00
f4aac048ea fix bug #72012 2025-01-29 17:44:17 +03:00
f815fec8ed Fix bug #72714 2025-01-29 17:14:53 +03:00
4ec217226d Fix bug #72721 2025-01-29 16:32:43 +03:00
3cef41e876 Added bookmark conversion, fix bugs, refactoring in hwp format 2025-01-29 16:22:03 +03:00
20bff1d6fe for bug #72794 2025-01-29 11:17:21 +00:00
8da1a109de Fix bug #72857 2025-01-29 02:28:47 +05:00
704cef604e fix bug #72496 2025-01-28 19:26:15 +03:00
3c850e2086 Fix bug #72667 2025-01-28 13:47:20 +00:00
ab660cb8a3 Merge pull request 'for bug #72496' (#198) from For/bug72496 into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/198
2025-01-28 13:12:05 +00:00
af4343b1d8 for bug #72496 2025-01-28 16:06:39 +03:00
7e4fe558f4 Fix bug #72847 2025-01-28 15:17:08 +03:00
f942e56361 fix namespaces 2025-01-28 13:46:28 +03:00
8b85f6987f Merge pull request 'Fix bug #72839' (#197) from fix/bug-72839 into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/197
2025-01-28 09:13:21 +00:00
cbe412d3c7 Fix bug #72839 2025-01-28 12:03:31 +03:00
6913cae8f3 Fix bug #72414 2025-01-28 06:09:12 +05:00
d3d9c8df94 Added text indent in hwp conversion 2025-01-27 22:14:25 +03:00
01b582c4b9 Added BorderFill in hwp conversion 2025-01-27 22:01:41 +03:00
4568144a22 Merge branch 'fix/bug72794' into release/v8.3.0 2025-01-27 20:38:15 +03:00
cc4df3726a fix bug #72745 2025-01-27 20:37:02 +03:00
696610862a . 2025-01-27 18:27:20 +03:00
da6a5e9e98 for binary 2025-01-27 15:30:56 +03:00
d395e63b80 Merge pull request 'Fix bug #72657' (#188) from fix/bug72657 into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/188
2025-01-27 12:30:02 +00:00
0350675df6 Fix min version 2025-01-27 13:58:30 +03:00
aead2e9fb8 Merge pull request 'Fix bug#72779' (#196) from fix/bug72779 into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/196
2025-01-27 10:03:20 +00:00
d12bad7bd1 Fix bug#72779 2025-01-27 15:58:25 +06:00
da2284fff6 Fix bug #72712 2025-01-26 18:26:03 +00:00
1382aa0b3d Fix bug #72780 2025-01-26 18:26:03 +00:00
8ba5df60d9 Fix bug #72705 2025-01-26 18:26:03 +00:00
5299872b17 Fixes for snapshots 2025-01-26 20:18:14 +03:00
e1757dd5d1 fix bug #72796 2025-01-26 12:10:44 +03:00
b5c5a5f1ed Fix bug #72781 2025-01-25 17:56:11 +00:00
6979e17c3d Added polygon and curve conversion in hwp format 2025-01-25 17:56:11 +00:00
c43fb92860 Fixed the correction of large text size in svg 2025-01-25 18:27:22 +03:00
63887c95b6 Use wmf&emf instead conversion to svg in zip images (for native convertations) 2025-01-25 13:39:35 +03:00
d3d4e86925 Merge pull request 'Fix bug #72365' (#179) from fix/bug72365 into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/179
2025-01-25 09:25:56 +00:00
f6383571eb fix bug #72794 2025-01-25 12:18:30 +03:00
a6f6a67aed Fix prev commit 2025-01-24 23:30:51 +03:00
f9543ef9de Year Up 2025-01-24 23:03:42 +03:00
bb58be4f18 Add new method for images inside zip 2025-01-24 22:51:04 +03:00
40efe7dabc Fix build 2025-01-24 18:10:29 +00:00
80b7caaf7a Fix bug #72721 2025-01-24 18:10:29 +00:00
08e3dfb061 Fix bug #72772 2025-01-24 18:10:29 +00:00
3a9d91b291 Fix bug #72719 2025-01-24 18:10:29 +00:00
45b26554b2 Merge pull request 'Fix bug #72175' (#191) from fix/bug72175 into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/191
2025-01-24 16:19:30 +00:00
09c4df8e05 Fix remove AP when transform 2025-01-24 17:53:23 +03:00
85533a6553 fix bug #72768 2025-01-24 17:35:53 +03:00
65898a94ad Merge pull request 'Fix hwp bugs' (#187) from fix/hwp into release/v8.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/187
2025-01-24 11:31:39 +00:00
86009ff6fa Fix bug #72175 2025-01-24 12:46:02 +03:00
b91dfb075e Fix bug #72657 2025-01-24 13:42:37 +06:00
f057a16bc1 Fix bug #72700 2025-01-24 04:32:32 +03:00
bd76adc97f Fix bug #72714 2025-01-23 23:36:47 +03:00
27b5dbf15e Fix bad conversion hwp to ooxml 2025-01-23 23:08:52 +03:00
7c2105b613 Fix bug #72365 2025-01-15 22:13:04 +05:00
6fe92e1725 Fix table header columns conversion 2024-12-20 17:58:52 +05:00
a1ebcaea23 Merge branch hotfix/v8.2.2 into develop 2024-12-09 12:00:03 +00:00
8489127f71 Merge pull request 'release/v8.3.0' (#114) from release/v8.3.0 into develop
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/114
2024-12-04 11:00:36 +00:00
87b5ae8f75 Merge branch hotfix/v8.2.2 into master 2024-11-28 12:16:10 +00:00
6b21323e8c Merge branch hotfix/v8.2.1 into master 2024-11-22 10:46:53 +00:00
d21d0caa68 Fix bug #70675 2024-10-16 18:42:07 +05:00
63bf1797c0 Fix bug #70671 2024-10-14 17:57:28 +05:00
f8ba0c59a6 Add license check for onlyoffice docbuilder builds 2024-09-25 16:04:17 +04:00
195 changed files with 3555 additions and 1369 deletions

View File

@ -316,7 +316,7 @@ namespace NSCSS
std::wstring wsTextAlign{oStyle.m_oText.GetAlign().ToWString()};
if (wsTextAlign.empty() && bInTable)
if (wsTextAlign.empty())
wsTextAlign = oStyle.m_oDisplay.GetHAlign().ToWString();
oXmlElement.AddPropertiesInP(PProperties::P_Jc, wsTextAlign);

View File

@ -68,6 +68,7 @@ public:
bool isOOXFormatFile(const std::wstring& fileName, bool unpacked = false);
bool isOpenOfficeFormatFile(const std::wstring& fileName, std::wstring& documentID);
bool isOnlyOfficeFormatFile(const std::wstring& fileName);
bool isMacFormatFile(const std::wstring& fileName);
bool isDocFormatFile(const std::wstring& fileName);
bool isXlsFormatFile(const std::wstring& fileName);
@ -80,6 +81,7 @@ public:
bool isMS_MITCRYPTOFormatFile(POLE::Storage* storage, std::wstring& documentID);
bool isVbaProjectFile(POLE::Storage* storage);
bool isMS_OFFCRYPTOFormatFile(const std::wstring& fileName, std::wstring& documentID);
bool isHwpFile(POLE::Storage* storage);
bool iXmlFile(const std::wstring& fileName);

View File

@ -451,6 +451,20 @@ bool COfficeFileFormatChecker::isVbaProjectFile(POLE::Storage *storage)
}
return true;
}
bool COfficeFileFormatChecker::isHwpFile(POLE::Storage* storage)
{
if (storage == NULL)
return false;
unsigned char buffer[10];
POLE::Stream stream(storage, L"BodyText/Section0");
if (stream.read(buffer, 10) < 1)
{
return false;
}
return true;
}
bool COfficeFileFormatChecker::isXlsFormatFile(POLE::Storage *storage)
{
if (storage == NULL)
@ -721,6 +735,11 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_VBAPROJECT;
return true;
}
else if (isHwpFile(&storage))
{
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
return true;
}
}
NSFile::CFileBinary file;
if (!file.OpenFile(fileName))
@ -767,6 +786,13 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
bufferDetect = NULL;
return true;
}
else if (isMacFormatFile(fileName))
{
if (bufferDetect)
delete[] bufferDetect;
bufferDetect = NULL;
return true;
}
}
//-----------------------------------------------------------------------------------------------
@ -1133,6 +1159,58 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring &fileNa
}
return false;
}
bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName)
{
COfficeUtils OfficeUtils(NULL);
ULONG nBufferSize = 0;
BYTE* pBuffer = NULL;
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Document.iwa", &pBuffer, nBufferSize);
if (hresult == S_OK && pBuffer != NULL)
{
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
delete[] pBuffer;
pBuffer = NULL;
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Slide.iwa", &pBuffer, nBufferSize);
if (hresult == S_OK && pBuffer != NULL)
{
delete[] pBuffer;
pBuffer = NULL;
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
return true;
}
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Tables/DataList.iwa", &pBuffer, nBufferSize);
if (hresult == S_OK && pBuffer != NULL)
{
delete[] pBuffer;
pBuffer = NULL;
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
return true;
}
std::wstring::size_type nExtPos = fileName.rfind(L'.');
std::wstring sExt = L"unknown";
if (nExtPos != std::wstring::npos)
sExt = fileName.substr(nExtPos);
std::transform(sExt.begin(), sExt.end(), sExt.begin(), tolower);
if (0 == sExt.compare(L".pages"))
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
else if (0 == sExt.compare(L".numbers"))
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
else if (0 == sExt.compare(L".key"))
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
return true;
}
return false;
}
bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring &fileName, std::wstring &documentID)
{
documentID.clear();

View File

@ -0,0 +1,60 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef DOC_BUILDER_ADDON_PRIVATE
#define DOC_BUILDER_ADDON_PRIVATE
#include <string>
namespace NSDoctRenderer
{
class CDocBuilderAddon
{
private:
std::wstring m_sWorkDirectory;
public:
CDocBuilderAddon(const std::wstring& sWorkDir)
{
m_sWorkDirectory = sWorkDir;
}
public:
std::wstring GetX2tSaveAddon()
{
return L"";
}
int GetX2tPreSaveError()
{
return 0;
}
};
}
#endif // DOC_BUILDER_ADDON_PRIVATE

View File

@ -191,7 +191,7 @@ namespace NSDoctRenderer
m_strSdkPath = oNode.ReadNodeText(L"sdkjs");
if (!m_strSdkPath.empty())
{
if (!NSDirectory::Exists(m_strSdkPath))
if (0 == m_strSdkPath.find(L"./") || !NSDirectory::Exists(m_strSdkPath))
m_strSdkPath = sConfigDir + m_strSdkPath;
}

View File

@ -47,14 +47,6 @@ namespace NSDoctRenderer
RELEASEOBJECT(m_pInternal);
}
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params)
{
m_pInternal->m_nFileType = -1;
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
return m_pInternal->OpenFile(path, params);
}
int CDocBuilder::SaveFile(const int& type, const wchar_t* path, const wchar_t* params)
{
return m_pInternal->SaveFile(type, path, params);

View File

@ -526,6 +526,7 @@ namespace NSDoctRenderer
CDocBuilder_Private* m_pInternal;
friend class CBuilderDocumentEmbed;
friend class CBuilderEmbed;
};
/**

View File

@ -82,7 +82,7 @@ CV8RealTimeWorker::~CV8RealTimeWorker()
m_context->Dispose();
}
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue)
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContext)
{
LOGGER_SPEED_START();
@ -92,14 +92,20 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
std::string commandA = U_TO_UTF8(command);
//commandA = "Api." + commandA;
CJSContextScope scope(m_context);
if (isEnterContext)
m_context->Enter();
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
LOGGER_SPEED_LAP("compile_command");
JSSmart<CJSValue> retNativeVal = m_context->runScript(commandA, try_catch);
if(try_catch->Check())
{
if (isEnterContext)
m_context->Exit();
return false;
}
if (retValue)
{
@ -110,6 +116,9 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
LOGGER_SPEED_LAP("run_command");
if (isEnterContext)
m_context->Exit();
return true;
}
@ -240,6 +249,14 @@ bool CV8RealTimeWorker::InitVariables()
if (try_catch->Check())
return false;
}
if (!m_sJSCodeStart.empty())
{
m_context->runScript(m_sJSCodeStart, try_catch);
if (try_catch->Check())
return false;
}
return true;
}
@ -336,7 +353,17 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
return !bIsBreak;
}
bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams)
bool CV8RealTimeWorker::NewSimpleJSInstance()
{
return InitVariables();
}
bool CV8RealTimeWorker::IsSimpleJSInstance()
{
return (-1 == m_nFileType);
}
bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams, const bool& isEnterContext)
{
NSDoctRenderer::DoctRendererFormat::FormatFile _formatDst = NSDoctRenderer::DoctRendererFormat::DOCT;
if (type & AVS_OFFICESTUDIO_FILE_PRESENTATION)
@ -362,7 +389,9 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
}
}
CJSContextScope scope(m_context);
if (isEnterContext)
m_context->Enter();
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
NSNativeControl::CNativeControl* pNative = NULL;
@ -391,7 +420,7 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
bIsSilentMode = true;
if (bIsSilentMode)
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);");
this->ExecuteCommand(L"Api.asc_SetSilentMode(false);", NULL, isEnterContext);
std::wstring strError;
bool bIsError = Doct_renderer_SaveFile_ForBuilder(_formatDst,
@ -403,7 +432,10 @@ bool CV8RealTimeWorker::SaveFileWithChanges(int type, const std::wstring& _path,
sJsonParams);
if (bIsSilentMode)
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);");
this->ExecuteCommand(L"Api.asc_SetSilentMode(true);", NULL, isEnterContext);
if (isEnterContext)
m_context->Exit();
return bIsError;
}
@ -1231,8 +1263,29 @@ namespace NSDoctRenderer
nCount = nIndex;
}
int CDocBuilder::OpenFile(const wchar_t* path, const wchar_t* params)
{
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
{
m_pInternal->m_bIsOpenedFromSimpleJS = false;
return true;
}
m_pInternal->m_nFileType = -1;
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
return m_pInternal->OpenFile(path, params);
}
bool CDocBuilder::CreateFile(const int& type)
{
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
{
m_pInternal->m_bIsOpenedFromSimpleJS = false;
return true;
}
m_pInternal->m_nFileType = -1;
if (!NSDirectory::Exists(m_pInternal->m_sTmpFolder))
NSDirectory::CreateDirectory(m_pInternal->m_sTmpFolder);
@ -1391,7 +1444,7 @@ namespace NSDoctRenderer
if (!sJsCommands.empty())
{
std::wstring sUnicodeCommand = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sJsCommands.c_str(), (LONG)sJsCommands.length());
bIsNoError = this->ExecuteCommand(sUnicodeCommand.c_str());
bIsNoError = this->m_pInternal->ExecuteCommand(sUnicodeCommand.c_str(), NULL, bIsBuilderJSCloseFile);
sJsCommands = "";
if (!bIsNoError)
return false;
@ -1413,6 +1466,10 @@ namespace NSDoctRenderer
if (0 == _builder_params[nCheckParam].find(L"jsValue(") && _builder_params[nCheckParam].length() > 9)
{
std::wstring sParam = _builder_params[nCheckParam].substr(8, _builder_params[nCheckParam].length() - 9);
if (NULL == m_pInternal->m_pWorker)
m_pInternal->CheckWorker();
_builder_params[nCheckParam] = m_pInternal->m_pWorker->GetJSVariable(sParam);
}
}
@ -1478,7 +1535,7 @@ namespace NSDoctRenderer
{
// Такого быть не должно!!! Так как результат никуда не сохранится. пустое действие.
std::wstring sUnicodeCommand = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sJsCommands.c_str(), (LONG)sJsCommands.length());
bool bIsNoError = this->ExecuteCommand(sUnicodeCommand.c_str());
bool bIsNoError = this->m_pInternal->ExecuteCommand(sUnicodeCommand.c_str(), NULL, true);
sJsCommands = "";
if (!bIsNoError)
return false;

View File

@ -63,6 +63,8 @@
#include "../common/ProcessEnv.h"
#include "docbuilder_addon.h"
#ifdef CreateFile
#undef CreateFile
#endif
@ -422,6 +424,7 @@ public:
int m_nFileType;
std::string m_sUtf8ArgumentJSON;
std::string m_sGlobalVariable;
std::string m_sJSCodeStart;
CJSContextData m_oContextData;
@ -434,14 +437,17 @@ public:
static void _LOGGING_ERROR_(const std::wstring& strType, const std::wstring& strError);
bool ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue = NULL);
bool ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue = NULL, const bool& isEnterContext = true);
std::string GetGlobalVariable();
std::wstring GetJSVariable(std::wstring sParam);
bool OpenFile(const std::wstring& sBasePath, const std::wstring& path, const NSDoctRenderer::DoctRendererEditorType& editorType, NSDoctRenderer::CDoctRendererConfig* config, CV8Params* pParams = NULL);
bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L"");
bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L"", const bool& isEnterContext = true);
bool InitVariables();
bool NewSimpleJSInstance();
bool IsSimpleJSInstance();
};
namespace NSDoctRenderer
@ -455,7 +461,8 @@ namespace NSDoctRenderer
std::wstring m_sTmpFolder;
std::wstring m_sFileDir;
int m_nFileType;
bool m_bJavascriptBeforeEditor;
std::wstring m_sCommandsBeforeContextCreated;
std::wstring m_sX2tPath;
@ -474,11 +481,13 @@ namespace NSDoctRenderer
NSDoctRenderer::CDocBuilder* m_pParent;
bool m_bIsOpenedFromSimpleJS;
static std::wstring m_sExternalDirectory;
public:
CDocBuilder_Private() : CDoctRendererConfig(), m_sTmpFolder(NSFile::CFileBinary::GetTempPath()), m_nFileType(-1),
m_pWorker(NULL), m_pAdditionalData(NULL), m_bIsInit(false), m_bIsServerSafeVersion(false),
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_bJavascriptBeforeEditor(false)
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_sCommandsBeforeContextCreated(L""), m_bIsOpenedFromSimpleJS(false)
{
}
@ -637,10 +646,14 @@ namespace NSDoctRenderer
{
NSDirectory::CreateDirectory(m_sFileDir + L"/media");
NSDirectory::CreateDirectory(m_sFileDir + L"/changes");
}
if (m_bJavascriptBeforeEditor)
CheckWorkerAfterOpen();
if (m_pWorker && m_pWorker->IsSimpleJSInstance() && !m_bIsOpenedFromSimpleJS)
{
RELEASEOBJECT(m_pWorker);
CheckWorker();
}
return bRet;
}
return bRet;
#else
@ -931,8 +944,11 @@ namespace NSDoctRenderer
if (0 == nReturnCode)
{
if (m_bJavascriptBeforeEditor)
CheckWorkerAfterOpen();
if (m_pWorker && m_pWorker->IsSimpleJSInstance() && !m_bIsOpenedFromSimpleJS)
{
RELEASEOBJECT(m_pWorker);
CheckWorker();
}
return 0;
}
@ -981,10 +997,16 @@ namespace NSDoctRenderer
return _path;
}
int SaveFile(const int& type, const std::wstring& path, const wchar_t* params = NULL)
int SaveFile(const int& type, const std::wstring& path, const wchar_t* params = NULL, const bool& isEnterContext = true)
{
Init();
CDocBuilderAddon oSaveAddon(m_sX2tPath);
int nPreSaveError = oSaveAddon.GetX2tPreSaveError();
if (0 != nPreSaveError)
return nPreSaveError;
if (-1 == m_nFileType)
{
CV8RealTimeWorker::_LOGGING_ERROR_(L"error (save)", L"file not opened!");
@ -1023,7 +1045,7 @@ namespace NSDoctRenderer
}
}
this->m_pWorker->SaveFileWithChanges(type, m_sFileDir + L"/Editor2.bin", sJsonParams);
this->m_pWorker->SaveFileWithChanges(type, m_sFileDir + L"/Editor2.bin", sJsonParams, isEnterContext);
sFileBin = L"/Editor2.bin";
}
@ -1068,6 +1090,8 @@ namespace NSDoctRenderer
if (!sOptions.empty())
oBuilder.WriteString(UTF8_TO_U(sOptions));
oBuilder.WriteString(oSaveAddon.GetX2tSaveAddon());
oBuilder.WriteString(L"</TaskQueueDataConvert>");
std::wstring sXmlConvert = oBuilder.GetData();
@ -1220,62 +1244,75 @@ namespace NSDoctRenderer
{
if (NULL == m_pWorker)
{
m_pWorker = new CV8RealTimeWorker(m_pParent, GetEditorType(), this);
NSDoctRenderer::DoctRendererEditorType editorType = GetEditorType();
m_pWorker = new CV8RealTimeWorker(m_pParent, editorType, this);
m_pWorker->m_sUtf8ArgumentJSON = m_oParams.m_sArgumentJSON;
m_pWorker->m_sGlobalVariable = m_sGlobalVariable;
m_pWorker->m_sJSCodeStart = U_TO_UTF8(m_sCommandsBeforeContextCreated);
return CheckWorkerAfterOpen();
m_pWorker->m_nFileType = m_nFileType;
if (-1 != m_nFileType)
m_sCommandsBeforeContextCreated = L"";
else
{
m_pWorker->NewSimpleJSInstance();
return true;
}
CV8Params oParams;
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
oParams.DocumentDirectory = m_sFileDir;
return m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, editorType, this, &oParams);
}
return true;
}
bool CheckWorkerAfterOpen()
{
if (!m_pWorker)
return false;
m_pWorker->m_nFileType = m_nFileType;
if (-1 == m_nFileType)
{
m_bJavascriptBeforeEditor = true;
return false;
}
m_bJavascriptBeforeEditor = false;
CV8Params oParams;
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
oParams.DocumentDirectory = m_sFileDir;
return m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, GetEditorType(), this, &oParams);
}
int SaveFile(const std::wstring& ext, const std::wstring& path, const wchar_t* params = NULL)
{
int nType = GetFormatByTexExtention(ext);
return SaveFile(nType, path, params);
}
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL)
bool ExecuteCommand(const std::wstring& command, CDocBuilderValue* retValue = NULL, const bool& forceExecute = false)
{
if (command.length() < 7 && !retValue) // minimum command (!!!)
return true;
if (m_nFileType == -1 && !forceExecute)
{
m_sCommandsBeforeContextCreated += command;
return true;
}
Init();
bool bRes = CheckWorker();
if (CheckWorker())
{
bool bIsOpenedFromSimpleJSOld = m_bIsOpenedFromSimpleJS;
bool bResult = m_pWorker->ExecuteCommand(command, retValue);
if (!bResult && !bIsOpenedFromSimpleJSOld && m_bIsOpenedFromSimpleJS)
{
RELEASEOBJECT(m_pWorker);
CheckWorker();
return m_pWorker->ExecuteCommand(command, retValue);
}
else
{
return bResult;
}
}
if (!bRes && m_pWorker && m_bJavascriptBeforeEditor)
m_pWorker->InitVariables();
return m_pWorker->ExecuteCommand(command, retValue);
return false;
}
CDocBuilderContext GetContext(bool enterContext)
{
CDocBuilderContext ctx;
CheckWorker();
if (!CheckWorker())
return ctx;
ctx.m_internal->m_context = m_pWorker->m_context;
ctx.m_internal->m_context_data = &m_pWorker->m_oContextData;

View File

@ -0,0 +1,130 @@
QT -= core
QT -= gui
VERSION = 1.0.0.3
TARGET = doctrenderer
TEMPLATE = lib
CONFIG += shared
CONFIG += plugin
CORE_ROOT_DIR = $$PWD/../..
PWD_ROOT_DIR = $$PWD
PWD_CUR = $$PWD
include($$PWD_CUR/../../Common/base.pri)
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
DEFINES += JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
#CONFIG += build_xp
#CONFIG += v8_version_60
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
HEADERS += \
$$PWD_CUR/config.h \
$$PWD_CUR/editors.h \
$$PWD_CUR/doctrenderer.h \
$$PWD_CUR/docbuilder.h
SOURCES += \
$$PWD_CUR/editors.cpp \
$$PWD_CUR/nativecontrol.cpp \
$$PWD_CUR/doctrenderer.cpp \
$$PWD_CUR/docbuilder.cpp \
$$PWD_CUR/docbuilder_p.cpp \
$$PWD_CUR/graphics.cpp \
$$PWD_CUR/hash.cpp
SOURCES += \
$$PWD_CUR/../../Common/OfficeFileFormatChecker2.cpp \
$$PWD_CUR/../../Common/3dParty/pole/pole.cpp \
$$PWD_CUR/../../OOXML/Base/unicode_util.cpp
HEADERS += \
$$PWD_CUR/docbuilder_p.h \
$$PWD_CUR/nativecontrol.h \
$$PWD_CUR/graphics.h \
$$PWD_CUR/hash.h \
$$PWD_CUR/server.h
HEADERS += \
$$PWD_CUR/embed/PointerEmbed.h \
$$PWD_CUR/embed/ZipEmbed.h \
$$PWD_CUR/embed/GraphicsEmbed.h \
$$PWD_CUR/embed/MemoryStreamEmbed.h \
$$PWD_CUR/embed/NativeControlEmbed.h \
$$PWD_CUR/embed/NativeBuilderEmbed.h \
$$PWD_CUR/embed/NativeBuilderDocumentEmbed.h \
$$PWD_CUR/embed/TextMeasurerEmbed.h \
$$PWD_CUR/embed/HashEmbed.h \
$$PWD_CUR/embed/Default.h \
$$PWD_CUR/js_internal/js_base.h
SOURCES += \
$$PWD_CUR/embed/PointerEmbed.cpp \
$$PWD_CUR/embed/ZipEmbed.cpp \
$$PWD_CUR/embed/GraphicsEmbed.cpp \
$$PWD_CUR/embed/MemoryStreamEmbed.cpp \
$$PWD_CUR/embed/NativeControlEmbed.cpp \
$$PWD_CUR/embed/NativeBuilderEmbed.cpp \
$$PWD_CUR/embed/NativeBuilderDocumentEmbed.cpp \
$$PWD_CUR/embed/TextMeasurerEmbed.cpp \
$$PWD_CUR/embed/HashEmbed.cpp \
$$PWD_CUR/embed/Default.cpp
# Serialize objects to JS
HEADERS += \
$$PWD_CUR/json/json.h \
$$PWD_CUR/json/json_p.h \
$$PWD_CUR/json/json_values.h \
$$PWD_CUR/json/serialization.h
SOURCES += \
$$PWD_CUR/json/json.cpp \
$$PWD_CUR/json/json_values.cpp
include($$PWD_CUR/js_internal/js_base.pri)
!use_javascript_core {
build_xp:DESTDIR=$$DESTDIR/xp
}
use_javascript_core {
OBJECTIVE_SOURCES += $$PWD_CUR/../common/Mac/NSString+StringUtils.mm
}
# files for embedded classes
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/GraphicsEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/HashEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/MemoryStreamEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeBuilderEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeBuilderDocumentEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/NativeControlEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/PointerEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/TextMeasurerEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/ZipEmbed.h)
include($$PWD_CUR/../graphics/pro/textshaper.pri)
include($$PWD_CUR/../../Common/3dParty/openssl/openssl.pri)
# downloader
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
CONFIG += drawingfile_support
drawingfile_support {
DEFINES += WASM_SERIALIZER_USE_ALLOCATOR
ADD_DEPENDENCY(PdfFile, XpsFile, DjVuFile, DocxRenderer)
HEADERS += \
$$PWD_CUR/drawingfile.h \
$$PWD_CUR/embed/DrawingFileEmbed.h
SOURCES += \
$$PWD_CUR/../graphics/pro/js/wasm/src/HTMLRendererText.cpp \
$$PWD_CUR/embed/DrawingFileEmbed.cpp
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER($$PWD_CUR/embed/DrawingFileEmbed.h)
}

View File

@ -1,128 +1,3 @@
QT -= core
QT -= gui
INCLUDEPATH += $$PWD/addon
VERSION = 1.0.0.3
TARGET = doctrenderer
TEMPLATE = lib
CONFIG += shared
CONFIG += plugin
CORE_ROOT_DIR = $$PWD/../..
PWD_ROOT_DIR = $$PWD
include(../../Common/base.pri)
DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
DEFINES += JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
#CONFIG += build_xp
#CONFIG += v8_version_60
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
HEADERS += \
config.h \
editors.h \
doctrenderer.h \
docbuilder.h
SOURCES += \
editors.cpp \
nativecontrol.cpp \
doctrenderer.cpp \
docbuilder.cpp \
docbuilder_p.cpp \
graphics.cpp \
hash.cpp
SOURCES += \
../../Common/OfficeFileFormatChecker2.cpp \
../../Common/3dParty/pole/pole.cpp \
../../OOXML/Base/unicode_util.cpp
HEADERS += \
docbuilder_p.h \
nativecontrol.h \
graphics.h \
hash.h \
server.h
HEADERS += \
embed/PointerEmbed.h \
embed/ZipEmbed.h \
embed/GraphicsEmbed.h \
embed/MemoryStreamEmbed.h \
embed/NativeControlEmbed.h \
embed/NativeBuilderEmbed.h \
embed/NativeBuilderDocumentEmbed.h \
embed/TextMeasurerEmbed.h \
embed/HashEmbed.h \
embed/Default.h \
js_internal/js_base.h
SOURCES += \
embed/PointerEmbed.cpp \
embed/ZipEmbed.cpp \
embed/GraphicsEmbed.cpp \
embed/MemoryStreamEmbed.cpp \
embed/NativeControlEmbed.cpp \
embed/NativeBuilderEmbed.cpp \
embed/NativeBuilderDocumentEmbed.cpp \
embed/TextMeasurerEmbed.cpp \
embed/HashEmbed.cpp \
embed/Default.cpp
# Serialize objects to JS
HEADERS += \
json/json.h \
json/json_p.h \
json/json_values.h \
json/serialization.h
SOURCES += \
json/json.cpp \
json/json_values.cpp
include($$PWD/js_internal/js_base.pri)
!use_javascript_core {
build_xp:DESTDIR=$$DESTDIR/xp
}
use_javascript_core {
OBJECTIVE_SOURCES += ../common/Mac/NSString+StringUtils.mm
}
# files for embedded classes
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/GraphicsEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/HashEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/MemoryStreamEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeBuilderEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeBuilderDocumentEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeControlEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/PointerEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/TextMeasurerEmbed.h)
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/ZipEmbed.h)
include(../graphics/pro/textshaper.pri)
include(../../Common/3dParty/openssl/openssl.pri)
# downloader
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
CONFIG += drawingfile_support
drawingfile_support {
DEFINES += WASM_SERIALIZER_USE_ALLOCATOR
ADD_DEPENDENCY(PdfFile, XpsFile, DjVuFile, DocxRenderer)
HEADERS += \
drawingfile.h \
embed/DrawingFileEmbed.h
SOURCES += \
../graphics/pro/js/wasm/src/HTMLRendererText.cpp \
embed/DrawingFileEmbed.cpp
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/DrawingFileEmbed.h)
}
include(doctrenderer.pri)

View File

@ -125,10 +125,6 @@ namespace NSDoctRenderer
AppendScript(builder, config->m_strSdkPath + L"/pdf/src/engine/drawingfile_native.js");
AppendScript(builder, config->m_strSdkPath + L"/pdf/src/annotations/stamps.json", "window[\"native_pdf_stamps\"]=", ";");
sCachePath = config->m_strSdkPath + L"/pdf/sdk-all";
std::string ss = builder->GetData();
NSFile::CFileBinary::SaveToFile(L"D:\\222.js", UTF8_TO_U(ss));
break;
}
default:

View File

@ -160,16 +160,30 @@ void CGraphicsEmbed::SetAppImage(CGraphicsAppImage* appImage)
JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm)
{
NSNativeControl::CNativeControl* pControl = NULL;
if (!Native->isNull())
{
pControl = (NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject();
JSSmart<CJSObject> pNativeObject = Native->toObject();
CJSEmbedObject* pNativeEmbedObject = pNativeObject->getNative();
if (m_pInternal->m_pAppImage)
delete m_pInternal->m_pAppImage;
m_pInternal->m_pAppImage = new CGraphicsAppImage();
m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory);
m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory);
if (pNativeEmbedObject)
{
NSNativeControl::CNativeControl* pControl = (NSNativeControl::CNativeControl*)pNativeEmbedObject->getObject();
m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory);
m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory);
}
else
{
JSSmart<CJSValue> checkResources = pNativeObject->get("isResourcesObject");
if (checkResources->isBool() && true == checkResources->toBool())
{
m_pInternal->m_pAppImage->SetFontsDirectory(pNativeObject->get("fontsDirectory")->toStringW());
m_pInternal->m_pAppImage->SetImagesDirectory(pNativeObject->get("imagesDirectory")->toStringW());
}
}
}
m_pInternal->init(width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());

View File

@ -8,7 +8,22 @@ JSSmart<CJSValue> CBuilderEmbed::OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSVa
{
std::wstring Path = sPath->toStringW();
std::wstring Params = sParams->toStringW();
// Since we now use snapshots, and we can't always determine which editor is needed
// (since the code may be BEFORE opening the file). And if the opening came from
// builderJS.OpenFile - in this case we skip reopening.
NSDoctRenderer::CDocBuilder_Private* pPrivate = GetPrivate();
if (pPrivate->m_pWorker->IsSimpleJSInstance())
pPrivate->m_bIsOpenedFromSimpleJS = true;
int ret = m_pBuilder->OpenFile(Path.c_str(), Params.c_str());
if (pPrivate->m_pWorker->IsSimpleJSInstance())
{
JSSmart<CJSContext> current = CJSContext::GetCurrent();
current->runScript("throw 0;");
}
return CJSContext::createInt(ret);
}
@ -20,7 +35,21 @@ JSSmart<CJSValue> CBuilderEmbed::CreateFile(JSSmart<CJSValue> type)
else
nFormat = type->toInt32();
// Since we now use snapshots, and we can't always determine which editor is needed
// (since the code may be BEFORE opening the file). And if the opening came from
// builderJS.OpenFile - in this case we skip reopening.
NSDoctRenderer::CDocBuilder_Private* pPrivate = GetPrivate();
if (pPrivate->m_pWorker->IsSimpleJSInstance())
pPrivate->m_bIsOpenedFromSimpleJS = true;
bool ret = m_pBuilder->CreateFile(nFormat);
if (pPrivate->m_pWorker->IsSimpleJSInstance())
{
JSSmart<CJSContext> current = CJSContext::GetCurrent();
current->runScript("throw 0;");
}
return CJSContext::createBool(ret);
}
@ -41,7 +70,7 @@ JSSmart<CJSValue> CBuilderEmbed::SaveFile(JSSmart<CJSValue> type, JSSmart<CJSVal
std::wstring sPath = path->toStringW();
std::wstring sParams = params->toStringW();
int ret = m_pBuilder->SaveFile(nFormat, sPath.c_str(), sParams.empty() ? NULL : sParams.c_str());
int ret = GetPrivate()->SaveFile(nFormat, sPath.c_str(), sParams.empty() ? NULL : sParams.c_str(), false);
return CJSContext::createInt(ret);
}

View File

@ -50,6 +50,7 @@ public:
~CBuilderEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
virtual void* getObject() { return (void*)m_pBuilder; }
NSDoctRenderer::CDocBuilder_Private* GetPrivate() { return m_pBuilder->GetPrivate(); }
public:
JSSmart<CJSValue> OpenFile(JSSmart<CJSValue> sPath, JSSmart<CJSValue> sParams);

View File

@ -258,3 +258,64 @@ JSSmart<CJSValue> CZipEmbed::getImageType(JSSmart<CJSValue> typedArray)
oBuffer.Free();
return CJSContext::createInt(bIsImageFile ? oChecker.eFileType : 0);
}
JSSmart<CJSValue> CZipEmbed::getImageBuffer(JSSmart<CJSValue> filePath)
{
if (!m_pFolder || !filePath->isString())
return CJSContext::createNull();
std::wstring sFilePath = filePath->toStringW();
IFolder::CBuffer* pBuffer;
if (!m_pFolder->read(sFilePath, pBuffer))
return CJSContext::createNull();
size_t nBufferSize = (size_t)pBuffer->Size;
CImageFileFormatChecker oChecker;
bool bIsImageFile = oChecker.isImageFile(pBuffer->Buffer, (DWORD)pBuffer->Size);
if (!bIsImageFile)
{
RELEASEOBJECT(pBuffer);
return CJSContext::createNull();
}
bool bIsNeedConvertMetfileToSvg = false;
// Make as wasm module
if (oChecker.eFileType == _CXIMAGE_FORMAT_WMF || oChecker.eFileType == _CXIMAGE_FORMAT_EMF)
oChecker.eFileType = _CXIMAGE_FORMAT_SVG;
else
bIsNeedConvertMetfileToSvg = false;
if (!bIsNeedConvertMetfileToSvg)
{
BYTE* pMemory = NSJSBase::NSAllocator::Alloc(nBufferSize);
memcpy(pMemory, pBuffer->Buffer, nBufferSize);
RELEASEOBJECT(pBuffer);
JSSmart<CJSObject> retObject = CJSContext::createObject();
retObject->set("type", CJSContext::createInt(oChecker.eFileType));
retObject->set("data", NSJSBase::CJSContext::createUint8Array(pMemory, (int)nBufferSize, false));
return retObject->toValue();
}
#ifndef GRAPHICS_DISABLE_METAFILE
MetaFile::IMetaFile* pMetaFile = MetaFile::Create(NULL);
pMetaFile->LoadFromBuffer(pBuffer->Buffer, (unsigned int)pBuffer->Size);
std::wstring wsSvg = pMetaFile->ConvertToSvg();
std::string sSvg = U_TO_UTF8(wsSvg);
pMetaFile->Release();
RELEASEOBJECT(pBuffer);
BYTE* pData = NSAllocator::Alloc(sSvg.length());
memcpy(pData, sSvg.c_str(), sSvg.length());
JSSmart<CJSObject> retObject = CJSContext::createObject();
retObject->set("type", CJSContext::createInt(24));
retObject->set("data", NSJSBase::CJSContext::createUint8Array(pData, sSvg.length(), false));
return retObject->toValue();
#else
return CJSContext::createNull();
#endif
}

View File

@ -36,6 +36,7 @@ public:
JSSmart<CJSValue> encodeImageData(JSSmart<CJSValue> typedArray, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> stride, JSSmart<CJSValue> format, JSSmart<CJSValue> isRgba);
JSSmart<CJSValue> encodeImage(JSSmart<CJSValue> typedArray, JSSmart<CJSValue> format);
JSSmart<CJSValue> getImageType(JSSmart<CJSValue> typedArray);
JSSmart<CJSValue> getImageBuffer(JSSmart<CJSValue> path);
DECLARE_EMBED_METHODS
};

View File

@ -17,6 +17,7 @@
-(JSValue*) encodeImageData : (JSValue*)typedArray : (JSValue*)w : (JSValue*)h : (JSValue*)stride : (JSValue*)format : (JSValue*)isRgba;
-(JSValue*) encodeImage : (JSValue*)typedArray : (JSValue*)format;
-(JSValue*) getImageType : (JSValue*)typedArray;
-(JSValue*) getImageBuffer : (JSValue*)path;
@end
@interface CJSCZipEmbed : NSObject<IJSCZipEmbed, JSEmbedObjectProtocol>
@ -41,6 +42,7 @@ FUNCTION_WRAPPER_JS_2(decodeImage, decodeImage)
FUNCTION_WRAPPER_JS_6(encodeImageData, encodeImageData)
FUNCTION_WRAPPER_JS_2(encodeImage, encodeImage)
FUNCTION_WRAPPER_JS_1(getImageType, getImageType)
FUNCTION_WRAPPER_JS_1(getImageBuffer, getImageBuffer)
@end
class CZipEmbedAdapter : public CJSEmbedObjectAdapterJSC

View File

@ -20,6 +20,7 @@ namespace NSZipEmbed
FUNCTION_WRAPPER_V8_6(_encodeImageData, encodeImageData)
FUNCTION_WRAPPER_V8_2(_encodeImage, encodeImage)
FUNCTION_WRAPPER_V8_1(_getImageType, getImageType)
FUNCTION_WRAPPER_V8_1(_getImageBuffer, getImageBuffer)
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
{
@ -39,6 +40,7 @@ namespace NSZipEmbed
NSV8Objects::Template_Set(result, "encodeImageData", _encodeImageData);
NSV8Objects::Template_Set(result, "encodeImage", _encodeImage);
NSV8Objects::Template_Set(result, "getImageType", _getImageType);
NSV8Objects::Template_Set(result, "getImageBuffer", _getImageBuffer);
return handle_scope.Escape(result);
}

View File

@ -374,7 +374,7 @@ namespace NSJSBase
JSSmart<CJSContext> CJSContext::GetCurrent()
{
CJSContext* ret = new CJSContext();
CJSContext* ret = new CJSContext(false);
ret->m_internal->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
return ret;
}

View File

@ -1,5 +1,5 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
* (c) Copyright Ascensio System SIA 2010-2024
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)

View File

@ -1,5 +1,5 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
* (c) Copyright Ascensio System SIA 2010-2024
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)

View File

@ -1,5 +1,5 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
* (c) Copyright Ascensio System SIA 2010-2024
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
@ -531,6 +531,45 @@ ZLib.prototype.getImageAsSvg = function(path)
return string;
};
/**
* Get image file raw data. this memory was copied and detach from archive.
* @returns {Uint8Array}
*/
ZLib.prototype.getImageBuffer = function(path)
{
let result = {
type : 0,
data : null
};
result.type = this.getImageType(path);
if (result.type === 0)
return null;
let fileData = this.getFile(path);
result.data = new Uint8Array(fileData.length);
result.data.set(fileData);
if (result.type != 10 &&
result.type != 21)
{
return result;
}
result.type = 24;
// Source was saved as result.data for using original image in native convertations.
// But for js we need svg for metafiles.
let encodedData = Module["_Raster_Encode"](this.files[path].p + 4, fileData.length, 24);
let encodedSize = Module["_Raster_GetEncodedSize"](encodedData);
let encodedBuffer = Module["_Raster_GetEncodedBuffer"](encodedData);
let fileDataEnc = new Uint8Array(Module["HEAP8"].buffer, encodedBuffer, encodedSize);
result.dataBlob = new Uint8Array(fileDataEnc.length);
result.dataBlob.set(fileDataEnc);
Module["_Raster_DestroyEncodedData"](encodedData);
return result;
};
/**
* Get image blob for browser
* @returns {Blob}

View File

@ -1,5 +1,5 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
* (c) Copyright Ascensio System SIA 2010-2024
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
@ -35,7 +35,7 @@
window['AscFonts'] = window['AscFonts'] || {};
var AscFonts = window['AscFonts'];
var g_native_engine = CreateEmbedObject("CTextMeasurerEmbed");
var g_native_engine = null;
function CReturnObject()
{
@ -236,4 +236,6 @@ AscFonts.Hyphen_Word = function(lang, word)
AscFonts.onLoadModule();
AscFonts.onLoadModule();
window["InitNativeTextMeasurer"] = function() { g_native_engine = CreateEmbedObject("CTextMeasurerEmbed"); };
})(window, undefined);

View File

@ -100,6 +100,7 @@
"FT_CONFIG_OPTION_SYSTEM_ZLIB",
"GRAPHICS_NO_USE_DYNAMIC_LIBRARY",
"HYPHEN_ENGINE_DISABLE_FILESYSTEM",
"METAFILE_DISABLE_FILESYSTEM",
"HAVE_UNISTD_H", "HAVE_FCNTL_H", "_ARM_ALIGN_",
"METAFILE_SUPPORT_WMF_EMF",
@ -259,10 +260,13 @@
"folder": "../../../OfficeUtils/js",
"files": ["../src/ZipBuffer.cpp", "wasm/src/base.cpp", "../src/zlib_addon.c"]
},
{
"folder": "../../",
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp"]
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp", "graphics/Matrix.cpp"]
},
{
"folder": "../../agg-2.4/src/",
"files": ["agg_trans_affine.cpp"]
},
{
"folder": "../../raster/",

View File

@ -1,5 +1,5 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
* (c) Copyright Ascensio System SIA 2010-2024
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
@ -761,6 +761,14 @@ function onLoadFontsModule(window, undefined)
{
return this.engine["getImageBlob"](path);
};
/**
* Get image file raw data. this memory was copied and detach from archive.
* @returns {Uint8Array}
*/
ZLib.prototype.getImageBuffer = function(path)
{
return this.engine["getImageBuffer"](path);
};
/**
* Get all file paths in archive
* @returns {Array}
@ -772,10 +780,84 @@ function onLoadFontsModule(window, undefined)
AscCommon.ZLib = ZLib;
function ZlibImageBlobs()
{
this.url2BlobUrl = {};
this.blobUrl2Data = {};
this.url2Base64 = {};
this.nativeBlobCounter = 1;
}
ZlibImageBlobs.prototype.getBlobUrl = function(path, zip)
{
if (this.url2BlobUrl[path])
return this.url2BlobUrl[path];
let result = zip.getImageBuffer(path);
if (result == null)
return "";
let blobUrl = "";
let blobType = AscCommon.openXml.GetMimeType((24 !== result["type"]) ? AscCommon.GetFileExtension(path) : "svg");
if (window["NATIVE_EDITOR_ENJINE"])
{
blobUrl = "blob:internal-image" + this.nativeBlobCounter++;
}
else
{
try
{
let blob = new Blob([result["dataBlob"] ? result["dataBlob"] : result["data"]], {type: blobType});
blobUrl = window.URL.createObjectURL(blob);
}
catch (e)
{
blobUrl = "error";
AscCommon.consoleLog("ERROR: Image blob was not loaded");
}
}
this.blobUrl2Data[blobUrl] = result;
this.url2BlobUrl[path] = blobUrl;
return blobUrl;
};
ZlibImageBlobs.prototype.getImageBase64 = function(url)
{
if (this.url2Base64[url])
return this.url2Base64[url];
let obj = this.blobUrl2Data[url];
if (!obj)
return url;
let header = "";
switch (obj.type)
{
case 3:
header = "data:image/jpeg;base64,";
break;
case 24:
header = "data:image/svg+xml;base64,";
break;
case 4:
default:
header = "data:image/png;base64,";
}
this.url2Base64[url] = header + AscCommon.Base64.encode(obj.data);
return this.url2Base64[url];
};
window["AscCommon"].g_oDocumentBlobUrls = new ZlibImageBlobs();
if (AscCommon["CZLibEngineJS"])
AscCommon["CZLibEngineJS"].prototype["isModuleInit"] = true;
window.nativeZlibEngine = new ZLib();
if (window["NATIVE_EDITOR_ENJINE"])
window["InitNativeZLib"] = function() { window.nativeZlibEngine = new ZLib(); };
else
window.nativeZlibEngine = new ZLib();
function Hyphenation()
{

View File

@ -153,13 +153,6 @@ IMetafileToRenderter::IMetafileToRenderter(IRenderer* pRenderer)
}
IMetafileToRenderter::~IMetafileToRenderter()
{
for (std::vector<std::wstring>::iterator i = m_arTempFiles.begin(); i != m_arTempFiles.end(); i++)
{
std::wstring sPath = *i;
if (NSFile::CFileBinary::Exists(sPath))
NSFile::CFileBinary::Remove(sPath);
}
if (m_pPicker)
{
CMetafileFontPicker* pPicker = (CMetafileFontPicker*)m_pPicker;
@ -234,8 +227,6 @@ std::wstring IMetafileToRenderter::GetImagePath(const std::wstring& sPath)
oFrame.put_Data(NULL);
sImagePath = sTempFile;
}
m_arTempFiles.push_back(sTempFile);
}
RELEASEARRAYOBJECTS(pImageBuffer);

View File

@ -49,7 +49,6 @@ public:
protected:
std::wstring m_sTempDir;
std::vector<std::wstring> m_arTempFiles;
std::wstring m_sThemesDir;
std::wstring m_sMediaDir;

View File

@ -682,6 +682,7 @@ HEADERS += \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/DropCap.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Table.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/ExternalImageStorage.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontStyleManager.h \
@ -706,6 +707,7 @@ SOURCES += \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/ContText.cpp \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.cpp \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.cpp \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Table.cpp \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.cpp \
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontManager.cpp \
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontStyleManager.cpp \

View File

@ -1,5 +1,5 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
* (c) Copyright Ascensio System SIA 2010-2024
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)

View File

@ -1,5 +1,5 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
* (c) Copyright Ascensio System SIA 2010-2024
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)

View File

@ -100,8 +100,6 @@ namespace MetaFile
m_bStartedPath = false;
m_bUpdatedClip = true;
m_pRenderer->CommandLong(c_nPenWidth0As1px, 1);
//int alpha = 0xff;
//m_pRenderer->put_BrushAlpha1(alpha);
//m_pRenderer->put_BrushType(c_BrushTypeSolid);
@ -1218,7 +1216,41 @@ namespace MetaFile
else if (PS_JOIN_MITER == ulPenJoin)
nJoinStyle = Aggplus::LineJoinMiter;
const double dWidth = pPen->GetWidth() * m_dScaleX;
double dWidth = pPen->GetWidth();
// Повторение кода из Graphics для вычисления минимальной ширины пера
double dM11, dM12, dM21, dM22, dDx, dDy;
m_pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
Aggplus::CMatrix oMatrix;
oMatrix.SetElements(dM11, dM12, dM21, dM22, dDx, dDy);
oMatrix.Scale(1. / m_dScaleX, 1. / m_dScaleY);
// Вычисление минимально возможной ширины пера
// # Код явялется дублированным из Graphics
const double dSqrtDet = sqrt(abs(oMatrix.Determinant()));
const double dWidthMinSize = (dSqrtDet != 0) ? (1.0 / dSqrtDet) : dWidth;
if (0 == pPen->GetWidth())
{
double dX = 0.72, dY = 0.72;
oMatrix.Invert();
oMatrix.TransformPoint(dX, dY);
dX -= oMatrix.OffsetX();
dY -= oMatrix.OffsetY();
dWidth = std::min(abs(dX), abs(dY));
}
//------------------------
else
{
dWidth *= m_dScaleX;
if (dWidth < dWidthMinSize)
dWidth = dWidthMinSize;
}
const double dMiterLimit = (0 != pPen->GetMiterLimit()) ? pPen->GetMiterLimit() : m_pFile->GetMiterLimit() * m_dScaleX;
BYTE nDashStyle = Aggplus::DashStyleSolid;
@ -1228,79 +1260,83 @@ namespace MetaFile
pPen->GetDashData(pDataDash, unSizeDash);
if (NULL != pDataDash && 0 != unSizeDash)
if ((NULL != pDataDash && 0 != unSizeDash) || PS_SOLID != ulPenStyle)
{
m_pRenderer->put_PenDashOffset(pPen->GetDashOffset());
// Дублированный код из Graphics
// Без этого используется оригинальный код в Graphics, который отрисовывает уже неверно
double dDashWidth{dWidth};
double dM11, dTemp;
m_pRenderer->GetTransform(&dM11, &dTemp, &dTemp, &dTemp, &dTemp, &dTemp);
double dDpi;
m_pRenderer->get_DpiX(&dDpi);
const double dNewWidth{dWidth * dM11 * dDpi / 25.4};
std::vector<double> arDashes(unSizeDash);
for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex)
arDashes[unIndex] = pDataDash[unIndex] * dNewWidth;
m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash);
nDashStyle = Aggplus::DashStyleCustom;
}
else if (PS_SOLID != ulPenStyle)
{
std::vector<double> arDashPattern;
double dM11, dTemp;
m_pRenderer->GetTransform(&dM11, &dTemp, &dTemp, &dTemp, &dTemp, &dTemp);
double dDpi;
m_pRenderer->get_DpiX(&dDpi);
const double dNewWidth{dWidth * dM11 * dDpi / 25.4};
switch (ulPenStyle)
if (!Equals(dWidthMinSize, dWidth))
{
case PS_DASH:
{
arDashPattern.push_back(9 * dNewWidth);
arDashPattern.push_back(3 * dNewWidth);
double dDet = oMatrix.Determinant();
break;
}
case PS_DOT:
{
arDashPattern.push_back(3 * dNewWidth);
arDashPattern.push_back(3 * dNewWidth);
break;
}
case PS_DASHDOT:
{
arDashPattern.push_back(9 * dNewWidth);
arDashPattern.push_back(3 * dNewWidth);
arDashPattern.push_back(3 * dNewWidth);
arDashPattern.push_back(3 * dNewWidth);
break;
}
case PS_DASHDOTDOT:
{
arDashPattern.push_back(9 * dNewWidth);
arDashPattern.push_back(3 * dNewWidth);
arDashPattern.push_back(3 * dNewWidth);
arDashPattern.push_back(3 * dNewWidth);
arDashPattern.push_back(3 * dNewWidth);
arDashPattern.push_back(3 * dNewWidth);
break;
}
if (fabs(dDet) < 0.0001)
dDashWidth *= dSqrtDet;
}
// -----------------------------
if (!arDashPattern.empty())
if (NULL != pDataDash && 0 != unSizeDash)
{
m_pRenderer->PenDashPattern(arDashPattern.data(), arDashPattern.size());
m_pRenderer->put_PenDashOffset(pPen->GetDashOffset());
std::vector<double> arDashes(unSizeDash);
for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex)
arDashes[unIndex] = pDataDash[unIndex] * dDashWidth;
m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash);
nDashStyle = Aggplus::DashStyleCustom;
nStartCapStyle = nEndCapStyle = Aggplus::LineCapFlat;
nJoinStyle = Aggplus::LineJoinMiter;
}
else
{
std::vector<double> arDashPattern;
switch (ulPenStyle)
{
case PS_DASH:
{
arDashPattern.push_back(9 * dDashWidth);
arDashPattern.push_back(3 * dDashWidth);
break;
}
case PS_DOT:
{
arDashPattern.push_back(3 * dDashWidth);
arDashPattern.push_back(3 * dDashWidth);
break;
}
case PS_DASHDOT:
{
arDashPattern.push_back(9 * dDashWidth);
arDashPattern.push_back(6 * dDashWidth);
arDashPattern.push_back(3 * dDashWidth);
arDashPattern.push_back(6 * dDashWidth);
break;
}
case PS_DASHDOTDOT:
{
arDashPattern.push_back(9 * dDashWidth);
arDashPattern.push_back(6 * dDashWidth);
arDashPattern.push_back(3 * dDashWidth);
arDashPattern.push_back(6 * dDashWidth);
arDashPattern.push_back(3 * dDashWidth);
arDashPattern.push_back(6 * dDashWidth);
break;
}
}
if (!arDashPattern.empty())
{
m_pRenderer->PenDashPattern(arDashPattern.data(), arDashPattern.size());
nDashStyle = Aggplus::DashStyleCustom;
nStartCapStyle = nEndCapStyle = Aggplus::LineCapFlat;
nJoinStyle = Aggplus::LineJoinMiter;
}
}
}

View File

@ -44,7 +44,8 @@ namespace MetaFile
: r(_r), g(_g), b(_b), a(_a)
{}
TRGBA::TRGBA(int nValue) : r((nValue >> 0) & 0xFF), g((nValue >> 8) & 0xFF), b((nValue >> 16) & 0xFF), a((nValue >> 24) & 0xFF)
TRGBA::TRGBA(int nValue)
: r((nValue >> 0) & 0xFF), g((nValue >> 8) & 0xFF), b((nValue >> 16) & 0xFF), a((nValue >> 24) & 0xFF)
{}
void TRGBA::Set(unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a)
@ -94,7 +95,18 @@ namespace MetaFile
return a;
}
TXForm::TXForm() : M11(1), M12(0), M21(0), M22(1), Dx(0), Dy(0)
TRGBA& TRGBA::operator=(const TRGBA& oRGBA)
{
r = oRGBA.r;
g = oRGBA.g;
b = oRGBA.b;
a = oRGBA.a;
return *this;
}
TXForm::TXForm()
: M11(1), M12(0), M21(0), M22(1), Dx(0), Dy(0)
{}
TXForm::TXForm(const TXForm &oXForm)

View File

@ -558,6 +558,8 @@ namespace MetaFile
unsigned char GetGreen() const;
unsigned char GetBlue() const;
unsigned char GetAlpha() const;
TRGBA& operator=(const TRGBA& oRGBA);
};
struct TXForm

View File

@ -147,6 +147,10 @@ namespace MetaFile
if (BI_JPEG != unCompression || BI_PNG != unCompression)
return false;
#ifdef METAFILE_DISABLE_FILESYSTEM
return false;
#endif
std::wstring wsTempFileName = GetTempFilename();
if (wsTempFileName.empty())
return false;
@ -233,7 +237,9 @@ namespace MetaFile
}
for (int nAddIndex = 0; nAddIndex < nAdditBytes; nAddIndex++)
{
int nByte = *pBuffer; pBuffer++; lBufLen--;
// int nByte = *pBuffer;
++pBuffer;
--lBufLen;
}
}
}
@ -267,7 +273,9 @@ namespace MetaFile
}
for (int nAddIndex = 0; nAddIndex < nAdditBytes; nAddIndex++)
{
int nByte = *pBuffer; pBuffer++; lBufLen--;
// int nByte = *pBuffer;
++pBuffer;
--lBufLen;
}
}
}
@ -486,7 +494,12 @@ namespace MetaFile
}
if (lBufLen < (nWidth + nAdd) * abs(nHeight))
{
if (pUncompressedBuffer)
delete[] pUncompressedBuffer;
return false;
}
pBgraBuffer = new BYTE[nWidth * abs(nHeight) * 4 * sizeof(BYTE)];
if (NULL == pBgraBuffer)
@ -639,7 +652,7 @@ namespace MetaFile
*pulWidth = ulWidth;
*pulHeight = ulHeight;
return false;
return true;
}
else if (BI_BITCOUNT_5 == ushBitCount)
{
@ -986,29 +999,6 @@ namespace MetaFile
}
}
std::wstring ascii_to_unicode(const char *src)
{
size_t nSize = mbstowcs(0, src, 0);
wchar_t* pBuffer = new wchar_t[nSize];
nSize = mbstowcs(pBuffer, src, nSize);
std::wstring sRes;
if (nSize != (size_t)-1)
sRes = std::wstring(pBuffer, nSize);
delete[] pBuffer;
return sRes;
}
std::string unicode_to_ascii(const wchar_t *src)
{
size_t nSize = wcstombs(0, src, 0);
char* pBuffer = new char[nSize];
nSize = wcstombs(pBuffer, src, nSize);
std::string sRes;
if (nSize != (size_t)-1)
sRes = std::string(pBuffer, nSize);
delete[] pBuffer;
return sRes;
}
std::wstring GetTempFilename(const std::wstring& sFolder)
{
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(sFolder.empty() ? NSFile::CFileBinary::GetTempPath() : sFolder, L"wmf");

View File

@ -1512,26 +1512,5 @@ namespace MetaFile
std::swap(oFirstClip, oSecondClip);
}
TRectD CEmfInterpretatorSvg::TranslateRect(const TRectL &oRect) const
{
TRectD oNewRect(oRect.Left, oRect.Top, oRect.Right, oRect.Bottom);
if (oNewRect.Right < oNewRect.Left)
{
double dTempValue = oNewRect.Left;
oNewRect.Left = oNewRect.Right;
oNewRect.Right = dTempValue;
}
if (oNewRect.Bottom < oNewRect.Top)
{
double dTempValue = oNewRect.Top;
oNewRect.Top = oNewRect.Bottom;
oNewRect.Bottom = dTempValue;
}
return oNewRect;
}
}

View File

@ -227,8 +227,6 @@ namespace MetaFile
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override {};
void SwapClips(CSvgClip& oFirstClip, CSvgClip& oSecondClip);
TRectD TranslateRect(const TRectL &oRect) const;
};
}

View File

@ -30,7 +30,6 @@
*
*/
#include "../../../raster/ImageFileFormatChecker.h"
#include "../../../graphics/Image.h"
#include "../Common/MetaFileUtils.h"

View File

@ -593,6 +593,8 @@ namespace MetaFile
if (!BanEMFProcesses())
HANDLE_EMR_CREATEBRUSHINDIRECT(ulBrushIndex, pBrush);
else
delete pBrush;
}
void CEmfParser::Read_EMR_SETTEXTCOLOR()
@ -630,6 +632,8 @@ namespace MetaFile
if (!BanEMFProcesses())
HANDLE_EMR_EXTCREATEFONTINDIRECTW(ulIndex, pFont);
else
delete pFont;
}
void CEmfParser::Read_EMR_SETTEXTALIGN()
@ -722,6 +726,8 @@ namespace MetaFile
if (!BanEMFProcesses())
HANDLE_EMR_EXTCREATEPEN(ulPenIndex, pPen, arUnused);
else
delete pPen;
}
void CEmfParser::Read_EMR_CREATEPEN()
@ -744,6 +750,8 @@ namespace MetaFile
if (!BanEMFProcesses())
HANDLE_EMR_CREATEPEN(ulPenIndex, widthX, pPen);
else
delete pPen;
}
void CEmfParser::Read_EMR_SETPOLYFILLMODE()
@ -1011,6 +1019,8 @@ namespace MetaFile
if (!BanEMFProcesses())
HANDLE_EMR_CREATEPALETTE(ulPaletteIndex, pPalette);
else
delete pPalette;
}
void CEmfParser::Read_EMR_SELECTPALETTE()

View File

@ -763,7 +763,7 @@ namespace MetaFile
if (InterpretatorType::Svg == oInterpretatorType)
{
CEmfInterpretatorSvg *pEmfInterpretatorSvg = new CEmfInterpretatorSvg(this, dWidth, dHeight);
pEmfInterpretatorSvg->SetShapeRendering(EShapeRendering::CrispEdges);
pEmfInterpretatorSvg->SetShapeRendering(EShapeRendering::OptimizeSpeed);
m_pInterpretator = pEmfInterpretatorSvg;
}
}

View File

@ -1,10 +1,6 @@
#ifndef CEMFPARSERBASE_H
#define CEMFPARSERBASE_H
//#include "../EmfTypes.h"
//#include "../EmfObjects.h"
//#include "../../Common/MetaFileUtils.h"
#include "../EmfPlayer.h"
#include "../../Common/MetaFile.h"

View File

@ -67,15 +67,11 @@
#define EMFPLUS_TRANSLATEWORLDTRANSFORM 0x402D
#include <map>
#include <iostream>
#include "CEmfParser.h"
#include "../../Wmf/WmfFile.h"
#include "../../Wmf/WmfInterpretator/CWmfInterpretatorSvg.h"
#include "../EmfInterpretator/CEmfInterpretator.h"
#include "../EmfInterpretator/CEmfInterpretatorSvg.h"
#include "../EmfInterpretator/CEmfInterpretatorArray.h"
#include "../EmfInterpretator/CEmfInterpretatorRender.h"
#ifdef METAFILE_SUPPORT_WMF_EMF_XML
@ -664,6 +660,9 @@ namespace MetaFile
for (unsigned int unIndex = 0; unIndex < unPositionCount; ++unIndex)
m_oStream >> pEmfPlusBrush->arGradientColors[unIndex].first;
pEmfPlusBrush->oColor = pEmfPlusBrush->arGradientColors.back() .first;
pEmfPlusBrush->oColorBack = pEmfPlusBrush->arGradientColors.front().first;
}
}
@ -772,7 +771,7 @@ namespace MetaFile
switch (nEndCap)
{
case 0: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_FLAT; break;
case 0: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_FLAT; break;
case 1: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_SQUARE; break;
case 2: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_ROUND; break;
}
@ -785,7 +784,7 @@ namespace MetaFile
switch (nJoin)
{
case 0: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_MITER; break;
case 0: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_MITER; break;
case 1: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_BEVEL; break;
case 2: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_ENDCAP_ROUND; break;
}
@ -871,7 +870,7 @@ namespace MetaFile
m_oStream >> *pLineCapData;
if (CustomLineCapDataFillPath == pLineCapData->unCustomLineCapDataFlags ||
CustomLineCapDataLinePath == pLineCapData->unCustomLineCapDataFlags)
CustomLineCapDataLinePath == pLineCapData->unCustomLineCapDataFlags)
{
m_oStream.Skip(4); // FillPathLength or LinePathLength
pLineCapData->pPath = ReadPath();
@ -1343,7 +1342,7 @@ namespace MetaFile
if (oImageAttributes.eWrapMode == WrapModeClamp)
{
if (oRectangle.dX < 0 || oRectangle.dX < 0 ||
oRectangle.dX >= oRectangle.dWidth || oRectangle.dY >= oRectangle.dHeight)
oRectangle.dX >= oRectangle.dWidth || oRectangle.dY >= oRectangle.dHeight)
return oImageAttributes.oClampColor;
}
@ -1541,14 +1540,10 @@ namespace MetaFile
case MetafileDataTypeEmf:
case MetafileDataTypeEmfPlusOnly:
case MetafileDataTypeEmfPlusDual:
{
return DrawMetafile<CEmfParser>(pBuffer, unSizeBuffer, oSrcRect, arPoints);
}
case MetafileDataTypeWmf:
case MetafileDataTypeWmfPlaceable:
{
return DrawMetafile<CWmfParser>(pBuffer, unSizeBuffer, oSrcRect, arPoints);
}
}
}
}
@ -1661,7 +1656,7 @@ namespace MetaFile
BYTE* pNewBuffer = GetClipedImage(pPixels, nWidth, nHeight, oClipRect, nW, nH);
m_pInterpretator->DrawBitmap(arPoints[0].X, arPoints[0].Y, arPoints[1].X - arPoints[0].X - m_pDC->GetPixelWidth(), arPoints[2].Y - arPoints[0].Y - m_pDC->GetPixelHeight(),
(NULL != pNewBuffer) ? pNewBuffer : pPixels, nW, nH);
(NULL != pNewBuffer) ? pNewBuffer : pPixels, nW, nH);
RELEASEINTERFACE(pGrRenderer);
RELEASEARRAYOBJECTS(pNewBuffer);
@ -1740,7 +1735,7 @@ namespace MetaFile
BYTE* pNewBuffer = GetClipedImage(pBytes, unWidth, unHeight, oClipRect, nW, nH);
m_pInterpretator->DrawBitmap(arPoints[0].X, arPoints[0].Y, arPoints[1].X - arPoints[0].X, arPoints[2].Y - arPoints[0].Y,
(NULL != pNewBuffer) ? pNewBuffer : pBytes, nW, nH);
(NULL != pNewBuffer) ? pNewBuffer : pBytes, nW, nH);
if (!bExternalBuffer)
RELEASEARRAYOBJECTS(pBytes);
@ -1803,17 +1798,15 @@ namespace MetaFile
m_pDC->SetPen(pPen);
if (AD_COUNTERCLOCKWISE != m_pDC->GetArcDirection())
{
dSweepAngle = dSweepAngle - 360;
}
TEmfPlusRectF oConvertedRect = GetConvertedRectangle(oRect);
MoveTo(oConvertedRect.dX, oConvertedRect.dY);
ArcTo(oConvertedRect.dX, oConvertedRect.dY,
oConvertedRect.dX + oConvertedRect.dWidth,
oConvertedRect.dY + oConvertedRect.dHeight,
dStartAngle, dSweepAngle);
oConvertedRect.dX + oConvertedRect.dWidth,
oConvertedRect.dY + oConvertedRect.dHeight,
dStartAngle, dSweepAngle);
DrawPath(true, false);
if (NULL != m_pInterpretator)
@ -2290,13 +2283,13 @@ namespace MetaFile
if (NULL != m_pInterpretator)
{
CPathConverter oPathConverter;
CPath oNewPath, oLineCapPath;
oPathConverter.GetUpdatedPath(oNewPath, oLineCapPath, *pPath, *pEmfPlusPen);
if (InterpretatorType::Render == m_pInterpretator->GetType())
{
CPathConverter oPathConverter;
CPath oNewPath, oLineCapPath;
oPathConverter.GetUpdatedPath(oNewPath, oLineCapPath, *pPath, *pEmfPlusPen);
oNewPath.DrawOn(m_pInterpretator, true, false);
oLineCapPath.DrawOn(m_pInterpretator, false, true);
}
@ -2833,7 +2826,7 @@ namespace MetaFile
void CEmfPlusParser::Read_EMFPLUS_FILLREGION(unsigned short unShFlags)
{
short shOgjectIndex = ExpressValue(unShFlags, 0, 7);
// short shOgjectIndex = ExpressValue(unShFlags, 0, 7);
unsigned int unBrushId;
m_oStream >> unBrushId;
@ -2992,34 +2985,34 @@ namespace MetaFile
void CEmfPlusParser::Read_EMFPLUS_SETANTIALIASMODE(unsigned short unShFlags)
{
short shSmoothingMode = ExpressValue(unShFlags, 1, 7);
// short shSmoothingMode = ExpressValue(unShFlags, 1, 7);
//TODO: реализовать
}
void CEmfPlusParser::Read_EMFPLUS_SETCOMPOSITINGMODE(unsigned short unShFlags)
{
short shCompositingMode = ExpressValue(unShFlags, 0, 7);
// short shCompositingMode = ExpressValue(unShFlags, 0, 7);
//TODO: реализовать
}
void CEmfPlusParser::Read_EMFPLUS_SETCOMPOSITINGQUALITY(unsigned short unShFlags)
{
short shCompositingQuality = ExpressValue(unShFlags, 0, 7);
// short shCompositingQuality = ExpressValue(unShFlags, 0, 7);
//TODO: реализовать
}
void CEmfPlusParser::Read_EMFPLUS_SETINTERPOLATIONMODE(unsigned short unShFlags)
{
short shInterpolationMode = ExpressValue(unShFlags, 0, 7);
// short shInterpolationMode = ExpressValue(unShFlags, 0, 7);
//TODO: реализовать
}
void CEmfPlusParser::Read_EMFPLUS_SETPIXELOFFSETMODE(unsigned short unShFlags)
{
short shPixelOffsetMode = ExpressValue(unShFlags, 0, 7);
// short shPixelOffsetMode = ExpressValue(unShFlags, 0, 7);
//TODO: реализовать
}
@ -3036,20 +3029,20 @@ namespace MetaFile
void CEmfPlusParser::Read_EMFPLUS_SETTEXTCONTRAST(unsigned short unShFlags)
{
short shTextContrast = ExpressValue(unShFlags, 0, 11);
// short shTextContrast = ExpressValue(unShFlags, 0, 11);
//TODO: реализовать
}
void CEmfPlusParser::Read_EMRPLUS_SETTEXTRENDERINGHINT(unsigned short unShFlags)
{
short shTextRenderingHint = ExpressValue(unShFlags, 0, 7);
// short shTextRenderingHint = ExpressValue(unShFlags, 0, 7);
//TODO: реализовать
}
void CEmfPlusParser::Read_EMFPLUS_BEGINCONTAINER(unsigned short unShFlags)
{
short shPageUnit = ExpressValue(unShFlags, 8, 15);
// short shPageUnit = ExpressValue(unShFlags, 8, 15);
TEmfPlusRectF oDestRect, oSrcRect;
unsigned int unStackIndex;

View File

@ -1,8 +1,6 @@
#ifndef CEMFPLUSPARSER_H
#define CEMFPLUSPARSER_H
//#include "../../Common/MetaFileUtils.h"
//#include "../../Common/MetaFile.h"
#include "../EmfPlusObjects.h"
#include "CEmfParserBase.h"
#include "../EmfPlusTypes.h"

View File

@ -106,6 +106,16 @@ namespace MetaFile
chRed = oARGB.chRed;
chAlpha = oARGB.chAlpha;
}
TEmfPlusARGB& operator=(const TEmfPlusARGB& oARGB)
{
chBlue = oARGB.chBlue;
chGreen = oARGB.chGreen;
chRed = oARGB.chRed;
chAlpha = oARGB.chAlpha;
return *this;
}
};
struct TGUID

View File

@ -611,6 +611,9 @@ namespace MetaFile
void CMetaFile::ConvertToRaster(const wchar_t* wsOutFilePath, unsigned int unFileType, int nWidth, int nHeight)
{
if (nWidth == 0 || nHeight == 0)
return;
NSGraphics::IGraphicsRenderer* pGrRenderer = NSGraphics::Create();
NSFonts::IFontManager* pFontManager = m_pAppFonts->GenerateFontManager();

View File

@ -266,6 +266,7 @@ void CSvmFile::Read_META_LINE()
{
case LINE_SOLID: last_pen->PenStyle = PS_SOLID ; break;
case LINE_DASH: last_pen->PenStyle = PS_DASH ; break;
default: break;
}
}
}
@ -323,6 +324,7 @@ void CSvmFile::Read_META_POLYLINE()
{
case LINE_SOLID: last_pen->PenStyle = PS_SOLID ; break;
case LINE_DASH: last_pen->PenStyle = PS_DASH ; break;
default: break;
}
if (last_pen->Width < 1)

View File

@ -560,16 +560,18 @@ namespace MetaFile
void CInterpretatorSvgBase::IntersectClip(const TRectD &oClip)
{
double dLeft = oClip.Left;
double dTop = oClip.Top;
double dRight = oClip.Right;
double dBottom = oClip.Bottom;
TRectD oUpdatedClip{oClip};
m_pParser->GetTransform().Apply(dLeft, dTop);
m_pParser->GetTransform().Apply(dRight, dBottom);
NormalizeRect(oUpdatedClip);
m_pParser->GetTransform().Apply(oUpdatedClip.Left, oUpdatedClip.Top);
m_pParser->GetTransform().Apply(oUpdatedClip.Right, oUpdatedClip.Bottom);
const std::wstring wsId = L"INTERSECTCLIP_" + ConvertToWString(++m_unNumberDefs, 0);
const std::wstring wsValue = L"<rect x=\"" + ConvertToWString(dLeft, 0) + L"\" y=\"" + ConvertToWString(dTop, 0) + L"\" width=\"" + ConvertToWString(dRight - dLeft, 0) + L"\" height=\"" + ConvertToWString(dBottom - dTop, 0) + L"\"/>";
const std::wstring wsValue = L"<rect x=\"" + ConvertToWString(oUpdatedClip.Left, 0) +
L"\" y=\"" + ConvertToWString(oUpdatedClip.Top, 0) +
L"\" width=\"" + ConvertToWString(oUpdatedClip.Right - oUpdatedClip.Left, 0) +
L"\" height=\"" + ConvertToWString(oUpdatedClip.Bottom - oUpdatedClip.Top, 0) + L"\"/>";
m_oClip.AddClipValue(wsId, wsValue);
}
@ -577,28 +579,24 @@ namespace MetaFile
void CInterpretatorSvgBase::ExcludeClip(const TRectD &oClip, const TRectD &oBB)
{
const TXForm &oTransform{m_pParser->GetTransform()};
double dClipLeft = oClip.Left;
double dClipTop = oClip.Top;
double dClipRight = oClip.Right;
double dClipBottom = oClip.Bottom;
oTransform.Apply(dClipLeft, dClipTop);
oTransform.Apply(dClipRight, dClipBottom);
TRectD oUpdatedClip{oClip};
NormalizeRect(oUpdatedClip);
double dBBLeft = oBB.Left;
double dBBTop = oBB.Top;
double dBBRight = oBB.Right;
double dBBBottom = oBB.Bottom;
oTransform.Apply(oUpdatedClip.Left, oUpdatedClip.Top);
oTransform.Apply(oUpdatedClip.Right, oUpdatedClip.Bottom);
oTransform.Apply(dBBLeft, dBBTop);
oTransform.Apply(dBBRight, dBBBottom);
TRectD oBBRect{oBB};
NormalizeRect(oBBRect);
oTransform.Apply(oBBRect.Left, oBBRect.Top);
oTransform.Apply(oBBRect.Right, oBBRect.Bottom);
const std::wstring wsId = L"EXCLUDECLIP_" + ConvertToWString(++m_unNumberDefs, 0);
const std::wstring wsValue = L"<path d=\"M" + ConvertToWString(dBBLeft) + L' ' + ConvertToWString(dBBTop) + L", L" + ConvertToWString(dBBRight) + L' ' + ConvertToWString(dBBTop) + L", " +
ConvertToWString(dBBRight) + L' ' + ConvertToWString(dBBBottom) + L", " + ConvertToWString(dBBLeft ) + L' ' + ConvertToWString(dBBBottom) + L", M" +
ConvertToWString(dClipLeft) + L' ' + ConvertToWString(dClipTop) + L", L" + ConvertToWString(dClipRight) + L' ' + ConvertToWString(dClipTop) + L", " +
ConvertToWString(dClipRight) + L' ' + ConvertToWString(dClipBottom) + L", " + ConvertToWString(dClipLeft) + L' ' + ConvertToWString(dClipLeft ) + L"\" clip-rule=\"evenodd\"/>";
const std::wstring wsValue = L"<path d=\"M" + ConvertToWString(oBBRect.Left) + L' ' + ConvertToWString(oBBRect.Top) + L", L" + ConvertToWString(oBBRect.Right) + L' ' + ConvertToWString(oBBRect.Top) + L", " +
ConvertToWString(oBBRect.Right) + L' ' + ConvertToWString(oBBRect.Bottom) + L", " + ConvertToWString(oBBRect.Left) + L' ' + ConvertToWString(oBBRect.Bottom) + L", Z M" +
ConvertToWString(oUpdatedClip.Left) + L' ' + ConvertToWString(oUpdatedClip.Top) + L", L" + ConvertToWString(oUpdatedClip.Right) + L' ' + ConvertToWString(oUpdatedClip.Top) + L", " +
ConvertToWString(oUpdatedClip.Right) + L' ' + ConvertToWString(oUpdatedClip.Bottom) + L", " + ConvertToWString(oUpdatedClip.Left) + L' ' + ConvertToWString(oUpdatedClip.Bottom) + L" Z\" clip-rule=\"evenodd\"/>";
m_oClip.AddClipValue(wsId, wsValue);
}
@ -2080,4 +2078,21 @@ namespace MetaFile
return CalculateColor(unColor, chAlpha);
}
void NormalizeRect(TRectD& oRect)
{
if (oRect.Right < oRect.Left)
std::swap(oRect.Right, oRect.Left);
if (oRect.Bottom < oRect.Top)
std::swap(oRect.Bottom, oRect.Top);
}
TRectD TranslateRect(const TRectL& oRect)
{
TRectD oNewRect(oRect.Left, oRect.Top, oRect.Right, oRect.Bottom);
NormalizeRect(oNewRect);
return oNewRect;
}
}

View File

@ -161,6 +161,8 @@ namespace MetaFile
std::wstring CalculateColor(unsigned int unColor);
std::wstring CalculateColor(unsigned int unColor, BYTE uchAlpha);
std::wstring CalculateColor(BYTE uchRed, BYTE uchGreen, BYTE uchBlue, BYTE uchAlpha);
void NormalizeRect(TRectD& oRect);
TRectD TranslateRect(const TRectL &oRect);
}
#endif // CINTERPRETATORSVGBASE_H

View File

@ -153,7 +153,13 @@ namespace MetaFile
const std::wstring wsText{ConvertToUnicode(pString, (long)shStringLength, (NULL != pFont) ? pFont->GetCharSet() : DEFAULT_CHARSET)};
TPointD oScale((m_pParser->IsWindowFlippedX()) ? -1 : 1, (m_pParser->IsWindowFlippedY()) ? -1 : 1);
TPointD oScale(1, 1);
if (NULL != m_pParser)
{
oScale.X = m_pParser->IsWindowFlippedX() ? -1 : 1;
oScale.Y = m_pParser->IsWindowFlippedY() ? -1 : 1;
}
std::vector<double> arDx(0);
@ -346,12 +352,7 @@ namespace MetaFile
void CWmfInterpretatorSvg::HANDLE_META_RECTANGLE(short shB, short shR, short shT, short shL)
{
TRectD oNewRect;
oNewRect.Left = shL;
oNewRect.Top = shT;
oNewRect.Right = shR;
oNewRect.Bottom = shB;
TRectD oNewRect = TranslateRect({shL, shT, shR, shB});
NodeAttributes arAttributes = {{L"x", ConvertToWString(oNewRect.Left)},
{L"y", ConvertToWString(oNewRect.Top)},
@ -369,12 +370,7 @@ namespace MetaFile
void CWmfInterpretatorSvg::HANDLE_META_ROUNDRECT(short shH, short shW, short shB, short shR, short shT, short shL)
{
TRectD oNewRect;
oNewRect.Left = shL;
oNewRect.Top = shT;
oNewRect.Right = shR;
oNewRect.Bottom = shB;
TRectD oNewRect = TranslateRect({shL, shT, shR, shB});
NodeAttributes arAttributes = {{L"x", ConvertToWString(oNewRect.Left)},
{L"y", ConvertToWString(oNewRect.Top)},

View File

@ -298,7 +298,7 @@ namespace MetaFile
m_oStream >> oBitmap;
unsigned int unRecordSizeDWORD = m_unRecordSize >> 1;
unsigned int unValue = (META_STRETCHBLT >> 8) + 3;
// unsigned int unValue = (META_STRETCHBLT >> 8) + 3;
if (unRecordSizeDWORD == ((META_STRETCHBLT >> 8) + 3))
{

View File

@ -196,7 +196,7 @@ namespace MetaFile
if (InterpretatorType::Svg == oInterpretatorType)
{
CWmfInterpretatorSvg *pWmfInterpretatorSvg = new CWmfInterpretatorSvg(this, unWidth, unHeight);
pWmfInterpretatorSvg->SetShapeRendering(EShapeRendering::CrispEdges);
pWmfInterpretatorSvg->SetShapeRendering(EShapeRendering::OptimizeSpeed);
m_pInterpretator = pWmfInterpretatorSvg;
}
}
@ -241,10 +241,10 @@ namespace MetaFile
{
const double dKoef = 96. / (double)m_oPlaceable.ushInch;
m_oDCRect.Left = std::round(m_oDCRect.Left * dKoef);
m_oDCRect.Top = std::round(m_oDCRect.Top * dKoef);
m_oDCRect.Right = std::round(m_oDCRect.Right * dKoef);
m_oDCRect.Bottom = std::round(m_oDCRect.Bottom * dKoef);
m_oDCRect.Left = static_cast<int>(std::round(m_oDCRect.Left * dKoef));
m_oDCRect.Top = static_cast<int>(std::round(m_oDCRect.Top * dKoef));
m_oDCRect.Right = static_cast<int>(std::round(m_oDCRect.Right * dKoef));
m_oDCRect.Bottom = static_cast<int>(std::round(m_oDCRect.Bottom * dKoef));
}
// Иногда m_oPlaceable.BoundingBox задается нулевой ширины и высоты
@ -292,6 +292,16 @@ namespace MetaFile
m_pDC->SetCurPos(shX, shY);
}
void CWmfParserBase::MoveToD(double dX, double dY)
{
if (NULL != m_pInterpretator)
m_pInterpretator->MoveTo(dX, dY);
else
RegisterPoint(static_cast<short>(dX), static_cast<short>(dY));
m_pDC->SetCurPos(static_cast<short>(dX), static_cast<short>(dY));
}
void CWmfParserBase::LineTo(short shX, short shY)
{
if (NULL != m_pInterpretator)
@ -396,7 +406,7 @@ namespace MetaFile
NSFonts::IFontManager* pFontManager = GetFontManager();
if (pFontManager)
{
int lLogicalFontHeight = pFont->GetHeight();
int lLogicalFontHeight = static_cast<int>(pFont->GetHeight());
if (lLogicalFontHeight < 0)
lLogicalFontHeight = -lLogicalFontHeight;
if (lLogicalFontHeight < 0.01)
@ -444,8 +454,8 @@ namespace MetaFile
{
pFontManager->LoadString1(wsText, 0, 0);
TBBox oBox = pFontManager->MeasureString2();
fL = (float)(oBox.fMinX);
fW = (float)(oBox.fMaxX - oBox.fMinX);
fL = static_cast<float>(oBox.fMinX);
fW = static_cast<float>(oBox.fMaxX - oBox.fMinX);
}
pFontManager->LoadString1(wsText, 0, 0);
@ -520,7 +530,7 @@ namespace MetaFile
}
else
{
int lLogicalFontHeight = pFont->GetHeight();
int lLogicalFontHeight = static_cast<int>(pFont->GetHeight());
if (lLogicalFontHeight < 0)
lLogicalFontHeight = -lLogicalFontHeight;
if (lLogicalFontHeight < 0.01)
@ -548,7 +558,7 @@ namespace MetaFile
fW = (float)(dFontHeight * wsText.length());
}
fH = dFontHeight * 1.2;
fH = (float)dFontHeight * 1.2f;
double dTheta = -((((double)pFont->GetEscapement()) / 10) * 3.14159265358979323846 / 180);
double dCosTheta = (float)cos(dTheta);
@ -724,17 +734,17 @@ namespace MetaFile
oNewRect.Top < 0 || oNewRect.Bottom < 0)
return NULL;
if (unHeight < (oNewRect.Bottom - oNewRect.Top))
oNewRect.Bottom = oNewRect.Top + unWidth;
if (unHeight < static_cast<unsigned int>(std::abs(oNewRect.Bottom - oNewRect.Top)))
oNewRect.Bottom = oNewRect.Top + unHeight;
if (unWidth < (oNewRect.Right - oNewRect.Left))
if (unWidth < static_cast<unsigned int>(std::abs(oNewRect.Right - oNewRect.Left)))
oNewRect.Right = oNewRect.Left + unWidth;
if (unHeight == (oNewRect.Bottom - oNewRect.Top) &&
unWidth == (oNewRect.Right - oNewRect.Left))
return NULL;
int nBeginX, nBeginY, nEndX, nEndY;
ULONG nBeginX, nBeginY, nEndX, nEndY;
nBeginX = (std::min)(oNewRect.Left, oNewRect.Right);
nBeginY = (std::min)(oNewRect.Top, oNewRect.Bottom);
@ -924,7 +934,7 @@ namespace MetaFile
double dSweepAngle = GetSweepAngle(dStartAngle, dEndAngle);
MoveTo(dX1, dY1);
MoveToD(dX1, dY1);
ArcTo(shLeft, shTop, shRight, shBottom, dStartAngle, dSweepAngle);
DrawPath(true, false);
}

View File

@ -188,6 +188,7 @@ namespace MetaFile
inline double GetSweepAngle(const double& dStartAngle, const double& dEndAngle) const;
void MoveTo(short shX, short shY);
void MoveToD(double dX, double dY);
void LineTo(short shX, short shY);
void ArcTo(short shL, short shT, short shR, short shB, double dStart, double dSweep);
void ClosePath();

View File

@ -442,14 +442,14 @@ namespace SVG
if (!Equals(0., dFontHeight) && dFontHeight < MIN_FONT_SIZE)
{
dXScale *= dFontHeight / MIN_FONT_SIZE;
dYScale *= dFontHeight / MIN_FONT_SIZE;
dXScale *= MIN_FONT_SIZE / dFontHeight;
dYScale *= MIN_FONT_SIZE / dFontHeight;
dFontHeight = MIN_FONT_SIZE;
}
else if (!Equals(0., dFontHeight) && dFontHeight > MAX_FONT_SIZE)
{
dXScale *= MAX_FONT_SIZE / dFontHeight;
dYScale *= MAX_FONT_SIZE / dFontHeight;
dXScale *= dFontHeight / MAX_FONT_SIZE;
dYScale *= dFontHeight / MAX_FONT_SIZE;
dFontHeight = MAX_FONT_SIZE;
}

View File

@ -9,6 +9,15 @@ namespace NSDocxRenderer
{
UINT CShape::m_gRelativeHeight = c_iStandartRelativeHeight;
unsigned int ClampUIntSign(const double& value)
{
if (value < 0)
return 0;
if (value > 0x7FFFFFFF)
return 0x7FFFFFFF;
return (unsigned int)value;
}
CShape::CShape()
{
m_nRelativeHeight = m_gRelativeHeight;
@ -881,10 +890,10 @@ namespace NSDocxRenderer
{
double to_percentage = 100.0 * 1000.0 / m_oPen.Size;
oWriter.WriteString(L"<a:ds d=\"");
oWriter.AddUInt(dash_pattern[i] * to_percentage);
oWriter.AddUInt(ClampUIntSign(dash_pattern[i] * to_percentage));
oWriter.WriteString(L"\" ");
oWriter.WriteString(L"sp=\"");
oWriter.AddUInt(dash_pattern[i + 1] * to_percentage);
oWriter.AddUInt(ClampUIntSign(dash_pattern[i + 1] * to_percentage));
oWriter.WriteString(L"\" />");
}
oWriter.WriteString(L"</a:custDash>");

View File

@ -1196,7 +1196,7 @@ public:
if (NULL == pCell)
continue;
pCell->SetColspan(unMaxIndex , MAXCOLUMNSINTABLE);
pCell->SetColspan(unMaxIndex, MAXCOLUMNSINTABLE);
continue;
}
@ -1208,9 +1208,9 @@ public:
if (NULL == pCell)
continue;
if (1 < pCell->GetColspan() && unIndex + pCell->GetColspan() > m_arMinColspan[unIndex])
if (1 < pCell->GetColspan() && pCell->GetColspan() > m_arMinColspan[unIndex])
{
pCell->SetColspan(m_arMinColspan[unIndex] - unIndex, MAXCOLUMNSINTABLE);
pCell->SetColspan(m_arMinColspan[unIndex], MAXCOLUMNSINTABLE);
continue;
}
@ -1746,6 +1746,15 @@ public:
oRelsWriter.CloseFile();
}
for (const std::pair<std::wstring, std::wstring>& oFootnote : m_mFootnotes)
{
m_oNoteXml.WriteString(L"<w:footnote w:id=\"");
m_oNoteXml.WriteString(oFootnote.second);
m_oNoteXml.WriteString(L"\"><w:p><w:pPr><w:pStyle w:val=\"footnote-p\"/></w:pPr><w:r><w:rPr><w:rStyle w:val=\"footnote\"/></w:rPr></w:r><w:r><w:t xml:space=\"preserve\">");
m_oNoteXml.WriteEncodeXmlString(oFootnote.first);
m_oNoteXml.WriteString(L"</w:t></w:r></w:p></w:footnote>");
}
m_oNoteXmlRels.WriteString(L"</Relationships>");
if (oRelsWriter.CreateFileW(m_sDst + L"/word/_rels/footnotes.xml.rels"))
{
@ -2372,6 +2381,8 @@ private:
if (oTS.bAddSpaces && m_oState.m_bInP && !m_oState.m_bInR && !iswspace(sText.front()) && !m_oState.m_bWasSpace && CTextSettings::Normal == oTS.eTextMode)
WriteSpace(pXml);
OpenP(pXml);
NSStringUtils::CStringBuilder oPPr;
std::wstring sPStyle = wrP(&oPPr, arSelectors, oTS);

View File

@ -12,6 +12,8 @@ PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
ADD_DEPENDENCY(kernel, UnicodeConverter, graphics)
DEFINES += HWPFILE_USE_DYNAMIC_LIBRARY
@ -62,6 +64,7 @@ SOURCES += \
HwpDoc/Paragraph/CtrlContainer.cpp \
HwpDoc/Paragraph/CtrlEmpty.cpp \
HwpDoc/Paragraph/CtrlEqEdit.cpp \
HwpDoc/Paragraph/CtrlField.cpp \
HwpDoc/Paragraph/CtrlForm.cpp \
HwpDoc/Paragraph/CtrlGeneralShape.cpp \
HwpDoc/Paragraph/CtrlHeadFoot.cpp \
@ -147,6 +150,7 @@ HEADERS += \
HwpDoc/Paragraph/CtrlContainer.h \
HwpDoc/Paragraph/CtrlEmpty.h \
HwpDoc/Paragraph/CtrlEqEdit.h \
HwpDoc/Paragraph/CtrlField.h \
HwpDoc/Paragraph/CtrlForm.h \
HwpDoc/Paragraph/CtrlGeneralShape.h \
HwpDoc/Paragraph/CtrlHeadFoot.h \

View File

@ -24,7 +24,10 @@ int CXMLNode::GetAttributeColor(const std::wstring& wsName, const int& _default)
if (L'#' == sColor.front())
sColor.erase(0, 1);
return std::stoi(sColor, 0, 16);
if (sColor.length() < 6)
return _default;
return std::stoi(sColor.substr(0, 6), nullptr, 16);
}
return _default;

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
#ifndef CONVERTER2OOXML_H
#define CONVERTER2OOXML_H
#include "../HWPFile.h"
#include "../../../DesktopEditor/common/StringBuilder.h"
#include "../Paragraph/CtrlField.h"
#include "../Paragraph/CtrlAutoNumber.h"
#include "../Paragraph/CtrlSectionDef.h"
#include "../Paragraph/CtrlShapeVideo.h"
@ -13,6 +13,9 @@
#include "../Paragraph/CtrlShapeOle.h"
#include "../Paragraph/CtrlEqEdit.h"
#include "../Paragraph/CtrlTable.h"
#include "../Paragraph/CtrlNote.h"
#include "../Paragraph/ParaText.h"
#include "../Paragraph/TblCell.h"
#include "FootnoteConverter.h"
@ -23,14 +26,31 @@
namespace HWP
{
struct THWPColor
{
BYTE m_uchRed;
BYTE m_uchGreen;
BYTE m_uchBlue;
};
struct TConversionState
{
bool m_bOpenedP;
bool m_bOpenedR;
bool m_bIsNote;
bool m_bInTextBox; // TODO:: используется, чтобы в wps:txbx не появилась новая фигура (посмотреть этот момент нужно подробнее)
unsigned short m_ushLastCharShapeId;
unsigned short m_ushSecdIndex;
unsigned int m_unParaIndex;
THWPColor *m_pHighlightColor;
VECTOR<const CCtrlHeadFoot*> m_arCtrlsHeadFoot; //only for hwpx
std::stack<int> m_arOpenedBookmarks;
const CCtrlSectionDef* m_pSectionDef;
const CCtrlColumnDef* m_pColumnDef;
@ -42,6 +62,8 @@ struct TConversionState
None
} m_eBreakType;
std::map<unsigned int, const CCtrlField*> m_mOpenField;
TConversionState();
};
@ -88,6 +110,8 @@ class CConverter2OOXML
unsigned short m_ushTableCount;
unsigned short m_ushEquationCount;
unsigned short m_ushBookmarkCount;
void CreateEmptyFiles();
void FillDefaultData();
void Close();
@ -100,39 +124,49 @@ class CConverter2OOXML
void WriteTableProperties(const CCtrlTable* pTable, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteCell(const CTblCell* pCell, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, ECellCreator eCellCreator);
void WriteCellProperties(short shBorderFillID, NSStringUtils::CStringBuilder& oBuilder);
void WriteCellBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder);
void WriteBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder);
void WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteEqEditShape(const CCtrlEqEdit* pEqEditShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteOleShape(const CCtrlShapeOle* pOleShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteEqEditShape(const CCtrlEqEdit* pEqEditShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteOleShape(const CCtrlShapeOle* pOleShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteSectionSettings(TConversionState& oState);
void WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder, const TConversionState& oState);
void WriteVideo(const CCtrlShapeVideo* pCtrlVideo, NSStringUtils::CStringBuilder& oBuilder, const TConversionState& oState);
void WritePicture(const CCtrlShapePic* pCtrlPic, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteVideo(const CCtrlShapeVideo* pCtrlVideo, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
bool SaveSVGFile(const HWP_STRING& sSVG, HWP_STRING& sFileName);
HWP_STRING SavePicture(const HWP_STRING& sBinItemId);
void WriteParaShapeProperties(short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const HWP_STRING& sExternStyles = L"");
void WriteTextBorderStyle(short shBorderFillId, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void OpenDrawingNode(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
void CloseDrawingNode(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
void WriteShapePosition(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
void WriteShapeExtent(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
void WriteShapeWrapMode(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
void WriteShapeProperty(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
void OpenParagraph(short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void CloseParagraph(NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteText(const std::wstring& wsText, short shParaShapeID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteText(const CParaText* pParaText, const VECTOR<TRangeTag>& arRangeTags, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteText(const HWP_STRING& wsText, short shParaShapeID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteLineSettings(const CCtrlGeneralShape* pCtrlGeneralShape, NSStringUtils::CStringBuilder& oBuilder);
void WriteLineSettings(ELineStyle2 eLineStyle, int nColor, int nThick, HWP_BYTE nCompoundLineType, NSStringUtils::CStringBuilder& oBuilder);
void WriteBorderSettings(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder);
void WriteAutoNumber(const CCtrlAutoNumber* pAutoNumber, short shParaShapeID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteCharacter(const CCtrlCharacter* pCharacter, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteShape(const CCtrlGeneralShape* pShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteShape(const CCtrlGeneralShape* pShape, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteNote(const CCtrlNote* pNote, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteField(const CCtrlField* pHyperlink, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void CloseField(const CCtrlField* pHyperlink, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteCaption(const CCtrlCommon* pCtrlCommon, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
HWP_STRING AddRelationship(const HWP_STRING& wsType, const HWP_STRING& wsTarget);
void AddContentType(const HWP_STRING& wsName, const HWP_STRING& wsType);

View File

@ -35,6 +35,7 @@ std::wstring CFootnoteConverter::CreateNote(const CCtrlNote* pNote, CConverter2O
pXMLBuilder->WriteString(L"<w:" + wsPrefix + L"note w:id=\"" + wsIndex + L"\">");
TConversionState oState;
oState.m_bIsNote = true;
for (const CHWPPargraph* pParagraph : pNote->GetParagraphs())
oConverter.WriteParagraph(pParagraph, *pXMLBuilder, oState);

View File

@ -27,12 +27,14 @@ int CNumberingConverter::CreateNumbering(const CHWPRecordNumbering* pNumbering,
if (nullptr == pNumbering || eHeadingType == EHeadingType::NONE || EHeadingType::OUTLINE == eHeadingType)
return 0;
std::vector<const CHWPRecordNumbering*>::const_iterator itFound = std::find(m_arUsedNumbering.cbegin(), m_arUsedNumbering.cend(), pNumbering);
std::vector<std::pair<EHeadingType, const CHWPRecordNumbering*>>::const_iterator itFound = std::find_if(m_arUsedNumbering.cbegin(), m_arUsedNumbering.cend(),
[pNumbering, eHeadingType](const std::pair<EHeadingType, const CHWPRecordNumbering*>& oValue)
{ return eHeadingType == oValue.first && pNumbering == oValue.second;});
if (m_arUsedNumbering.cend() != itFound)
return itFound - m_arUsedNumbering.cbegin() + 1;
m_arUsedNumbering.push_back(pNumbering);
m_arUsedNumbering.push_back(std::make_pair(eHeadingType, pNumbering));
m_oNumberXml.WriteString(L"<w:abstractNum w:abstractNumId=\"" + std::to_wstring(m_arUsedNumbering.size()) + L"\">");
@ -51,7 +53,15 @@ int CNumberingConverter::CreateNumbering(const CHWPRecordNumbering* pNumbering,
m_oNumberXml.WriteString(L"<w:suff w:val=\"space\"/>");
wsLvlText = pNumbering->GetNumFormat(shIndex);
std::replace(wsLvlText.begin(), wsLvlText.end(), L'^', L'%');
if (wsLvlText.empty())
{
for (short shLvl = 0; shLvl <= shIndex; ++shLvl)
wsLvlText += L'%' + std::to_wstring(shLvl + 1) + L'.';
}
else
std::replace(wsLvlText.begin(), wsLvlText.end(), L'^', L'%');
m_oNumberXml.WriteString(L"<w:lvlText w:val=\"" + wsLvlText + L"\"/>");
m_oNumberXml.WriteString(L"<w:lvlJc w:val=\"");
@ -73,9 +83,8 @@ int CNumberingConverter::CreateNumbering(const CHWPRecordNumbering* pNumbering,
{
m_oNumberXml.WriteString(L"<w:lvl w:ilvl=\"" + std::to_wstring(shIndex) + L"\">");
m_oNumberXml.WriteString(L"<w:start w:val=\"1\"/>");
m_oNumberXml.WriteString(L"<w:numFmt w:val=\"" + wsNumFormat + L"\"/>");
m_oNumberXml.WriteString(L"<w:suff w:val=\"space\"/>");
m_oNumberXml.WriteString(L"<w:isLgl w:val=\"false\"/>");
m_oNumberXml.WriteString(L"<w:lvlJc w:val=\"");
switch(pNumbering->GetAlign(shIndex))
@ -174,7 +183,7 @@ bool CNumberingConverter::SaveToFile(const std::wstring& wsDirectory)
else
{
for (unsigned short ushIndex = 1; ushIndex <= m_arUsedNumbering.size(); ++ushIndex)
m_oNumberXml.WriteString(L"<w:num w:numId=\"" + std::to_wstring(ushIndex) + L"\"><w:abstractNumId w:val=\"" + std::to_wstring(ushIndex) + L"\"/></w:num>");
oNumberingData.WriteString(L"<w:num w:numId=\"" + std::to_wstring(ushIndex) + L"\"><w:abstractNumId w:val=\"" + std::to_wstring(ushIndex) + L"\"/></w:num>");
}
oNumberingData.WriteString(L"</w:numbering>");

View File

@ -11,7 +11,7 @@ namespace HWP
class CNumberingConverter
{
NSStringUtils::CStringBuilder m_oNumberXml;
std::vector<const CHWPRecordNumbering*> m_arUsedNumbering;
std::vector<std::pair<EHeadingType, const CHWPRecordNumbering*>> m_arUsedNumbering;
public:
CNumberingConverter();

View File

@ -123,8 +123,8 @@ void COleConverter::CreateChart(CHWPStream& oOleStream)
NSStringUtils::CStringBuilder oRelsData;
oRelsData.WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
oRelsData.WriteString(L"<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
oRelsData.WriteString(L"<Relationship Id=\"rId1\" Type=\"http://schemas.microsoft.com/office/2011/relationships/chartStyle\" Target=\"style1.xml\"/>");
oRelsData.WriteString(L"<Relationship Id=\"rId2\" Type=\"http://schemas.microsoft.com/office/2011/relationships/chartColorStyle\" Target=\"colors1.xml\"/>");
oRelsData.WriteString(L"<Relationship Id=\"rId1\" Type=\"http://schemas.microsoft.com/office/2011/relationships/chartStyle\" Target=\"style" + std::to_wstring(m_unCountCharts) + L".xml\"/>");
oRelsData.WriteString(L"<Relationship Id=\"rId2\" Type=\"http://schemas.microsoft.com/office/2011/relationships/chartColorStyle\" Target=\"colors" + std::to_wstring(m_unCountCharts) + L".xml\"/>");
oRelsData.WriteString(L"</Relationships>");
NSFile::CFileBinary oRelsFile;

View File

@ -288,7 +288,7 @@ const CHWPRecord* CHWPDocInfo::GetCharShape(int nIndex) const
const CHWPRecord* CHWPDocInfo::GetNumbering(int nIndex) const
{
GET_RECORD(m_arNumberings, nIndex - 1);
GET_RECORD(m_arNumberings, nIndex);
}
const CHWPRecord* CHWPDocInfo::GetBullet(int nIndex) const
@ -318,10 +318,33 @@ CHWPFile* CHWPDocInfo::GetParentHWP()
const CHWPRecord* CHWPDocInfo::GetBinData(const HWP_STRING& sID) const
{
if (m_mBinDatas.end() == m_mBinDatas.find(sID))
return nullptr;
switch (m_eHanType)
{
case EHanType::HWP:
{
short shID = std::stoi(sID) - 1;
return m_mBinDatas.at(sID);
if (shID >= m_mBinDatas.size())
return nullptr;
std::map<HWP_STRING, CHWPRecord*>::const_iterator itElement = m_mBinDatas.cbegin();
for (unsigned short ushIndex = 0; ushIndex < shID; ++ushIndex)
++itElement;
return itElement->second;
}
case EHanType::HWPX:
{
if (m_mBinDatas.end() == m_mBinDatas.find(sID))
return nullptr;
return m_mBinDatas.at(sID);
break;
}
default:
return nullptr;
}
}
EHanType CHWPDocInfo::GetHanType() const

View File

@ -43,12 +43,6 @@ EState GetState(int nValue)
CHWPRecordBinData::CHWPRecordBinData(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
: CHWPRecord(nTagNum, nLevel, nSize)
{
if (EHanType::HWP == oDocInfo.GetHanType())
{
if (oDocInfo.GetParentHWP()->GetBinData().empty())
oDocInfo.GetParentHWP()->SetBinData(oDocInfo.GetParentHWP()->GetOleFile()->GetChildEntries(L"BinData"));
}
oBuffer.SavePosition();
short shTypeBits;

View File

@ -48,48 +48,65 @@ ELang GetLang(int nValue)
EUnderline GetUnderline(int nValue)
{
switch(static_cast<EUnderline>(nValue))
SWITCH(EUnderline, nValue)
{
case EUnderline::NONE:
case EUnderline::BOTTOM:
case EUnderline::CENTER:
case EUnderline::TOP:
return static_cast<EUnderline>(nValue);
default:
return EUnderline::NONE;
DEFAULT(EUnderline::NONE);
CASE(EUnderline::BOTTOM);
CASE(EUnderline::CENTER);
CASE(EUnderline::TOP);
}
}
EUnderline GetUnderline(const HWP_STRING& sValue)
{
IF_STRING_IN_ENUM(BOTTOM, sValue, EUnderline);
ELSE_IF_STRING_IN_ENUM(CENTER, sValue, EUnderline);
ELSE_IF_STRING_IN_ENUM(TOP, sValue, EUnderline);
ELSE_STRING_IN_ENUM(NONE, EUnderline);
}
EOutline GetOutline(int nValue)
{
switch(static_cast<EOutline>(nValue))
SWITCH(EOutline, nValue)
{
case EOutline::NONE:
case EOutline::SOLID:
case EOutline::DOTTED:
case EOutline::BOLD:
case EOutline::DASHED:
case EOutline::DASH_DOT:
case EOutline::DASH_2DOT:
return static_cast<EOutline>(nValue);
default:
return EOutline::NONE;
DEFAULT(EOutline::NONE);
CASE(EOutline::SOLID);
CASE(EOutline::DOTTED);
CASE(EOutline::BOLD);
CASE(EOutline::DASHED);
CASE(EOutline::DASH_DOT);
CASE(EOutline::DASH_2DOT);
}
}
EOutline GetOutline(const HWP_STRING& sValue)
{
IF_STRING_IN_ENUM(SOLID, sValue, EOutline);
ELSE_IF_STRING_IN_ENUM(DOTTED, sValue, EOutline);
ELSE_IF_STRING_IN_ENUM(BOLD, sValue, EOutline);
ELSE_IF_STRING_IN_ENUM(DASHED, sValue, EOutline);
ELSE_IF_STRING_IN_ENUM(DASH_DOT, sValue, EOutline);
ELSE_IF_STRING_IN_ENUM(DASH_2DOT, sValue, EOutline);
ELSE_STRING_IN_ENUM(NONE, EOutline);
}
EShadow GetShadow(int nValue)
{
switch(static_cast<EShadow>(nValue))
SWITCH(EShadow, nValue)
{
case EShadow::NONE:
case EShadow::DISCRETE:
case EShadow::CONTINUOUS:
return static_cast<EShadow>(nValue);
default:
return EShadow::NONE;
DEFAULT(EShadow::NONE);
CASE(EShadow::DISCRETE);
CASE(EShadow::CONTINUOUS);
}
}
EShadow GetShadow(const HWP_STRING& sValue)
{
IF_STRING_IN_ENUM(DISCRETE, sValue, EShadow);
ELSE_IF_STRING_IN_ENUM(CONTINUOUS, sValue, EShadow);
ELSE_STRING_IN_ENUM(NONE, EShadow);
}
void CHWPRecordCharShape::ReadContainerData(CXMLNode& oNode, short arValues[], int nDefaultValue)
{
arValues[(int)ELang::HANGUL] = oNode.GetAttributeInt(L"hangul", nDefaultValue);
@ -231,7 +248,7 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode,
ReadContainerData(oChild, m_arCharOffset);
else if (L"hh:underline" == oChild.GetName())
{
m_eUnderline = GetUnderline(oChild.GetAttributeInt(L"type"));
m_eUnderline = GetUnderline(oChild.GetAttribute(L"type"));
m_eUnderLineShape = GetLineStyle1(oChild.GetAttribute(L"shape"));
m_nUnderlineColor = oChild.GetAttributeColor(L"color");
}
@ -245,7 +262,7 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode,
}
else if (L"hh:outline" == oChild.GetName())
{
m_eOutline = GetOutline(oChild.GetAttributeInt(L"type"));
m_eOutline = GetOutline(oChild.GetAttribute(L"type"));
}
else if (L"hh:shadow" == oChild.GetName())
{
@ -355,4 +372,9 @@ int CHWPRecordCharShape::GetTextColor() const
{
return m_nTextColor;
}
short CHWPRecordCharShape::GetBorderFillID() const
{
return m_shBorderFillIDRef;
}
}

View File

@ -123,6 +123,8 @@ public:
HWP_STRING GetFontName(ELang eLang) const;
short GetSpacing(ELang eLang) const;
int GetTextColor() const;
short GetBorderFillID() const;
};
}

View File

@ -1,4 +1,5 @@
#include "HWPRecordCtrlData.h"
#include "../Paragraph/CtrlField.h"
namespace HWP
{
@ -35,7 +36,53 @@ int CHWPRecordCtrlData::ParseCtrl(CCtrl& oCtrl, int nSize, CHWPStream& oBuffer,
// TODO:: Вернуться к этому моменту
// Само по себе содержание документа Hankom не позволяет понять, как его интерпретировать.
oBuffer.Skip(nSize);
oBuffer.SavePosition();
if (ECtrlObjectType::Field == oCtrl.GetCtrlType())
{
short shSetID, shNumberItems;
oBuffer.ReadShort(shSetID);
oBuffer.ReadShort(shNumberItems);
short shItemID, shItemType;
for (unsigned short ushIndex = 0; ushIndex < shNumberItems; ++ushIndex)
{
oBuffer.ReadShort(shItemID);
short shUnknownValue;
oBuffer.ReadShort(shUnknownValue); // Unknown Data
oBuffer.ReadShort(shItemType);
switch (GetParamItemType(shItemType))
{
case EParamItemType::PIT_NULL: oBuffer.Skip(4); break;
case EParamItemType::PIT_BSTR:
{
HWP_STRING sValue;
oBuffer.ReadString(sValue, EStringCharacter::UTF16);
if (EFieldType::Bookmark == ((CCtrlField&)oCtrl).GetType())
((CCtrlField&)oCtrl).AddStringParam(L"bookmarkname", sValue);
break;
}
case EParamItemType::PIT_I1: oBuffer.Skip(1); break;
case EParamItemType::PIT_I2: oBuffer.Skip(2); break;
case EParamItemType::PIT_I4: oBuffer.Skip(4); break;
case EParamItemType::PIT_I: oBuffer.Skip(4); break;
case EParamItemType::PIT_UI1: oBuffer.Skip(1); break;
case EParamItemType::PIT_UI2: oBuffer.Skip(2); break;
case EParamItemType::PIT_UI4: oBuffer.Skip(4); break;
case EParamItemType::PIT_UI: oBuffer.Skip(4); break;
case EParamItemType::PIT_SET:
case EParamItemType::PIT_ARRAY:
case EParamItemType::PIT_BINDATA:
break;
}
}
}
oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true));
return nSize;
}
}

View File

@ -13,6 +13,7 @@
#include "../Paragraph/CtrlSectionDef.h"
#include "../Paragraph/CtrlTable.h"
#include "../Paragraph/CtrlEmpty.h"
#include "../Paragraph/CtrlField.h"
namespace HWP
{
@ -77,6 +78,12 @@ CCtrl* CHWPRecordCtrlHeader::Parse(int nTagNum, int nLevel, int nSize, CHWPStrea
pCtrl = new CCtrlPageNumPos(sCtrlID, nSize - oBuffer.GetDistanceToLastPos(), oBuffer, 0, nVersion);
pCtrl->SetFullFilled();
}
else if (L"klh%" == sCtrlID ||
L"kmb%" == sCtrlID)
{
pCtrl = new CCtrlField(sCtrlID, nSize - oBuffer.GetDistanceToLastPos(), oBuffer, 0, nVersion);
pCtrl->SetFullFilled();
}
// else if (L"klh%" == sCtrlID || // hyperlink
// L"frx%" == sCtrlID || // FIELD_CROSSREF
// L"knu%" == sCtrlID || // FIELD_UNKNOWN

View File

@ -44,19 +44,6 @@ CHWPRecordIDMaping::CHWPRecordIDMaping(CHWPDocInfo& oDocInfo, int nTagNum, int n
m_arIdMappingNum.push_back(nCount);
m_arCounts[nIndex] = nCount;
switch (GetIndex(nIndex))
{
case EIndex::BIN_DATA:
{
// TODO:: проверить
if (nullptr != m_pParent && m_pParent->GetParentHWP()->GetBinData().empty())
m_pParent->GetParentHWP()->SetBinData(m_pParent->GetParentHWP()->GetOleFile()->GetChildEntries(L"BinData"));
break;
}
default: break;
}
}
}
}

View File

@ -218,4 +218,12 @@ int CHWPRecordNumbering::GetStartNumber(unsigned short ushIndex) const
return m_arNumbering[ushIndex].m_nStartNumber;
}
int CHWPRecordNumbering::GetCharShape(unsigned short ushIndex) const
{
if (ushIndex >= 7)
return 0;
return m_arNumbering[ushIndex].m_nCharShape;
}
}

View File

@ -42,6 +42,7 @@ public:
HWP_STRING GetNumFormat(unsigned short ushIndex) const;
HWP_BYTE GetAlign(unsigned short ushIndex) const;
int GetStartNumber(unsigned short ushIndex) const;
int GetCharShape(unsigned short ushIndex) const;
};
}

View File

@ -11,29 +11,22 @@ int CHWPRecordParaRangeTag::Parse(CHWPPargraph& oPara, int nTagNum, int nLevel,
{
oBuffer.SavePosition();
TRangeTag *pRangeTag = nullptr;
while (nSize - oBuffer.GetDistanceToLastPos() >= 12)
{
pRangeTag = new TRangeTag();
TRangeTag oRangeTag;
if (nullptr == pRangeTag)
{
oBuffer.Skip(12);
continue;
}
oBuffer.ReadInt(oRangeTag.m_nStartPos);
oBuffer.ReadInt(oRangeTag.m_nEndPos);
oBuffer.ReadInt(pRangeTag->m_nStartPos);
oBuffer.ReadInt(pRangeTag->m_nEndPos);
oBuffer.ReadInt(pRangeTag->m_nTag);
for (unsigned short ushIndex = 0; ushIndex < 3; ++ushIndex)
oBuffer.ReadByte(oRangeTag.m_arData[ushIndex]);
oPara.AddRangeTag(pRangeTag);
oBuffer.ReadByte(oRangeTag.m_chType);
oPara.AddRangeTag(oRangeTag);
}
oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true));
return nSize;
}
}

View File

@ -13,6 +13,14 @@ EHeadingType GetHeadingType(int nValue)
}
}
EHeadingType GetHeadingType(const HWP_STRING& sValue)
{
IF_STRING_IN_ENUM(OUTLINE, sValue, EHeadingType);
ELSE_IF_STRING_IN_ENUM(NUMBER, sValue, EHeadingType);
ELSE_IF_STRING_IN_ENUM(BULLET, sValue, EHeadingType);
ELSE_STRING_IN_ENUM(NONE, EHeadingType);
}
EHorizontalAlign GetHorizontalAlign(int nValue)
{
SWITCH(EHorizontalAlign, nValue)
@ -26,6 +34,16 @@ EHorizontalAlign GetHorizontalAlign(int nValue)
}
}
EHorizontalAlign GetHorizontalAlign(const HWP_STRING& sValue)
{
IF_STRING_IN_ENUM(RIGHT, sValue, EHorizontalAlign);
ELSE_IF_STRING_IN_ENUM(CENTER, sValue, EHorizontalAlign);
ELSE_IF_STRING_IN_ENUM(DISTRIBUTE, sValue, EHorizontalAlign);
ELSE_IF_STRING_IN_ENUM(DISTRIBUTE_SPACE, sValue, EHorizontalAlign);
ELSE_IF_STRING_IN_ENUM(JUSTIFY, sValue, EHorizontalAlign);
ELSE_STRING_IN_ENUM(LEFT, EHorizontalAlign);
}
EVerticalAlign GetVerticalAlign(int nValue)
{
SWITCH(EVerticalAlign, nValue)
@ -37,6 +55,14 @@ EVerticalAlign GetVerticalAlign(int nValue)
}
}
EVerticalAlign GetVerticalAlign(const HWP_STRING& sValue)
{
IF_STRING_IN_ENUM(CENTER, sValue, EVerticalAlign);
ELSE_IF_STRING_IN_ENUM(BOTTOM, sValue, EVerticalAlign);
ELSE_IF_STRING_IN_ENUM(BASELINE, sValue, EVerticalAlign);
ELSE_STRING_IN_ENUM(TOP, EVerticalAlign);
}
CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
: CHWPRecord(nTagNum, nLevel, nSize), m_pParent(&oDocInfo)
{
@ -125,12 +151,12 @@ void CHWPRecordParaShape::RecursiveParaShape(CXMLNode& oNode)
{
if (L"hh:align" == oNode.GetName())
{
m_eAlign = ::HWP::GetHorizontalAlign(oNode.GetAttributeInt(L"horizontal"));
m_eVertAlign = ::HWP::GetVerticalAlign(oNode.GetAttributeInt(L"vertical"));
m_eAlign = ::HWP::GetHorizontalAlign(oNode.GetAttribute(L"horizontal"));
m_eVertAlign = ::HWP::GetVerticalAlign(oNode.GetAttribute(L"vertical"));
}
else if (L"hh:heading" == oNode.GetName())
{
m_eHeadingType = ::HWP::GetHeadingType(oNode.GetAttributeInt(L"type"));
m_eHeadingType = ::HWP::GetHeadingType(oNode.GetAttribute(L"type"));
m_shHeadingIdRef = oNode.GetAttributeInt(L"idRef");
m_chHeadingLevel = (HWP_BYTE)oNode.GetAttributeInt(L"level");
}
@ -262,6 +288,11 @@ int CHWPRecordParaShape::GetMarginNext() const
return m_nMarginNext;
}
int CHWPRecordParaShape::GetIndent() const
{
return m_nIndent;
}
bool CHWPRecordParaShape::KeepWithNext() const
{
return m_bKeepWithNext;

View File

@ -90,6 +90,8 @@ public:
int GetMarginPrev() const;
int GetMarginNext() const;
int GetIndent() const;
bool KeepWithNext() const;
};
}

View File

@ -12,6 +12,7 @@
#include "../Paragraph/CtrlGeneralShape.h"
#include "../Paragraph/CtrlTable.h"
#include "../Paragraph/CtrlEqEdit.h"
#include "../Paragraph/CtrlField.h"
#include <regex>
@ -36,7 +37,8 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
return LIST<CCtrl*>();
}
std::wregex oRegex(L"([\\u0000-\\u001f]|.{2}[\\u0000-\u0017]{4})"); // [\\u0000\\u000a\\u000d\\u0018-\\u001f]|[\\u0001\\u0002-\\u0009\\u000b-\\u000c\\u000e-\\u0017].{6}[\\u0001\\u0002-\\u0009\\u000b-\\u000c\\u000e-\\u0017]
//TODO:: перейти на обычный проход по символам
std::wregex oRegex(L"([\\u0000-\\u001f]|.{2}[\\u0000-\\u0017]{4})"); // [\\u0000\\u000a\\u000d\\u0018-\\u001f]|[\\u0001\\u0002-\\u0009\\u000b-\\u000c\\u000e-\\u0017].{6}[\\u0001\\u0002-\\u0009\\u000b-\\u000c\\u000e-\\u0017]
std::wsregex_iterator itCurrent(sText.begin(), sText.end(), oRegex);
std::wsregex_iterator itEnd = std::wsregex_iterator();
@ -49,9 +51,9 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
#define UPDATE_CURRENT_TEXT() \
do { \
if (!sCurrentText.empty()) \
if (!sCurrentText.empty() && (unsigned int)sCurrentText[0] > 0x001f) \
{ \
arParas.push_back(new CParaText(L"____", sCurrentText, nPrevIndex)); \
arParas.push_back(new CParaText(L"____", sCurrentText, nPrevIndex + 1)); \
sCurrentText.clear(); \
}} while (false)
@ -69,9 +71,6 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
{
case 0x00:
case 0x02:
case 0x13:
// case 0x03:
// case 0x04:
// case 0x17:
// case 0x19:
{
@ -79,13 +78,9 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
break;
}
case 0x03:
{
UPDATE_CURRENT_TEXT();
break;
}
case 0x04:
{
bEnd = true;
UPDATE_CURRENT_TEXT();
break;
}
case 0x08:
@ -134,9 +129,11 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
// Пока данный вариант невозможен
else if (6 == itCurrent->length())
{
UPDATE_CURRENT_TEXT();
//TODO:: Проверить
HWP_STRING sInfo = sText.substr(itCurrent->position(), 2);
std::wregex wrReplaceRegex(L"[\\x00-\\x20]+$");
std::wregex wrReplaceRegex(L"[\\u0000-\\u0017]+$");
sInfo = std::regex_replace(sInfo, wrReplaceRegex, L"");
HWP_STRING sType;
@ -147,6 +144,9 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
sType[2] = (sInfo[1] & 0xFF);
sType[3] = ((sInfo[1] >> 8) & 0xFF);
if (0x17 >= sType[3])
sType[3] = L' ';
//TODO:: более подробно разобраться в данном моменте
if (L"daeh" == sType ||
L"tood" == sType)
@ -170,6 +170,11 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
arParas.push_back(new CCtrlTable(sType));
else if (L"deqe" == sType)
arParas.push_back(new CCtrlEqEdit(sType));
else if (L"klh%" == sType || // hyperlink start
L"klh " == sType || // hyperlink end
L"kmb%" == sType || // bookmark start
L"kmb " == sType) // bookmark end
arParas.push_back(new CCtrlField(sType));
}
nPrevIndex = itCurrent->position() + itCurrent->length();
@ -180,7 +185,7 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
sCurrentText += sText.substr(nPrevIndex);
if (!sCurrentText.empty())
arParas.push_back(new CParaText(L"____", sCurrentText, nPrevIndex));
arParas.push_back(new CParaText(L"____", sCurrentText, nPrevIndex + 1));
oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true));
return arParas;

View File

@ -4,6 +4,12 @@
#include "../OfficeUtils/src/OfficeUtils.h"
#include "../DesktopEditor/common/Directory.h"
// For decrypt
#include "../../Common/3dParty/cryptopp/modes.h"
#include "../../Common/3dParty/cryptopp/aes.h"
#include "../../Common/3dParty/cryptopp/filters.h"
// ----------
#define DEFAULT_BUFFER_SIZE 8096
namespace HWP
@ -67,7 +73,7 @@ bool CHWPFile::Open()
if (!m_oFileHeader.Distributable() && !GetBodyText(m_nVersion))
return false;
if (!m_oFileHeader.Distributable() && !GetViewText(m_nVersion))
if (m_oFileHeader.Distributable() && !GetViewText(m_nVersion))
return false;
return true;
@ -115,35 +121,7 @@ bool CHWPFile::GetComponent(const HWP_STRING& sEntryName, CHWPStream& oBuffer)
{
return m_oOleFile.GetComponent(sEntryName, oBuffer);
}
//TODO:: написанно, что данные методы используются только для отображения в LibbreOffice
// проверить и если нужны будут, то реализовать
VECTOR<CDirectoryEntry*> CHWPFile::GetBinData()
{
return VECTOR<CDirectoryEntry*>();
}
void CHWPFile::SetBinData(const std::vector<CDirectoryEntry*>& arBinData)
{
}
VECTOR<CHWPPargraph*> CHWPFile::GetParas()
{
return VECTOR<CHWPPargraph*>();
}
void CHWPFile::AddParas(const std::vector<CHWPPargraph*>& arParas)
{
}
//------------
void CHWPFile::SaveChildEntries(const HWP_STRING& sBasePath, const HWP_STRING& sStorageName, ECompressed eCompressed)
{
// TODO:: перенести
}
CDirectoryEntry* CHWPFile::FindChildEntry(const HWP_STRING& sBasePath, const CDirectoryEntry& oBaseEntry, const HWP_STRING& sEntryName) const
{
for (CDirectoryEntry* pEntry : m_oOleFile.GetChildEntries(&oBaseEntry))
@ -303,6 +281,24 @@ bool CHWPFile::Unzip(CHWPStream& oInput, CHWPStream& oBuffer)
return DEFLATE_OK == nRes || DEFLATE_STREAM_END == nRes;
}
// Так как на всех ОС необходимо одинаковое поведение,
// то используем свой рандомайзер
class CRandomizer
{
uint32_t m_unSeed;
public:
CRandomizer(uint32_t unSeed)
: m_unSeed(unSeed)
{}
int rand()
{
m_unSeed = m_unSeed * 214013L + 2531011L;
return (m_unSeed >> 16) & 0x7fff;
}
};
bool CHWPFile::Decrypt(CHWPStream& oInput, CHWPStream& oBuffer)
{
int nHeader;
@ -320,8 +316,43 @@ bool CHWPFile::Decrypt(CHWPStream& oInput, CHWPStream& oBuffer)
if (256 != nSize)
return false;
//TODO:: реализовать
return false;
CHWPStream oDocData(256);
oDocData.Copy(oInput, 256);
oInput.Skip(256);
int nSeed;
oDocData.ReadInt(nSeed);
oDocData.Skip(-4);
CRandomizer oRandomizer(nSeed);
unsigned char chKey;
for (unsigned int unIndex = 0, unCount = 0; unIndex < 256; ++unIndex)
{
if (0 == unCount)
{
chKey = oRandomizer.rand() & 0xFF;
unCount = (oRandomizer.rand() & 0xF) + 1;
}
if (unIndex >= 4)
*(oDocData.GetCurPtr() + unIndex) = oDocData[unIndex] ^ chKey;
--unCount;
}
int nHashOffset = (nSeed & 0x0f) + 4;
oBuffer.Expand(oInput.SizeToEnd());
using namespace CryptoPP;
ECB_Mode<AES>::Decryption oDecryptor;
oDecryptor.SetKey((byte*)(oDocData.GetCurPtr() + nHashOffset), 16);
ArraySource((byte*)oInput.GetCurPtr(), oInput.SizeToEnd(), true, new StreamTransformationFilter(oDecryptor, new ArraySink( (byte*)oBuffer.GetCurPtr(), oBuffer.GetSize()), StreamTransformationFilter::NO_PADDING));
return true;
}
bool CHWPFile::GetBodyText(int nVersion)

View File

@ -32,13 +32,8 @@ public:
const CHWPDocInfo* GetDocInfo() const;
bool GetDocInfo(int nVersion);
bool GetComponent(const HWP_STRING& sEntryName, CHWPStream& oBuffer);
VECTOR<CDirectoryEntry*> GetBinData();
void SetBinData(const VECTOR<CDirectoryEntry*>& arBinData);
VECTOR<CHWPPargraph*> GetParas();
void AddParas(const VECTOR<CHWPPargraph*>& arParas);
bool GetChildStream(const HWP_STRING& sEntryName, ECompressed eCompressed, CHWPStream& oBuffer);
private:
void SaveChildEntries(const HWP_STRING& sBasePath, const HWP_STRING& sStorageName, ECompressed eCompressed);
CDirectoryEntry* FindChildEntry(const HWP_STRING& sBasePath, const CDirectoryEntry& oBaseEntry, const HWP_STRING& sEntryName) const;
HWP_STRING SaveChildEntry(const HWP_STRING& sRootPath, const HWP_STRING& sEntryName, ECompressed eCompressed);

View File

@ -529,8 +529,6 @@ int CHWPSection::ParseCtrlRecurse(CCtrl* pCurrCtrl, int nRunLevel, CHWPStream& o
ParseRecurse(pNewPara, nLevel, oBuffer, 0, nVersion);
}
else if (ECtrlObjectType::Shape == pCtrl->GetCtrlType())
// else if (nullptr != dynamic_cast<CCtrlShapeRect*>(pCtrl) ||
// nullptr != dynamic_cast<CCtrlGeneralShape*>(pCtrl))
{
CCtrlCommon* pCtrlCommon = (CCtrlCommon*)pCtrl;
oBuffer.Skip(-6);
@ -573,7 +571,6 @@ int CHWPSection::ParseCtrlRecurse(CCtrl* pCurrCtrl, int nRunLevel, CHWPStream& o
case HWPTAG_SHAPE_COMPONENT_TEXTART:
case HWPTAG_SHAPE_COMPONENT_UNKNOWN:
{
// if (nullptr != dynamic_cast<CCtrlGeneralShape*>(pCtrl))
if (ECtrlObjectType::Shape == pCtrl->GetCtrlType())
ParseCtrlRecurse((CCtrlGeneralShape*)pCtrl, nLevel, oBuffer, 0, nVersion);
else
@ -856,6 +853,8 @@ int CHWPSection::ParseCtrlRecurse(CCtrl* pCurrCtrl, int nRunLevel, CHWPStream& o
}
}
oBuffer.RemoveLastSavedPos();
return 0;
}
@ -895,6 +894,7 @@ int CHWPSection::ParseContainerRecurse(CCtrlContainer* pContainer, int nRunLevel
while (oBuffer.CanRead())
{
oBuffer.ReadInt(nHeader);
oBuffer.Skip(-4);
nTagNum = nHeader & 0x3FF; // 10 bits (0 - 9 bit)
nLevel = (nHeader & 0xFFC00) >> 10; // 10 bits (10-19 bit)
nSize = (nHeader & 0xFFF00000) >> 20; // 12 bits (20-31 bit)
@ -979,7 +979,6 @@ int CHWPSection::ParseContainerRecurse(CCtrlContainer* pContainer, int nRunLevel
{
CCtrlGeneralShape* pCtrl = pContainer->GetLastShape();
int nSubParaCount = CHWPRecordListHeader::GetCount(nTagNum, nLevel, nSize, oBuffer, 0, nVersion);
oBuffer.Skip(6);
if (EShapeType::Rect == pCtrl->GetShapeType() || EShapeType::Polygon == pCtrl->GetShapeType())
{

View File

@ -36,6 +36,11 @@ void CHWPStream::Clear()
m_arSavedPositions.pop();
}
void CHWPStream::Copy(CHWPStream& oStream, unsigned long ulSize)
{
memcpy(m_pCur, oStream.GetCurPtr(), (std::min)(SizeToEnd(), (unsigned long)(std::min)(ulSize, oStream.SizeToEnd())));
}
void CHWPStream::SetStream(HWP_BYTE* pBuffer, unsigned long ulSize, bool bExternalBuffer)
{
m_pBegin = pBuffer;

View File

@ -28,6 +28,7 @@ public:
~CHWPStream();
void Clear();
void Copy(CHWPStream& oStream, unsigned long ulSize);
void SetStream(HWP_BYTE* pBuffer, unsigned long ulSize, bool bExternalBuffer = true);

View File

@ -1,5 +1,6 @@
#include "CharShape.h"
#include "CtrlCharacter.h"
#include "CtrlAutoNumber.h"
#include "ParaText.h"
#include <algorithm>

View File

@ -6,6 +6,7 @@
#include "CtrlNewNumber.h"
#include "CtrlNote.h"
#include "CtrlPageNumPos.h"
#include "CtrlField.h"
namespace HWP
{
@ -67,6 +68,9 @@ CCtrl* CCtrl::GetCtrl(CXMLNode& oNode, int nVersion)
return new CCtrlNewNumber(L"onwn", oNode, nVersion);
else if (L"hp:pageNum" == oNode.GetName())
return new CCtrlPageNumPos(L"pngp", oNode, nVersion);
else if (L"hp:fieldBegin" == oNode.GetName() ||
L"hp:fieldEnd" == oNode.GetName())
return new CCtrlField(L"", oNode, nVersion);
return nullptr;
}

View File

@ -22,6 +22,7 @@ enum class ECtrlObjectType
Table,
ParaText,
Common,
Field,
Empty
};

View File

@ -1,7 +1,7 @@
#include "CtrlCommon.h"
#include "../Common/Common.h"
#include "CellParagraph.h"
#include "CapParagraph.h"
namespace HWP
{
@ -337,8 +337,8 @@ namespace HWP
for (CXMLNode& oSubList : oChild.GetChilds(L"hp:subList"))
{
for (CXMLNode& oParagraph : oSubList.GetChilds(L"p"))
m_arParas.push_back(new CCellParagraph(oParagraph, nVersion));
for (CXMLNode& oParagraph : oSubList.GetChilds(L"hp:p"))
m_arCaption.push_back(new CCapParagraph(oParagraph, nVersion));
}
}
}
@ -497,6 +497,16 @@ namespace HWP
return m_nZOrder;
}
bool CCtrlCommon::HaveCaption() const
{
return !m_arCaption.empty();
}
std::vector<const CCapParagraph*> CCtrlCommon::GetCaptionParas() const
{
RETURN_VECTOR_CONST_PTR(CCapParagraph, m_arCaption);
}
int CCtrlCommon::ParseCtrl(CCtrlCommon& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
{
HWP_STRING sCtrlId;

View File

@ -149,6 +149,9 @@ public:
HWP_BYTE GetTextFlow() const;
int GetZOrder() const;
bool HaveCaption() const;
VECTOR<const CCapParagraph*> GetCaptionParas() const;
static int ParseCtrl(CCtrlCommon& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
static int ParseCaption(CCtrlCommon& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
};

View File

@ -0,0 +1,113 @@
#include "CtrlField.h"
#include <iostream>
#include <ostream>
namespace HWP
{
CCtrlField::CCtrlField(const HWP_STRING& sCtrlID)
: CCtrl(sCtrlID), m_eType(EFieldType::Unknown)
{
UpdateType(sCtrlID);
}
CCtrlField::CCtrlField(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
: CCtrl(sCtrlID), m_eType(EFieldType::Unknown)
{
UpdateType(sCtrlID);
oBuffer.ReadInt(m_nProperty);
oBuffer.ReadByte(m_chEtcProperty);
oBuffer.ReadString(m_sCommand, EStringCharacter::UTF16);
oBuffer.ReadInt(m_nInstanceID);
}
void CCtrlField::UpdateType(const HWP_STRING& sCtrlID)
{
if (L"klh%" == sCtrlID)
m_eType = EFieldType::Hyperlink;
else if (L"klh " == sCtrlID)
m_eType = EFieldType::HyperlinkClosing;
else if (L"kmb%" == sCtrlID)
m_eType = EFieldType::Bookmark;
else if (L"kmb " == sCtrlID)
m_eType = EFieldType::BookmarkClosing;
}
CCtrlField::CCtrlField(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion)
: CCtrl(sCtrlID), m_eType(EFieldType::Unknown)
{
if (L"hp:fieldBegin" == oNode.GetName())
{
HWP_STRING sType = oNode.GetAttribute(L"type");
if (L"HYPERLINK" == sType)
m_eType = EFieldType::Hyperlink;
else if (L"BOOKMARK" == sType)
m_eType = EFieldType::Bookmark;
m_nInstanceID = oNode.GetAttributeInt(L"fieldid");
HWP_STRING sName = oNode.GetAttribute(L"name");
if (!sName.empty() && EFieldType::Bookmark == m_eType)
AddStringParam(L"bookmarkname", sName);
for (CXMLNode& oChild : oNode.GetChild(L"hp:parameters").GetChilds())
{
if (L"hp:stringParam" == oChild.GetName())
AddStringParam(oChild.GetAttribute(L"name"), oChild.GetText());
else if (L"hp:integerParam" == oChild.GetName())
AddIntegerParam(oChild.GetAttribute(L"name"), std::stoi(oChild.GetText()));
}
}
else if (L"hp:fieldEnd" == oNode.GetName())
{
m_nInstanceID = oNode.GetAttributeInt(L"fieldid");
}
}
ECtrlObjectType CCtrlField::GetCtrlType() const
{
return ECtrlObjectType::Field;
}
void CCtrlField::AddStringParam(const HWP_STRING& wsName, const HWP_STRING& wsValue)
{
m_mStringParams.insert(std::make_pair(wsName, wsValue));
}
void CCtrlField::AddIntegerParam(const HWP_STRING& wsName, int nValue)
{
m_mIntegerParam.insert(std::make_pair(wsName, nValue));
}
HWP_STRING CCtrlField::GetStringParam(const HWP_STRING& wsName) const
{
std::map<HWP_STRING, HWP_STRING>::const_iterator itFound = m_mStringParams.find(wsName);
return ((m_mStringParams.cend() != itFound) ? itFound->second : HWP_STRING());
}
int CCtrlField::GetIntegerParam(const HWP_STRING& wsName) const
{
std::map<HWP_STRING, int>::const_iterator itFound = m_mIntegerParam.find(wsName);
return ((m_mIntegerParam.cend() != itFound) ? itFound->second : 0);
}
int CCtrlField::GetInstanceID() const
{
return m_nInstanceID;
}
EFieldType CCtrlField::GetType() const
{
return m_eType;
}
HWP_STRING CCtrlField::GetCommand() const
{
return m_sCommand;
}
}

View File

@ -0,0 +1,51 @@
#ifndef CTRLFIELD_H
#define CTRLFIELD_H
#include "Ctrl.h"
#include "../HWPStream.h"
namespace HWP
{
enum class EFieldType
{
Hyperlink,
HyperlinkClosing,
Bookmark,
BookmarkClosing,
Unknown
};
class CCtrlField : public CCtrl
{
int m_nProperty;
HWP_BYTE m_chEtcProperty;
HWP_STRING m_sCommand;
int m_nInstanceID;
EFieldType m_eType;
std::map<HWP_STRING, HWP_STRING> m_mStringParams;
std::map<HWP_STRING, int> m_mIntegerParam;
void UpdateType(const HWP_STRING& sCtrlID);
public:
CCtrlField(const HWP_STRING& sCtrlID);
CCtrlField(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
CCtrlField(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion);
ECtrlObjectType GetCtrlType() const override;
void AddStringParam(const HWP_STRING& wsName, const HWP_STRING& wsValue);
void AddIntegerParam(const HWP_STRING& wsName, int nValue);
HWP_STRING GetStringParam(const HWP_STRING& wsName) const;
int GetIntegerParam(const HWP_STRING& wsName) const;
int GetInstanceID() const;
EFieldType GetType() const;
HWP_STRING GetCommand() const;
};
}
#endif // CTRLFIELD_H

View File

@ -179,7 +179,7 @@ const CPage* CCtrlSectionDef::GetPage() const
return m_pPage;
}
std::vector<const CCtrlHeadFoot*> CCtrlSectionDef::GetHeaderFooters() const
VECTOR<const CCtrlHeadFoot*> CCtrlSectionDef::GetHeaderFooters() const
{
VECTOR<const CCtrlHeadFoot*> arHeaderFooters(m_arHeaderFooter.size());

View File

@ -47,6 +47,21 @@ EShapeType CCtrlShapeArc::GetShapeType() const
return EShapeType::Arc;
}
TPoint CCtrlShapeArc::GetCenterPoint() const
{
return {m_nCenterX, m_nCenterY};
}
TPoint CCtrlShapeArc::GetFirstPoint() const
{
return {m_nAxixX1, m_nAxixY1};
}
TPoint CCtrlShapeArc::GetSecondPoint() const
{
return {m_nAxixX2, m_nAxixY2};
}
int CCtrlShapeArc::ParseElement(CCtrlShapeArc& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
{
oBuffer.SavePosition();

View File

@ -2,6 +2,7 @@
#define CTRLSHAPEARC_H
#include "CtrlShapeEllipse.h"
#include "Point.h"
namespace HWP
{
@ -23,6 +24,10 @@ public:
EShapeType GetShapeType() const override;
TPoint GetCenterPoint() const;
TPoint GetFirstPoint() const;
TPoint GetSecondPoint() const;
static int ParseElement(CCtrlShapeArc& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
static int ParseCtrl(CCtrlShapeArc& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
};

View File

@ -22,7 +22,7 @@ CCtrlShapeCurve::CCtrlShapeCurve(const HWP_STRING& sCtrlID, CXMLNode& oNode, int
{
std::vector<CXMLNode> arChilds{oNode.GetChilds(L"hp:seg")};
m_arPoints.resize(arChilds.size());
m_arPoints.resize(arChilds.size() + 1);
m_arSegmentType.resize(arChilds.size());
HWP_STRING sType;
@ -38,6 +38,12 @@ CCtrlShapeCurve::CCtrlShapeCurve(const HWP_STRING& sCtrlID, CXMLNode& oNode, int
m_arPoints[unIndex].m_nX = arChilds[unIndex].GetAttributeInt(L"x1");
m_arPoints[unIndex].m_nY = arChilds[unIndex].GetAttributeInt(L"y1");
if (unIndex == arChilds.size() - 1)
{
m_arPoints[unIndex + 1].m_nX = arChilds[unIndex].GetAttributeInt(L"x2");
m_arPoints[unIndex + 1].m_nY = arChilds[unIndex].GetAttributeInt(L"y2");
}
}
}
@ -46,6 +52,16 @@ EShapeType CCtrlShapeCurve::GetShapeType() const
return EShapeType::Curve;
}
VECTOR<TPoint> CCtrlShapeCurve::GetPoints() const
{
return m_arPoints;
}
VECTOR<HWP_BYTE> CCtrlShapeCurve::GetSegmentsType() const
{
return m_arSegmentType;
}
int CCtrlShapeCurve::ParseElement(CCtrlShapeCurve& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
{
oBuffer.SavePosition();

View File

@ -9,8 +9,8 @@ namespace HWP
class CCtrlShapeCurve : public CCtrlGeneralShape
{
int m_nPoints;
std::vector<TPoint> m_arPoints;
std::vector<HWP_BYTE> m_arSegmentType;
VECTOR<TPoint> m_arPoints;
VECTOR<HWP_BYTE> m_arSegmentType;
public:
CCtrlShapeCurve();
CCtrlShapeCurve(const HWP_STRING& sCtrlID);
@ -20,6 +20,9 @@ public:
EShapeType GetShapeType() const override;
VECTOR<TPoint> GetPoints() const;
VECTOR<HWP_BYTE> GetSegmentsType() const;
static int ParseElement(CCtrlShapeCurve& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
static int ParseCtrl(CCtrlShapeCurve& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
};

View File

@ -38,6 +38,11 @@ EShapeType CCtrlShapePolygon::GetShapeType() const
return EShapeType::Polygon;
}
std::vector<TPoint> CCtrlShapePolygon::GetPoints() const
{
return m_arPoints;
}
int CCtrlShapePolygon::ParseElement(CCtrlShapePolygon& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
{
oBuffer.SavePosition();

View File

@ -19,6 +19,8 @@ public:
EShapeType GetShapeType() const override;
VECTOR<TPoint> GetPoints() const;
static int ParseElement(CCtrlShapePolygon& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
static int ParseCtrl(CCtrlShapePolygon& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
static int ParseListHeaderAppend(CCtrlShapePolygon& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);

View File

@ -17,15 +17,15 @@ CCtrlShapeVideo::CCtrlShapeVideo(const HWP_STRING& sCtrlID, int nSize, CHWPStrea
CCtrlShapeVideo::CCtrlShapeVideo(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion)
: CCtrlGeneralShape(sCtrlID, oNode, nVersion)
{
HWP_STRING sType = oNode.GetAttribute(L"type");
HWP_STRING sType = oNode.GetAttribute(L"videotype");
if (L"VT_LOCAL" == sType)
if (L"Local" == sType)
m_nVideoType = 0;
else if (L"VT_WEB" == sType)
else if (L"Web" == sType)
m_nVideoType = 1;
m_shVideoBinID = oNode.GetAttributeInt(L"fileIDRef");
m_sThumnailBinID = oNode.GetAttributeInt(L"imageIDRef");
m_sThumnailBinID = oNode.GetAttribute(L"imageIDRef");
if (1 == m_nVideoType)
m_sWebURL = oNode.GetAttribute(L"tag");
@ -65,7 +65,7 @@ int CCtrlShapeVideo::ParseElement(CCtrlShapeVideo& oObj, int nSize, CHWPStream&
if (0 == oObj.m_nVideoType)
oBuffer.ReadShort(oObj.m_shVideoBinID);
else if (1 == oObj.m_nVideoType)
oBuffer.ReadString(oObj.m_sObjDesc, EStringCharacter::UTF16);
oBuffer.ReadString(oObj.m_sWebURL, EStringCharacter::UTF16);
short m_sBinID;
oBuffer.ReadShort(m_sBinID);

View File

@ -67,8 +67,6 @@ CHWPPargraph::~CHWPPargraph()
{
if (nullptr != m_pLineSegs)
delete m_pLineSegs;
CLEAR_ARRAY(TRangeTag, m_arRangeTags);
}
bool CHWPPargraph::ParseHWPParagraph(CXMLNode& oNode, int nCharShapeID, int nVersion)
@ -163,9 +161,9 @@ void CHWPPargraph::SetLineSeg(CLineSeg* pLineSeg)
m_pLineSegs = pLineSeg;
}
void CHWPPargraph::AddRangeTag(TRangeTag* pRangeTag)
void CHWPPargraph::AddRangeTag(const TRangeTag& oRangeTag)
{
m_arRangeTags.push_back(pRangeTag);
m_arRangeTags.push_back(oRangeTag);
}
void CHWPPargraph::AddCtrl(CCtrl* pCtrl)
@ -229,6 +227,11 @@ const CLineSeg* CHWPPargraph::GetLineSeg() const
return m_pLineSegs;
}
VECTOR<TRangeTag> CHWPPargraph::GetRangeTags() const
{
return m_arRangeTags;
}
CHWPPargraph* CHWPPargraph::Parse(int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
{
CHWPPargraph *pPara = new CHWPPargraph();

View File

@ -22,7 +22,7 @@ class CHWPPargraph : public IRef
HWP_BYTE m_chBreakType; // HWPTAG_PARA_HEADER
CLineSeg *m_pLineSegs; // HWPTAG_PARA_LINE_SEG
VECTOR<TRangeTag*> m_arRangeTags; // HWPTAG_PARA_RANGE_TAG
VECTOR<TRangeTag> m_arRangeTags; // HWPTAG_PARA_RANGE_TAG
VECTOR<CCtrl*> m_arP; //HWPTAG_PARA_TEXT
@ -36,7 +36,7 @@ public:
void SetLineSeg(CLineSeg* pLineSeg);
void AddRangeTag(TRangeTag* pRangeTag);
void AddRangeTag(const TRangeTag& oRangeTag);
void AddCtrl(CCtrl* pCtrl);
void AddCtrls(const LIST<CCtrl*>& arCtrls);
@ -53,6 +53,8 @@ public:
const CLineSeg* GetLineSeg() const;
VECTOR<TRangeTag> GetRangeTags() const;
static CHWPPargraph* Parse(int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
static int Parse(CHWPPargraph& oPara, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);

View File

@ -1,13 +1,16 @@
#ifndef RANGETAG_H
#define RANGETAG_H
#include "../Common/Common.h"
namespace HWP
{
struct TRangeTag
{
int m_nStartPos;
int m_nEndPos;
int m_nTag;
HWP_BYTE m_chType;
HWP_BYTE m_arData[3];
};
}

View File

@ -6,8 +6,8 @@ int main()
{
CHWPFile oFile;
if (oFile.OpenHWPX(L"C:/ONLYOFFICE/Files/hwpx/test_multiple_elements.hwpx"))
// if (oFile.OpenHWP(L"C:/ONLYOFFICE/Files/hwp/Examples/test_rect.hwp"))
// if (oFile.OpenHWPX(L"YOUR_PATH"))
if (oFile.OpenHWP(L"YOUR_PATH"))
{
std::cout << "Successful" << std::endl;
}
@ -23,4 +23,5 @@ int main()
NSDirectory::CreateDirectory(wsTempDir);
oFile.SetTempDirectory(wsTempDir);
oFile.ConvertToOOXML(L"result.docx");
oFile.Close();
}

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