Compare commits

..

365 Commits

Author SHA1 Message Date
c727f0cba8 Merge remote-tracking branch 'origin/hotfix/v5.2.5' into develop 2018-12-21 13:08:59 +03:00
181f613893 OdfFormatReader - fix bug #39979 2018-12-20 19:30:45 +03:00
8c4d1cde6c . 2018-12-20 15:18:14 +03:00
6e515a1ee5 . 2018-12-19 19:19:17 +03:00
3532d4088d OdfFormat - fix after testing 2018-12-19 18:03:24 +03:00
eec7ab20fd XlsFormat - fix bug #40065 2018-12-19 18:02:40 +03:00
8b568ddefb Merge remote-tracking branch 'origin/hotfix/v5.2.5' into develop 2018-12-19 13:24:09 +03:00
708c07c072 x2t - version upt - 2.4.560 2018-12-19 13:21:34 +03:00
c7524a2509 OdfFormatReader - fix after testing 2018-12-19 13:09:08 +03:00
90240caa0b Download correct (MacOS) 2018-12-19 10:19:15 +03:00
f8098f1237 No latin symbols in url 2018-12-18 18:52:08 +03:00
760dfbf0d7 OdfFormatReader - fix after testing 2018-12-18 14:25:33 +03:00
784f57dea4 Revert "Merge branch 'hotfix/v5.2.5' of https://github.com/ONLYOFFICE/core into hotfix/v5.2.5"
This reverts commit e280dcbb27, reversing
changes made to 097559c25e.
2018-12-17 12:33:52 +03:00
e280dcbb27 Merge branch 'hotfix/v5.2.5' of https://github.com/ONLYOFFICE/core into hotfix/v5.2.5 2018-12-17 12:31:52 +03:00
3953fd1add [ios][x2t] fixed build 2018-12-14 14:43:05 +03:00
30986e3c36 Fix buld crash 2018-12-14 14:09:43 +03:00
6eb596080c x2t - verison up - 2.4.558 2018-12-14 14:09:32 +03:00
b45d705e2b OdfFormatReader - fix #39976 2018-12-14 14:09:22 +03:00
21dffa628d OdfFormatReader - fix bug #39976 2018-12-14 14:09:12 +03:00
1b949a978b OdfFormatReader - fix bug #39983 2018-12-14 14:09:03 +03:00
17e140debf XlsFormatReader - fix bug #39961 2018-12-14 14:08:54 +03:00
6452e9956e OdfFormat - fix users files 2018-12-14 14:08:45 +03:00
f8ad532f77 Merge pull request #129 from ONLYOFFICE/feature/pdfUtfBOM
Feature/pdf utf bom
2018-12-14 14:06:56 +03:00
e05551e679 x2t - DocxFormat - fix bug #39935 2018-12-14 14:02:22 +03:00
850959f791 PptFormatReader -fix bug #39929 2018-12-14 14:02:06 +03:00
d0661e871d Merge pull request #128 from ONLYOFFICE/hotfix/v5.2.5
Hotfix/v5.2.5
2018-12-14 13:40:59 +03:00
ec173776ea Merge branch 'develop' into hotfix/v5.2.5 2018-12-14 13:40:47 +03:00
0a3b9fb8e9 Fix buld crash 2018-12-14 12:34:41 +03:00
097559c25e x2t - verison up - 2.4.558 2018-12-13 18:58:00 +03:00
6a571ba1c9 OdfFormatReader - fix #39976 2018-12-13 14:09:17 +03:00
c4a46114a2 Merge remote-tracking branch 'origin/hotfix/v5.2.5' into develop 2018-12-13 12:15:05 +03:00
724335bdda OdfFormatReader - fix bug #39976 2018-12-12 18:12:14 +03:00
7e85df3cc5 OdfFormatReader - fix bug #39983 2018-12-12 17:32:39 +03:00
326cfbde93 XlsFormatReader - fix bug #39961 2018-12-12 15:18:57 +03:00
5df8901b59 OdfFormat - fix users files 2018-12-11 20:03:56 +03:00
9c24fa2ff1 Merge pull request #127 from ONLYOFFICE/feature/pdfUtfBOM
Feature/pdf utf bom
2018-12-11 18:26:56 +03:00
82dca18ebc Correct coding to Utf16 2018-12-11 18:08:25 +03:00
86d97d050d x2t - DocxFormat - fix bug #39935 2018-12-11 18:03:16 +03:00
a6ab10d585 PptFormatReader -fix bug #39929 2018-12-11 18:00:32 +03:00
2b8efdd9b1 v5.2.4 2018-12-11 16:07:08 +03:00
1022754391 clang build fix 2018-12-11 15:38:29 +03:00
2c10457a63 . 2018-12-08 17:22:58 +03:00
e0630979c5 . 2018-12-06 13:09:12 +03:00
8bc8b7cf58 . 2018-12-05 15:43:01 +03:00
14f4364962 . 2018-12-05 14:38:22 +03:00
9de3cb016f . 2018-12-03 16:56:41 +03:00
f12cd8ff8f [ios][x2t] fixed build 2018-12-03 16:25:12 +03:00
436015b5d2 DocFormatReader - write strict writeProtection; DocxFormatReader - read ecma & strict writeProtection 2018-12-03 16:05:36 +03:00
c078df93c9 . 2018-12-03 13:17:35 +03:00
e5e8e01490 Xls/XlsxFormat - protection verify 2018-12-02 14:19:47 +03:00
4fcc3b4f41 DocFormatReader - convert writeProtect 2018-12-02 12:57:41 +03:00
ce44e50d0e OdfFormatReader - protection sheets 2018-11-29 19:01:54 +03:00
143590f17b XlsxFormat - sheet protection, ... 2018-11-29 11:25:22 +03:00
abb7a85337 [android][x2t] fix build script 2018-11-28 15:37:24 +03:00
f0fe00aa3e Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-27 15:27:12 +03:00
98a568177d . 2018-11-27 15:26:08 +03:00
e58f1929e1 x2t - version up - 2.5.556 2018-11-27 14:57:53 +03:00
2143869e69 OdfFormatReader - .. 2018-11-27 14:28:21 +03:00
ac6a1a19da Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-26 14:43:12 +03:00
fb574f1994 [android][pe] utils 2018-11-23 17:50:54 +03:00
f9af786d5a . 2018-11-23 12:19:38 +03:00
3cde3a4444 OdfFormatReader - fix after testing 2018-11-22 19:27:58 +03:00
eb2221f006 Fix previous commit 2018-11-22 11:30:02 +03:00
394d1e7b38 Remove preload libcef library 2018-11-22 11:24:18 +03:00
d9d1473fd0 Add support of RLE8 compression for Wmf/Emf 2018-11-21 18:17:58 +03:00
45ba99b9bf Up cef version on linux 2018-11-21 16:20:33 +03:00
9576ce5f28 OdfFormatReader - convert ms ole objects in open office 2018-11-20 15:42:00 +03:00
7092922d1b DocFormatReader - parsing extra property draw - blob 2018-11-20 11:19:43 +03:00
e112c63f12 OdfFormatReader - external links in formulas and defineds 2018-11-20 11:13:33 +03:00
ae9ec197f1 Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-16 18:29:14 +03:00
af7640e736 DocFormat - fix after testing 2018-11-16 18:28:34 +03:00
f467912988 Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-16 15:53:13 +03:00
292781e6fb DocFormat - fix after testing
x2t version up - 2.4.556
2018-11-16 15:50:05 +03:00
9cd97d48b8 MetaFile - fix bugs #39745, #39747 2018-11-16 14:10:37 +03:00
579b441edc . 2018-11-16 12:05:22 +03:00
63b71d256b Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-15 19:51:18 +03:00
90f1aa055c OdfFormatReader - fix after testing 2018-11-15 19:49:54 +03:00
d75352f1f2 x2t - fix convert vml -> drawing_ml 2018-11-13 14:29:19 +03:00
51cbcfa9f2 Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-12 18:37:55 +03:00
eef66b3498 OdfFormat - fix convert same autoshapes 2018-11-12 18:37:19 +03:00
945d43997a Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-12 15:47:51 +03:00
b41170a233 Update .gitignore 2018-11-12 15:17:34 +03:00
b64541e6bd fix String<->StringExt 2018-11-12 12:41:27 +03:00
5626963bdf Fix build 2018-11-12 12:16:04 +03:00
5b7d637c78 Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-12 11:53:39 +03:00
643f117a92 . 2018-11-12 11:53:01 +03:00
f6d38c1f1b Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-10 19:05:45 +03:00
dd24ca837f x2t - version up. 2.4.555. 2018-11-10 19:04:30 +03:00
f555e3f821 OdfFormat - refactoring same auto shapes 2018-11-10 19:03:18 +03:00
503e87077b [x2t] xlsx_dir2xlst_bin: copy Editor.xlsx only if xlsx has pivot table 2018-11-09 19:38:24 +03:00
07a07a1abd PdfWriter - fix encrypt 2018-11-09 19:18:09 +03:00
30473ee9b7 MacOS build (clang) 2018-11-09 15:38:15 +03:00
73ef4140a2 [x2t] rename String.h -> StringExt.h 2018-11-09 14:33:25 +03:00
8b6e5f17c8 MacOS 2018-11-09 14:06:51 +03:00
fcede43d99 [android][xt2] fix for build 2018-11-08 12:07:06 +03:00
c37f011d6d OdfFormatWriter - convert externalLinks 2018-11-07 17:55:25 +03:00
52ec27a679 [android][xt2] fix for build 2018-11-07 16:39:13 +03:00
a687e49a6a [android][x2t] fix for build 2018-11-07 14:04:27 +03:00
4d0e44c8b6 Fix PRODUCT_VERSION substitution 2018-11-07 11:39:03 +03:00
4dddc6d9bc Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-06 19:18:30 +03:00
b6b79576a1 Update base.pri 2018-11-06 14:25:39 +03:00
1c1223b148 Fix misprint 2018-11-06 14:22:40 +03:00
9947f058a9 XlsFormat - fix bug #39541 2018-11-06 13:17:16 +03:00
54f55ad2ac Fix build without PRODUCT_VERSION env 2018-11-06 12:22:40 +03:00
e4edb9cca4 Fix current year substitution into copyright on windows 2018-11-02 18:18:18 +03:00
8bb23e9ce1 [ios][x2t] fix build 2018-11-02 17:45:12 +03:00
aacea2f015 Fix year in copyright on windows 2018-11-02 17:14:31 +03:00
1475b2fef9 Fix misprint 2018-11-02 16:31:01 +03:00
8e58975095 Add publisher name and version env param 2018-11-02 16:25:26 +03:00
04550f06ad Fix bug with metadata in UTF16 format 2018-11-02 15:20:36 +03:00
d2b6444730 Fix bug with metadata in UTF16 format 2018-11-02 15:19:11 +03:00
08738092c6 [ios][pe] events 2018-11-02 11:31:59 +03:00
8e220427eb Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-01 14:25:05 +03:00
962c31dc2a [x2t] To Revision: d12cc81745 2018-11-01 11:45:52 +03:00
d12cc81745 [x2t] Add app/core.xml to Editor.bin 2018-10-31 20:27:03 +03:00
988423f6e0 OdfFormatReader - write part tables
x2t version 2.4..554
2018-10-31 18:12:11 +03:00
2b096f0977 Wmf meta file - fix bug #39533 2018-10-31 18:03:19 +03:00
7c0962f834 Fix multi-thread build crash 2018-10-31 14:45:25 +03:00
17423cdcdb Merge pull request #123 from ONLYOFFICE/feature/qt_word
Feature/qt word
2018-10-30 19:05:23 +03:00
5dc512dc3b Merge pull request #122 from ONLYOFFICE/feature/Bug_builder
Fix builder bug
2018-10-30 19:03:48 +03:00
1393073694 Merge branch 'feature/fix2_v5.2.3' into hotfix/v5.2.4 2018-10-30 17:43:06 +03:00
7da761a009 Standart Tester epsilon for pixel diffs 2018-10-30 16:45:19 +03:00
e21e0afb45 Fix bug with rendering some emf files 2018-10-30 15:01:34 +03:00
626eb87203 v5.2.3 2018-10-30 12:58:37 +03:00
5b0dad3d99 Standart Tester bugs (+ gamma for stroke functionality) 2018-10-29 19:31:27 +03:00
9d3b7b91af Fix builder bug 2018-10-29 15:40:29 +03:00
f40d82a097 Fix issue https://github.com/ONLYOFFICE/DocumentServer/issues/413 2018-10-29 15:20:48 +03:00
9112c87b1f Merge remote-tracking branch 'origin/feature/fix2_v5.2.3' into develop 2018-10-29 13:19:17 +03:00
01691950b9 . 2018-10-29 13:18:34 +03:00
78bbaecefe Merge remote-tracking branch 'origin/feature/fix2_v5.2.3' into develop 2018-10-29 11:39:01 +03:00
9e085c5ae8 OdfFormat - fix conditional formatting 2018-10-28 17:45:25 +03:00
f55cafa2af OdfFormat -fix after testing 2018-10-26 19:51:12 +03:00
17bc27199c OdfFormatWriter - fix bug#39467 2018-10-25 18:51:07 +03:00
ee4167ec8c Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-25 17:48:00 +03:00
e436c13fcc [x2t] Fix bug 39456 2018-10-25 17:45:03 +03:00
8e2c980152 OdfFormat - fix after testing (#118)
OdfFormat - fix after testing
2018-10-25 17:43:11 +03:00
658bfbc348 Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-23 13:35:31 +03:00
ff9ef8f941 PptFormatReader - fix users files 2018-10-23 13:19:30 +03:00
0a2401471e [x2t] Fix bug 39391
Fix writing only last ConditionalFormatting from Editor.bin
2018-10-23 11:37:06 +03:00
5ca5597c58 [ios][pe] translations 2018-10-22 16:22:53 +03:00
e55dc5ea75 . 2018-10-22 15:47:09 +03:00
e2db849b03 Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-22 12:01:03 +03:00
fef30772fd OdfFormatWriter - fix after testing 2018-10-21 18:10:29 +03:00
23ba8a23a4 Fix multi-thread build crash 2018-10-21 15:37:15 +03:00
866af012eb . 2018-10-19 17:55:39 +03:00
4df09fd25a Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 16:27:27 +03:00
8bae2e3255 . 2018-10-19 14:25:35 +03:00
6180fedb0b Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 13:05:15 +03:00
35113a76ca . 2018-10-19 12:10:06 +03:00
5895bc9641 Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 10:51:20 +03:00
a5a6686501 Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 10:50:49 +03:00
f776bb6c4e OdfFormatWriter - fix after testing 2018-10-19 10:36:02 +03:00
4c930e716b Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-17 15:38:13 +03:00
595ecae254 x2t - binary - native convert locked canvas - bix bug #28246 2018-10-17 13:29:55 +03:00
8d3e50f8c0 x2t - version up 2018-10-16 19:11:14 +03:00
2439106397 Fix crash on empty dash pen 2018-10-16 17:52:22 +03:00
8953b74579 Fix bug 39214 (text selection in pdf/xps) 2018-10-16 17:17:13 +03:00
bd7978e474 Correct test 2018-10-16 15:52:28 +03:00
95238af0f5 Merge branch 'hotfix/v5.2.3' of https://github.com/ONLYOFFICE/core into hotfix/v5.2.3 2018-10-15 14:02:06 +03:00
e83daf6c91 RtfFormatReader - fix bug #39315 2018-10-15 14:01:27 +03:00
a4cade5a58 Test for work with standart docs 2018-10-15 13:59:52 +03:00
4fb284ebee x2t - fix bug #39307 2018-10-15 13:12:27 +03:00
900ed115c7 Test for work with standart docs 2018-10-12 19:44:43 +03:00
d34b850c52 [ios][pe] events 2018-10-12 19:15:18 +03:00
cc31becec1 [x2t] Fix bug 39305
Fix String.ToString2 after f7a13e04d8
2018-10-12 16:39:01 +03:00
24332cca42 [ios][x2t] fixed build 2018-10-12 12:39:04 +03:00
9b5f052c97 OdfFormatWriter - fix after testing 2018-10-11 17:57:45 +03:00
2017a8c692 OdfFormat - fix after testing 2018-10-10 19:29:31 +03:00
55e7777abb [zlib] Remove zlib-1.2.3 2018-10-10 18:46:27 +03:00
b7c8bc2769 [zlib] Update zlib to 1.2.11
Fix opening of xlsx created by NPOI(bad-zip.xlsx)
2018-10-10 18:42:45 +03:00
13900daf08 [zlib] Repeat local changes from zlib-1.2.3 2018-10-10 18:39:00 +03:00
2feb1ac8e8 Add zlib-1.2.11 2018-10-10 17:52:04 +03:00
558c669fb6 Disable truetype fonts convertasion in html viewer 2018-10-10 15:58:26 +03:00
6268e8c3f3 PptxFormat - fix after testing 2018-10-10 11:27:39 +03:00
d872f4220c Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-10-09 18:14:42 +03:00
3c24392e16 PptxFormat - fix after testing 2018-10-09 18:13:57 +03:00
e859821647 Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-10-09 17:02:46 +03:00
5c1a2f11f9 XlsFormatReader - fix users file (external defined names) 2018-10-09 14:53:04 +03:00
f7a13e04d8 DocxFormat - fix read binary file - bug #39248 2018-10-09 14:02:15 +03:00
18cbd41c84 Add GetImage method to IImageCache 2018-10-08 18:16:06 +03:00
c6e47a7bcf DocxFormat - fix bug #39216 2018-10-08 13:08:17 +03:00
62d6581c43 DocFormatReader - fix bug #39236 2018-10-08 11:32:31 +03:00
2d0e5aefa0 Merge pull request #117 from ONLYOFFICE/feature/aspose-math
Feature/aspose math
2018-10-05 17:04:41 +03:00
78a5546d0a PptxFormat - fix binary convert mathType version over 3.0 2018-10-05 12:49:01 +03:00
8985395ef1 [x2t] Move from mm to twips in Editor.bin 2018-10-04 17:58:29 +03:00
f55a5418e9 x2t - fix pptx section list 2018-10-04 17:39:32 +03:00
9410862444 [x2t] Fix bin->docx default style falg 2018-10-04 15:08:14 +03:00
f4d72572c0 Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-10-04 13:04:52 +03:00
f078605031 x2t - select method encrypt files 2018-10-04 13:01:49 +03:00
9105894416 . 2018-10-04 11:32:05 +03:00
1102f7f9b0 OdfFormat - not strong encryption 2018-10-03 20:13:49 +03:00
9aad3d1adb x2t - ooxml - not strong encryption 2018-10-03 20:01:57 +03:00
bc319bddbf Gost algorithms 2018-10-03 19:18:01 +03:00
8d664c2a4f . 2018-10-03 17:22:33 +03:00
cbfa907451 graphics - metafile - fix convert to rastr on linux without set fonts 2018-10-03 15:02:29 +03:00
0712bcfd5c OdfFormatwriter - convert bookmarks 2018-10-02 19:16:14 +03:00
474873531d OdfFormatReader - fix bug #39192 2018-10-02 14:47:38 +03:00
8625e93ac5 [x2t] Rename READ2_DEF -> READ2_DEF_SPREADSHEET 2018-10-01 18:14:04 +03:00
fb79df8c6c . 2018-10-01 11:40:48 +03:00
071ad3f86e . 2018-09-30 17:21:48 +03:00
65bcdb3bea . 2018-09-30 17:08:42 +03:00
f9f26e84fd . 2018-09-30 14:35:49 +03:00
a3888a8186 . 2018-09-28 17:19:20 +03:00
1493e4a949 [ios][x2t] fixed build 2018-09-28 16:36:12 +03:00
85bf4b8fac Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-09-28 15:57:47 +03:00
94ec819e68 x2t clear compiling warnings 2018-09-28 15:56:59 +03:00
cb7c7cb4d5 . 2018-09-28 14:55:50 +03:00
b1b911b538 Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-09-28 14:51:13 +03:00
d94595f755 OdfFormat - refactoring convert word-arts from/to ooxml; convert form controls in spreadsheets 2018-09-28 14:50:09 +03:00
2192bff46b Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-09-28 14:39:43 +03:00
c7eb16fa64 x2t - clear compiling warnings 2018-09-28 14:30:27 +03:00
d9922e4782 x2t - binary file - add converting effects for drawings 2018-09-28 14:29:33 +03:00
6ee7d79cc4 RtfFormatReader - fix bug #39172 2018-09-28 14:25:18 +03:00
332348ef5b release/v5.2.0 2018-09-27 19:07:44 +03:00
e4e6acd1bc [android][x2t] added doctrenderer file stub 2018-09-27 15:03:47 +03:00
7418b2327a Merge remote-tracking branch 'origin/develop' into develop 2018-09-27 14:10:28 +03:00
18d610e3e0 [android][x2t] added example of converter 2018-09-27 14:09:12 +03:00
4e81420eed [ios][x2t] fixed build 2018-09-26 16:18:50 +03:00
e26f836da7 Merge commit '69d2b12f5315e96442fc5a0620d4f4c2070c4e77' into develop 2018-09-24 18:34:51 +03:00
69d2b12f53 . 2018-09-24 17:48:02 +03:00
f2260748c8 . 2018-09-24 17:48:02 +03:00
b59f84b262 . 2018-09-24 17:48:02 +03:00
3e5fed8482 x2t - fix return codes 2018-09-24 17:48:02 +03:00
538e477818 Revert "[test] Define AVS_ERROR_FIRST as 0 to avoid issues with assignment and comparison uint64, int64, int32"
This reverts commit 05694d13f3.
2018-09-24 13:19:18 +03:00
b212e878c6 Merge pull request #114 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-09-24 01:13:01 +03:00
05694d13f3 [test] Define AVS_ERROR_FIRST as 0 to avoid issues with assignment and comparison uint64, int64, int32 2018-09-24 01:04:14 +03:00
1dd72c99a2 Remove define GetCharWidth 2018-09-21 16:43:39 +02:00
4b73e58693 [bug] Fix missing function name 2018-09-21 17:36:32 +03:00
bee4f57dd3 [bug] Fix opening encrypted odf files 2018-09-21 17:36:32 +03:00
dd40e3e53c Merge pull request #111 from ONLYOFFICE/feature/ComboFonts
Fix bug with squares in combobox fonts (& empty rects)
2018-09-21 14:54:43 +03:00
d657ece017 Fix bug with squares in combobox fonts (& empty rects) 2018-09-21 14:36:14 +03:00
b21b1b8aaf [bug] Fix missing function name 2018-09-21 13:02:23 +03:00
09fb980060 [bug] Fix opening encrypted odf files 2018-09-21 12:01:01 +03:00
142f9f57a3 OdfFormatReader&Writer - refactoring converting wordarts from/to ooxml 2018-09-20 18:59:51 +03:00
1955dc98df [x2t] Set default value for math nodes with val attribute and COnOff type 2018-09-20 17:38:30 +03:00
28346c4571 Fix bug with squares in combobox fonts (& empty rects) 2018-09-20 14:53:10 +03:00
9810087ee1 Merge pull request #108 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-09-20 14:38:32 +03:00
2b8e1456c2 . 2018-09-20 11:41:42 +03:00
274c000ce7 fix PdfReader 2018-09-20 11:35:30 +03:00
9e6dd1fbb1 fix OdfReader 2018-09-20 11:35:30 +03:00
158692f824 [x2t] Fix opening docx with track changes and math created by aspose 2018-09-19 16:53:05 +03:00
49723e648a . 2018-09-19 11:29:43 +03:00
b0a2104b21 Merge commit 'de51052f6ae59ac36665fb3f85804081a888c7c5' into develop 2018-09-18 20:03:33 +03:00
e4986f4202 . 2018-09-18 19:35:06 +03:00
de51052f6a [bug] Fix file corruption after pasting picture with error 2018-09-18 18:47:12 +03:00
bd1dc5a7b6 . 2018-09-17 17:28:46 +03:00
1ccbe323f4 . 2018-09-14 19:21:12 +03:00
2c8efcb183 Merge pull request #106 from ONLYOFFICE/feature/provideARCtoKernel
send use ARC parameter to downloader
2018-09-14 18:46:40 +03:00
9c2a717870 send use ARC parameter to downloader 2018-09-14 17:03:12 +03:00
3811169415 Merge commit '185dc3064f731e4adb04040e116dc53110c6d866' into develop 2018-09-14 11:36:36 +03:00
2871769479 . 2018-09-14 11:34:07 +03:00
185dc3064f OdfFormat - fix comment in empty cell-row, fix default background color 2018-09-13 19:51:31 +03:00
c6f8a1cde8 [bug] Fix bug 38876 2018-09-13 16:47:50 +03:00
acdce1edb9 . 2018-09-12 17:53:40 +03:00
67a40a5fc4 Constructor of __ox_drawing doesn't receive parameters 2018-09-12 15:41:37 +03:00
67cd654785 OdfFormatReader - convert form controls in spreadsheets 2018-09-11 14:59:10 +03:00
3816162555 Merge commit '3fb166f99a211e85474c121009019d06710722f8' into develop 2018-09-10 18:43:15 +03:00
3fb166f99a OdfFormatWriter - fix repeated rows 2018-09-10 18:15:35 +03:00
d8121d1a12 [ios][x2t] fixed array check 2018-09-06 19:11:47 +03:00
a76bf57051 fix bug #38817 2018-09-06 13:46:47 +03:00
97b92cf75c . 2018-09-05 18:39:32 +03:00
506de8e9e1 fix bug #38678 2018-09-05 18:38:55 +03:00
fb34d57ee6 DocFormatReader - fix footnotes for doc1995; optimization convert 2018-09-05 14:45:24 +03:00
da2d997838 . 2018-09-03 19:50:02 +03:00
76d68fa70f Fix bug #38544
Fix the problem with calculating transformation matrix for the EMF. Add support of EMR_STRETCHBLT field.
2018-09-03 18:07:10 +03:00
677e3e49e0 . 2018-08-31 17:38:17 +03:00
02c84d107b Merge commit 'b59908e4c25b265641e77b2167826f236b3b9d64' into develop 2018-08-31 17:27:06 +03:00
b59908e4c2 OdfFormatWriter - add same preset ooxml shapes 2018-08-31 16:13:07 +03:00
04e6b642f4 OdfFormatWriter - fix bug #38720 2018-08-31 14:12:49 +03:00
49cd76d0f3 Ooxml encrypt files - add support compatibility with Office 2003-2007(+ add rc4 method to encrtypt); add des method in agile encryption 2018-08-30 17:47:17 +03:00
c9ddd5b7b5 [bug] Fix tmp file name if nedd download src file 2018-08-30 16:37:15 +03:00
53a75261e3 . 2018-08-29 19:05:30 +03:00
26f32dd511 [ios][pe] chart events 2018-08-29 18:25:08 +03:00
e1e788b768 [x2t] Add Compat settings to Editor.bin 2018-08-29 17:30:18 +03:00
a74c927e7e DocFormatReader - fix after testing 2018-08-28 15:13:41 +03:00
c94e1e3223 V8 windows xp support 2018-08-27 16:40:56 +03:00
395e54cf76 [ios][x2t] fixed build 2018-08-24 15:11:04 +03:00
40476e7555 [ios][x2t] use system libxml2 2018-08-24 14:59:54 +03:00
04f06c23a1 DocxFormat - extend shading pPr 2018-08-24 13:22:45 +03:00
a9a635747a [ios][x2t] fixed build 2018-08-24 12:50:05 +03:00
4afe985955 Fix building libicue on all glibc > 2.26 systems 2018-08-24 12:35:45 +03:00
4027a0de25 Merge commit 'a232fcd9e1042811d624ff8934dc689f57ac2f57' into develop 2018-08-24 11:10:03 +03:00
a232fcd9e1 DocFormatReader - fix bug #38524 2018-08-23 19:55:44 +03:00
5bc537749e Add date_time library 2018-08-22 19:41:12 +03:00
6e7f6cf204 . 2018-08-22 19:39:28 +03:00
b0c10403c5 OdfFormat - fix bug #38506; others from after testing 2018-08-22 15:42:26 +03:00
5f516f0c56 OdfFormatReader - fix after testing 2018-08-21 13:24:20 +03:00
bfe8abb847 XlsFormatReader - fix users file 2018-08-20 16:56:12 +03:00
d765a7590b DocxFormat - fix bug #38594 2018-08-20 14:11:58 +03:00
dac34c32c0 RtfFormat - fix fonts in meta files 2018-08-17 18:46:47 +03:00
599bf9654d x2t - fix bug #38432 2018-08-17 16:16:22 +03:00
fbd55ca485 OdfFormatReader - fix bugs #38485, #38507 2018-08-17 14:53:40 +03:00
68bb25301d [x2t] Add tcPr.hMerge to Editor.bin 2018-08-16 20:00:14 +03:00
2390e5bffe [x2t] Add custom docx properties SdtGlobalColor, SdtGlobalShowHighlight 2018-08-16 19:11:40 +03:00
01c9c018af [bug] Fix bug 38496 2018-08-16 18:44:50 +03:00
53ed94dbbe [x2t] Add w15:appearance and w15:color to sdtPr 2018-08-13 19:39:52 +03:00
e1fa9b5c46 Add /usr/local/share/fonts to search folders 2018-08-10 17:47:18 +03:00
6341cdbbdb [x2t] Write application and company name from environment variable 2018-08-09 19:35:51 +03:00
c93989767e raster pri fix 2018-08-09 17:02:41 +03:00
f4fa754ce4 Merge pull request #96 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-08-08 15:04:56 +02:00
a965b30d72 GIF palette generator 2018-08-08 16:04:03 +03:00
dd3dd1e42a [x2t] For bug 38295 2018-08-06 19:47:20 +03:00
d2f1460f1b [x2t] Fix bug 38360 2018-08-06 13:54:43 +03:00
7d88a91fcc up 2018-08-03 10:39:59 +03:00
bf02eec8ef XlsFormatReader - fix #38293 2018-08-02 17:07:55 +03:00
8513ec5ae7 OdfFormatReader - fix after testing 2018-08-01 20:12:59 +03:00
35b43e0683 PptFormatReader - fix bug#37445 2018-08-01 20:11:05 +03:00
421e58fe34 x2t - 2.4.541 fix after testing 2018-08-01 12:51:13 +03:00
048cac74b6 . 2018-07-30 18:28:40 +03:00
069b12839f Merge commit 'c23ff4c8cd5bb2040f75a3a9845fc41d9d496216' into develop 2018-07-30 10:45:09 +03:00
c23ff4c8cd OdfFormatReader - fix after testing.
x2t - version up 2.4.540
2018-07-27 12:59:44 +03:00
ccc27a2e1b x2t - fix after testing 2018-07-26 19:06:06 +03:00
3843f52601 XlsFormat - fix user file 2018-07-26 15:17:54 +03:00
c3ec17c132 . 2018-07-26 13:07:47 +03:00
72cb63b9f5 Add PDFA fornat (emulation) 2018-07-24 18:49:12 +03:00
dd04f5cf12 DocFormatReader - add word 2.0 to checker files 2018-07-24 18:11:16 +03:00
dde6621d10 Merge branch 'release/v5.2.0' of https://github.com/ONLYOFFICE/core into release/v5.2.0 2018-07-24 17:16:02 +03:00
7c3b060794 . 2018-07-24 17:01:49 +03:00
a8e4ccdf80 Remove unused files 2018-07-24 14:46:10 +03:00
aa609336ca [ios][x2t] fixed build 2018-07-23 19:48:36 +03:00
9601d90671 OdfFormatReader - fix dataValidations, conditional formating 2018-07-23 17:31:39 +03:00
f59d7ff845 Merge branch 'release/v5.2.0' of https://github.com/ONLYOFFICE/core into release/v5.2.0 2018-07-23 16:50:13 +03:00
adf2399368 x2t - DocFormat - fix after testing 2018-07-23 16:36:13 +03:00
5da57d65c1 [x2t] Fix empty hyperlink rels bin->docx 2018-07-20 15:12:30 +03:00
feddb37222 static link open ssl to desktop (mac) 2018-07-19 19:46:59 +03:00
81db8d1776 Fix macos build 2018-07-19 15:00:47 +03:00
2a809ab970 OdfFormat - read/write macros OnlyOffice. 2018-07-19 14:48:33 +03:00
b6a0614f00 OdfFormatReader - fix bug #38244 2018-07-19 11:43:57 +03:00
452917f213 [pe][ios] Apply timing to all 2018-07-19 11:13:28 +03:00
96202979ea [x2t] Add headerFooter, legacyDrawingHF, picture, rowBreaks to Editor.bin 2018-07-18 20:42:34 +03:00
5b5ccdc9be [pe][ios] Events 2018-07-18 19:19:13 +03:00
4ca2126abc OdfFormatReader - fix issue #128 2018-07-18 17:10:27 +03:00
adf7ca65ea [ios][pe] events 2018-07-18 16:48:45 +03:00
89235ca12a Changes for core develop branch (desktop) 2018-07-18 12:01:02 +03:00
08d551752e Changes for desktop (develop branch) 2018-07-17 19:55:31 +03:00
77b1303d62 . 2018-07-17 18:12:51 +03:00
94548131a1 v5.1.5 2018-07-17 17:08:49 +03:00
93e56e2b8a OdfFormatReader - fix issue #128, add cross references, fix simple annotations 2018-07-17 16:14:20 +03:00
e032fc8294 [bug] Compilation bug 2018-07-17 14:04:07 +03:00
5ae2ac2385 [ios][x2t] fixed build 2018-07-16 15:43:07 +03:00
6b8cb6cae4 Merge pull request #94 from ONLYOFFICE/feature/bin2xlsx-enh
[x2t] Decrease memory consumption while bin->xlsx conversion
2018-07-16 14:10:56 +03:00
e66ea7c628 [x2t] Add saving of templates to fromDocxDir, fromXlsxDir, fromPptxDir 2018-07-16 13:57:20 +03:00
2447925fd6 OdfFormatWriter - alphabetical indexes 2018-07-16 11:31:58 +03:00
9991195d56 . 2018-07-13 18:59:23 +03:00
51f579a682 [ios][pe] events 2018-07-13 18:23:28 +03:00
45e0459434 OdfFormatWriter - .. 2018-07-13 15:26:51 +03:00
2f194ebd97 . 2018-07-13 13:24:56 +03:00
5e4ce83dc1 Ignore -no-warrowing warning while building PdfWriter
Errors looks like:
`../Src/ICCProfile.h:52: error: narrowing conversion of '-72' from 'int'
to 'unsigned char' inside { } [-Wnarrowing]`
2018-07-13 13:05:13 +03:00
50d4f451b9 . 2018-07-12 20:46:00 +03:00
d464aa659a OdfFormat - .. 2018-07-12 19:37:33 +03:00
db2d001110 Fix possible typo
`realink -n` return empty string
Introduced in
51569b626f
Seems have nothing to do with mac, since all other file has `readlink
-f`
2018-07-12 18:24:22 +03:00
b883cfcbd4 Add workaround for building icu on ArchLinux
See https://bugs.archlinux.org/task/55246
2018-07-12 16:51:17 +03:00
bb8add215a Fail on any error in subscripts
Without this command any errors are just ignored and script continues
2018-07-12 16:24:32 +03:00
ff7d7a908c [ios][pe] events 2018-07-12 11:15:40 +03:00
958e213f9b [x2t] Fix RemoveWhiteSpaces 2018-07-11 19:40:27 +03:00
3d3baa50b5 . 2018-07-11 18:15:28 +03:00
ee987f8713 OdfFormatWriter - add documentID, add table of content, table of indexes 2018-07-11 17:20:51 +03:00
5e126e28ff [x2t] Decrease memory consumption while bin->xlsx conversion 2018-07-11 16:58:07 +03:00
e98f4ae7b4 PdfWriter - add documentID 2018-07-11 12:30:37 +03:00
6900c0a640 [x2t] Remove LvlRestart stubs 2018-07-10 20:28:09 +03:00
5f09bf7835 . 2018-07-10 19:06:46 +03:00
5a9a89979c Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2018-07-10 18:38:26 +03:00
6a052f68aa PdfWriter - fix encrypt 2018-07-10 18:37:50 +03:00
fc9b5e0613 [ios][x2t] fixed icu 2018-07-10 18:33:35 +03:00
f7d1009974 OdfFormatReader - styles template table of content 2018-07-09 19:27:30 +03:00
1120 changed files with 85917 additions and 39251 deletions

4
.gitignore vendored
View File

@ -35,6 +35,7 @@ Common/3dParty/openssl/openssl
.idea
.svn
.DS_Store
.qmake.stash
Thumbs.db
*.xcuserstate
*.xcuserdatad
@ -46,6 +47,8 @@ ASCOfficeXlsFile2/win32/_ASCOfficeXlsFile2_p.c
ASCOfficeXlsFile2/win32/dlldata.c
OfficeUtils/win32/OfficeUtilsLib/OfficeUtilsLib/ReadMe.txt
X2tConverter/**/Makefile.*
X2tConverter/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/Makefile
X2tConverter/Common/DocxFormat/DocxFormatLib/Makefile
*.7z
*.obj
*.pdb
@ -55,3 +58,4 @@ X2tConverter/**/Makefile.*
*.zip
*.tar.gz
**/*.build/

View File

@ -52,8 +52,10 @@
#include <string.h>
#endif
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
#include "../../DesktopEditor/common/Types.h"
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
#include "../../UnicodeConverter/UnicodeConverter.h"
#include <boost/format.hpp>

View File

@ -58,7 +58,8 @@ namespace DocFileFormat
}
else
{
short cch = reader->ReadInt16();
short cch = reader->ReadInt16();
unsigned char *chars = reader->ReadBytes(18, true);
@ -67,13 +68,34 @@ namespace DocFileFormat
newObject->m_AuthorIndex = reader->ReadUInt16();
//skip 4 bytes
reader->ReadBytes(4, false);
unsigned int skip = reader->ReadUInt32();
newObject->m_BookmarkId = reader->ReadInt32();
newObject->m_BookmarkId = reader->ReadInt32(); //-1 - comment is on a length zero text range in the Main Document
RELEASEARRAYOBJECTS(chars);
}
return static_cast<ByteStructure*>(newObject);
}
ByteStructure* AnnotationReferenceExDescriptor::ConstructObject(VirtualStreamReader* reader, int length)
{
AnnotationReferenceExDescriptor *newObject = new AnnotationReferenceExDescriptor();
if (reader->nWordVersion > 0)
{
}
else
{
m_nDTTM = reader->ReadUInt32();
reader->ReadUInt16(); //padding1
m_nDepth = reader->ReadUInt32();
m_nDiatrdParent = reader->ReadUInt32();
unsigned int flag = reader->ReadUInt32();
m_fInkAtn = GETBIT(flag, 1);
}
return static_cast<ByteStructure*>(newObject);
}
}

View File

@ -46,21 +46,6 @@ namespace DocFileFormat
return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
inline std::wstring GetUserInitials() const
{
return m_UserInitials;
}
inline unsigned short GetAuthorIndex() const
{
return m_AuthorIndex;
}
inline int GetBookmarkId() const
{
return m_BookmarkId;
}
AnnotationReferenceDescriptor() : m_AuthorIndex(0), m_BookmarkId(0)
{
}
@ -71,13 +56,35 @@ namespace DocFileFormat
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length );
private:
/// The initials of the user who left the annotation.
std::wstring m_UserInitials;
/// An index into the string table of comment author names.
unsigned short m_AuthorIndex;
/// Identifies a bookmark.
int m_BookmarkId;
};
class AnnotationReferenceExDescriptor: public ByteStructure
{
public:
static const int STRUCTURE_SIZE = 18;
static const int STRUCTURE_SIZE_OLD = 0;
static const int GetSize(int nWordVersion)
{
return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
AnnotationReferenceExDescriptor() : m_nDTTM(0), m_nDepth(0), m_nDiatrdParent(0), m_fInkAtn(false)
{
}
virtual ~AnnotationReferenceExDescriptor()
{
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length );
unsigned int m_nDTTM;
unsigned int m_nDepth;
unsigned int m_nDiatrdParent;
bool m_fInkAtn;
};
}

View File

@ -39,13 +39,8 @@ namespace DocFileFormat
class BookmarkFirst: public ByteStructure
{
private:
/// An unsigned integer that specifies a zero-based index into the PlcfBkl or PlcfBkld
/// that is paired with the PlcfBkf or PlcfBkfd containing this FBKF.
/// The entry found at said index specifies the location of the end of the bookmark associated with this FBKF.
/// Ibkl MUST be unique for all FBKFs inside a given PlcfBkf or PlcfBkfd.
short ibkl;
/// A BKC that specifies further information about the bookmark associated with this FBKF.
short bkc;
short ibkl;
short bkc;
public:
static const int STRUCTURE_SIZE = 4;
@ -78,4 +73,32 @@ namespace DocFileFormat
return static_cast<ByteStructure*>( newObject );
}
};
class AtnBookmarkFirst: public ByteStructure
{
public:
unsigned short bmc;
unsigned int lTag;
static const int STRUCTURE_SIZE = 10;
AtnBookmarkFirst()
{
}
virtual ~AtnBookmarkFirst()
{
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
AtnBookmarkFirst *newObject = new AtnBookmarkFirst();
newObject->bmc = reader->ReadUInt16(); //0x0100
newObject->lTag = reader->ReadUInt32();
unsigned int lTagOld = reader->ReadUInt32();
return static_cast<ByteStructure*>( newObject );
}
};
}

View File

@ -75,7 +75,7 @@ namespace DocFileFormat
convertSprms( dynamic_cast<CharacterPropertyExceptions*>( chpx )->grpprl, _rPr );
// apend revision changes
if (_revisionData->Type == Changed)
if ((_revisionData) && (_revisionData->Type == Changed))
{
XMLTools::XMLElement rPrChange( L"w:rPrChange");

View File

@ -52,8 +52,6 @@ namespace DocFileFormat
{
m_context->_docx->RegisterComments();
int index = 0;
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
m_pXmlWriter->WriteNodeBegin( L"w:comments", TRUE );
@ -63,33 +61,60 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute( L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute( L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute( L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" );
m_pXmlWriter->WriteAttribute( L"xmlns:cx", L"http://schemas.microsoft.com/office/drawing/2014/chartex" );
m_pXmlWriter->WriteAttribute( L"xmlns:cx1", L"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" );
m_pXmlWriter->WriteAttribute( L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006" );
m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" );
m_pXmlWriter->WriteAttribute( L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" );
m_pXmlWriter->WriteAttribute( L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" );
m_pXmlWriter->WriteAttribute( L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:w15", L"http://schemas.microsoft.com/office/word/2012/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:w16se", L"http://schemas.microsoft.com/office/word/2015/wordml/symex" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk" );
m_pXmlWriter->WriteAttribute( L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape" );
m_pXmlWriter->WriteAttribute( L"mc:Ignorable", L"w14 w15 w16se wp14");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
int cp = m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn + m_document->FIB->m_RgLw97.ccpHdr;
size_t count = m_document->AnnotationsReferencePlex->Elements.size();
for (size_t i = 0; i < count; ++i)
for (size_t index = 0; index < count; ++index)
{
AnnotationReferenceDescriptor* atrdPre10 = static_cast<AnnotationReferenceDescriptor*>(m_document->AnnotationsReferencePlex->Elements[index]);
AnnotationReferenceExDescriptor* atrdPost10 = m_document->AnnotationsReferenceExPlex ? static_cast<AnnotationReferenceExDescriptor*>(m_document->AnnotationsReferenceExPlex->Elements[index]) : NULL;
unsigned short index_author = atrdPre10->GetAuthorIndex();
m_pXmlWriter->WriteNodeBegin( L"w:comment", TRUE );
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 ));
if (index_author < m_document->AnnotationOwners->size()) //conv_253l2H1CehgKwsxCtNk__docx.doc
if (atrdPre10->m_BookmarkId < 0)
{
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 + count + 1024 ));
}
else
{
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 ));
}
if (atrdPost10)
{
//!!!TODO!!!
/*//ATRDpost10 is optional and not saved in all files
if (doc.AnnotationReferenceExtraTable != null &&
doc.AnnotationReferenceExtraTable.Count > index)
{
AnnotationReferenceDescriptorExtra atrdPost10 = doc.AnnotationReferenceExtraTable[index];
atrdPost10.Date.Convert(new DateMapping(_writer));
}*/
}
if (atrdPre10->m_AuthorIndex < m_document->AnnotationOwners->size()) //conv_253l2H1CehgKwsxCtNk__docx.doc
{
m_pXmlWriter->WriteAttribute( L"w:author",
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( index_author ) ));
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->m_AuthorIndex ) ));
}
m_pXmlWriter->WriteAttribute( L"w:initials", atrdPre10->GetUserInitials());
m_pXmlWriter->WriteAttribute( L"w:initials", atrdPre10->m_UserInitials);
//!!!TODO!!!
/*//ATRDpost10 is optional and not saved in all files
if (doc.AnnotationReferenceExtraTable != null &&
doc.AnnotationReferenceExtraTable.Count > index)
{
AnnotationReferenceDescriptorExtra atrdPost10 = doc.AnnotationReferenceExtraTable[index];
atrdPost10.Date.Convert(new DateMapping(_writer));
}*/
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
@ -116,8 +141,6 @@ namespace DocFileFormat
}
m_pXmlWriter->WriteNodeEnd(L"w:comment" );
++index;
}
m_pXmlWriter->WriteNodeEnd( L"w:comments" );

View File

@ -61,7 +61,7 @@ namespace DocFileFormat
namespace DocFileFormat
{
long Converter::Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress)
_UINT32 Converter::Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress)
{
if (!doc || !docx) return S_FALSE;
@ -202,20 +202,18 @@ namespace DocFileFormat
return S_OK;
}
long Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress, bool &bMacros)
_UINT32 Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress, bool &bMacros)
{
long result = S_FALSE;
WordDocument doc(progress, m_sTempFolder);
WordprocessingDocument docx(strDstDirectory, &doc);
result = doc.LoadDocument(strSrcFile, password);
_UINT32 result = doc.LoadDocument(strSrcFile, password);
if (result == S_OK)
if (result == 0)
{
result = Convert(&doc, &docx, progress);
if (result == S_OK)
if (result == 0)
{
docx.SaveDocument(bMacros);

View File

@ -32,6 +32,7 @@
#pragma once
#include <string>
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
struct ProgressCallback;
@ -48,9 +49,9 @@ namespace DocFileFormat
std::wstring m_sTempFolder;
long LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, const ProgressCallback* progress, bool &bMacros);
_UINT32 LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, const ProgressCallback* progress, bool &bMacros);
private:
long Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress);
_UINT32 Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress);
};
}

View File

@ -45,7 +45,7 @@ namespace DocFileFormat
{
DocumentMapping::DocumentMapping(ConversionContext* context, IMapping* caller) : _skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL),
AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() ), _sectionNr(0), _footnoteNr(0),
_endnoteNr(0), _commentNr(0), _caller(caller)
_endnoteNr(0), _commentNr(1), _caller(caller)
{
m_document = NULL;
m_context = context;
@ -484,6 +484,266 @@ namespace DocFileFormat
return result_cp;
}
void DocumentMapping::writeField(const std::wstring& sFieldString, int cpFieldStart, int cpFieldEnd)
{
_fieldLevels.push_back(fieldLevels());
std::vector<std::wstring> arField;
boost::algorithm::split(arField, sFieldString, boost::algorithm::is_any_of(L"\\"), boost::algorithm::token_compress_on);
std::wstring f;
std::wstring EMBED ( L"EMBED" );
std::wstring embed ( L"embed" );
std::wstring LINK ( L"LINK" );
std::wstring FORM ( L"FORM" );
std::wstring Excel ( L"Excel" );
std::wstring Word ( L"Word" );
std::wstring opendocument(L"opendocument" );
std::wstring Equation ( L"Equation" );
std::wstring MERGEFORMAT( L"MERGEFORMAT" );
std::wstring QUOTE ( L"QUOTE" );
std::wstring chart ( L"Chart" );
std::wstring PBrush ( L"PBrush" );
std::wstring TOC ( L"TOC" );
std::wstring HYPERLINK ( L"HYPERLINK" );
std::wstring PAGEREF ( L"PAGEREF" );
std::wstring PAGE ( L"PAGE" );
std::wstring SHAPE ( L"SHAPE" );
if (arField.empty() == false)
f = arField[0];
else
f = sFieldString;
bool bChart = search( f.begin(), f.end(), chart.begin(), chart.end()) != f.end();
bool bEMBED = search( f.begin(), f.end(), EMBED.begin(), EMBED.end()) != f.end() ||
search( f.begin(), f.end(), embed.begin(), embed.end()) != f.end();
bool bLINK = search( f.begin(), f.end(), LINK.begin(), LINK.end()) != f.end();
bool bOpendocument = search( f.begin(), f.end(), opendocument.begin(), opendocument.end()) != f.end();
bool bFORM = search( f.begin(), f.end(), FORM.begin(), FORM.end()) != f.end();
bool bMERGEFORMAT = search( f.begin(), f.end(), MERGEFORMAT.begin(), MERGEFORMAT.end()) != f.end();
bool bExcel = search( f.begin(), f.end(), Excel.begin(), Excel.end()) != f.end();
bool bWord = search( f.begin(), f.end(), Word.begin(), Word.end()) != f.end();
bool bHYPERLINK = search( f.begin(), f.end(), HYPERLINK.begin(), HYPERLINK.end()) != f.end();
bool bQUOTE = search( f.begin(), f.end(), QUOTE.begin(), QUOTE.end()) != f.end();
bool bEquation = search( f.begin(), f.end(), Equation.begin(), Equation.end()) != f.end();
bool bPAGE = search( f.begin(), f.end(), PAGE.begin(), PAGE.end()) != f.end();
bool bTOC = search( f.begin(), f.end(), TOC.begin(), TOC.end()) != f.end();
bool bSHAPE = search( f.begin(), f.end(), SHAPE.begin(), SHAPE.end()) != f.end();
bool bPAGEREF = false;
if (bHYPERLINK && arField.size() > 1)
{
std::wstring f1 = arField[1];
bPAGEREF = search( f1.begin(), f1.end(), PAGEREF.begin(), PAGEREF.end()) != f1.end();
}
if (bTOC)
_bContentWrite = true;
if ( bFORM )
{
std::wstring FORMTEXT ( L" FORMTEXT" );
std::wstring FORMCHECKBOX ( L" FORMCHECKBOX" );
std::wstring FORMDROPDOWN ( L" FORMDROPDOWN" );
m_pXmlWriter->WriteNodeBegin( L"w:fldChar" , true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType" , L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true, false );
bool bFORMTEXT = search( f.begin(), f.end(), FORMTEXT.begin(), FORMTEXT.end()) != f.end();
bool bFORMCHECKBOX = search( f.begin(), f.end(), FORMCHECKBOX.begin(), FORMCHECKBOX.end()) != f.end();
bool bFORMDROPDOWN = search( f.begin(), f.end(), FORMDROPDOWN.begin(), FORMDROPDOWN.end()) != f.end();
if (bFORMTEXT || bFORMCHECKBOX || bFORMDROPDOWN)
{
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
if (cpPic < cpFieldEnd)
{
int fcPic = m_document->FindFileCharPos( cpPic );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
if (chpxs)
{
CharacterPropertyExceptions* chpxSep = chpxs->front();
FormFieldData ffdata (2, chpxSep, m_document->DataStream, false);
FormFieldDataMapping data_mapping(m_pXmlWriter, m_context, _caller);
ffdata.Convert(&data_mapping);
RELEASEOBJECT( chpxs );
}
}
}
m_pXmlWriter->WriteNodeEnd( L"w:fldChar" );
_fieldLevels.back().bBegin = true;
}
else if ( ( bMERGEFORMAT || bExcel || bWord || bOpendocument )
&&
( ( bEMBED || bLINK ) && bChart) )
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true, false );
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
m_pXmlWriter->WriteNodeEnd( L"w:fldChar" );
_fieldLevels.back().bBegin = true;
}
else if (bHYPERLINK && bPAGEREF)
{
int cpFieldSep2 = cpFieldStart, cpFieldSep1 = cpFieldStart;
std::vector<std::wstring> toc;
if (arField.size() > 1)
f = arField[1];
if ( _bContentWrite )
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true );
_fieldLevels.back().bBegin = true;
}
else
{
for (size_t i = 1; i < arField.size(); i++)
{
std::wstring f1 = arField[1];
int d = (int)f1.find(PAGEREF);
if (d > 0)
{
_writeWebHidden = true;
std::wstring _writeTocLink =f1.substr(d + 9);
d = (int)_writeTocLink.find(L" ");
_writeTocLink = _writeTocLink.substr(0, d);
_writeAfterRun = std::wstring (L"<w:hyperlink w:anchor = \"");
_writeAfterRun += _writeTocLink;
_writeAfterRun += std::wstring (L"\" w:history=\"1\">");
break;
//cp = cpFieldSep1;
}
//cpFieldSep1 = cpFieldSep2;
}
_skipRuns = 5; //with separator
}
}
else if ( bEMBED || (bLINK && !bHYPERLINK)|| bQUOTE)
{
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
if (cpPic < cpFieldEnd)
{
int fcPic = m_document->FindFileCharPos( cpPic );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
CharacterPropertyExceptions* chpxObj = chpxs->front();
RevisionData oData = RevisionData(chpxObj);
CharacterPropertiesMapping* rPr = new CharacterPropertiesMapping(m_pXmlWriter, m_document, &oData, _lastValidPapx, false);
if(rPr)
{
chpxObj->Convert(rPr);
RELEASEOBJECT(rPr);
}
XMLTools::CStringXmlWriter oleWriter;
XMLTools::CStringXmlWriter oleObjectWriter;
VMLPictureMapping oVmlMapper (m_context, &oleWriter, true, _caller);
if (!m_shapeIdOwner.empty()) //4571833.doc
oVmlMapper.m_shapeId = m_shapeIdOwner;
if (m_document->nWordVersion > 0)
{
OleObject ole ( chpxObj, m_document);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dxaGoal + ole.pictureDesciptor.dxaOrigin ) ));
oleWriter.WriteAttribute( L"w:dyaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dyaGoal + ole.pictureDesciptor.dyaOrigin ) ));
oleWriter.WriteNodeEnd( L"", true, false );
ole.pictureDesciptor.Convert(&oVmlMapper);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &ole.pictureDesciptor, _caller, oVmlMapper.m_shapeId);
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
}
else
{
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->nWordVersion);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( pic.dxaGoal + pic.dxaOrigin ) ) );
oleWriter.WriteAttribute( L"w:dyaOrig", FormatUtils::IntToWideString( ( pic.dyaGoal + pic.dyaOrigin ) ) );
oleWriter.WriteNodeEnd( L"", true, false );
pic.Convert(&oVmlMapper);
RELEASEOBJECT(chpxs);
if ( cpFieldSep < cpFieldEnd && m_document->m_PieceTable)
{
int fcFieldSep = m_document->m_PieceTable->FileCharacterPositions->operator []( cpFieldSep );
int fcFieldSep1 = m_document->FindFileCharPos( cpFieldSep );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcFieldSep, ( fcFieldSep + 1 ) );
CharacterPropertyExceptions* chpxSep = chpxs->front();
OleObject ole ( chpxSep, m_document);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &pic, _caller, oVmlMapper.m_shapeId );
if (oVmlMapper.m_isEmbedded)
{
ole.isEquation = oVmlMapper.m_isEquation;
ole.isEmbedded = oVmlMapper.m_isEmbedded;
ole.emeddedData = oVmlMapper.m_embeddedData;
}
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
RELEASEOBJECT( chpxs );
}
}
oleWriter.WriteString( _lastOLEObject );
oleWriter.WriteNodeEnd( L"w:object" );
if (!oVmlMapper.m_isEmbedded && oVmlMapper.m_isEquation)
{
//нельзя в Run писать oMath
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml);
_writeAfterRun = oVmlMapper.m_equationXml;
}
else
{
m_pXmlWriter->WriteString(oleWriter.GetXmlString());
}
}
_skipRuns = 3;
_embeddedObject = true;
}
else
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true );
_fieldLevels.back().bBegin = true;
}
}
// Writes the given text to the document
int DocumentMapping::writeText(std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText)
{
@ -506,7 +766,7 @@ namespace DocFileFormat
}
//write text
for (unsigned int i = 0; i < chars->size(); ++i)
for (size_t i = 0; i < chars->size(); ++i)
{
wchar_t c = chars->at(i), code = c;
@ -526,7 +786,20 @@ namespace DocFileFormat
text.clear();
XMLTools::XMLElement elem(L"w:br");
if (textType == L"instrText")
{
m_pXmlWriter->WriteNodeEnd(L"w:r");
m_pXmlWriter->WriteNodeBegin(L"w:r");
CharacterPropertiesMapping* rPr = new CharacterPropertiesMapping(m_pXmlWriter, m_document, NULL, _lastValidPapx, false);
if (rPr)
{
rPr->_webHidden = _writeWebHidden;
chpx->Convert(rPr);
RELEASEOBJECT(rPr);
}
}
XMLTools::XMLElement elem(L"w:br");
elem.AppendAttribute(L"w:type", L"textWrapping");
elem.AppendAttribute(L"w:clear", L"all");
@ -563,287 +836,15 @@ namespace DocFileFormat
}
else if (TextMark::FieldBeginMark == code)
{
_fieldLevels.push_back(fieldLevels());
int cpFieldStart = initialCp + i;
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
std::wstring f, sFieldString;
std::wstring sFieldString;
if (cpFieldEnd < (int)m_document->Text->size())
sFieldString = std::wstring( ( m_document->Text->begin() + cpFieldStart ), ( m_document->Text->begin() + cpFieldEnd + 1 ) );
std::vector<std::wstring> arField;
boost::algorithm::split(arField, sFieldString, boost::algorithm::is_any_of(L"\\"), boost::algorithm::token_compress_on);
std::wstring EMBED ( L"EMBED" );
std::wstring embed ( L"embed" );
std::wstring LINK ( L"LINK" );
std::wstring FORM ( L"FORM" );
std::wstring Excel ( L"Excel" );
std::wstring Word ( L"Word" );
std::wstring opendocument(L"opendocument" );
std::wstring Equation ( L"Equation" );
std::wstring MERGEFORMAT( L"MERGEFORMAT" );
std::wstring QUOTE ( L"QUOTE" );
std::wstring chart ( L"Chart" );
std::wstring PBrush ( L"PBrush" );
std::wstring TOC ( L"TOC" );
std::wstring HYPERLINK ( L"HYPERLINK" );
std::wstring PAGEREF ( L"PAGEREF" );
std::wstring PAGE ( L"PAGE" );
writeField(sFieldString, cpFieldStart, cpFieldEnd);
if (arField.empty() == false)
f = arField[0];
else
f = sFieldString;
bool bChart = search( f.begin(), f.end(), chart.begin(), chart.end()) != f.end();
bool bEMBED = search( f.begin(), f.end(), EMBED.begin(), EMBED.end()) != f.end() ||
search( f.begin(), f.end(), embed.begin(), embed.end()) != f.end();
bool bLINK = search( f.begin(), f.end(), LINK.begin(), LINK.end()) != f.end();
bool bOpendocument = search( f.begin(), f.end(), opendocument.begin(), opendocument.end()) != f.end();
bool bFORM = search( f.begin(), f.end(), FORM.begin(), FORM.end()) != f.end();
bool bMERGEFORMAT = search( f.begin(), f.end(), MERGEFORMAT.begin(), MERGEFORMAT.end()) != f.end();
bool bExcel = search( f.begin(), f.end(), Excel.begin(), Excel.end()) != f.end();
bool bWord = search( f.begin(), f.end(), Word.begin(), Word.end()) != f.end();
bool bHYPERLINK = search( f.begin(), f.end(), HYPERLINK.begin(), HYPERLINK.end()) != f.end();
bool bQUOTE = search( f.begin(), f.end(), QUOTE.begin(), QUOTE.end()) != f.end();
bool bEquation = search( f.begin(), f.end(), Equation.begin(), Equation.end()) != f.end();
bool bPAGE = search( f.begin(), f.end(), PAGE.begin(), PAGE.end()) != f.end();
bool bTOC = search( f.begin(), f.end(), TOC.begin(), TOC.end()) != f.end();
bool bPAGEREF = false;
if (bHYPERLINK && arField.size() > 1)
{
std::wstring f1 = arField[1];
bPAGEREF = search( f1.begin(), f1.end(), PAGEREF.begin(), PAGEREF.end()) != f1.end();
}
if (bTOC)
_bContentWrite = true;
if ( bFORM )
{
std::wstring FORMTEXT ( L" FORMTEXT" );
std::wstring FORMCHECKBOX ( L" FORMCHECKBOX" );
std::wstring FORMDROPDOWN ( L" FORMDROPDOWN" );
m_pXmlWriter->WriteNodeBegin( L"w:fldChar" , true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType" , L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true, false );
bool bFORMTEXT = search( f.begin(), f.end(), FORMTEXT.begin(), FORMTEXT.end()) != f.end();
bool bFORMCHECKBOX = search( f.begin(), f.end(), FORMCHECKBOX.begin(), FORMCHECKBOX.end()) != f.end();
bool bFORMDROPDOWN = search( f.begin(), f.end(), FORMDROPDOWN.begin(), FORMDROPDOWN.end()) != f.end();
if (bFORMTEXT || bFORMCHECKBOX || bFORMDROPDOWN)
{
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
if (cpPic < cpFieldEnd)
{
int fcPic = m_document->FindFileCharPos( cpPic );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
if (chpxs)
{
CharacterPropertyExceptions* chpxSep = chpxs->front();
FormFieldData ffdata (2, chpxSep, m_document->DataStream, false);
FormFieldDataMapping data_mapping(m_pXmlWriter, m_context, _caller);
ffdata.Convert(&data_mapping);
RELEASEOBJECT( chpxs );
}
}
}
m_pXmlWriter->WriteNodeEnd( L"w:fldChar" );
_fieldLevels.back().bBegin = true;
}
else if ( ( bMERGEFORMAT || bExcel || bWord || bOpendocument )
&&
( ( bEMBED || bLINK ) && bChart) )
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true, false );
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
m_pXmlWriter->WriteNodeEnd( L"w:fldChar" );
_fieldLevels.back().bBegin = true;
}
else if (bHYPERLINK && bPAGEREF)
{
int cpFieldSep2 = cpFieldStart, cpFieldSep1 = cpFieldStart;
std::vector<std::wstring> toc;
if (arField.size() > 1)
f = arField[1];
if ( _bContentWrite )
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true );
_fieldLevels.back().bBegin = true;
}
else
{
for (size_t i = 1; i < arField.size(); i++)
{
std::wstring f1 = arField[1];
int d = (int)f1.find(PAGEREF);
if (d > 0)
{
_writeWebHidden = true;
std::wstring _writeTocLink =f1.substr(d + 9);
d = (int)_writeTocLink.find(L" ");
_writeTocLink = _writeTocLink.substr(0, d);
_writeAfterRun = std::wstring (L"<w:hyperlink w:anchor = \"");
_writeAfterRun += _writeTocLink;
_writeAfterRun += std::wstring (L"\" w:history=\"1\">");
break;
//cp = cpFieldSep1;
}
//cpFieldSep1 = cpFieldSep2;
}
_skipRuns = 5; //with separator
}
}
//else if ( bHYPERLINK )
//{//todooo - выделение гиперссылки отдельно
// std::vector<std::wstring> arRefs;
// boost::algorithm::split(arRefs, f, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
//
// std::wstring sLink = arRefs[2];
// m_pXmlWriter->WriteNodeBegin( L"w:hyperlink", true );
// int relID = m_context->_docx->RegisterHyperlink(_caller, sLink);
// m_pXmlWriter->WriteAttribute( L"r:id", L"rId"+ FormatUtils::IntToWideString( relID ) );
// m_pXmlWriter->WriteAttribute( L"w:history", 1 );
// m_pXmlWriter->WriteNodeEnd( L"", true, false );
// if (arRefs.size() > 2)
// {
// writeTextElement(arRefs[3].substr(1, arRefs[3].length() - 2), textType);
// }
// m_pXmlWriter->WriteNodeEnd( L"w:hyperlink", false, true );
// _skipRuns = 1;
//}
else if ( bEMBED || (bLINK && !bHYPERLINK)|| bQUOTE)
{
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
if (cpPic < cpFieldEnd)
{
int fcPic = m_document->FindFileCharPos( cpPic );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
CharacterPropertyExceptions* chpxObj = chpxs->front();
RevisionData oData = RevisionData(chpxObj);
CharacterPropertiesMapping* rPr = new CharacterPropertiesMapping(m_pXmlWriter, m_document, &oData, _lastValidPapx, false);
if(rPr)
{
chpxObj->Convert(rPr);
RELEASEOBJECT(rPr);
}
XMLTools::CStringXmlWriter oleWriter;
XMLTools::CStringXmlWriter oleObjectWriter;
VMLPictureMapping oVmlMapper (m_context, &oleWriter, true, _caller);
if (!m_shapeIdOwner.empty()) //4571833.doc
oVmlMapper.m_shapeId = m_shapeIdOwner;
if (m_document->nWordVersion > 0)
{
OleObject ole ( chpxObj, m_document);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dxaGoal + ole.pictureDesciptor.dxaOrigin ) ));
oleWriter.WriteAttribute( L"w:dyaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dyaGoal + ole.pictureDesciptor.dyaOrigin ) ));
oleWriter.WriteNodeEnd( L"", true, false );
ole.pictureDesciptor.Convert(&oVmlMapper);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &ole.pictureDesciptor, _caller, oVmlMapper.m_shapeId);
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
}
else
{
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->nWordVersion);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( pic.dxaGoal + pic.dxaOrigin ) ) );
oleWriter.WriteAttribute( L"w:dyaOrig", FormatUtils::IntToWideString( ( pic.dyaGoal + pic.dyaOrigin ) ) );
oleWriter.WriteNodeEnd( L"", true, false );
pic.Convert(&oVmlMapper);
RELEASEOBJECT(chpxs);
if ( cpFieldSep < cpFieldEnd && m_document->m_PieceTable)
{
int fcFieldSep = m_document->m_PieceTable->FileCharacterPositions->operator []( cpFieldSep );
int fcFieldSep1 = m_document->FindFileCharPos( cpFieldSep );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcFieldSep, ( fcFieldSep + 1 ) );
CharacterPropertyExceptions* chpxSep = chpxs->front();
OleObject ole ( chpxSep, m_document);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &pic, _caller, oVmlMapper.m_shapeId );
if (oVmlMapper.m_isEmbedded)
{
ole.isEquation = oVmlMapper.m_isEquation;
ole.isEmbedded = oVmlMapper.m_isEmbedded;
ole.emeddedData = oVmlMapper.m_embeddedData;
}
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
RELEASEOBJECT( chpxs );
}
}
oleWriter.WriteString( _lastOLEObject );
oleWriter.WriteNodeEnd( L"w:object" );
if (!oVmlMapper.m_isEmbedded && oVmlMapper.m_isEquation)
{
//нельзя в Run писать oMath
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml);
_writeAfterRun = oVmlMapper.m_equationXml;
}
else
{
m_pXmlWriter->WriteString(oleWriter.GetXmlString());
}
}
_skipRuns = 3;
_embeddedObject = true;
}
else
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true );
_fieldLevels.back().bBegin = true;
}
}
else if (TextMark::FieldSeparator == code)
{
@ -916,7 +917,7 @@ namespace DocFileFormat
PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->nWordVersion);
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeContainer(pSpa->GetShapeID());
if (pShape)
if ((pShape) /*&& (false == pShape->isLastIdentify())*/)
{
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, &pictDiscr, _caller);
@ -950,55 +951,64 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd (L"w:pict");
}
else if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer))
else if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer)/* && (false == oPicture.shapeContainer->isLastIdentify())*/)
{
bool bFormula = false;
XMLTools::CStringXmlWriter pictWriter;
pictWriter.WriteNodeBegin (L"w:pict");
bool picture = true;
bool bPicture = true;
bool m_bSkip = false;
if (oPicture.shapeContainer)
{
int shape_type = oPicture.shapeContainer->getShapeType();
if (oPicture.shapeContainer->m_nShapeType != msosptPictureFrame)
bPicture = false;//шаблон 1.doc картинка в колонтитуле
if (shape_type != msosptPictureFrame) picture = false;//шаблон 1.doc картинка в колонтитуле
m_bSkip = oPicture.shapeContainer->m_bSkip;
}
if (picture)
if (!m_bSkip)
{
VMLPictureMapping oVmlMapper(m_context, &pictWriter, false, _caller, isInline);
oPicture.Convert (&oVmlMapper);
if (oVmlMapper.m_isEmbedded)
bool bFormula = false;
XMLTools::CStringXmlWriter pictWriter;
pictWriter.WriteNodeBegin (L"w:pict");
if (bPicture)
{
OleObject ole ( chpx, m_document);
OleObjectMapping oleObjectMapping( &pictWriter, m_context, &oPicture, _caller, oVmlMapper.m_shapeId );
VMLPictureMapping oVmlMapper(m_context, &pictWriter, false, _caller, isInline);
oPicture.Convert (&oVmlMapper);
ole.isEquation = oVmlMapper.m_isEquation;
ole.isEmbedded = oVmlMapper.m_isEmbedded;
ole.emeddedData = oVmlMapper.m_embeddedData;
ole.Convert( &oleObjectMapping );
if (oVmlMapper.m_isEmbedded)
{
OleObject ole ( chpx, m_document);
OleObjectMapping oleObjectMapping( &pictWriter, m_context, &oPicture, _caller, oVmlMapper.m_shapeId );
ole.isEquation = oVmlMapper.m_isEquation;
ole.isEmbedded = oVmlMapper.m_isEmbedded;
ole.emeddedData = oVmlMapper.m_embeddedData;
ole.Convert( &oleObjectMapping );
}
else if (oVmlMapper.m_isEquation)
{
//нельзя в Run писать oMath
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml);
_writeAfterRun = oVmlMapper.m_equationXml;
bFormula = true;
}
else if (oVmlMapper.m_isBlob)
{
_writeAfterRun = oVmlMapper.m_blobXml;
bFormula = true;
}
}
else if (oVmlMapper.m_isEquation)
else
{
//нельзя в Run писать oMath
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml);
_writeAfterRun = oVmlMapper.m_equationXml;
bFormula = true;
VMLShapeMapping oVmlMapper(m_context, &pictWriter, NULL, &oPicture, _caller, isInline);
oPicture.shapeContainer->Convert(&oVmlMapper);
}
}else
{
VMLShapeMapping oVmlMapper(m_context, &pictWriter, NULL, &oPicture, _caller, isInline);
oPicture.shapeContainer->Convert(&oVmlMapper);
}
pictWriter.WriteNodeEnd (L"w:pict");
pictWriter.WriteNodeEnd (L"w:pict");
if (!bFormula)
m_pXmlWriter->WriteString(pictWriter.GetXmlString());
if (!bFormula)
m_pXmlWriter->WriteString(pictWriter.GetXmlString());
}
}
}
@ -1007,6 +1017,11 @@ namespace DocFileFormat
if ((m_document->FootnoteReferenceCharactersPlex != NULL) && (m_document->FootnoteReferenceCharactersPlex->IsCpExists(cp)))
{
m_pXmlWriter->WriteNodeBegin( L"w:footnoteReference", true );
FootnoteDescriptor* desc = dynamic_cast<FootnoteDescriptor*>(m_document->FootnoteReferenceCharactersPlex->Elements[_footnoteNr]);
if (desc && desc->aFtnIdx == 0)
{
m_pXmlWriter->WriteAttribute( L"w:customMarkFollows", L"1");
}
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString(_footnoteNr++ ) );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
@ -1018,6 +1033,11 @@ namespace DocFileFormat
else if ((m_document->EndnoteReferenceCharactersPlex != NULL) && (m_document->EndnoteReferenceCharactersPlex->IsCpExists(cp)))
{
m_pXmlWriter->WriteNodeBegin( L"w:endnoteReference", true );
EndnoteDescriptor* desc = dynamic_cast<EndnoteDescriptor*>(m_document->EndnoteReferenceCharactersPlex->Elements[_endnoteNr]);
if (desc && desc->aEndIdx == 0)
{
m_pXmlWriter->WriteAttribute( L"w:customMarkFollows", L"1");
}
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString(_endnoteNr++ ));
m_pXmlWriter->WriteNodeEnd( L"", true );
}
@ -1035,10 +1055,10 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin( L"w:annotationRef", true );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
else
else if ((m_document->AnnotationsReferencePlex) && (_commentNr <= m_document->AnnotationsReferencePlex->Elements.size()))
{
m_pXmlWriter->WriteNodeBegin( L"w:commentReference", true );
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( _commentNr ));
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( _commentNr++ ));
m_pXmlWriter->WriteNodeEnd( L"", true );
}
}
@ -1049,7 +1069,21 @@ namespace DocFileFormat
cp++;
}
if (std::wstring::npos != text.find(L"EMBED"))
{//если есть мааркер конца поля и маркер замещающей картинки и нету маркера начала
//О реорганизации территориальных органов ПФР с 01.11.2018.doc
int cpFieldStart = initialCp;
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
bool bStartField = _fieldLevels.empty() ? false : (_fieldLevels.back().bBegin && !_fieldLevels.back().bSeparate);
if (cpFieldStart < cpPic && cpPic < cpFieldEnd && !bStartField)
{
writeField(text, cpFieldStart, cpFieldEnd);
text.clear();
}
}
if (!text.empty())
{
//bool preserve_space = (text.find(L"\x20")) != text.npos) ? true : false;
@ -1190,7 +1224,7 @@ namespace DocFileFormat
// add the parts
for (unsigned int i = 0; i < splitIndices->size(); ++i)
for (size_t i = 0; i < splitIndices->size(); ++i)
{
int cch = splitIndices->at( i ) - startIndex;
@ -1319,6 +1353,8 @@ namespace DocFileFormat
{
iTap_current = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize );
}break;
default:
break;
}
}
if (nestingLevel == iTap_current)
@ -1348,6 +1384,8 @@ namespace DocFileFormat
AddBoundary(boundary2, max_boundary, boundaries);
}break;
default:
break;
}
}
}

View File

@ -85,21 +85,17 @@ namespace DocFileFormat
int getCurrentSection (int cp);
//---------------------------------
bool isSectionEnd ( int cp );
// Writes a Paragraph that starts at the given cp and
// ends at the next paragraph end mark or section end mark
int writeParagraph( int cp, int cpEnd );
// Writes a Paragraph that starts at the given cpStart and
// ends at the given cpEnd
int writeParagraph( int initialCp, int cpEnd, bool sectionEnd, bool lastBad = false );
// Writes a Paragraph RSID
void writeParagraphRsid( const ParagraphPropertyExceptions* papx );
// Writes a run with the given characters and CHPX
int writeRun( std::vector<wchar_t>* chars, CharacterPropertyExceptions* chpx, int initialCp );
// Writes the given text to the document
int writeText ( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
int writeText ( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
void writeParagraphRsid ( const ParagraphPropertyExceptions* papx );
void writeTextElement ( const std::wstring& text, const std::wstring& textType );
void writeTextStart ( const std::wstring& textType, bool preserve_space);
void writeTextEnd ( const std::wstring& textType );
void writeField (const std::wstring& sFieldString, int cpFieldStart, int cpFieldEnd);
std::vector<int> searchBookmarks( std::vector<wchar_t>* chars, int initialCp );
std::vector<int> searchAnnot(std::vector<wchar_t>* chars, int initialCp);

View File

@ -37,21 +37,14 @@ namespace DocFileFormat
{
class EndnoteDescriptor: public ByteStructure
{
private:
short aEndIdx;
public:
static const int STRUCTURE_SIZE = 2;
EndnoteDescriptor():
aEndIdx(0)
{
}
EndnoteDescriptor(): aEndIdx(0) {}
virtual ~EndnoteDescriptor()
{
}
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
EndnoteDescriptor *newObject = new EndnoteDescriptor();
@ -60,5 +53,7 @@ namespace DocFileFormat
return static_cast<ByteStructure*>( newObject );
}
short aEndIdx;
};
}

View File

@ -110,7 +110,7 @@ namespace DocFileFormat
typedef struct FibWord2
{
unsigned int Spare = 0;
unsigned char rgwSpare0[3];
unsigned short rgwSpare0[3];
unsigned int fcPlcMcr = 0;
unsigned int lcbPlcMcr = 0;
@ -560,8 +560,7 @@ namespace DocFileFormat
m_FibWord97.fcPlcffndRef = reader.ReadInt32();
m_FibWord97.lcbPlcffndRef = reader.ReadInt32();
m_FibWord97.lcbPlcfandTxt = reader.ReadInt32();//112
m_FibWord97.fcPlcffndTxt = reader.ReadInt32();//112
m_FibWord97.lcbPlcffndTxt = reader.ReadInt32();
m_FibWord97.fcPlcfandRef = reader.ReadInt32();
@ -1313,10 +1312,10 @@ namespace DocFileFormat
flag16 = reader.ReadUInt16(); //10
m_FibBase.fDot = (flag16 & 0x0001) >> 2;
m_FibBase.fGlsy = (flag16 & 0x0002) >> 1;
m_FibBase.fComplex = (flag16 & 0x0004) >> 2;
m_FibBase.fHasPic = (flag16 & 0x0008) >> 3;
m_FibBase.fDot = ((flag16 & 0x0001) >> 2) != 0;
m_FibBase.fGlsy = ((flag16 & 0x0002) >> 1) != 0;
m_FibBase.fComplex = ((flag16 & 0x0004) >> 2) != 0;
m_FibBase.fHasPic = ((flag16 & 0x0008) >> 3) != 0;
m_FibBase.cQuickSaves = (WORD)(((int)flag16 & 0x00F0) >> 4);
m_FibBase.fEncrypted = FormatUtils::BitmaskToBool((int)flag16, 0x0100);
m_FibBase.fWhichTblStm = FormatUtils::BitmaskToBool((int)flag16, 0x0200);

View File

@ -37,21 +37,15 @@ namespace DocFileFormat
{
class FootnoteDescriptor: public ByteStructure
{
private:
short aFtnIdx;
public:
static const int STRUCTURE_SIZE = 2;
FootnoteDescriptor():
aFtnIdx(0)
{
}
FootnoteDescriptor() : aFtnIdx(0) {}
virtual ~FootnoteDescriptor()
{
}
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
FootnoteDescriptor *newObject = new FootnoteDescriptor();
@ -60,5 +54,7 @@ namespace DocFileFormat
return static_cast<ByteStructure*>( newObject );
}
short aFtnIdx;
};
}

View File

@ -63,7 +63,35 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute( L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute( L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute( L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" );
m_pXmlWriter->WriteAttribute( L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
m_pXmlWriter->WriteAttribute( L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute( L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute( L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk" );
m_pXmlWriter->WriteAttribute( L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape" );
m_pXmlWriter->WriteAttribute( L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main" );
m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" );
m_pXmlWriter->WriteAttribute( L"mc:Ignorable", L"w14 wp14" );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
//m_pXmlWriter->WriteNodeBegin( L"w:footnote", TRUE );
//m_pXmlWriter->WriteAttribute( L"w:type", L"separator");
//m_pXmlWriter->WriteAttribute( L"w:id", L"-1");
//m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
//m_pXmlWriter->WriteString(L"<w:p><w:pPr><w:spacing w:lineRule=\"auto\" w:line=\"240\" w:after=\"0\"/></w:pPr><w:r></w:r><w:r><w:separator/></w:r></w:p>");
//m_pXmlWriter->WriteNodeEnd( L"w:footnote");
//m_pXmlWriter->WriteNodeBegin( L"w:footnote", TRUE );
//m_pXmlWriter->WriteAttribute( L"w:type", L"continuationSeparator");
//m_pXmlWriter->WriteAttribute( L"w:id", L"0");
//m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
//m_pXmlWriter->WriteString(L"<w:p><w:pPr><w:spacing w:lineRule=\"auto\" w:line=\"240\" w:after=\"0\"/></w:pPr><w:r></w:r><w:r><w:continuationSeparator/></w:r></w:p>");
//m_pXmlWriter->WriteNodeEnd( L"w:footnote");
int cp = m_document->FIB->m_RgLw97.ccpText;

View File

@ -46,7 +46,7 @@ std::wstring readXstz(VirtualStreamReader *reader)
std::wstring ret;
if (cch > 0)
if (cch > 0 && cch < 0x0fff)
{
std::shared_ptr<unsigned char>data = std::shared_ptr<unsigned char>(reader->ReadBytes(cch * 2, true));
#if defined(_WIN32) || defined(_WIN64)
@ -134,6 +134,8 @@ FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx,
bNilPICFAndBinData = true; // or bPICFAndOfficeArtData - shape, pic, ole
}
break;
default:
break;
}
}

View File

@ -32,6 +32,8 @@
#include "ListData.h"
#include <boost/make_shared.hpp>
#include <algorithm>
#include <functional>
#include <cctype>
@ -46,6 +48,11 @@ namespace DocFileFormat
RELEASEOBJECT(rglvl);
}
ListDataPtr ListData::create(VirtualStreamReader* reader, int length)
{
return boost::make_shared<ListData>(reader, length);
}
// Parses the StreamReader to retrieve a ListData
ListData::ListData(VirtualStreamReader* reader, int length) : rglvl(NULL)
@ -80,9 +87,85 @@ namespace DocFileFormat
grfhic = reader->ReadByte();
}
NumberingDescriptorPtr NumberingDescriptor::create(unsigned char * data, int length)
{
return boost::make_shared<NumberingDescriptor>(data, length);
}
bool NumberingDescriptor::operator == (const NumberingDescriptor & val) const
{
const bool res =
nfc == val.nfc &&
cbTextBefore == val.cbTextBefore &&
cbTextAfter == val.cbTextAfter &&
jc == val.jc &&
fPrev == val.fPrev &&
fHang == val.fHang &&
fSetBold == val.fSetBold &&
fSetItalic == val.fSetItalic &&
fSetSmallCaps == val.fSetSmallCaps &&
fSetCaps == val.fSetCaps &&
fSetStrike == val.fSetStrike &&
fSetKul == val.fSetKul &&
fPrevSpace == val.fPrevSpace &&
fBold == val.fBold &&
fItalic == val.fItalic &&
fSmallCaps == val.fSmallCaps &&
fCaps == val.fCaps &&
fStrike == val.fStrike &&
kul == val.kul &&
ico == val.ico &&
ftc == val.ftc &&
hps == val.hps &&
iStartAt == val.iStartAt &&
dxaIndent == val.dxaIndent &&
dxaSpace == val.dxaSpace &&
fNumber1 == val.fNumber1 &&
fNumberAcross == val.fNumberAcross &&
fRestartHdn == val.fRestartHdn &&
fSpareX == val.fSpareX;
return res;
}
bool NumberingDescriptor::operator == (const NumberingDescriptorPtr & val) const
{
if (!val) return false;
const bool res =
nfc == val->nfc &&
cbTextBefore == val->cbTextBefore &&
cbTextAfter == val->cbTextAfter &&
jc == val->jc &&
fPrev == val->fPrev &&
fHang == val->fHang &&
fSetBold == val->fSetBold &&
fSetItalic == val->fSetItalic &&
fSetSmallCaps == val->fSetSmallCaps &&
fSetCaps == val->fSetCaps &&
fSetStrike == val->fSetStrike &&
fSetKul == val->fSetKul &&
fPrevSpace == val->fPrevSpace &&
fBold == val->fBold &&
fItalic == val->fItalic &&
fSmallCaps == val->fSmallCaps &&
fCaps == val->fCaps &&
fStrike == val->fStrike &&
kul == val->kul &&
ico == val->ico &&
ftc == val->ftc &&
hps == val->hps &&
iStartAt == val->iStartAt &&
dxaIndent == val->dxaIndent &&
dxaSpace == val->dxaSpace &&
fNumber1 == val->fNumber1 &&
fNumberAcross == val->fNumberAcross &&
fRestartHdn == val->fRestartHdn &&
fSpareX == val->fSpareX;
return res;
}
NumberingDescriptor::NumberingDescriptor( unsigned char * data, int length )
{
id = 0;
nfc = FormatUtils::BytesToUChar(data, 0, length);
cbTextBefore = FormatUtils::BytesToUChar(data, 1, length);
cbTextAfter = FormatUtils::BytesToUChar(data, 2, length);

View File

@ -36,6 +36,9 @@
namespace DocFileFormat
{
class ListData;
typedef class boost::shared_ptr<ListData> ListDataPtr;
class ListData
{
friend class ListTable;
@ -74,15 +77,20 @@ namespace DocFileFormat
virtual ~ListData();
ListData( VirtualStreamReader* reader, int length );
static ListDataPtr create(VirtualStreamReader* reader, int length);
};
class NumberingDescriptor;
typedef class boost::shared_ptr<NumberingDescriptor> NumberingDescriptorPtr;
class NumberingDescriptor : public IVisitable
{
friend class ListTable;
friend class NumberingMapping;
private:
size_t id;
unsigned char nfc;
unsigned char cbTextBefore;
unsigned char cbTextAfter;
@ -121,9 +129,15 @@ namespace DocFileFormat
std::wstring xst; //32 chars ansi
public:
bool operator == (const NumberingDescriptor & val) const;
bool operator == (const NumberingDescriptorPtr & val) const;
virtual ~NumberingDescriptor(){}
// Parses the given StreamReader to retrieve a ANLD struct
NumberingDescriptor( unsigned char * data, int length ); //cbANLD (count of bytes of ANLD) is 52
static NumberingDescriptorPtr create(unsigned char * data, int length);
};

View File

@ -38,7 +38,6 @@ namespace DocFileFormat
{
ListTable::~ListTable()
{
for_each( this->listData.begin(), this->listData.end(), DeleteDynamicObject() );
}
ListTable::ListTable( FileInformationBlock* fib, POLE::Stream* tableStream )
@ -59,23 +58,32 @@ namespace DocFileFormat
//read the LSTF structs
for ( int i = 0; i < count; i++ )
{
listData.push_back( new ListData( &reader, ListData::VARIABLE_LENGTH ) );
listData.push_back( ListData::create( &reader, ListData::VARIABLE_LENGTH ) );
}
//read the LVLF structs
for ( std::list<ListData*>::iterator iter = listData.begin(); iter != listData.end(); iter++ )
for ( size_t i = 0; i < listData.size(); ++i)
{
for ( unsigned int j = 0; j < (*iter)->rglvl->size(); j++ )
for ( size_t j = 0; j < listData[i]->rglvl->size(); j++ )
{
(*iter)->rglvl->operator []( j ) = new ListLevel( &reader, ListData::VARIABLE_LENGTH );
listData[i]->rglvl->operator []( j ) = new ListLevel( &reader, ListData::VARIABLE_LENGTH );
}
}
}
}
void ListTable::appendNumbering( const NumberingDescriptor & desc )
size_t ListTable::appendNumbering( NumberingDescriptorPtr &desc )
{
for (size_t i = 0; i < listNumbering.size(); ++i)
{
if (listNumbering[i]->operator==(desc))
{
return listNumbering[i]->id;
}
}
desc->id = listData.size() + listNumbering.size()/* + 1*/;
listNumbering.push_back(desc);
return desc->id;
}
}

View File

@ -41,12 +41,12 @@ namespace DocFileFormat
class ListTable: public IVisitable
{
public:
std::list<ListData*> listData;
std::list<NumberingDescriptor> listNumbering;
std::vector<ListDataPtr> listData;
std::vector<NumberingDescriptorPtr> listNumbering;
virtual ~ListTable();
ListTable( FileInformationBlock* fib, POLE::Stream* tableStream );
void appendNumbering( const NumberingDescriptor & desc );
size_t appendNumbering( NumberingDescriptorPtr &desc );
};
}

View File

@ -31,6 +31,7 @@
*/
#include "MainDocumentMapping.h"
#include "OfficeDrawing/FillStyleBooleanProperties.h"
namespace DocFileFormat
{
@ -59,35 +60,51 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute(L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteAttribute(L"xmlns:v", OpenXmlNamespaces::VectorML );
m_pXmlWriter->WriteAttribute(L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute(L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute(L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute(L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute(L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
//m_pXmlWriter->WriteAttribute(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
//m_pXmlWriter->WriteAttribute(L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
//m_pXmlWriter->WriteAttribute(L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
//m_pXmlWriter->WriteAttribute(L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
//m_pXmlWriter->WriteAttribute(L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml");
//m_pXmlWriter->WriteAttribute(L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
//m_pXmlWriter->WriteAttribute(L"mc:Ignorable", L"w14 wp14");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteAttribute(L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
m_pXmlWriter->WriteAttribute(L"xmlns:cx", L"http://schemas.microsoft.com/office/drawing/2014/chartex");
m_pXmlWriter->WriteAttribute(L"xmlns:cx1", L"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex");
m_pXmlWriter->WriteAttribute(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
m_pXmlWriter->WriteAttribute(L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute(L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute(L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml");
m_pXmlWriter->WriteAttribute(L"xmlns:w15", L"http://schemas.microsoft.com/office/word/2012/wordml");
m_pXmlWriter->WriteAttribute(L"xmlns:w16se", L"http://schemas.microsoft.com/office/word/2015/wordml/symex");
m_pXmlWriter->WriteAttribute(L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
m_pXmlWriter->WriteAttribute(L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
m_pXmlWriter->WriteAttribute(L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml");
m_pXmlWriter->WriteAttribute(L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
m_pXmlWriter->WriteAttribute(L"mc:Ignorable", L"w14 w15 w16se wp14");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
if ((m_document->GetOfficeArt()) && (m_document->GetOfficeArt()->GetShapeBackgound()))
{
bool bFilled = true;
m_document->DocProperties->bDisplayBackgroundShape = true;
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeBackgound();
m_pXmlWriter->WriteNodeBegin ( L"w:background", TRUE);
m_pXmlWriter->WriteAttribute ( L"w:color", L"FFFFFF");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, NULL, NULL, _caller);
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (L"w:background");
OptionEntryPtr boolFill = pShape->ExtractOption(fillStyleBooleanProperties);
FillStyleBooleanProperties booleans(boolFill ? boolFill->op : 0);
if (booleans.fUsefFilled && !booleans.fFilled)
{
bFilled = false;
}
if (bFilled)
{
m_pXmlWriter->WriteNodeBegin ( L"w:background", TRUE);
m_pXmlWriter->WriteAttribute ( L"w:color", L"FFFFFF");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, NULL, NULL, _caller);
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (L"w:background");
}
}
m_pXmlWriter->WriteNodeBegin( L"w:body", FALSE );

View File

@ -78,7 +78,14 @@ public:
return rdUShort;
}
void WriteUInt16(unsigned short val)
{
if (m_Data)
{
((unsigned short *)(m_Data + m_Position))[0] = val;
m_Position += sizeof(unsigned short);
}
}
virtual short ReadInt16()
{
short rdShort = 0;
@ -104,7 +111,14 @@ public:
return rdInt;
}
void WriteInt32(_INT32 val)
{
if (m_Data)
{
((_INT32 *)(m_Data + m_Position))[0] = val;
m_Position += sizeof(_INT32);
}
}
virtual unsigned int ReadUInt32()
{
int rdUInt = 0;
@ -117,7 +131,22 @@ public:
return rdUInt;
}
void WriteByte(unsigned char val)
{
if (m_Data)
{
m_Data[m_Position] = val;
m_Position += 1;
}
}
void WriteUInt32(_UINT32 val)
{
if (m_Data)
{
((_UINT32 *)(m_Data + m_Position))[0] = val;
m_Position += sizeof(_UINT32);
}
}
virtual unsigned char ReadByte()
{
unsigned char rdByte = 0;
@ -159,6 +188,14 @@ public:
return pBytes;
}
void WriteBytes(unsigned char* pData, int size)
{
if (m_Data)
{
memcpy(m_Data + m_Position, pData, size);
m_Position += size;
}
}
virtual unsigned long GetPosition() const
{
@ -172,7 +209,7 @@ public:
virtual int Seek (int offset, int origin = 0/*STREAM_SEEK_SET*/)
{
if ( (m_Data != NULL) && (offset > 0) && ((unsigned int)offset < m_Size) )
if ( (m_Data != NULL) && (offset >= 0) && ((unsigned int)offset < m_Size) )
return m_Position = offset;
return 0;
@ -180,7 +217,7 @@ public:
private:
unsigned char* m_Data;
unsigned char* m_Data;
unsigned long m_Size;
unsigned long m_Position;
bool bMemoryCopy;

View File

@ -72,33 +72,42 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute( L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute( L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute( L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" );
m_pXmlWriter->WriteAttribute( L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
m_pXmlWriter->WriteAttribute( L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute( L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute( L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk" );
m_pXmlWriter->WriteAttribute( L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape" );
m_pXmlWriter->WriteAttribute( L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main" );
m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" );
m_pXmlWriter->WriteAttribute( L"mc:Ignorable", L"w14 wp14" );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
PictureBulletsMapping();
int i = 0;
for (std::list<ListData*>::iterator iter = rglst->listData.begin(); iter != rglst->listData.end(); ++iter, ++i)
for (size_t i = 0; i < rglst->listData.size(); ++i)
{
//start abstractNum
m_pXmlWriter->WriteNodeBegin( L"w:abstractNum", TRUE );
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::IntToWideString( i ));
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::IntToWideString( i /*+ 1 */));
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
//nsid
m_pXmlWriter->WriteNodeBegin( L"w:nsid", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( (*iter)->lsid, L"%08x" ));
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( rglst->listData[i]->lsid, L"%08x" ));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
//multiLevelType
m_pXmlWriter->WriteNodeBegin( L"w:multiLevelType", TRUE );
if ( (*iter)->fHybrid )
if ( rglst->listData[i]->fHybrid )
{
m_pXmlWriter->WriteAttribute( L"w:val", L"hybridMultilevel" );
}
else if ( (*iter)->fSimpleList )
else if ( rglst->listData[i]->fSimpleList )
{
m_pXmlWriter->WriteAttribute( L"w:val", L"singleLevel" );
}
@ -111,32 +120,32 @@ namespace DocFileFormat
//template
m_pXmlWriter->WriteNodeBegin( L"w:tmpl", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( (*iter)->tplc, L"%08x"));
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( rglst->listData[i]->tplc, L"%08x"));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
// writes the levels
size_t length = (*iter)->rglvl->size();
size_t length = rglst->listData[i]->rglvl->size();
for (size_t j = 0; j < length; ++j)
{
ListLevel* lvl = (*iter)->rglvl->at(j);
LevelMapping(lvl, j, (*iter)->rgistd[j]);
ListLevel* lvl = rglst->listData[i]->rglvl->at(j);
LevelMapping(lvl, j, rglst->listData[i]->rgistd[j]);
}
//end abstractNum
m_pXmlWriter->WriteNodeEnd( L"w:abstractNum" );
}
//write old style numbering (сложносоставных не сущестует)
for (std::list<NumberingDescriptor>::iterator iter = rglst->listNumbering.begin(); iter != rglst->listNumbering.end(); ++iter, ++i)
for (size_t i = 0; i < rglst->listNumbering.size(); ++i)
{
//start abstractNum
m_pXmlWriter->WriteNodeBegin( L"w:abstractNum", TRUE );
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::IntToWideString( i ));
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::IntToWideString( rglst->listNumbering[i]->id ));
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
////nsid
//m_pXmlWriter->WriteNodeBegin( L"w:nsid", TRUE );
//m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( (*iter)->lsid, L"%08x" ) ));
//m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( rglst->listNumbering[i]->lsid, L"%08x" ) ));
//m_pXmlWriter->WriteNodeEnd( L"", TRUE );
//multiLevelType
@ -147,14 +156,14 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
LevelMapping(*iter, 0);
LevelMapping(rglst->listNumbering[i], 0);
//end abstractNum
m_pXmlWriter->WriteNodeEnd( L"w:abstractNum" );
}
//write the overrides
for (unsigned int i = 0; i < m_document->listFormatOverrideTable->size(); ++i)
for (size_t i = 0; i < m_document->listFormatOverrideTable->size(); ++i)
{
ListFormatOverride* lfo = m_document->listFormatOverrideTable->at(i);
@ -193,16 +202,15 @@ namespace DocFileFormat
if (m_document->listFormatOverrideTable->empty() && !rglst->listNumbering.empty())
{
i = 0;
for (std::list<NumberingDescriptor>::iterator iter = rglst->listNumbering.begin(); iter != rglst->listNumbering.end(); ++iter, ++i)
for (size_t i = 0; i < rglst->listNumbering.size(); ++i)
{
m_pXmlWriter->WriteNodeBegin( L"w:num", TRUE );
m_pXmlWriter->WriteAttribute( L"w:numId", FormatUtils::IntToWideString(i+1));
m_pXmlWriter->WriteAttribute( L"w:numId", FormatUtils::IntToWideString(rglst->listNumbering[i]->id));
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeBegin( L"w:abstractNumId", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToWideString( i ));
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToWideString( rglst->listNumbering[i]->id ));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
m_pXmlWriter->WriteNodeEnd(L"w:num");
@ -215,21 +223,20 @@ namespace DocFileFormat
}
}
int NumberingMapping::FindIndexbyId(const std::list<ListData*>& listData, int id)
int NumberingMapping::FindIndexbyId(std::vector<ListDataPtr>& listData, int lsid)
{
int ret = -1;
int i = 0;
for (std::list<ListData*>::const_iterator iter = listData.begin(); iter != listData.end(); ++iter, ++i)
for (size_t i = 0; i < listData.size(); ++i)
{
if ((*iter)->lsid == id)
if (listData[i]->lsid == lsid)
{
ret = i;
break;
return i;
}
}
return ret;
return -1;
}
// Converts the number text of the binary format to the number text of OOXML.
@ -288,15 +295,17 @@ namespace DocFileFormat
return ret;
}
std::wstring NumberingMapping::GetLvlText(const NumberingDescriptor& lvl, bool bIsSymbol, int Before, int After) const
std::wstring NumberingMapping::GetLvlText(NumberingDescriptorPtr& lvl, bool bIsSymbol, int Before, int After) const
{
if (!lvl)return L"";
std::wstring ret;
if (lvl.nfc == 0xff)
if (lvl->nfc == 0xff)
{
if (!lvl.xst.empty())
if (!lvl->xst.empty())
{
wchar_t xchBullet = lvl.xst[0];
wchar_t xchBullet = lvl->xst[0];
// В символьном шрифте обрезать надо, в других случаях - нет
if (bIsSymbol && (xchBullet & 0xF000) != 0)
@ -306,7 +315,7 @@ namespace DocFileFormat
if (!FormatUtils::IsControlSymbol(xchBullet))
{
ret.push_back(lvl.xst[0]);
ret.push_back(lvl->xst[0]);
}
}
else
@ -316,8 +325,8 @@ namespace DocFileFormat
}
else
{
std::wstring strBefore = lvl.xst.substr(0, Before);
std::wstring strAfter = lvl.xst.substr(Before, After);
std::wstring strBefore = lvl->xst.substr(0, Before);
std::wstring strAfter = lvl->xst.substr(Before, After);
ret = strBefore + L"%1" + strAfter ;
}
@ -473,14 +482,16 @@ namespace DocFileFormat
}
}
void NumberingMapping::LevelMapping(const NumberingDescriptor& lvl, unsigned int level)
void NumberingMapping::LevelMapping(NumberingDescriptorPtr & lvl, unsigned int level)
{
if (!lvl) return;
std::wstring fontFamily;
bool isSymbol = false;
if( lvl.ftc < m_document->FontTable->Data.size() )
if( lvl->ftc < m_document->FontTable->Data.size() )
{
FontFamilyName* ffn = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( lvl.ftc ) );
FontFamilyName* ffn = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( lvl->ftc ) );
isSymbol = (ffn->chs == 2);
fontFamily = FormatUtils::XmlEncode(ffn->xszFtn);
}
@ -491,22 +502,22 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeBegin( L"w:start", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToWideString(lvl.iStartAt));
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToWideString(lvl->iStartAt));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
m_pXmlWriter->WriteNodeBegin( L"w:numFmt", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", GetNumberFormatWideString(lvl.nfc, true));
m_pXmlWriter->WriteAttribute( L"w:val", GetNumberFormatWideString(lvl->nfc, true));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
//// suffix
// m_pXmlWriter->WriteNodeBegin( L"w:suff", TRUE );
// m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::MapValueToWideString(lvl.ixchFollow, &FollowingCharMap[0][0], 3, 8));
// m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::MapValueToWideString(lvl->ixchFollow, &FollowingCharMap[0][0], 3, 8));
// m_pXmlWriter->WriteNodeEnd( L"", TRUE );
// Number level text
std::wstring lvlText = GetLvlText(lvl, isSymbol, lvl.cbTextBefore, lvl.cbTextAfter);
std::wstring lvlText = GetLvlText(lvl, isSymbol, lvl->cbTextBefore, lvl->cbTextAfter);
//if (lvlText.empty() && lvl.ftc == 0)//auto
//if (lvlText.empty() && lvl->ftc == 0)//auto
//{
// lvlText.push_back(L'\xF0B7');
// lvlText.push_back(L'\0');
@ -522,7 +533,7 @@ namespace DocFileFormat
// jc
m_pXmlWriter->WriteNodeBegin( L"w:lvlJc", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::MapValueToWideString(lvl.jc, &LevelJustificationMap[0][0], 3, 7));
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::MapValueToWideString(lvl->jc, &LevelJustificationMap[0][0], 3, 7));
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
// pPr
m_pXmlWriter->WriteNodeBegin( L"w:pPr", FALSE );
@ -686,6 +697,8 @@ namespace DocFileFormat
{
isPictureBullet = FormatUtils::BitmaskToBool(FormatUtils::BytesToUInt16(iter->Arguments, 0, iter->argumentsSize), 0x1);
}break;
default:
break;
}
}

View File

@ -63,7 +63,7 @@ namespace DocFileFormat
NumberingMapping(ConversionContext* ctx);
void Apply(IVisitable* visited);
static int FindIndexbyId(const std::list<ListData*>& listData, int id);
static int FindIndexbyId(std::vector<ListDataPtr>& listData, int id);
/// Converts the number format code of the binary format.
static std::wstring GetNumberFormatWideString(int nfc, int nWordVersion = 0);
@ -73,12 +73,12 @@ namespace DocFileFormat
// Converts the number text of the binary format to the number text of OOXML.
// OOXML uses different placeholders for the numbers.
std::wstring GetLvlText(const ListLevel* lvl, bool bIsSymbol) const;
std::wstring GetLvlText(const NumberingDescriptor& lvl, bool bIsSymbol, int Before, int After) const;
std::wstring GetLvlText(NumberingDescriptorPtr& lvl, bool bIsSymbol, int Before, int After) const;
static bool IsPlaceholder(wchar_t symbol);
void LevelMapping(const ListLevel* lvl, unsigned int level, short styleIndex);
void LevelMapping(const NumberingDescriptor& lvl, unsigned int level);
void LevelMapping(NumberingDescriptorPtr & lvl, unsigned int level);
void PictureBulletsMapping();
void WriteLevelPictureBullet(const CharacterPropertyExceptions* grpprlChpx);

View File

@ -58,7 +58,7 @@ namespace DocFileFormat
public:
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL), m_pBackgroud(NULL)
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL), m_pBackgroud(NULL), m_uLastShapeId(1024)
{
VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_nWordVersion);
@ -79,14 +79,13 @@ namespace DocFileFormat
drawing.dgglbl = (DrawingType)oStearmReader.ReadByte();
drawing.container = static_cast<DrawingContainer*>(RecordFactory::ReadRecord (&oStearmReader, 0));
for (unsigned int i = 0; i < drawing.container->Children.size(); ++i)
for (size_t i = 0; i < drawing.container->Children.size(); ++i)
{
Record* groupChild = drawing.container->Children[i];
if (groupChild)
{
if (GroupContainer::TYPE_CODE_0xF003 == groupChild->TypeCode)
{
// the child is a subgroup
GroupContainer* group = static_cast<GroupContainer*>(groupChild);
if (group)
{
@ -95,17 +94,24 @@ namespace DocFileFormat
}
else if (ShapeContainer::TYPE_CODE_0xF004 == groupChild->TypeCode)
{
// the child is a shape
ShapeContainer* shape = static_cast<ShapeContainer*>(groupChild);
if (shape)
{
shape->Index = i;
if (shape->isBackground())
shape->m_nIndex = (int)i;
if (shape->m_bBackground)
{
m_pBackgroud = shape;
}
}
}
else if (DrawingRecord::TYPE_CODE_0xF008 == groupChild->TypeCode)
{
DrawingRecord* dr = static_cast<DrawingRecord*>(groupChild);
if (dr)
{
m_uLastShapeId = dr->spidCur;
}
}
}
}
@ -134,7 +140,7 @@ namespace DocFileFormat
GroupContainer* group = iter->container->FirstChildWithType<GroupContainer>();
if (group)
{
for (unsigned int i = 1; i < group->Children.size(); ++i)
for (size_t i = 1; i < group->Children.size(); ++i)
{
Record* groupChild = group->Children[i];
@ -183,7 +189,7 @@ namespace DocFileFormat
{
return m_pDrawingGroupData;
}
unsigned int m_uLastShapeId;
private:
ShapeContainer* m_pBackgroud;
DrawingGroup* m_pDrawingGroupData;

View File

@ -40,13 +40,13 @@ namespace DocFileFormat
public:
static const unsigned short TYPE_CODE_0xF010 = 0xF010;
ClientAnchor() : Record(), clientanchor(0)
ClientAnchor() : Record(), value(0)
{
}
ClientAnchor (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance), clientanchor(0)
ClientAnchor (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance), value(0)
{
clientanchor = Reader->ReadInt32();
value = Reader->ReadInt32(); //index PlcfSpa
}
virtual ~ClientAnchor()
@ -58,8 +58,6 @@ namespace DocFileFormat
return new ClientAnchor (_reader, bodySize, typeCode, version, instance);
}
private:
int clientanchor;
unsigned int value;
};
}

View File

@ -38,30 +38,30 @@ namespace DocFileFormat
class DrawingRecord: public Record
{
public:
static const unsigned short TYPE_CODE_0xF008 = 0xF008;
static const unsigned short TYPE_CODE_0xF008 = 0xF008;
unsigned int csp; // The number of shapes in this drawing
int spidCur; // The last MSOSPID given to an SP in this DG
unsigned int csp; // The number of shapes in this drawing
unsigned int spidCur; // The last MSOSPID given to an SP in this DG
DrawingRecord():
Record(), csp(0), spidCur(0)
{
}
DrawingRecord():
Record(), csp(0), spidCur(0)
{
}
DrawingRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ):
Record( _reader, size, typeCode, version, instance )
{
DrawingRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ):
Record( _reader, size, typeCode, version, instance )
{
csp = Reader->ReadUInt32();
spidCur = Reader->ReadInt32();
}
}
virtual ~DrawingRecord()
{
}
virtual ~DrawingRecord()
{
}
virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance )
{
return new DrawingRecord( _reader, bodySize, typeCode, version, instance );
}
virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance )
{
return new DrawingRecord( _reader, bodySize, typeCode, version, instance );
}
};
}

View File

@ -65,7 +65,7 @@ namespace DocFileFormat
{
// the child is a shape
ShapeContainer* shape = static_cast<ShapeContainer*>(groupChild);
shape->Index = i;
shape->m_nIndex = i;
this->Children[i] = shape;
}
}

View File

@ -112,7 +112,7 @@ namespace DocFileFormat
if (lMinF <= point.x)
{
int index = (DWORD)point.x - 0x80000000;
if (index >= 0 && index < guides.size())
if (index >= 0 && index < (int)guides.size())
{
point.x = guides[index].param3;
}
@ -120,7 +120,7 @@ namespace DocFileFormat
if (lMinF <= point.y)
{
int index = (DWORD)point.y - 0x80000000;
if (index >= 0 && index < guides.size())
if (index >= 0 && index < (int)guides.size())
{
point.y = guides[index].param3;
}

View File

@ -50,13 +50,9 @@ namespace DocFileFormat
/*========================================================================================================*/
Record::Record( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance ):
HeaderSize(0), BodySize(0), RawData(NULL), SiblingIdx(0), TypeCode(0), Version(0), Instance(0), Reader(NULL),
HeaderSize(Record::HEADER_SIZE_IN_BYTES), BodySize(bodySize), RawData(NULL), SiblingIdx(0), TypeCode(typeCode), Version(version), Instance(instance), Reader(NULL),
_ParentRecord(NULL)
{
BodySize = bodySize;
TypeCode = typeCode;
Version = version;
Instance = instance;
HeaderSize = Record::HEADER_SIZE_IN_BYTES;
int real_size = _reader->GetSize() - _reader->GetPosition();

View File

@ -76,7 +76,7 @@ namespace DocFileFormat
{
result = pRecord->NewObject (reader, size, typeCode, version, instance);
if (result)
result->SiblingIdx = siblingIdx;
result->SiblingIdx = siblingIdx;
RELEASEOBJECT(pRecord);
}
}

View File

@ -84,11 +84,11 @@ namespace DocFileFormat
{
T* firstChildWithType = NULL;
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
for ( size_t i = 0; i < this->Children.size(); ++i )
{
if ( (*iter != NULL) && (typeid(T) == typeid(**iter)) )
if ( (this->Children[i] != NULL) && (typeid(T) == typeid(*(this->Children[i]))) )
{
firstChildWithType = static_cast<T*>(*iter);
firstChildWithType = static_cast<T*>(this->Children[i]);
break;
}

View File

@ -34,6 +34,7 @@
#include "RegularContainer.h"
#include "ShapeOptions.h"
#include "Shape.h"
#include "ClientAnchor.h"
namespace DocFileFormat
{
@ -42,30 +43,35 @@ namespace DocFileFormat
public:
static const unsigned short TYPE_CODE_0xF004 = 0xF004;
int Index;
int m_nIndex;
unsigned int m_nShapeType;
bool m_bBackground;
bool m_bOLE;
bool m_bSkip;
ShapeContainer():
RegularContainer(), Index(0)
RegularContainer(), m_nIndex(0), m_nShapeType(0), m_bSkip(false), m_bBackground(false), m_bOLE(false)
{
}
ShapeContainer( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ):
RegularContainer( _reader, size, typeCode, version, instance ), Index(0)
ShapeContainer( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ) :
m_bSkip(false), m_bBackground(false), m_bOLE(false), m_nIndex(0), m_nShapeType(0), RegularContainer( _reader, size, typeCode, version, instance )
{
}
int getShapeType()
{
int ret = 0;
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
for ( size_t i = 0; i < this->Children.size(); ++i )
{
Shape* sh = dynamic_cast<Shape*>( *iter );
ClientAnchor *clientAnchor = dynamic_cast<ClientAnchor*>( this->Children[i] );
//if ( (clientAnchor) && (clientAnchor->value == 0x80000000))
// m_bSkip = true; //О реорганизации территориальных органов ПФР с 01.11.2018.doc
Shape* sh = dynamic_cast<Shape*>( this->Children[i] );
if (sh)
{
m_bBackground = sh->fBackground;
m_bOLE = sh->fOleShape;
if (sh->shapeType)
{
return sh->shapeType->GetTypeCode();
m_nShapeType = sh->shapeType->GetTypeCode();
}
else
{
@ -76,44 +82,16 @@ namespace DocFileFormat
{
if (sh_options->OptionsByID.end() != sh_options->OptionsByID.find(Pib))
{
return msosptPictureFrame;
m_nShapeType = msosptPictureFrame;
}
}
}
return 0;
}
}
}
return 0;
}
bool isBackground()
{
int ret = 0;
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
Shape* sh = dynamic_cast<Shape*>( *iter );
if (sh)
{
return sh->fBackground;
}
}
return false;
}
bool isOLE()
{
int ret = 0;
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
Shape* sh = dynamic_cast<Shape*>( *iter );
if (sh)
{
return sh->fOleShape;
}
}
return false;
}
virtual ~ShapeContainer()
{
}
@ -123,14 +101,32 @@ namespace DocFileFormat
return new ShapeContainer( _reader, bodySize, typeCode, version, instance );
}
OptionEntryPtr ExtractOption(const PropertyId & prop) const
{
OptionEntryPtr ret;
for ( size_t i = 0; i < this->Children.size(); ++i )
{
ShapeOptions* opt = dynamic_cast<ShapeOptions*>( this->Children[i] );
if ( opt == NULL ) continue;
std::map<PropertyId, OptionEntryPtr>::iterator pFind = opt->OptionsByID.find(prop);
if (pFind != opt->OptionsByID.end())
{
ret = pFind->second;
}
}
return ret;
}
std::vector<OptionEntryPtr> ExtractOptions() const
{
std::vector<OptionEntryPtr> ret;
//build the list of all option entries of this shape
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
for ( size_t i = 0; i < this->Children.size(); ++i )
{
ShapeOptions* opt = dynamic_cast<ShapeOptions*>( *iter );
ShapeOptions* opt = dynamic_cast<ShapeOptions*>( this->Children[i] );
if ( opt == NULL ) continue;

View File

@ -104,7 +104,7 @@ OleObject::OleObject( const CharacterPropertyExceptions* chpx, WordDocument* doc
szData = szData >> 16;
}
unsigned char* bytes = reader.ReadBytes( szData, true );
if (bytes)
if (bytes && szData < 0xffff)
{
emeddedData = std::string((char*)bytes, szData);
delete []bytes;

View File

@ -422,12 +422,11 @@ namespace DocFileFormat
//numbering
case sprmOldPAnld:
{
NumberingDescriptor desc( iter->Arguments, iter->argumentsSize );
NumberingDescriptorPtr desc = NumberingDescriptor::create( iter->Arguments, iter->argumentsSize );
if (m_document->listTable)
{
m_document->listTable->appendNumbering( desc );
short numId = static_cast<short>(m_document->listTable->listNumbering.size());
unsigned short numId = m_document->listTable->appendNumbering( desc );
appendValueElement( &numPr, L"numId", numId, true );
}
}break;
@ -460,7 +459,8 @@ namespace DocFileFormat
//Todo разобраться с закоментированным кодом
if (NULL != m_document->listTable && false == m_document->listTable->listData.empty())
{
appendValueElement( &numPr, L"numId", FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ), true );
unsigned short numId = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueElement( &numPr, L"numId", numId, true );
}
//check if there is a ilvl reference, if not, check the count of LVLs.
@ -566,14 +566,35 @@ namespace DocFileFormat
case sprmOldPDxaAbs:
case sprmPDxaAbs:
appendValueAttribute( _framePr, L"w:x", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break;
{
unsigned short val = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
switch (val)
{
case 0x0000: break; //left
case 0xfffc: appendValueAttribute( _framePr, L"w:xAlign", L"center"); break;
case 0xfff8: appendValueAttribute( _framePr, L"w:xAlign", L"right"); break;
case 0xfff4: appendValueAttribute( _framePr, L"w:xAlign", L"inside"); break;
case 0xfff0: appendValueAttribute( _framePr, L"w:xAlign", L"outside"); break;
default:
appendValueAttribute( _framePr, L"w:x", (short)val);
}
}break;
case sprmOldPDyaAbs:
case sprmPDyaAbs:
appendValueAttribute( _framePr, L"w:y", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break;
{
unsigned short val = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
switch (val)
{
case 0x0000: break; //inline
case 0xfffc: appendValueAttribute( _framePr, L"w:yAlign", L"top"); break;
case 0xfff8: appendValueAttribute( _framePr, L"w:yAlign", L"center"); break;
case 0xfff4: appendValueAttribute( _framePr, L"w:yAlign", L"bottom"); break;
case 0xfff0: appendValueAttribute( _framePr, L"w:yAlign", L"inside"); break;
case 0xffec: appendValueAttribute( _framePr, L"w:yAlign", L"outside"); break;
default:
appendValueAttribute( _framePr, L"w:y", (short)val );
}
}break;
case sprmPWHeightAbs:
appendValueAttribute( _framePr, L"w:h", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
break;

View File

@ -244,6 +244,8 @@ namespace DocFileFormat
case sprmOldCFData:
case sprmCFData:
break;
default:
break;
}
}

View File

@ -48,6 +48,7 @@ namespace DocFileFormat
std::vector<ByteStructure*> Elements;
bool m_bIsValid;
std::map<int, int> mapCP;
public:
Plex(int structureLength, POLE::Stream* stream, unsigned int fc, unsigned int lcb, int nWordVersion)
: m_bIsValid(false), CP_LENGTH(/*nWordVersion == 2 ? 2 :*/ 4)
@ -77,7 +78,10 @@ namespace DocFileFormat
for (int i = 0; i < (n + 1); ++i)
{
CharacterPositions.push_back(reader.ReadInt32());
int val = reader.ReadInt32();
mapCP.insert(std::make_pair(val, (int)CharacterPositions.size()));
CharacterPositions.push_back(val);
}
// read the n structs
@ -96,9 +100,9 @@ namespace DocFileFormat
~Plex()
{
for (std::vector<ByteStructure*>::iterator iter = Elements.begin(); iter != Elements.end(); ++iter)
for (size_t i = 0; i < Elements.size(); ++i)
{
RELEASEOBJECT(*iter);
RELEASEOBJECT(Elements[i]);
}
}
@ -109,15 +113,14 @@ namespace DocFileFormat
{
int index = -1;
for (int i = 0; i < (int)CharacterPositions.size(); ++i)
std::map<int, int>::iterator pFind = mapCP.find(cp);
if (pFind != mapCP.end())
{
if (CharacterPositions[i] == cp)
{
index = i;
break;
}
index = pFind->second;
}
if ((index >= 0) && (index < (int)Elements.size()))
return this->Elements[index];
@ -128,13 +131,11 @@ namespace DocFileFormat
{
bool result = false;
for (int i = 0; i < (int)CharacterPositions.size(); ++i)
std::map<int, int>::const_iterator pFind = mapCP.find(cp);
if (pFind != mapCP.end())
{
if (CharacterPositions[i] == cp)
{
result = true;
break;
}
result = true;
}
return result;
@ -142,7 +143,7 @@ namespace DocFileFormat
inline int operator [] (unsigned int index) const
{
if (index < CharacterPositions.size())
if (index < (unsigned int)CharacterPositions.size())
return CharacterPositions[index];
return -1;

View File

@ -117,6 +117,8 @@ namespace DocFileFormat
this->RsidDel = FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize );
}
break;
default:
break;
}
//put the sprm on the revision stack

View File

@ -130,6 +130,8 @@ namespace DocFileFormat
appendValueAttribute( &pgBorders, L"w:display", L"notFirstPage" );
}break;
default:
break;
}
}
if (_ctx->_doc->nWordVersion == 2)

View File

@ -32,9 +32,38 @@
#include "SettingsMapping.h"
#include "../../OfficeCryptReader/source/CryptTransform.h"
namespace DocFileFormat
{
std::string DecodeBase64(const std::string & value)
{
int nLength = 0;
unsigned char *pData = NULL;
std::string result;
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
if (pData)
{
result = std::string((char*)pData, nLength);
delete []pData; pData = NULL;
}
return result;
}
std::wstring EncodeBase64(const std::string & value)
{
int nLength = 0;
char *pData = NULL;
std::string result;
NSFile::CBase64Converter::Encode((BYTE*)value.c_str(), value.length(), pData, nLength, NSBase64::B64_BASE64_FLAG_NOCRLF);
if (pData)
{
result = std::string(pData, nLength);
delete []pData; pData = NULL;
}
return std::wstring(result.begin(), result.end());
}
SettingsMapping::SettingsMapping (ConversionContext* ctx): PropertiesMapping(&m_oXmlWriter)
{
_ctx = ctx;
@ -49,11 +78,39 @@ namespace DocFileFormat
//start w:settings
m_oXmlWriter.WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
m_oXmlWriter.WriteNodeBegin( L"w:settings", TRUE );
//write namespaces
m_oXmlWriter.WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_oXmlWriter.WriteNodeEnd( L"", TRUE, FALSE );
if (_ctx->_doc->FIB->m_FibBase.fWriteReservation)
{
m_oXmlWriter.WriteNodeBegin( L"w:writeProtection", TRUE );
WideString* passw = static_cast<WideString*>(_ctx->_doc->AssocNames->operator[]( 17 ));
if (passw && false == passw->empty())
{
CRYPT::_ecmaWriteProtectData data;
CRYPT::ECMAWriteProtect protect;
protect.SetCryptData(data);
protect.SetPassword(*passw);
protect.Generate();
protect.GetCryptData(data);
//m_oXmlWriter.WriteAttribute ( L"w:cryptProviderType", L"rsaAES");
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmSid", 14); //sha-512
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmType", L"typeAny");
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmClass", L"hash");
//m_oXmlWriter.WriteAttribute ( L"w:cryptSpinCount", data.spinCount);
//m_oXmlWriter.WriteAttribute ( L"w:hash", EncodeBase64(data.hashValue));
//m_oXmlWriter.WriteAttribute ( L"w:salt", EncodeBase64(data.saltValue));
m_oXmlWriter.WriteAttribute ( L"w:algorithmName", L"SHA-512");
m_oXmlWriter.WriteAttribute ( L"w:spinCount", data.spinCount);
m_oXmlWriter.WriteAttribute ( L"w:hashValue", EncodeBase64(data.hashValue));
m_oXmlWriter.WriteAttribute ( L"w:saltValue", EncodeBase64(data.saltValue));
}
m_oXmlWriter.WriteNodeEnd( L"", TRUE, TRUE );
}
//zoom
m_oXmlWriter.WriteNodeBegin ( L"w:zoom", TRUE );
m_oXmlWriter.WriteAttribute ( L"w:percent", FormatUtils::IntToWideString( dop->wScaleSaved > 0 ? dop->wScaleSaved : 100 ) );

View File

@ -92,6 +92,8 @@ namespace DocFileFormat
{
iTap_current = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize );
}break;
default:
break;
}
}
std::list<SinglePropertyModifier>::const_reverse_iterator rend = tapx->grpprl->rend();
@ -318,8 +320,22 @@ namespace DocFileFormat
}
}
break;
default:
break;
}
}
if (_gridSpan <= 1 && nComputedCellWidth > _width && _width > 1)
{
int width_current = 0;
for (int i = _gridIndex; i < _grid->size(); i++)
{
width_current += _grid->at(i);
if (width_current >= nComputedCellWidth)
break;
_gridSpan++;
}
_width = nComputedCellWidth;
}
XMLTools::XMLElement tcW ( L"w:tcW" );
@ -333,22 +349,23 @@ namespace DocFileFormat
_tcPr->AppendChild( tcW );
//if ( ( _gridIndex < (int)_grid->size() ) && ( nComputedCellWidth > _grid->at( _gridIndex ) ) )
//{
// //check the number of merged cells
// int w = _grid->at( _gridIndex );
if ( _gridSpan == 1 && ( _gridIndex < (int)_grid->size() ) && ( nComputedCellWidth > _grid->at( _gridIndex ) ) )
{
//check the number of merged cells
int w = _grid->at( _gridIndex );
// for ( size_t i = _gridIndex + 1; i < _grid->size(); i++ )
// {
// _gridSpan++;
for ( size_t i = _gridIndex + 1; i < _grid->size(); i++ )
{
_gridSpan++;
// w += _grid->at( i );
w += _grid->at( i );
// if ( w >= nComputedCellWidth )
// {
// break;
// }
// }
if ( w >= nComputedCellWidth )
{
break;
}
}
}
if (_gridSpan > 1)
{
appendValueElement( _tcPr, L"gridSpan", FormatUtils::IntToWideString( _gridSpan ), true );

View File

@ -70,9 +70,7 @@ namespace DocFileFormat
case sprmTDefTable:
{
//SprmTDefTable tdef = new SprmTDefTable(sprm.Arguments);
}
break;
}break;
case sprmOldTTableHeader:
case sprmTTableHeader:
{ //header row
@ -84,9 +82,7 @@ namespace DocFileFormat
XMLTools::XMLElement header( L"w:tblHeader" );
_trPr->AppendChild( header );
}
}
break;
}break;
case sprmTWidthAfter:
{ //width after
XMLTools::XMLElement wAfter( L"w:wAfter" );
@ -96,9 +92,7 @@ namespace DocFileFormat
XMLTools::XMLAttribute wAfterType( L"w:type", L"dxa" );
wAfter.AppendAttribute( wAfterType );
_trPr->AppendChild( wAfter, true );
}
break;
}break;
case sprmTWidthBefore:
{ //width before
short before = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
@ -113,9 +107,7 @@ namespace DocFileFormat
wBefore.AppendAttribute( wBeforeType );
_trPr->AppendChild( wBefore, true );
}
}
break;
}break;
case sprmOldTDyaRowHeight:
case sprmTDyaRowHeight:
{ //row height
@ -147,20 +139,19 @@ namespace DocFileFormat
_trPr->AppendChild( rowHeight );
}
break;
case sprmOldTFCantSplit:
case sprmTFCantSplit:
case sprmTFCantSplit90:
{ //can't split
appendFlagElement( _trPr, *iter, L"cantSplit", true );
}break;
case sprmOldTFCantSplit:
case sprmTFCantSplit:
case sprmTFCantSplit90:
{ //can't split
appendFlagElement( _trPr, *iter, L"cantSplit", true );
}break;
//div id
case sprmTIpgp:
{
appendValueElement( _trPr, L"divId", FormatUtils::IntToWideString( FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
//div id
case sprmTIpgp:// = PGPInfo.ipgpSelf (PGPInfo structure describes the border and margin properties)
{
}break;
default:
break;
//borders 80 exceptions
//case SinglePropertyModifier.OperationCode.sprmTTableBorders80:
// unsigned char[] brc80 = new unsigned char[4];

View File

@ -38,7 +38,7 @@
#include "OfficeDrawing/GroupShapeBooleanProperties.h"
#include "OfficeDrawing/MetafilePictBlip.h"
#include "../../DesktopEditor/common/String.h"
#include "../../DesktopEditor/common/StringExt.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Document.h"
#include "../../DesktopEditor/common/File.h"
@ -138,11 +138,56 @@ namespace DocFileFormat
}
return btWin32;
}
bool VMLPictureMapping::ParseEmbeddedBlob( const std::string & xmlString, std::wstring & newXmlString)
{
newXmlString.clear();
std::wstring sTempFolder = m_context->_doc->m_sTempFolder;
if (sTempFolder.empty())
{
sTempFolder = NSFile::CFileBinary::GetTempPath();
}
std::wstring sTempXmlFile = NSDirectory::CreateTempFileWithUniqueName(sTempFolder, L"emb");
NSFile::CFileBinary file;
file.CreateFileW(sTempXmlFile);
file.WriteFile((BYTE*)xmlString.c_str(), xmlString.size());
file.CloseFile();
COfficeUtils officeUtils(NULL);
BYTE *utf8Data = NULL;
ULONG utf8DataSize = 0;
if (S_OK != officeUtils.LoadFileFromArchive(sTempXmlFile, L"drs/shapexml.xml", &utf8Data, utf8DataSize))
{
if (S_OK == officeUtils.IsFileExistInArchive(sTempXmlFile, L"drs/diagrams"))
{
officeUtils.LoadFileFromArchive(sTempXmlFile, L"drs/diagrams/drawing1.xml", &utf8Data, utf8DataSize);
}
else if (S_OK != officeUtils.LoadFileFromArchive(sTempXmlFile, L"drs/e2oDoc.xml", &utf8Data, utf8DataSize))
{
}
}
if (utf8Data && utf8DataSize > 0)
{
newXmlString = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize);
delete []utf8Data;
}
NSFile::CFileBinary::Remove(sTempXmlFile);
if (newXmlString.empty()) return false;
return true;
}
bool VMLPictureMapping::ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString)
{
newXmlString.clear();
std::wstring sTempFolder = m_ctx->_doc->m_sTempFolder;
std::wstring sTempFolder = m_context->_doc->m_sTempFolder;
if (sTempFolder.empty())
{
sTempFolder = NSFile::CFileBinary::GetTempPath();
@ -211,7 +256,7 @@ namespace DocFileFormat
VMLPictureMapping::VMLPictureMapping(ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture) : PropertiesMapping(writer)
{
m_ctx = ctx;
m_context = ctx;
m_isOlePreview = olePreview;
m_imageData = NULL;
m_nImageId = 0;
@ -221,6 +266,7 @@ namespace DocFileFormat
m_isBullete = false;
m_isEquation = false;
m_isEmbedded = false;
m_isBlob = false;
m_imageData = new XMLTools::XMLElement( L"v:imagedata" );
}
@ -229,7 +275,18 @@ namespace DocFileFormat
{
RELEASEOBJECT(m_imageData);
}
std::wstring VMLPictureMapping::GetShapeID(const Shape* pShape) const
{
std::wstring strXmlAttr;
if (NULL != pShape)
{
strXmlAttr += std::wstring(L"_x0000_i");
strXmlAttr += FormatUtils::IntToWideString(pShape->GetShapeID());
}
return strXmlAttr;
}
void VMLPictureMapping::Apply( IVisitable* visited )
{
PictureDescriptor* pict = dynamic_cast<PictureDescriptor*>(visited);
@ -248,13 +305,14 @@ namespace DocFileFormat
std::vector<OptionEntryPtr> options;
PictureFrameType type;
Shape* pShape = NULL;
if ((pict->shapeContainer || pict->blipStoreEntry) && pict->shapeContainer->Children.size() > 0)
{
Shape* shape = static_cast<Shape*>(*(pict->shapeContainer->Children.begin()));
options = pict->shapeContainer->ExtractOptions();
pShape = static_cast<Shape*>(*(pict->shapeContainer->Children.begin()));
options = pict->shapeContainer->ExtractOptions();
//v:shapetype
type.SetType(shape->Instance);
type.SetType(pShape->Instance);
VMLShapeTypeMapping* vmlShapeTypeMapping = new VMLShapeTypeMapping( m_pXmlWriter, m_isInlinePicture );
@ -265,13 +323,16 @@ namespace DocFileFormat
{
type.SetType(msosptPictureFrame);
}
m_pXmlWriter->WriteNodeBegin( L"v:shape", true );
m_pXmlWriter->WriteNodeBegin( L"v:shape", true );
//m_shapeId = GetShapeID(pShape); - todooo одинаковые картинки (одинаковый spid) - Anexo№3.doc
count_vml_objects++;
if (m_shapeId.empty())
m_shapeId = L"_x0000_s" + FormatUtils::IntToWideString(1024 + count_vml_objects);
{
m_context->_doc->GetOfficeArt()->m_uLastShapeId++;
m_shapeId = L"_x0000_i" + FormatUtils::IntToWideString(m_context->_doc->GetOfficeArt()->m_uLastShapeId);
}
m_pXmlWriter->WriteAttribute( L"id", m_shapeId);
@ -299,7 +360,9 @@ namespace DocFileFormat
case metroBlob:
{
//встроенная неведомая хуйня
m_isBlob = true;
m_isEmbedded = true;
m_embeddedData = std::string((char*)iter->opComplex.get(), iter->op);
//if (ParseEmbeddedBlob( m_embeddedData, m_blobXml)) // todoooo
@ -309,24 +372,28 @@ namespace DocFileFormat
}break;
//BORDERS
case borderBottomColor:
if (!pict->brcBottom)
{
RGBColor bottomColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:borderbottomcolor", L"#" + bottomColor.SixDigitHexCode);
}
break;
case borderLeftColor:
if (!pict->brcLeft)
{
RGBColor leftColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:borderleftcolor", L"#" + leftColor.SixDigitHexCode);
}
break;
case borderRightColor:
if (!pict->brcRight)
{
RGBColor rightColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:borderrightcolor", L"#" + rightColor.SixDigitHexCode);
}
break;
case borderTopColor:
if (!pict->brcTop)
{
RGBColor topColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:bordertopcolor", L"#" + topColor.SixDigitHexCode);
@ -408,8 +475,9 @@ namespace DocFileFormat
{
appendStyleProperty(&strStyle, L"visibility", L"hidden");
}
}
break;
}break;
default:
break;
}
}
@ -443,14 +511,15 @@ namespace DocFileFormat
}
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
//v:imageData
if (CopyPicture(pict))
{
//v:imageData
appendValueAttribute(m_imageData, L"r:id", L"rId" + FormatUtils::IntToWideString(m_nImageId));
appendValueAttribute(m_imageData, L"o:title", L"" );
m_pXmlWriter->WriteString(m_imageData->GetXMLString());
}
{//borders
writePictureBorder( L"bordertop", pict->brcTop );
writePictureBorder( L"borderleft", pict->brcLeft );
@ -510,10 +579,10 @@ namespace DocFileFormat
pict->embeddedData = newData;
}
m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(Global::msoblipDIB),
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(Global::msoblipDIB),
std::vector<unsigned char>(pict->embeddedData, (pict->embeddedData + pict->embeddedDataSize)), Global::msoblipDIB));
m_nImageId = m_ctx->_docx->RegisterImage(m_caller, btWin32);
m_nImageId = m_context->_docx->RegisterImage(m_caller, btWin32);
result = true;
}
else if ((oBlipEntry != NULL) && (oBlipEntry->Blip != NULL))
@ -530,7 +599,7 @@ namespace DocFileFormat
unsigned char *newData = NULL;
int newDataSize = metaBlip->oMetaFile.ToBuffer(newData);
m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32), std::vector<unsigned char>(newData, (newData + newDataSize))));
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32), std::vector<unsigned char>(newData, (newData + newDataSize))));
RELEASEARRAYOBJECTS(newData);
}
@ -546,7 +615,7 @@ namespace DocFileFormat
BitmapBlip* bitBlip = static_cast<BitmapBlip*>(oBlipEntry->Blip);
if (bitBlip)
{
m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32),
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32),
std::vector<unsigned char>(bitBlip->m_pvBits, (bitBlip->m_pvBits + bitBlip->pvBitsSize)), oBlipEntry->btWin32));
}
}break;
@ -557,7 +626,7 @@ namespace DocFileFormat
}break;
}
m_nImageId = m_ctx->_docx->RegisterImage(m_caller, oBlipEntry->btWin32);
m_nImageId = m_context->_docx->RegisterImage(m_caller, oBlipEntry->btWin32);
result = true;
}

View File

@ -58,6 +58,8 @@ namespace DocFileFormat
void writePictureBorder (const std::wstring & name, const BorderCode* brc);
void appendStyleProperty( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const;
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString );
bool ParseEmbeddedBlob(const std::string & xmlString, std::wstring & newXmlString);
std::wstring GetShapeID(const Shape* pShape) const;
protected:
/// Copies the picture from the binary stream to the zip archive
/// and creates the relationships for the image.
@ -68,16 +70,18 @@ namespace DocFileFormat
static std::wstring GetTargetExt (Global::BlipType nType);
static std::wstring GetContentType (Global::BlipType nType);
bool m_isBlob;
bool m_isBullete;
bool m_isEquation;
bool m_isEmbedded;
std::string m_embeddedData;
std::wstring m_equationXml;
std::wstring m_blobXml;
std::wstring m_shapeId;
private:
ConversionContext* m_ctx;
ConversionContext* m_context;
IMapping* m_caller;
int m_nImageId;

View File

@ -55,7 +55,7 @@
#include "DrawingPrimitives.h"
#include "../../DesktopEditor/common/String.h"
#include "../../DesktopEditor/common/StringExt.h"
#include "../Common/FormatUtils.h"
@ -168,6 +168,8 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute(L"wrapcoords", wrapCoords);
}
break;
default:
break;
}
}
@ -235,10 +237,11 @@ namespace DocFileFormat
m_shapeId = GetShapeID(pShape);
count_vml_objects++;
if (m_shapeId.empty())
m_shapeId = std::wstring(L"_x0000_s") + FormatUtils::IntToWideString(1024 + count_vml_objects);
{
m_context->_doc->GetOfficeArt()->m_uLastShapeId++;
m_shapeId = std::wstring(L"_x0000_s") + FormatUtils::IntToWideString(m_context->_doc->GetOfficeArt()->m_uLastShapeId);
}
m_pXmlWriter->WriteAttribute ( L"id", m_shapeId );
@ -249,7 +252,7 @@ namespace DocFileFormat
freeform = false;
m_pXmlWriter->WriteAttribute( L"type", (std::wstring(L"#") + VMLShapeTypeMapping::GenerateTypeId(pShape->GetShapeType())));
}
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->Index)));
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->m_nIndex)));
if (pShape->is<LineType>())
{
@ -1681,6 +1684,8 @@ namespace DocFileFormat
{
appendStyleProperty(oStyle, L"mso-wrap-distance-top", (FormatUtils::DoubleToWideString(EmuValue((int)iter->op).ToPoints()) + std::wstring(L"pt")));
}break;
default:
break;
}
}
@ -1818,12 +1823,12 @@ namespace DocFileFormat
{
switch ( op )
{
default: return L"none";
case 1: return L"block";
case 2: return L"classic";
case 3: return L"diamond";
case 4: return L"oval";
case 5: return L"open";
default: return L"none";
}
}
@ -1831,9 +1836,9 @@ namespace DocFileFormat
{
switch ( op )
{
default: return L"short";
case 1: return L"medium";
case 2: return L"long";
default: return L"short";
}
}
@ -1841,9 +1846,9 @@ namespace DocFileFormat
{
switch ( op )
{
default: return L"narrow";
case 1: return L"medium";
case 2: return L"wide";
default: return L"narrow";
}
}
@ -2265,9 +2270,10 @@ namespace DocFileFormat
TwipsValue w( primitive->dxa );
TwipsValue h( primitive->dya );
std::wstring strId = std::wstring(L"_x0000_s") + FormatUtils::IntToWideString(1024 + count_vml_objects);
m_context->_doc->GetOfficeArt()->m_uLastShapeId++;
std::wstring strId = std::wstring(L"_x0000_s") + FormatUtils::IntToWideString(m_context->_doc->GetOfficeArt()->m_uLastShapeId);
count_vml_objects++;
//m_pXmlWriter->WriteAttribute ( L"id") , strId);
m_pXmlWriter->WriteAttribute ( L"o:spid", strId);

View File

@ -124,12 +124,12 @@ namespace DocFileFormat
else if (_isInlineShape)
{
m_pXmlWriter->WriteString(L"<v:formulas><v:f eqn=\"if lineDrawn pixelLineWidth 0\"/>\
<v:f eqn=\"sum @0 1 0\"/><v:f eqn=\"sum 0 0 @1\"/>\
<v:f eqn=\"prod @2 1 2\"/><v:f eqn=\"prod @3 21600 pixelWidth\"/>\
<v:f eqn=\"prod @3 21600 pixelHeight\"/><v:f eqn=\"sum @0 0 1\"/>\
<v:f eqn=\"prod @6 1 2\"/><v:f eqn=\"prod @7 21600 pixelWidth\"/>\
<v:f eqn=\"sum @8 21600 0\"/><v:f eqn=\"prod @7 21600 pixelHeight\"/>\
<v:f eqn=\"sum @10 21600 0\"/></v:formulas>");
<v:f eqn=\"sum @0 1 0\"/><v:f eqn=\"sum 0 0 @1\"/>\
<v:f eqn=\"prod @2 1 2\"/><v:f eqn=\"prod @3 21600 pixelWidth\"/>\
<v:f eqn=\"prod @3 21600 pixelHeight\"/><v:f eqn=\"sum @0 0 1\"/>\
<v:f eqn=\"prod @6 1 2\"/><v:f eqn=\"prod @7 21600 pixelWidth\"/>\
<v:f eqn=\"sum @8 21600 0\"/><v:f eqn=\"prod @7 21600 pixelHeight\"/>\
<v:f eqn=\"sum @10 21600 0\"/></v:formulas>");
}
// Path

View File

@ -37,8 +37,6 @@
namespace DocFileFormat
{
static int count_vml_objects = 0;
class VMLShapeTypeMapping: public PropertiesMapping, public IMapping
{
private:

View File

@ -85,7 +85,7 @@ namespace DocFileFormat
IndividualFootnotesPlex(NULL), FootnoteReferenceCharactersPlex(NULL), IndividualEndnotesPlex(NULL),
EndnoteReferenceCharactersPlex(NULL), FieldsPlex(NULL), FootnoteDocumentFieldsPlex(NULL),
EndnoteDocumentFieldsPlex(NULL), HeadersAndFootersDocumentFieldsPlex(NULL), HeaderStoriesPlex(NULL),
AnnotationsReferencePlex(NULL), IndividualCommentsPlex(NULL), TextboxBreakPlex(NULL), TextboxBreakPlexHeader(NULL),
AnnotationsReferencePlex(NULL), AnnotationsReferenceExPlex(NULL), IndividualCommentsPlex(NULL), TextboxBreakPlex(NULL), TextboxBreakPlexHeader(NULL),
TextboxIndividualPlex(NULL),AssocNames(NULL), BookmarkAnnotNames(NULL), Captions(NULL), AutoCaptions(NULL), ListPlex(NULL),
OfficeDrawingPlex(NULL), OfficeDrawingPlexHeader(NULL), SectionPlex(NULL), BookmarkStartPlex(NULL), BookmarkEndPlex(NULL),
AutoTextPlex(NULL), AllPapxFkps(NULL), AllChpxFkps(NULL), AllPapx(NULL), AllPapxVector(NULL), AllSepx(NULL), Styles(NULL), listTable(NULL),
@ -117,7 +117,7 @@ namespace DocFileFormat
namespace DocFileFormat
{
int WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password)
_UINT32 WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password)
{
m_sFileName = fileName;
m_sPassword = password;
@ -318,8 +318,8 @@ namespace DocFileFormat
// Read all needed PLCFs
if (FIB->m_RgLw97.ccpFtn > 0)
{
IndividualFootnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt, nWordVersion);
FootnoteReferenceCharactersPlex = new Plex<FootnoteDescriptor>(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef, nWordVersion);
IndividualFootnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt, nWordVersion);
}
if (nWordVersion > 0 && FIB->m_FibWord97.lcbPlcPad > 0)
@ -329,8 +329,8 @@ namespace DocFileFormat
if (FIB->m_RgLw97.ccpEdn > 0)
{
IndividualEndnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt, nWordVersion);
EndnoteReferenceCharactersPlex = new Plex<EndnoteDescriptor>(EndnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendRef, FIB->m_FibWord97.lcbPlcfendRef, nWordVersion);
IndividualEndnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt, nWordVersion);
}
if (FIB->m_RgLw97.ccpHdr > 0)
@ -338,11 +338,16 @@ namespace DocFileFormat
HeaderStoriesPlex = new Plex<EmptyStructure>( EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfHdd, FIB->m_FibWord97.lcbPlcfHdd, nWordVersion);
}
if (FIB->m_RgLw97.ccpAtn > 0)
if (FIB->m_RgLw97.ccpAtn > 0)
{
AnnotationsReferencePlex = new Plex<AnnotationReferenceDescriptor>(AnnotationReferenceDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcfandRef, FIB->m_FibWord97.lcbPlcfandRef, nWordVersion);
IndividualCommentsPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfandTxt, FIB->m_FibWord97.lcbPlcfandTxt, nWordVersion);
}
if (FIB->m_FibWord2002.lcbAtrdExtra > 0)
{
AnnotationsReferenceExPlex = new Plex<AnnotationReferenceExDescriptor>(AnnotationReferenceExDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord2002.fcAtrdExtra, FIB->m_FibWord2002.lcbAtrdExtra, nWordVersion);
}
OfficeDrawingPlex = new Plex<Spa> (Spa::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom, nWordVersion);
OfficeDrawingPlexHeader = new Plex<Spa> (Spa::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcSpaHdr, FIB->m_FibWord97.lcbPlcSpaHdr, nWordVersion);
@ -356,7 +361,7 @@ namespace DocFileFormat
TextboxBreakPlex = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxBkd, FIB->m_FibWord97.lcbPlcfTxbxBkd, nWordVersion);
TextboxBreakPlexHeader = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxHdrBkd, FIB->m_FibWord97.lcbPlcfTxbxHdrBkd, nWordVersion);
AnnotStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkf, FIB->m_FibWord97.lcbPlcfAtnBkf, nWordVersion);
AnnotStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkf, FIB->m_FibWord97.lcbPlcfAtnBkf, nWordVersion);
AnnotEndPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkl, FIB->m_FibWord97.lcbPlcfAtnBkl, nWordVersion);
@ -368,18 +373,19 @@ namespace DocFileFormat
BookmarkStartEndCPs.push_back(std::make_pair(BookmarkStartPlex->CharacterPositions[i], BookmarkEndPlex->CharacterPositions[pBookmark->GetIndex()]));
}
}
for (size_t i = 0; i < AnnotStartPlex->Elements.size(); ++i)
for (size_t i = 0; AnnotStartPlex && i < AnnotStartPlex->Elements.size(); ++i)
{
BookmarkFirst* pBookmark = static_cast<BookmarkFirst*>(AnnotStartPlex->Elements[i]);
BookmarkFirst* pBookmark = static_cast<BookmarkFirst*>(AnnotStartPlex->Elements[i]);
if (pBookmark)
{
short end = pBookmark->GetIndex();
if (i < AnnotStartPlex->CharacterPositions.size() && end < AnnotEndPlex->CharacterPositions.size())
short ind = pBookmark->GetIndex();
if (i < AnnotStartPlex->CharacterPositions.size() -1 )
{
AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[end]));
AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[i + 1]));
}
}
}
AutoTextPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, nWordVersion);
FieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, nWordVersion);
FootnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, nWordVersion);
@ -417,7 +423,7 @@ namespace DocFileFormat
AnnotationOwners = new AnnotationOwnerList (FIB, TableStream);
}
if (m_pCallFunc)
if (m_pCallFunc)
{
m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 300000 );
@ -435,24 +441,24 @@ namespace DocFileFormat
std::unordered_map<int, int> fonts_charsets;
bool bFontsCodePage = false;
for ( std::vector<ByteStructure*>::iterator iter = FontTable->Data.begin(); !bFontsCodePage && iter != FontTable->Data.end(); iter++ )
for ( size_t i = 0; FIB->m_FibWord97.lcbClx > 0 && !bFontsCodePage && i < FontTable->Data.size(); ++i)
{
FontFamilyName* font = dynamic_cast<FontFamilyName*>( *iter );
FontFamilyName* font = dynamic_cast<FontFamilyName*>( FontTable->Data[i]);
if (!font) continue;
if (fonts_charsets.find(font->chs) == fonts_charsets.end())
{
fonts_charsets.insert(std::make_pair(font->chs, font->ff));
for (int i = 0 ; i < sizeof(aCodePages) / 2; i++)
{
if (aCodePages[i][0] == font->chs && font->chs != 0)
{
nFontsCodePage = aCodePages[i][1];
bFontsCodePage = true;
break;
}
}
for (size_t j = 0 ; j < 32; j++)
{
if (aCodePages[j][0] == font->chs && font->chs > 2)
{
nFontsCodePage = aCodePages[j][1];
bFontsCodePage = true;
break;
}
}
}
}
}
@ -465,7 +471,7 @@ namespace DocFileFormat
Text = m_PieceTable->GetAllEncodingText (WordDocumentStream);
}
if (FIB->m_FibWord97.lcbClx < 1 || ((Text) && (Text->empty())))
if (FIB->m_FibWord97.lcbClx < 1 || ((Text) && (Text->empty())))
{
int cb = FIB->m_FibBase.fcMac - FIB->m_FibBase.fcMin;
@ -488,13 +494,13 @@ namespace DocFileFormat
if (BookmarkNames)
{
for (unsigned int i = 0; i < BookmarkStartEndCPs.size(); ++i)
for (size_t i = 0; i < BookmarkStartEndCPs.size(); ++i)
{
WideString* bookmarkName = static_cast<WideString*>(BookmarkNames->operator[]( i ));
if ( ( bookmarkName != NULL ) && ( *bookmarkName == L"_PictureBullets" ) )
{
for (unsigned int j = BookmarkStartEndCPs[i].first, k = 0; j < Text->size(); ++j, ++k )
for (size_t j = BookmarkStartEndCPs[i].first, k = 0; j < Text->size(); ++j, ++k )
{
if ( Text->at( j ) == 1 )
{
@ -540,7 +546,7 @@ namespace DocFileFormat
{
AllSepx = new std::map<int, SectionPropertyExceptions*>();
for (unsigned int i = 0; i < SectionPlex->Elements.size(); ++i)
for (size_t i = 0; i < SectionPlex->Elements.size(); ++i)
{
//Read the SED
SectionDescriptor* sed = static_cast<SectionDescriptor*>(SectionPlex->Elements.at(i));
@ -869,6 +875,7 @@ namespace DocFileFormat
RELEASEOBJECT(HeaderStoriesPlex);
RELEASEOBJECT(IndividualCommentsPlex);
RELEASEOBJECT(AnnotationsReferencePlex);
RELEASEOBJECT(AnnotationsReferenceExPlex);
RELEASEOBJECT(TextboxBreakPlex);
RELEASEOBJECT(TextboxBreakPlexHeader);
RELEASEOBJECT(OfficeDrawingPlex);

View File

@ -88,13 +88,14 @@ namespace DocFileFormat
friend class VMLPictureMapping;
friend class OpenXmlPackage;
friend class TextboxMapping;
friend class SettingsMapping;
public:
WordDocument (const ProgressCallback* pCallFunc, const std::wstring & tempFolder );
virtual ~WordDocument();
int LoadDocument(const std::wstring & fileName, const std::wstring & password);
_UINT32 LoadDocument(const std::wstring & fileName, const std::wstring & password);
int nWordVersion;
int nDocumentCodePage;
@ -224,6 +225,7 @@ namespace DocFileFormat
Plex<FieldCharacter> *EndnoteDocumentFieldsPlex;
Plex<FieldCharacter> *HeadersAndFootersDocumentFieldsPlex;
Plex<AnnotationReferenceDescriptor> *AnnotationsReferencePlex;
Plex<AnnotationReferenceExDescriptor> *AnnotationsReferenceExPlex;
Plex<EmptyStructure> *AutoTextPlex;
// Each character position specifies the beginning of a range of text that constitutes the contents of an AutoText item

View File

@ -34,6 +34,7 @@
#include "../../DesktopEditor/raster/BgraFrame.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/common/SystemUtils.h"
#include "../../Common/DocxFormat/Source/DocxFormat/App.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Core.h"
@ -224,7 +225,10 @@ namespace DocFileFormat
OOX::CApp* pApp = new OOX::CApp(NULL);
if (pApp)
{
pApp->SetApplication(L"ONLYOFFICE");
std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName);
if (sApplication.empty())
sApplication = NSSystemUtils::gc_EnvApplicationNameDefault;
pApp->SetApplication(sApplication);
#if defined(INTVER)
pApp->SetAppVersion(VALUE2STR(INTVER));
#endif

View File

@ -34,9 +34,9 @@
#include "../DocDocxConverter/Converter.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack)
_UINT32 COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack)
{
HRESULT hr = S_FALSE;
_UINT32 hr = 0;
DocFileFormat::Converter docToDocx;
docToDocx.m_sTempFolder = m_sTempFolder;
@ -46,7 +46,7 @@ HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::w
return hr;
}
HRESULT COfficeDocFile::SaveToFile (const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack )
_UINT32 COfficeDocFile::SaveToFile (const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack )
{
return S_OK;
return 0;
}

View File

@ -53,8 +53,8 @@ public:
std::wstring m_sTempFolder;
HRESULT LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstFileName, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack = NULL);
HRESULT SaveToFile(const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack = NULL);
_UINT32 LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstFileName, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack = NULL);
_UINT32 SaveToFile(const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack = NULL);
};

View File

@ -172,7 +172,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_ATL_CSTRINGS;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"

View File

@ -45,7 +45,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../DesktopEditor/xml/build/vs2005;../../DesktopEditor/xml/libxml2/include;../../DesktopEditor/freetype-2.5.2/include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_ATL_CSTRINGS;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;DONT_WRITE_EMBEDDED_FONTS"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="false"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@ -205,7 +205,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\..\..\Common\OfficeDrawing;&quot;..\..\..\..\..\DesktopEditor\freetype-2.5.2\include&quot;;..\..\..\..\..\Common\OfficeDrawing\Shapes"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;DONT_WRITE_EMBEDDED_FONTS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@ -373,6 +373,10 @@
RelativePath="..\..\XlsxSerializerCom\Writer\CSVWriter.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\BinReader\CustormXmlWriter.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\DocxSerializer.cpp"
>

View File

@ -0,0 +1,76 @@
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "CustormXmlWriter.h"
#include "../../Common/DocxFormat/Source/DocxFormat/CustomXml.h"
#include "../../ASCOfficePPTXFile/ASCOfficeDrawingConverter.h"
namespace Writers
{
CustomXmlWriter::CustomXmlWriter(std::wstring sDir, NSBinPptxRW::CDrawingConverter* pDrawingConverter):m_sDir(sDir),m_pDrawingConverter(pDrawingConverter)
{
m_nCount = 0;
}
std::wstring CustomXmlWriter::WriteCustomXml(const std::wstring& sUrl, const std::wstring& sXml)
{
m_nCount++;
OOX::CCustomXMLProps oCustomXMLProps(NULL);
OOX::CCustomXMLProps::CShemaRef* pShemaRef = new OOX::CCustomXMLProps::CShemaRef();
pShemaRef->m_sUri = sUrl;
//todo guid
oCustomXMLProps.m_oItemID.FromString(L"{5D0AEA6B-E499-4EEF-98A3-AFBB261C493E}");
oCustomXMLProps.m_oShemaRefs.Init();
oCustomXMLProps.m_oShemaRefs->m_arrItems.push_back(pShemaRef);
std::wstring sCustomXmlPropsDir = m_sDir + FILE_SEPARATOR_STR;
sCustomXmlPropsDir += OOX::FileTypes::CustomXmlProps.DefaultDirectory().GetPath();
NSDirectory::CreateDirectories(sCustomXmlPropsDir);
std::wstring sCustomXMLPropsFilename = OOX::FileTypes::CustomXmlProps.DefaultFileName().GetBasename();
sCustomXMLPropsFilename += std::to_wstring(m_nCount) + OOX::FileTypes::CustomXmlProps.DefaultFileName().GetExtention();
oCustomXMLProps.write(OOX::CPath(sCustomXmlPropsDir + FILE_SEPARATOR_STR + sCustomXMLPropsFilename), OOX::CPath(sCustomXmlPropsDir), *m_pDrawingConverter->GetContentTypes());
std::wstring sCustomXmlFilename;
sCustomXmlFilename = OOX::FileTypes::CustomXml.DefaultFileName().GetBasename() + std::to_wstring(m_nCount);
sCustomXmlFilename += OOX::FileTypes::CustomXml.DefaultFileName().GetExtention();
std::wstring sCustomXmlDir = m_sDir + FILE_SEPARATOR_STR + OOX::FileTypes::CustomXml.DefaultDirectory().GetPath();
std::wstring sCustomXmlRelsDir = sCustomXmlDir + FILE_SEPARATOR_STR + L"_rels";
NSDirectory::CreateDirectories(sCustomXmlRelsDir);
m_pDrawingConverter->SetDstContentRels();
unsigned int lId;
m_pDrawingConverter->WriteRels(OOX::FileTypes::CustomXmlProps.RelationType(), sCustomXMLPropsFilename, L"", &lId);
m_pDrawingConverter->SaveDstContentRels(sCustomXmlRelsDir + FILE_SEPARATOR_STR + sCustomXmlFilename + L".rels");
NSFile::CFileBinary::SaveToFile(sCustomXmlDir + FILE_SEPARATOR_STR + sCustomXmlFilename, sXml);
return sCustomXmlFilename;
}
}

View File

@ -0,0 +1,54 @@
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef CUSTOM_XML_WRITER
#define CUSTOM_XML_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace NSBinPptxRW
{
class CDrawingConverter;
}
namespace Writers
{
class CustomXmlWriter
{
int m_nCount;
std::wstring m_sDir;
NSBinPptxRW::CDrawingConverter* m_pDrawingConverter;
public:
CustomXmlWriter(std::wstring sDir, NSBinPptxRW::CDrawingConverter* pDrawingConverter);
std::wstring WriteCustomXml(const std::wstring& sUrl, const std::wstring& sXml);
};
}
#endif // #ifndef CUSTOM_XML_WRITER

View File

@ -66,12 +66,13 @@ xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawin
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
mc:Ignorable=\"w14 wp14\">")));
mc:Ignorable=\"w14 w15 wp14\">")));
oFile.WriteStringUTF8(m_oBackground.GetData());

View File

@ -47,6 +47,7 @@
#include "DocumentRelsWriter.h"
#include "webSettingsWriter.h"
#include "DefaultThemeWriter.h"
#include "CustormXmlWriter.h"
namespace BinDocxRW
{
@ -77,6 +78,7 @@ namespace Writers
DocumentRelsWriter m_oDocumentRelsWriter;
WebSettingsWriter m_oWebSettingsWriter;
DefaultThemeWriter m_oTheme;
CustomXmlWriter m_oCustomXmlWriter;
smart_ptr<OOX::VbaProject> m_pVbaProject;
@ -102,7 +104,8 @@ namespace Writers
m_oDocumentRelsWriter (sDirOutput),
m_oWebSettingsWriter (sDirOutput),
m_nDocPrIndex(0),
m_pComments(NULL)
m_pComments(NULL),
m_oCustomXmlWriter (sDirOutput, pDrawingConverter)
{
}
int getNextDocPr()

View File

@ -72,12 +72,13 @@ xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawin
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
mc:Ignorable=\"w14 wp14\">");
mc:Ignorable=\"w14 w15 wp14\">");
static std::wstring g_string_hdr_End = _T("</w:hdr>");
static std::wstring g_string_ftr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
@ -92,18 +93,19 @@ xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawin
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
mc:Ignorable=\"w14 wp14\">");
mc:Ignorable=\"w14 w15 wp14\">");
static std::wstring g_string_ftr_End = _T("</w:ftr>");
static std::wstring g_string_footnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:footnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" mc:Ignorable=\"w14 wp14\">");
static std::wstring g_string_footnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:footnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" mc:Ignorable=\"w14 w15 wp14\">");
static std::wstring g_string_footnotes_End = _T("</w:footnotes>");
static std::wstring g_string_endnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:endnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" mc:Ignorable=\"w14 wp14\">");
static std::wstring g_string_endnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:endnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" mc:Ignorable=\"w14 w15 wp14\">");
static std::wstring g_string_endnotes_End = _T("</w:endnotes>");
class HeaderFooterWriter

View File

@ -36,7 +36,7 @@
namespace Writers
{
static std::wstring g_string_n_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:numbering xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
static std::wstring g_string_n_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:numbering xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 w15 wp14\">");
static std::wstring g_string_n_End = _T("</w:numbering>");
class NumberingWriter

View File

@ -42,15 +42,15 @@ class SectPr
{
public:
std::wstring sHeaderFooterReference;
double W;
double H;
long W;
long H;
BYTE cOrientation;
double Left;
double Top;
double Right;
double Bottom;
double Header;
double Footer;
long Left;
long Top;
long Right;
long Bottom;
long Header;
long Footer;
bool TitlePg;
bool EvenAndOddHeaders;
BYTE SectionType;
@ -61,6 +61,13 @@ public:
std::wstring footnotePr;
std::wstring endnotePr;
bool bW;
bool bH;
bool bOrientation;
bool bLeft;
bool bTop;
bool bRight;
bool bBottom;
bool bHeader;
bool bFooter;
bool bTitlePg;
@ -69,18 +76,16 @@ public:
bool bPageNumStart;
SectPr()
{
W = Page_Width;
H = Page_Height;
cOrientation = orientation_Portrait;
Left = 30;
Top = 20;
Right = 15;
Bottom = 20;
Header = 12.5;
Footer = 12.5;
sHeaderFooterReference = _T("");
cols = _T("<w:cols w:space=\"708\"/>");
bW = false;
bH = false;
bOrientation = false;
bLeft = false;
bTop = false;
bRight = false;
bBottom = false;
bHeader = false;
bFooter = false;
bTitlePg = false;
@ -91,14 +96,6 @@ public:
std::wstring Write()
{
std::wstring sRes = _T("");
long nWidth = SerializeCommon::Round(W * g_dKoef_mm_to_twips);
long nHeight = SerializeCommon::Round(H * g_dKoef_mm_to_twips);
long nMLeft = SerializeCommon::Round(Left * g_dKoef_mm_to_twips);
long nMTop = SerializeCommon::Round(Top * g_dKoef_mm_to_twips);
long nMRight = SerializeCommon::Round(Right * g_dKoef_mm_to_twips);
long nMBottom = SerializeCommon::Round(Bottom * g_dKoef_mm_to_twips);
long nMHeader = SerializeCommon::Round(Header * g_dKoef_mm_to_twips);
long nMFooter = SerializeCommon::Round(Footer * g_dKoef_mm_to_twips);
if(!sHeaderFooterReference.empty())
sRes += sHeaderFooterReference;
@ -120,19 +117,41 @@ public:
}
sRes += L"<w:type w:val=\"" + sType + L"\"/>";
}
sRes += L"<w:pgSz w:w=\"" + std::to_wstring(nWidth) + L"\" w:h=\"" + std::to_wstring(nHeight) + L"\"";
if(orientation_Portrait != cOrientation)
sRes += L" w:orient=\"landscape\"";
sRes += L"/>";
if((bW && bH) || bOrientation)
{
sRes += L"<w:pgSz";
if(bW && bH)
{
sRes += L" w:w=\"" + std::to_wstring(W) + L"\" w:h=\"" + std::to_wstring(H) + L"\"";
}
if(bOrientation)
{
if(orientation_Portrait != cOrientation)
sRes += L" w:orient=\"landscape\"";
else
sRes += L" w:orient=\"portrait\"";
}
sRes += L"<w:pgMar w:top=\"" + std::to_wstring(nMTop) + L"\" w:right=\"" + std::to_wstring(nMRight) +
L"\" w:bottom=\"" + std::to_wstring(nMBottom) + L"\" w:left=\"" + std::to_wstring(nMLeft) + L"\" w:gutter=\"0\"";
sRes += L"/>";
}
if(bHeader)
sRes += L" w:header=\"" + std::to_wstring(nMHeader) + L"\"";
if(bFooter)
sRes += L" w:footer=\"" + std::to_wstring(nMFooter) + L"\"";
sRes += L"/>";
if(bLeft || bTop || bRight || bBottom || bHeader || bFooter)
{
sRes += L"<w:pgMar";
if(bTop)
sRes += L" w:top=\"" + std::to_wstring(Top) + L"\"";
if(bRight)
sRes += L" w:right=\"" + std::to_wstring(Right) + L"\"";
if(bBottom)
sRes += L" w:bottom=\"" + std::to_wstring(Bottom) + L"\"";
if(bLeft)
sRes += L" w:left=\"" + std::to_wstring(Left) + L"\"";
if(bHeader)
sRes += L" w:header=\"" + std::to_wstring(Header) + L"\"";
if(bFooter)
sRes += L" w:footer=\"" + std::to_wstring(Footer) + L"\"";
sRes += L" w:gutter=\"0\"/>";
}
if(!pgBorders.empty())
sRes += pgBorders;
@ -245,6 +264,7 @@ class Spacing
public:
bool bLineRule;
bool bLine;
bool bLineTwips;
bool bAfter;
bool bBefore;
bool bAfterAuto;
@ -252,14 +272,16 @@ public:
BYTE LineRule;
double Line;
double After;
double Before;
long LineTwips;
long After;
long Before;
bool AfterAuto;
bool BeforeAuto;
Spacing()
{
bLineRule = false;
bLine = false;
bLineTwips = false;
bAfter = false;
bBefore = false;
bAfterAuto = false;
@ -335,10 +357,48 @@ public:
sShd += L"<w:shd";
if(bValue)
{
if(shd_Nil == Value)
sShd += L" w:val=\"nil\"";
else
sShd += L" w:val=\"clear\"";
switch(Value)
{
case SimpleTypes::shdClear : sShd += L" w:val=\"clear\""; break;
case SimpleTypes::shdDiagCross : sShd += L" w:val=\"diagCross\""; break;
case SimpleTypes::shdDiagStripe : sShd += L" w:val=\"diagStripe\""; break;
case SimpleTypes::shdHorzCross : sShd += L" w:val=\"horzCross\""; break;
case SimpleTypes::shdHorzStripe : sShd += L" w:val=\"horzStripe\""; break;
case SimpleTypes::shdNil : sShd += L" w:val=\"nil\""; break;
case SimpleTypes::shdPct10 : sShd += L" w:val=\"pct10\""; break;
case SimpleTypes::shdPct12 : sShd += L" w:val=\"pct12\""; break;
case SimpleTypes::shdPct15 : sShd += L" w:val=\"pct15\""; break;
case SimpleTypes::shdPct20 : sShd += L" w:val=\"pct20\""; break;
case SimpleTypes::shdPct25 : sShd += L" w:val=\"pct25\""; break;
case SimpleTypes::shdPct30 : sShd += L" w:val=\"pct30\""; break;
case SimpleTypes::shdPct35 : sShd += L" w:val=\"pct35\""; break;
case SimpleTypes::shdPct37 : sShd += L" w:val=\"pct37\""; break;
case SimpleTypes::shdPct40 : sShd += L" w:val=\"pct40\""; break;
case SimpleTypes::shdPct45 : sShd += L" w:val=\"pct45\""; break;
case SimpleTypes::shdPct5 : sShd += L" w:val=\"pct5\""; break;
case SimpleTypes::shdPct50 : sShd += L" w:val=\"pct50\""; break;
case SimpleTypes::shdPct55 : sShd += L" w:val=\"pct55\""; break;
case SimpleTypes::shdPct60 : sShd += L" w:val=\"pct60\""; break;
case SimpleTypes::shdPct62 : sShd += L" w:val=\"pct62\""; break;
case SimpleTypes::shdPct65 : sShd += L" w:val=\"pct65\""; break;
case SimpleTypes::shdPct70 : sShd += L" w:val=\"pct70\""; break;
case SimpleTypes::shdPct75 : sShd += L" w:val=\"pct75\""; break;
case SimpleTypes::shdPct80 : sShd += L" w:val=\"pct80\""; break;
case SimpleTypes::shdPct85 : sShd += L" w:val=\"pct85\""; break;
case SimpleTypes::shdPct87 : sShd += L" w:val=\"pct87\""; break;
case SimpleTypes::shdPct90 : sShd += L" w:val=\"pct90\""; break;
case SimpleTypes::shdPct95 : sShd += L" w:val=\"pct95\""; break;
case SimpleTypes::shdReverseDiagStripe : sShd += L" w:val=\"reverseDiagStripe\""; break;
case SimpleTypes::shdSolid : sShd += L" w:val=\"solid\""; break;
case SimpleTypes::shdThinDiagCross : sShd += L" w:val=\"thinDiagCross\""; break;
case SimpleTypes::shdThinDiagStripe : sShd += L" w:val=\"thinDiagStripe\""; break;
case SimpleTypes::shdThinHorzCross : sShd += L" w:val=\"thinHorzCross\""; break;
case SimpleTypes::shdThinHorzStripe : sShd += L" w:val=\"thinHorzStripe\""; break;
case SimpleTypes::shdThinReverseDiagStripe : sShd += L" w:val=\"thinReverseDiagStripe\""; break;
case SimpleTypes::shdThinVertStripe : sShd += L" w:val=\"thinVertStripe\""; break;
case SimpleTypes::shdVertStripe : sShd += L" w:val=\"vertStripe\""; break;
default : sShd += L" w:val=\"solid\""; break;
}
}
sShd += L" w:color=\"auto\"";
if(bColor)
@ -363,7 +423,7 @@ class Tab
{
public:
BYTE Val;
double Pos;
long Pos;
BYTE Leader;
bool bLeader;
Tab()
@ -397,11 +457,11 @@ public:
docRGB HighLight;
std::wstring Shd;
std::wstring RStyle;
double Spacing;
long Spacing;
bool DStrikeout;
bool Caps;
bool SmallCaps;
double Position;
long Position;
BYTE FontHint;
bool BoldCs;
bool ItalicCs;
@ -642,13 +702,11 @@ public:
}
if(bSpacing)
{
long nSpacing = SerializeCommon::Round( g_dKoef_mm_to_twips * Spacing);
pCStringWriter->WriteString(L"<w:spacing w:val=\"" + std::to_wstring(nSpacing) + L"\"/>");
pCStringWriter->WriteString(L"<w:spacing w:val=\"" + std::to_wstring(Spacing) + L"\"/>");
}
if(bPosition)
{
long nPosition = SerializeCommon::Round( g_dKoef_mm_to_hps * Position);
std::wstring sPosition = L"<w:position w:val=\"" + std::to_wstring(nPosition) + L"\"/>";
std::wstring sPosition = L"<w:position w:val=\"" + std::to_wstring(Position) + L"\"/>";
pCStringWriter->WriteString(sPosition);
}
if(bFontSize)
@ -1001,6 +1059,26 @@ public:
};
class PaddingsToWrite
{
public:
long Left;
long Top;
long Right;
long Bottom;
bool bLeft;
bool bTop;
bool bRight;
bool bBottom;
public: PaddingsToWrite()
{
bLeft = false;
bTop = false;
bRight = false;
bBottom = false;
}
};
class PaddingsToWriteMM
{
public:
double Left;
double Top;
@ -1011,7 +1089,7 @@ public:
bool bTop;
bool bRight;
bool bBottom;
public: PaddingsToWrite()
public: PaddingsToWriteMM()
{
bLeft = false;
bTop = false;
@ -1028,7 +1106,7 @@ public:
double Y;
double Width;
double Height;
PaddingsToWrite Paddings;
PaddingsToWriteMM Paddings;
int m_nDocPr;
bool bMediaId;
@ -1167,8 +1245,8 @@ class docBorder
{
public:
docRGB Color;
double Space;
double Size;
long Space;
long Size;
BYTE Value;
CThemeColor ThemeColor;
@ -1201,13 +1279,11 @@ public:
}
if(bSize)
{
long nSize = SerializeCommon::Round(g_dKoef_mm_to_eightpoint * Size);
pCStringWriter->WriteString(L" w:sz=\"" + std::to_wstring(nSize) + L"\"");
pCStringWriter->WriteString(L" w:sz=\"" + std::to_wstring(Size) + L"\"");
}
if(bSpace)
{
long nSpace = SerializeCommon::Round(g_dKoef_mm_to_pt * Space);
pCStringWriter->WriteString(L" w:space=\"" + std::to_wstring(nSpace) + L"\"");
pCStringWriter->WriteString(L" w:space=\"" + std::to_wstring(Space) + L"\"");
}
if(bThemeColor && ThemeColor.IsNoEmpty())
{
@ -1417,7 +1493,7 @@ public:
oWriter.WriteString(L"<w:numFmt w:val=\"" + sFormat + L"\"/>");
}
}
if(bRestart && 0 == Restart)
if(bRestart)
{
oWriter.WriteString(L"<w:lvlRestart w:val=\"" + std::to_wstring(Restart) + L"\"/>");
}
@ -2074,8 +2150,8 @@ public:
class CDrawingPropertyWrapPoint
{
public:
double X;
double Y;
__int64 X;
__int64 Y;
bool bX;
bool bY;
@ -2115,36 +2191,36 @@ class CDrawingProperty
public:
bool bObject;
std::wstring sObjectProgram;
long nObjectId;
unsigned int nObjectId;
BYTE nObjectType;
long DataPos;
long DataLength;
BYTE Type;
bool BehindDoc;
double DistL;
double DistT;
double DistR;
double DistB;
__int64 DistL;
__int64 DistT;
__int64 DistR;
__int64 DistB;
bool LayoutInCell;
unsigned long RelativeHeight;
bool BSimplePos;
double EffectExtentL;
double EffectExtentT;
double EffectExtentR;
double EffectExtentB;
double Width;
double Height;
__int64 EffectExtentL;
__int64 EffectExtentT;
__int64 EffectExtentR;
__int64 EffectExtentB;
__int64 Width;
__int64 Height;
BYTE PositionHRelativeFrom;
BYTE PositionHAlign;
double PositionHPosOffset;
double PositionHPctOffset;
__int64 PositionHPosOffset;
double PositionHPctOffset;
BYTE PositionVRelativeFrom;
BYTE PositionVAlign;
double PositionVPosOffset;
__int64 PositionVPosOffset;
double PositionVPctOffset;
double SimplePosX;
double SimplePosY;
__int64 SimplePosX;
__int64 SimplePosY;
std::wstring sChartRels;
std::wstring sSizeRelH;
std::wstring sSizeRelV;
@ -2234,24 +2310,17 @@ public:
{
if(bWidth && bHeight)
{
__int64 emuWidth = (__int64)(g_dKoef_mm_to_emu * Width);
__int64 emuHeight = (__int64)(g_dKoef_mm_to_emu * Height);
if(false == bChart)
sXml += L"<wp:inline xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstring(emuWidth) + L"\" cy=\"" + std::to_wstring(emuHeight) + L"\"/>";
distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstring(Width) + L"\" cy=\"" + std::to_wstring(Height) + L"\"/>";
else
sXml += L"<w:drawing><wp:inline distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">\
<wp:extent cx=\"" + std::to_wstring(emuWidth) + L"\" cy=\"" + std::to_wstring(emuHeight) + L"\"/>";
<wp:extent cx=\"" + std::to_wstring(Width) + L"\" cy=\"" + std::to_wstring(Height) + L"\"/>";
if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB)
{
__int64 emuEffectExtentL = (__int64)(g_dKoef_mm_to_emu * EffectExtentL);
__int64 emuEffectExtentT = (__int64)(g_dKoef_mm_to_emu * EffectExtentT);
__int64 emuEffectExtentR = (__int64)(g_dKoef_mm_to_emu * EffectExtentR);
__int64 emuEffectExtentB = (__int64)(g_dKoef_mm_to_emu * EffectExtentB);
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(emuEffectExtentL) + L"\" t=\"" + std::to_wstring(emuEffectExtentT) +
L"\" r=\"" + std::to_wstring(emuEffectExtentR) + L"\" b=\"" + std::to_wstring(emuEffectExtentB) + L"\"/>";
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(EffectExtentL) + L"\" t=\"" + std::to_wstring(EffectExtentT) +
L"\" r=\"" + std::to_wstring(EffectExtentR) + L"\" b=\"" + std::to_wstring(EffectExtentB) + L"\"/>";
}
if(!sDocPr.empty())
@ -2293,13 +2362,13 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
__int64 emuDistB = 0;
if(bDistL)
emuDistL = (__int64)(g_dKoef_mm_to_emu * DistL);
emuDistL = DistL;
if(bDistT)
emuDistT = (__int64)(g_dKoef_mm_to_emu * DistT);
emuDistT = DistT;
if(bDistR)
emuDistR = (__int64)(g_dKoef_mm_to_emu * DistR);
emuDistR = DistR;
if(bDistB)
emuDistB = (__int64)(g_dKoef_mm_to_emu * DistB);
emuDistB = DistB;
int nSimplePos = 0;
if(bBSimplePos && BSimplePos)
nSimplePos = 1;
@ -2328,10 +2397,10 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
__int64 emuX = 0;
if(bSimplePosX)
emuX = (__int64)(g_dKoef_mm_to_emu * SimplePosX);
emuX = SimplePosX;
__int64 emuY = 0;
if(bSimplePosY)
emuY = (__int64)(g_dKoef_mm_to_emu * SimplePosY);
emuY = SimplePosY;
sXml += L"<wp:simplePos x=\"" + std::to_wstring(emuX) + L"\" y=\"" + std::to_wstring(emuY) + L"\"/>";
if(bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset))
@ -2362,8 +2431,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
}
else if(bPositionHPosOffset)
{
__int64 emuPosOffset = (__int64)(g_dKoef_mm_to_emu * PositionHPosOffset);
sContent = L"<wp:posOffset>" + std::to_wstring(emuPosOffset) + L"</wp:posOffset>";
sContent = L"<wp:posOffset>" + std::to_wstring(PositionHPosOffset) + L"</wp:posOffset>";
}
else if(bPositionHPctOffset)
{
@ -2400,8 +2468,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
}
else if(bPositionVPosOffset)
{
__int64 emuPosOffset = (__int64)(g_dKoef_mm_to_emu * PositionVPosOffset);
sContent = L"<wp:posOffset>" + std::to_wstring(emuPosOffset) + L"</wp:posOffset>";
sContent = L"<wp:posOffset>" + std::to_wstring(PositionVPosOffset) + L"</wp:posOffset>";
}
else if(bPositionVPctOffset)
{
@ -2410,20 +2477,13 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
}
sXml += L"<wp:positionV relativeFrom=\"" + sRelativeFrom + L"\">" + sContent + L"</wp:positionV>";
}
__int64 emuWidth = (__int64)(g_dKoef_mm_to_emu * Width);
__int64 emuHeight = (__int64)(g_dKoef_mm_to_emu * Height);
sXml += L"<wp:extent cx=\"" + std::to_wstring(emuWidth) + L"\" cy=\"" + std::to_wstring(emuHeight)+ L"\"/>";
sXml += L"<wp:extent cx=\"" + std::to_wstring(Width) + L"\" cy=\"" + std::to_wstring(Height)+ L"\"/>";
if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB)
{
__int64 emuEffectExtentL = (__int64)(g_dKoef_mm_to_emu * EffectExtentL);
__int64 emuEffectExtentT = (__int64)(g_dKoef_mm_to_emu * EffectExtentT);
__int64 emuEffectExtentR = (__int64)(g_dKoef_mm_to_emu * EffectExtentR);
__int64 emuEffectExtentB = (__int64)(g_dKoef_mm_to_emu * EffectExtentB);
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(emuEffectExtentL) +
L"\" t=\"" + std::to_wstring(emuEffectExtentT) + L"\" r=\"" + std::to_wstring(emuEffectExtentR) +
L"\" b=\"" + std::to_wstring(emuEffectExtentB) + L"\"/>";
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(EffectExtentL) +
L"\" t=\"" + std::to_wstring(EffectExtentT) + L"\" r=\"" + std::to_wstring(EffectExtentR) +
L"\" b=\"" + std::to_wstring(EffectExtentB) + L"\"/>";
}
if(bDrawingPropertyWrap && DrawingPropertyWrap.bWrappingType)
{
@ -2454,9 +2514,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
if(DrawingPropertyWrap.bStart && DrawingPropertyWrap.Start.bX && DrawingPropertyWrap.Start.bY)
{
__int64 emuX = (__int64)(g_dKoef_mm_to_emu * DrawingPropertyWrap.Start.X);
__int64 emuY = (__int64)(g_dKoef_mm_to_emu * DrawingPropertyWrap.Start.Y);
sXml += L"<wp:start x=\"" + std::to_wstring(emuX) + L"\" y=\"" + std::to_wstring(emuY) + L"\"/>";
sXml += L"<wp:start x=\"" + std::to_wstring(DrawingPropertyWrap.Start.X) + L"\" y=\"" + std::to_wstring(DrawingPropertyWrap.Start.Y) + L"\"/>";
}
for(size_t i = 0; i < DrawingPropertyWrap.Points.size(); ++i)
@ -2464,9 +2522,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
CDrawingPropertyWrapPoint* pWrapPoint = DrawingPropertyWrap.Points[i];
if(pWrapPoint->bX && pWrapPoint->bY)
{
__int64 emuX = (__int64)(g_dKoef_mm_to_emu * pWrapPoint->X);
__int64 emuY = (__int64)(g_dKoef_mm_to_emu * pWrapPoint->Y);
sXml += L"<wp:lineTo x=\"" + std::to_wstring(emuX) + L"\" y=\"" + std::to_wstring(emuY) + L"\"/>";
sXml += L"<wp:lineTo x=\"" + std::to_wstring(pWrapPoint->X) + L"\" y=\"" + std::to_wstring(pWrapPoint->Y) + L"\"/>";
}
}
sXml += L"</wp:wrapPolygon>";
@ -2800,30 +2856,51 @@ public:
}
void Write(NSStringUtils::CStringBuilder& wr)
{
if(false == rId.empty())
wr.WriteString(L"<w:hyperlink");
if(!rId.empty())
{
std::wstring sCorrect_rId = XmlUtils::EncodeXmlString(rId);
std::wstring sCorrect_tooltip = XmlUtils::EncodeXmlString(sTooltip);
std::wstring sCorrect_anchor = XmlUtils::EncodeXmlString(sAnchor);
std::wstring sStart = L"<w:hyperlink r:id=\"" + sCorrect_rId + L"\"";
if(false == sTooltip.empty())
{
sStart += L" w:tooltip=\"";
sStart += sCorrect_tooltip;
sStart += L"\"";
}
if(false == sAnchor.empty())
{
sStart += L" w:anchor=\"";
sStart += sCorrect_anchor;
sStart += L"\"";
}
sStart += L" w:history=\"1\">";
wr.WriteString(sStart);
wr.Write(writer);
wr.WriteString(L"</w:hyperlink>");
wr.WriteString(L" r:id=\"");
wr.WriteEncodeXmlString(rId);
wr.WriteString(L"\"");
}
if(!sTooltip.empty())
{
wr.WriteString(L" w:tooltip=\"");
wr.WriteEncodeXmlString(sTooltip);
wr.WriteString(L"\"");
}
if(!sAnchor.empty())
{
wr.WriteString(L" w:anchor=\"");
wr.WriteEncodeXmlString(sAnchor);
wr.WriteString(L"\"");
}
if (bHistory)
{
if (History)
{
wr.WriteString(L" w:history=\"1\"");
}
else
{
wr.WriteString(L" w:history=\"0\"");
}
}
if (!sDocLocation.empty())
{
wr.WriteString(L" w:docLocation=\"");
wr.WriteEncodeXmlString(sDocLocation);
wr.WriteString(L"\"");
}
if (!sTgtFrame.empty())
{
wr.WriteString(L" w:tgtFrame=\"");
wr.WriteEncodeXmlString(sTgtFrame);
wr.WriteString(L"\"");
}
wr.WriteString(L">");
wr.Write(writer);
wr.WriteString(L"</w:hyperlink>");
}
};
class CFldSimple{

View File

@ -34,6 +34,41 @@
namespace BinDocxRW {
void InnerColorToOOX(rPr& oRPr, ComplexTypes::Word::CColor& oColor)
{
if (oRPr.bColor)
{
oColor.m_oVal.Init();
oColor.m_oVal->SetValue(SimpleTypes::hexcolorRGB);
oColor.m_oVal->Set_R(oRPr.Color.R);
oColor.m_oVal->Set_G(oRPr.Color.G);
oColor.m_oVal->Set_B(oRPr.Color.B);
}
if (oRPr.bThemeColor && oRPr.ThemeColor.IsNoEmpty())
{
if(oRPr.ThemeColor.Auto && !oRPr.bColor)
{
oColor.m_oVal.Init();
oColor.m_oVal->SetValue(SimpleTypes::hexcolorAuto);
}
if(oRPr.ThemeColor.bColor)
{
oColor.m_oThemeColor.Init();
oColor.m_oThemeColor->SetValue((SimpleTypes::EThemeColor)oRPr.ThemeColor.Color);
}
if(oRPr.ThemeColor.bTint)
{
oColor.m_oThemeTint.Init();
oColor.m_oThemeTint->SetValue(oRPr.ThemeColor.Tint);
}
if(oRPr.ThemeColor.bShade)
{
oColor.m_oThemeShade.Init();
oColor.m_oThemeShade->SetValue(oRPr.ThemeColor.Shade);
}
}
}
int Binary_VbaProjectTableReader::Read()
{
m_oFileWriter.m_pVbaProject = new OOX::VbaProject(NULL);

View File

@ -100,10 +100,9 @@ public:
RELEASEOBJECT(m_oRPr)
}
};
#define READ1_DEF(stLen, res, fReadFunction, arg) {\
long read1defCurPos = 0;\
while(read1defCurPos < stLen)\
while(read1defCurPos < (long)stLen)\
{\
BYTE read1defType = m_oBufferedStream.GetUChar();\
long read1defLength = m_oBufferedStream.GetLong();\
@ -120,7 +119,7 @@ public:
}
#define READ2_DEF(stLen, res, fReadFunction, arg) {\
long read2defCurPos = 0;\
while(read2defCurPos < stLen)\
while(read2defCurPos < (long)stLen)\
{\
BYTE read2defType = m_oBufferedStream.GetUChar();\
long read2defLenType = m_oBufferedStream.GetUChar();\
@ -182,6 +181,8 @@ public:
poResult->UserId = m_oBufferedStream.GetString3(length);\
}
void InnerColorToOOX(rPr& oRPr, ComplexTypes::Word::CColor& oColor);
class Binary_CommonReader
{
protected:
@ -454,7 +455,13 @@ public:
case c_oSerProp_rPrType::Spacing:
{
orPr->bSpacing = true;
orPr->Spacing = m_oBufferedStream.GetDouble();
orPr->Spacing = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
break;
case c_oSerProp_rPrType::SpacingTwips:
{
orPr->bSpacing = true;
orPr->Spacing = m_oBufferedStream.GetLong();
}
break;
case c_oSerProp_rPrType::DStrikeout:
@ -478,7 +485,13 @@ public:
case c_oSerProp_rPrType::Position:
{
orPr->bPosition = true;
orPr->Position = m_oBufferedStream.GetDouble();
orPr->Position = SerializeCommon::Round( g_dKoef_mm_to_hps * m_oBufferedStream.GetDouble());
}
break;
case c_oSerProp_rPrType::PositionHps:
{
orPr->bPosition = true;
orPr->Position = m_oBufferedStream.GetLong();
}
break;
case c_oSerProp_rPrType::FontHint:
@ -722,12 +735,12 @@ public:
{
Spacing oSpacing;
READ2_DEF(length, res, this->ReadSpacing, &oSpacing);
if(oSpacing.bLine || oSpacing.bAfter || oSpacing.bAfterAuto || oSpacing.bBefore || oSpacing.bBeforeAuto)
if(oSpacing.bLine || oSpacing.bLineTwips || oSpacing.bAfter || oSpacing.bAfterAuto || oSpacing.bBefore || oSpacing.bBeforeAuto)
{
pCStringWriter->WriteString(std::wstring(L"<w:spacing"));
BYTE bLineRule = linerule_Auto;
//проверяется bLine, а не bLineRule чтобы всегда писать LineRule, если есть w:line
if(oSpacing.bLine)
if(oSpacing.bLine || oSpacing.bLineTwips)
{
if(oSpacing.bLineRule)
bLineRule = oSpacing.LineRule;
@ -755,10 +768,13 @@ public:
}
pCStringWriter->WriteString(sLine);
}
else if(oSpacing.bLineTwips)
{
pCStringWriter->WriteString(L" w:line=\"" + std::to_wstring(oSpacing.LineTwips) + L"\"");
}
if(oSpacing.bAfter)
{
long After = SerializeCommon::Round( g_dKoef_mm_to_twips * oSpacing.After);
std::wstring sAfter = L" w:after=\"" + std::to_wstring(After) + L"\"";
std::wstring sAfter = L" w:after=\"" + std::to_wstring(oSpacing.After) + L"\"";
pCStringWriter->WriteString(sAfter);
}
if(oSpacing.bAfterAuto)
@ -770,8 +786,7 @@ public:
}
if(oSpacing.bBefore)
{
long Before = SerializeCommon::Round( g_dKoef_mm_to_twips * oSpacing.Before);
std::wstring sBefore = L" w:before=\"" + std::to_wstring(Before) + L"\"";
std::wstring sBefore = L" w:before=\"" + std::to_wstring(oSpacing.Before) + L"\"";
pCStringWriter->WriteString(sBefore);
}
if(oSpacing.bBeforeAuto)
@ -815,7 +830,6 @@ public:
for(size_t i = 0; i < nLen; ++i)
{
Tab& oTab = oTabs.m_aTabs[i];
long nTab = SerializeCommon::Round( g_dKoef_mm_to_twips * oTab.Pos);
std::wstring sVal;
switch(oTab.Val)
{
@ -824,7 +838,7 @@ public:
case g_tabtype_clear: sVal = L"clear"; break;
default: sVal = L"left"; break;
}
pCStringWriter->WriteString(L"<w:tab w:val=\"" + sVal + L"\" w:pos=\"" + std::to_wstring(nTab) + L"\"");
pCStringWriter->WriteString(L"<w:tab w:val=\"" + sVal + L"\" w:pos=\"" + std::to_wstring(oTab.Pos) + L"\"");
if (oTab.bLeader)
{
std::wstring sLeader;
@ -936,6 +950,11 @@ public:
pCStringWriter->WriteString(L" w:left=\"" + std::to_wstring(nIndLeft) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_LeftTwips:
{
pCStringWriter->WriteString(L" w:left=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_Right:
{
double dIndRight = m_oBufferedStream.GetDouble();
@ -944,18 +963,34 @@ public:
pCStringWriter->WriteString(L" w:right=\"" + std::to_wstring(nIndRight) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_RightTwips:
{
pCStringWriter->WriteString(L" w:right=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_FirstLine:
{
double dIndFirstLine = m_oBufferedStream.GetDouble();
long nIndFirstLine = SerializeCommon::Round(dIndFirstLine * g_dKoef_mm_to_twips);
std::wstring sIndFirstLine;
if(nIndFirstLine > 0)
if(nIndFirstLine >= 0)
sIndFirstLine = L" w:firstLine =\"" + std::to_wstring(nIndFirstLine) + L"\"";
else
sIndFirstLine = L" w:hanging=\"" + std::to_wstring(-nIndFirstLine) + L"\"";
pCStringWriter->WriteString(sIndFirstLine);
break;
}
case c_oSerProp_pPrType::Ind_FirstLineTwips:
{
long nIndFirstLine = m_oBufferedStream.GetLong();
std::wstring sIndFirstLine;
if(nIndFirstLine >= 0)
sIndFirstLine = L" w:firstLine =\"" + std::to_wstring(nIndFirstLine) + L"\"";
else
sIndFirstLine = L" w:hanging=\"" + std::to_wstring(-nIndFirstLine) + L"\"";
pCStringWriter->WriteString(sIndFirstLine);
break;
}
default:
res = c_oSerConstants::ReadUnknown;
break;
@ -972,17 +1007,29 @@ public:
pSpacing->bLine = true;
pSpacing->Line = m_oBufferedStream.GetDouble();
break;
case c_oSerProp_pPrType::Spacing_LineTwips:
pSpacing->bLineTwips = true;
pSpacing->LineTwips = m_oBufferedStream.GetLong();
break;
case c_oSerProp_pPrType::Spacing_LineRule:
pSpacing->bLineRule = true;
pSpacing->LineRule = m_oBufferedStream.GetUChar();
break;
case c_oSerProp_pPrType::Spacing_Before:
pSpacing->bBefore = true;
pSpacing->Before = m_oBufferedStream.GetDouble();
pSpacing->Before = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
break;
case c_oSerProp_pPrType::Spacing_BeforeTwips:
pSpacing->bBefore = true;
pSpacing->Before = m_oBufferedStream.GetLong();
break;
case c_oSerProp_pPrType::Spacing_After:
pSpacing->bAfter = true;
pSpacing->After = m_oBufferedStream.GetDouble();
pSpacing->After = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
break;
case c_oSerProp_pPrType::Spacing_AfterTwips:
pSpacing->bAfter = true;
pSpacing->After = m_oBufferedStream.GetLong();
break;
case c_oSerProp_pPrType::Spacing_BeforeAuto:
pSpacing->bBeforeAuto = true;
@ -1019,7 +1066,9 @@ public:
if(c_oSerProp_pPrType::Tab_Item_Val == type)
poTabItem->Val = m_oBufferedStream.GetUChar();
else if(c_oSerProp_pPrType::Tab_Item_Pos == type)
poTabItem->Pos = m_oBufferedStream.GetDouble();
poTabItem->Pos = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
else if(c_oSerProp_pPrType::Tab_Item_PosTwips == type)
poTabItem->Pos = m_oBufferedStream.GetLong();
else if(c_oSerProp_pPrType::Tab_Item_Leader == type)
{
poTabItem->bLeader = true;
@ -1112,12 +1161,22 @@ public:
else if( c_oSerBorderType::Space == type )
{
odocBorder->bSpace = true;
odocBorder->Space = m_oBufferedStream.GetDouble();
odocBorder->Space = SerializeCommon::Round(g_dKoef_mm_to_pt * m_oBufferedStream.GetDouble());
}
else if( c_oSerBorderType::SpacePoint == type )
{
odocBorder->bSpace = true;
odocBorder->Space = m_oBufferedStream.GetLong();
}
else if( c_oSerBorderType::Size == type )
{
odocBorder->bSize = true;
odocBorder->Size = m_oBufferedStream.GetDouble();
odocBorder->Size = SerializeCommon::Round(g_dKoef_mm_to_eightpoint * m_oBufferedStream.GetDouble());
}
else if( c_oSerBorderType::Size8Point == type )
{
odocBorder->bSize = true;
odocBorder->Size = m_oBufferedStream.GetLong();
}
else if( c_oSerBorderType::Value == type )
{
@ -1373,15 +1432,28 @@ public:
int res = c_oSerConstants::ReadOk;
if( c_oSer_pgSzType::Orientation == type )
{
pSectPr->bOrientation = true;
pSectPr->cOrientation = m_oBufferedStream.GetUChar();
}
else if( c_oSer_pgSzType::W == type )
{
pSectPr->W = m_oBufferedStream.GetDouble();
pSectPr->bW = true;
pSectPr->W = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgSzType::WTwips == type )
{
pSectPr->bW = true;
pSectPr->W = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgSzType::H == type )
{
pSectPr->H = m_oBufferedStream.GetDouble();
pSectPr->bH = true;
pSectPr->H = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgSzType::HTwips == type )
{
pSectPr->bH = true;
pSectPr->H = m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -1393,29 +1465,63 @@ public:
int res = c_oSerConstants::ReadOk;
if( c_oSer_pgMarType::Left == type )
{
pSectPr->Left = m_oBufferedStream.GetDouble();
pSectPr->bLeft = true;
pSectPr->Left = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::LeftTwips == type )
{
pSectPr->bLeft = true;
pSectPr->Left = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Top == type )
{
pSectPr->Top = m_oBufferedStream.GetDouble();
pSectPr->bTop = true;
pSectPr->Top = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::TopTwips == type )
{
pSectPr->bTop = true;
pSectPr->Top = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Right == type )
{
pSectPr->Right = m_oBufferedStream.GetDouble();
pSectPr->bRight = true;
pSectPr->Right = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::RightTwips == type )
{
pSectPr->bRight = true;
pSectPr->Right = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Bottom == type )
{
pSectPr->Bottom = m_oBufferedStream.GetDouble();
pSectPr->bBottom = true;
pSectPr->Bottom = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::BottomTwips == type )
{
pSectPr->bBottom = true;
pSectPr->Bottom = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Header == type )
{
pSectPr->bHeader = true;
pSectPr->Header = m_oBufferedStream.GetDouble();
pSectPr->Header = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::HeaderTwips == type )
{
pSectPr->bHeader = true;
pSectPr->Header = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Footer == type )
{
pSectPr->bFooter = true;
pSectPr->Footer = m_oBufferedStream.GetDouble();
pSectPr->Footer = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::FooterTwips == type )
{
pSectPr->bFooter = true;
pSectPr->Footer = m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -1715,6 +1821,10 @@ public:
long nInd = SerializeCommon::Round( g_dKoef_mm_to_twips * dInd);
pWiterTblPr->TableInd = L"<w:tblInd w:w=\"" + std::to_wstring(nInd) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::TableIndTwips == type )
{
pWiterTblPr->TableInd = L"<w:tblInd w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::TableW == type )
{
docW odocW;
@ -1814,6 +1924,10 @@ public:
long nSpacing = SerializeCommon::Round( g_dKoef_mm_to_twips * dSpacing);
pWiterTblPr->TableCellSpacing = L"<w:tblCellSpacing w:w=\"" + std::to_wstring(nSpacing) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::TableCellSpacingTwips == type )
{
pWiterTblPr->TableCellSpacing = L"<w:tblCellSpacing w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::tblCaption == type )
{
pWiterTblPr->Caption = m_oBufferedStream.GetString3(length);
@ -1958,6 +2072,10 @@ public:
pCStringWriter->WriteString(L" w:tblpX=\"" + std::to_wstring(nX) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpXTwips == type )
{
pCStringWriter->WriteString(L" w:tblpX=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpXSpec == type )
{
std::wstring sXml;
@ -1991,6 +2109,10 @@ public:
pCStringWriter->WriteString(L" w:tblpY=\"" + std::to_wstring(nY) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpYTwips == type )
{
pCStringWriter->WriteString(L" w:tblpY=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpYSpec == type )
{
std::wstring sXml;
@ -2054,7 +2176,7 @@ public:
if(true == orowPrAfterBefore.bGridAfter && orowPrAfterBefore.nGridAfter > 0 && false == orowPrAfterBefore.oAfterWidth.bW)
{
//ищем по tblGrid
if(orowPrAfterBefore.nGridAfter < m_aCurTblGrid.size())
if(orowPrAfterBefore.nGridAfter < (long)m_aCurTblGrid.size())
{
double nSumW = 0;
for(int i = 0; i < orowPrAfterBefore.nGridAfter; i++)
@ -2086,6 +2208,10 @@ public:
pCStringWriter->WriteString(L"<w:tblCellSpacing w:w=\"" + std::to_wstring(nSpacing) + L"\" w:type=\"dxa\"/>");
}
else if( c_oSerProp_rowPrType::TableCellSpacingTwips == type )
{
pCStringWriter->WriteString(L"<w:tblCellSpacing w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\" w:type=\"dxa\"/>");
}
else if( c_oSerProp_rowPrType::Height == type )
{
RowHeight val;
@ -2179,6 +2305,10 @@ public:
double dHeight = m_oBufferedStream.GetDouble();
pHeight->nHeight = SerializeCommon::Round( g_dKoef_mm_to_twips * dHeight);
}
else if( c_oSerProp_rowPrType::Height_ValueTwips == type )
{
pHeight->nHeight = m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -2249,6 +2379,15 @@ public:
case vmerge_Continue:pCStringWriter->WriteString(std::wstring(_T("<w:vMerge w:val=\"continue\" />")));break;
}
}
else if( c_oSerProp_cellPrType::HMerge == type )
{
BYTE HMerge = m_oBufferedStream.GetUChar();
switch(HMerge)
{
case vmerge_Restart:pCStringWriter->WriteString(std::wstring(_T("<w:hMerge w:val=\"restart\" />")));break;
case vmerge_Continue:pCStringWriter->WriteString(std::wstring(_T("<w:hMerge w:val=\"continue\" />")));break;
}
}
else if( c_oSerProp_cellPrType::CellDel == type )
{
TrackRevision Del;
@ -2348,6 +2487,10 @@ public:
pCStringWriter->WriteString(L" w:leftFromText=\"" + std::to_wstring(nLeft) + L"\"");
}
else if (c_oSerPaddingType::leftTwips == type)
{
pCStringWriter->WriteString(L" w:leftFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if (c_oSerPaddingType::top == type)
{
double dTop = m_oBufferedStream.GetDouble();
@ -2355,6 +2498,10 @@ public:
pCStringWriter->WriteString(L" w:topFromText=\"" + std::to_wstring(nTop) + L"\"");
}
else if (c_oSerPaddingType::topTwips == type)
{
pCStringWriter->WriteString(L" w:topFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if (c_oSerPaddingType::right == type)
{
double dRight = m_oBufferedStream.GetDouble();
@ -2362,6 +2509,10 @@ public:
pCStringWriter->WriteString(L" w:rightFromText=\"" + std::to_wstring(nRight) + L"\"");
}
else if (c_oSerPaddingType::rightTwips == type)
{
pCStringWriter->WriteString(L" w:rightFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if (c_oSerPaddingType::bottom == type)
{
double dBottom = m_oBufferedStream.GetDouble();
@ -2369,6 +2520,10 @@ public:
pCStringWriter->WriteString(L" w:bottomFromText=\"" + std::to_wstring(nBottom) + L"\"");
}
else if (c_oSerPaddingType::bottomTwips == type)
{
pCStringWriter->WriteString(L" w:bottomFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -2587,7 +2742,7 @@ public:
if ( c_oSerNumTypes::Lvl == type )
{
docLvl* odocLvl = new docLvl();
odocLvl->ILvl = odocANum->Lvls.size();
odocLvl->ILvl = (long)odocANum->Lvls.size();
READ2_DEF(length, res, this->ReadLevel, odocLvl);
odocANum->Lvls.push_back(odocLvl);
}
@ -2821,7 +2976,8 @@ public:
}
else if(c_oSer_sts::Style_Default == type)
{
odocStyle->bDefault = (0 != m_oBufferedStream.GetUChar());
odocStyle->bDefault = true;
odocStyle->Default = m_oBufferedStream.GetBool();
}
else if(c_oSer_sts::Style_BasedOn == type)
{
@ -3220,11 +3376,13 @@ public:
class Binary_SettingsTableReader : public Binary_CommonReader
{
Binary_pPrReader m_oBinary_pPrReader;
Binary_rPrReader m_oBinary_rPrReader;
Writers::SettingWriter& m_oSettingWriter;
Writers::FileWriter& m_oFileWriter;
OOX::CSettingsCustom& m_oSettingsCustom;
public:
Binary_SettingsTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter):
Binary_CommonReader(poBufferedStream),m_oSettingWriter(oFileWriter.m_oSettingWriter),m_oFileWriter(oFileWriter),m_oBinary_pPrReader(poBufferedStream, oFileWriter)
Binary_SettingsTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, OOX::CSettingsCustom& oSettingsCustom):
Binary_CommonReader(poBufferedStream),m_oSettingWriter(oFileWriter.m_oSettingWriter),m_oFileWriter(oFileWriter),m_oBinary_pPrReader(poBufferedStream, oFileWriter),m_oBinary_rPrReader(poBufferedStream, oFileWriter),m_oSettingsCustom(oSettingsCustom)
{
}
int Read()
@ -3282,10 +3440,12 @@ public:
{
double dDefTabStop = m_oBufferedStream.GetDouble();
long nDefTabStop = SerializeCommon::Round(dDefTabStop * g_dKoef_mm_to_twips);
std::wstring sXml;
m_oFileWriter.m_oSettingWriter.AddSetting(L"<w:defaultTabStop w:val=\"" + std::to_wstring(nDefTabStop) + L"\"/>");
}
else if ( c_oSer_SettingsType::DefaultTabStopTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<w:defaultTabStop w:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else if ( c_oSer_SettingsType::MathPr == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(_T("<m:mathPr>"));
@ -3316,6 +3476,18 @@ public:
READ1_DEF(length, res, this->ReadEndnotePr, &oEdnProps);
m_oFileWriter.m_oSettingWriter.AddSetting(oEdnProps.toXML());
}
else if( c_oSer_SettingsType::SdtGlobalColor == type )
{
rPr oRPr(m_oFileWriter.m_oFontTableWriter.m_mapFonts);
res = m_oBinary_rPrReader.Read(length, &oRPr);
m_oSettingsCustom.m_oSdtGlobalColor.Init();
InnerColorToOOX(oRPr, m_oSettingsCustom.m_oSdtGlobalColor.get2());
}
else if( c_oSer_SettingsType::SdtGlobalShowHighlight == type )
{
m_oSettingsCustom.m_oSdtGlobalShowHighlight.Init();
m_oSettingsCustom.m_oSdtGlobalShowHighlight->m_oVal.FromBool(m_oBufferedStream.GetBool());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3558,6 +3730,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:interSp m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:interSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3590,6 +3766,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:intraSp m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:intraSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3603,6 +3783,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:lMargin m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:lMargin m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3654,6 +3838,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:postSp m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:postSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3667,6 +3855,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:preSp m:val=\"" + std::to_wstring(lVal)+ L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:preSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3680,6 +3872,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:rMargin m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:rMargin m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3710,6 +3906,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:wrapIndent m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:wrapIndent m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3868,7 +4068,7 @@ public:
oFile.WriteFile(pData, length);
oFile.CloseFile();
long lId;
unsigned int lId = 0;
m_oFileWriter.m_pDrawingConverter->WriteRels(OOX::FileTypes::JsaProject.RelationType(), sJsaProject.GetPath(), L"", &lId);
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(sJsaProject.GetExtention(false));
}
@ -3945,6 +4145,12 @@ public:
READ1_DEF(length, res, this->ReadMathArg, poResult);
m_oDocumentWriter.m_oContent.WriteString(std::wstring(_T("</m:oMath>")));
}
else if ( c_oSerParType::MRun == type )
{
GetRunStringWriter().WriteString(std::wstring(_T("<m:r>")));
READ1_DEF(length, res, this->ReadMathMRun, poResult);
GetRunStringWriter().WriteString(std::wstring(_T("</m:r>")));
}
else if ( c_oSerParType::Hyperlink == type )
{
CHyperlink oHyperlink;
@ -4493,11 +4699,13 @@ public:
NSStringUtils::CStringBuilder* pPrevWriter = m_pCurWriter;
m_pCurWriter = &pHyperlink->writer;
READ1_DEF(length, res, this->ReadParagraphContent, NULL);
long rId;
std::wstring sHref = XmlUtils::EncodeXmlString(pHyperlink->sLink);
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink")), sHref, std::wstring(_T("External")), &rId);
pHyperlink->rId = L"rId" + std::to_wstring(rId);
if (!pHyperlink->sLink.empty())
{
unsigned int rId;
std::wstring sHref = XmlUtils::EncodeXmlString(pHyperlink->sLink);
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink")), sHref, std::wstring(_T("External")), &rId);
pHyperlink->rId = L"rId" + std::to_wstring(rId);
}
m_pCurWriter = pPrevWriter;
}
else
@ -4565,6 +4773,12 @@ public:
READ1_DEF(length, res, this->ReadMathDelimiter, poResult);
GetRunStringWriter().WriteString(std::wstring(_T("</m:d>")));
}
else if ( c_oSer_OMathContentType::Del == type )
{
TrackRevision oTrackRevision;
READ1_DEF(length, res, this->ReadDelIns, &oTrackRevision);
oTrackRevision.Write(&GetRunStringWriter(), _T("w:del"));
}
else if ( c_oSer_OMathContentType::EqArr == type )
{
GetRunStringWriter().WriteString(std::wstring(_T("<m:eqArr>")));
@ -4589,6 +4803,12 @@ public:
READ1_DEF(length, res, this->ReadMathGroupChr, poResult);
GetRunStringWriter().WriteString(std::wstring(_T("</m:groupChr>")));
}
else if ( c_oSer_OMathContentType::Ins == type )
{
TrackRevision oTrackRevision;
READ1_DEF(length, res, this->ReadDelIns, &oTrackRevision);
oTrackRevision.Write(&GetRunStringWriter(), _T("w:ins"));
}
else if ( c_oSer_OMathContentType::LimLow == type )
{
GetRunStringWriter().WriteString(std::wstring(_T("<m:limLow>")));
@ -6844,7 +7064,7 @@ public:
std::wstring sNewImgRel = _T("media/") + sNewImgName;
sNewImgRel = XmlUtils::EncodeXmlString(sNewImgRel);
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image")), sNewImgRel, std::wstring(), &rId);
odocImg.srId = L"rId" + std::to_wstring(rId);
//odocImg.srId = m_oMediaWriter.m_poDocumentRelsWriter->AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"), sNewImgRel, false);
@ -7105,6 +7325,10 @@ public:
pCStringWriter->WriteString(L"<w:gridCol w:w=\"" + std::to_wstring(ngridCol)+ L"\"/>");
}
else if( c_oSerDocTableType::tblGrid_ItemTwips == type )
{
pCStringWriter->WriteString(L"<w:gridCol w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong())+ L"\"/>");
}
else if( c_oSerDocTableType::tblGridChange == type )
{
TrackRevision oTrackRevision;
@ -7385,7 +7609,7 @@ public:
if (oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace))
{
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rIdXlsx;
unsigned int rIdXlsx;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
@ -7412,7 +7636,7 @@ public:
OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + sFilename + L".rels";
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(pathChartsRels.GetPath());
long rIdChart;
unsigned int rIdChart;
std::wstring bstrChartRelType = OOX::FileTypes::Chart.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartRelType, sRelsName, std::wstring(), &rIdChart);
@ -7445,22 +7669,42 @@ public:
else if ( c_oSerImageType2::DistL == type )
{
pDrawingProperty->bDistL = true;
pDrawingProperty->DistL = m_oBufferedStream.GetDouble();
pDrawingProperty->DistL = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistLEmu == type )
{
pDrawingProperty->bDistL = true;
pDrawingProperty->DistL = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::DistT == type )
{
pDrawingProperty->bDistT = true;
pDrawingProperty->DistT = m_oBufferedStream.GetDouble();
pDrawingProperty->DistT = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistTEmu == type )
{
pDrawingProperty->bDistT = true;
pDrawingProperty->DistT = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::DistR == type )
{
pDrawingProperty->bDistR = true;
pDrawingProperty->DistR = m_oBufferedStream.GetDouble();
pDrawingProperty->DistR = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistREmu == type )
{
pDrawingProperty->bDistR = true;
pDrawingProperty->DistR = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::DistB == type )
{
pDrawingProperty->bDistB = true;
pDrawingProperty->DistB = m_oBufferedStream.GetDouble();
pDrawingProperty->DistB = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistBEmu == type )
{
pDrawingProperty->bDistB = true;
pDrawingProperty->DistB = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::LayoutInCell == type )
{
@ -7700,22 +7944,42 @@ public:
if ( c_oSerEffectExtent::Left == type )
{
pDrawingProperty->bEffectExtentL = true;
pDrawingProperty->EffectExtentL = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentL = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::LeftEmu == type )
{
pDrawingProperty->bEffectExtentL = true;
pDrawingProperty->EffectExtentL = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerEffectExtent::Top == type )
{
pDrawingProperty->bEffectExtentT = true;
pDrawingProperty->EffectExtentT = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentT = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::TopEmu == type )
{
pDrawingProperty->bEffectExtentT = true;
pDrawingProperty->EffectExtentT = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerEffectExtent::Right == type )
{
pDrawingProperty->bEffectExtentR = true;
pDrawingProperty->EffectExtentR = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentR = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::RightEmu == type )
{
pDrawingProperty->bEffectExtentR = true;
pDrawingProperty->EffectExtentR = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerEffectExtent::Bottom == type )
{
pDrawingProperty->bEffectExtentB = true;
pDrawingProperty->EffectExtentB = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentB = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::BottomEmu == type )
{
pDrawingProperty->bEffectExtentB = true;
pDrawingProperty->EffectExtentB = (__int64)m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -7728,12 +7992,22 @@ public:
if ( c_oSerExtent::Cx == type )
{
pDrawingProperty->bWidth = true;
pDrawingProperty->Width = m_oBufferedStream.GetDouble();
pDrawingProperty->Width = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerExtent::CxEmu == type )
{
pDrawingProperty->bWidth = true;
pDrawingProperty->Width = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerExtent::Cy == type )
{
pDrawingProperty->bHeight = true;
pDrawingProperty->Height = m_oBufferedStream.GetDouble();
pDrawingProperty->Height = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerExtent::CyEmu == type )
{
pDrawingProperty->bHeight = true;
pDrawingProperty->Height = (__int64)m_oBufferedStream.GetULong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -7756,7 +8030,12 @@ public:
else if ( c_oSerPosHV::PosOffset == type )
{
pDrawingProperty->bPositionHPosOffset = true;
pDrawingProperty->PositionHPosOffset = m_oBufferedStream.GetDouble();
pDrawingProperty->PositionHPosOffset = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPosHV::PosOffsetEmu == type )
{
pDrawingProperty->bPositionHPosOffset = true;
pDrawingProperty->PositionHPosOffset = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerPosHV::PctOffset == type )
{
@ -7784,7 +8063,12 @@ public:
else if ( c_oSerPosHV::PosOffset == type )
{
pDrawingProperty->bPositionVPosOffset = true;
pDrawingProperty->PositionVPosOffset = m_oBufferedStream.GetDouble();
pDrawingProperty->PositionVPosOffset = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPosHV::PosOffsetEmu == type )
{
pDrawingProperty->bPositionVPosOffset = true;
pDrawingProperty->PositionVPosOffset = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerPosHV::PctOffset == type )
{
@ -7802,12 +8086,22 @@ public:
if ( c_oSerSimplePos::X == type )
{
pDrawingProperty->bSimplePosX = true;
pDrawingProperty->SimplePosX = m_oBufferedStream.GetDouble();
pDrawingProperty->SimplePosX = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerSimplePos::XEmu == type )
{
pDrawingProperty->bSimplePosX = true;
pDrawingProperty->SimplePosX = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerSimplePos::Y == type )
{
pDrawingProperty->bSimplePosY = true;
pDrawingProperty->SimplePosY = m_oBufferedStream.GetDouble();
pDrawingProperty->SimplePosY = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerSimplePos::YEmu == type )
{
pDrawingProperty->bSimplePosY = true;
pDrawingProperty->SimplePosY = (__int64)m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -7903,12 +8197,22 @@ public:
if ( c_oSerPoint2D::X == type )
{
pWrapPoint->bX = true;
pWrapPoint->X = m_oBufferedStream.GetDouble();
pWrapPoint->X = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPoint2D::XEmu == type )
{
pWrapPoint->bX = true;
pWrapPoint->X = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerPoint2D::Y == type )
{
pWrapPoint->bY = true;
pWrapPoint->Y = m_oBufferedStream.GetDouble();
pWrapPoint->Y = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPoint2D::YEmu == type )
{
pWrapPoint->bY = true;
pWrapPoint->Y = (__int64)m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -8002,11 +8306,24 @@ public:
pSdtPr->m_oAlias->m_sVal.Init();
pSdtPr->m_oAlias->m_sVal->append(m_oBufferedStream.GetString3(length));
}
else if (c_oSerSdt::Appearance == type)
{
pSdtPr->m_oAppearance.Init();
pSdtPr->m_oAppearance->m_oVal.Init();
pSdtPr->m_oAppearance->m_oVal->SetValue((SimpleTypes::ESdtAppearance)m_oBufferedStream.GetUChar());
}
else if (c_oSerSdt::ComboBox == type)
{
pSdtPr->m_oComboBox.Init();
READ1_DEF(length, res, this->ReadSdtComboBox, pSdtPr->m_oComboBox.GetPointer());
}
else if (c_oSerSdt::Color == type)
{
rPr oRPr(m_oFileWriter.m_oFontTableWriter.m_mapFonts);
res = oBinary_rPrReader.Read(length, &oRPr);
pSdtPr->m_oColor.Init();
InnerColorToOOX(oRPr, pSdtPr->m_oColor.get2());
}
else if (c_oSerSdt::DataBinding == type)
{
pSdtPr->m_oDataBinding.Init();
@ -8422,11 +8739,12 @@ public:
if(c_oSerConstants::ReadOk != res)
return res;
}
OOX::CSettingsCustom oSettingsCustom;
if(-1 != nSettingsOffset)
{
int nOldPos = m_oBufferedStream.GetPos();
m_oBufferedStream.Seek(nSettingsOffset);
res = Binary_SettingsTableReader(m_oBufferedStream, m_oFileWriter).Read();
res = Binary_SettingsTableReader(m_oBufferedStream, m_oFileWriter, oSettingsCustom).Read();
if(c_oSerConstants::ReadOk != res)
return res;
}
@ -8505,7 +8823,7 @@ public:
m_oBufferedStream.Seek(nDocumentOffset);
m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
long stamdartRId;
unsigned int stamdartRId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml", L"", &stamdartRId);
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings", L"settings.xml", L"", &stamdartRId);
@ -8533,19 +8851,19 @@ public:
if(false == m_oFileWriter.m_oNumberingWriter.IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", L"numbering.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", L"/word", L"numbering.xml");
}
if(false == m_oFileWriter.m_oFootnotesWriter.IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", L"footnotes.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", L"/word", L"footnotes.xml");
}
if(false == m_oFileWriter.m_oEndnotesWriter.IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes", L"endnotes.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml", L"/word", L"endnotes.xml");
}
@ -8554,7 +8872,7 @@ public:
Writers::HdrFtrItem* pHeader = m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders[i];
if(false == pHeader->IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", pHeader->m_sFilename, std::wstring(), &rId);
pHeader->rId = L"rId" + std::to_wstring( rId );
@ -8566,13 +8884,20 @@ public:
Writers::HdrFtrItem* pFooter = m_oFileWriter.m_oHeaderFooterWriter.m_aFooters[i];
if(false == pFooter->IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", pFooter->m_sFilename, std::wstring(), &rId);
pFooter->rId = L"rId" + std::to_wstring( rId );
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml", L"/word", pFooter->m_sFilename);
}
}
if(!oSettingsCustom.IsEmpty()){
std::wstring sFilename = m_oFileWriter.m_oCustomXmlWriter.WriteCustomXml(oSettingsCustom.GetSchemaUrl(), oSettingsCustom.ToXml());
std::wstring sRelsPath = L"../" + OOX::FileTypes::CustomXml.DefaultDirectory().GetPath() + L"/" + sFilename;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(OOX::FileTypes::CustomXml.RelationType(), sRelsPath, L"", &rId);
}
res = Binary_DocumentTableReader(m_oBufferedStream, m_oFileWriter, m_oFileWriter.m_oDocumentWriter, &oBinary_CommentsTableReader.m_oComments).Read();
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word"
@ -8590,19 +8915,19 @@ public:
if(false == oCommentsWriter.m_sComment.empty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", L"comments.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml", L"/word", L"comments.xml");
}
if(false == oCommentsWriter.m_sCommentExt.empty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/commentsExtended", L"commentsExtended.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml", L"/word", L"commentsExtended.xml");
}
if(false == oCommentsWriter.m_sPeople.empty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/people", L"people.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml", L"/word", L"people.xml");
}

File diff suppressed because one or more lines are too long

View File

@ -38,7 +38,7 @@
namespace Writers
{
static std::wstring g_string_ft_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:fonts xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" mc:Ignorable=\"w14\">");
static std::wstring g_string_ft_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:fonts xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" mc:Ignorable=\"w14 w15\">");
static std::wstring g_string_ft_End = _T("</w:fonts>");
class FontTableWriter

View File

@ -1438,8 +1438,8 @@ namespace MathEquation
}
else if (eType == commandBrackets)
{
MBRACKETSTYPE ebType;
EndBrackets(ebType, false,false);
MBRACKETSTYPE ebType = MBRACKETSTYPE::bracketsAngle; //???
EndBrackets(ebType, false, false);
}
}
virtual void BeginAngleBracketsWithSeparator(MANGLEBRACKETSWITHSEPARATORTYPE eType)

View File

@ -36,17 +36,6 @@ namespace BinDocxRW
{
const double eps = 0.001;
const int Page_Width = 210;
const int Page_Height = 297;
const int X_Left_Margin = 30; // 3 cm
const int X_Right_Margin = 15; // 1.5 cm
const int Y_Bottom_Margin = 20; // 2 cm
const int Y_Top_Margin = 20; // 2 cm
const double Y_Default_Header = 12.5; // 1.25 cm расстояние от верха страницы до верха верхнего колонтитула
const double Y_Default_Footer = 12.5; // 1.25 cm расстояние от низа страницы до низа нижнего колонтитула
const int shd_Clear = 0;
const int shd_Nil = 1;
@ -156,7 +145,8 @@ extern int g_nCurFormatVersion;
Endnotes = 11,
Background = 12,
VbaProject = 13,
App = 14
App = 15,
Core = 16
};}
namespace c_oSerSigTypes{enum c_oSerSigTypes
{
@ -311,7 +301,9 @@ extern int g_nCurFormatVersion;
RowBandSize = 15,
ColBandSize = 16,
tblCaption = 17,
tblDescription = 18
tblDescription = 18,
TableIndTwips = 19,
TableCellSpacingTwips = 20
};}
namespace c_oSer_tblpPrType{enum c_oSer_tblpPrType
{
@ -328,7 +320,9 @@ extern int g_nCurFormatVersion;
VertAnchor = 3,
TblpY = 4,
TblpYSpec = 5,
Paddings = 6
Paddings = 6,
TblpXTwips = 7,
TblpYTwips = 8
};}
namespace c_oSerProp_pPrType{enum c_oSerProp_pPrType
{
@ -365,7 +359,14 @@ extern int g_nCurFormatVersion;
numPr_Ins = 32,
pPrChange = 33,
outlineLvl = 34,
Tab_Item_Leader = 35
Tab_Item_Leader = 35,
Ind_LeftTwips = 36,
Ind_RightTwips = 37,
Ind_FirstLineTwips = 38,
Spacing_LineTwips = 39,
Spacing_BeforeTwips = 40,
Spacing_AfterTwips = 41,
Tab_Item_PosTwips = 42
};}
namespace c_oSerProp_rPrType{enum c_oSerProp_rPrType
{
@ -406,7 +407,9 @@ extern int g_nCurFormatVersion;
Ins = 34,
rPrChange = 35,
MoveFrom = 36,
MoveTo = 37
MoveTo = 37,
SpacingTwips = 38,
PositionHps = 39
};}
namespace c_oSerProp_rowPrType{enum c_oSerProp_rowPrType
{
@ -427,7 +430,9 @@ extern int g_nCurFormatVersion;
TableHeader = 14,
Del = 15,
Ins = 16,
trPrChange = 17
trPrChange = 17,
TableCellSpacingTwips = 18,
Height_ValueTwips = 19
};}
namespace c_oSerProp_cellPrType{enum c_oSerProp_cellPrType
{
@ -445,7 +450,8 @@ extern int g_nCurFormatVersion;
textDirection = 11,
hideMark = 12,
noWrap = 13,
tcFitText = 14
tcFitText = 14,
HMerge = 15
};}
namespace c_oSerProp_secPrType{enum c_oSerProp_secPrType
{
@ -498,8 +504,8 @@ extern int g_nCurFormatVersion;
MoveToRangeEnd = 21,
JsaProject = 22,
BookmarkStart = 23,
BookmarkEnd = 24
BookmarkEnd = 24,
MRun = 25
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{
@ -516,7 +522,8 @@ extern int g_nCurFormatVersion;
tblGridChange = 9,
Sdt = 10,
BookmarkStart = 11,
BookmarkEnd = 12
BookmarkEnd = 12,
tblGrid_ItemTwips = 13
};}
namespace c_oSerRunType{enum c_oSerRunType
{
@ -606,26 +613,37 @@ extern int g_nCurFormatVersion;
SizeRelV = 28,
Embedded = 29,
GraphicFramePr = 30,
DocPr = 31
DocPr = 31,
DistBEmu = 32,
DistLEmu = 33,
DistREmu = 34,
DistTEmu = 35
};}
namespace c_oSerEffectExtent{enum c_oSerEffectExtent
{
Left = 0,
Top = 1,
Right = 2,
Bottom = 3
Bottom = 3,
LeftEmu = 4,
TopEmu = 5,
RightEmu = 6,
BottomEmu = 7
};}
namespace c_oSerExtent{enum c_oSerExtent
{
Cx = 0,
Cy = 1
Cy = 1,
CxEmu = 2,
CyEmu = 3
};}
namespace c_oSerPosHV{enum c_oSerPosHV
{
RelativeFrom = 0,
Align = 1,
PosOffset = 2,
PctOffset = 3
PctOffset = 3,
PosOffsetEmu = 4
};}
namespace c_oSerSizeRelHV{enum c_oSerSizeRelHV
{
@ -635,7 +653,9 @@ extern int g_nCurFormatVersion;
namespace c_oSerSimplePos{enum c_oSerSimplePos
{
X = 0,
Y = 1
Y = 1,
XEmu = 2,
YEmu = 3
};}
namespace c_oSerWrapSquare{enum c_oSerWrapSquare
{
@ -644,20 +664,28 @@ extern int g_nCurFormatVersion;
DistR = 2,
DistB = 3,
WrapText = 4,
EffectExtent = 5
EffectExtent = 5,
DistLEmu = 6,
DistTEmu = 7,
DistREmu = 8,
DistBEmu = 9
};}
namespace c_oSerWrapThroughTight{enum c_oSerWrapThroughTight
{
DistL = 0,
DistR = 1,
WrapText = 2,
WrapPolygon = 3
WrapPolygon = 3,
DistLEmu = 4,
DistREmu = 5
};}
namespace c_oSerWrapTopBottom{enum c_oSerWrapTopBottom
{
DistT = 0,
DistB = 1,
EffectExtent = 2
EffectExtent = 2,
DistTEmu = 3,
DistBEmu = 4
};}
namespace c_oSerWrapPolygon{enum c_oSerWrapPolygon
{
@ -669,7 +697,9 @@ extern int g_nCurFormatVersion;
namespace c_oSerPoint2D{enum c_oSerPoint2D
{
X = 0,
Y = 1
Y = 1,
XEmu = 2,
YEmu = 3
};}
namespace c_oSerBorderType{enum c_oSerBorderType
{
@ -677,7 +707,9 @@ extern int g_nCurFormatVersion;
Space = 1,
Size = 2,
Value = 3,
ColorTheme = 4
ColorTheme = 4,
SpacePoint = 5,
Size8Point = 6
};}
namespace c_oSerShdType{enum c_oSerShdType
{
@ -690,7 +722,11 @@ extern int g_nCurFormatVersion;
left = 0,
top = 1,
right = 2,
bottom = 3
bottom = 3,
leftTwips = 4,
topTwips = 5,
rightTwips = 6,
bottomTwips = 7
};}
namespace c_oSerMarginsType{enum c_oSerMarginsType
{
@ -724,7 +760,9 @@ extern int g_nCurFormatVersion;
{
W = 0,
H = 1,
Orientation = 2
Orientation = 2,
WTwips = 3,
HTwips = 4
};}
namespace c_oSer_pgMarType{enum c_oSer_pgMarType
{
@ -733,7 +771,13 @@ extern int g_nCurFormatVersion;
Right = 2,
Bottom = 3,
Header = 4,
Footer = 5
Footer = 5,
LeftTwips = 6,
TopTwips = 7,
RightTwips = 8,
BottomTwips = 9,
HeaderTwips = 10,
FooterTwips = 11
};}
namespace c_oSer_ColorType{enum c_oSer_ColorType
{
@ -761,7 +805,11 @@ extern int g_nCurFormatVersion;
MathPr = 2,
TrackRevisions = 3,
FootnotePr = 4,
EndnotePr = 5
EndnotePr = 5,
SdtGlobalColor = 6,
SdtGlobalShowHighlight = 7,
Compat = 8,
DefaultTabStopTwips = 9
};}
namespace c_oSer_MathPrType{enum c_oSer_SettingsType
{
@ -856,7 +904,8 @@ extern int g_nCurFormatVersion;
namespace c_oSer_OMathBottomNodesValType{enum c_oSer_OMathBottomNodesValType
{
Val = 0,
AlnAt = 1
AlnAt = 1,
ValTwips = 2
};}
namespace c_oSer_OMathContentType{enum c_oSer_OMathContentType
{
@ -1096,7 +1145,9 @@ extern int g_nCurFormatVersion;
TabIndex = 32,
Tag = 33,
Temporary = 34,
MultiLine = 35
MultiLine = 35,
Appearance = 36,
Color = 37
};}
namespace c_oSerFFData{enum c_oSerFFData
{
@ -1145,6 +1196,13 @@ extern int g_nCurFormatVersion;
ColFirst = 3,
ColLast = 4
};}
namespace c_oSerCompat{enum c_oSerCompat
{
CompatSetting = 0,
CompatName = 1,
CompatUri = 2,
CompatValue = 3
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES

File diff suppressed because it is too large Load Diff

View File

@ -282,7 +282,7 @@ namespace BinXlsxRW{
{
OOX::Spreadsheet::CTableColumn* pTableColumn = new OOX::Spreadsheet::CTableColumn();
pTableColumn->m_oId.Init();
pTableColumn->m_oId->SetValue(i + 1);
pTableColumn->m_oId->SetValue((unsigned int)i + 1);
pTableColumn->m_oName.Init();
pTableColumn->m_oName->append(m_aTableNames[i]);
pTable->m_oTable->m_oTableColumns->m_arrItems.push_back(pTableColumn);
@ -604,7 +604,7 @@ namespace BinXlsxRW{
// Не число
aSharedStrings.push_back(val);
pCell->m_oType->SetValue(SimpleTypes::Spreadsheet::celltypeSharedString);
pCell->m_oValue->m_sText = std::to_wstring(aSharedStrings.size() - 1);
pCell->m_oValue->m_sText = std::to_wstring((int)aSharedStrings.size() - 1);
}
else
{
@ -658,7 +658,7 @@ namespace BinXlsxRW{
if(NULL != format)
{
int nXfsIndex = m_aXfs.size();
int nXfsIndex = (int)m_aXfs.size();
boost::unordered_map<std::wstring, int>::const_iterator itFormat = m_mapFormats.find(*format);
if(itFormat == m_mapFormats.end())

View File

@ -34,6 +34,7 @@
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/common/File.h"
#include "../../DesktopEditor/common/Path.h"
#include "../../DesktopEditor/common/SystemUtils.h"
#include "../BinWriter/BinWriters.h"
#include "../BinReader/Readers.h"
#include "../../ASCOfficePPTXFile/Editor/FontPicker.h"
@ -195,7 +196,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
bool bValidFormat = false;
std::wstring sSignature(g_sFormatSignature);
int nSigLength = (int)sSignature.length();
if(nBase64DataSize > nSigLength)
if((int)nBase64DataSize > nSigLength)
{
std::string sCurSig((char*)pBase64Data, nSigLength);
if(sSignature == std::wstring(sCurSig.begin(), sCurSig.end()))
@ -298,7 +299,10 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
OOX::CApp* pApp = new OOX::CApp(NULL);
if (pApp)
{
pApp->SetApplication(L"ONLYOFFICE");
std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName);
if (sApplication.empty())
sApplication = NSSystemUtils::gc_EnvApplicationNameDefault;
pApp->SetApplication(sApplication);
#if defined(INTVER)
pApp->SetAppVersion(VALUE2STR(INTVER));
#endif

View File

@ -85,7 +85,7 @@ namespace BinXlsxRW{
sMediaPath = pathMediaDir.GetPath();
sEmbedPath = pathEmbedDir.GetPath();
}
int CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
_UINT32 CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
{
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
@ -100,7 +100,7 @@ namespace BinXlsxRW{
BinXlsxRW::BinaryFileReader oBinaryFileReader;
return oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oDrawingConverter, sXMLOptions);
}
int CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
_UINT32 CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
{
COfficeFontPicker* pFontPicker = new COfficeFontPicker();
pFontPicker->Init(m_sFontDir);
@ -136,7 +136,7 @@ namespace BinXlsxRW{
oOfficeDrawingConverter.SetFontPicker(pFontPicker);
BinXlsxRW::BinaryFileWriter oBinaryFileWriter(fp);
int result = oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions, m_bIsNoBase64);
_UINT32 result = oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions, m_bIsNoBase64);
RELEASEOBJECT(pFontPicker);
return result;
@ -186,7 +186,7 @@ namespace BinXlsxRW{
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;
unsigned int rId;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
@ -265,4 +265,11 @@ namespace BinXlsxRW{
NSDirectory::DeleteDirectory(sTempDir);
return res;
}
bool CXlsxSerializer::hasPivot(const std::wstring& sSrcPath)
{
//todo CXlsx
std::wstring sData;
NSFile::CFileBinary::ReadAllTextUtf8(sSrcPath + FILE_SEPARATOR_STR + L"[Content_Types].xml", sData);
return std::wstring::npos != sData.find(OOX::Spreadsheet::FileTypes::PivotTable.OverrideType());
}
};

View File

@ -33,6 +33,7 @@
#define XLSX_SERIALIZER
#include <string>
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
namespace OOX
{
@ -62,8 +63,8 @@ namespace BinXlsxRW {
static void CreateXlsxFolders (const std::wstring& sXmlOptions, const std::wstring& sDstPath, std::wstring& sMediaPath, std::wstring& sEmbedPath);
int loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedPath);
int saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions);
_UINT32 loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedPath);
_UINT32 saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions);
bool saveChart (NSBinPptxRW::CBinaryFileReader* pReader, long lLength, const std::wstring& sFilename, const long& lChartNumber);
@ -73,6 +74,7 @@ namespace BinXlsxRW {
void setIsNoBase64 (bool bIsNoBase64);
bool writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
bool hasPivot (const std::wstring& sSrcPath);
};
}
#endif // #ifndef XLSX_SERIALIZER

View File

@ -34,7 +34,8 @@ SOURCES += \
../../XlsxSerializerCom/Writer/CSVWriter.cpp \
../../OfficeCryptReader/source/ECMACryptFile.cpp \
../../OfficeCryptReader/source/CryptTransform.cpp \
../BinReader/Readers.cpp
../BinReader/Readers.cpp \
../BinReader/CustormXmlWriter.cpp
HEADERS += ../DocWrapper/DocxSerializer.h \
../DocWrapper/FontProcessor.h \
@ -69,4 +70,5 @@ HEADERS += ../DocWrapper/DocxSerializer.h \
../BinReader/DefaultThemeWriter.h \
../DocWrapper/ChartWriter.h \
../../OfficeCryptReader/source/ECMACryptFile.h \
../../OfficeCryptReader/source/CryptTransform.h
../../OfficeCryptReader/source/CryptTransform.h \
../BinReader/CustormXmlWriter.h

View File

@ -53,6 +53,8 @@
69F181AF1C77274E00B2952B /* FileDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 69F181AD1C77274E00B2952B /* FileDownloader.h */; };
8A404FD3208A01AF00F2D5CF /* FileDownloader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A404FD2208A01AF00F2D5CF /* FileDownloader.cpp */; };
8A404FD5208A01CE00F2D5CF /* FileDownloader_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A404FD4208A01CE00F2D5CF /* FileDownloader_private.h */; };
8AB24BFD213004E400E80DDD /* CustormXmlWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AB24BFB213004E300E80DDD /* CustormXmlWriter.cpp */; };
8AB24BFE213004E400E80DDD /* CustormXmlWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AB24BFC213004E300E80DDD /* CustormXmlWriter.h */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -103,6 +105,8 @@
69F181AD1C77274E00B2952B /* FileDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileDownloader.h; path = ../../../Common/FileDownloader/FileDownloader.h; sourceTree = "<group>"; };
8A404FD2208A01AF00F2D5CF /* FileDownloader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileDownloader.cpp; path = ../../../Common/FileDownloader/FileDownloader.cpp; sourceTree = "<group>"; };
8A404FD4208A01CE00F2D5CF /* FileDownloader_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileDownloader_private.h; path = ../../../Common/FileDownloader/FileDownloader_private.h; sourceTree = "<group>"; };
8AB24BFB213004E300E80DDD /* CustormXmlWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustormXmlWriter.cpp; sourceTree = "<group>"; };
8AB24BFC213004E300E80DDD /* CustormXmlWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustormXmlWriter.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -149,6 +153,8 @@
children = (
17E17EEB1AC4544900BEA2EA /* ChartWriter.h */,
17E17EEC1AC4544900BEA2EA /* CommentsWriter.h */,
8AB24BFB213004E300E80DDD /* CustormXmlWriter.cpp */,
8AB24BFC213004E300E80DDD /* CustormXmlWriter.h */,
17A765271B0F3DC30046BC0B /* DefaultThemeWriter.h */,
17E17EF01AC4544900BEA2EA /* DocumentRelsWriter.h */,
17E17EF11AC4544900BEA2EA /* DocumentWriter.h */,
@ -292,6 +298,7 @@
17C1FEBC1ACC42C4006B99B3 /* DocxSerializer.h in Headers */,
17C1FEBD1ACC42C4006B99B3 /* FileWriter.h in Headers */,
17C1FEBE1ACC42C4006B99B3 /* CSVWriter.h in Headers */,
8AB24BFE213004E400E80DDD /* CustormXmlWriter.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -346,6 +353,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8AB24BFD213004E400E80DDD /* CustormXmlWriter.cpp in Sources */,
17C1FE961ACC42C4006B99B3 /* Common.cpp in Sources */,
17C1FE971ACC42C4006B99B3 /* ChartFromToBinary.cpp in Sources */,
17C1FE981ACC42C4006B99B3 /* CSVReader.cpp in Sources */,
@ -375,18 +383,11 @@
GCC_PREPROCESSOR_DEFINITIONS = (
UNICODE,
_UNICODE,
NODOCX,
_USE_XMLLITE_READER_,
USE_LITE_READER,
USE_ATL_CSTRING,
USE_AVSOFFICESTUDIO_XMLUTILS,
SOLUTION_ASCOFFICEDOCXFILE2,
_USE_LIBXML2_READER_,
LIBXML_READER_ENABLED,
DONT_WRITE_EMBEDDED_FONTS,
MAC,
unix,
_IOS,
DONT_WRITE_EMBEDDED_FONTS,
_XCODE,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
@ -397,7 +398,7 @@
"$(PROJECT_DIR)/../../DesktopEditor/freetype-2.5.2/include",
"$(PROJECT_DIR)/../../Common/3dParty/boost/boost_1_58_0",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
PRODUCT_NAME = ASCOfficeDocxFile2Lib_ios;
SDKROOT = iphoneos;
};
@ -414,18 +415,11 @@
GCC_PREPROCESSOR_DEFINITIONS = (
UNICODE,
_UNICODE,
NODOCX,
_USE_XMLLITE_READER_,
USE_LITE_READER,
USE_ATL_CSTRING,
USE_AVSOFFICESTUDIO_XMLUTILS,
SOLUTION_ASCOFFICEDOCXFILE2,
_USE_LIBXML2_READER_,
LIBXML_READER_ENABLED,
DONT_WRITE_EMBEDDED_FONTS,
MAC,
unix,
_IOS,
DONT_WRITE_EMBEDDED_FONTS,
_XCODE,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
@ -436,7 +430,7 @@
"$(PROJECT_DIR)/../../DesktopEditor/freetype-2.5.2/include",
"$(PROJECT_DIR)/../../Common/3dParty/boost/boost_1_58_0",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
PRODUCT_NAME = ASCOfficeDocxFile2Lib_ios;
SDKROOT = iphoneos;
};

View File

@ -105,7 +105,7 @@ HRESULT convert_single(std::wstring srcFileName)
}
_CP_LOG << L"[info] " << srcFileName << std::endl;
nResult = ConvertODF2OOXml(srcTempPath, dstTempPath, L"C:\\Windows\\Fonts", srcTempPath2, L"password", NULL);
nResult = ConvertODF2OOXml(srcTempPath, dstTempPath, L"C:\\Windows\\Fonts", srcTempPath2, L"", NULL);
if (srcTempPath != srcFileName)
{

View File

@ -36,6 +36,7 @@
#include "../include/CPScopedPtr.h"
namespace cpdoccore {
namespace formulasconvert {
@ -44,7 +45,7 @@ namespace formulasconvert {
class odf2oox_converter
{
public:
odf2oox_converter();
odf2oox_converter();
~odf2oox_converter();
// of:=SUM([.DDA1:.BA3]) -> SUM(DDA1:BA3)

View File

@ -35,6 +35,7 @@
#include <boost/algorithm/string.hpp>
#include"../../Common/DocxFormat/Source/XML/Utils.h"
#include "../src/docx/xlsxconversioncontext.h"
namespace cpdoccore {
namespace formulasconvert {
@ -42,6 +43,9 @@ namespace formulasconvert {
class odf2oox_converter::Impl
{
public:
Impl() {}
static std::unordered_map<std::wstring, int> & mapExternalLink_;
std::wstring convert(const std::wstring& expr);
std::wstring convert_chart_distance(const std::wstring& expr);
@ -51,23 +55,158 @@ namespace formulasconvert {
void replace_cells_range(std::wstring& expr, bool withTableName);
bool check_formula(std::wstring& expr);
void replace_semicolons(std::wstring& expr);
void replace_tilda(std::wstring& expr);
void replace_vertical(std::wstring& expr);
void replace_space(std::wstring& expr);
std::wstring convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator);
std::wstring convert_named_expr(const std::wstring& expr, bool withTableName);
static std::wstring replace_named_ref_formater(boost::wsmatch const & what);
static std::wstring replace_named_ref_formater1(boost::wsmatch const & what);
static std::wstring replace_cell_range_formater(boost::wsmatch const & what);
//static std::wstring replace_cell_range_formater(boost::wsmatch const & what);
void replace_named_formula(std::wstring & expr, bool w = true);
void replace_named_ref(std::wstring & expr, bool w = true);
bool find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref);
bool find_first_last_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref_first,std::wstring & ref_last);
static bool convert_with_TableName;
static std::wstring table_name_;
static bool convert_with_TableName;
static std::wstring table_name_;
//-------------------------------------------------------------------------------------------------------------
static std::wstring replace_semicolons_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L",";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
else
return L"";
}
static std::wstring replace_tilda_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L";";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
else
return L"";
}
static std::wstring replace_vertical_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L"|", L";");
return L"{" + inner + L"}";
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
static void replace_tmp_back(std::wstring &expr)
{
XmlUtils::replace_all( expr, L"ТОСHKA", L".");
XmlUtils::replace_all( expr, L"VOSKL", L"!");
XmlUtils::replace_all( expr, L"SCOBCAIN", L"(");
XmlUtils::replace_all( expr, L"SCOBCAOUT", L")");
XmlUtils::replace_all( expr, L"KVADRATIN", L"[");
XmlUtils::replace_all( expr, L"KVADRATOUT", L"]");
XmlUtils::replace_all( expr, L"PROBEL", L" ");
XmlUtils::replace_all( expr, L"APOSTROF", L"'");
XmlUtils::replace_all( expr, L"KAVYCHKA", L"\"");
}
static void replace_tmp(std::wstring &expr)
{
XmlUtils::replace_all( expr, L".", L"ТОСHKA");
XmlUtils::replace_all( expr, L"!", L"VOSKL");
XmlUtils::replace_all( expr, L"(", L"SCOBCAIN");
XmlUtils::replace_all( expr, L")", L"SCOBCAOUT");
//XmlUtils::replace_all( expr, L"[", L"KVADRATIN");
//XmlUtils::replace_all( expr, L"]", L"KVADRATOUT");
XmlUtils::replace_all( expr, L" ", L"PROBEL");
// XmlUtils::replace_all( expr, L"'", L"APOSTROF");
// XmlUtils::replace_all( expr, L"\"", L"KAVYCHKA");
}
static std::wstring convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
replace_tmp(inner);
return inner;
}
else if (what[2].matched)
{
std::wstring inner = what[2].str();
replace_tmp(inner);
return inner;
}
else if (what[3].matched)
return what[3].str();
return L"";
}
static std::wstring replace_space_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L" ", L",");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
static std::wstring is_forbidden(const std::wstring & formula)
{
std::wstring result = formula;
std::map<std::wstring, std::wstring> forbidden_formulas;
forbidden_formulas.insert(std::make_pair(L"FORMULA", L"_xlfn.FORMULATEXT"));
for (std::map<std::wstring, std::wstring>::iterator it = forbidden_formulas.begin(); it != forbidden_formulas.end(); ++it)
{
if (boost::algorithm::contains(formula, it->first))
{
XmlUtils::replace_all(result, it->first, it->second);
}
}
return result;
}
};
bool odf2oox_converter::Impl::convert_with_TableName = true;
std::wstring odf2oox_converter::Impl::table_name_ = L"";
std::unordered_map<std::wstring, int> &odf2oox_converter::Impl::mapExternalLink_ = oox::xlsx_conversion_context::mapExternalLink_;
bool odf2oox_converter::Impl::find_first_last_ref(std::wstring const & expr, std::wstring & table,std::wstring & ref_first,std::wstring & ref_last)
{
@ -75,14 +214,14 @@ namespace formulasconvert {
boost::algorithm::split(splitted, expr, boost::algorithm::is_any_of(L".:"), boost::algorithm::token_compress_on);
if (splitted.size()==3)
if (splitted.size() == 3)
{
table = splitted[0];
ref_first = splitted[1];
ref_last = splitted[2];
return true;
}
if (splitted.size()==4)
if (splitted.size() == 4)
{
table = splitted[0];
ref_first = splitted[1];
@ -94,7 +233,7 @@ namespace formulasconvert {
bool odf2oox_converter::Impl::find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref)
{
boost::wregex re(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.([a-zA-Z\\$]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]");
boost::wregex re(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.([\\w^0-9\\$]+\\d+)(?::\\.([\\w^0-9]+\\d+)){0,1}\\]");
boost::wsmatch result;
bool b = boost::regex_search(expr, result, re);
@ -117,101 +256,92 @@ namespace formulasconvert {
}
std::wstring odf2oox_converter::Impl::replace_cell_range_formater(boost::wsmatch const & what)
{
const size_t sz = what.size();
if (sz == 4 && !what[1].matched)
{
const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str();
const std::wstring s = c1 + (c2.empty() ? L"" : (L":" + c2) );
return s;
}
else if (sz == 4 && what[1].matched)
{
std::wstring sheet1 = what[1].str();
XmlUtils::replace_all( sheet1, L"$", L"");
//std::wstring odf2oox_converter::Impl::replace_cell_range_formater(boost::wsmatch const & what)
//{
// const size_t sz = what.size();
// if (sz == 4 && !what[1].matched)
// {
// const std::wstring c1 = what[2].str();
// const std::wstring c2 = what[3].str();
// const std::wstring s = c1 + (c2.empty() ? L"" : (L":" + c2) );
// return s;
// }
// else if (sz == 4 && what[1].matched)
// {
// std::wstring sheet1 = what[1].str();
// XmlUtils::replace_all( sheet1, L"$", L"");
const std::wstring c1 = what[2].str();
std::wstring c2 = what[3].str();
if (c2.empty()) c2 = what[4].str();
const std::wstring s = sheet1 + L"!" + c1 + (c2.empty() ? L"" : (L":" + c2) );
return s;
}
return L"";
}
// const std::wstring c1 = what[2].str();
// std::wstring c2 = what[3].str();
// if (c2.empty()) c2 = what[4].str();
// const std::wstring s = sheet1 + L"!" + c1 + (c2.empty() ? L"" : (L":" + c2) );
// return s;
// }
// return L"";
//}
std::wstring odf2oox_converter::Impl::replace_named_ref_formater(boost::wsmatch const & what)
{
const size_t sz = what.size();
if (sz == 4 && !what[1].matched)
if (sz < 6) return what[0].str();
std::wstring c0 = what[0].str();
std::wstring external = sz == 7 ? what[1].matched ? what[1].str() : what[2].str() : what[1].str();
std::wstring sheet1 = sz == 7 ? what[3].str() : what[2].str();
std::wstring ref1 = sz == 7 ? what[4].str() : what[3].str();
std::wstring sheet2 = sz == 7 ? what[5].str() : what[4].str();
std::wstring ref2 = sz == 7 ? what[6].str() : what[5].str();
XmlUtils::replace_all( sheet1, L"$", L"");
//XmlUtils::replace_all( sheet2, L"$", L"");
std::wstring result;
if (false == external.empty())
{
const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str();
const std::wstring s = c1 + (c2.empty() ? L"" : (L":" + c2) );
return s;
}
else if (sz == 4 && what[1].matched)
{
std::wstring sheet1 = what[1].str();
XmlUtils::replace_all( sheet1, L"$", L"");
replace_tmp_back(external);
table_name_ = sheet1;
const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str();
if (convert_with_TableName)
int id = -1;//add_external_link(external);
std::unordered_map<std::wstring, int>::iterator pFind = mapExternalLink_.find(external);
if ( pFind == mapExternalLink_.end())
{
if (std::wstring::npos != sheet1.find(L" "))
{
if (sheet1[0] != L'\'')
{
sheet1 = L"'" + sheet1 + L"'";
}
}
return (sheet1 + L"!") + c1 + (c2.empty() ? L"" : (L":" + c2) );
id = (int)mapExternalLink_.size() + 1;
mapExternalLink_.insert(std::make_pair(external, id));
}
else
{
return c1 + (c2.empty() ? L"" : (L":" + c2) );
id = pFind->second;
}
}
else if (sz == 5 && what[1].matched)
{
std::wstring sheet1 = what[1].str();
XmlUtils::replace_all( sheet1, L"$", L"");
const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str(); //sheet name 2
const std::wstring c3 = what[4].str();
table_name_ = sheet1;
if (convert_with_TableName)
if (sheet1[0] == L'\'')
{
return (sheet1 + L"!") + c1 + (c3.empty() ? L"" : (L":" + c3) );
}
else
{
return c1 + (c3.empty() ? L"" : (L":" + c3) );
sheet1 = sheet1.substr(1, sheet1.length() - 2);
}
sheet1 = L"'[" + std::to_wstring(id) + L"]" + sheet1 + L"'";
}
else if (sz == 5 && !what[1].matched)
else if (std::wstring::npos != sheet1.find(L" "))
{
const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str(); //sheet name 2
const std::wstring c3 = what[4].str();
return c1 + (c3.empty() ? L"" : (L":" + c3) );
if (sheet1[0] != L'\'')
{
sheet1 = L"'" + sheet1 + L"'";
}
}
table_name_ = sheet1;
if (convert_with_TableName)
{
return (sheet1.empty() ? L"" : (sheet1 + L"!")) + ref1 + (ref2.empty() ? L"" : (L":" + ref2) );
}
else
{
return ref1 + (ref2.empty() ? L"" : (L":" + ref2) );
}
return L"";
}
std::wstring odf2oox_converter::Impl::replace_named_ref_formater1(boost::wsmatch const & what)
{
boost::wregex complexRef(L"\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)){0,1}");
boost::wregex complexRef(L"(?:\'([^\']*)\'#){0,1}\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]+\\${0,1}\\d+)(?::\\.(\\${0,1}[\\w^0-9]+\\${0,1}\\d+)){0,1}");
// 'external'# $ Sheet2 . A1 : ( $ Sheet2)? . B5
std::wstring expr = what[1].str();
const std::wstring res = boost::regex_replace(
expr,
@ -232,26 +362,34 @@ namespace formulasconvert {
// [$'Sheet2 A'.$B2] -> 'Sheet2 A'!$B2
void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr, bool withTableName)
{
XmlUtils::replace_all( expr, L"#REF !", L"#REF!");
XmlUtils::replace_all( expr, L"#REF!#REF!", L"#REF!");
XmlUtils::replace_all( expr, L"$#REF!$#REF!", L"#REF!");
convert_with_TableName = withTableName;
boost::wregex complexRef(L"\\[(?:\$)?([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}\\]");
/*
[ $ Sheet2 . A1 : ( $ Sheet2)? . B5 ]
*/
//boost::wregex complexRef(L"\\[(?:\'([^\']*)\'#){0,1}\\[{0,1}(?:\\$){0,1}([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}\\]{0,1}");
boost::wregex complexRef(L"(?:(?:(?:(?:\\[\'([^\']*)\'#)|(?:\'([^\']*)\'#\\[)))|(?:\\[))\
(?:\\$){0,1}([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}\\]");
// [ 'external'# [ $ Sheet2 . A1 : ( $ Sheet2)? . B5 ]
const std::wstring res = boost::regex_replace(
expr,
expr = boost::regex_replace(
expr,
complexRef,
&replace_named_ref_formater,
boost::match_default | boost::format_all);
expr = res;
}
void odf2oox_converter::Impl::replace_named_ref(std::wstring & expr, bool withTableName)
{
XmlUtils::replace_all( expr, L"#REF !", L"#REF!");
XmlUtils::replace_all( expr, L"#REF!#REF!", L"#REF!");
XmlUtils::replace_all( expr, L"$#REF!$#REF!", L"#REF!");
convert_with_TableName = withTableName;
//boost::wregex complexRef(L"\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)){0,1}");
boost::wregex complexRef(L"\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)(?::\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}");
boost::wregex complexRef(L"\\[{0,1}(?:\'([^\']*)\'#){0,1}\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}\\]{0,1}");
// 'external'# $ Sheet2 . A1 : ( $ Sheet2)? . B5
const std::wstring res = boost::regex_replace(
expr,
@ -280,19 +418,7 @@ namespace formulasconvert {
}
std::wstring replace_semicolons_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L",";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
else
return L"";
}
// TODO
// заменить точки с запятой во всех вхождениях кроме находящихся в кавычках --*и в фигурных скобках*--
void odf2oox_converter::Impl::replace_semicolons(std::wstring& expr)
{
@ -302,126 +428,20 @@ namespace formulasconvert {
boost::wregex(L"(;)|(\".*?\")|('.*?')"),
&replace_semicolons_formater,
boost::match_default | boost::format_all);
expr = res;
}
std::wstring replace_vertical_formater(boost::wsmatch const & what)
void odf2oox_converter::Impl::replace_tilda(std::wstring& expr)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L"|", L";");
return L"{" + inner + L"}";
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
const std::wstring res = boost::regex_replace(
expr,
//boost::wregex(L"(;)|(?:\".*?\")|(?:'.*?')"),
boost::wregex(L"(~)|(\".*?\")|('.*?')"),
&replace_semicolons_formater,
boost::match_default | boost::format_all);
expr = res;
}
std::wstring replace_point_space(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L" ", L"PROBEL");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
std::wstring convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L".", L"ТОСHKA");
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"'", L"APOSTROF");
return inner;
}
else if (what[2].matched)
{
std::wstring inner = what[2].str();
XmlUtils::replace_all( inner, L".", L"ТОСHKA");
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"\"", L"KAVYCHKA");
return inner;
}
else if (what[3].matched)
return what[3].str();
return L"";
}
std::wstring replace_space_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L" ", L",");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
//std::wstring forbidden_formulas[] =
//{
// L"NULLFORMULA"
// //L"BETADIST",
// //L"CEILING",
// //L"FLOOR",
// //L"RANK",
// //L"ROUND",
// //L"ROUNDDOWN",
// //L"ROUNDUP",
// //L"SUBTOTAL",
// //L"FORMULA",
// //L"ISREF"
//};
std::wstring is_forbidden(const std::wstring & formula)
{
std::wstring result = formula;
std::map<std::wstring, std::wstring> forbidden_formulas;
forbidden_formulas.insert(std::make_pair(L"FORMULA", L"_xlfn.FORMULATEXT"));
for (std::map<std::wstring, std::wstring>::iterator it = forbidden_formulas.begin(); it != forbidden_formulas.end(); ++it)
{
if (boost::algorithm::contains(formula, it->first))
{
XmlUtils::replace_all(result, it->first, it->second);
}
}
return result;
}
// заменить вертикальную черту во всех вхождениях в фигурных скобках, но не внутри строк
void odf2oox_converter::Impl::replace_vertical(std::wstring& expr)
{
@ -446,22 +466,17 @@ namespace formulasconvert {
std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr)
{
std::wstring workstr = is_forbidden(expr);
//boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// Better_Donut.ods- cell(c27)
//std::wstring workstr = boost::regex_replace(
// expr,
// complexRef,
// &replace_point_space,
// boost::match_default | boost::format_all);
bool isFormula = check_formula(workstr);
boost::regex_replace(
workstr,
//экранирование
workstr = boost::regex_replace(workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
replace_cells_range (workstr, true);
replace_semicolons (workstr);
replace_tilda (workstr);
replace_vertical (workstr);
if (isFormula)
@ -469,9 +484,9 @@ namespace formulasconvert {
XmlUtils::replace_all( workstr, L"FDIST(", L"_xlfn.F.DIST(");
// ROUNDUP( - тут в oox 2 параметра - разрядность нужно - ,0) - EV Requirements v2.2.3.ods
int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
if (std::wstring::npos != workstr.find(L"CONCATINATE"))
{
bool l = true;
//могут быть частично заданы диапазоны
//todooo
}
@ -486,39 +501,23 @@ namespace formulasconvert {
//-----------------------------------------------------------
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
XmlUtils::replace_all( workstr, L"ТОСHKA" , L".");
XmlUtils::replace_all( workstr, L"SCOBCAIN" , L"(");
XmlUtils::replace_all( workstr, L"SCOBCAOUT" , L")");
XmlUtils::replace_all( workstr, L"KVADRATIN" , L"[");
XmlUtils::replace_all( workstr, L"KVADRATOUT", L"]");
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
XmlUtils::replace_all( workstr, L"KAVYCHKA" , L"\"");
replace_tmp_back(workstr);
return workstr;
}
void odf2oox_converter::Impl::split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out)
{
std::wstring workstr = expr;
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
workstr = boost::regex_replace(
std::wstring workstr = boost::regex_replace(
expr,
complexRef,
&replace_point_space,
boost::match_default | boost::format_all);
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
boost::algorithm::split(out, workstr, boost::algorithm::is_any_of(by), boost::algorithm::token_compress_on);
for (size_t i = 0; i < out.size(); i++)
{
XmlUtils::replace_all( out[i], L"PROBEL", L" ");
XmlUtils::replace_all( out[i], L"TOCHKA", L".");
replace_tmp_back(out[i]);
}
}
@ -528,15 +527,10 @@ namespace formulasconvert {
std::wstring odf2oox_converter::Impl::convert_chart_distance(const std::wstring& expr)
{
std::wstring workstr = is_forbidden(expr);
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
workstr = boost::regex_replace(
expr,
complexRef,
&replace_point_space,
boost::match_default | boost::format_all);
std::wstring workstr = boost::regex_replace(
is_forbidden(expr),
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
//распарсить по диапазонам - одф-пробел, ик-эль-запятая
@ -568,10 +562,10 @@ namespace formulasconvert {
cells_out.append(cells[j]);
cells_out.append(L":");
}
int res1 = sheet.find(L"-");
int res2 = sheet.find(L"'");
size_t res1 = sheet.find(L"-");
size_t res2 = sheet.find(L"'");
if (res1 >= 0 && !(res2 == 0))
if (res1 != std::wstring::npos && res2 != std::wstring::npos && !(res2 == 0))
{
sheet = L"'" + sheet + L"'";
}
@ -585,12 +579,78 @@ namespace formulasconvert {
result.append(distance_out[i]);
result.append(L",");
}
XmlUtils::replace_all( result, L"PROBEL" , L" ");
XmlUtils::replace_all( result, L"TOCHKA", L".");
replace_tmp_back( result );
return result.substr(0, result.size() - 1);// минус последняя лишняя запятая
}
odf2oox_converter::odf2oox_converter(): impl_(new odf2oox_converter::Impl)
std::wstring odf2oox_converter::Impl::convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator)
{
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
std::wstring workstr = expr;
workstr = boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
replace_named_ref(workstr, withTableName);
if (separator != L" ")
{
XmlUtils::replace_all( workstr, L" ", separator);
}
replace_tmp_back( workstr );
if (table_name_.empty() == false)
{
replace_tmp_back( table_name_ );
}
return workstr;
}
std::wstring odf2oox_converter::Impl::convert_named_expr(const std::wstring& expr, bool withTableName)
{
std::wstring workstr = expr;
bool isFormula = check_formula(workstr);
if (isFormula)
{
workstr = convert(expr);
}
else
{
workstr = boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
replace_cells_range(workstr, withTableName);
replace_semicolons(workstr);
replace_vertical(workstr);
size_t res_find = 0;
if ((res_find = workstr.find(L"CONCATINATE")) != std::wstring::npos)
{
//могут быть частично заданы диапазоны
//todooo
}
replace_tmp_back(workstr);
if (table_name_.empty() == false)
{
replace_tmp_back(table_name_);
}
}
return workstr;
}
//------------------------------------------------------------------------------------------------------------
odf2oox_converter::odf2oox_converter() : impl_(new odf2oox_converter::Impl())
{
}
@ -617,82 +677,11 @@ namespace formulasconvert {
}
std::wstring odf2oox_converter::convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator)
{
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
std::wstring workstr = boost::regex_replace(
expr,
complexRef,
&replace_point_space,
boost::match_default | boost::format_all);
XmlUtils::replace_all( workstr, L"'", L"APOSTROF");
//XmlUtils::replace_all( workstr, L"", L"APOSTROF");
impl_->replace_named_ref(workstr, withTableName);
if (separator != L" ")
{
XmlUtils::replace_all( workstr, L" " , separator);
}
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
XmlUtils::replace_all( workstr, L"TOCHKA" , L".");
if (impl_->table_name_.empty() == false)
{
XmlUtils::replace_all( impl_->table_name_, L"PROBEL" , L" ");
XmlUtils::replace_all( impl_->table_name_, L"APOSTROF" , L"'");
XmlUtils::replace_all( impl_->table_name_, L"TOCHKA" , L".");
}
return workstr;
return impl_->convert_named_ref(expr, withTableName, separator);
}
std::wstring odf2oox_converter::convert_named_expr(const std::wstring& expr, bool withTableName)
{
std::wstring workstr = expr;
bool isFormula = impl_->check_formula(workstr);
if (isFormula)
{
workstr = impl_->convert(expr);
}
else
{
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
workstr = boost::regex_replace(
workstr,
complexRef,
&replace_point_space,
boost::match_default | boost::format_all);
XmlUtils::replace_all( workstr, L"'", L"APOSTROF");
impl_->replace_cells_range(workstr, withTableName);
impl_->replace_semicolons(workstr);
impl_->replace_vertical(workstr);
int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
{
//могут быть частично заданы диапазоны
//todooo
}
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
XmlUtils::replace_all( workstr, L"TOCHKA" , L".");
if (impl_->table_name_.empty() == false)
{
XmlUtils::replace_all( impl_->table_name_, L"PROBEL" , L" ");
XmlUtils::replace_all( impl_->table_name_, L"APOSTROF" , L"'");
XmlUtils::replace_all( impl_->table_name_, L"TOCHKA" , L".");
}
}
return workstr;
return impl_->convert_named_expr(expr, withTableName);
}
std::wstring odf2oox_converter::convert_ref(std::wstring const & expr)
@ -705,8 +694,8 @@ namespace formulasconvert {
{
while(true)
{
int pos = expr.find(L"%20");
if (pos <0)break;
size_t pos = expr.find(L"%20");
if (pos == std::wstring::npos)break;
expr.replace(pos,3,L" ");
}

View File

@ -32,7 +32,6 @@
#include "formulasconvert.h"
#include <boost/regex.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>
#include"../../Common/DocxFormat/Source/XML/Utils.h"
@ -40,6 +39,22 @@
namespace cpdoccore {
namespace formulasconvert {
static std::wstring forbidden_formulas1[] =
{
L"NULLFORMULA()"
/*
L"BETADIST",
L"CEILING",
L"FLOOR",
L"RANK",
L"ROUND",
L"ROUNDDOWN",
L"ROUNDUP",
L"SUBTOTAL",
L"FORMULA",
L"ISREF"*/
};
class oox2odf_converter::Impl
{
public:
@ -49,7 +64,7 @@ public:
std::wstring convert_conditional_formula(const std::wstring& expr);
std::wstring convert_chart_distance(const std::wstring& expr);
static void replace_cells_range(std::wstring& expr);
static void replace_cells_range(std::wstring& expr, bool bSelect = true);
static void replace_semicolons(std::wstring& expr);
static void replace_vertical(std::wstring& expr);
@ -60,7 +75,104 @@ public:
static std::wstring replace_arguments(boost::wsmatch const & what);
static std::wstring convert_scobci(boost::wsmatch const & what);
void replace_named_ref(std::wstring & expr);
static std::wstring replace_tilda_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L";";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
//else if (what[4].matched)
// return what[4].str();
else
return L"";
}
static std::wstring replace_semicolons_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L";";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
//else if (what[4].matched)
// return what[4].str();
else
return L"";
}
static std::wstring replace_vertical_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L";", L"|");
return L"{" + inner + L"}";
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
static std::wstring replace_space_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L",", L" ");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
static void oox_replace_tmp_back(std::wstring &expr)
{
XmlUtils::replace_all( expr, L"ТОСHKA", L".");
XmlUtils::replace_all( expr, L"VOSKL", L"!");
XmlUtils::replace_all( expr, L"SCOBCAIN", L"(");
XmlUtils::replace_all( expr, L"SCOBCAOUT", L")");
XmlUtils::replace_all( expr, L"KVADRATIN", L"[");
XmlUtils::replace_all( expr, L"KVADRATOUT", L"]");
XmlUtils::replace_all( expr, L"PROBEL", L" ");
XmlUtils::replace_all( expr, L"APOSTROF", L"'");
XmlUtils::replace_all( expr, L"KAVYCHKA", L"\"");
}
static void oox_replace_tmp(std::wstring &expr)
{
XmlUtils::replace_all( expr, L".", L"ТОСHKA");
XmlUtils::replace_all( expr, L"!", L"VOSKL");
XmlUtils::replace_all( expr, L"(", L"SCOBCAIN");
XmlUtils::replace_all( expr, L")", L"SCOBCAOUT");
XmlUtils::replace_all( expr, L"[", L"KVADRATIN");
XmlUtils::replace_all( expr, L"]", L"KVADRATOUT");
XmlUtils::replace_all( expr, L" ", L"PROBEL");
XmlUtils::replace_all( expr, L"'", L"APOSTROF");
XmlUtils::replace_all( expr, L"\"", L"KAVYCHKA");
}
static bool is_forbidden1(const std::wstring & formula)
{
for (size_t i = 0; i < 1; i++)
{
if (boost::algorithm::contains(formula, forbidden_formulas1[i]))
return true;
}
return false;
}
void replace_named_ref(std::wstring & expr);
void replace_named_formula(std::wstring & expr);
static bool isFindBaseCell_;
@ -71,8 +183,11 @@ public:
bool oox2odf_converter::Impl::isFindBaseCell_ = false;
std::wstring oox2odf_converter::Impl::table_name_ = L"";
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr, bool bSelect)
{
if ((0 == expr.find(L"KAVYCHKA")) && (expr.length() - 8 == expr.rfind(L"KAVYCHKA") ))
return;
boost::wregex re(L"([:$!])+");
boost::wsmatch result;
@ -80,7 +195,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
if (b)
{
boost::wregex re1(L"(\\$?\\w+\\!)?([a-zA-Z$]*\\d*)\\:?([a-zA-Z$]*\\d*)?");
boost::wregex re1(L"(\\$?[^\']+\\!)?([\\w^0-9$]*\\d*)\\:?([\\w^0-9$]*\\d*)?");
// $ Sheet2 ! $ A1 : $ B5
// $ Sheet2 ! $ A : $ A
// $ Sheet2 ! $ 1 : $ 1
@ -89,7 +204,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
std::wstring res = boost::regex_replace(
workstr,
re1,
&replace_cells_range_formater1,
bSelect ? &replace_cells_range_formater1 : &replace_cells_range_formater2,
boost::match_default | boost::format_all);
expr = res;
@ -112,8 +227,12 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
std::wstring c1 = what[2].str();
std::wstring c2 = what[3].str();
if (!c1.empty() || !c2.empty() || !sheet.empty())
if ((0 == c1.find(L"KAVYCHKA")) && (c1.length() - 8 == c1.rfind(L"KAVYCHKA") ))
{
return c1;
}
else if (!c1.empty() || !c2.empty() || !sheet.empty())
{
XmlUtils::replace_all( sheet, L"!", L"");
@ -123,9 +242,8 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
}
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
s = std::wstring(L"[") + sheet + L"." +
c1 +
(c2.empty() ? L"" : (L":" + sheet + L"." + c2) ) + std::wstring(L"]");
s = L"[" + sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"]");
}
return s;
}
@ -145,18 +263,43 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater2(boost::wsmat
{
const size_t sz = what.size();
if (sz > 2)
if (sz > 3)
{
std::wstring s;
std::wstring sheet = what[1].matched ? what[1].str() : L"";
std::wstring c1 = what[2].str();
std::wstring c2 = what[3].str();
if ((0 == c1.find(L"KAVYCHKA")) && (c1.length() - 8 == c1.rfind(L"KAVYCHKA") ))
{
return c1;
}
else if (!c1.empty() || !c2.empty() || !sheet.empty())
{
XmlUtils::replace_all( sheet, L"!", L"");
if (isFindBaseCell_ && table_name_.empty() && !sheet.empty())
{
table_name_ = sheet + L".$A$1";
}
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
s = sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"");
}
return s;
}
else
{
const std::wstring c1 = what[1].str();
const std::wstring c2 = what[2].str();
const std::wstring s = std::wstring(L"[.") + c1 + (c2.empty() ? L"" : (L":." + c2) ) + std::wstring(L"]");
const std::wstring s = std::wstring(L".") + c1 + (c2.empty() ? L"" : (L":." + c2) );
return s;
}
return L"";
return L"";
}
void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
@ -168,7 +311,6 @@ void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
isFindBaseCell_ = false;
}
// Лист1!$A$1 -> $Лист1.$A$1
void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
{
table_name_.clear();
@ -179,27 +321,22 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
replace_vertical(workstr);
replace_semicolons(workstr);
std::wstring res1 = boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&oox2odf_converter::Impl::convert_scobci, boost::match_default | boost::format_all);
std::vector<std::wstring> distance;
boost::algorithm::split(distance,workstr, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
boost::algorithm::split(distance, res1, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
for (size_t i = 0; i < distance.size(); i++)
{
std::wstring &d = distance[i];
XmlUtils::replace_all( d, L"(", L"SCOBCAIN");
XmlUtils::replace_all( d, L")", L"SCOBCAOUT");
XmlUtils::replace_all( d, L" ", L"PROBEL");
XmlUtils::replace_all( d, L"'", L"APOSTROF");
XmlUtils::replace_all( d, L"\"", L"KAVYCHKA");
replace_cells_range(d);
replace_cells_range(d, false);
XmlUtils::replace_all( d, L"SCOBCAIN", L"(");
XmlUtils::replace_all( d, L"SCOBCAOUT", L")");
XmlUtils::replace_all( d, L"PROBEL", L" ");
XmlUtils::replace_all( d, L"APOSTROF", L"'");
XmlUtils::replace_all( d, L"KAVYCHKA", L"\"");
oox_replace_tmp_back(d);
out = out + d + std::wstring(L";");
}
@ -210,33 +347,11 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
if (table_name_.empty() == false)
{
XmlUtils::replace_all( table_name_, L"SCOBCAIN", L"(");
XmlUtils::replace_all( table_name_, L"SCOBCAOUT", L")");
XmlUtils::replace_all( table_name_, L"PROBEL", L" ");
XmlUtils::replace_all( table_name_, L"APOSTROF", L"'");
XmlUtils::replace_all( table_name_, L"KAVYCHKA", L"\"");
oox_replace_tmp_back(table_name_);
}
}
namespace
{
std::wstring replace_semicolons_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L";";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
//else if (what[4].matched)
// return what[4].str();
else
return L"";
}
}
// TODO
// заменить запятые на точки с запятой во всех вхождениях кроме находящихся в кавычках --*и в фигурных скобках*--
@ -252,67 +367,7 @@ void oox2odf_converter::Impl::replace_semicolons(std::wstring& expr)
expr = res;
}
namespace
{
std::wstring replace_vertical_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L";", L"|");
return L"{" + inner + L"}";
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
std::wstring replace_space_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L",", L" ");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
}
std::wstring forbidden_formulas1[] =
{
L"NULLFORMULA()"
/*
L"BETADIST",
L"CEILING",
L"FLOOR",
L"RANK",
L"ROUND",
L"ROUNDDOWN",
L"ROUNDUP",
L"SUBTOTAL",
L"FORMULA",
L"ISREF"*/
};
bool is_forbidden1(const std::wstring & formula)
{
BOOST_FOREACH(const std::wstring & s, forbidden_formulas1)
{
if (boost::algorithm::contains(formula, s))
return true;
}
return false;
}
//void oox2odf_converter::Impl::split_(std::wstring& expr)
//{
// const std::wstring res = boost::regex_split(
@ -343,47 +398,18 @@ void oox2odf_converter::Impl::replace_space(std::wstring& expr)
expr = res;
}
std::wstring replace_(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L",", L" ");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"'", L"APOSTROF");
oox_replace_tmp(inner);
return inner;
}
else if (what[2].matched)
{
std::wstring inner = what[2].str();
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"\"", L"KAVYCHKA");
oox_replace_tmp(inner);
return inner;
}
else if (what[3].matched)
@ -396,7 +422,7 @@ std::wstring oox2odf_converter::Impl::replace_arguments(boost::wsmatch const &
{
std::wstring out;
int sz = what.size();
size_t sz = what.size();
if (what[1].matched)
{
@ -432,13 +458,13 @@ std::wstring oox2odf_converter::Impl::convert(const std::wstring& expr)
if (is_forbidden1(expr))
return L"NULLFORMULA";
std::wstring workstr = expr;
std::wstring workstr = expr;
replace_cells_range(workstr);
replace_vertical(workstr);
replace_semicolons(workstr);
return workstr;
}
// of:=(Formula) -> (Formula)
// (Formula) -> of:=(Formula)
std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
{
std::wstring workstr = expr;
@ -450,9 +476,13 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
std::wstring res = boost::regex_replace(
res1,
boost::wregex(L"(?!([a-zA-Z]+\\d*\\())(([a-zA-Z]+\\!)?\\$?[a-zA-Z]*\\$?\\d*(\\:\\$?[a-zA-Z]*\\$?\\d*){0,1})"),
boost::wregex(L"(?!([\\w^0-9]+\\d*\\())(([\\w^0-9]+\\!)?\\$?[\\w^0-9]*\\$?\\d*(\\:\\$?[\\w^0-9]*\\$?\\d*){0,1})"),
&oox2odf_converter::Impl::replace_arguments, boost::match_default | boost::format_all);
//SUBTOTAL(109,Expense31[Amount])
XmlUtils::replace_all( res, L"[", L"KVADRATIN");
XmlUtils::replace_all( res, L"]", L"KVADRATOUT");
if (res1 == res)
{
XmlUtils::replace_all( res1, L"KAVYCHKA", L"\""); //IMCONJUGATE_emb.xlsx
@ -464,16 +494,7 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
boost::match_default | boost::format_all);
}
XmlUtils::replace_all( res, L"SCOBCAIN", L"(");
XmlUtils::replace_all( res, L"SCOBCAOUT", L")");
XmlUtils::replace_all( res, L"KVADRATIN", L"[");
XmlUtils::replace_all( res, L"KVADRATOUT", L"]");
XmlUtils::replace_all( res, L"APOSTROF", L"'");
XmlUtils::replace_all( res, L"KAVYCHKA", L"\"");
oox_replace_tmp_back(res);
replace_vertical(res);
replace_semicolons(res);
@ -482,17 +503,7 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
if (table_name_.empty() == false)
{
XmlUtils::replace_all( table_name_, L"SCOBCAIN", L"(");
XmlUtils::replace_all( table_name_, L"SCOBCAOUT", L")");
XmlUtils::replace_all( table_name_, L"KVADRATIN", L"[");
XmlUtils::replace_all( table_name_, L"KVADRATOUT", L"]");
XmlUtils::replace_all( table_name_, L"APOSTROF", L"'");
XmlUtils::replace_all( table_name_, L"KAVYCHKA", L"\"");
XmlUtils::replace_all( table_name_, L"PROBEL", L" ");
oox_replace_tmp_back(table_name_);
}
return std::wstring(L"of:=") + res;
@ -521,12 +532,7 @@ std::wstring oox2odf_converter::Impl::convert_conditional_formula(const std::wst
}
XmlUtils::replace_all( res, L"SCOBCAIN", L"(");
XmlUtils::replace_all( res, L"SCOBCAOUT", L")");
XmlUtils::replace_all( res, L"APOSTROF", L"'");
XmlUtils::replace_all( res, L"KAVYCHKA", L"\"");
oox_replace_tmp_back( res);
replace_vertical(res);
replace_semicolons(res);
@ -556,7 +562,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
boost::algorithm::split(distance_inp,expr, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (int i = 0; i < distance_inp.size(); i++)
for (size_t i = 0; i < distance_inp.size(); i++)
{
std::wstring sheet;
std::vector<std::wstring> range;
@ -564,7 +570,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
boost::algorithm::split(range, distance_inp[i], boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
for (int j = 0 ; j < range.size(); j++)
for (size_t j = 0 ; j < range.size(); j++)
{
int pos = range[j].find('!');
if (0 <= pos)
@ -576,7 +582,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
}
std::wstring cells_out;
for (int c = 0; c < cells.size(); c++)
for (size_t c = 0; c < cells.size(); c++)
{
if (!sheet.empty())
cells_out += sheet + L".";
@ -595,7 +601,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
}
std::wstring result;
for (int i = 0 ; i < distance_out.size(); i++)
for (size_t i = 0 ; i < distance_out.size(); i++)
{
result += distance_out[i];
result += L" ";
@ -642,8 +648,6 @@ std::wstring oox2odf_converter::get_table_name()
{
return impl_->table_name_;
}
std::wstring oox2odf_converter::convert_ref(std::wstring const & expr)
{
std::wstring workstr = expr;
@ -669,9 +673,10 @@ size_t getColAddressInv(const std::wstring & a_)
size_t mul = 1;
bool f = true;
size_t res = 0;
BOOST_REVERSE_FOREACH(const wchar_t c, a)
for (int i = a.length() - 1; i >= 0; i--)
{
size_t v = c - L'A';
size_t v = a[i] - L'A';
if (f)
f = false;
else
@ -700,14 +705,13 @@ void splitCellAddress(const std::wstring & a_, std::wstring & col, std::wstring
::XmlUtils::replace_all( a, L"$", L"");
//::XmlUtils::replace_all( a, L"'", L"");
::boost::algorithm::to_upper(a);
BOOST_FOREACH(wchar_t c, a)
for (size_t i = 0; i < a.length(); i++)
{
if (c >= L'0' && c <= L'9')
row +=c;
if (a[i] >= L'0' && a[i] <= L'9')
row += a[i];
else
col += c;
col += a[i];
}
std::reverse(col.begin(), col.end());
std::reverse(row.begin(), row.end());
@ -731,7 +735,7 @@ int oox2odf_converter::get_count_value_points(std::wstring expr)
XmlUtils::replace_all( expr, L")", L"");
boost::algorithm::split(splitted, expr, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (long i=0; i < splitted.size(); i++)
for (size_t i=0; i < splitted.size(); i++)
{
int res = splitted[i].find(L"!");
if (res > 0) splitted[i] = splitted[i].substr(res+1, splitted[i].size()-res);

View File

@ -52,8 +52,10 @@ enum ElementType
typeTextReferenceMarkEnd,
typeTextReferenceRef,
typeTextFieldFieldmarkStart,
typeTextFieldFieldmarkEnd,
typeFieldFieldmarkStart,
typeFieldFieldmarkEnd,
typeFieldFieldmark,
typeFieldParam,
typeTextSpan,
typeTextA,
@ -330,6 +332,7 @@ enum ElementType
typeTableTableRowGroup,
typeTableTableRowNoGroup,
typeTableTableSource,
typeTableTableProtection,
typeTableDataPilotTables,
typeTableDataPilotTable,
@ -452,6 +455,7 @@ enum ElementType
typeDrawPolyline,
typeDrawRegularPolyline,
typeDrawPath,
typeDrawContourPath,
typeDrawCircle,
typeDrawg,
typeDrawPageThumbnail,
@ -501,6 +505,7 @@ enum ElementType
typeFormTextarea,
typeFormTime,
typeFormValueRange,
typeFormItem,
typeDrawPage,
typePresentationFooterDecl,

View File

@ -43,7 +43,7 @@
#include <boost/variant.hpp>
#include <boost/lexical_cast.hpp>
#include "../../../../Common/DocxFormat/Source/XML/Utils.h"
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
namespace cpdoccore
{

View File

@ -310,6 +310,7 @@ typedef xml::writer::element<wchar_t> xml_element;
#define CP_XML_WRITER(STRM) if (bool _b_ = false) {} else for (xml_writer _xml_wr_((STRM));!_b_;_b_=true)
#define CP_XML_NODE(NAME) if (bool _b_ = false) {} else for (xml_element _xml_node_(_xml_wr_, (NAME));!_b_;_b_=true)
#define CP_XML_ATTR(NAME, VAL) _xml_node_.attr((NAME),(VAL))
#define CP_XML_ATTR2(NAME, VAL) _xml_node_.attr((std::wstring(NAME).c_str()),(VAL))
#define CP_XML_CONTENT(VAL) _xml_node_.contents((VAL))
#define CP_XML_STREAM() _xml_node_.stream()

View File

@ -45,7 +45,7 @@ namespace utils {
std::wstring replace_xml_to_text_ImplRegEx(const std::wstring & Text);
std::string replace_xml_to_text_ImplRegEx(const std::string & Text);
std::wstring replace_text_to_xml_ImplReplace(const std::wstring & Text);
std::wstring replace_text_to_xml_ImplReplace(const std::wstring & Text, bool dDeleteUnicode = false);
std::string replace_text_to_xml_ImplReplace(const std::string & Text);
std::wstring replace_amp_text_to_xml_ImplReplace(const std::wstring & Text);
@ -55,7 +55,7 @@ namespace utils {
std::string replace_xml_to_text_ImplReplace(const std::string & Text);
}
std::wstring replace_text_to_xml(const std::wstring & Text);
std::wstring replace_text_to_xml(const std::wstring & Text, bool dDeleteUnicode = false);
std::string replace_text_to_xml(const std::string & Text);
std::wstring replace_amp_text_to_xml(const std::wstring & Text);

View File

@ -214,8 +214,8 @@ SOURCES += \
../src/odf/datatypes/tablefunction.cpp \
../src/odf/datatypes/tableorder.cpp \
../src/odf/datatypes/dategroup.cpp \
../src/odf/datatypes/bibliography \
../src/odfcommandtype.cpp \
../src/odf/datatypes/bibliography.cpp \
../src/odf/datatypes/commandtype.cpp \
../src/docx/xlsx_conditionalFormatting.cpp \
../src/docx/xlsx_dxfs.cpp \
../src/docx/docx_content_type.cpp \

View File

@ -43,7 +43,7 @@
#include "../include/odf/odf_document.h"
int ConvertOds2Xlsx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
_UINT32 ConvertOds2Xlsx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
{
cpdoccore::oox::package::xlsx_document outputXlsx;
cpdoccore::oox::xlsx_conversion_context conversionContext( &inputOdf);
@ -56,7 +56,7 @@ int ConvertOds2Xlsx(cpdoccore::odf_reader::odf_document & inputOdf, const std::w
outputXlsx.write(dstPath);
return 0;
}
int ConvertOdt2Docx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
_UINT32 ConvertOdt2Docx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
{
cpdoccore::oox::package::docx_document outputDocx;
cpdoccore::oox::docx_conversion_context conversionContext(&inputOdf);
@ -70,7 +70,7 @@ int ConvertOdt2Docx(cpdoccore::odf_reader::odf_document & inputOdf, const std::w
return 0;
}
int ConvertOdp2Pptx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
_UINT32 ConvertOdp2Pptx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
{
cpdoccore::oox::package::pptx_document outputPptx;
cpdoccore::oox::pptx_conversion_context conversionContext(&inputOdf);
@ -83,9 +83,9 @@ int ConvertOdp2Pptx(cpdoccore::odf_reader::odf_document & inputOdf, const std::w
return 0;
}
int ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstPath, const std::wstring & fontsPath, const std::wstring & tempPath, const std::wstring & password, const ProgressCallback* CallBack)
_UINT32 ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstPath, const std::wstring & fontsPath, const std::wstring & tempPath, const std::wstring & password, const ProgressCallback* CallBack)
{
int nResult = 0;
_UINT32 nResult = 0;
try
{
@ -134,9 +134,9 @@ int ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstPath,
}
int ConvertOTF2ODF(const std::wstring & srcPath)
_UINT32 ConvertOTF2ODF(const std::wstring & srcPath)
{
int nResult = 0;
_UINT32 nResult = 0;
std::wstring manifest_xml = srcPath + FILE_SEPARATOR_STR + L"META-INF" + FILE_SEPARATOR_STR + L"manifest.xml";
std::wstring mimetype_xml = srcPath + FILE_SEPARATOR_STR + L"mimetype";

View File

@ -31,10 +31,11 @@
*/
#include "../../DesktopEditor/common/Types.h"
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
#include <string>
struct ProgressCallback;
int ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstPath, const std::wstring & fontsPath, const std::wstring & tempPath, const std::wstring & password, const ProgressCallback* CallBack);
_UINT32 ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstPath, const std::wstring & fontsPath, const std::wstring & tempPath, const std::wstring & password, const ProgressCallback* CallBack);
int ConvertOTF2ODF(const std::wstring & otfPath);
_UINT32 ConvertOTF2ODF(const std::wstring & otfPath);

View File

@ -31,7 +31,6 @@
*/
#include <string>
#include <boost/foreach.hpp>
#include <cmath>
#include <boost/optional/optional_io.hpp>
@ -78,14 +77,13 @@ std::wstring RGBToString(int r, int g, int b)
color v(r, g, b);
double minDist = (std::numeric_limits<double>::max)();
BOOST_FOREACH(color const & c, colors)
for (size_t i = 0; i < 6; i++)
{
double dist = color_dist(v, c);
double dist = color_dist(v, colors[i]);
if (dist < minDist)
{
minDist = dist;
result = c.name_;
result = colors[i].name_;
}
}

View File

@ -42,7 +42,7 @@ std::string ansi_to_utf8(const std::string & _AnsiString)
std::wstring utf8_to_utf16(const std::string & _Utf8String)
{
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)_Utf8String.c_str(), _Utf8String.length());
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)_Utf8String.c_str(), (LONG)_Utf8String.length());
}
std::string utf16_to_utf8(const std::wstring & _Utf16String)

View File

@ -72,10 +72,10 @@ std::wostream & override_content_type::xml_to_stream(std::wostream & _Wostream)
return _Wostream;
}
const wchar_t * content_type_content::ns = L"";
const wchar_t * content_type_content::name = L"Types";
const wchar_t * content_type::ns = L"";
const wchar_t * content_type::name = L"Types";
std::wostream & content_type_content::xml_to_stream(std::wostream & _Wostream) const
std::wostream & content_type::xml_to_stream(std::wostream & _Wostream) const
{
CP_XML_WRITER(_Wostream)
{

View File

@ -86,8 +86,8 @@ public:
};
///////////////////////////////////////////////////////////////////////////////////////
// content_type_content
class content_type_content : public xml::element_impl<content_type_content>
// content_type
class content_type : public xml::element_impl<content_type>
{
public:
static const wchar_t * ns;

View File

@ -30,9 +30,6 @@
*
*/
#include <boost/foreach.hpp>
#include <iostream>
#include <xml/utils.h>
@ -131,63 +128,14 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
else
return current_state_; //empty
}
//----------------------------------------------------------------------------------------------------------------
void text_forms_context::start_element (int type)
{
current_state_.clear();
current_state_.type = type;
}
void text_forms_context::set_id (const std::wstring& id)
{
current_state_.id = id;
}
void text_forms_context::set_name (const std::wstring& name)
{
current_state_.name = name;
}
void text_forms_context::set_label (const std::wstring& label)
{
current_state_.label = label;
}
void text_forms_context::set_uuid (const std::wstring& uuid)
{
current_state_.uuid = uuid;
}
void text_forms_context::set_value (const std::wstring &value)
{
current_state_.value = value;
}
void text_forms_context::set_element(odf_reader::form_element *elm)
{
current_state_.element = elm;
}
void text_forms_context::end_element ()
{
mapElements_.insert( std::make_pair(current_state_.id, current_state_));
current_state_.clear();
}
text_forms_context::_state& text_forms_context::get_state_element (std::wstring id)
{
std::map<std::wstring, _state>::iterator it = mapElements_.find(id);
if (it != mapElements_.end())
{
return it->second;
}
else
return current_state_; //empty
}
//----------------------------------------------------------------------------------------------------------------
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
next_dump_page_properties_ (false),
page_break_ (false),
page_break_after_ (false),
page_break_before_ (false),
in_run_ (false),
in_automatic_style_ (false),
in_paragraph_ (false),
in_header_ (false),
in_drawing_content_ (false),
in_table_content_ (false),
@ -198,7 +146,6 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
new_list_style_number_ (0),
current_margin_left_ (0),
is_rtl_ (false),
is_paragraph_keep_ (false),
is_delete_text_ (false),
delayed_converting_ (false),
process_headers_footers_ (false),
@ -208,12 +155,9 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
odf_document_ (OdfDocument)
{
streams_man_ = streams_man::create(temp_stream_);
applicationFonts_ = NSFonts::NSApplication::Create();
}
docx_conversion_context::~docx_conversion_context()
{
if (applicationFonts_)
delete applicationFonts_;
}
void docx_conversion_context::set_output_document(package::docx_document * document)
{
@ -221,8 +165,7 @@ void docx_conversion_context::set_output_document(package::docx_document * docum
}
void docx_conversion_context::set_font_directory(std::wstring pathFonts)
{
if (applicationFonts_)
applicationFonts_->InitializeFromFolder(pathFonts);
mediaitems_.set_font_directory(pathFonts);
}
std::wstring styles_map::get(const std::wstring & Name, odf_types::style_family::type Type)
{
@ -250,14 +193,14 @@ std::wstring styles_map::name(const std::wstring & Name, odf_types::style_family
}
void docx_conversion_context::add_element_to_run(std::wstring parenStyleId)
{
if (!in_run_)
if (!state_.in_run_)
{
in_run_ = true;
state_.in_run_ = true;
output_stream() << L"<w:r>";
if (!text_properties_stack_.empty() || parenStyleId.length() > 0)
if (!state_.text_properties_stack_.empty() || parenStyleId.length() > 0)
{
if (!text_properties_stack_.empty())
if (!state_.text_properties_stack_.empty())
{
odf_reader::style_text_properties_ptr textProp = this->current_text_properties();
get_styles_context().start();
@ -275,41 +218,46 @@ void docx_conversion_context::add_element_to_run(std::wstring parenStyleId)
void docx_conversion_context::start_paragraph(bool is_header)
{
if (in_paragraph_)
if (state_.in_paragraph_)
finish_paragraph();
output_stream() << L"<w:p>";
in_header_ = is_header;
in_paragraph_ = true;
is_rtl_ = false;
state_.in_paragraph_ = true;
start_changes();
}
void docx_conversion_context::finish_paragraph()
{
if (in_paragraph_)
if (state_.in_paragraph_)
{
end_changes();
output_stream() << L"</w:p>";
}
in_paragraph_ = false;
in_header_ = false;
is_paragraph_keep_ = false;
in_header_ = false;
state_.is_paragraph_keep_ = false;
state_.in_paragraph_ = false;
}
void docx_conversion_context::finish_run()
{
if (false == in_run_) return;
if (false == state_.in_run_) return;
if (get_comments_context().state() == 4)
{
output_stream()<< L"<w:commentReference w:id=\"" << get_comments_context().current_id() << L"\"/>";
get_comments_context().state(0);
}
output_stream() << L"</w:r>";
in_run_ = false;
state_.in_run_ = false;
if (get_comments_context().state()==2)
if (get_comments_context().state() == 2)
{
output_stream()<< L"<w:commentRangeEnd w:id=\"" << get_comments_context().current_id() << L"\"/>";
@ -318,7 +266,6 @@ void docx_conversion_context::finish_run()
get_comments_context().state(0);
finish_run();
}
}
void docx_conversion_context::start_math_formula()
{
@ -369,46 +316,77 @@ void docx_conversion_context::start_index_content()
std::wstring sInstrText;
switch(table_content_context_.type_table_content)
if (table_content_context_.type_table_content == 3)
{
case 1: sInstrText += L" TOC \\f \\h \\u"; break;
case 2:
case 4:
case 6:
case 7: sInstrText += L" TOC \\h \\z"; break;
case 5: sInstrText += L" INDEX \\z"; break;
case 3: sInstrText += L" BIBLIOGRAPHY"; break;
sInstrText = L" BIBLIOGRAPHY ";
}
if (table_content_context_.min_outline_level > 0)
else if (table_content_context_.type_table_content == 5)
{
if (table_content_context_.max_outline_level > 9)
table_content_context_.max_outline_level = 9;
sInstrText += L" \\o \"" + std::to_wstring(table_content_context_.min_outline_level) + L"-" +
std::to_wstring(table_content_context_.max_outline_level) + L"\" ";
sInstrText = L" INDEX";
if (table_content_context_.bSeparators)
sInstrText += L" \\h \"A\"";
}
/*\\l 1-3*/
if (!table_content_context_.caption_sequence_name.empty())
else
{
sInstrText += L" \\c \"" + table_content_context_.caption_sequence_name + L"\"";
}
sInstrText += L" TOC";
bool bLink = false, bPages = false;
output_stream() << L"<w:r>";
output_stream() << L"<w:fldChar w:fldCharType=\"begin\"/>";
output_stream() << L"</w:r>";
output_stream() << L"<w:r>";
output_stream() << L"<w:instrText xml:space=\"preserve\">" << sInstrText << L" </w:instrText>";
output_stream() << L"</w:r>";
output_stream() << L"<w:r>";
//output_stream() << L"<w:rPr>
//output_stream() << L"<w:rFonts w:ascii="Minion Pro" w:eastAsia="DejaVuSans" w:hAnsi="Minion Pro"/>
//output_stream() << L"<w:bCs w:val="0"/>
//output_stream() << L"<w:sz w:val="21"/>
//output_stream() << L"<w:szCs w:val="24"/>
//output_stream() << L"</w:rPr>
output_stream() << L"<w:fldChar w:fldCharType=\"separate\"/>";
output_stream() << L"</w:r>";
if (table_content_context_.current_template.empty())
{
bLink = true;
bPages = true;
}
else
{
for (size_t i = 0; i < table_content_context_.current_template.size(); i++)
{
for (size_t j = 0; j < table_content_context_.current_template[i].content.size(); j++)
{
if (table_content_context_.current_template[i].content[j] == 3) bLink = true;
if (table_content_context_.current_template[i].content[j] == 6) bPages = true;
}
}
}
if (bLink)
sInstrText += L" \\h";
if (table_content_context_.type_table_content == 1)
sInstrText += L" \\f \\u";
else
sInstrText += L" \\z";
if (table_content_context_.min_outline_level > 0)
{
if (table_content_context_.max_outline_level > 9)
table_content_context_.max_outline_level = 9;
sInstrText += L" \\o \"" + std::to_wstring(table_content_context_.min_outline_level) + L"-" +
std::to_wstring(table_content_context_.max_outline_level) + L"\"";
if (!bPages)
sInstrText += L" \\n "+ std::to_wstring(table_content_context_.min_outline_level) + L"-" +
std::to_wstring(table_content_context_.max_outline_level);
}
if (false == table_content_context_.outline_level_styles.empty())
{
sInstrText += L" \\t \"";
for (std::map<int, std::wstring>::iterator it = table_content_context_.outline_level_styles.begin();
it != table_content_context_.outline_level_styles.end(); ++it)
{
sInstrText += it->second + L";" + std::to_wstring(it->first) + L";";
}
sInstrText += L"\"";
}
if (!table_content_context_.caption_sequence_name.empty())
{
sInstrText += L" \\c \"" + table_content_context_.caption_sequence_name + L"\"";
}
}
start_field(sInstrText, L"");
finish_paragraph();
}
@ -417,16 +395,51 @@ void docx_conversion_context::end_index_content()
if (!in_table_content_) return;
start_paragraph(false);
output_stream() << L"<w:r>";
//output_stream() << L"<w:rPr>";
//output_stream() << L"<w:rFonts w:ascii="Minion Pro" w:hAnsi="Minion Pro"/>";
//output_stream() << L"<w:sz w:val="20"/>
//output_stream() << L"</w:rPr>";
output_stream() << L"<w:fldChar w:fldCharType=\"end\"/>";
output_stream() << L"</w:r>";
end_field();
finish_paragraph();
}
void docx_conversion_context::start_field(const std::wstring & sInstrText, const std::wstring & sName)
{
output_stream() << L"<w:r>";
output_stream() << L"<w:fldChar w:fldCharType=\"begin\">";
if (!sName.empty())
{
output_stream() << L"<w:ffData><w:name w:val=\"" << sName << L"\"/><w:enabled/><w:calcOnExit w:val=\"0\"/></w:ffData>";
}
output_stream() << L"</w:fldChar>";
output_stream() << L"</w:r>";
output_stream() << L"<w:r>";
output_stream() << L"<w:instrText xml:space=\"preserve\">" << XmlUtils::EncodeXmlString(sInstrText) << L" </w:instrText>";
output_stream() << L"</w:r>";
output_stream() << L"<w:r>";
output_stream() << L"<w:fldChar w:fldCharType=\"separate\"/>";
output_stream() << L"</w:r>";
if (!sName.empty())
{
start_bookmark(sName);
}
fields_names_stack_.push_back(sName);
}
void docx_conversion_context::end_field()
{
if (fields_names_stack_.empty()) return;
output_stream() << L"<w:r>";
output_stream() << L"<w:fldChar w:fldCharType=\"end\"/>";
output_stream() << L"</w:r>";
std::wstring sName = fields_names_stack_.back();
fields_names_stack_.pop_back();
if (!sName.empty())
{
end_bookmark(sName);
}
}
void docx_conversion_context::end_sdt()
{
if (!in_table_content_) return;
@ -466,7 +479,7 @@ void docx_conversion_context::start_bookmark (const std::wstring &name)
}
finish_run();
output_stream() << L"<w:bookmarkStart w:id=\"" << std::to_wstring(id) << L"\" w:name=\"" << name << L"\"/>";
output_stream() << L"<w:bookmarkStart w:id=\"" << std::to_wstring(id) << L"\" w:name=\"" << XmlUtils::EncodeXmlString(name) << L"\"/>";
}
void docx_conversion_context::end_bookmark (const std::wstring &name)
@ -564,10 +577,32 @@ oox_chart_context & docx_conversion_context::current_chart()
throw std::runtime_error("internal error");
}
}
void docx_conversion_context::reset_context_state()
{
keep_state_.push_back(state_);
state_.in_paragraph_ = false;
state_.in_run_ = false;
state_.is_paragraph_keep_ = false;
state_.drawing_text_props_.clear();
state_.text_properties_stack_.clear();
get_styles_context().text_style_ext().clear();
}
void docx_conversion_context::back_context_state()
{
state_ = keep_state_.back();
keep_state_.pop_back();
get_styles_context().text_style_ext().clear();
}
void docx_conversion_context::add_new_run(std::wstring parentStyleId)
{
finish_run();
if (get_comments_context().state()==1)
if (get_comments_context().state() == 1 ||
get_comments_context().state() == 4)//??? comment in run
{
output_stream() << L"<w:commentRangeStart w:id=\"" << get_comments_context().current_id() << L"\" />";
get_comments_context().state(2);//active
@ -647,7 +682,7 @@ void docx_conversion_context::end_document()
output_document_->get_word_files().set_document ( package::simple_element::create(L"document.xml", document_xml_.str()) );
output_document_->get_word_files().set_settings ( package::simple_element::create(L"settings.xml", dump_settings_document()));
output_document_->get_word_files().set_media ( mediaitems_, applicationFonts_);
output_document_->get_word_files().set_media ( mediaitems_);
output_document_->get_word_files().set_comments ( comments_context_);
output_document_->get_word_files().set_headers_footers( headers_footers_);
@ -867,22 +902,24 @@ xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"
mc:Ignorable=\"w14 wp14\">";
std::vector<int> numIds;
BOOST_FOREACH(odf_reader::list_style_instance_ptr & inst, list_styles.instances())
{
odf_reader::office_element_ptr_array & content = inst->get_text_list_style()->get_content();
odf_reader::list_style_container::instances_array & arListStyles = list_styles.instances();
for (size_t i = 0; i < arListStyles.size(); i++)
{
odf_reader::office_element_ptr_array & content = arListStyles[i]->get_text_list_style()->get_content();
if (content.size() < 1)
continue;
const int abstractNumId = list_styles.id_by_name(inst->get_style_name());
const int abstractNumId = list_styles.id_by_name(arListStyles[i]->get_style_name());
strm << L"<w:abstractNum w:abstractNumId=\"" << abstractNumId << "\">";
numIds.push_back(abstractNumId);
for (size_t i = 0; i < (std::min)( content.size(), (size_t)9); i++)
for (size_t j = 0; j < (std::min)( content.size(), (size_t)9); j++)
{
start_text_list_style(inst->get_text_list_style()->get_style_name());
content[i]->docx_convert(*this);
start_text_list_style(arListStyles[i]->get_text_list_style()->get_style_name());
content[j]->docx_convert(*this);
// TODO
end_text_list_style();
}
@ -913,21 +950,25 @@ void docx_conversion_context::process_fonts()
odf_reader::odf_read_context & context = doc->odf_context();
odf_reader::fonts_container & fonts = context.fontContainer();
BOOST_FOREACH(odf_reader::font_instance_ptr & inst, fonts.instances())
odf_reader::fonts_container::instances_array &arFonts = fonts.instances();
for (size_t i = 0; i < arFonts.size(); i++)
{
strm << L"<w:font w:name=\"" << inst->name() << L"\" >";
if (!arFonts[i]) continue;
if (arFonts[i]->name().empty()) continue;
if (!inst->charset().empty())
strm << L"<w:charset w:val=\"" << inst->charset() <<"\" />";
strm << L"<w:font w:name=\"" << arFonts[i]->name() << L"\" >";
if (!inst->family().empty())
strm << L"<w:family w:val=\"" << inst->family() << "\" />";
if (!arFonts[i]->charset().empty())
strm << L"<w:charset w:val=\"" << arFonts[i]->charset() <<"\" />";
if (!inst->pitch().empty())
strm << L"<w:pitch w:val=\"" << inst->pitch() << "\" />";
if (!arFonts[i]->family().empty())
strm << L"<w:family w:val=\"" << arFonts[i]->family() << "\" />";
if (!inst->alt_name().empty())
strm << L"<w:altName w:val=\"" << inst->alt_name() << "\" />";
if (!arFonts[i]->pitch().empty())
strm << L"<w:pitch w:val=\"" << arFonts[i]->pitch() << "\" />";
if (!arFonts[i]->alt_name().empty())
strm << L"<w:altName w:val=\"" << arFonts[i]->alt_name() << "\" />";
strm << L"</w:font>";
}
@ -958,9 +999,11 @@ void docx_conversion_context::process_styles()
odf_reader::styles_container & styles = context.styleContainer();
// add all styles to the map
BOOST_FOREACH(odf_reader::style_instance_ptr & inst, styles.instances())
odf_reader::styles_container::instances_array &arStyles = styles.instances();
for (size_t i = 0; i < arStyles.size(); i++)
{
styles_map_.get(inst->name(), inst->type());
if (!arStyles[i]) continue;
styles_map_.get(arStyles[i]->name(), arStyles[i]->type());
}
_Wostream << L"<w:docDefaults>";
@ -970,60 +1013,86 @@ void docx_conversion_context::process_styles()
_Wostream << L"<w:pPrDefault>";
if ( odf_reader::style_content * content = defaultParStyle->content())
{
if (content->get_style_paragraph_properties())
{
if(content->get_style_paragraph_properties()->content_.fo_background_color_)
{
odf_types::background_color color = *content->get_style_paragraph_properties()->content_.fo_background_color_;
if ((color.get_type() != odf_types::background_color::Transparent &&
color.get_color() == odf_types::color(L"ffffff")) ||
(color.get_type() == odf_types::background_color::Transparent))
{
content->get_style_paragraph_properties()->content_.fo_background_color_ = boost::none;
}
}
}
get_styles_context().start_process_style(defaultParStyle);
content->docx_convert(*this);
get_styles_context().end_process_style();
}
_Wostream << L"</w:pPrDefault>";
}
if (odf_reader::style_instance * defaultParStyle = styles.style_default_by_type(odf_types::style_family::Text))
{
_Wostream << L"<w:rPrDefault>";
if ( odf_reader::style_content * content = defaultParStyle->content())
{
get_styles_context().start_process_style(defaultParStyle);
content->docx_convert(*this);
get_styles_context().end_process_style();
}
_Wostream << L"</w:rPrDefault>";
}
_Wostream << L"</w:docDefaults>";
BOOST_FOREACH(odf_reader::style_instance_ptr & inst, styles.instances())
{
if (!inst->is_automatic() &&
for (size_t i = 0; i < arStyles.size(); i++)
{
if (!arStyles[i]->is_automatic() &&
(
inst->type() == odf_types::style_family::Paragraph ||
inst->type() == odf_types::style_family::Text
arStyles[i]->type() == odf_types::style_family::Paragraph ||
arStyles[i]->type() == odf_types::style_family::Text
))
{
const std::wstring id = styles_map_.get(inst->name(), inst->type());
_Wostream << L"<w:style w:styleId=\"" << id << L"\" w:type=\"" << StyleTypeOdf2Docx(inst->type()) << L"\"";
if (!inst->is_default())
const std::wstring id = styles_map_.get(arStyles[i]->name(), arStyles[i]->type());
_Wostream << L"<w:style w:styleId=\"" << id << L"\" w:type=\"" << StyleTypeOdf2Docx(arStyles[i]->type()) << L"\"";
if (!arStyles[i]->is_default())
{
_Wostream << L" w:customStyle=\"1\"";
}
_Wostream << L">";
const std::wstring displayName = StyleDisplayName(inst->name(), inst->type());
const std::wstring displayName = StyleDisplayName(arStyles[i]->name(), arStyles[i]->type());
_Wostream << L"<w:name w:val=\"" << displayName << L"\" />";
if (odf_reader::style_instance * baseOn = inst->parent())
if (odf_reader::style_instance * baseOn = arStyles[i]->parent())
{
const std::wstring basedOnId = styles_map_.get(baseOn->name(), baseOn->type());
_Wostream << L"<w:basedOn w:val=\"" << basedOnId << "\" />";
}
else if (!inst->is_default() && styles_map_.check(L"", inst->type()))
else if (!arStyles[i]->is_default() && styles_map_.check(L"", arStyles[i]->type()))
{
const std::wstring basedOnId = styles_map_.get(L"", inst->type());
const std::wstring basedOnId = styles_map_.get(L"", arStyles[i]->type());
_Wostream << L"<w:basedOn w:val=\"" << basedOnId << "\" />";
}
if (odf_reader::style_instance * next = inst->next())
if (odf_reader::style_instance * next = arStyles[i]->next())
{
const std::wstring nextId = styles_map_.get(next->name(), next->type());
_Wostream << L"<w:next w:val=\"" << nextId << "\" />";
}
else if (inst->is_default())
else if (arStyles[i]->is_default())
{
// self
_Wostream << L"<w:next w:val=\"" << id << "\" />";
}
if (odf_reader::style_content * content = inst->content())
if (odf_reader::style_content * content = arStyles[i]->content())
{
get_styles_context().start_process_style(inst.get());
get_tabs_context().clear();
calc_tab_stops(arStyles[i].get(), get_tabs_context());
get_styles_context().start_process_style(arStyles[i].get());
content->docx_convert(*this, true);
get_styles_context().end_process_style();
}
@ -1273,21 +1342,22 @@ bool docx_conversion_context::in_automatic_style()
void docx_conversion_context::push_text_properties(const odf_reader::style_text_properties * TextProperties)
{
text_properties_stack_.push_back(TextProperties);
state_.text_properties_stack_.push_back(TextProperties);
}
void docx_conversion_context::pop_text_properties()
{
text_properties_stack_.pop_back();
state_.text_properties_stack_.pop_back();
}
odf_reader::style_text_properties_ptr docx_conversion_context::current_text_properties()
{
odf_reader::style_text_properties_ptr cur = boost::make_shared<odf_reader::style_text_properties>();
BOOST_FOREACH(const odf_reader::style_text_properties * prop, text_properties_stack_)
for (size_t i = 0; i < state_.text_properties_stack_.size(); i++)
{
if (prop)
cur->content().apply_from( prop->content() );
if (state_.text_properties_stack_[i])
cur->content().apply_from( state_.text_properties_stack_[i]->content() );
}
return cur;
}
@ -1495,7 +1565,7 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_
start_automatic_style(id);
odf_reader::calc_tab_stops(styleInst, get_tabs_context());
calc_tab_stops(styleInst, get_tabs_context());
//вытаскивает rtl c цепочки стилей !! - просто прописать в наследуемом НЕЛЬЗЯ !!
odf_reader::paragraph_format_properties properties = odf_reader::calc_paragraph_properties_content(styleInst);
@ -1534,15 +1604,31 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_
output_stream() << L"</w:pPr>";
finish_paragraph();
start_paragraph();
start_paragraph();
if ((Attr->outline_level_) && (*Attr->outline_level_ > 0))
{
output_stream() << L"<w:pPr>";
output_stream() << L"<w:outlineLvl w:val=\"" << *Attr->outline_level_ - 1 << L"\"/>";
output_stream() << L"</w:pPr>";
}
}
else
{
output_stream() << get_section_context().dump_;
get_section_context().dump_.clear();
if ((Attr->outline_level_) && (*Attr->outline_level_ > 0))
{
output_stream() << L"<w:outlineLvl w:val=\"" << *Attr->outline_level_ - 1 << L"\"/>";
}
output_stream() << L"</w:pPr>";
}
}
else if ((Attr->outline_level_) && (*Attr->outline_level_ > 0))
{
output_stream() << L"<w:pPr>";
output_stream() << L"<w:outlineLvl w:val=\"" << *Attr->outline_level_ - 1 << L"\"/>";
output_stream() << L"</w:pPr>";
}
return 1;
}
}
@ -1671,6 +1757,11 @@ void docx_conversion_context::serialize_list_properties(std::wostream & strm)
}
}
void docx_conversion_context::set_drawing_text_props (const std::wstring &props)
{
get_styles_context().text_style_ext() = props;
}
void docx_conversion_context::add_delayed_element(odf_reader::office_element * Elm)
{
delayed_elements_.push_back(Elm);
@ -1704,10 +1795,7 @@ namespace
{
// обработка Header/Footer
// конвертируем содержимое header/footer и сохраняем результат в виде строки
void process_one_header_footer(docx_conversion_context & Context,
const std::wstring & styleName,
odf_reader::office_element * elm,
headers_footers::Type type)
void process_one_header_footer(docx_conversion_context & Context, const std::wstring & styleName, odf_reader::office_element *elm, headers_footers::Type type)
{
if (!elm) return;
@ -1725,13 +1813,7 @@ namespace
Context.dump_hyperlinks(internal_rels, hyperlinks::document_place);
Context.get_headers_footers().add(styleName, dbgStr, type, internal_rels);
if (type == headers_footers::headerLeft || type == headers_footers::footerLeft)
{
Context.set_settings_property(odf_reader::_property(L"evenAndOddHeaders",true));
}
}
}
}
void docx_conversion_context::set_settings_property(const odf_reader::_property & prop)
{
@ -1753,21 +1835,39 @@ void docx_conversion_context::process_headers_footers()
odf_reader::page_layout_container & pageLayouts = context.pageLayoutContainer();
// проходим по всем page layout
BOOST_FOREACH(const odf_reader::style_master_page* page, pageLayouts.master_pages())
{
const std::wstring & styleName = page->attlist_.style_name_.get_value_or( L"" );
const std::wstring masterPageNameLayout =context.pageLayoutContainer().page_layout_name_by_style(styleName);
add_page_properties(masterPageNameLayout);
process_one_header_footer(*this, styleName, page->style_header_.get(), headers_footers::header);
process_one_header_footer(*this, styleName, page->style_footer_.get(), headers_footers::footer );
process_one_header_footer(*this, styleName, page->style_header_first_.get(), headers_footers::headerFirst);
process_one_header_footer(*this, styleName, page->style_footer_first_.get(), headers_footers::footerFirst );
process_one_header_footer(*this, styleName, page->style_header_left_.get(), headers_footers::headerLeft );
process_one_header_footer(*this, styleName, page->style_footer_left_.get(), headers_footers::footerLeft );
std::vector<odf_reader::style_master_page*> & master_pages = pageLayouts.master_pages();
if (!page->style_header_ && !page->style_footer_ && !page->style_header_first_ && !page->style_footer_first_
&& !page->style_header_left_ && !page->style_footer_left_)
bool bOddEvenPages = false;
for (size_t i = 0; i < master_pages.size(); i++)
{
if (master_pages[i]->style_header_left_ || master_pages[i]->style_footer_left_)
bOddEvenPages = true;
}
if (bOddEvenPages)
{
set_settings_property(odf_reader::_property(L"evenAndOddHeaders", true));
}
for (size_t i = 0; i < master_pages.size(); i++)
{
const std::wstring & styleName = master_pages[i]->attlist_.style_name_.get_value_or( L"" );
const std::wstring masterPageNameLayout =context.pageLayoutContainer().page_layout_name_by_style(styleName);
add_page_properties(masterPageNameLayout);
process_one_header_footer(*this, styleName, master_pages[i]->style_header_.get(), headers_footers::header);
process_one_header_footer(*this, styleName, master_pages[i]->style_footer_.get(), headers_footers::footer );
process_one_header_footer(*this, styleName, master_pages[i]->style_header_first_.get(), headers_footers::headerFirst);
process_one_header_footer(*this, styleName, master_pages[i]->style_footer_first_.get(), headers_footers::footerFirst );
process_one_header_footer(*this, styleName, master_pages[i]->style_header_left_.get(), headers_footers::headerLeft );
process_one_header_footer(*this, styleName, master_pages[i]->style_footer_left_.get(), headers_footers::footerLeft );
if (bOddEvenPages && !master_pages[i]->style_header_left_)
process_one_header_footer(*this, styleName, master_pages[i]->style_header_.get(), headers_footers::headerLeft);
if (bOddEvenPages && !master_pages[i]->style_footer_left_)
process_one_header_footer(*this, styleName, master_pages[i]->style_footer_.get(), headers_footers::footerLeft );
if (!master_pages[i]->style_header_ && !master_pages[i]->style_footer_ && !master_pages[i]->style_header_first_ && !master_pages[i]->style_footer_first_
&& !master_pages[i]->style_header_left_ && !master_pages[i]->style_footer_left_)
{
//отключенные колонтитулы
rels rels_;
@ -1837,7 +1937,7 @@ void docx_conversion_context::start_text_changes (const std::wstring &id)
map_current_changes_.insert(std::pair<std::wstring, text_tracked_context::_state> (id, state_add));
if (in_paragraph_ && ( state_add.type == 1 || state_add.type == 2 ))
if (state_.in_paragraph_ && ( state_add.type == 1 || state_add.type == 2 ))
{
map_changes_iterator it = map_current_changes_.find(id);
text_tracked_context::_state &state = it->second;
@ -2009,7 +2109,7 @@ void docx_conversion_context::end_text_changes (const std::wstring &id)
if (state.active)
{
if (in_paragraph_)
if (state_.in_paragraph_)
finish_run();
if (state.type == 1) output_stream() << L"</w:ins>";
@ -2030,5 +2130,13 @@ std::wstring docx_conversion_context::get_user_field(const std::wstring & name)
return pFind != map_user_fields.end() ? pFind->second : L"";
}
void docx_conversion_context::add_jsaProject(const std::string &content)
{
if (content.empty()) return;
output_document_->get_word_files().add_jsaProject(content);
output_document_->get_content_types_file().add_or_find_default(L"bin");
}
}
}

View File

@ -47,8 +47,6 @@
#include "hyperlinks.h"
#include "mediaitems.h"
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace odf_types
@ -190,14 +188,14 @@ public:
}
void set_position_child_group(_INT32 x, _INT32 y)
{
if (groups_.size() < 1) return;
if (groups_.empty()) return;
if (groups_.back().x > x) groups_.back().x = x;
if (groups_.back().y > y) groups_.back().y = y;
}
void set_size_child_group(_INT32 cx, _INT32 cy)
{
if (groups_.size() < 1) return;
if (groups_.empty()) return;
if (groups_.back().cx < cx) groups_.back().cx = cx;
if (groups_.back().cy < cy) groups_.back().cy = cy;
@ -205,7 +203,7 @@ public:
void get_position_group(_INT32 & x, _INT32 & y)
{
x = y = 0;
if (groups_.size() < 1) return;
if (groups_.empty()) return;
x = groups_.back().x;
y = groups_.back().y;
@ -213,7 +211,7 @@ public:
void get_size_group(_INT32 & cx, _INT32 & cy)
{
cx = cy = 0;
if (groups_.size() < 1) return;
if (groups_.empty()) return;
cx = groups_.back().cx;
cy = groups_.back().cy;
@ -486,14 +484,14 @@ public:
std::wstring author;
std::wstring initials;
};
void start_comment(const std::wstring & content, const std::wstring & author, const std::wstring & date)
void start_comment(const std::wstring & content, const std::wstring & author, const std::wstring & date, bool inRun = false)
{
int id = comments_.size()+1;
_comment_desc new_comment={content,id,date,author};
int id = comments_.size() + 1;
_comment_desc new_comment={content, id, date, author};
comments_.push_back(new_comment);
state_ = 1;
state_ = inRun ? 4 : 1;
}
int current_id()
{
@ -572,47 +570,6 @@ private:
std::map<std::wstring, _state> mapChanges_;
};
class text_forms_context
{
public:
struct _state
{
std::wstring id;
std::wstring name;
int type = 0; //enum?
std::wstring label;
std::wstring uuid;
std::wstring value;
odf_reader::form_element* element = NULL;
void clear()
{
type = 0;
id.clear();
name.clear();
label.clear();
value.clear();
uuid.clear();
element = NULL;
}
};
text_forms_context(){}
void start_element (int type);
void set_id (const std::wstring& id);
void set_name (const std::wstring& name);
void set_label (const std::wstring& label);
void set_uuid (const std::wstring& uuid);
void set_value (const std::wstring& value);
void set_element(odf_reader::form_element *elm);
void end_element ();
_state& get_state_element (std::wstring id);
private:
_state current_state_;
std::map<std::wstring, _state> mapElements_;
};
class table_content_context
{
public:
@ -668,7 +625,7 @@ public:
{
current_state.content.push_back(type);
}
void set_outline_level(int level)
void add_outline_level_style(const std::wstring& style_name, int level)
{
if (min_outline_level == -1 || min_outline_level > level)
min_outline_level = level;
@ -676,21 +633,27 @@ public:
if (max_outline_level == -1 || max_outline_level < level)
max_outline_level = level;
if (!style_name.empty())
outline_level_styles.insert(std::make_pair(level, style_name));
current_state.outline_level = level;
}
void end_level()
{
current_template.insert(std::make_pair(current_state.name, current_state));
current_template.push_back(current_state);
map_current_template.insert(std::make_pair(current_state.name, current_state));
current_state.clear();
}
void set_current_level(const std::wstring &name)
{
std::map<std::wstring, _state>::iterator pFind = current_template.find(name);
if (pFind == current_template.end())
std::map<std::wstring, _state>::iterator pFind = map_current_template.find(name);
if (pFind == map_current_template.end())
{
current_content_template_.clear();
}
current_content_template_ = pFind->second.content;
else
current_content_template_ = pFind->second.content;
current_content_template_index_ = 0;
}
@ -722,10 +685,13 @@ public:
current_content_template_index_ = 0;
current_content_template_.clear();
current_template.clear();
map_current_template.clear();
current_state.clear();
caption_sequence_name.clear();
min_outline_level = -1;
max_outline_level = -1;
outline_level_styles.clear();
bSeparators = false;
}
void add_sequence(const std::wstring & name, int outline_level)
{
@ -749,12 +715,15 @@ public:
int type_table_content;
int min_outline_level;
int max_outline_level;
std::map<int, std::wstring> outline_level_styles;
bool bSeparators;
std::vector<_state> current_template;
private:
std::vector<int> current_content_template_;
int current_content_template_index_;
std::map<std::wstring, _state> current_template;
std::map<std::wstring, _state> map_current_template;
_state current_state;
//std::map<std::wstring, int> sequences;
std::vector<std::wstring> sequences;
@ -785,9 +754,7 @@ public:
void add_element_to_run (std::wstring parenStyleId = _T(""));
void finish_run ();
void add_new_run (std::wstring parentStyleId = _T(""));
bool get_run_state () { return in_run_; }
void set_run_state (bool Val) { in_run_ = Val; }
void add_new_run (std::wstring parentStyleId = _T(""));
void start_paragraph (bool is_header = false);
void finish_paragraph ();
@ -795,10 +762,18 @@ public:
bool is_alphabetical_index () { return false == mapAlphabeticals.empty();}
bool is_table_content () { return in_table_content_; }
bool is_paragraph_header () { return in_header_; }
bool get_paragraph_state () { return in_paragraph_; }
void set_paragraph_state (bool val) { in_paragraph_ = val; }
bool get_paragraph_keep () { return is_paragraph_keep_;}
void set_paragraph_keep (bool val) { is_paragraph_keep_ = val; }
void reset_context_state();
void back_context_state();
bool get_run_state () { return state_.in_run_; }
void set_run_state (bool Val) { state_.in_run_ = Val; }
bool get_paragraph_state () { return state_.in_paragraph_; }
void set_paragraph_state (bool val) { state_.in_paragraph_ = val; }
bool get_paragraph_keep () { return state_.is_paragraph_keep_;}
void set_paragraph_keep (bool val) { state_.is_paragraph_keep_ = val; }
bool get_delete_text_state () { return is_delete_text_; }
void set_delete_text_state (bool Val) { is_delete_text_ = Val; }
@ -819,19 +794,18 @@ public:
bool next_dump_page_properties_;
bool next_dump_section_;
odf_reader::odf_document * root()
odf_reader::odf_document *root()
{
return odf_document_;
}
void start_document ();
void end_document ();
void start_body ();
void end_body ();
void start_office_text ();
void end_office_text ();
void start_office_text ();
void end_office_text ();
void start_sdt (int type);
void end_sdt ();
@ -842,6 +816,9 @@ public:
void start_index_element();
void end_index_element();
void start_field(const std::wstring & sInstrText, const std::wstring & sName);
void end_field();
void process_styles ();
void process_fonts ();
@ -915,11 +892,13 @@ public:
section_context & get_section_context() { return section_context_; }
notes_context & get_notes_context() { return notes_context_; }
text_tracked_context& get_text_tracked_context(){ return text_tracked_context_; }
text_forms_context & get_forms_context() { return text_forms_context_; }
forms_context & get_forms_context() { return forms_context_; }
tabs_context & get_tabs_context() { return tabs_context_;}
table_content_context & get_table_content_context() { return table_content_context_;}
void set_drawing_text_props (const std::wstring &props);
void docx_convert_delayed ();
void add_delayed_element (odf_reader::office_element * Elm);
@ -960,20 +939,34 @@ public:
void add_alphabetical_index_text (odf_reader::office_element_ptr & elem);
void set_process_headers_footers(bool Val) { process_headers_footers_ = Val; }
headers_footers & get_headers_footers() { return headers_footers_; }
headers_footers & get_headers_footers() { return headers_footers_; }
header_footer_context & get_header_footer_context() { return header_footer_context_; }
drop_cap_context & get_drop_cap_context(){return drop_cap_context_;}
drop_cap_context & get_drop_cap_context() {return drop_cap_context_;}
styles_map styles_map_;
bool process_headers_footers_;
bool delayed_converting_;
bool convert_delayed_enabled_;
styles_map styles_map_;
bool process_headers_footers_;
bool delayed_converting_;
bool convert_delayed_enabled_;
void start_changes();
void end_changes();
void start_changes();
void end_changes();
void add_jsaProject(const std::string &content);
private:
struct _context_state
{
bool in_paragraph_ = false;
bool in_run_ = false;
bool is_paragraph_keep_ = false;
std::wstring drawing_text_props_;
std::vector< const odf_reader::style_text_properties*> text_properties_stack_;
}state_;
std::vector<_context_state> keep_state_;
std::wstringstream document_xml_;
std::wstringstream styles_xml_;
std::wstringstream fontTable_xml_;
@ -996,7 +989,7 @@ private:
header_footer_context header_footer_context_;
notes_context notes_context_;
text_tracked_context text_tracked_context_;
text_forms_context text_forms_context_;
forms_context forms_context_;
tabs_context tabs_context_;
table_content_context table_content_context_;
@ -1004,7 +997,6 @@ private:
package::docx_document * output_document_;
odf_reader::odf_document * odf_document_;
NSFonts::IApplicationFonts * applicationFonts_;
std::vector<odf_reader::_property> settings_properties_;
@ -1016,8 +1008,11 @@ private:
std::wstring automatic_parent_style_;
std::wstring current_master_page_name_;
std::wstring text_list_style_name_;
std::vector<std::wstring> list_style_stack_;
bool first_element_list_item_;
std::vector<std::wstring> fields_names_stack_;
bool first_element_list_item_;
bool page_break_after_;
bool page_break_before_;
@ -1026,12 +1021,10 @@ private:
bool in_automatic_style_;
bool in_drawing_content_;
bool in_table_content_;
bool in_paragraph_;
bool in_run_;
bool in_header_;
bool is_delete_text_;
bool is_rtl_; // right-to-left
bool is_paragraph_keep_;
std::wstring current_alphabetic_index_;
int current_margin_left_;
@ -1040,7 +1033,6 @@ private:
std::vector<odf_reader::office_element*> delayed_elements_;
std::vector< const odf_reader::style_text_properties*> text_properties_stack_;
std::map<std::wstring, text_tracked_context::_state> map_current_changes_;
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;// цепочки переименований нумераций

View File

@ -231,7 +231,7 @@ void docx_serialize_image_child(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"a:avLst");
}
oox_serialize_ln(CP_XML_STREAM(),val.additional);
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
}
}

View File

@ -124,6 +124,12 @@ void word_files::write(const std::wstring & RootPath)
charts_files_.set_main_document(get_main_document());
charts_files_.write(path);
}
if (jsaProject_)
{
rels_files_.add( relationship(L"jsaId", L"http://schemas.onlyoffice.com/jsaProject", L"jsaProject.bin" ) );
jsaProject_->write( path );
}
if (notes_)
{
@ -141,11 +147,11 @@ void word_files::update_rels(docx_conversion_context & Context)
Context.dump_notes (rels_files_.get_rel_file()->get_rels());
}
void word_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts)
void word_files::set_media(mediaitems & _Mediaitems)
{
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
}
if (_Mediaitems.count_object > 0)
{
@ -185,7 +191,10 @@ bool word_files::has_numbering()
{
return numbering_ ? true : false;
}
void word_files::add_jsaProject(const std::string &content)
{
jsaProject_ = package::simple_element::create(L"jsaProject.bin", content);
}
void word_files::set_headers_footers(headers_footers & HeadersFooters)
{
headers_footers_elements * elm = new headers_footers_elements(HeadersFooters);
@ -234,7 +243,7 @@ void customXml_files::write(const std::wstring & RootPath)
const std::wstring fileNameItem = std::wstring(L"item") + std::to_wstring(i+1) + L".xml";
const std::wstring fileNameProps = std::wstring(L"itemProps") + std::to_wstring(i+1) + L".xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/customXml/") + fileNameProps,
L"application/vnd.openxmlformats-officedocument.customXmlProperties+xml");
@ -271,7 +280,7 @@ void docx_charts_files::write(const std::wstring & RootPath)
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring(count) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/word/charts/") + fileName, kWSConType);
package::simple_element(fileName, charts_[i]->str()).write(path);

View File

@ -40,8 +40,6 @@
#include "docx_content_type.h"
#include "oox_package.h"
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace oox {
@ -139,12 +137,13 @@ public:
void set_numbering (element_ptr Element);
void set_settings (element_ptr Element);
bool has_numbering ();
void set_media (mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts);
void set_media (mediaitems & mediaitems_);
void set_headers_footers(headers_footers & HeadersFooters);
void set_notes (notes_context & notesContext);
void set_comments (comments_context & commentsContext);
void add_charts(chart_content_ptr chart);
void add_jsaProject(const std::string &content);
void add_rels(relationship const & r);
@ -163,6 +162,7 @@ private:
element_ptr notes_;
element_ptr settings_;
element_ptr comments_;
element_ptr jsaProject_;
};

View File

@ -94,8 +94,16 @@ std::wstring docx_table_state::current_row_style() const
double docx_table_state::get_current_cell_width()
{
if (current_table_column_ < columns_width_.size())
return columns_width_[current_table_column_];
if (current_table_column_ + columns_spanned_num_ < columns_width_.size())
{
//return columns_width_[current_table_column_];
double res = 0;
for (unsigned int i = 0; i < columns_spanned_num_ + 1; i++)
{
res += columns_width_[current_table_column_ + i];
}
return res;
}
else
return 0;
}

View File

@ -73,7 +73,8 @@ struct drawing_object_description
_oox_fill fill_;
bool in_group_;
bool lined_;
bool connector_;
int shape_type_; //default - frame
std::vector<drawing_object_description> child_objects_;

View File

@ -31,7 +31,6 @@
*/
#include "headers_footers.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
namespace cpdoccore {
@ -88,12 +87,12 @@ std::wstring get_rel_type(headers_footers::Type _Type)
void headers_footers::dump_rels(rels & Rels) const//внешние релсы
{
BOOST_FOREACH(const instances_map::value_type & instAr, instances_)
for (boost::unordered_map<std::wstring, instances_array>::const_iterator it = instances_.begin(); it != instances_.end(); ++it)
{
BOOST_FOREACH(const instance_ptr & inst, instAr.second)
for (size_t i = 0; i < it->second.size(); i++)
{
if (inst->type_ == none) continue;
Rels.add( relationship( inst->id_, get_rel_type(inst->type_), inst->name_, L"" ) );
if (it->second[i]->type_ == none) continue;
Rels.add( relationship( it->second[i]->id_, get_rel_type(it->second[i]->type_), it->second[i]->name_, L"" ) );
}
}
}
@ -107,9 +106,13 @@ bool headers_footers::write_sectPr(const std::wstring & StyleName, bool next_pag
bool first = false, left = false;
bool res = false;
instances_array & pFind = instances_.at(StyleName);
BOOST_FOREACH(const instance_ptr & inst, instances_.at(StyleName))
for (size_t i = 0; i < pFind.size(); i++)
{
instance_ptr & inst = pFind[i];
std::wstring type = L"default";
if ( inst->type_ == headerFirst || inst->type_ == footerFirst )

View File

@ -36,7 +36,7 @@
#include <float.h>
#include "../../DesktopEditor/graphics/pro/Fonts.h"
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace utils {

View File

@ -41,6 +41,7 @@
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/raster/ImageFileFormatChecker.h"
#include "../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace oox {
@ -74,7 +75,32 @@ mediaitems::item::item( std::wstring const & _href,
count_add = 1;
count_used = 0;
}
mediaitems::mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
{
count_charts = 0;
count_shape = 0;
count_image = 0;
count_tables = 0;
count_media = 0;
count_object = 0;
count_audio = 0;
count_video = 0;
count_slide = 0;
count_activeX = 0;
count_control = 0;
applicationFonts_ = NSFonts::NSApplication::Create();
}
mediaitems::~mediaitems()
{
if (applicationFonts_)
delete applicationFonts_;
}
void mediaitems::set_font_directory(std::wstring pathFonts)
{
if (applicationFonts_)
applicationFonts_->InitializeFromFolder(pathFonts);
}
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal)
{
std::wstring ref;
@ -101,6 +127,10 @@ std::wstring static get_default_file_name(RelsType type)
return L"video";
case typeAudio:
return L"audio";
case typeControl:
return L"control";
case typeControlProps:
return L"controlProps";
default:
return L"";
}
@ -122,8 +152,8 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
if (sExt.empty())
{
int n = uri.find(L"ObjectReplacements");
if (n >= 0)
size_t n = uri.find(L"ObjectReplacements");
if (n != std::wstring::npos)
{
if (!isInternal) return L"";
@ -134,9 +164,9 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
if (sExt.empty())
{
//то что есть ..
int n = uri.rfind(L".");
if (n > 0)
sExt = uri.substr(n);
size_t n = uri.rfind(L".");
if (n != std::wstring::npos)
sExt = XmlUtils::GetLower(uri.substr(n));
}
}
@ -163,7 +193,7 @@ std::wstring mediaitems::detectImageFileExtension(const std::wstring &fileName)
if (!sExt.empty()) sExt = std::wstring(L".") + sExt;
}
return sExt;
return XmlUtils::GetLower(sExt);
}
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref)
@ -180,6 +210,10 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
{
sub_path = L"embeddings/";
}
else if ( type == typeControlProps)
{
sub_path = L"ctrlProps/";
}
else
{
isMediaInternal = is_internal(href, odf_packet_);
@ -198,6 +232,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
else if ( type == typeSlide) number = count_slide + 1;
else if ( type == typeMsObject ||
type == typeOleObject) number = count_object + 1;
else if ( type == typeControl) number = count_control + 1;
else
number = items_.size() + 1;
@ -233,8 +268,8 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
}
else if ( type == typeImage)
{
int n_svm = outputPath.rfind (L".svm");
if ( n_svm >= 0 )
size_t n_svm = outputPath.rfind (L".svm");
if ( n_svm != std::wstring::npos )
{
outputPath = outputPath.substr(0, n_svm) + L".png";
}
@ -277,7 +312,19 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
isInternal = isMediaInternal;
return id;
}
std::wstring mediaitems::add_control_props(std::wstring & oox_target)
{
const bool isMediaInternal = true;
count_control++;
std::wstring rId = std::wstring(L"ctrlId") + std::to_wstring(count_control);
oox_target = std::wstring(L"ctrlProp") + std::to_wstring(count_control) + L".xml";
items_.push_back( item(L"", typeControlProps, oox_target, isMediaInternal, rId) );
return rId;
}
void mediaitems::dump_rels(rels & Rels)
{
for (size_t i = 0; i < items_.size(); i++)

View File

@ -33,7 +33,12 @@
#include "oox_rels.h"
#include "../../../../Common/DocxFormat/Source/XML/Utils.h"
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
namespace NSFonts
{
class IApplicationFonts;
}
namespace cpdoccore {
namespace oox {
@ -41,18 +46,8 @@ namespace oox {
class mediaitems
{
public:
mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
{
count_charts = 0;
count_shape = 0;
count_image = 0;
count_tables = 0;
count_media = 0;
count_object = 0;
count_audio = 0;
count_video = 0;
count_slide = 0;
}
mediaitems(const std::wstring & odfPacket);
virtual ~mediaitems();
struct item
{
@ -82,10 +77,17 @@ public:
size_t count_shape;
size_t count_tables;
size_t count_object;
size_t count_activeX;
size_t count_control;
void set_font_directory(std::wstring pathFonts);
NSFonts::IApplicationFonts *applicationFonts() {return applicationFonts_;}
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal);//возможны ссылки на один и тот же объект
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref);
std::wstring add_control_props (std::wstring & oox_target);
void dump_rels(rels & Rels);
items_array & items() { return items_; }
@ -102,15 +104,18 @@ public:
case typeAudio: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio";
case typeVideo: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video";
case typeSlide: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
case typeExternalLink: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath";
case typeActiveX: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/control";
case typeControlProps: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp";
default:
return L"";
}
}
static RelsType detectMediaType(const std::wstring & fileName)
{
int pos = fileName.rfind(L".");
size_t pos = fileName.rfind(L".");
std::wstring sExt = (pos >=0 ? fileName.substr(pos + 1) : L"");
std::wstring sExt = (pos != std::wstring::npos ? fileName.substr(pos + 1) : L"");
if (sExt.empty()) return typeMedia;
@ -138,6 +143,7 @@ private:
items_array items_;
std::wstring odf_packet_;
NSFonts::IApplicationFonts *applicationFonts_;
};
}

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