Compare commits

..

277 Commits

Author SHA1 Message Date
64c7b7a3fd handout binary 2026-02-02 22:36:39 +03:00
d286b8459b Add offset for unexisted symbol (last width) 2026-02-02 15:36:07 +03:00
ff93f1e8b3 Merge pull request 'Fix bug #79712' (#636) from fix/bug-79712 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/636
2026-02-02 11:08:52 +00:00
4471940b92 Fix bug #79712 2026-01-31 18:26:05 +03:00
6df0cf26f3 Merge pull request 'fix bug #79684' (#634) from fix/bug79684 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/634
2026-01-30 14:24:20 +00:00
720d66ad74 Merge pull request 'fix bug #79698' (#633) from fix/bug79698 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/633
2026-01-30 14:23:49 +00:00
e6522c6ce4 Merge pull request 'fix bug #79699' (#632) from fix/bug79699 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/632
2026-01-30 14:23:23 +00:00
9b3c2291d8 Merge pull request 'Fix subset tag font' (#635) from fix/pdf-font into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/635
2026-01-30 13:49:31 +00:00
e7cfb67962 Fix subset tag font 2026-01-30 16:44:57 +03:00
8725be55f0 fix bug #79699 2026-01-30 18:48:21 +06:00
37ae77d0d2 fix bug #79698 2026-01-30 16:23:03 +06:00
4c6ded76a1 Merge pull request 'Fix bug 67390' (#631) from fix/bug67390 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/631
2026-01-30 08:54:09 +00:00
2d8701cd4f Fix bug 67390 2026-01-30 11:25:45 +03:00
d5c321d47d fix bug #79684 2026-01-30 14:25:41 +06:00
324f7b3933 Merge pull request 'feature/add-xls-writing' (#630) from feature/add-xls-writing into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/630
2026-01-30 07:21:45 +00:00
edef6a83c8 Merge pull request 'feature/docx-renderer' (#629) from feature/docx-renderer into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/629
2026-01-30 05:02:42 +00:00
e7c21fb2cd Fix bugs 2026-01-30 06:43:34 +03:00
be8ba62c3f Merge pull request 'release/v9.3.0' from release/v9.3.0 into feature/docx-renderer 2026-01-29 22:26:04 +00:00
fda8c8e445 No calc asc/desc using spaces in text lines 2026-01-30 01:15:24 +03:00
d9ebae1724 Change single line width 2026-01-29 23:53:19 +03:00
f4867bd9f9 Fix more bugs 2026-01-29 22:26:37 +03:00
9b9da90dcc Fix bugs 2026-01-29 22:03:24 +03:00
cba4bc8085 add legend conversion 2026-01-29 20:41:24 +06:00
325c2d3000 Fix text line shape between lines of paragraph 2026-01-29 16:50:48 +03:00
3187913c8e fix bug #79660 2026-01-29 16:46:05 +03:00
8958d13b56 fix bug #78766 2026-01-29 15:25:40 +03:00
9d13526724 add line 3d chart conversion 2026-01-29 16:56:37 +06:00
93f70176bc add area chart3d conversion 2026-01-29 16:40:44 +06:00
e2ad965d7c add 3dBarChartConversion 2026-01-29 15:58:06 +06:00
d535aa64ef Merge pull request 'Fix bug 75486' (#607) from fix/bug75486 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/607
2026-01-29 09:46:37 +00:00
c155a4c53a add chart3d conversion 2026-01-29 15:11:42 +06:00
97cbd8dcc7 Fix text shape offsets 2026-01-29 09:42:54 +03:00
d38576085c Merge pull request 'fix/bug79554' (#627) from fix/bug79554 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/627
2026-01-28 17:48:19 +00:00
46dd9efa2e for bug #47231 2026-01-28 16:58:30 +03:00
6af52920a2 fix/bug79554
fix bug #79554
2026-01-28 16:51:11 +03:00
f13baca136 Fix build with c++14 2026-01-28 16:16:32 +03:00
28a91a1519 add area chart conversion 2026-01-28 17:57:30 +06:00
0e48e65ef1 add radar chart conversion 2026-01-28 17:44:31 +06:00
ad1709d4af Merge pull request 'Fix include' (#626) from fix/pdf-font into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/626
2026-01-28 11:26:33 +00:00
e2c6ecec9b Fix include 2026-01-28 14:20:27 +03:00
ef55594f90 Merge pull request 'Fix pdf font' (#625) from fix/pdf-font into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/625
2026-01-28 09:48:08 +00:00
223bbe3347 Fix bug 79318 2026-01-28 12:23:29 +03:00
eca0cdb318 Fix GIDByUnicode for non-CID font 2026-01-28 11:35:21 +03:00
4a52368c30 Merge remote-tracking branch 'origin/release/v9.3.0' into release/v9.3.0 2026-01-27 16:23:22 +00:00
73f4e20c56 Fix qmake bug 2026-01-27 19:21:05 +03:00
d53768969b . 2026-01-27 16:20:16 +00:00
324d6ec0bd Merge pull request 'fix/bug79433' (#624) from fix/bug79433 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/624
2026-01-27 13:25:07 +00:00
767b652ef2 fix/bug79433
fix bug #79433 and fix 51965
2026-01-27 16:10:42 +03:00
68f2f0760d fix surface conversion 2026-01-27 18:35:55 +06:00
694282a013 Merge pull request 'Fix bug 79426' (#623) from fix/bug-79426 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/623
2026-01-27 10:39:07 +00:00
e64eeb26af Fix bug 79426 2026-01-27 13:31:41 +03:00
873b2b9351 Add scatter chart conversion 2026-01-27 16:23:03 +06:00
d5ecb00472 Add surf chart conversion 2026-01-27 16:22:46 +06:00
2ac6801afa add area chart conversion 2026-01-27 14:39:29 +06:00
213c65fe54 Add line chart conversion 2026-01-27 14:23:07 +06:00
8269c14207 Merge pull request 'fix/bug77970' (#622) from fix/bug77970 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/622
2026-01-27 08:20:57 +00:00
f438a17779 fix bug #79483 2026-01-27 00:39:19 +03:00
9c8b739d0e fix bug #77970 2026-01-27 00:38:21 +03:00
7f0720bb95 Merge pull request 'Fix merging conts' (#621) from fix/docx-renderer-merge-conts-fix into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/621
2026-01-26 15:28:13 +00:00
846b212882 Fix merging conts 2026-01-26 18:22:05 +03:00
344a096e24 Merge pull request 'PdfWriter use embedded fonts' (#619) from fix/pdf-font into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/619
2026-01-26 14:07:14 +00:00
15eb4793f5 Fix CodeToUnicode and CodeToGID 2026-01-26 15:31:44 +03:00
3ce4b4bfe8 Merge pull request 'Fix readAnnotationsInfoFromBinary Link' (#620) from fix/pdf-action into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/620
2026-01-26 10:00:29 +00:00
b8fab6f4df Fix readAnnotationsInfoFromBinary Link 2026-01-26 12:56:03 +03:00
7ebf12c1e4 Complete PdfFont 2026-01-23 17:16:58 +03:00
1813e09e1f add chart title conversion 2026-01-23 20:02:11 +06:00
d2a986c480 Merge pull request 'fix/bug59965' (#618) from fix/bug59965 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/618
2026-01-22 13:27:24 +00:00
73880f6207 fix/bug59965
fix #bug59965
2026-01-22 16:22:47 +03:00
24ad4adf6f Merge pull request 'fix/bug79432' (#616) from fix/bug79432 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/616
2026-01-22 13:15:38 +00:00
e4ea19ed81 fix/bug79432
fix #bug79432
2026-01-22 15:59:33 +03:00
575e379c4b Develop PdfFont 2026-01-22 15:11:17 +03:00
86d8c7bfa3 Change anchor 2026-01-22 14:20:41 +03:00
a3e1efb75b add pie chart conversion 2026-01-22 17:13:59 +06:00
e1f7feb5c1 fix bar chart conversion 2026-01-22 15:43:49 +06:00
13008c60e5 Merge pull request 'Fix signature size of xref' (#615) from fix/pdf-signature into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/615
2026-01-21 15:41:53 +00:00
df69099689 Fix Copy ProxyObject 2026-01-21 18:36:26 +03:00
4e6f6e44bd Fix clear ProxyObject 2026-01-21 18:32:44 +03:00
67b54dc371 Fix signature size of xref 2026-01-21 18:28:21 +03:00
b0c3172ae5 Remove wrong comment 2026-01-21 18:13:11 +03:00
91d21a80ac Add support sign params 2026-01-21 18:11:03 +03:00
e820a9c936 fix chart conversion 2026-01-21 19:08:27 +06:00
b38b12dfaf Merge pull request 'Fix empty password' (#614) from fix/pdf-password into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/614
2026-01-21 13:03:16 +00:00
39b9e89e77 Fix empty password 2026-01-21 16:01:24 +03:00
0b6ea2a399 Create PdfFont 2026-01-21 15:51:28 +03:00
eee3161833 save tsv 2026-01-21 13:53:11 +03:00
fc422bb2e7 fix chartsheet writing 2026-01-21 16:30:57 +06:00
f359f180bb Merge branch 'develop' into feature/add-xls-writing 2026-01-21 13:26:04 +06:00
b0338919fe [android] Add ooxmlsignature 2026-01-21 09:05:41 +03:00
41358e3308 Fix build 2026-01-20 23:38:47 +03:00
1a29fb1389 Merge pull request 'feature/ios-swiftc' (#613) from feature/ios-swiftc into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/613
2026-01-20 20:30:42 +00:00
2fa048303f Add ooxmlsirnature ref to x2t 2026-01-20 20:57:02 +03:00
e837479426 Fix build 2026-01-20 19:57:20 +03:00
e8f68e3a40 Merge pull request 'for/bug70498' (#612) from for/bug70498 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/612
2026-01-20 16:24:30 +00:00
702987e00c Merge pull request 'Password NULL and empty' (#608) from fix/pdf-password into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/608
2026-01-20 15:56:50 +00:00
83745da5f3 add attached label conversion 2026-01-20 21:47:55 +06:00
6b73faac12 fix variable 2026-01-20 17:53:04 +03:00
cab91648ce Merge pull request 'fix/bug74265' (#611) from fix/bug74265 into for/bug70498
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/611
2026-01-20 14:47:32 +00:00
57b51a8854 fix prev 2026-01-20 17:44:40 +03:00
4a84b8887f Use environment variables set from build_tools 2026-01-20 17:11:04 +04:00
23027e4c2c Merge pull request 'fix bug #79436' (#610) from fix/bug79436 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/610
2026-01-20 12:31:17 +00:00
52c61219dc fix bug #79436 2026-01-20 16:57:10 +06:00
2c37dac18c Merge pull request 'For bug 59181' (#609) from fix/forbug59181 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/609
2026-01-20 10:02:27 +00:00
aa7f104e60 Fix prev 2026-01-20 12:59:08 +03:00
83ea144c16 Merge branch 'release/v9.3.0' into fix/forbug59181 2026-01-20 12:22:50 +03:00
ea6fdc8872 For bug 59181 2026-01-20 11:47:09 +03:00
b64b31a972 Merge remote-tracking branch 'origin/release/v9.3.0' into develop 2026-01-20 11:35:55 +03:00
59fb6e4838 fix bug #79287 2026-01-20 11:16:58 +03:00
d38ce5b836 . 2026-01-19 22:23:33 +03:00
bb4ceb14e5 Password NULL and empty 2026-01-19 17:14:26 +03:00
ef9f25aa4d Fix bug 75486 2026-01-19 16:04:31 +03:00
0c2a5eac1b fix barChart conversion 2026-01-19 16:58:32 +06:00
0f85422315 Merge pull request 'fix bug #79291' (#595) from fix/bug79291 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/595
2026-01-19 09:28:31 +00:00
38fa7436c0 Merge pull request 'fix/bug59181' (#603) from fix/bug59181 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/603
2026-01-19 07:50:40 +00:00
e2ce58a055 Fix compilation for ios simulators 2026-01-18 20:54:56 +04:00
cadba798b0 for bug #70498 2026-01-18 16:54:18 +03:00
3941d5ced2 Add m_sCmapDir param 2026-01-16 21:20:38 +03:00
c529cc6d5c Merge pull request 'feature/docx-renderer' (#606) from feature/docx-renderer into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/606
2026-01-16 18:19:45 +00:00
31f274fbc4 add barChart crt conversion 2026-01-16 21:37:14 +06:00
58fe8ae679 Fix to compile both on ios and simulator
TODO: fails to compile for x86_64 ios_simulator
2026-01-16 18:35:26 +04:00
e3f77e11e0 Fix spacing problem 2026-01-16 17:17:57 +03:00
6e696daa15 add dv axis conversion 2026-01-16 20:15:31 +06:00
21dd930d30 Merge pull request 'Fix bug 79329' (#604) from fix/bug-79329 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/604
2026-01-16 13:45:33 +00:00
c4708222c6 Merge branch 'develop' into feature/add-xls-writing 2026-01-16 19:02:08 +06:00
34aae89432 Merge pull request 'Fix bug #79297' (#605) from fix/bug-79297 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/605
2026-01-16 12:53:48 +00:00
273454a391 Fix path reset 2026-01-16 14:53:19 +03:00
ae4edab75e For bug 79329 2026-01-16 14:20:28 +03:00
e61aa447f2 Merge pull request 'fix bug #76076' (#601) from fix/bug76076 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/601
2026-01-15 14:30:24 +00:00
6609e84bd1 Merge pull request 'for bug #78691' (#602) from fix/bug78691 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/602
2026-01-15 14:30:05 +00:00
402fe2c796 for bug #78691 2026-01-15 20:26:40 +06:00
e2aab8a241 Merge pull request 'Fix GetGIDByUnicode' (#599) from fix/pdf-text into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/599
2026-01-15 12:06:34 +00:00
555a251211 Fix GetGIDByUnicode 2026-01-15 15:04:42 +03:00
4a605d2424 Remove charspace fix 2026-01-15 13:33:47 +03:00
e49c4bc7fe Fix calcucaltion bug 2026-01-15 13:30:27 +03:00
f5a4e570bb Merge pull request 'Fix bug 78932' (#598) from fix/bug-78932 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/598
2026-01-15 10:30:23 +00:00
af5a87327b fix bug #76076 2026-01-15 16:28:35 +06:00
11c637deeb Fix bug 78932 2026-01-15 13:07:47 +03:00
b3a7e20b35 Merge pull request 'release/v9.3.0' (#597) from release/v9.3.0 into feature/docx-renderer
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/597
2026-01-15 09:13:16 +00:00
915576a819 [android] add libStarMathConverter 2026-01-15 11:35:33 +03:00
38a07b3c4d Merge pull request 'Fix Redact repeat XObject' (#596) from fix/pdf-bugs into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/596
2026-01-14 12:48:08 +00:00
ead20d7bfe Merge commit '2ff12c06a428232d1742d5f76970e8e87d83dc4f' into develop 2026-01-14 15:39:56 +03:00
90dc792fae Update ContText.cpp 2026-01-14 10:22:51 +03:00
0561ed2182 Fix Redact repeat forms 2026-01-13 17:47:04 +03:00
116ec89cd2 add ivaxis conversion 2026-01-13 19:20:37 +06:00
f44de11437 fix bug #79291 2026-01-13 15:15:37 +06:00
f5395b8b5f Add support swift files (TODO: calculate sdk/arch) 2026-01-12 23:00:01 +03:00
614222ee44 Fix bug #79297 2026-01-12 22:05:31 +03:00
1b5d71a14c Fix Redact repeat images 2026-01-12 17:27:27 +03:00
2ff12c06a4 Merge pull request 'fix bug #79272' (#594) from fix/bug79272 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/594
2026-01-12 11:45:21 +00:00
a3b6295058 fix bug #79272 2026-01-12 15:57:19 +06:00
efd9e3a29e Merge pull request 'Fix type of pdf print' (#593) from fix/pdf-print into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/593
2025-12-30 12:49:20 +00:00
0fa13f3659 Fix type of pdf print 2025-12-30 15:08:18 +03:00
8133e3f7b7 add axisParent conversion 2025-12-30 16:07:33 +06:00
7eabfd0838 Merge pull request 'fix/bug76636' (#592) from fix/bug76636 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/592
2025-12-29 18:45:28 +00:00
3081d02c9c Add ser2crt conversion 2025-12-29 19:24:13 +06:00
fd2710e46e For bug 59181 2025-12-29 14:57:48 +03:00
bc076fb5b6 fix/bug76636
fix bug #76636
2025-12-29 14:09:56 +03:00
33fa3fa38b Merge pull request 'Feature pdf print' (#590) from feature/pdf-print into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/590
2025-12-29 11:03:41 +00:00
9bc03ffdef Fix pdf PrintPages 2025-12-29 13:56:42 +03:00
91afd3d340 Merge branch 'develop' into feature/add-xls-writing 2025-12-29 15:28:05 +06:00
6018add7a5 Merge remote-tracking branch 'origin/release/v9.3.0' into feature/pdf-print 2025-12-29 11:23:19 +03:00
b616ce6fd7 Merge branch 'release/v9.3.0' into develop 2025-12-28 14:35:30 +03:00
570482b60d fix build 2025-12-28 14:32:22 +03:00
201cae0e6f pdf PrintPages 2025-12-26 23:08:41 +03:00
1cca5e3c12 Merge branch hotfix/v9.2.1 into release/v9.3.0 2025-12-26 16:24:55 +00:00
048eebc613 Merge branch hotfix/v9.2.1 into develop 2025-12-26 16:24:54 +00:00
760b4f9079 Merge pull request 'fix bug #79244' (#588) from fix/bug79244 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/588
2025-12-26 14:17:27 +00:00
578118380e add series style conversion 2025-12-26 19:53:11 +06:00
59f376908c Merge branch 'develop' into feature/add-xls-writing 2025-12-26 18:35:06 +06:00
38ceb61e4a Merge pull request 'Fix paths in pro file for starmath lib' (#589) from fix/build-starmath into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/589
2025-12-26 11:42:54 +00:00
b3a76d5678 Fix paths in pro file 2025-12-26 14:43:03 +04:00
c2d1bf113b fix bug #79244 2025-12-26 15:18:32 +06:00
bde1115962 Merge remote-tracking branch 'origin/release/v9.3.0' into feature/pdf-print 2025-12-26 10:19:42 +03:00
d8dc82ea35 Strip binaries on macos 2025-12-26 01:18:06 +03:00
0ef0518f1a Remove old linker flag on macos 2025-12-25 23:11:46 +03:00
f2da15defa Fix previous commit 2025-12-25 23:01:52 +03:00
e3272a5e91 Add strip binaries 2025-12-25 21:50:17 +03:00
d29dae37cb Merge pull request '[mac] Fix path to binary in docbuilder.py' (#587) from fix/py-mac-docbuilder into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/587
2025-12-25 18:31:07 +00:00
d82c96dc0f Fix path to binary in docbuilder.py on mac 2025-12-25 22:18:09 +04:00
69948ba383 . 2025-12-25 16:36:20 +03:00
d04f9cb8cf Merge pull request 'feature/EQN2OOXml2' (#419) from feature/EQN2OOXml2 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/419
2025-12-25 12:50:58 +00:00
5d6caf8a93 Add BRAI records conversion 2025-12-25 18:10:16 +06:00
f6ede7a53f Merge pull request 'Feature pdf new renderer command' (#586) from feature/pdf-new-command into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/586
2025-12-25 11:37:22 +00:00
3839ab4c15 Brush offset, brush scale, tile flip 2025-12-25 14:26:35 +03:00
6283a68841 add seriesFormat conversion 2025-12-25 16:06:52 +06:00
75477e8c03 fix text direction 2025-12-25 12:30:33 +03:00
527cc5f89f Merge branch 'release/v9.3.0' into develop 2025-12-25 11:53:08 +03:00
f4cb421b49 refactoring 2025-12-25 11:51:44 +03:00
83d8a073a7 Merge remote-tracking branch 'origin/release/v9.3.0' into fix/fix-bugs 2025-12-25 09:12:16 +03:00
55ba36f4d2 Merge pull request 'Add logs during snapshot creation' (#585) from feature/v8-snapshots-android into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/585
2025-12-24 18:58:57 +00:00
f760d03281 Remove LOGD in platform-common code 2025-12-24 22:57:52 +04:00
50ae7db2f0 add area format conversion 2025-12-24 17:38:27 +06:00
0e02919540 Merge pull request 'release/v9.3.0' (#584) from release/v9.3.0 into feature/EQN2OOXml2
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/584
2025-12-24 10:59:04 +00:00
1237991ffb Fix typo 2025-12-24 13:11:47 +03:00
5e5293b77b Merge remote-tracking branch 'origin/release/v9.3.0' into fix/fix-bugs 2025-12-24 12:35:09 +03:00
8250b59558 Test ConvertToRasterBase64 2025-12-24 11:10:19 +03:00
646c29166e Merge remote-tracking branch 'origin/feature/texture-fill' into release/v9.3.0 2025-12-23 19:34:09 +03:00
a2fc927b39 Resolve merge conflict 2025-12-23 17:58:22 +03:00
b6f024b73f Refactoring 2025-12-23 16:43:29 +03:00
3aca7bec15 Merge pull request 'For bug 79199' (#582) from fix/bug-79199 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/582
2025-12-23 13:40:02 +00:00
078ec02efd For bug 79199 2025-12-23 16:23:42 +03:00
dd17cb7243 add frame conversion 2025-12-23 19:16:45 +06:00
deff23eaac Merge pull request 'Fix bugs' (#581) from fix/svg into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/581
2025-12-22 12:58:25 +00:00
b3988b002f add chartformats conversion 2025-12-22 18:51:32 +06:00
db2a9e88a1 Merge pull request 'Fix bug 79153' (#580) from fix/bug-79153 into release/v9.3.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/580
2025-12-22 10:11:01 +00:00
a8fe05fb6a Fix bug 79153 2025-12-22 12:15:15 +03:00
bb3091b6f1 Merge branch 'develop' into feature/add-xls-writing 2025-12-22 13:26:37 +06:00
d908cb668e Refactoring sysroots 2025-12-22 05:55:07 +03:00
d595d3ea86 Refactoring sysroots 2025-12-20 23:42:01 +03:00
b000343b86 For bug 59181 2025-12-18 17:59:59 +03:00
707aab41f3 refactoring 2025-12-18 14:42:44 +03:00
482810712e Merge branch hotfix/v9.2.1 into develop 2025-12-17 15:27:40 +00:00
f38759d071 Refactoring 2025-12-17 17:29:48 +03:00
52e47745de Added the latex formula processing flag in md 2025-12-17 14:49:11 +03:00
554d3d0dfd Fix bug in html 2025-12-17 14:48:15 +03:00
c9100737e0 fix prev 2025-12-17 14:38:52 +03:00
ea338db68a add chart drawing conversion 2025-12-17 14:17:37 +06:00
76f3afc6c0 Merge branch 'develop' into feature/add-xls-writing 2025-12-16 16:16:04 +06:00
3870d23511 Realize AddPath in IRenderer 2025-12-11 15:58:40 +03:00
9c12c0b30a Merge remote-tracking branch 'origin/release/v9.3.0' into develop 2025-12-11 11:20:42 +03:00
e232fc779d Merge remote-tracking branch 'origin/hotfix/v9.2.1' into develop 2025-12-11 11:19:31 +03:00
0d6d273573 Fix bug #74628 2025-12-10 19:07:26 +03:00
981df3fce7 add chart sheet conversion 2025-12-10 20:43:38 +06:00
05d7d88481 Add logs during snapshot creation 2025-12-10 17:17:51 +04:00
c3b3a1b5ef Fix SetDV for radiobutton 2025-12-10 15:23:40 +03:00
47258d9c30 Fix typo 2025-12-10 15:23:29 +03:00
10ab7009a1 Refactoring 2025-12-10 15:23:22 +03:00
85d98daedd Merge branch 'develop' into feature/add-xls-writing 2025-12-10 15:43:25 +06:00
0c87e66785 Fix Parent page 2025-12-10 12:17:52 +03:00
d2527e5707 Fix stretch not rotate 2025-12-09 19:46:05 +03:00
3484834b9d Test PrintPdf 2025-12-09 18:45:41 +03:00
81b4ba3493 Rollback 2025-12-09 16:28:15 +03:00
44e217cf7c Move AddPath to IRenderer 2025-12-09 15:53:54 +03:00
bcdcfa8bf7 fix bug #74265 2025-12-08 16:36:25 +03:00
1ee8baa672 Develop PrintPages 2025-12-05 17:06:26 +03:00
6422ce7f78 Fix bugs in html 2025-12-05 15:55:23 +03:00
31f7136f70 Fix bug #78915 2025-12-05 14:05:19 +03:00
3730827cd8 Create PrintPages 2025-12-04 17:51:23 +03:00
dd00be6dce add fontlist writing 2025-12-04 13:53:42 +06:00
b5f0b39258 Remove pure virtual functions 2025-12-02 11:22:12 +03:00
3f6a800dd8 Rollback 2025-12-02 02:06:17 +03:00
1c8ad7a5c4 Add docxmethods for test 2025-12-02 01:44:07 +03:00
8464d3aeb7 Add AddPath method for test 2025-12-02 01:41:15 +03:00
ed939ebd1d Add html methods for test 2025-12-02 01:37:30 +03:00
fe6c5614d4 Add pdf methods for test 2025-12-02 01:24:49 +03:00
cd80bca553 Fix fill with context color in svg 2025-12-01 16:49:44 +03:00
6e49670513 Implemented support for the BaselineShift property in svg 2025-12-01 16:13:49 +03:00
f0b266793f Refactoring 2025-11-19 23:24:05 +03:00
490281dda0 Fix compare double 2025-11-19 23:14:28 +03:00
b98b808cda Delete unused methods 2025-11-19 22:40:25 +03:00
6c77718f17 Fix reset rotation 2025-11-19 22:30:47 +03:00
74a2b3b06f Fix Not rotate 2025-11-18 22:41:23 +03:00
8f3e19a5db Fix offset 2025-11-18 22:06:42 +03:00
0019f589bc Fix scale tile texture 2025-11-18 10:12:59 +03:00
200c17ee40 Fix not rotate 2025-11-17 19:37:30 +03:00
4543bfa6cd Fix add path to renderer 2025-11-17 11:26:07 +03:00
16e78d87a4 Add logic for customRect 2025-11-17 10:14:35 +03:00
051597a78a Add new commands to CheckBuffer 2025-11-17 10:14:06 +03:00
13e03328af Renumbering tile flip 2025-11-14 16:58:09 +03:00
04ccd4fe27 Fix scale for tile 2025-11-14 16:56:43 +03:00
4b335fc796 Add mirror for tile brush 2025-10-23 14:41:34 +03:00
5e177412e2 Add scale for brush rect 2025-10-23 14:37:48 +03:00
dec13334db Add not rotation with shape 2025-10-20 16:57:13 +03:00
c8ebcfac87 Add offset for brush rect 2025-09-25 16:12:07 +03:00
2931c4b53e Aff offset metafile command 2025-09-25 13:58:55 +03:00
deb90037d5 StarMath conversion to a dynamic library 2025-09-04 17:12:15 +03:00
930165a993 fix bugs 2025-08-14 14:50:46 +03:00
fe2b631c87 Merge pull request 'release/v9.1.0' (#405) from release/v9.1.0 into feature/EQN2OOXml2
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/405
2025-08-12 08:13:11 +00:00
cb68e4389e EQN conversion added to HWPX 2025-08-04 20:16:57 +03:00
0f1cb37153 edit of the previous comment 2025-07-22 18:23:24 +03:00
95bad7b071 writing Arabic characters 2025-07-22 18:04:52 +03:00
05404c1bad Merge pull request 'develop' (#398) from develop into feature/EQN2OOXml2
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/398
2025-07-18 09:21:14 +00:00
b0e810013d editing conversion and parsing, fixing bugs, adding tests 2025-07-18 12:18:27 +03:00
9b3b6caef9 pars diacritical marks 2025-06-27 13:12:49 +03:00
2aeec01f1e fix index 2025-06-12 16:40:26 +03:00
70412f5f8e pars index(without underover) 2025-04-27 20:22:26 +03:00
b1885e5b91 pars oper 2025-04-22 10:55:36 +03:00
8e2d1e2c16 parse development 2025-04-17 22:19:08 +03:00
264 changed files with 9993 additions and 5021 deletions

View File

@ -6,12 +6,13 @@ import os
if not base.is_dir("glm"):
base.cmd("git", ["clone", "https://github.com/g-truc/glm.git"])
base.cmd_in_dir("glm", "git", ["checkout", "33b4a621a697a305bc3a7610d290677b96beb181", "--quiet"])
base.replaceInFile("./glm/glm/detail/func_common.inl", "vec<L, T, Q> v;", "vec<L, T, Q> v{};")
if not base.is_dir("mdds"):
base.cmd("git", ["clone", "https://github.com/kohei-us/mdds.git"])
base.cmd_in_dir("mdds", "git", ["checkout", "0783158939c6ce4b0b1b89e345ab983ccb0f0ad0"], "--quiet")
fix_cpp_version = "#if __cplusplus < 201402L\n"
fix_cpp_version = "#if __cplusplus < 201703L\n"
fix_cpp_version += "#ifndef _MSC_VER\n"
fix_cpp_version += "namespace std {\n"
fix_cpp_version += " template<bool __v>\n"

View File

@ -3,6 +3,8 @@ DEPENDPATH += $$PWD
CORE_ROOT_DIR = $$PWD/../../../..
include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri)
css_calculator_without_xhtml {
HEADERS += \
$$PWD/src/CCssCalculator_Private.h \

File diff suppressed because it is too large Load Diff

View File

@ -4,11 +4,14 @@
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include "../../../../DesktopEditor/graphics/Matrix.h"
#include "CUnitMeasureConverter.h"
#include <boost/optional.hpp>
#include "boost/blank.hpp"
#include <boost/variant2/variant.hpp>
namespace NSCSS
{
namespace NSProperties
@ -16,33 +19,34 @@ namespace NSCSS
#define NEXT_LEVEL UINT_MAX, true
template<typename T>
class CValue
class CValueBase
{
friend class CString;
friend class CMatrix;
friend class CDigit;
friend class CColor;
friend class CEnum;
friend class CURL;
protected:
CValueBase()
: m_unLevel(0), m_bImportant(false)
{}
CValueBase(const CValueBase& oValue)
: m_oValue(oValue.m_oValue), m_unLevel(oValue.m_unLevel), m_bImportant(oValue.m_bImportant)
{}
CValueBase(const T& oValue, unsigned int unLevel, bool bImportant)
: m_oValue(oValue), m_unLevel(unLevel), m_bImportant(bImportant)
{}
T m_oValue;
unsigned int m_unLevel;
bool m_bImportant;
public:
CValue(const T& oValue, unsigned int unLevel, bool bImportant) :
m_oValue(oValue), m_unLevel(unLevel), m_bImportant(bImportant)
{
}
virtual bool Empty() const = 0;
virtual void Clear() = 0;
virtual bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) = 0;
virtual bool Empty() const = 0;
virtual void Clear() = 0;
virtual int ToInt() const = 0;
virtual double ToDouble() const = 0;
virtual std::wstring ToWString() const = 0;
static void Equation(CValue &oFirstValue, CValue &oSecondValue)
static void Equation(CValueBase &oFirstValue, CValueBase &oSecondValue)
{
if (oFirstValue.m_bImportant && !oSecondValue.m_bImportant && oFirstValue.Empty())
oSecondValue.Clear();
@ -57,18 +61,39 @@ namespace NSCSS
}
}
static bool LevelIsSame(const CValue& oFirstValue, const CValue& oSecondValue)
static bool LevelIsSame(const CValueBase& oFirstValue, const CValueBase& oSecondValue)
{
return oFirstValue.m_unLevel == oSecondValue.m_unLevel;
}
bool operator==(const T& oValue) const { return m_oValue == oValue; }
bool operator>=(const T& oValue) const { return m_oValue >= oValue; }
bool operator<=(const T& oValue) const { return m_oValue <= oValue; }
bool operator> (const T& oValue) const { return m_oValue > oValue; }
bool operator< (const T& oValue) const { return m_oValue < oValue; }
friend bool operator==(const CValueBase& oLeftValue, const CValueBase& oRightValue)
{
if (oLeftValue.Empty() && oRightValue.Empty())
return true;
virtual CValue& operator =(const CValue& oValue)
if (( oLeftValue.Empty() && !oRightValue.Empty()) ||
(!oLeftValue.Empty() && oRightValue.Empty()))
return false;
return oLeftValue.m_oValue == oRightValue.m_oValue;
}
friend bool operator!=(const CValueBase& oLeftValue, const CValueBase& oRightValue)
{
return !(oLeftValue == oRightValue);
}
bool operator==(const T& oValue) const
{
return m_oValue == oValue;
}
bool operator!=(const T& oValue) const
{
return m_oValue != oValue;
}
virtual CValueBase& operator =(const CValueBase& oValue)
{
m_oValue = oValue.m_oValue;
m_unLevel = oValue.m_unLevel;
@ -77,70 +102,93 @@ namespace NSCSS
return *this;
}
virtual CValue& operator =(const T& oValue)
virtual CValueBase& operator =(const T& oValue)
{
//m_oValue = oValue.m_oValue;
m_oValue = oValue;
return *this;
}
virtual CValue& operator+=(const CValue& oValue)
virtual CValueBase& operator+=(const CValueBase& oValue)
{
if (m_unLevel > oValue.m_unLevel || (m_bImportant && !oValue.m_bImportant) || oValue.Empty())
return *this;
m_oValue = oValue.m_oValue;
m_unLevel = oValue.m_unLevel;
m_bImportant = oValue.m_bImportant;
*this = oValue;
return *this;
}
};
virtual bool operator==(const CValue& oValue) const
template<typename T>
class CValueOptional : public CValueBase<boost::optional<T>>
{
protected:
CValueOptional() = default;
CValueOptional(const T& oValue, unsigned int unLevel = 0, bool bImportant = false)
: CValueBase<boost::optional<T>>(oValue, unLevel, bImportant)
{}
public:
virtual bool Empty() const override
{
return m_oValue == oValue.m_oValue;
return !this->m_oValue.has_value();
}
void Clear() override
{
this->m_oValue.reset();
this->m_unLevel = 0;
this->m_bImportant = false;
}
virtual bool operator!=(const CValue& oValue) const
bool operator==(const T& oValue) const
{
return m_oValue != oValue.m_oValue;
if (!this->m_oValue.has_value())
return false;
return this->m_oValue.value() == oValue;
}
virtual CValueOptional& operator=(const T& oValue)
{
this->m_oValue = oValue;
return *this;
}
};
class CString : public CValue<std::wstring>
class CString : public CValueOptional<std::wstring>
{
public:
CString();
CString(const std::wstring& wsValue, unsigned int unLevel, bool bImportant = false);
CString() = default;
CString(const std::wstring& wsValue, unsigned int unLevel = 0, bool bImportant = false);
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
bool SetValue(const std::wstring& wsValue, const std::vector<std::wstring>& arValiableValues, unsigned int unLevel, bool bHardMode);
bool SetValue(const std::wstring& wsValue, const std::map<std::wstring, std::wstring>& arValiableValues, unsigned int unLevel, bool bHardMode);
bool Empty() const override;
void Clear() override;
int ToInt() const override;
double ToDouble() const override;
std::wstring ToWString() const override;
CString& operator+=(const CString& oString);
bool operator==(const wchar_t* pValue) const;
bool operator!=(const wchar_t* pValue) const;
using CValueOptional<std::wstring>::operator=;
};
class CDigit : public CValue<double>
class CDigit : public CValueOptional<double>
{
UnitMeasure m_enUnitMeasure;
double ConvertValue(double dPrevValue, UnitMeasure enUnitMeasure) const;
public:
CDigit();
CDigit(double dValue);
CDigit(double dValue, unsigned int unLevel, bool bImportant = false);
CDigit(const double& dValue, unsigned int unLevel = 0, bool bImportant = false);
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
bool SetValue(const CDigit& oValue);
bool SetValue(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel = 0, bool bHardMode = true);
bool Empty() const override;
bool Zero() const;
void Clear() override;
@ -156,7 +204,7 @@ namespace NSCSS
UnitMeasure GetUnitMeasure() const;
bool operator==(const double& oValue) const;
bool operator==(const double& dValue) const;
bool operator==(const CDigit& oDigit) const;
bool operator!=(const double& oValue) const;
@ -171,11 +219,19 @@ namespace NSCSS
CDigit& operator+=(const CDigit& oDigit);
CDigit& operator-=(const CDigit& oDigit);
CDigit& operator+=(double dValue);
CDigit& operator-=(double dValue);
CDigit& operator*=(double dValue);
CDigit& operator/=(double dValue);
CDigit& operator =(double dValue);
CDigit& operator+=(const double& dValue);
CDigit& operator-=(const double& dValue);
CDigit& operator*=(const double& dValue);
CDigit& operator/=(const double& dValue);
using CValueOptional<double>::operator=;
private:
UnitMeasure m_enUnitMeasure;
double ConvertValue(double dPrevValue, UnitMeasure enUnitMeasure) const;
template <typename Operation>
CDigit ApplyOperation(const CDigit& oDigit, Operation operation) const;
};
struct TRGB
@ -186,6 +242,8 @@ namespace NSCSS
bool Empty() const;
int ToInt() const;
bool operator==(const TRGB& oRGB) const;
bool operator!=(const TRGB& oRGB) const;
};
@ -211,31 +269,58 @@ namespace NSCSS
typedef enum
{
ColorEmpty,
ColorNone,
ColorRGB,
ColorHEX,
ColorUrl,
ColorContextStroke,
ColorContextFill
} ColorType;
} EColorType;
class CColor : public CValue<void*>
class CColorValue
{
using color_value = boost::variant2::variant<boost::blank, std::wstring, TRGB, CURL>;
protected:
EColorType m_eType;
public:
CColorValue();
CColorValue(const CColorValue& oValue);
CColorValue(const std::wstring& wsValue);
CColorValue(const TRGB& oValue);
CColorValue(const CURL& oValue);
EColorType GetType() const;
bool operator==(const CColorValue& oValue) const;
color_value m_oValue;
};
class CColorValueContextStroke : public CColorValue
{
public:
CColorValueContextStroke();
};
class CColorValueContextFill : public CColorValue
{
public:
CColorValueContextFill();
};
class CColor : public CValueOptional<CColorValue>
{
public:
CColor();
CColor(const CColor& oColor);
~CColor();
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
bool SetOpacity(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true);
bool Empty() const override;
bool None() const;
bool Url() const;
void Clear() override;
ColorType GetType() const;
EColorType GetType() const;
double GetOpacity() const;
@ -249,20 +334,15 @@ namespace NSCSS
static TRGB ConvertHEXtoRGB(const std::wstring& wsValue);
static std::wstring ConvertRGBtoHEX(const TRGB& oValue);
bool operator==(const CColor& oColor) const;
bool operator!=(const CColor& oColor) const;
CColor& operator =(const CColor& oColor);
CColor& operator+=(const CColor& oColor);
using CValueOptional<CColorValue>::operator=;
private:
CDigit m_oOpacity;
ColorType m_enType;
CDigit m_oOpacity;
void SetEmpty(unsigned int unLevel = 0);
void SetRGB(unsigned char uchR, unsigned char uchG, unsigned char uchB);
void SetRGB(const TRGB& oRGB);
void SetHEX(const std::wstring& wsValue);
void SetUrl(const std::wstring& wsValue);
bool SetUrl(const std::wstring& wsValue);
void SetNone();
};
@ -279,7 +359,7 @@ namespace NSCSS
typedef std::vector<std::pair<std::vector<double>, TransformType>> MatrixValues;
class CMatrix : public CValue<MatrixValues>
class CMatrix : public CValueBase<MatrixValues>
{
std::vector<std::wstring> CutTransforms(const std::wstring& wsValue) const;
public:
@ -304,29 +384,27 @@ namespace NSCSS
bool operator==(const CMatrix& oMatrix) const;
CMatrix& operator+=(const CMatrix& oMatrix);
CMatrix& operator-=(const CMatrix& oMatrix);
using CValueBase<MatrixValues>::operator=;
};
class CEnum : public CValue<int>
class CEnum : public CValueOptional<int>
{
std::map<std::wstring, int> m_mMap;
public:
CEnum();
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
void SetMapping(const std::map<std::wstring, int>& mMap, int nDefaulvalue = -1);
bool Empty() const override;
void Clear() override;
CEnum &operator =(int nValue);
bool operator==(int nValue) const;
bool operator!=(int nValue) const;
int ToInt() const override;
using CValueOptional<int>::operator=;
private:
double ToDouble() const override;
std::wstring ToWString() const override;
int m_nDefaultValue;
std::map<std::wstring, int> m_mMap;
};
// PROPERTIES
@ -619,6 +697,30 @@ namespace NSCSS
bool operator==(const TTextDecoration& oTextDecoration) const;
};
typedef enum
{
Baseline,
Sub,
Super,
Percentage,
Length
} EBaselineShift;
class CBaselineShift
{
CEnum m_eType;
CDigit m_oValue;
public:
CBaselineShift();
bool Empty() const;
EBaselineShift GetType() const;
double GetValue() const;
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
};
class CText
{
public:
@ -626,11 +728,12 @@ namespace NSCSS
static void Equation(CText &oFirstText, CText &oSecondText);
bool SetIndent (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetDecoration(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetHighlight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetIndent (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetDecoration (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetHighlight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetBaselineShift (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
const CDigit& GetIndent() const;
const CString& GetAlign() const;
@ -638,6 +741,9 @@ namespace NSCSS
const CColor& GetColor() const;
const CColor& GetHighlight() const;
EBaselineShift GetBaselineShiftType() const;
double GetBaselineShiftValue() const;
bool Empty() const;
bool Underline() const;
@ -647,6 +753,7 @@ namespace NSCSS
CText& operator+=(const CText& oText);
bool operator==(const CText& oText) const;
private:
CBaselineShift m_oBaselineShift;
TTextDecoration m_oDecoration;
CDigit m_oIndent;
CString m_oAlign;

View File

@ -5,7 +5,7 @@
namespace Md
{
#define MD_PARSER_FLAGS MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM | MD_FLAG_HARD_SOFT_BREAKS | MD_HTML_FLAG_XHTML
#define MD_PARSER_FLAGS MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM | MD_FLAG_HARD_SOFT_BREAKS | MD_HTML_FLAG_XHTML | MD_FLAG_LATEXMATHSPANS
#define MD_RENDERER_FLAGS MD_HTML_FLAG_XHTML
void ToHtml(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)

View File

@ -1,6 +1,6 @@
.cipd
.gclient
.gclient_entries
.gclient*
.gcs*
v8
depot_tools
v8.data

View File

@ -967,7 +967,12 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT;
else if (0 == sExt.compare(L".md"))
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".tsv") || 0 == sExt.compare(L".xls") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xlsb"))
else if (0 == sExt.compare(L".tsv"))
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV;
else if (0 == sExt.compare(L".scsv"))
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV;
else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".tsv") || 0 == sExt.compare(L".dsv") || 0 == sExt.compare(L".cssv")
|| 0 == sExt.compare(L".xls") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xlsb"))
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
else if (0 == sExt.compare(L".html") || 0 == sExt.compare(L".htm"))
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML;
@ -1799,6 +1804,10 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
return L".ods";
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV:
return L".csv";
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV:
return L".tsv";
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV:
return L".scsv";
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT:
return L".fods";
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS:
@ -1988,7 +1997,11 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSB;
if (L".xls" == ext)
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS;
if (L".csv" == ext)
if (L".tsv" == ext)
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV;
if (L".scsv" == ext)
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV;
if (L".csv" == ext || L".dsv" == ext)
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
if (L".fods" == ext)
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT;

View File

@ -87,13 +87,14 @@
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0005
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0006
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0007
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSB AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0008
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0009
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000a
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000b
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_PACKAGE AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000c
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000d
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0014
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0024
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM 0x0200
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0001

View File

@ -118,13 +118,13 @@ win32:contains(QMAKE_TARGET.arch, arm64): {
}
linux-clang-libc++ {
CONFIG += core_linux
CONFIG += core_linux
CONFIG += core_linux_64
CONFIG += core_linux_clang
message("linux-64-clang-libc++")
}
linux-clang-libc++-32 {
CONFIG += core_linux
CONFIG += core_linux
CONFIG += core_linux_32
CONFIG += core_linux_clang
message("linux-32-clang-libc++")
@ -180,9 +180,9 @@ mac {
!core_ios {
CONFIG += core_mac
CONFIG += core_mac_64
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
}
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
}
# DEFINES
@ -199,32 +199,58 @@ core_win_64 {
DEFINES += WIN64 _WIN64
}
defineTest(startsWith) {
tmp = $$2
tmp ~= s,^$$re_escape($$1),,
!equals(tmp, $$2): return(true)
return(false)
}
core_linux {
DEFINES += LINUX _LINUX
QMAKE_CUSTOM_SYSROOT = $$(QMAKE_CUSTOM_SYSROOT)
QMAKE_CUSTOM_SYSROOT_BIN = $$(QMAKE_CUSTOM_SYSROOT)/usr/bin/
!isEmpty(QMAKE_CUSTOM_SYSROOT) {
CONFIG += core_linix_use_sysroot
message("using custom sysroot $$QMAKE_CUSTOM_SYSROOT")
core_linux_64 {
!linux_arm64 { # x86_64
QMAKE_CUSTOM_SYSROOT_LIB = $$(QMAKE_CUSTOM_SYSROOT)/usr/lib/x86_64-linux-gnu
!isEmpty(QMAKE_CUSTOM_SYSROOT) {
message("using custom sysroot $$QMAKE_CUSTOM_SYSROOT")
QMAKE_CC = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "gcc")
QMAKE_CXX = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
QMAKE_LINK = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
QMAKE_LINK_SHLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
QMAKE_CFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
QMAKE_CXXFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT -std=gnu++1y
QMAKE_LFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
}
QMAKE_CUSTOM_SYSROOT_BIN = $$(QMAKE_CUSTOM_SYSROOT_BIN)
isEmpty(QMAKE_CUSTOM_SYSROOT_BIN) {
QMAKE_CUSTOM_SYSROOT_BIN = $$QMAKE_CUSTOM_SYSROOT/usr/bin
}
QMAKE_CUSTOM_SYSROOT_BIN = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , /)
startsWith($$QMAKE_CUSTOM_SYSROOT, $$QMAKE_CUSTOM_SYSROOT_BIN) {
message("Using compilers from same sysroot")
QMAKE_CC = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "gcc")
QMAKE_CXX = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
QMAKE_LINK = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
QMAKE_LINK_SHLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
QMAKE_AR = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "ar") cqs
QMAKE_RANLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "ranlib")
QMAKE_STRIP = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "strip")
} else {
message("Using cross-compilers from host sysroot")
QMAKE_CC = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-gcc")
QMAKE_CXX = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-g++")
QMAKE_LINK = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-g++")
QMAKE_LINK_SHLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-g++")
QMAKE_AR = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-ar") cqs
QMAKE_RANLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-ranlib")
QMAKE_STRIP = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-strip")
QMAKE_OBJCOPY = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "aarch64-linux-gnu-objcopy")
}
QMAKE_CFLAGS += --sysroot=$$QMAKE_CUSTOM_SYSROOT
QMAKE_CXXFLAGS += --sysroot=$$QMAKE_CUSTOM_SYSROOT -std=gnu++1y
QMAKE_LFLAGS += --sysroot=$$QMAKE_CUSTOM_SYSROOT
QMAKE_INCDIR += $$QMAKE_CUSTOM_SYSROOT/usr/include
}
}
gcc {
COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion")
COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion")
COMPILER_MAJOR_VERSION_ARRAY = $$split(COMPILER_VERSION, ".")
COMPILER_MAJOR_VERSION = $$member(COMPILER_MAJOR_VERSION_ARRAY, 0)
lessThan(COMPILER_MAJOR_VERSION, 5): CONFIG += build_gcc_less_5
@ -254,6 +280,11 @@ core_mac {
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
!apple_silicon:QMAKE_APPLE_DEVICE_ARCHS = x86_64
}
!core_debug {
equals(TEMPLATE, app):QMAKE_POST_LINK += strip $(TARGET)
# TODO: plugin!
}
}
core_linux_clang {
@ -312,6 +343,10 @@ core_linux {
core_linux {
equals(TEMPLATE, app):CONFIG += core_static_link_libstd
plugin:CONFIG += core_static_link_libstd
equals(TEMPLATE, app):QMAKE_LFLAGS_RELEASE += -Wl,-s
plugin:QMAKE_LFLAGS_RELEASE += -Wl,-s
}
core_win_32 {
@ -321,7 +356,7 @@ core_win_64 {
CORE_BUILDS_PLATFORM_PREFIX = win_64
}
core_win_arm64 {
CORE_BUILDS_PLATFORM_PREFIX = win_arm64
CORE_BUILDS_PLATFORM_PREFIX = win_arm64
}
core_linux_32 {
CORE_BUILDS_PLATFORM_PREFIX = linux_32
@ -343,27 +378,6 @@ core_linux_arm {
linux_arm64 {
CORE_BUILDS_PLATFORM_PREFIX = linux_arm64
DEFINES += _ARM_ALIGN_
ARM64_TOOLCHAIN_BIN = $$(ARM64_TOOLCHAIN_BIN)
ARM64_TOOLCHAIN_BIN_PREFIX = $$(ARM64_TOOLCHAIN_BIN_PREFIX)
!isEmpty(ARM64_TOOLCHAIN_BIN){
!isEmpty(ARM64_TOOLCHAIN_BIN_PREFIX){
ARM64_TOOLCHAIN_BIN_FULL = $$ARM64_TOOLCHAIN_BIN/$$ARM64_TOOLCHAIN_BIN_PREFIX
message("using arm64 toolchain $$ARM64_TOOLCHAIN_BIN")
QMAKE_CC = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "gcc")
QMAKE_CXX = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "g++")
QMAKE_LINK = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "g++")
QMAKE_LINK_SHLIB = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "g++")
QMAKE_AR = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "ar cqs")
QMAKE_OBJCOPY = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "objcopy")
QMAKE_NM = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "nm -P")
QMAKE_STRIP = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "strip")
}
}
}
core_ios {
CORE_BUILDS_PLATFORM_PREFIX = ios
@ -690,3 +704,105 @@ ADD_INC_PATH = $$(ADDITIONAL_INCLUDE_PATH)
!disable_precompiled_header {
CONFIG += precompile_header
}
SWIFT_SOURCES=
defineTest(UseSwift) {
isEmpty(SWIFT_SOURCES): return(false)
# work only on ios and mac
!core_ios:!core_mac {
return(false)
}
# path to the bridging header that exposes Objective-C code to Swift
BRIDGING_HEADER = $$1
# sdk and toolchain (set from environment variables)
SDK_PATH = $$(SDK_PATH)
XCODE_TOOLCHAIN_PATH = $$(XCODE_TOOLCHAIN_PATH)
IOS_TARGET_PLATFORM = apple-ios11.0
SWIFT_GEN_HEADERS_PATH = $$PWD_ROOT_DIR/core_build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
ARCHS = arm64
# simulator
xcframework_platform_ios_simulator {
IOS_TARGET_PLATFORM = $${IOS_TARGET_PLATFORM}-simulator
SWIFT_GEN_HEADERS_PATH = $$SWIFT_GEN_HEADERS_PATH/simulator
ARCHS += x86_64
}
# add swift compiler for each architecture
SWIFT_COMPILERS_OUT =
for(ARCH, ARCHS) {
COMPILER_NAME = swift_compiler_$${ARCH}
COMPILER_OUTPUT = $$SWIFT_GEN_HEADERS_PATH/swift_module_$${ARCH}.o
SWIFT_COMPILERS_OUT += $$COMPILER_OUTPUT
$${COMPILER_NAME}.name = SwiftCompiler_$${ARCH}
$${COMPILER_NAME}.input = SWIFT_SOURCES
$${COMPILER_NAME}.output = $$COMPILER_OUTPUT
SWIFT_CMD = swiftc -c $$SWIFT_SOURCES \
-module-name SwiftModule \
-whole-module-optimization \
-emit-objc-header \
-emit-objc-header-path $$SWIFT_GEN_HEADERS_PATH/SwiftModule-Swift.h \
-emit-object \
-sdk $$SDK_PATH \
-target $${ARCH}-$${IOS_TARGET_PLATFORM} \
-o $$COMPILER_OUTPUT \
-framework UIKit
!isEmpty(BRIDGING_HEADER) {
SWIFT_CMD += -import-objc-header $$BRIDGING_HEADER
}
$${COMPILER_NAME}.commands = $$SWIFT_CMD
$${COMPILER_NAME}.CONFIG = combine target_predeps no_link
export($${COMPILER_NAME}.name)
export($${COMPILER_NAME}.input)
export($${COMPILER_NAME}.output)
export($${COMPILER_NAME}.commands)
export($${COMPILER_NAME}.CONFIG)
QMAKE_EXTRA_COMPILERS += $${COMPILER_NAME}
}
# add lipo tool execution to form universal binary
LIPO_OUT = $$SWIFT_GEN_HEADERS_PATH/swift_module.o
lipo_tool.name = LipoTool
# as input for lipo_tool we set SWIFT_SOURCES (not SWIFT_COMPILERS_OUT as it won't be executed otherwise!)
lipo_tool.input = SWIFT_SOURCES
# compiled swift sources go into depends
lipo_tool.depends = $$SWIFT_COMPILERS_OUT
lipo_tool.output = $$LIPO_OUT
lipo_tool.commands = lipo -create $$SWIFT_COMPILERS_OUT -output $$LIPO_OUT
lipo_tool.CONFIG = combine target_predeps no_link
lipo_tool.variable_out = OBJECTS
export(lipo_tool.name)
export(lipo_tool.input)
export(lipo_tool.depends)
export(lipo_tool.output)
export(lipo_tool.commands)
export(lipo_tool.CONFIG)
export(lipo_tool.variable_out)
QMAKE_EXTRA_COMPILERS += lipo_tool
export(QMAKE_EXTRA_COMPILERS)
INCLUDEPATH += $$SWIFT_GEN_HEADERS_PATH
export(INCLUDEPATH)
# link with libs from toolchain
SWIFT_LIB_PATH = $$XCODE_TOOLCHAIN_PATH/usr/lib/swift/iphoneos
xcframework_platform_ios_simulator {
SWIFT_LIB_PATH = $$XCODE_TOOLCHAIN_PATH/usr/lib/swift/iphonesimulator
}
LIBS += -L$$SWIFT_LIB_PATH
LIBS += -lswiftCore -lswiftFoundation -lswiftObjectiveC
export(LIBS)
OTHER_FILES += $$SWIFT_SOURCES
export(OTHER_FILES)
return(true)
}

View File

@ -26,7 +26,7 @@ def _loadLibrary(path):
library_name = 'libdocbuilder.c.dylib'
# if there is no dylib file, get library from framework
if not os.path.exists(path + '/' + library_name):
path = path + '/docbuilder.c.framework'
path = path + '/docbuilder.c.framework/Versions/A'
library_name = 'docbuilder.c'
_lib = ctypes.CDLL(path + '/' + library_name)

View File

@ -120,7 +120,7 @@ public:
}
public:
bool OpenFile(const std::wstring& sFile, const std::wstring& sPassword)
bool OpenFile(const std::wstring& sFile, const wchar_t* sPassword)
{
CloseFile();
@ -171,7 +171,7 @@ public:
return m_pFile ? true : false;
}
bool OpenFile(BYTE* data, LONG size, const std::wstring& sPassword)
bool OpenFile(BYTE* data, LONG size, const wchar_t* sPassword)
{
CloseFile();
@ -245,7 +245,7 @@ public:
return 0;
}
bool CheckOwnerPassword(const std::wstring& sPassword)
bool CheckOwnerPassword(const wchar_t* sPassword)
{
if (m_nType == 0)
return ((CPdfFile*)m_pFile)->CheckOwnerPassword(sPassword);
@ -454,6 +454,20 @@ public:
if (m_nType == 0)
((CPdfFile*)m_pFile)->SetCMapMemory(data, size);
}
void SetScanPageFonts(int nPageIndex)
{
if (NULL == m_pImageStorage)
m_pImageStorage = NSDocxRenderer::CreateWasmImageStorage();
CDocxRenderer oRenderer(m_pApplicationFonts);
oRenderer.SetExternalImageStorage(m_pImageStorage);
oRenderer.SetTextAssociationType(NSDocxRenderer::TextAssociationType::tatParagraphToShape);
oRenderer.ScanPageBin(m_pFile, nPageIndex);
if (m_nType == 0)
((CPdfFile*)m_pFile)->SetPageFonts(nPageIndex);
}
BYTE* ScanPage(int nPageIndex, int mode)
{
if (NULL == m_pImageStorage)

View File

@ -26,7 +26,8 @@ CDrawingFileEmbed::~CDrawingFileEmbed()
JSSmart<CJSValue> CDrawingFileEmbed::OpenFile(JSSmart<CJSValue> sFile, JSSmart<CJSValue> sPassword)
{
bool bResult = m_pFile->OpenFile(sFile->toStringW(), sPassword->isString() ? sPassword->toStringW() : L"");
std::wstring wsPassword = sPassword->isString() ? sPassword->toStringW() : L"";
bool bResult = m_pFile->OpenFile(sFile->toStringW(), sPassword->isString() ? wsPassword.c_str() : NULL);
return CJSContext::createBool(bResult);
}
JSSmart<CJSValue> CDrawingFileEmbed::CloseFile()

View File

@ -461,6 +461,8 @@ namespace NSJSBase
v8::SnapshotCreator snapshotCreator;
v8::Isolate* isolate = snapshotCreator.GetIsolate();
{
CV8TryCatch try_catch(isolate);
v8::HandleScope handle_scope(isolate);
// Create a new context
v8::Local<v8::Context> context = v8::Context::New(isolate);
@ -472,11 +474,12 @@ namespace NSJSBase
global->Set(context, v8::String::NewFromUtf8Literal(isolate, "self"), global).Check();
global->Set(context, v8::String::NewFromUtf8Literal(isolate, "native"), v8::Undefined(isolate)).Check();
// Compile and run
// Compile
v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, script.c_str()).ToLocalChecked();
v8::Local<v8::Script> script = v8::Script::Compile(context, source).ToLocalChecked();
// Run
script->Run(context).IsEmpty();
snapshotCreator.SetDefaultContext(context);
}
v8::StartupData data = snapshotCreator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep);

View File

@ -62,7 +62,13 @@ v8::Local<v8::String> CreateV8String(v8::Isolate* i, const std::string& str);
#include <android/log.h>
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, "js", __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "js", __VA_ARGS__)
#endif
#ifdef _DEBUG
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "js", __VA_ARGS__)
#else
// should be disabled for release builds
#define LOGD(...)
#endif // _DEBUG
#endif // ANDROID_LOGS
#endif
@ -799,6 +805,9 @@ namespace NSJSBase
CV8TryCatch() : CJSTryCatch(), try_catch(V8IsolateOneArg)
{
}
CV8TryCatch(v8::Isolate* isolate) : CJSTryCatch(), try_catch(isolate)
{
}
virtual ~CV8TryCatch()
{
}

View File

@ -419,6 +419,7 @@ namespace Aggplus
m_bReleaseImage = FALSE;
Alpha = 255;
m_bUseBounds = false;
m_bIsScale = false;
}
CBrushTexture::CBrushTexture(const std::wstring& strName, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
@ -427,6 +428,7 @@ namespace Aggplus
m_bReleaseImage = TRUE;
Alpha = 255;
m_bUseBounds = false;
m_bIsScale = false;
}
CBrushTexture::CBrushTexture(CImage *pImage, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
@ -435,6 +437,7 @@ namespace Aggplus
m_bReleaseImage = FALSE;
Alpha = 255;
m_bUseBounds = false;
m_bIsScale = false;
}
CBrushTexture::~CBrushTexture()

View File

@ -205,6 +205,10 @@ public:
bool m_bUseBounds;
CDoubleRect m_oBounds;
bool m_bIsScale;
double m_dScaleX;
double m_dScaleY;
BYTE Alpha;
};
}

View File

@ -847,6 +847,8 @@ namespace Aggplus
double dScaleY = m_dDpiY / m_dDpiTile;
brushMatrix.Scale(dScaleX, dScaleY, Aggplus::MatrixOrderAppend);
if (ptxBrush->m_bIsScale)
brushMatrix.Scale(ptxBrush->m_dScaleX, ptxBrush->m_dScaleY, Aggplus::MatrixOrderAppend);
}
brushMatrix.Translate(x, y, Aggplus::MatrixOrderAppend);

View File

@ -886,12 +886,12 @@ namespace Aggplus
if (isCurve)
{
std::vector<PointD> points = GetPoints(idx, 4);
area = 3.0 * (points[3].Y - points[0].Y) * (points[1].X + points[2].X)
area = 3.0 * ((points[3].Y - points[0].Y) * (points[1].X + points[2].X)
- (points[3].X - points[0].X) * (points[1].Y + points[2].Y)
+ points[1].Y * (points[0].X - points[2].X)
- points[1].X * (points[0].Y - points[2].Y)
+ points[3].Y * (points[2].X + points[0].X / 3.0)
- points[3].X * (points[2].Y + points[0].Y / 3.0) / 20.0;
- points[3].X * (points[2].Y + points[0].Y / 3.0)) / 20.0;
}
else
{
@ -1007,16 +1007,18 @@ namespace Aggplus
bool CGraphicsPath::operator==(const CGraphicsPath& other) noexcept
{
unsigned pointsCount = GetPointCount(),
otherPointsCount = other.GetPointCount();
otherPointsCount = other.GetPointCount();
if (pointsCount != otherPointsCount)
return false;
std::vector<PointD> points = GetPoints(0, pointsCount),
otherPoints = other.GetPoints(0, otherPointsCount);
otherPoints = other.GetPoints(0, otherPointsCount);
bool reverse = IsClockwise() ^ other.IsClockwise();
for (unsigned i = 0; i < pointsCount; i++)
if (!points[i].Equals(otherPoints[i]))
if (!points[i].Equals(otherPoints[reverse ? pointsCount - i - 1 : i]))
return false;
return true;
@ -1549,3 +1551,31 @@ namespace Aggplus
return false;
}
}
HRESULT IRenderer::AddPath(const Aggplus::CGraphicsPath& path)
{
if (path.GetPointCount() == 0)
return S_FALSE;
size_t length = path.GetPointCount() + path.GetCloseCount();
std::vector<Aggplus::PointD> points = path.GetPoints(0, length);
for (size_t i = 0; i < length; i++)
{
if (path.IsCurvePoint(i))
{
PathCommandCurveTo(points[i].X, points[i].Y,
points[i + 1].X, points[i + 1].Y,
points[i + 2].X, points[i + 2].Y);
i += 2;
}
else if (path.IsMovePoint(i))
PathCommandMoveTo(points[i].X, points[i].Y);
else if (path.IsLinePoint(i))
PathCommandLineTo(points[i].X, points[i].Y);
else
PathCommandClose();
}
return S_OK;
}

View File

@ -613,6 +613,32 @@ HRESULT CGraphicsRenderer::put_BrushTransform(const Aggplus::CMatrix& oMatrix)
m_oBrush.Transform = oMatrix;
return S_OK;
}
HRESULT CGraphicsRenderer::get_BrushOffset(double& offsetX, double& offsetY) const
{
offsetX = m_oBrush.OffsetX;
offsetY = m_oBrush.OffsetY;
return S_OK;
}
HRESULT CGraphicsRenderer::put_BrushOffset(const double& offsetX, const double& offsetY)
{
m_oBrush.OffsetX = offsetX;
m_oBrush.OffsetY = offsetY;
return S_OK;
}
HRESULT CGraphicsRenderer::get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const
{
isScale = m_oBrush.IsScale;
scaleX = m_oBrush.ScaleX;
scaleY = m_oBrush.ScaleY;
return S_OK;
}
HRESULT CGraphicsRenderer::put_BrushScale(bool isScale, const double& scaleX, const double& scaleY)
{
m_oBrush.IsScale = isScale;
m_oBrush.ScaleX = scaleX;
m_oBrush.ScaleY = scaleY;
return S_OK;
}
HRESULT CGraphicsRenderer::BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height)
{
m_oBrush.Rectable = val;
@ -946,11 +972,18 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
switch (m_oBrush.TextureMode)
{
case c_BrushTextureModeTile:
oMode = Aggplus::WrapModeTile;
break;
case c_BrushTextureModeTileCenter:
oMode = Aggplus::WrapModeTile;
break;
case c_BrushTextureModeTileFlipX:
oMode = Aggplus::WrapModeTileFlipX;
break;
case c_BrushTextureModeTileFlipY:
oMode = Aggplus::WrapModeTileFlipY;
break;
case c_BrushTextureModeTileFlipXY:
oMode = Aggplus::WrapModeTileFlipXY;
break;
default:
break;
}
@ -1023,11 +1056,18 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
if (m_oBrush.Rectable == 1)
{
pTextureBrush->m_bUseBounds = true;
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X;
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y;
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X + m_oBrush.OffsetX;
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y + m_oBrush.OffsetY;
pTextureBrush->m_oBounds.right = pTextureBrush->m_oBounds.left + m_oBrush.Rect.Width;
pTextureBrush->m_oBounds.bottom = pTextureBrush->m_oBounds.top + m_oBrush.Rect.Height;
}
if (m_oBrush.IsScale == 1)
{
pTextureBrush->m_bIsScale = true;
pTextureBrush->m_dScaleX = m_oBrush.ScaleX;
pTextureBrush->m_dScaleY = m_oBrush.ScaleY;
}
}
pBrush = pTextureBrush;

View File

@ -189,6 +189,10 @@ public:
virtual HRESULT put_BrushLinearAngle(const double& dAngle);
virtual HRESULT get_BrushTransform(Aggplus::CMatrix& oMatrix);
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix);
virtual HRESULT get_BrushOffset(double& offsetX, double& offsetY) const;
virtual HRESULT put_BrushOffset(const double& offsetX, const double& offsetY);
virtual HRESULT get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const;
virtual HRESULT put_BrushScale(bool isScale, const double& scaleX, const double& scaleY);
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height);
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height);
virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount);

View File

@ -169,7 +169,10 @@ public:
AdvancedCommandType GetCommandType() { return m_nCommandType; }
};
namespace Aggplus { class CImage; }
namespace Aggplus {
class CImage;
class CGraphicsPath;
}
// IRenderer
class IRenderer : public IGrObject
@ -241,6 +244,32 @@ public:
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix) = 0;
virtual HRESULT get_BrushLinearAngle(double* dAngle) = 0;
virtual HRESULT put_BrushLinearAngle(const double& dAngle) = 0;
virtual HRESULT get_BrushOffset(double& offsetX, double& offsetY) const
{
UNUSED_VARIABLE(offsetX);
UNUSED_VARIABLE(offsetY);
return S_OK;
}
virtual HRESULT put_BrushOffset(const double& offsetX, const double& offsetY)
{
UNUSED_VARIABLE(offsetX);
UNUSED_VARIABLE(offsetY);
return S_OK;
}
virtual HRESULT get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const
{
UNUSED_VARIABLE(isScale);
UNUSED_VARIABLE(scaleX);
UNUSED_VARIABLE(scaleY);
return S_OK;
}
virtual HRESULT put_BrushScale(bool isScale, const double& scaleX, const double& scaleY)
{
UNUSED_VARIABLE(isScale);
UNUSED_VARIABLE(scaleX);
UNUSED_VARIABLE(scaleY);
return S_OK;
}
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height) = 0;
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height) = 0;
@ -300,6 +329,8 @@ public:
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
HRESULT AddPath(const Aggplus::CGraphicsPath& path);
//-------- Функции для вывода изображений ---------------------------------------------------
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255) = 0;

View File

@ -36,6 +36,7 @@
#include "../fontengine/FontManager.h"
#include "../raster/BgraFrame.h"
#include "../common/StringExt.h"
#include "GraphicsPath.h"
// этот класс нужно переписать. должно работать как и в js
// а не просто на каждом символе переключаться, если нужно
@ -351,7 +352,13 @@ namespace NSOnlineOfficeBinToPdf
bool bIsPathOpened = false;
bool bIsEnableBrushRect = false;
double old_t1, old_t2, old_t3, old_t4, old_t5, old_t6;
CBufferReader oReader(pBuffer, lBufferLen);
Aggplus::CGraphicsPath path;
Aggplus::CMatrix transMatrRot;
Aggplus::RectF_T<double> clipRect;
bool isResetRot = false;
while (oReader.Check())
{
eCommand = (CommandType)(oReader.ReadByte());
@ -382,6 +389,8 @@ namespace NSOnlineOfficeBinToPdf
if (bIsPathOpened)
{
pRenderer->PathCommandEnd();
if (path.GetPointCount())
path.Reset();
pRenderer->EndCommand(c_nPathType);
}
bIsPathOpened = false;
@ -471,6 +480,16 @@ namespace NSOnlineOfficeBinToPdf
double m2 = oReader.ReadDouble();
double m3 = oReader.ReadDouble();
double m4 = oReader.ReadDouble();
long type;
pRenderer->get_BrushTextureMode(&type);
if (type != c_BrushTextureModeStretch)
{
m1 = 0.0;
m2 = 0.0;
}
clipRect = Aggplus::RectF_T<double>(m1, m2, m3, m4);
pRenderer->BrushRect(bIsEnableBrushRect ? 1 : 0, m1, m2, m3, m4);
break;
}
@ -590,6 +609,16 @@ namespace NSOnlineOfficeBinToPdf
pRenderer->put_BrushTextureAlpha(lAlpha);
break;
}
case ctBrushResetRotation:
{
pRenderer->GetTransform(&old_t1, &old_t2, &old_t3, &old_t4, &old_t5, &old_t6);
Aggplus::CMatrix mtr(old_t1, old_t2, old_t3, old_t4, old_t5, old_t6);
double rot = mtr.rotation();
transMatrRot.Rotate(agg::rad2deg(rot));
isResetRot = true;
break;
}
case ctSetTransform:
{
double m1 = oReader.ReadDouble();
@ -606,11 +635,15 @@ namespace NSOnlineOfficeBinToPdf
if (bIsPathOpened)
{
pRenderer->PathCommandEnd();
if (path.GetPointCount())
path.Reset();
pRenderer->EndCommand(c_nPathType);
}
pRenderer->BeginCommand(c_nPathType);
pRenderer->PathCommandStart();
path.Reset();
path.StartFigure();
bIsPathOpened = true;
break;
@ -619,14 +652,14 @@ namespace NSOnlineOfficeBinToPdf
{
double m1 = oReader.ReadDouble();
double m2 = oReader.ReadDouble();
pRenderer->PathCommandMoveTo(m1, m2);
path.MoveTo(m1, m2);
break;
}
case ctPathCommandLineTo:
{
double m1 = oReader.ReadDouble();
double m2 = oReader.ReadDouble();
pRenderer->PathCommandLineTo(m1, m2);
path.LineTo(m1, m2);
break;
}
case ctPathCommandCurveTo:
@ -637,12 +670,12 @@ namespace NSOnlineOfficeBinToPdf
double m4 = oReader.ReadDouble();
double m5 = oReader.ReadDouble();
double m6 = oReader.ReadDouble();
pRenderer->PathCommandCurveTo(m1, m2, m3, m4, m5, m6);
path.CurveTo(m1, m2, m3, m4, m5, m6);
break;
}
case ctPathCommandClose:
{
pRenderer->PathCommandClose();
path.CloseFigure();
break;
}
case ctPathCommandEnd:
@ -650,14 +683,108 @@ namespace NSOnlineOfficeBinToPdf
if (bIsPathOpened)
{
pRenderer->PathCommandEnd();
if (path.GetPointCount())
path.Reset();
pRenderer->EndCommand(c_nPathType);
bIsPathOpened = false;
}
break;
}
case ctPathCommandOffset:
{
double m1 = oReader.ReadDouble();
double m2 = oReader.ReadDouble();
pRenderer->put_BrushOffset(m1, m2);
break;
}
case ctPathCommandScale:
{
double m1 = oReader.ReadDouble();
double m2 = oReader.ReadDouble();
pRenderer->put_BrushScale(true, m1, m2);
break;
}
case ctDrawPath:
{
pRenderer->DrawPath(oReader.ReadInt());
long fill = oReader.ReadInt();
long type;
pRenderer->get_BrushType(&type);
if (fill != c_nStroke && type == c_BrushTypeTexture)
{
Aggplus::CGraphicsPath clipPath;
Aggplus::CGraphicsPath drawPath(path);
if (isResetRot)
{
pRenderer->get_BrushTextureMode(&type);
bool isStretch = type == c_BrushTextureModeStretch;
double left, top, width, height;
drawPath.GetBounds(left, top, width, height);
double rot = transMatrRot.rotation();
double cX = left + width / 2.0;
double cY = top + height / 2.0;
bool isZeroPt = clipRect.X < 0.1 && clipRect.X > -0.1 && clipRect.Y < 0.1 && clipRect.Y > -0.1;
bool isZeroRot = rot < 1e-6 && rot > -1e-6;
transMatrRot.Reset();
transMatrRot.RotateAt(agg::rad2deg(rot), cX, cY, Aggplus::MatrixOrderAppend);
double offX = old_t5 - transMatrRot.tx();
double offY = old_t6 - transMatrRot.ty();
drawPath.Transform(&transMatrRot);
pRenderer->SetTransform(1.0, 0.0, 0.0, 1.0, offX, offY);
if (isZeroPt && !isZeroRot && isStretch)
drawPath.GetBounds(left, top, width, height);
else
{
Aggplus::CGraphicsPath tmpPath;
tmpPath.AddRectangle(left, top, width, height);
tmpPath.Transform(&transMatrRot);
tmpPath.GetBounds(left, top, width, height);
}
if (isZeroPt || !isStretch)
clipRect = Aggplus::RectF_T<double>(left, top, width, height);
if (isStretch)
{
if (!isZeroPt)
clipRect.Offset(-offX, -offY);
pRenderer->BrushRect(true, clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height);
}
else
{
double tileOffX, tileOffY;
pRenderer->get_BrushOffset(tileOffX, tileOffY);
pRenderer->put_BrushOffset(tileOffX - offX, tileOffY - offY);
}
}
clipPath.AddRectangle(clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height);
path = Aggplus::CalcBooleanOperation(drawPath, clipPath, Aggplus::Intersection);
clipRect = Aggplus::RectF_T<double>();
}
pRenderer->AddPath(path);
pRenderer->DrawPath(fill);
if (isResetRot)
{
pRenderer->SetTransform(old_t1, old_t2, old_t3, old_t4, old_t5, old_t6);
transMatrRot.Reset();
isResetRot = false;
}
pRenderer->put_BrushScale(false, 1.0, 1.0);
pRenderer->put_BrushOffset(0.0, 0.0);
break;
}
case ctDrawImageFromFile:
@ -734,6 +861,8 @@ namespace NSOnlineOfficeBinToPdf
if (bIsPathOpened)
{
pRenderer->PathCommandEnd();
if (path.GetPointCount())
path.Reset();
pRenderer->EndCommand(4);
bIsPathOpened = false;
}
@ -747,8 +876,13 @@ namespace NSOnlineOfficeBinToPdf
pRenderer->EndCommand(4);
bIsPathOpened = false;
}
pRenderer->EndCommand((DWORD)(oReader.ReadInt()));
int nCommand = oReader.ReadInt();
if (path.GetPointCount() && nCommand == c_nClipType)
pRenderer->AddPath(path);
pRenderer->EndCommand((DWORD)nCommand);
pRenderer->PathCommandEnd();
if (path.GetPointCount())
path.Reset();
break;
}
case ctGradientFill:
@ -1132,6 +1266,10 @@ namespace NSOnlineOfficeBinToPdf
oReader.Skip(1);
break;
}
case ctBrushResetRotation:
{
break;
}
case ctSetTransform:
{
oReader.SkipInt(6);
@ -1164,6 +1302,16 @@ namespace NSOnlineOfficeBinToPdf
{
break;
}
case ctPathCommandOffset:
{
oReader.SkipInt(2);
break;
}
case ctPathCommandScale:
{
oReader.SkipInt(2);
break;
}
case ctDrawPath:
{
oReader.SkipInt();

View File

@ -108,6 +108,7 @@ namespace NSOnlineOfficeBinToPdf
ctBrushRectableEnabled = 30,
ctBrushGradient = 31,
ctBrushTexturePath = 32,
ctBrushResetRotation = 33,
// font
ctFontXML = 40,
@ -153,6 +154,8 @@ namespace NSOnlineOfficeBinToPdf
ctPathCommandGetCurrentPoint = 101,
ctPathCommandText = 102,
ctPathCommandTextEx = 103,
ctPathCommandOffset = 104,
ctPathCommandScale = 105,
// image
ctDrawImage = 110,

View File

@ -214,6 +214,18 @@ public:
inline bool IsPositive() { return Width > 0 && Height > 0; }
RectF_T& operator=(const RectF_T& other)
{
if (this == &other)
return *this;
X = other.X;
Y = other.Y;
Width = other.Width;
Height = other.Height;
return *this;
};
public:
T X, Y, Width, Height;
};

View File

@ -51,6 +51,7 @@
"_DestroyTextInfo",
"_IsNeedCMap",
"_SetCMapData",
"_SetScanPageFonts",
"_ScanPage",
"_SplitPages",
"_MergePages",
@ -196,7 +197,7 @@
},
{
"folder": "../../../../PdfFile/SrcReader/",
"files": ["Adaptors.cpp", "GfxClip.cpp", "RendererOutputDev.cpp", "JPXStream2.cpp", "PdfAnnot.cpp"]
"files": ["Adaptors.cpp", "GfxClip.cpp", "RendererOutputDev.cpp", "JPXStream2.cpp", "PdfAnnot.cpp", "PdfFont.cpp"]
},
{
"folder": "../../../../PdfFile/SrcWriter/",

View File

@ -639,6 +639,7 @@ SOURCES += \
$$PDF_ROOT_DIR/SrcReader/Adaptors.cpp \
$$PDF_ROOT_DIR/SrcReader/GfxClip.cpp \
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.cpp \
$$PDF_ROOT_DIR/SrcReader/PdfFont.cpp \
$$PDF_ROOT_DIR/Resources/BaseFonts.cpp \
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp
@ -664,6 +665,7 @@ HEADERS +=\
$$PDF_ROOT_DIR/SrcReader/MemoryUtils.h \
$$PDF_ROOT_DIR/SrcReader/GfxClip.h \
$$PDF_ROOT_DIR/SrcReader/FontsWasm.h \
$$PDF_ROOT_DIR/SrcReader/PdfFont.h \
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.h
DEFINES += CRYPTOPP_DISABLE_ASM

View File

@ -1047,11 +1047,15 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
if (flags & (1 << 0))
{
rec["A"] = {};
if (isRead)
readStringFunc.call(reader);
readAction(reader, rec["A"], readDoubleFunc, readStringFunc);
}
if (flags & (1 << 1))
{
rec["PA"] = {};
if (isRead)
readStringFunc.call(reader);
readAction(reader, rec["PA"], readDoubleFunc, readStringFunc);
}
// Selection mode - H
@ -1702,6 +1706,11 @@ CFile.prototype["readAnnotationsInfoFromBinary"] = function(AnnotInfo)
};
// SCAN PAGES
CFile.prototype["scanPageFonts"] = function(page)
{
this._setScanPageFonts(page);
};
CFile.prototype["scanPage"] = function(page, mode)
{
let ptr = this._scanPage(page, mode);

View File

@ -252,6 +252,11 @@ CFile.prototype._getInteractiveFormsAP = function(width, height, backgroundColor
};
// SCAN PAGES
CFile.prototype._setScanPageFonts = function(page)
{
g_native_drawing_file["SetScanPageFonts"](page);
};
CFile.prototype._scanPage = function(page, mode)
{
g_module_pointer.ptr = g_native_drawing_file["ScanPage"](page, (mode === undefined) ? 0 : mode);

View File

@ -106,7 +106,7 @@ CFile.prototype._openFile = function(buffer, password)
}
let passwordPtr = 0;
if (password)
if (password !== undefined)
{
let passwordBuf = password.toUtf8();
passwordPtr = Module["_malloc"](passwordBuf.length);
@ -227,7 +227,7 @@ CFile.prototype._UndoRedact = function()
CFile.prototype._CheckOwnerPassword = function(password)
{
let passwordPtr = 0;
if (password)
if (password !== undefined)
{
let passwordBuf = password.toUtf8();
passwordPtr = Module["_malloc"](passwordBuf.length);
@ -388,6 +388,11 @@ CFile.prototype._getInteractiveFormsAP = function(width, height, backgroundColor
};
// SCAN PAGES
CFile.prototype._setScanPageFonts = function(page)
{
Module["_SetScanPageFonts"](this.nativeFile, page);
};
CFile.prototype._scanPage = function(page, mode)
{
g_module_pointer.ptr = Module["_ScanPage"](this.nativeFile, page, (mode === undefined) ? 0 : mode);

View File

@ -80,7 +80,7 @@ WASM_EXPORT CDrawingFile* Open(BYTE* data, LONG size, const char* password)
std::wstring sPassword = L"";
if (NULL != password)
sPassword = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)password, strlen(password));
pFile->OpenFile(data, size, sPassword);
pFile->OpenFile(data, size, password ? sPassword.c_str() : NULL);
return pFile;
}
WASM_EXPORT int GetType(CDrawingFile* pFile)
@ -166,6 +166,10 @@ WASM_EXPORT void SetCMapData(CDrawingFile* pFile, BYTE* data, int size)
{
pFile->SetCMapData(data, size);
}
WASM_EXPORT void SetScanPageFonts(CDrawingFile* pFile, int nPageIndex)
{
return pFile->SetScanPageFonts(nPageIndex);
}
WASM_EXPORT BYTE* ScanPage(CDrawingFile* pFile, int nPageIndex, int mode)
{
return pFile->ScanPage(nPageIndex, mode);
@ -200,7 +204,7 @@ WASM_EXPORT int CheckOwnerPassword(CDrawingFile* pFile, const char* password)
std::wstring sPassword = L"";
if (NULL != password)
sPassword = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)password, strlen(password));
return pFile->CheckOwnerPassword(sPassword) ? 1 : 0;
return pFile->CheckOwnerPassword(password ? sPassword.c_str() : NULL) ? 1 : 0;
}
WASM_EXPORT int CheckPerm(CDrawingFile* pFile, int nPermFlag)
{

View File

@ -971,7 +971,7 @@ void ReadInteractiveFormsFonts(CDrawingFile* pGrFile, int nType)
int nFontLength = READ_INT(pFont + i2);
i2 += 4;
std::cout << std::endl << "CIDtoUnicode" << std::endl;
std::cout << std::endl << "GIDtoUnicode" << std::endl;
for (int j = 0; j < nFontLength; ++j)
{
@ -979,7 +979,7 @@ void ReadInteractiveFormsFonts(CDrawingFile* pGrFile, int nType)
i2 += 4;
unsigned int unicode = READ_INT(pFont + i2);
i2 += 4;
std::cout << "cid\t" << code << "\tunicode\t" << unicode << std::endl;
std::cout << "gid\t" << code << "\tunicode\t" << unicode << std::endl;
}
std::cout << std::endl;
@ -1072,7 +1072,7 @@ int main(int argc, char* argv[])
if (!NSFile::CFileBinary::ReadAllBytes(sFilePath, &pFileData, nFileDataLen))
return 1;
CDrawingFile* pGrFile = Open(pFileData, (LONG)nFileDataLen, "");
CDrawingFile* pGrFile = Open(pFileData, (LONG)nFileDataLen, NULL);
int nError = GetErrorCode(pGrFile);
if (nError != 0)
@ -1080,7 +1080,7 @@ int main(int argc, char* argv[])
Close(pGrFile);
if (nError == 4)
{
std::string sPassword = "123456";
std::string sPassword = "";
pGrFile = Open(pFileData, nFileDataLen, sPassword.c_str());
}
else
@ -1100,7 +1100,7 @@ int main(int argc, char* argv[])
if (true && GetFromBase64(NSFile::GetProcessDirectory() + L"/split.txt", &pBuffer, &nBufferLen))
{
std::vector<int> arrPages = { 2 };
std::vector<int> arrPages = { 0 };
BYTE* pSplitPages = SplitPages(pGrFile, arrPages.data(), arrPages.size(), pBuffer, nBufferLen);
int nLength = READ_INT(pSplitPages);
@ -1175,7 +1175,7 @@ int main(int argc, char* argv[])
// OWNER PASSWORD
if (false)
{
std::string sPassword = "gfhjkmgfhjkm";
std::string sPassword = "";
std::cout << "CheckPerm 4 Edit " << CheckPerm(pGrFile, 4) << std::endl;
std::cout << "CheckPerm 4 Print " << CheckPerm(pGrFile, 3) << std::endl;
@ -1184,10 +1184,10 @@ int main(int argc, char* argv[])
std::cout << "CheckPerm 4 Print " << CheckPerm(pGrFile, 3) << std::endl;
}
BYTE* pColor = new BYTE[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// REDACT
if (false)
{
BYTE* pColor = new BYTE[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int pRect[8] = { 307499, 217499, 307499, 1124999, 1799999, 1124999, 1799999, 217499 };
if (!RedactPage(pGrFile, nTestPage, pRect, 1, pColor, 12))
std::cout << "Redact false" << std::endl;
@ -1364,7 +1364,7 @@ int main(int argc, char* argv[])
}
// INTERACTIVE FORMS
if (true)
if (false)
{
ReadInteractiveFormsFonts(pGrFile, 1);
ReadInteractiveFormsFonts(pGrFile, 2);
@ -1483,7 +1483,7 @@ int main(int argc, char* argv[])
}
// ANNOTS
if (true)
if (false)
{
BYTE* pAnnots = GetAnnotationsInfo(pGrFile, -1);
nLength = READ_INT(pAnnots);
@ -2251,12 +2251,10 @@ int main(int argc, char* argv[])
free(pAnnotAP);
}
// SCAN PAGE
// SCAN PAGE Fonts
if (true)
{
BYTE* pScan = ScanPage(pGrFile, nTestPage, 2);
if (pScan)
free(pScan);
SetScanPageFonts(pGrFile, nTestPage);
ReadInteractiveFormsFonts(pGrFile, 1);
ReadInteractiveFormsFonts(pGrFile, 2);

View File

@ -63,9 +63,9 @@ public:
// Open
virtual bool LoadFromFile(const std::wstring& file, const std::wstring& options = L"",
const std::wstring& owner_password = L"", const std::wstring& user_password = L"") = 0;
const wchar_t* owner_password = NULL, const wchar_t* user_password = NULL) = 0;
virtual bool LoadFromMemory(unsigned char* data, unsigned long length, const std::wstring& options = L"",
const std::wstring& owner_password = L"", const std::wstring& user_password = L"") = 0;
const wchar_t* owner_password = NULL, const wchar_t* user_password = NULL) = 0;
// Close
virtual void Close() = 0;

View File

@ -113,7 +113,10 @@ const long c_BrushTypeTensorCurveGradient = 6007;
const long c_BrushTextureModeStretch = 0;
const long c_BrushTextureModeTile = 1;
const long c_BrushTextureModeTileCenter = 2;
const long c_BrushTextureModeTileFlipX = 2;
const long c_BrushTextureModeTileFlipY = 3;
const long c_BrushTextureModeTileFlipXY = 4;
const long c_BrushTextureModeTileCenter = 5;
// --------------------------------------------------------------
namespace Aggplus { class CImage; }
@ -284,6 +287,13 @@ namespace NSStructures
Aggplus::RectF Rect;
Aggplus::CDoubleRect Bounds;
int IsScale;
double ScaleX;
double ScaleY;
double OffsetX;
double OffsetY;
double LinearAngle;
std::vector<TSubColor> m_arrSubColors;
NSStructures::GradientInfo m_oGradientInfo;
@ -415,6 +425,13 @@ namespace NSStructures
Rect.Width = 0.0F;
Rect.Height = 0.0F;
IsScale = FALSE;
ScaleX = 1.0;
ScaleY = 1.0;
OffsetX = 0.0;
OffsetY = 0.0;
Bounds.left = 0;
Bounds.top = 0;
Bounds.right = 0;
@ -454,6 +471,10 @@ namespace NSStructures
Rect = other.Rect;
Bounds = other.Bounds;
IsScale = other.IsScale;
ScaleX = other.ScaleX;
ScaleY = other.ScaleY;
LinearAngle = other.LinearAngle;
m_arrSubColors = other.m_arrSubColors;
m_oGradientInfo = other.m_oGradientInfo;

View File

@ -8,8 +8,8 @@ namespace SVG
: CObject(oReader), m_enUnits{EMarkerUnits::StrokeWidth}, m_enOrient{EMarkerOrient::Angle},
m_dAngle(0.), m_oBounds{0., 0., 0., 0.}
{
m_oWindow.m_oWidth.SetValue(3);
m_oWindow.m_oHeight.SetValue(3);
m_oWindow.m_oWidth.SetValue(3, NSCSS::Pixel);
m_oWindow.m_oHeight.SetValue(3, NSCSS::Pixel);
}
ObjectType CMarker::GetType() const

View File

@ -153,7 +153,7 @@ namespace SVG
bool CObject::ApplyClip(IRenderer *pRenderer, const TClip *pClip, const CSvgFile *pFile, const TBounds &oBounds) const
{
if (NULL == pRenderer || NULL == pClip || NULL == pFile || pClip->m_oHref.Empty() || NSCSS::NSProperties::ColorType::ColorUrl != pClip->m_oHref.GetType())
if (NULL == pRenderer || NULL == pClip || NULL == pFile || pClip->m_oHref.Empty() || NSCSS::NSProperties::EColorType::ColorUrl != pClip->m_oHref.GetType())
return false;
if (pClip->m_oRule == L"evenodd")
@ -169,7 +169,7 @@ namespace SVG
bool CObject::ApplyMask(IRenderer *pRenderer, const NSCSS::NSProperties::CColor *pMask, const CSvgFile *pFile, const TBounds &oBounds) const
{
if (NULL == pRenderer || NULL == pMask || NULL == pFile || NSCSS::NSProperties::ColorType::ColorUrl != pMask->GetType())
if (NULL == pRenderer || NULL == pMask || NULL == pFile || NSCSS::NSProperties::EColorType::ColorUrl != pMask->GetType())
return false;
return ApplyDef(pRenderer, pFile, pMask->ToWString(), oBounds);
@ -358,7 +358,7 @@ namespace SVG
bool CRenderedObject::ApplyStroke(IRenderer *pRenderer, const TStroke *pStroke, bool bUseDefault, const CRenderedObject* pContextObject) const
{
if (NULL == pRenderer || NULL == pStroke || NSCSS::NSProperties::ColorType::ColorNone == pStroke->m_oColor.GetType() || (!bUseDefault && ((pStroke->m_oWidth.Empty() || pStroke->m_oWidth.Zero()) && pStroke->m_oColor.Empty())))
if (NULL == pRenderer || NULL == pStroke || pStroke->m_oColor.None() || (!bUseDefault && ((pStroke->m_oWidth.Empty() || pStroke->m_oWidth.Zero()) && pStroke->m_oColor.Empty())))
{
pRenderer->put_PenSize(0);
return false;
@ -369,12 +369,12 @@ namespace SVG
if (Equals(0., dStrokeWidth))
dStrokeWidth = 1.;
if (NSCSS::NSProperties::ColorType::ColorContextFill == pStroke->m_oColor.GetType() && NULL != pContextObject)
if (NSCSS::NSProperties::EColorType::ColorContextFill == pStroke->m_oColor.GetType() && NULL != pContextObject)
pRenderer->put_PenColor(pContextObject->m_oStyles.m_oFill.ToInt());
else if (NSCSS::NSProperties::ColorType::ColorContextStroke == pStroke->m_oColor.GetType() && NULL != pContextObject)
else if (NSCSS::NSProperties::EColorType::ColorContextStroke == pStroke->m_oColor.GetType() && NULL != pContextObject)
pRenderer->put_PenColor(pContextObject->m_oStyles.m_oStroke.m_oColor.ToInt());
else
pRenderer->put_PenColor((pStroke->m_oColor.Empty() || NSCSS::NSProperties::ColorType::ColorNone == pStroke->m_oColor.GetType()) ? 0 : pStroke->m_oColor.ToInt());
pRenderer->put_PenColor((pStroke->m_oColor.Empty() || NSCSS::NSProperties::EColorType::ColorNone == pStroke->m_oColor.GetType()) ? 0 : pStroke->m_oColor.ToInt());
pRenderer->put_PenSize(dStrokeWidth);
pRenderer->put_PenAlpha(255. * pStroke->m_oColor.GetOpacity());
@ -401,18 +401,18 @@ namespace SVG
bool CRenderedObject::ApplyFill(IRenderer *pRenderer, const NSCSS::NSProperties::CColor *pFill, const CSvgFile *pFile, bool bUseDefault, const CRenderedObject* pContextObject) const
{
if (NULL == pRenderer || NULL == pFill || NSCSS::NSProperties::ColorType::ColorNone == pFill->GetType() || (!bUseDefault && pFill->Empty()))
if (NULL == pRenderer || NULL == pFill || pFill->None() || (!bUseDefault && pFill->Empty()))
{
pRenderer->put_BrushType(c_BrushTypeNoFill);
return false;
}
else if (NSCSS::NSProperties::ColorType::ColorHEX == pFill->GetType() ||
NSCSS::NSProperties::ColorType::ColorRGB == pFill->GetType())
else if (NSCSS::NSProperties::EColorType::ColorHEX == pFill->GetType() ||
NSCSS::NSProperties::EColorType::ColorRGB == pFill->GetType())
{
pRenderer->put_BrushColor1((pFill->Empty() && bUseDefault) ? 0 : pFill->ToInt());
pRenderer->put_BrushType(c_BrushTypeSolid);
}
else if (NSCSS::NSProperties::ColorType::ColorUrl == pFill->GetType())
else if (NSCSS::NSProperties::EColorType::ColorUrl == pFill->GetType())
{
if (!ApplyDef(pRenderer, pFile, pFill->ToWString(), GetBounds()))
{
@ -425,10 +425,16 @@ namespace SVG
return false;
}
}
else if (NSCSS::NSProperties::ColorType::ColorContextFill == pFill->GetType() && NULL != pContextObject)
pRenderer->put_BrushColor1(pContextObject->m_oStyles.m_oFill.ToInt());
else if (NSCSS::NSProperties::ColorType::ColorContextStroke == pFill->GetType() && NULL != pContextObject)
pRenderer->put_BrushColor1(pContextObject->m_oStyles.m_oStroke.m_oColor.ToInt());
else if (NSCSS::NSProperties::EColorType::ColorContextFill == pFill->GetType() && NULL != pContextObject)
{
if (!ApplyFill(pRenderer, &pContextObject->m_oStyles.m_oFill, pFile, bUseDefault, pContextObject))
return false;
}
else if (NSCSS::NSProperties::EColorType::ColorContextStroke == pFill->GetType() && NULL != pContextObject)
{
if (!ApplyFill(pRenderer, &pContextObject->m_oStyles.m_oStroke.m_oColor, pFile, bUseDefault, pContextObject))
return false;
}
else if (bUseDefault)
{
pRenderer->put_BrushColor1(0);

View File

@ -566,7 +566,7 @@ namespace SVG
#define CALCULATE_ANGLE(firstPoint, secondPoint) std::atan2(secondPoint.dY - firstPoint.dY, secondPoint.dX - firstPoint.dX) * 180. / M_PI
if (!m_oMarkers.m_oStart.Empty() && NSCSS::NSProperties::ColorType::ColorUrl == m_oMarkers.m_oStart.GetType())
if (!m_oMarkers.m_oStart.Empty() && NSCSS::NSProperties::EColorType::ColorUrl == m_oMarkers.m_oStart.GetType())
{
CMarker *pStartMarker = dynamic_cast<CMarker*>(pFile->GetMarkedObject(m_oMarkers.m_oStart.ToWString()));
@ -610,7 +610,7 @@ namespace SVG
}
}
if (!m_oMarkers.m_oMid.Empty() && NSCSS::NSProperties::ColorType::ColorUrl == m_oMarkers.m_oMid.GetType())
if (!m_oMarkers.m_oMid.Empty() && NSCSS::NSProperties::EColorType::ColorUrl == m_oMarkers.m_oMid.GetType())
{
CMarker *pMidMarker = dynamic_cast<CMarker*>(pFile->GetMarkedObject(m_oMarkers.m_oMid.ToWString()));
@ -638,7 +638,7 @@ namespace SVG
}
}
if (!m_oMarkers.m_oEnd.Empty() && NSCSS::NSProperties::ColorType::ColorUrl == m_oMarkers.m_oEnd.GetType())
if (!m_oMarkers.m_oEnd.Empty() && NSCSS::NSProperties::EColorType::ColorUrl == m_oMarkers.m_oEnd.GetType())
{
CMarker *pEndMarker = dynamic_cast<CMarker*>(pFile->GetMarkedObject(m_oMarkers.m_oEnd.ToWString()));

View File

@ -110,6 +110,9 @@ namespace SVG
if (mAttributes.end() != mAttributes.find(L"text-decoration"))
m_oText.SetDecoration(mAttributes.at(L"text-decoration"), ushLevel, bHardMode);
if (mAttributes.end() != mAttributes.find(L"baseline-shift"))
m_oText.SetBaselineShift(mAttributes.at(L"baseline-shift"), ushLevel, bHardMode);
//POSITION
if (mAttributes.end() != mAttributes.find(L"rotate"))
{
@ -241,7 +244,27 @@ namespace SVG
std::wstring wsFontFamily = DefaultFontFamily;
double dFontSize = ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE) * 72. / 25.4;
Normalize(pRenderer, dX, dY, dFontSize, oOldMatrix);
double dScaleX = 1., dScaleY = 1.;
NormalizeFontSize(dFontSize, dScaleX, dScaleY);
if (!Equals(1., dScaleX) || !Equals(1., dScaleY))
{
dX /= dScaleX;
dY /= dScaleY;
double dM11, dM12, dM21, dM22, dDx, dDy;
pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
oOldMatrix.SetElements(dM11, dM12, dM21, dM22, dDx, dDy);
Aggplus::CMatrix oMatrix(dM11, dM12, dM21, dM22, dDx, dDy);
oMatrix.Scale(dScaleX, dScaleY);
pRenderer->SetTransform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty());
}
if (!m_oFont.GetFamily().Empty())
{
@ -271,12 +294,12 @@ namespace SVG
m_pFontManager->LoadFontByName(wsFontFamily, dFontSize, nStyle, 72., 72.);
m_pFontManager->SetCharSpacing(0);
double dKoef = 25.4 / 72.;
const double dKoef = 25.4 / 72.;
NSFonts::IFontFile* pFontFile = m_pFontManager->GetFile();
if (pFontFile)
dFHeight *= pFontFile->GetHeight() / pFontFile->Units_Per_Em() * dKoef;
dFHeight *= pFontFile->GetHeight() / pFontFile->Units_Per_Em() * dKoef;
m_pFontManager->LoadString1(m_wsText, 0, 0);
TBBox oBox = m_pFontManager->MeasureString2();
@ -299,6 +322,45 @@ namespace SVG
else if (L"center" == m_oText.GetAlign().ToWString())
dX += -fW / 2;
if (NSCSS::NSProperties::EBaselineShift::Baseline != m_oText.GetBaselineShiftType())
{
switch(m_oText.GetBaselineShiftType())
{
case NSCSS::NSProperties::Sub:
{
dY += dFHeight / 2.;
break;
}
case NSCSS::NSProperties::Super:
{
double dParentHeight{dFHeight};
if (nullptr != m_pParent)
dParentHeight = ((CTSpan*)m_pParent)->GetFontHeight() / dScaleY;
dY -= dParentHeight - dFHeight / 2.;
break;
}
case NSCSS::NSProperties::Percentage:
{
double dParentHeight{dFHeight};
if (nullptr != m_pParent)
dParentHeight = ((CTSpan*)m_pParent)->GetFontHeight() / dScaleY;
dY -= dParentHeight * (m_oText.GetBaselineShiftValue() / 100.);
break;
}
case NSCSS::NSProperties::Length:
{
dY -= m_oText.GetBaselineShiftValue() / dScaleY;
break;
}
default:
break;
}
}
if (m_oText.Underline() || m_oText.LineThrough() || m_oText.Overline())
{
pRenderer->put_PenSize((double)fUndSize);
@ -389,7 +451,7 @@ namespace SVG
oBounds.m_dRight = oBounds.m_dLeft + GetWidth();
oBounds.m_dBottom = m_oY.ToDouble(NSCSS::Pixel);
oBounds.m_dTop = oBounds.m_dBottom + ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE);
oBounds.m_dTop = oBounds.m_dBottom - ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE);
if (nullptr != pTransform)
{
@ -484,56 +546,33 @@ namespace SVG
dY = m_oY.ToDouble(NSCSS::Pixel, oBounds.m_dBottom - oBounds.m_dTop);
}
void CTSpan::Normalize(IRenderer *pRenderer, double &dX, double &dY, double &dFontHeight, Aggplus::CMatrix& oOldMatrix) const
void CTSpan::NormalizeFontSize(double& dFontHeight, double& dScaleX, double& dScaleY) const
{
if (NULL == pRenderer)
return;
Aggplus::CMatrix oCurrentMatrix(m_oTransformation.m_oTransform.GetMatrix().GetFinalValue());
double dXScale = 1., dYScale = 1.;
const double dModuleM11 = std::abs(oCurrentMatrix.sx());
const double dModuleM22 = std::abs(oCurrentMatrix.sy());
if (!ISZERO(dModuleM11) && (dModuleM11 < MIN_SCALE || dModuleM11 > MAX_SCALE))
dXScale /= dModuleM11;
dScaleX /= dModuleM11;
if (!ISZERO(dModuleM22) && (dModuleM22 < MIN_SCALE || dModuleM22 > MAX_SCALE))
dYScale /= dModuleM22;
dScaleY /= dModuleM22;
dFontHeight *= dYScale;
dFontHeight *= dScaleY;
if (!Equals(0., dFontHeight) && dFontHeight < MIN_FONT_SIZE)
{
dXScale *= MIN_FONT_SIZE / dFontHeight;
dYScale *= MIN_FONT_SIZE / dFontHeight;
dScaleX *= MIN_FONT_SIZE / dFontHeight;
dScaleY *= MIN_FONT_SIZE / dFontHeight;
dFontHeight = MIN_FONT_SIZE;
}
else if (!Equals(0., dFontHeight) && dFontHeight > MAX_FONT_SIZE)
{
dXScale *= dFontHeight / MAX_FONT_SIZE;
dYScale *= dFontHeight / MAX_FONT_SIZE;
dScaleX *= dFontHeight / MAX_FONT_SIZE;
dScaleY *= dFontHeight / MAX_FONT_SIZE;
dFontHeight = MAX_FONT_SIZE;
}
if (Equals(1., dXScale) && Equals(1., dYScale))
return;
dX /= dXScale;
dY /= dYScale;
double dM11, dM12, dM21, dM22, dDx, dDy;
pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
oOldMatrix.SetElements(dM11, dM12, dM21, dM22, dDx, dDy);
Aggplus::CMatrix oMatrix(dM11, dM12, dM21, dM22, dDx, dDy);
oMatrix.Scale(dXScale, dYScale);
pRenderer->SetTransform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty());
}
void CTSpan::SetPosition(const Point &oPosition)
@ -569,6 +608,40 @@ namespace SVG
}
double CTSpan::GetFontHeight() const
{
if (NULL == m_pFontManager)
return ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE) * 72. / 25.4;
std::wstring wsFontFamily = DefaultFontFamily;
double dFontSize = ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE) * 72. / 25.4;
if (!m_oFont.GetFamily().Empty())
{
wsFontFamily = m_oFont.GetFamily().ToWString();
CorrectFontFamily(wsFontFamily);
}
int nStyle = 0;
if (m_oFont.GetWeight().ToWString() == L"bold")
nStyle |= 0x01;
if (m_oFont.GetStyle() .ToWString() == L"italic")
nStyle |= 0x02;
if (m_oText.Underline())
nStyle |= (1 << 2);
// Вычиления размеров текста
m_pFontManager->LoadFontByName(wsFontFamily, dFontSize, nStyle, 72., 72.);
m_pFontManager->SetCharSpacing(0);
m_pFontManager->LoadString1(m_wsText, 0, 0);
TBBox oBox = m_pFontManager->MeasureString2();
return (double)(25.4f / 72.f * (oBox.fMaxY - oBox.fMinY));
}
std::vector<CTSpan> CTSpan::Split() const
{
std::vector<CTSpan> arGlyphs;

View File

@ -44,11 +44,13 @@ namespace SVG
void CalculatePosition(double& dX, double& dY) const;
void Normalize(IRenderer* pRenderer, double& dX, double& dY, double& dFontHeight, Aggplus::CMatrix& oOldMatrix) const;
void NormalizeFontSize(double& dFontHeight, double& dScaleX, double& dScaleY) const;
void SetPosition(const Point& oPosition);
void SetPositionFromParent(CRenderedObject* pParent);
double GetFontHeight() const;
std::vector<CTSpan> Split() const;
NSFonts::IFontManager* m_pFontManager;

View File

@ -24,6 +24,7 @@
#include <openssl/engine.h>
#include <openssl/evp.h>
#include <openssl/conf.h>
#include <openssl/rand.h>
#include <map>
#include <memory>
@ -604,6 +605,12 @@ public:
evp = EVP_sha512();
else if (m_alg == OOXML_HASH_ALG_ECDSA_384)
evp = EVP_sha384();
else if (m_alg == OOXML_HASH_ALG_SHA256)
evp = EVP_sha256();
else if (m_alg == OOXML_HASH_ALG_SHA384)
evp = EVP_sha384();
else if (m_alg == OOXML_HASH_ALG_SHA512)
evp = EVP_sha512();
if (!PKCS7_sign_add_signer(pkcs7, m_cert, m_key, evp, 0))
{

View File

@ -42,7 +42,7 @@ CDjVuFile::~CDjVuFile()
delete m_pImplementation;
}
bool CDjVuFile::LoadFromFile(const std::wstring& file, const std::wstring& options,
const std::wstring& owner_password, const std::wstring& user_password)
const wchar_t* owner_password, const wchar_t* user_password)
{
if (m_pImplementation)
return m_pImplementation->LoadFromFile(file, options);
@ -50,7 +50,7 @@ bool CDjVuFile::LoadFromFile(const std::wstring& file, const std::wstring& optio
return false;
}
bool CDjVuFile::LoadFromMemory(BYTE* data, DWORD length, const std::wstring& options,
const std::wstring& owner_password, const std::wstring& user_password)
const wchar_t* owner_password, const wchar_t* user_password)
{
if (m_pImplementation)
return m_pImplementation->LoadFromMemory(data, length, options);

View File

@ -55,9 +55,9 @@ public:
virtual ~CDjVuFile();
virtual bool LoadFromFile(const std::wstring& file, const std::wstring& options = L"",
const std::wstring& owner_password = L"", const std::wstring& user_password = L"");
const wchar_t* owner_password = NULL, const wchar_t* user_password = NULL);
virtual bool LoadFromMemory(BYTE* data, DWORD length, const std::wstring& options = L"",
const std::wstring& owner_password = L"", const std::wstring& user_password = L"");
const wchar_t* owner_password = NULL, const wchar_t* user_password = NULL);
virtual void Close();
virtual NSFonts::IApplicationFonts* GetFonts();

View File

@ -92,6 +92,7 @@ int CDocxRenderer::Convert(IOfficeDrawingFile* pFile, const std::wstring& sDst,
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = false;
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = false;
m_pInternal->m_bIsSupportShapeCommands = false;
m_pInternal->m_oDocument.m_bIsRecord = true;
if (bIsOutCompress)
m_pInternal->m_oDocument.m_strTempDirectory = NSDirectory::CreateDirectoryWithUniqueName(m_pInternal->m_sTempDirectory);
@ -130,6 +131,7 @@ std::vector<std::wstring> CDocxRenderer::ScanPage(IOfficeDrawingFile* pFile, siz
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = true;
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
m_pInternal->m_bIsSupportShapeCommands = false;
m_pInternal->m_oDocument.m_bIsRecord = false;
DrawPage(pFile, nPage);
@ -146,6 +148,7 @@ std::vector<std::wstring> CDocxRenderer::ScanPagePptx(IOfficeDrawingFile* pFile,
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
m_pInternal->m_oDocument.m_oCurrentPage.m_bCollectMetaInfo = true;
m_pInternal->m_bIsSupportShapeCommands = true;
m_pInternal->m_oDocument.m_bIsRecord = false;
m_pInternal->m_eShapeSerializeType = ShapeSerializeType::sstXml;
DrawPage(pFile, nPage);
@ -162,7 +165,10 @@ NSWasm::CData CDocxRenderer::ScanPageBin(IOfficeDrawingFile* pFile, size_t nPage
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = true;
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
m_pInternal->m_oDocument.m_oCurrentPage.m_bCollectMetaInfo = true;
m_pInternal->m_oDocument.m_bIsRecord = false;
m_pInternal->m_bIsSupportShapeCommands = true;
m_pInternal->m_oDocument.m_oFontStyleManager.Clear();
m_pInternal->m_oDocument.m_oFontSelector.ClearCache();
DrawPage(pFile, nPage);

View File

@ -572,8 +572,11 @@ namespace NSDocxRenderer
m_oPageBuilder.ClearNoAttack();
m_oCurrentPage.Analyze();
m_oCurrentPage.Record(m_oPageBuilder, m_lPageNum >= m_lNumberPages - 1);
m_arXmlString.push_back(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(m_oPageBuilder.GetBuffer(), (LONG)m_oPageBuilder.GetCurSize()));
if (m_bIsRecord)
{
m_oCurrentPage.Record(m_oPageBuilder, m_lPageNum >= m_lNumberPages - 1);
m_arXmlString.push_back(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(m_oPageBuilder.GetBuffer(), (LONG)m_oPageBuilder.GetCurSize()));
}
if (m_oPageBuilder.GetCurSize() > 100000000/*100Mb*/)
m_oPageBuilder.Clear();

View File

@ -40,6 +40,7 @@ namespace NSDocxRenderer
LONG m_lNumberPages{0};
bool m_bIsDisablePageCommand {false}; // disable commands inside draw function
bool m_bIsRecord {true};
NSStringUtils::CStringBuilder m_oPageBuilder;
std::list<std::string> m_arXmlString;

View File

@ -70,6 +70,8 @@ namespace NSDocxRenderer
m_oContBuilder.Clear();
m_arCompleteObjectsXml.clear();
m_arLuminosityShapes.clear();
m_bFontSubstitution = false;
}
CPage::~CPage()
@ -193,14 +195,17 @@ namespace NSDocxRenderer
if (!m_arShapes.empty())
{
auto& last_shape = m_arShapes.back();
if (last_shape->IsEqual(top, bot, left, right) && rotation == last_shape->m_dRotation)
auto& last_shape = m_arShapes.back();
if (last_shape->IsEqual(top, bot, left, right) && rotation == last_shape->m_dRotation && lType != m_lLastType && m_lLastType != 0)
{
set_fill_mode(last_shape);
// Reset stroke/fill logic
m_lLastType = 0;
return;
}
}
m_lLastType = lType;
auto shape = std::make_shared<CShape>();
shape->m_oPen.Size *= transform_det;
set_fill_mode(shape);
@ -327,13 +332,15 @@ namespace NSDocxRenderer
m_oManagers.pFontManager->SetStringGid(0);
m_oManagers.pFontManager->MeasureStringGids(pUnicodes, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::mtPosition);
}
_h = m_oManagers.pFontManager->GetFontHeight();
double baseline = dTextY + fBaseLineOffset;
double top = baseline - _h;
double left = dTextX;
double right = left + _w;
double right = dTextR;
if (left == right) // XPS
right = left + _w;
// use forced fold option
const auto& oParams = m_oManagers.pFontManager->GetFontSelectParams();
@ -641,20 +648,8 @@ namespace NSDocxRenderer
{
for (auto& line : m_arTextLines)
for (auto& cont : line->m_arConts)
{
if (cont && cont->m_oSelectedSizes.dHeight == 0.0 && cont->m_oSelectedSizes.dWidth == 0.0)
{
if (m_bUseDefaultFont)
{
cont->m_oSelectedSizes.dHeight = cont->m_dHeight;
cont->m_oSelectedSizes.dWidth = cont->m_dWidth;
}
else
{
cont->CalcSelected();
}
}
}
if (cont && !m_bUseDefaultFont)
cont->CalcSelected();
}
void CPage::AnalyzeShapes()
@ -767,6 +762,19 @@ namespace NSDocxRenderer
if (line && line->m_arConts.empty())
line = nullptr;
for (auto& line : m_arTextLines)
if (line)
{
bool is_remove = true;
for(auto& cont : line->m_arConts)
if (cont && !cont->IsOnlySpaces())
is_remove = false;
if (is_remove)
line = nullptr;
}
auto right = MoveNullptr(m_arTextLines.begin(), m_arTextLines.end());
m_arTextLines.erase(right, m_arTextLines.end());
@ -835,7 +843,8 @@ namespace NSDocxRenderer
// шейпы из буквиц
for (auto&& drop_cap : drop_caps)
{
drop_cap->CalcSelected();
if (!m_bUseDefaultFont)
drop_cap->CalcSelected();
auto line = std::make_shared<CTextLine>();
line->AddCont(drop_cap);
@ -1351,6 +1360,21 @@ namespace NSDocxRenderer
return IsHorizontalLineTrough(dummy_cont);
}
bool CPage::IsTextLineBetween(text_line_ptr_t pFirst, text_line_ptr_t pSecond) const noexcept
{
double left = std::min(pFirst->m_dLeft, pSecond->m_dLeft);
double right = std::max(pFirst->m_dRight, pSecond->m_dRight);
double top = std::min(pFirst->m_dBotWithMaxDescent, pSecond->m_dBotWithMaxDescent);
double bot = std::max(pFirst->m_dTopWithMaxAscent, pSecond->m_dTopWithMaxAscent);
auto dummy_cont = std::make_shared<CContText>();
dummy_cont->m_dLeft = left - c_dGRAPHICS_ERROR_MM;
dummy_cont->m_dRight = right + c_dGRAPHICS_ERROR_MM;
dummy_cont->m_dTop = top - c_dGRAPHICS_ERROR_MM;
dummy_cont->m_dBot = bot + c_dGRAPHICS_ERROR_MM;
return IsTextLineTrough(dummy_cont);
}
bool CPage::IsVerticalLineTrough(base_item_ptr_t pFirst) const noexcept
{
@ -1359,7 +1383,9 @@ namespace NSDocxRenderer
const auto center = pFirst->m_dTop + height / 2;
for (const auto& line : ver_lines)
if (line.pos > pFirst->m_dLeft && line.pos < pFirst->m_dRight && line.min <= center && line.max >= center)
if (line.pos - pFirst->m_dLeft > c_dGRAPHICS_ERROR_IN_LINES_MM &&
pFirst->m_dRight - line.pos > c_dGRAPHICS_ERROR_IN_LINES_MM &&
line.min <= center && line.max >= center)
return true;
return false;
@ -1376,6 +1402,20 @@ namespace NSDocxRenderer
return false;
}
bool CPage::IsTextLineTrough(base_item_ptr_t pFirst) const noexcept
{
const auto width = pFirst->m_dRight - pFirst->m_dLeft;
const auto center = pFirst->m_dLeft + width / 2;
for (const auto& text_line : m_arShapes)
if (text_line && text_line->m_eType == CShape::eShapeType::stTextBox && text_line->m_dBot > pFirst->m_dTop &&
text_line->m_dBot < pFirst->m_dBot &&
text_line->m_dLeft <= center &&
text_line->m_dRight >= center)
return true;
return false;
}
void CPage::SplitLines()
{
@ -1445,7 +1485,7 @@ namespace NSDocxRenderer
for (const auto& line : m_arTextLines)
{
if (fabs(line->m_dBotWithMaxDescent - curr_bot) < 4 * c_dTHE_SAME_STRING_Y_PRECISION_MM)
if (fabs(line->m_dBot - curr_bot) < 4 * c_dTHE_SAME_STRING_Y_PRECISION_MM)
{
bot_aligned_text_lines.back().push_back(line);
}
@ -1453,7 +1493,7 @@ namespace NSDocxRenderer
{
bot_aligned_text_lines.push_back({});
bot_aligned_text_lines.back().push_back(line);
curr_bot = line->m_dBotWithMaxDescent;
curr_bot = line->m_dBot;
}
}
@ -1571,10 +1611,12 @@ namespace NSDocxRenderer
curr_line->CalcFirstWordWidth();
for (auto& cont : prev_line->m_arConts)
cont->CalcSelected();
if (!m_bUseDefaultFont)
cont->CalcSelected();
for (auto& cont : curr_line->m_arConts)
cont->CalcSelected();
if (!m_bUseDefaultFont)
cont->CalcSelected();
m_arShapes.push_back(CreateSingleLineShape(prev_line));
m_arShapes.push_back(CreateSingleLineShape(curr_line));
@ -1606,9 +1648,9 @@ namespace NSDocxRenderer
// lamda to setup and add paragpraph
auto add_paragraph = [this, &max_right, &min_left, &ar_paragraphs] (paragraph_ptr_t& paragraph) {
double additional_bottom = paragraph->m_arTextLines.front()->m_dTopWithMaxAscent - paragraph->m_arTextLines.front()->m_dTop;
paragraph->m_dBot = paragraph->m_arTextLines.back()->m_dBot + additional_bottom;
paragraph->m_dTop = paragraph->m_arTextLines.front()->m_dTopWithMaxAscent;
std::shared_ptr<CTextLine>& firstLine = paragraph->m_arTextLines.front();
paragraph->m_dBot = paragraph->m_arTextLines.back()->m_dBotWithMaxDescent;
paragraph->m_dTop = firstLine->m_dTopWithMaxAscent;
paragraph->m_dRight = max_right;
paragraph->m_dLeft = min_left;
@ -1625,6 +1667,23 @@ namespace NSDocxRenderer
paragraph->MergeLines();
// Correct first line position
double firstLine_height = firstLine->m_dBotWithMaxDescent - firstLine->m_dTopWithMaxAscent;
if (paragraph->m_dLineHeight > firstLine_height)
{
double offset = paragraph->m_dLineHeight - firstLine_height;
paragraph->m_dTop -= offset;
paragraph->m_dBot -= offset;
}
else
{
double ascent = firstLine->m_dBot - firstLine->m_dTopWithMaxAscent;
double newAscent = ascent * paragraph->m_dLineHeight / firstLine_height;
double offset = ascent - newAscent;
paragraph->m_dTop += offset;
paragraph->m_dBot += offset;
}
// setting TextAlignmentType
if (paragraph->m_arTextLines.size() > 1)
{
@ -1922,6 +1981,8 @@ namespace NSDocxRenderer
{
if (IsHorizontalLineBetween(text_lines[index], text_lines[index + 1]))
ar_delims[index] = true;
if (IsTextLineBetween(text_lines[index], text_lines[index + 1]))
ar_delims[index] = true;
}
// на основе ar_delims разбиваем на параграфы
@ -2555,9 +2616,9 @@ namespace NSDocxRenderer
pParagraph->m_arTextLines.push_back(pLine);
pParagraph->m_dLeft = pLine->m_dLeft;
pParagraph->m_dTop = pLine->m_dTopWithMaxAscent;
pParagraph->m_dBot = pLine->m_dBot + (pLine->m_dTopWithMaxAscent - pLine->m_dTop);
pParagraph->m_dBot = pLine->m_dBotWithMaxDescent;
pParagraph->m_dWidth = pLine->m_dWidth;
pParagraph->m_dHeight = pLine->m_dHeight;
pParagraph->m_dHeight = pLine->m_dBotWithMaxDescent - pLine->m_dTopWithMaxAscent;
pParagraph->m_dRight = pLine->m_dRight;
pParagraph->m_dLineHeight = pParagraph->m_dHeight;
pParagraph->m_nOrder = pLine->m_nOrder;
@ -2574,11 +2635,11 @@ namespace NSDocxRenderer
pShape->m_eType = CShape::eShapeType::stTextBox;
pShape->m_dLeft = pParagraph->m_dLeft;
pShape->m_dRight = pParagraph->m_dRight * 1.025;
pShape->m_dTop = pParagraph->m_dTop;
pShape->m_dBot = pParagraph->m_dBot;
pShape->m_dWidth = pParagraph->m_dWidth;
pShape->m_dWidth = pShape->m_dRight - pShape->m_dLeft;
pShape->m_dHeight = pParagraph->m_dHeight;
pShape->m_dRight = pParagraph->m_dRight;
pShape->m_nOrder = pParagraph->m_nOrder;
pShape->m_bIsBehindDoc = false;
@ -2590,11 +2651,12 @@ namespace NSDocxRenderer
auto pShape = std::make_shared<CShape>();
pShape->m_dLeft = pParagraph->m_dLeft;
pShape->m_dTop = pParagraph->m_dTop;
pShape->m_dRight = pParagraph->m_dRight;
if (pParagraph->m_arTextLines.size() == 1) pShape->m_dRight *= 1.025;
pShape->m_dTop = pParagraph->m_dTop;
pShape->m_dBot = pParagraph->m_dBot;
pShape->m_dHeight = pParagraph->m_dHeight;
pShape->m_dWidth = pParagraph->m_dWidth;
pShape->m_dWidth = pShape->m_dRight - pShape->m_dLeft;
pShape->m_nOrder = pParagraph->m_nOrder;
if (pParagraph->m_bIsNeedFirstLineIndent && pParagraph->m_dFirstLine < 0)

View File

@ -194,9 +194,11 @@ namespace NSDocxRenderer
bool IsVerticalLineBetween(text_line_ptr_t pFirst, text_line_ptr_t pSecond) const noexcept;
bool IsHorizontalLineBetween(text_line_ptr_t pFirst, text_line_ptr_t pSecond) const noexcept;
bool IsTextLineBetween(text_line_ptr_t pFirst, text_line_ptr_t pSecond) const noexcept;
bool IsVerticalLineTrough(base_item_ptr_t pFirst) const noexcept;
bool IsHorizontalLineTrough(base_item_ptr_t pFirst) const noexcept;
bool IsTextLineTrough(base_item_ptr_t pFirst) const noexcept;
void ToXml(NSStringUtils::CStringBuilder& oWriter) const noexcept;
void WriteSectionToFile(bool bLastPage, NSStringUtils::CStringBuilder& oWriter) const noexcept;
@ -231,6 +233,8 @@ namespace NSDocxRenderer
std::vector<shape_ptr_t> m_arLuminosityShapes;
std::vector<shape_ptr_t> m_arOneColorGradientShape;
long m_lLastType = 0;
size_t m_nCurrentOrder = 0;
};
}

View File

@ -178,7 +178,10 @@ namespace NSDocxRenderer
}
bool CBaseItem::IsEqual(double dTop, double dBot, double dLeft, double dRight) const noexcept
{
return m_dLeft == dLeft && m_dTop == dTop && m_dBot == dBot && m_dRight == dRight;
return fabs(m_dLeft - dLeft) < c_dGRAPHICS_ERROR_MM &&
fabs(m_dTop - dTop) < c_dGRAPHICS_ERROR_MM &&
fabs(m_dBot - dBot) < c_dGRAPHICS_ERROR_MM &&
fabs(m_dRight - dRight) < c_dGRAPHICS_ERROR_MM;
}
bool CBaseItem::operator==(const CBaseItem& other)
{

View File

@ -92,6 +92,7 @@ namespace NSDocxRenderer
m_arOriginLefts[i] = rCont.m_arOriginLefts[i];
m_bFontSubstitution = rCont.m_bFontSubstitution;
m_dSpacing = rCont.m_dSpacing;
return *this;
}
@ -100,7 +101,6 @@ namespace NSDocxRenderer
{
if (!m_pFontStyle->wsFontName.empty() && !m_oText.empty())
{
// нужно перемерять...
if (m_oSelectedFont.Path.empty())
m_pManager->LoadFontByName(m_oSelectedFont);
else
@ -121,6 +121,7 @@ namespace NSDocxRenderer
m_oSelectedSizes.dWidth = dBoxWidth;
m_oSelectedSizes.dHeight = dBoxHeight;
m_dSpacing = (m_dWidth - m_oSelectedSizes.dWidth) / (m_oText.length());
}
}
@ -207,34 +208,34 @@ namespace NSDocxRenderer
return eVerticalCrossingType::vctCurrentInsideNext;
else if (this_top < other_top && this_bot > other_bot)
return eVerticalCrossingType::vctCurrentOutsideNext;
return eVerticalCrossingType::vctCurrentOutsideNext;
else if (this_top < other_top && this_bot < other_bot &&
(this_bot >= other_top || fabs(this_bot - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
return eVerticalCrossingType::vctCurrentAboveNext;
else if (this_top < other_top && this_bot < other_bot && this_bot > other_top &&
this_bot - other_top > c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctCurrentAboveNext;
else if (this_top > other_top && this_bot > other_bot &&
(this_top <= other_bot || fabs(this_top - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
return eVerticalCrossingType::vctCurrentBelowNext;
else if (this_top > other_top && this_bot > other_bot && this_top < other_bot &&
other_bot - this_top > c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctCurrentBelowNext;
else if (this_top == other_top && this_bot == other_bot)
return eVerticalCrossingType::vctDublicate;
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctTopBorderMatch;
return eVerticalCrossingType::vctTopBorderMatch;
else if (fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctBottomBorderMatch;
return eVerticalCrossingType::vctBottomBorderMatch;
else if (this_bot < other_top)
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
else if (other_top - this_bot > -c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
else if (this_top > other_bot)
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
else if (this_top - other_bot > -c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
else
return eVerticalCrossingType::vctUnknown;
@ -258,18 +259,11 @@ namespace NSDocxRenderer
LONG lCalculatedSpacing = 0;
// mm to points * 20
if (!m_oText.empty())
{
double dSpacing = (m_dWidth - m_oSelectedSizes.dWidth) / (m_oText.length());
dSpacing *= c_dMMToDx;
lCalculatedSpacing = static_cast<LONG>(m_dSpacing * c_dMMToDx);
//mm to points * 20
lCalculatedSpacing = static_cast<LONG>(dSpacing);
}
// принудительно уменьшаем spacing чтобы текстовые линии не выходили за правую границу
lCalculatedSpacing -= 1;
if (lCalculatedSpacing != 0)
{
oWriter.WriteString(L"<w:spacing w:val=\"");
@ -396,14 +390,7 @@ namespace NSDocxRenderer
LONG lCalculatedSpacing = 0;
if (!m_oText.empty())
{
double dSpacing = (m_dWidth - m_oSelectedSizes.dWidth) / (m_oText.length());
dSpacing *= c_dMMToPt * 100;
lCalculatedSpacing = static_cast<LONG>(dSpacing);
}
// принудительно уменьшаем spacing чтобы текстовые линии не выходили за правую границу
lCalculatedSpacing -= 15;
lCalculatedSpacing = static_cast<LONG>(m_dSpacing * c_dMMToPt * 100);
oWriter.WriteString(L" spc=\"");
oWriter.AddInt(lCalculatedSpacing);
@ -541,12 +528,7 @@ namespace NSDocxRenderer
{
int lCalculatedSpacing = 0;
if (!m_oText.empty())
{
double dSpacing = (m_dWidth - m_oSelectedSizes.dWidth) / (m_oText.length());
dSpacing *= c_dMMToPt * 100;
lCalculatedSpacing = static_cast<LONG>(dSpacing);
}
lCalculatedSpacing -= 15;
lCalculatedSpacing = static_cast<LONG>(m_dSpacing * c_dMMToPt * 100);
const BYTE kPARRUN_TYPE_RUN = 1;
oWriter.StartRecord(kPARRUN_TYPE_RUN);
@ -573,6 +555,9 @@ namespace NSDocxRenderer
std::wstring origin_lefts{};
for (auto& l : m_arOriginLefts)
origin_lefts += std::to_wstring(static_cast<int>(l * c_dMMToEMU)) + L";";
// add offset for last symbol
if (!m_arSymWidths.empty())
origin_lefts += std::to_wstring(static_cast<int>((m_arOriginLefts.back() + m_arSymWidths.back()) * c_dMMToEMU)) + L";";
oWriter.WriteBYTE(5); oWriter.WriteStringUtf16(origin_lefts); // Origin lefts
oWriter.WriteBYTE(6); oWriter.WriteBool(m_bFontSubstitution); // Font Substitution (just pass from pdf)
@ -676,6 +661,7 @@ namespace NSDocxRenderer
bool CContText::IsEqual(const CContText *pCont) const noexcept
{
bool bIf0 = IsFontsEqual(m_oSelectedFont, pCont->m_oSelectedFont);
bool bIf1 = m_pFontStyle->wsFontStyleId == pCont->m_pFontStyle->wsFontStyleId;
bool bIf2 = m_bIsStrikeoutPresent == pCont->m_bIsStrikeoutPresent;
bool bIf3 = m_bIsDoubleStrikeout == pCont->m_bIsDoubleStrikeout;
@ -692,7 +678,7 @@ namespace NSDocxRenderer
bool bIf14 = m_eVertAlignType == eVertAlignType::vatUnknown && pCont->m_eVertAlignType == eVertAlignType::vatBase;
bool bIf15 = m_eVertAlignType == eVertAlignType::vatBase && pCont->m_eVertAlignType == eVertAlignType::vatUnknown;
return (bIf1 && bIf2 && bIf3 && bIf4 && bIf5 && bIf6 && bIf7 &&
return (bIf0 && bIf1 && bIf2 && bIf3 && bIf4 && bIf5 && bIf6 && bIf7 &&
bIf8 && bIf9 && bIf10 && bIf11 && bIf12 && (bIf13 || bIf14 || bIf15));
}
@ -754,14 +740,14 @@ namespace NSDocxRenderer
continue;
}
m_arSymWidths.push_back(w);
m_dWidth += w;
m_oText += oText.at(i);
m_arOriginLefts.push_back(arOriginLefts[i]);
m_dRight = arOriginLefts[i] + w;
if (!arGids.empty() && m_bCollectMetaInfo)
m_arGids.push_back(arGids[i]);
}
m_dRight = m_dLeft + m_dWidth;
m_dWidth = m_dRight - m_dLeft;
}
void CContText::AddTextFront(const NSStringUtils::CStringUTF32& oText,
const std::vector<double>& arSymWidths,
@ -770,18 +756,11 @@ namespace NSDocxRenderer
{
m_oText = oText + m_oText;
double addtitional_width = 0;
for (auto& w : arSymWidths)
addtitional_width += w;
auto ar_sym_w = m_arSymWidths;
m_arSymWidths = arSymWidths;
for (auto& w : ar_sym_w)
m_arSymWidths.push_back(w);
m_dWidth += addtitional_width;
m_dLeft = m_dRight - m_dWidth;
if (!arGids.empty() && m_bCollectMetaInfo)
{
auto ar_gids = m_arGids;
@ -794,6 +773,9 @@ namespace NSDocxRenderer
m_arOriginLefts = arOriginLefts;
for (auto& left : ar_lefts)
m_arOriginLefts.push_back(left);
m_dLeft = m_arOriginLefts.back();
m_dWidth = m_dRight - m_dLeft;
}
void CContText::SetText(const NSStringUtils::CStringUTF32& oText,
const std::vector<double>& arSymWidths,
@ -834,8 +816,8 @@ namespace NSDocxRenderer
m_arGids.push_back(nGid);
}
}
m_dWidth += dWidth;
m_dRight = m_dLeft + m_dWidth;
m_dRight = dLeft + dWidth;
m_dWidth = m_dRight - m_dLeft;
}
void CContText::AddSymFront(uint32_t cSym, double dWidth, double dLeft, unsigned int nGid)
{
@ -844,7 +826,7 @@ namespace NSDocxRenderer
text += m_oText;
m_oText = text;
m_dLeft -= dWidth;
m_dLeft = dLeft;
m_dWidth = m_dRight - m_dLeft;
m_arSymWidths.insert(m_arSymWidths.begin(), dWidth);
@ -878,11 +860,16 @@ namespace NSDocxRenderer
void CContText::RemoveLastSym()
{
m_oText = m_oText.substr(0, m_oText.length() - 1);
m_dWidth -= m_arSymWidths[m_arSymWidths.size() - 1];
m_dRight = m_dLeft + m_dWidth;
m_arSymWidths.resize(m_arSymWidths.size() - 1);
m_arOriginLefts.resize(m_arOriginLefts.size() - 1);
if (!m_arOriginLefts.empty())
m_dRight = m_arOriginLefts.back() + m_arSymWidths.back();
else
m_dRight = m_dLeft;
m_dWidth = m_dRight - m_dLeft;
if (!m_arGids.empty() && m_bCollectMetaInfo)
m_arGids.resize(m_arGids.size() - 1);
}
@ -899,7 +886,7 @@ namespace NSDocxRenderer
{
return m_arSymWidths;
}
const std::vector<double> CContText::GetSymLefts() const noexcept
const std::vector<double>& CContText::GetSymLefts() const noexcept
{
return m_arOriginLefts;
}
@ -911,12 +898,12 @@ namespace NSDocxRenderer
eHorizontalCrossingType eHType)
{
//Условие пересечения по вертикали
bool bIf1 = eVType == eVerticalCrossingType::vctCurrentAboveNext; //текущий cont выше
bool bIf2 = eVType == eVerticalCrossingType::vctCurrentBelowNext; //текущий cont ниже
bool bIf1 = eVType == eVerticalCrossingType::vctCurrentAboveNext;
bool bIf2 = eVType == eVerticalCrossingType::vctCurrentBelowNext;
//Условие пересечения по горизонтали
bool bIf3 = eHType == eHorizontalCrossingType::hctCurrentLeftOfNext; //текущий cont левее
bool bIf4 = eHType == eHorizontalCrossingType::hctCurrentRightOfNext; //текущий cont правее
bool bIf3 = eHType == eHorizontalCrossingType::hctCurrentLeftOfNext;
bool bIf4 = eHType == eHorizontalCrossingType::hctCurrentRightOfNext;
//Размеры шрифта и текст должны бать одинаковыми
bool bIf5 = pFirstCont->m_pFontStyle->dFontSize == pSecondCont->m_pFontStyle->dFontSize;
@ -932,9 +919,7 @@ namespace NSDocxRenderer
bool bIf11 = pFirstCont->m_pFontStyle->oBrush.Color1 == c_iGreyColor2;
bool bIf12 = pSecondCont->m_pFontStyle->oBrush.Color1 == c_iGreyColor2;
//note Каждый символ с Emboss или Engrave разбиваются на 3 символа с разными цветами
//note Логика подобрана для конкретного примера - возможно нужно будет ее обобщить.
//todo существует проблема неправильного определением FontEffects с физически пересекаемыми строчками - файл generaltest.pdf p.14
// каждый символ с Emboss или Engrave разбиваются на 3 символа с разными цветами
if (bIf5 && bIf6)
{
if (bIf12 && pFirstCont->m_bIsEmbossPresent)
@ -994,8 +979,10 @@ namespace NSDocxRenderer
eHorizontalCrossingType eHType)
{
double first_height = pFirstCont->m_dBotWithDescent - pFirstCont->m_dTopWithAscent;
bool bIf1 = eVType == eVerticalCrossingType::vctCurrentAboveNext ||
eVType == eVerticalCrossingType::vctCurrentInsideNext;
eVType == eVerticalCrossingType::vctCurrentInsideNext &&
pSecondCont->m_dBot - pFirstCont->m_dBot > first_height * 0.2;
bool bIf2 = eVType == eVerticalCrossingType::vctCurrentBelowNext;
@ -1107,6 +1094,19 @@ namespace NSDocxRenderer
{
return 0x0300 <= cSym && 0x036F >= cSym;
}
bool CContText::IsFontsEqual(const NSStructures::CFont& oFont1, const NSStructures::CFont& oFont2)
{
bool res = oFont1.Name == oFont2.Name;
res = res && oFont1.Path == oFont2.Path;
res = res && oFont1.FaceIndex == oFont2.FaceIndex;
res = res && oFont1.StringGID == oFont2.StringGID;
res = res && oFont1.Size == oFont2.Size;
res = res && oFont1.Bold == oFont2.Bold;
res = res && oFont1.Italic == oFont2.Italic;
res = res && oFont1.Underline == oFont2.Underline;
res = res && oFont1.Strikeout == oFont2.Strikeout;
return res;
}
double CContText::CalculateSpace() const noexcept
{
@ -1174,22 +1174,25 @@ namespace NSDocxRenderer
oText.length() == 1 && CContText::IsUnicodeDiacriticalMark(oText.at(0))) &&
bFontSubstitution == m_pCurrCont->m_bFontSubstitution)
{
double avg_width = dWidth / oText.length();
for (size_t i = 0; i < oText.length(); ++i)
if (oText.at(i) == c_SPACE_SYM)
m_pCurrCont->m_pFontStyle->UpdateAvgSpaceWidth(avg_width);
double avg_space_width = m_pCurrCont->m_pFontStyle->GetAvgSpaceWidth();
double space_width =
avg_space_width != 0.0 ?
avg_space_width * c_dAVERAGE_SPACE_WIDTH_COEF :
m_pCurrCont->CalculateSpace() * c_dSPACE_WIDTH_COEF;
double spacing = dLeft - m_dPrevRight;
bool is_added = false;
bool diff_spacing = false;
// set spacing at the second symbol
if (m_pCurrCont->GetLength() == 1)
m_pCurrCont->m_dSpacing = spacing;
if (fabs(spacing - m_pCurrCont->m_dSpacing) > c_dTHE_SAME_SPACING_ERROR)
diff_spacing = true;
// some_text+more_text
if (fabs(m_pCurrCont->m_dRight - dLeft) < space_width && dRight > m_pCurrCont->m_dRight)
if (!diff_spacing && fabs(m_pCurrCont->m_dRight - dLeft) < space_width && dRight > m_pCurrCont->m_dRight)
{
double left_avg_width = (dRight - m_pCurrCont->m_dRight) / oText.length();
std::vector<double> ar_widths;
@ -1201,7 +1204,7 @@ namespace NSDocxRenderer
}
// more_text+some_text
else if (fabs(m_pCurrCont->m_dLeft - dRight) < space_width && dLeft < m_pCurrCont->m_dLeft)
else if (diff_spacing && fabs(m_pCurrCont->m_dLeft - dRight) < space_width && dLeft < m_pCurrCont->m_dLeft)
{
double right_avg_width = (m_pCurrCont->m_dLeft - dLeft) / oText.length();
std::vector<double> ar_widths;
@ -1219,6 +1222,7 @@ namespace NSDocxRenderer
m_pCurrCont->m_dHeight = m_pCurrCont->m_dBot - m_pCurrCont->m_dTop;
m_pCurrCont->m_dWidth = m_pCurrCont->m_dRight - m_pCurrCont->m_dLeft;
m_pCurrCont->m_nOrder = nOrder;
m_dPrevRight = dRight;
return;
}
}
@ -1242,14 +1246,14 @@ namespace NSDocxRenderer
m_pFontSelector->IsSelectedItalic(),
m_pFontSelector->IsSelectedBold() || bForcedBold);
// just in case if oText contains more than 1 symbol
std::vector<double> ar_widths;
double avg_width = abs(dRight - dLeft) / oText.length();
double avg_width = dWidth / oText.length();
for (size_t i = 0; i < oText.length(); ++i)
if (oText.at(i) == c_SPACE_SYM)
pCont->m_pFontStyle->UpdateAvgSpaceWidth(avg_width);
std::vector<double> ar_widths;
for (size_t i = 0; i < oText.length(); ++i)
{
if (oText.at(i) == c_SPACE_SYM) pCont->m_pFontStyle->UpdateAvgSpaceWidth(avg_width);
ar_widths.push_back(avg_width);
}
pCont->m_bCollectMetaInfo = bCollectMetaInfo;
pCont->SetText(oText, ar_widths, std::move(gids), std::move(origin_lefts));
@ -1258,12 +1262,11 @@ namespace NSDocxRenderer
pCont->m_dWidth = dWidth;
pCont->m_dRight = dRight;
double font_size = oFont.Size;
double em_height = oMetrics.dEmHeight;
double ratio = font_size / em_height * c_dPtToMM;
double ascent = pFontManager->GetFontAscent();
double descent = pFontManager->GetFontDescent();
pCont->m_dTopWithAscent = pCont->m_dBot - (oMetrics.dAscent * ratio);
pCont->m_dBotWithDescent = pCont->m_dBot + (oMetrics.dDescent * ratio);
pCont->m_dTopWithAscent = pCont->m_dBot - ascent;
pCont->m_dBotWithDescent = pCont->m_dBot + fabs(descent);
pCont->m_dSpaceWidthMM = pFontManager->GetSpaceWidthMM();
pCont->m_wsOriginFontName = oFont.Name;
@ -1299,6 +1302,7 @@ namespace NSDocxRenderer
m_pCurrCont = pCont;
m_oPrevFont = oFont;
m_oPrevBrush = oBrush;
m_dPrevRight = dRight;
}
void CContTextBuilder::NullCurrCont()

View File

@ -67,6 +67,7 @@ namespace NSDocxRenderer
// sizes
double m_dSpaceWidthMM{0};
double m_dSpacing{0};
CSelectedSizes m_oSelectedSizes{};
double m_dTopWithAscent{0};
@ -121,7 +122,7 @@ namespace NSDocxRenderer
const NSStringUtils::CStringUTF32& GetText() const noexcept;
const std::vector<double>& GetSymWidths() const noexcept;
const std::vector<double> GetSymLefts() const noexcept;
const std::vector<double>& GetSymLefts() const noexcept;
std::shared_ptr<CContText> Split(size_t index);
std::shared_ptr<CContText> Split(double dLeft);
@ -158,6 +159,8 @@ namespace NSDocxRenderer
static bool IsUnicodeSymbol(uint32_t symbol);
static bool IsUnicodeDiacriticalMark(uint32_t symbol);
static bool IsFontsEqual(const NSStructures::CFont& oFont1, const NSStructures::CFont& oFont2);
private:
NSStringUtils::CStringUTF32 m_oText{};
std::vector<double> m_arSymWidths{};
@ -198,8 +201,8 @@ namespace NSDocxRenderer
void NullCurrCont();
void Clear();
private:
std::vector<cont_ptr_t> m_arConts;
std::vector<cont_ptr_t> m_arDiacs;
@ -210,5 +213,6 @@ namespace NSDocxRenderer
CFontStyleManager* m_pFontStyleManager {nullptr};
CFontSelector* m_pFontSelector {nullptr};
double m_dPrevRight = 0;
};
}

View File

@ -1343,7 +1343,7 @@ namespace NSDocxRenderer
// WriteRecord WriteBodyPr
oWriter.StartRecord(0);
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
oWriter.WriteBYTE(1); oWriter.WriteBYTE(1); // anchor
oWriter.WriteBYTE(1); oWriter.WriteBYTE(4); // anchor
oWriter.WriteBYTE(2); oWriter.WriteBool(false); // anchorCtr
oWriter.WriteBYTE(3); oWriter.AddInt(0); // bIns
oWriter.WriteBYTE(4); oWriter.WriteBool(true); // compatLnSpc

View File

@ -66,6 +66,8 @@ namespace NSDocxRenderer
std::sort(m_arConts.begin(), m_arConts.end(), [] (const cont_ptr_t& a, const cont_ptr_t& b) {
if (!a) return false;
if (!b) return true;
if (fabs(a->m_dLeft - b->m_dLeft) < c_dTHE_SAME_STRING_X_PRECISION_MM)
return a->m_dRight < b->m_dRight;
return a->m_dLeft < b->m_dLeft;
});
@ -194,16 +196,20 @@ namespace NSDocxRenderer
continue;
const auto& text = cont->GetText();
auto ar_widths = cont->GetSymWidths();
auto ar_lefts = cont->GetSymLefts();
auto ar_width = cont->GetSymWidths();
for (size_t i = 0; i < text.length(); ++i)
{
if (text.at(i) == c_SPACE_SYM)
{
m_dFirstWordWidth = width;
if (i == 0)
m_dFirstWordWidth = cont->m_dLeft - m_dLeft;
else
m_dFirstWordWidth = ar_lefts[i - 1] - m_dLeft + ar_width[i - 1];
is_done = true;
break;
}
width += ar_widths[i];
}
if (is_done)
break;
@ -239,15 +245,15 @@ namespace NSDocxRenderer
return eVerticalCrossingType::vctCurrentInsideNext;
else if (this_top < other_top && this_bot > other_bot)
return eVerticalCrossingType::vctCurrentOutsideNext;
return eVerticalCrossingType::vctCurrentOutsideNext;
else if (this_top < other_top && this_bot < other_bot &&
(this_bot >= other_top || fabs(this_bot - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
return eVerticalCrossingType::vctCurrentAboveNext;
else if (this_top < other_top && this_bot < other_bot && this_bot > other_top &&
this_bot - other_top > c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctCurrentAboveNext;
else if (this_top > other_top && this_bot > other_bot &&
(this_top <= other_bot || fabs(this_top - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
return eVerticalCrossingType::vctCurrentBelowNext;
else if (this_top > other_top && this_bot > other_bot && this_top < other_bot &&
other_bot - this_top > c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctCurrentBelowNext;
else if (this_top == other_top && this_bot == other_bot &&
m_dLeft == pLine->m_dLeft && m_dRight == pLine->m_dRight)
@ -255,31 +261,33 @@ namespace NSDocxRenderer
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctTopBorderMatch;
return eVerticalCrossingType::vctTopBorderMatch;
else if (fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
return eVerticalCrossingType::vctBottomBorderMatch;
return eVerticalCrossingType::vctBottomBorderMatch;
else if (this_bot < other_top)
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
else if (other_top - this_bot > -c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
else if (this_top > other_bot)
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
else if (this_top - other_bot > -c_dOVERLAP_TEXT_LINE_ERROR_MM)
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
else
return eVerticalCrossingType::vctUnknown;
return eVerticalCrossingType::vctUnknown;
}
void CTextLine::RecalcWithNewItem(const CContText* pCont)
{
CBaseItem::RecalcWithNewItem(pCont);
if (m_dTopWithMaxAscent == 0.0) m_dTopWithMaxAscent = pCont->m_dTopWithAscent;
else m_dTopWithMaxAscent = std::min(m_dTopWithMaxAscent, pCont->m_dTopWithAscent);
m_dBotWithMaxDescent = std::max(m_dBotWithMaxDescent, pCont->m_dBotWithDescent);
if (!pCont->IsOnlySpaces())
{
if (m_dTopWithMaxAscent == 0.0) m_dTopWithMaxAscent = pCont->m_dTopWithAscent;
else m_dTopWithMaxAscent = std::min(m_dTopWithMaxAscent, pCont->m_dTopWithAscent);
m_dBotWithMaxDescent = std::max(m_dBotWithMaxDescent, pCont->m_dBotWithDescent);
}
}
void CTextLine::SetVertAlignType(const eVertAlignType& oType)

View File

@ -581,6 +581,16 @@ namespace NSDocxRenderer
{
return c_dPtToMM * (m_oFontMetrics.dLineSpacing * m_oFont.Size) / m_oFontMetrics.dEmHeight;
}
double CFontManager::GetFontAscent() const
{
//double tmp = m_oFontMetrics.dAscent;
double tmp = m_oFontMetrics.dLineSpacing - fabs(m_oFontMetrics.dDescent);
return c_dPtToMM * (tmp * m_oFont.Size) / m_oFontMetrics.dEmHeight;
}
double CFontManager::GetFontDescent() const
{
return c_dPtToMM * (m_oFontMetrics.dDescent * m_oFont.Size) / m_oFontMetrics.dEmHeight;
}
double CFontManager::GetSpaceWidthMM() const
{
double dSpaceWidthMM = 0.0;

View File

@ -124,6 +124,9 @@ namespace NSDocxRenderer
const CFontMetrics& GetFontMetrics() const noexcept;
double GetFontHeight() const;
double GetFontAscent() const;
double GetFontDescent() const;
double GetSpaceWidthMM() const;
void SetStringGid(const LONG& lGid);

View File

@ -24,9 +24,11 @@ constexpr double c_dPtToEMU = 12700.0;
constexpr double c_dDegreeToAngle = 60000.0;
const double c_dSTANDART_STRING_HEIGHT_MM = 4.2333333333333334;
const double c_dTHE_SAME_STRING_Y_PRECISION_MM = 0.02;
const double c_dTHE_SAME_STRING_X_PRECISION_MM = 0.02;
const double c_dTHE_SAME_STRING_Y_PRECISION_MM = 0.015;
const double c_dTHE_SAME_STRING_X_PRECISION_MM = 0.03;
const double c_dTHE_SAME_SPACING_ERROR = 0.1;
const double c_dLINE_DISTANCE_ERROR_MM = 0.3;
const double c_dOVERLAP_TEXT_LINE_ERROR_MM = 0.5;
const double c_dERROR_OF_PARAGRAPH_BORDERS_MM = 1.0;
const double c_dCENTER_POSITION_ERROR_MM = 1.5;
const double c_dTHE_STRING_X_PRECISION_MM = 0.5;

View File

@ -288,7 +288,8 @@ struct CTextSettings
CTextSettings(const CTextSettings& oTS) :
bBdo(oTS.bBdo), bPre(oTS.bPre), bQ(oTS.bQ), bAddSpaces(oTS.bAddSpaces), bMergeText(oTS.bMergeText),
nLi(oTS.nLi), bNumberingLi(oTS.bNumberingLi), sPStyle(oTS.sPStyle), eTextMode(oTS.eTextMode)
nLi(oTS.nLi), bNumberingLi(oTS.bNumberingLi), sPStyle(oTS.sPStyle), eTextMode(oTS.eTextMode),
oAdditionalStyle(oTS.oAdditionalStyle)
{}
void AddPStyle(const std::wstring& wsStyle)
@ -331,12 +332,12 @@ void WriteEmptyParagraph(NSStringUtils::CStringBuilder* pXml, bool bVahish = fal
if (!bInP)
pXml->WriteString(L"<w:p><w:pPr>");
pXml->WriteString(L"<w:r><w:rPr><w:rFonts w:eastAsia=\"Times New Roman\"/>");
pXml->WriteString(L"<w:rPr><w:rFonts w:eastAsia=\"Times New Roman\"/>");
if (bVahish)
pXml->WriteString(L"<w:vanish/>");
pXml->WriteString(L"<w:sz w:val=\"2\"/><w:szCs w:val=\"2\"/><w:vanish/>");
pXml->WriteString(L"</w:rPr></w:r>");
pXml->WriteString(L"</w:rPr>");
if (!bInP)
pXml->WriteString(L"</w:pPr></w:p>");
@ -1404,6 +1405,123 @@ void ReplaceSpaces(std::wstring& wsValue)
}
}
std::wstring StandardizeHeaderId(const std::wstring& header)
{
if (header.empty())
return std::wstring();
std::wstring result;
result.reserve(header.size());
// Флаг, указывающий, был ли предыдущий символ дефисом
bool prevWasHyphen = false;
bool inWhitespaceSequence = false;
wchar_t lowerC;
for (wchar_t c : header)
{
// Приведение к нижнему регистру
lowerC = std::tolower(c);
// Проверяем, является ли символ буквой или цифрой
if (std::iswalnum(lowerC))
{
result.push_back(lowerC);
prevWasHyphen = false;
inWhitespaceSequence = false;
}
// Проверяем, является ли символ пробельным (пробел, табуляция и т.д.)
else if (std::iswspace(lowerC))
{
// Заменяем последовательности пробельных символов на один дефис
if (!inWhitespaceSequence && !result.empty())
{
result.push_back(L'-');
inWhitespaceSequence = true;
}
}
// Проверяем, является ли символ дефисом или подчеркиванием
else if (c == L'-' || c == L'_')
{
// Добавляем дефис, если предыдущий символ не был дефисом
if (!prevWasHyphen && !result.empty())
{
result.push_back(L'-');
prevWasHyphen = true;
}
inWhitespaceSequence = false;
}
// Все остальные символы (знаки препинания) пропускаем
// Но если это буква в Unicode, мы можем её обработать
else if (std::iswalpha(lowerC))
{
// Для Unicode-символов, которые являются буквами
result.push_back(lowerC);
prevWasHyphen = false;
inWhitespaceSequence = false;
}
// Остальные символы игнорируем
}
// Удаляем дефисы в начале и конце
size_t start = 0;
size_t end = result.length();
while (start < end && result[start] == L'-')
++start;
while (end > start && result[end - 1] == L'-')
--end;
// Удаляем последовательные дефисы
std::wstring finalResult;
finalResult.reserve(end - start);
bool lastWasHyphen = false;
for (size_t i = start; i < end; i++)
{
if (result[i] == L'-')
{
if (!lastWasHyphen)
{
finalResult.push_back(L'-');
lastWasHyphen = true;
}
}
else
{
finalResult.push_back(result[i]);
lastWasHyphen = false;
}
}
return finalResult;
}
bool ElementInHeader(const std::vector<NSCSS::CNode> arSelsectors)
{
for (const NSCSS::CNode& oNode : arSelsectors)
{
if (2 != oNode.m_wsName.length() && L'h' != oNode.m_wsName[0])
continue;
switch (GetHtmlTag(oNode.m_wsName))
{
case HTML_TAG(H1):
case HTML_TAG(H2):
case HTML_TAG(H3):
case HTML_TAG(H4):
case HTML_TAG(H5):
case HTML_TAG(H6):
return true;
default:
continue;
}
}
return false;
}
std::wstring EncodeXmlString(const std::wstring& s)
{
std::wstring sRes = s;
@ -1445,6 +1563,11 @@ bool CanUseThisPath(const std::wstring& wsPath, const std::wstring& wsSrcPath, c
return true;
}
bool UnreadableNode(const std::wstring& wsNodeName)
{
return L"head" == wsNodeName || L"meta" == wsNodeName || L"style" == wsNodeName;
}
class CHtmlFile2_Private
{
public:
@ -1467,6 +1590,9 @@ private:
int m_nId; // ID остальные элементы
int m_nShapeId; // Id shape's
using anchors_map = std::map<std::wstring, std::wstring>;
anchors_map m_mAnchors; // Map якорей с индивидуальными id
NSStringUtils::CStringBuilder m_oStylesXml; // styles.xml
NSStringUtils::CStringBuilder m_oDocXmlRels; // document.xml.rels
NSStringUtils::CStringBuilder m_oNoteXmlRels; // footnotes.xml.rels
@ -1486,8 +1612,10 @@ private:
bool m_bBanUpdatePageData; // Запретить обновление данных о странице?
HtmlTag m_eLastElement;
TState()
: m_bInP(false), m_bInR(false), m_bInT(false), m_bWasPStyle(false), m_bWasSpace(true), m_bInHyperlink(false), m_bBanUpdatePageData(false)
: m_bInP(false), m_bInR(false), m_bInT(false), m_bWasPStyle(false), m_bWasSpace(true), m_bInHyperlink(false), m_bBanUpdatePageData(false), m_eLastElement(HTML_TAG(UNKNOWN))
{}
} m_oState;
@ -2178,10 +2306,18 @@ private:
m_oState.m_bWasSpace = true;
}
void WriteBookmark(NSStringUtils::CStringBuilder* pXml, const std::wstring& wsId)
std::wstring AddAnchor(const std::wstring& wsAnchorValue)
{
const std::wstring wsAnchorId{L"anchor-" + std::to_wstring(m_mAnchors.size() + 1)};
m_mAnchors[wsAnchorValue] = wsAnchorId;
return wsAnchorId;
}
std::wstring WriteBookmark(NSStringUtils::CStringBuilder* pXml, const std::wstring& wsId)
{
if (NULL == pXml)
return;
return std::wstring();
const std::wstring sCrossId = std::to_wstring(m_mBookmarks.size() + 1);
std::wstring sName;
@ -2190,7 +2326,13 @@ private:
sName = wsId + L"_" + std::to_wstring(++m_mBookmarks[wsId]);
else
{
sName = wsId;
const anchors_map::const_iterator itFound{m_mAnchors.find(wsId)};
if (m_mAnchors.end() != itFound)
sName = itFound->second;
else
sName = AddAnchor(wsId);
m_mBookmarks.insert({wsId, 1});
}
@ -2198,8 +2340,20 @@ private:
pXml->WriteString(sCrossId);
pXml->WriteString(L"\" w:name=\"");
pXml->WriteEncodeXmlString(sName);
pXml->WriteString(L"\"/><w:bookmarkEnd w:id=\"");
pXml->WriteString(sCrossId);
pXml->WriteString(L"\"/>");
return sCrossId;
}
void WriteEmptyBookmark(NSStringUtils::CStringBuilder* pXml, const std::wstring& wsId)
{
const std::wstring wsCrossId{WriteBookmark(pXml, wsId)};
if (wsCrossId.empty())
return;
pXml->WriteString(L"<w:bookmarkEnd w:id=\"");
pXml->WriteString(wsCrossId);
pXml->WriteString(L"\"/>");
}
@ -2279,7 +2433,7 @@ private:
else if(sName == L"id")
{
oNode.m_wsId = EncodeXmlString(m_oLightReader.GetText());
WriteBookmark(oXml, oNode.m_wsId);
WriteEmptyBookmark(oXml, oNode.m_wsId);
if (!m_oStylesCalculator.HaveStylesById(oNode.m_wsId))
oNode.m_wsId.clear();
@ -2402,6 +2556,11 @@ private:
if (!bPre && sText.end() == std::find_if_not(sText.begin(), sText.end(), [](wchar_t wchChar){ return iswspace(wchChar) && 0xa0 != wchChar;}))
return false;
std::wstring wsHeaderId;
if (ElementInHeader(arSelectors))
wsHeaderId = StandardizeHeaderId(sText);
if(oTS.bBdo)
std::reverse(sText.begin(), sText.end());
@ -2418,6 +2577,11 @@ private:
WriteToStringBuilder(oPPr, *pXml);
std::wstring wsCrossId;
if (!wsHeaderId.empty())
WriteEmptyBookmark(pXml, wsHeaderId);
NSStringUtils::CStringBuilder oRPr;
std::wstring sRStyle;
@ -3066,11 +3230,10 @@ private:
bool readInside (NSStringUtils::CStringBuilder* oXml, std::vector<NSCSS::CNode>& sSelectors, CTextSettings& oTS, const std::wstring& sName)
{
//TODO:: обработать все варианты return'а
if(sName == L"#text")
return ReadText(oXml, sSelectors, oTS);
if (TagIsUnprocessed(sName))
if (UnreadableNode(sName) || TagIsUnprocessed(sName))
return false;
std::wstring sNote = GetSubClass(oXml, sSelectors);
@ -3378,7 +3541,12 @@ private:
}
if (HTML_TAG(DIV) != eHtmlTag && HTML_TAG(ASIDE) != eHtmlTag)
{
if (bResult)
m_oState.m_eLastElement = eHtmlTag;
m_oState.m_bBanUpdatePageData = true;
}
readNote(oXml, sSelectors, sNote);
sSelectors.pop_back();
@ -3755,6 +3923,9 @@ private:
if(m_oLightReader.IsEmptyNode())
return false;
if (HTML_TAG(TABLE) == m_oState.m_eLastElement)
WriteEmptyParagraph(oXml, true);
CTable oTable;
CTextSettings oTextSettings{oTS};
oTextSettings.sPStyle.clear();
@ -3871,7 +4042,6 @@ private:
oTable.Shorten();
oTable.CompleteTable();
oTable.ConvertToOOXML(*oXml);
WriteEmptyParagraph(oXml, true);
return true;
}
@ -3912,9 +4082,6 @@ private:
bool ReadListElement(NSStringUtils::CStringBuilder* oXml, std::vector<NSCSS::CNode>& arSelectors, CTextSettings& oTS)
{
if (OpenP(oXml))
wrP(oXml, arSelectors, oTS);
const bool bResult{readStream(oXml, arSelectors, oTS)};
CloseP(oXml, arSelectors);
@ -3927,8 +4094,6 @@ private:
if(m_oLightReader.IsEmptyNode())
return false;
GetSubClass(oXml, arSelectors);
CloseP(oXml, arSelectors);
CTextSettings oTSLi(oTS);
@ -3969,6 +4134,8 @@ private:
m_oNumberXml.WriteString(wsStart);
m_oNumberXml.WriteString(L"\"/><w:numFmt w:val=\"decimal\"/><w:isLgl w:val=\"false\"/><w:suff w:val=\"tab\"/><w:lvlText w:val=\"%9.\"/><w:lvlJc w:val=\"right\"/><w:pPr><w:ind w:left=\"6469\" w:hanging=\"180\"/></w:pPr></w:lvl></w:abstractNum>");
}
else
oTSLi.bNumberingLi = false;
CTextSettings oTSList{oTSLi};
@ -3990,7 +4157,6 @@ private:
}
CloseP(oXml, arSelectors);
arSelectors.pop_back();
return true;
}
@ -4158,12 +4324,28 @@ private:
if(bCross)
{
m_oState.m_bInHyperlink = true;
oXml->WriteString(L"<w:hyperlink w:tooltip=\"Current Document\" w:anchor=\"");
oXml->WriteString(L"<w:hyperlink w:anchor=\"");
size_t nSharp = sRef.find('#');
std::wstring wsAnchorValue;
if(nSharp == std::wstring::npos)
oXml->WriteString(NSFile::GetFileName(sRef));
wsAnchorValue = NSFile::GetFileName(sRef);
else
oXml->WriteEncodeXmlString(sRef.c_str() + nSharp + 1);
wsAnchorValue = (sRef.c_str() + nSharp + 1);
if (!wsAnchorValue.empty())
{
const anchors_map::iterator itFound = m_mAnchors.find(wsAnchorValue);
std::wstring wsAnchorId;
if (m_mAnchors.end() != itFound)
wsAnchorId = itFound->second;
else
wsAnchorId = AddAnchor(wsAnchorValue);
oXml->WriteEncodeXmlString(wsAnchorId);
}
}
// Внешняя ссылка
else
@ -4562,11 +4744,21 @@ private:
if (!m_oState.m_bInP)
return L"";
std::wstring sRStyle = GetStyle(*sSelectors.back().m_pCompiledStyle, false);
NSCSS::CCompiledStyle oMainStyle{*sSelectors.back().m_pCompiledStyle};
std::wstring sRSettings;
m_oXmlStyle.WriteLiteRStyle(oTS.oAdditionalStyle);
const std::wstring sRSettings = m_oXmlStyle.GetStyle();
m_oXmlStyle.Clear();
std::wstring sRStyle = GetStyle(oMainStyle, false);
if (!oTS.oAdditionalStyle.Empty())
{
NSCSS::CCompiledStyle oSettingStyle{oTS.oAdditionalStyle};
NSCSS::CCompiledStyle::StyleEquation(oMainStyle, oSettingStyle);
m_oXmlStyle.WriteLiteRStyle(oSettingStyle);
sRSettings = m_oXmlStyle.GetStyle();
m_oXmlStyle.Clear();
}
std::wstring wsFontSize;
@ -4574,7 +4766,7 @@ private:
if (0 != nCalculatedFontChange)
{
int nFontSizeLevel{static_cast<int>((sSelectors.back().m_pCompiledStyle->m_oFont.Empty()) ? 3 : GetFontSizeLevel(sSelectors.back().m_pCompiledStyle->m_oFont.GetSize().ToInt(NSCSS::Point) * 2))};
int nFontSizeLevel{static_cast<int>((oMainStyle.m_oFont.Empty()) ? 3 : GetFontSizeLevel(oMainStyle.m_oFont.GetSize().ToInt(NSCSS::Point) * 2))};
nFontSizeLevel += nCalculatedFontChange;

View File

@ -14,7 +14,7 @@ include($$CORE_ROOT_DIR/Common/base.pri)
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
ADD_DEPENDENCY(kernel, UnicodeConverter, graphics)
ADD_DEPENDENCY(kernel, UnicodeConverter, graphics, StarMathConverter)
DEFINES += HWPFILE_USE_DYNAMIC_LIBRARY \
CRYPTOPP_DISABLE_ASM

View File

@ -21,6 +21,9 @@
#include "../HWPElements/HWPRecordParaShape.h"
#include "../HWPElements/HWPRecordCharShape.h"
//For EQN
#include "../../../OdfFile/Reader/Converter/StarMath2OOXML/conversionmathformula.h"
#include "Transform.h"
#define PARA_SPACING_SCALE 0.85
@ -792,7 +795,8 @@ void CConverter2OOXML::WriteTable(const CCtrlTable* pTable, short shParaShapeID,
}
}
unColIndex += oValue.second->GetColSpan() - 1;
if (oValue.second->GetColSpan() > 1)
unColIndex += oValue.second->GetColSpan() - 1;
}
}
@ -828,10 +832,16 @@ void CConverter2OOXML::WriteTable(const CCtrlTable* pTable, short shParaShapeID,
oBuilder.WriteString(L"</w:tbl>");
oState.m_oLastNode.m_eType = TConversionState::TLastNode::ELastNodeType::Table;
oState.m_oLastNode.m_unParaIndex = oState.m_unParaIndex;
oState.m_bInTable = bTableInTable;
if (oState.m_bInTable)
{
oBuilder.WriteString(L"<w:p><w:r><w:rPr><w:vanish/></w:rPr></w:r></w:p>");
oState.m_oLastNode.m_eType = TConversionState::TLastNode::ELastNodeType::Paragraph;
}
else
oState.m_oLastNode.m_eType = TConversionState::TLastNode::ELastNodeType::Table;
}
void CConverter2OOXML::WriteTableProperties(const CCtrlTable* pTable, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
@ -881,10 +891,10 @@ void CConverter2OOXML::WriteCell(const CTblCell* pCell, NSStringUtils::CStringBu
oBuilder.WriteString(L"<w:tcPr>");
oBuilder.WriteString(L"<w:tcW w:w=\"" + std::to_wstring(Transform::HWPUINT2Twips(pCell->GetWidth())) + L"\" w:type=\"dxa\"/>");
if (1 != pCell->GetColSpan())
if (1 < pCell->GetColSpan())
oBuilder.WriteString(L"<w:gridSpan w:val=\"" + std::to_wstring(pCell->GetColSpan()) + L"\"/>");
if (1 != pCell->GetRowSpan())
if (1 < pCell->GetRowSpan())
oBuilder.WriteString(L"<w:vMerge w:val=\"" + HWP_STRING(((ECellCreator::FILE == eCellCreator) ? L"restart" : L"continue")) + L"\"/>");
WriteCellProperties(pCell->GetBorderFillID(), oBuilder);
@ -1245,17 +1255,17 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
void CConverter2OOXML::WriteEqEditShape(const CCtrlEqEdit* pEqEditShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
{
//TODO:: добавить конвертацию eqn формулы в ooxml
++m_ushEquationCount;
WriteCaption((const CCtrlCommon*)pEqEditShape, oBuilder, oState);
OpenParagraph(shParaShapeID, shParaStyleID, oBuilder, oState);
oBuilder.WriteString(L"<w:r>");
oBuilder.WriteString(L"<w:r><w:t xml:space=\"preserve\">");
oBuilder.WriteString(L"<w:t xml:space=\"preserve\">");
oBuilder.WriteEncodeXmlString(pEqEditShape->GetEqn());
StarMath::CStarMathConverter oConverterStarMath;
oBuilder.WriteString(oConverterStarMath.ConvertEQNToOOXml(pEqEditShape->GetEqn()));
oBuilder.WriteString(L"</w:t></w:r>");
}

View File

@ -66,7 +66,10 @@ namespace DocFileFormat
brcType = bytes[5];
short val = FormatUtils::BytesToInt16( bytes, 6, size );
dptSpace = val & 0x001F;
if (val == -1)
dptSpace = 0;
else
dptSpace = val & 0x001F;
//not sure if this is correct, the values from the spec are definitly wrong:
fShadow = FormatUtils::BitmaskToBool( val, 0x20 );

View File

@ -270,6 +270,7 @@ namespace DocFileFormat
int cp = initialCp;
int fc = m_document->FindFileCharPos(cp);
int fcEnd = m_document->FindFileCharPos(cpEnd);
bool PBookmark = false;
ParagraphPropertyExceptions* papx = findValidPapx(fc);
@ -338,6 +339,7 @@ namespace DocFileFormat
if ((chpxs != NULL) && (chpxFcs != NULL) && !chpxFcs->empty())//? второе
{
size_t i = 0;
bool changechpx = false;
// write a runs for each CHPX
for (size_t it = 0; it < chpxs->size(); ++it)
@ -346,9 +348,18 @@ namespace DocFileFormat
int fcChpxStart = ((chpxFcs) && (i < chpxFcs->size())) ? chpxFcs->at(i) : fc;
int fcChpxEnd = fcEnd;
if ((chpxFcs) && ( i < chpxFcs->size() - 1))
fcChpxEnd = chpxFcs->at(i + 1);
if (i > 0)
{
int previous = chpxFcs->at(i-1);
if ((fcChpxStart != fc) && (previous > fcChpxStart))
{
fcChpxStart = previous;
changechpx = true;
}
}
if ((chpxFcs) && ( i < chpxFcs->size() - 1))
fcChpxEnd = chpxFcs->at(i + 1);
//it's the first chpx and it starts before the paragraph
@ -396,13 +407,17 @@ namespace DocFileFormat
{
for (std::vector<std::vector<wchar_t> >::iterator iter = runs->begin(); iter != runs->end(); ++iter)
{
if (writeBookmarks(cp))
if (writeBookmarks(cp, PBookmark))
{
cp = writeRun(&(*iter), chpxs->at(it), cp);
}
PBookmark = true;
if (cp == m_document->FIB->m_RgLw97.ccpText - 1)
writeBookmarks(cp, PBookmark);
}
RELEASEOBJECT(runs);
PBookmark = false;
}
}
else
@ -427,7 +442,13 @@ namespace DocFileFormat
}
else
{
cp = writeRun(chpxChars, chpxs->at(it), cp);
if (changechpx == true)
{
size_t a = it - 1;
cp = writeRun(chpxChars, chpxs->at(a), cp);
}
else
cp = writeRun(chpxChars, chpxs->at(it), cp);
}
}
}
@ -1955,22 +1976,77 @@ namespace DocFileFormat
}
return true;
}
bool DocumentMapping::writeBookmarks(int cp)
bool DocumentMapping::writeBookmarks(int cp, bool para)
{
bool result = true;
static std::vector<int> openedInThisPara;
static std::set<int> allClosedIds;
static int nextIdForSequence = 0;
for (size_t b = 0; b < m_document->BookmarkStartEndCPs.size(); ++b)
{
if (m_document->BookmarkStartEndCPs[b].start == cp)
{
result = writeBookmarkStart(b);
}
for (size_t b = 0; b < m_document->BookmarkStartEndCPs.size(); ++b)
{
if (m_document->BookmarkStartEndCPs[b].start == cp)
{
int xmlId = b;
if (m_document->BookmarkStartEndCPs[b].end == cp)
{
result = writeBookmarkEnd(b);
}
}
result = writeBookmarkStart(xmlId);
openedInThisPara.push_back(xmlId);
}
}
bool hasPositionClosings = false;
int positionClosingCount = 0;
for (size_t b = 0; b < m_document->BookmarkStartEndCPs.size(); ++b)
{
if (m_document->BookmarkStartEndCPs[b].end == cp)
{
hasPositionClosings = true;
positionClosingCount++;
}
}
if (hasPositionClosings)
{
for (int i = 0; i < positionClosingCount; i++)
{
if (!openedInThisPara.empty())
{
int idToClose = openedInThisPara[0];
result = writeBookmarkEnd(idToClose);
allClosedIds.insert(idToClose);
openedInThisPara.erase(openedInThisPara.begin());
}
else
{
while (allClosedIds.find(nextIdForSequence) != allClosedIds.end())
{
nextIdForSequence++;
}
result = writeBookmarkEnd(nextIdForSequence);
allClosedIds.insert(nextIdForSequence);
nextIdForSequence++;
}
}
}
else if (para)
{
while (allClosedIds.find(nextIdForSequence) != allClosedIds.end())
{
nextIdForSequence++;
}
result = writeBookmarkEnd(nextIdForSequence);
allClosedIds.insert(nextIdForSequence);
nextIdForSequence++;
}
if (para)
{
openedInThisPara.clear();
}
return result;
}

View File

@ -118,7 +118,7 @@ namespace DocFileFormat
std::vector<int> searchAnnotation(std::vector<wchar_t>* chars, int initialCp);
std::vector<int> searchPermission(std::vector<wchar_t>* chars, int initialCp);
bool writeBookmarks ( int cp );
bool writeBookmarks ( int cp, bool para );
bool writeBookmarkStart ( short id );
bool writeBookmarkEnd ( short id );

View File

@ -74,9 +74,11 @@ namespace DocFileFormat
{
n = totalSize / elementSize;
if (totalSize % elementSize != 0)
if (totalSize % elementSize != 0 && structureLength == 6)
{
n += 1;
structureLength = 4;
elementSize = structureLength + CP_LENGTH;
n = totalSize/elementSize;
}
}
}

View File

@ -439,6 +439,10 @@ namespace DocFileFormat
{
val.SetValue( getBorderType( brc->brcType ));
border->AppendAttribute( val );
if (brc->dptLineWidth == 0xFF)
{
brc->dptLineWidth = 0;
}
XMLTools::XMLAttribute sz( L"w:sz", FormatUtils::IntToWideString( brc->dptLineWidth ));
border->AppendAttribute( sz );

View File

@ -218,6 +218,25 @@ namespace DocFileFormat
m_oXmlWriter.WriteNodeBegin( L"w:noPunctuationKerning", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
}
if (dop->doptypography->iJustification != 0)
{
m_oXmlWriter.WriteNodeBegin(L"w:characterSpacingControl", TRUE);
const wchar_t* spacingValue = L"doNotCompress";
switch(dop->doptypography->iJustification)
{
case 1:
spacingValue = L"compressPunctuation";
break;
case 2:
spacingValue = L"compressPunctuationAndJapaneseKana";
break;
}
m_oXmlWriter.WriteAttribute(L"w:val", spacingValue);
m_oXmlWriter.WriteNodeEnd(L"", TRUE);
}
}
//footnote properties

View File

@ -415,6 +415,7 @@ namespace DocFileFormat
TableCell tableCell ( documentMapping, _cp );
bool bBadMarker = false;
bool cell = false;
do
{
fc = documentMapping->m_document->FindFileCharPos(_cp);
@ -473,6 +474,7 @@ namespace DocFileFormat
tableRow.AddCell(tableCell);
tableCell.Clear();
paragraphBeginCP = (_cp + 1);
cell = true;
}
}
else if ( IsRowMarker( _cp ) )
@ -520,6 +522,19 @@ namespace DocFileFormat
}
while ( ( tai.fInTable ) && ( tai.iTap == _depth ) );
if (paragraphBeginCP < _cp && tableCell.IsEmpty() && cell && (documentMapping->m_document->Text->at(_cp-1) == 0x0007))
{
DocParagraph para(documentMapping, paragraphBeginCP, _cp);
tableCell.AddItem(para);
if (!tableCell.IsEmpty())
tableRow.AddCell(tableCell);
if (!tableRow.IsEmpty())
AddRow(tableRow);
++_cp;
}
cpEnd = ( _cp - 1 );
documentMapping->_lastValidPapx = papxBackup;

View File

@ -2544,10 +2544,13 @@ void XlsConverter::convert(XLS::Obj * obj)
std::wstring objectId_bin = xlsx_context->get_mediaitems().add_control_activeX(target_bin);
NSFile::CFileBinary file;
if ( file.CreateFileW(xlsx_context->get_mediaitems().activeX_path() + target_bin) )
{
file.WriteFile(xls_global_info->controls_data.first.get() + obj->pictFmla.lPosInCtlStm, obj->pictFmla.cbBufInCtlStm);
file.CloseFile();
if(xls_global_info->controls_data.second >= obj->pictFmla.lPosInCtlStm + obj->pictFmla.cbBufInCtlStm)
{
if ( file.CreateFileW(xlsx_context->get_mediaitems().activeX_path() + target_bin) )
{
file.WriteFile(xls_global_info->controls_data.first.get() + obj->pictFmla.lPosInCtlStm, obj->pictFmla.cbBufInCtlStm);
file.CloseFile();
}
}
std::wstring objectId_xml = xlsx_context->start_activeX();
xlsx_context->get_drawing_context().set_control_activeX(objectId_xml);

View File

@ -37,6 +37,9 @@ namespace XLS
AreaFormat::AreaFormat()
{
rgbFore.red = 0xFF;
rgbFore.green = 0xFF;
rgbFore.blue = 0xFF;
}

View File

@ -62,11 +62,11 @@ public:
_UINT16 fls = 0;
bool fAuto = false;
bool fAuto = true;
bool fInvertNeg = false;
IcvChart icvFore = 0;
IcvChart icvBack = 0;
IcvChart icvFore = 0x004D;
IcvChart icvBack = 0x0009;
};
} // namespace XLS

View File

@ -69,7 +69,7 @@ void AxcExt::readFields(CFRecord& record)
void AxcExt::writeFields(CFRecord& record)
{
unsigned char flags = 0;
unsigned short flags = 0;
SETBIT(flags, 0, fAutoMin)
SETBIT(flags, 1, fAutoMax)
SETBIT(flags, 2, fAutoMajor)

View File

@ -52,6 +52,12 @@ BaseObjectPtr CRN::clone()
void CRN::readFields(CFRecord& record)
{
record >> colLast >> colFirst >> row;
if(colFirst > colLast)
{
colFirst = 0;
colLast = 0;
return;
}
for(int i = 0; i < colLast - colFirst + 1; ++i)
{
@ -61,6 +67,11 @@ void CRN::readFields(CFRecord& record)
SerArPtr ser(SerAr::createSerAr(rec_type));
record >> *ser;
crnOper.push_back(ser);
if(record.getRdPtr() >= record.getDataSize())
{
colLast = colFirst + i;
break;
}
}
}

View File

@ -50,7 +50,7 @@ public:
static const ElementType type = typeDataFormat;
_UINT16 xi = 0;
_UINT16 xi = 0xFFFF;
_UINT16 yi = 0;
_UINT16 iss = 0;

View File

@ -54,7 +54,7 @@ public:
//-----------------------------
_UINT16 frt = 0;
bool fAutoSize = false;
bool fAutoPosition = false;
bool fAutoPosition = true;
};

View File

@ -53,5 +53,15 @@ void FrtFontList::readFields(CFRecord& record)
}
}
void FrtFontList::writeFields(CFRecord& record)
{
frtHeaderOld.rt = 0x085A;
record << frtHeaderOld << verExcel;
record.reserveNunBytes(1);
record << cFont;
for(auto i : rgFrtFontInfo)
record << i;
}
} // namespace XLS

View File

@ -49,6 +49,7 @@ public:
BaseObjectPtr clone();
void readFields(CFRecord& record);
void writeFields(CFRecord& record);
static const ElementType type = typeFrtFontList;

View File

@ -71,6 +71,7 @@ void Legend::writeFields(CFRecord& record)
{
unsigned short flags = 0;
SETBIT(flags, 0, fAutoPosition)
SETBIT(flags, 1, 1) //reserved
SETBIT(flags, 2, fAutoPosX)
SETBIT(flags, 3, fAutoPosY)
SETBIT(flags, 4, fVert)

View File

@ -57,7 +57,7 @@ public:
_UINT32 y = 0;
_UINT32 dx = 0;
_UINT32 dy = 0;
unsigned char wSpace = 0;
unsigned char wSpace = 1;
bool fAutoPosition = false;
bool fAutoPosX = false;

View File

@ -54,12 +54,12 @@ public:
int serialize(std::wostream & _stream);
//-----------------------------
LongRGB rgb;
_UINT16 lns = 0;
_UINT16 we = 0;
_UINT16 lns = 5;
_UINT16 we = 0xFFFF;
bool fAuto = false;
bool fAxisOn = false;
bool fAutoCo = false;
IcvChart icv = 0;
IcvChart icv = 0x004D;
};
} // namespace XLS

View File

@ -179,6 +179,36 @@ void MsoDrawing::prepareComment(const unsigned int CommentId)
}
}
void MsoDrawing::prepareChart(const unsigned int chartId, const unsigned int xPos, const unsigned int xOffset,
const unsigned int yPos, const unsigned int yOffset)
{
auto fdgPtr = new ODRAW::OfficeArtFDG;
fdgPtr->rh_own.recInstance = chartId;
fdgPtr->csp = 1;
fdgPtr->spidCur = chartId;
rgChildRec.m_OfficeArtFDG = ODRAW::OfficeArtRecordPtr(fdgPtr);
auto spgrContainer = new ODRAW::OfficeArtSpgrContainer(ODRAW::OfficeArtRecord::CA_Chart);
rgChildRec.m_OfficeArtSpgrContainer = ODRAW::OfficeArtRecordPtr(spgrContainer);
auto SpContainer = new ODRAW::OfficeArtSpContainer(ODRAW::OfficeArtRecord::CA_Chart);
spgrContainer->m_OfficeArtSpgrContainerFileBlock.push_back(ODRAW::OfficeArtContainerPtr(SpContainer));
auto groupFSPGR = new ODRAW::OfficeArtFSPGR;
groupFSPGR->xLeft = xPos;
groupFSPGR->xRight = xOffset;
groupFSPGR->yTop = yPos;
groupFSPGR->yBottom = yOffset;
SpContainer->m_OfficeArtFSPGR = ODRAW::OfficeArtRecordPtr(groupFSPGR);
auto fsprPtr = new ODRAW::OfficeArtFSP;
SpContainer->m_OfficeArtFSP = ODRAW::OfficeArtRecordPtr(fsprPtr);
fsprPtr->shape_id = 0;
fsprPtr->spid = chartId;
fsprPtr->fGroup = true;
fsprPtr->fPatriarch = true;
}
} // namespace XLS

View File

@ -62,6 +62,8 @@ public:
virtual void useContinueRecords (CFRecord& record);
void prepareComment (const unsigned int CommentId);
void prepareChart (const unsigned int chartId, const unsigned int xPos, const unsigned int xOffset,
const unsigned int yPos, const unsigned int yOffset );
//-----------------------------
ODRAW::OfficeArtDgContainer rgChildRec;

View File

@ -37,6 +37,8 @@ namespace XLS
PlotGrowth::PlotGrowth()
{
dxPlotGrowth = 1;
dyPlotGrowth = 1;
}

View File

@ -57,8 +57,8 @@ public:
static const ElementType type = typePos;
_UINT16 mdTopLt = 0;
_UINT16 mdBotRt = 0;
_UINT16 mdTopLt = 2;
_UINT16 mdBotRt = 2;
_INT16 x1 = 0;
_INT16 y1 = 0;

View File

@ -54,8 +54,8 @@ public:
int serialize(std::wostream & _stream);
//-----------------------------
_UINT16 pcBubbleSizeRatio = 0;
_UINT16 wBubbleSize = 0;
_UINT16 pcBubbleSizeRatio = 100;
_UINT16 wBubbleSize = 1;
bool fBubbles = false;
bool fShowNegBubbles = false;
bool fHasShadow = false;

View File

@ -55,8 +55,8 @@ public:
static const ElementType type = typeScl;
//-----------------------------
_INT16 nscl = 0;
_INT16 dscl = 1;
_INT16 nscl = 117;
_INT16 dscl = 100;
};

View File

@ -55,9 +55,9 @@ public:
static const ElementType type = typeSeries;
//-----------------------------
_UINT16 sdtX = 0;
_UINT16 sdtY = 0;
_UINT16 sdtBSize = 0;
_UINT16 sdtX = 1;
_UINT16 sdtY = 0x0001;
_UINT16 sdtBSize = 0x0001;
_UINT16 cValx = 0;
_UINT16 cValy = 0;

View File

@ -62,7 +62,7 @@ void ShapePropsStream::readFields(CFRecord& record)
_UINT32 cb=0;
record >> cb;
if (cb > 0)
if (cb > 0 && cb + record.getRdPtr() <= record.getDataSize())
{
xml_ = std::string( record.getCurData<char>(), cb);
record.skipNunBytes(cb);

View File

@ -56,8 +56,8 @@ public:
//-----------------------------
bool fManSerAlloc = false;
bool fManPlotArea = false;
bool fPlotVisOnly = false;
bool fManPlotArea = false;
bool fPlotVisOnly = true;
bool fNotSizeWith = false;
bool fAlwaysAutoPlotArea = false;
unsigned char mdBlank = 0;

View File

@ -57,7 +57,7 @@ public:
int serialize(std::wostream & _stream);
//-----------------------------
bool fFillSurface = false;
bool fFillSurface = true;
bool f3DPhongShade = false;
};

View File

@ -40,7 +40,7 @@ Text::Text()
is_area = false;
dlp = false;
iReadingOrder = 0;
icvText = 0xff;
icvText = 0;
}

View File

@ -56,10 +56,10 @@ public:
int serialize(std::wostream & _stream);
unsigned char at = 0;
unsigned char vat = 0;
unsigned char at = 2;
unsigned char vat = 2;
_UINT16 wBkgMode = 0;
_UINT16 wBkgMode = 1;
LongRGB rgbText;
_INT32 x = 0;
@ -73,7 +73,7 @@ public:
bool fAutoText = false;
bool fGenerated = false;
bool fDeleted = false;
bool fAutoMode = false;
bool fAutoMode = true;
bool fShowLabelAndPerc = false;
bool fShowPercent = false;
bool fShowBubbleSizes = false;

View File

@ -65,6 +65,7 @@ void CellParsedFormula::load(CFRecord& record)
// record.skipNunBytes(record.getDataSize() - record.getRdPtr());
//}
//else
if(record.getRdPtr() + cce <= record.getDataSize())
{
rgce.load(record, cce);
rgcb.load(record, rgce.getPtgs(), is_part_of_a_revision_);

View File

@ -64,7 +64,7 @@ void DVParsedFormula::load(CFRecord& record, bool bLoad)
record >> cce;
}
if (bLoad)
if (bLoad && record.getRdPtr() + cce <= record.getDataSize())
return load(record);
else
{

View File

@ -47,6 +47,13 @@ void FrtFontInfo::load(CFRecord& record)
fScaled = GETBIT(flags, 0);
}
void FrtFontInfo::save(CFRecord& record)
{
unsigned short flags = 0;
SETBIT(flags, 0, fScaled);
record << flags << ifnt;
}
} // namespace XLS

View File

@ -48,9 +48,10 @@ public:
static const ElementType type = typeFontInfo;
virtual void load(CFRecord& record);
virtual void save(CFRecord& record);
bool fScaled;
bool fScaled = false;
FontIndex ifnt;
};
} // namespace XLS
} // namespace XLS

View File

@ -145,7 +145,7 @@ std::wstring HyperlinkObject::loadHyperlinkString(XLS::CFRecord& record)
_INT32 size = 0;
record >> size;
if (size < 1) return L"";
if (size < 1 || record.getRdPtr() + size > record.getDataSize()) return L"";
_INT32 size_record = record.getDataSize() - record.getRdPtr();
if (size > size_record)

View File

@ -77,8 +77,6 @@ void RC4EncryptionHeader::load(XLS::CFRecord& record)
_UINT32 Reserved1; record >> Reserved1;
_UINT32 Reserved2; record >> Reserved2;
int pos = record.getRdPtr();
int size = record.getDataSize();
std::wstring providerName;
record >> providerName;
@ -86,7 +84,11 @@ void RC4EncryptionHeader::load(XLS::CFRecord& record)
//EncryptionVerifier
record >> crypt_data_aes.saltSize;
int pos = record.getRdPtr();
int size = record.getDataSize();
if(pos + crypt_data_aes.saltSize > size)
return;
unsigned char *pDataRead = new unsigned char[crypt_data_aes.saltSize];
memcpy(pDataRead, record.getCurData<unsigned char>(), crypt_data_aes.saltSize);
record.skipNunBytes(crypt_data_aes.saltSize);

View File

@ -75,7 +75,6 @@ const bool StringPtgParser::parseToPtgs(const std::wstring& assembled_formula, R
for(std::wstring::const_iterator it = assembled_formula.begin(), itEnd = assembled_formula.end(); it != itEnd;)
{
#pragma region Operators
if(SyntaxPtg::is_operators(it, itEnd) || SyntaxPtg::is_PtgIsect(it, itEnd))
{
OperatorPtgPtr found_operator;
@ -184,8 +183,6 @@ const bool StringPtgParser::parseToPtgs(const std::wstring& assembled_formula, R
ptg_stack.push(found_operator);
last_ptg = found_operator;
}
#pragma endregion
#pragma region Parenthesis
else if(SyntaxPtg::extract_LeftParenthesis(it, itEnd))
{
PtgFuncPtr func;
@ -250,8 +247,6 @@ const bool StringPtgParser::parseToPtgs(const std::wstring& assembled_formula, R
rgce.addPtg(last_ptg);
operand_expected = false;
}
#pragma endregion
#pragma region Comma and PtgUnion
else if(SyntaxPtg::extract_comma(it, itEnd))
{
SyntaxPtg::remove_extraSymbols(it, itEnd);
@ -278,8 +273,6 @@ const bool StringPtgParser::parseToPtgs(const std::wstring& assembled_formula, R
last_ptg = left_p; // PtgParen. Mostly to differ unary and binary minuses and pluses
operand_expected = true;
}
#pragma endregion
#pragma region Operands
else
{
OperandPtgPtr found_operand;
@ -437,7 +430,6 @@ const bool StringPtgParser::parseToPtgs(const std::wstring& assembled_formula, R
union_expected = false;
}
}
#pragma endregion
}
while(ptg_stack.size())

View File

@ -102,11 +102,14 @@ const bool AXISPARENT::loadContent(BinProcessor& proc)
const bool AXISPARENT::saveContent(BinProcessor& proc)
{
if(m_AxisParent == nullptr)
return false;
proc.mandatory(*m_AxisParent);
proc.mandatory<AxisParent>();
else
proc.mandatory(*m_AxisParent);
proc.mandatory<Begin>();
if(m_Pos != nullptr)
proc.mandatory(*m_Pos);
else
proc.mandatory<Pos>();
if(m_AXES != nullptr)
proc.mandatory(*m_AXES);
for(auto i: m_arCRT)

View File

@ -294,6 +294,10 @@ const bool CHARTFORMATS::saveContent(BinProcessor& proc)
return false;
proc.mandatory(*m_ChartRect);
proc.mandatory<Begin>();
for(auto i : m_arFONTLIST)
{
proc.mandatory(*i);
}
if(m_Scl != nullptr)
proc.mandatory(*m_Scl);
else

View File

@ -95,5 +95,24 @@ const bool FONTLIST::loadContent(BinProcessor& proc)
return true;
}
const bool FONTLIST::saveContent(BinProcessor& proc)
{
if(m_fontList == nullptr)
return false;
proc.mandatory(*m_fontList);
if(m_startObject != nullptr)
proc.mandatory(*m_startObject);
for(auto i : m_fonts)
{
if(i.first != nullptr)
proc.mandatory(*i.first);
if(i.second != nullptr)
proc.mandatory(*i.second);
}
if(m_endObject != nullptr)
proc.mandatory(*m_endObject);
return true;
}
} // namespace XLS

View File

@ -48,7 +48,12 @@ public:
BaseObjectPtr clone();
virtual const bool loadContent(BinProcessor& proc);
virtual const bool saveContent(BinProcessor& proc);
BaseObjectPtr m_fontList;
BaseObjectPtr m_startObject;
std::vector<std::pair<BaseObjectPtr,BaseObjectPtr>> m_fonts;
BaseObjectPtr m_endObject;
static const ElementType type = typeFONTLIST;
};

View File

@ -106,9 +106,10 @@ const bool FRAME::loadContent(BinProcessor& proc)
const bool FRAME::saveContent(BinProcessor& proc)
{
if(m_Frame == nullptr)
return false;
proc.mandatory(*m_Frame);
if(m_Frame != nullptr)
proc.mandatory(*m_Frame);
else
proc.mandatory<Frame>();
proc.mandatory<Begin>();
if(m_LineFormat != nullptr)
proc.mandatory(*m_LineFormat);

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